代码中要处理A的弹起和ESC的按下两种按键。虽然已通过,不知道有没有更好的写法
assume cs:code
stack segment
dw 128 dup(0)
stack ends
code segment
start:mov ax,stack
mov ss,ax
mov sp,128
mov ax,cs
mov ds,ax
mov si,offset int9h
mov ax,0
mov es,ax
mov di,204h
mov cx,offset int9hend-offset int9h
cld
rep movsb
push es:[9*4]
pop es:[200h]
push es:[9*4+2]
pop es:[200h+2]
cli
mov word ptr es:[9*4],200h
mov word ptr es:[9*4+2],0h
sti
mov ax,0b800h
mov es,ax
mov di,[160*12]
mov ah,'a'
s: mov es:[di],ah
call delay
cmp ah,'z'
inc ah
jna s
mov ax,0
mov es,ax
push es:[200h]
pop es:[9*4]
push es:[202h]
pop es:[9*4+2]
mov ax,4c00h
int 21h
delay: push ax
push dx
mov dx,1000h
mov ax,0h
s2: sub ax,1
sbb dx,0
cmp ax,0
jne s2
cmp dx,0
jne s2
pop dx
pop ax
ret
int9h: push ax
push bx
push cx
push es
in al,60h
pushf
push es
mov bx,0
mov es,bx
call dword ptr es:[200h]
pop es
cmp al,09Eh
jne colo
mov ax,0b800h
mov es,ax
mov bx,0
mov cx,2000
mov al,'A'
disA: mov es:[bx],al
inc bx
inc bx
loop disA
jmp short int9ret
colo: cmp al,01h
jne int9ret
mov ax,0b800h
mov es,ax
inc byte ptr es:[12*160+1]
jmp short int9ret
int9ret:pop es
pop cx
pop bx
pop ax
iret
int9hend:nop
code ends
end start |