相关链接:INT21H的0Ah号功能实现原理
http://topic.csdn.net/u/20100711/11/9326a3e5-000e-4db8-a05b-8c71e46c0d6a.html
;int21h的0ah号功能实现原理
assume cs:code,ds:data
data segment
string db 0dh,0ah,'Press any kry to exit...$'
buffer db 5,0,5 dup (0)
data ends
code segment
start: mov ax,data
mov ds,ax
mov dx,offset buffer
mov ah,0ah
;以下部分实现int21h的0ah号功能
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
push si
push bx
push ax
mov si,dx
mov bx,[si] ;0,0ffh
dec bx
add si,2
getkey:
mov ah,0
int 16h ;读键盘
cmp al,08 ;Backspace //行内编辑功能功能1
jz @del
cmp al,0 ;!!!!!!!! //过滤部分输入
jnz cheshi
cmp ah,4bh ;方向键"<-" //行内编辑功能功能2
jnz skip
@del: or bh,bh ;cmp bh,0
jz skip
mov ax,0e08h
int 10h
mov al,20h
int 10h
mov al,08h
int 10h
dec si
dec bh
skip:jmp getkey
cheshi:
cmp bh,bl
jb yes
cmp al,0dh
jz yes
mov ax,0e07h ;超出缓冲区警告
int 10h
jmp getkey
yes: mov [si],al ;存入缓冲区
inc si
cmp al,0dh ;回车结束输入
jz quit
mov ah,0eh
int 10h ;在当前光标处显示
inc bh ;Byte计数,最多为255个
jmp getkey
quit: mov si,dx
mov [si+1],bh
pop ax
pop bx
pop si
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
mov dx,offset string
mov ah,9
int 21h
mov ah,0
int 16h
mov ax,4c00h
int 21h
code ends
end start