section code align=16 vstart=7c00h
mov ax,cs
mov ss,ax
mov sp,stack_end
start mov ah,0
int 16h;用16号中断读取键盘的输入
mov cl,al
mov ch,ah;用ch存储键盘的通码
call put_string
jmp start
put_string push ax
push bx
;push cx
push dx
push es
push ds
push bp
mov dx,3d4h
mov al,0eh
out dx,al
mov dx,3d5h
in al,dx
mov ah,al;读取光标位置的高8位
mov dx,3d4h
mov al,0fh
out dx,al
mov dx,3d5h
in al,dx;读取光标位置的低8位
mov bx,ax;用bx保存光标位置
mov ax,0b800h
mov es,ax
cmp cl,0dh;判断是否是回车键
je cr_lf
cmp cl,08h;判断是否是backspace键
je backspace
cmp cl,7fh;判断是否是delete键
je next
cmp ch,48h;向上方向键的通码
je lastrow
cmp ch,50h;向下方向键的通码
je nextrow
cmp ch,4bh;向左方向键的通码
je lastone
cmp ch,4dh;向右方向键的通码
je nextone
jmp show_str
show_str shl bx,1
mov [es:bx],cl
mov byte [es:bx+1],07h
shr bx,1
add bx,1
jmp near scroll
nextone add bx,1
jmp near set_cursor
lastone sub bx,1
jmp near set_cursor
nextrow add bx,80
jmp near scroll
lastrow sub bx,80
jmp near set_cursor
next add bx,1
shl bx,1
mov cl,[es:bx]
cmp cl,20h
jne del
shr bx,1
sub bx,1
jmp near set_cursor
del mov word [es:bx],0720h
shr bx,1
jmp near set_cursor
backspace sub bx,1
shl bx,1
mov word [es:bx],0720h
shr bx,1
jmp near set_cursor
cr_lf mov ax,bx
mov bl,80
div bl
mul bl
mov bx,ax
add bx,80
jmp scroll
scroll cmp bx,2000;判断光标是否超过了文字模式下第一页的范围是则向上滚屏一行
jb set_cursor
mov ax,0b800h
mov ds,ax
mov es,ax
mov di,0
mov si,0a0h
mov cx,24*80
rep movsw
mov bp,24*160
mov cx,80
clear mov word [bp],0720h;清除最后一行
loop clear
详细解决方案
初学者各位大神啊一个用光标跟踪字符输入的程序不知道出什么有关问题了
热度:231 发布时间:2016-05-02 04:37:27.0
相关解决方案