;安装一个新的int9中断例程
;在DOS下,按下"A"后,除非不再松开,如果松开,就显示满屏幕的"A",其他键照常处理
assume cs:code,ss:stack
stack segment
db 128 dup (0)
stack ends
code segment
start: mov ax,stack
mov ss,ax
mov sp,128
mov ax,0
mov es,ax
push es:[9*4] ;ip
push es:[9*4+2] ;cs
pop es:[202h]
pop es:[200h]
call installint9 ;安装int9中断例程
cli ;防止在设置段地址和偏移地址之间发生中断
mov ax,0
mov es,ax
mov word ptr es:[9*4],204h
mov word ptr es:[9*4+2],0
sti
mov ax,4c00h
int 21h
installint9:push cx
push si
push di
push ds
push es
mov ax,0
mov ds,ax
mov si,offset int9
mov ax,0
mov es,ax
mov di,204h
mov cx,offset int9end - offset int9
cld
rep movsb
pop es
pop ds
pop di
pop si
pop cx
ret
int9: push ax
push cx
push di
push es
pushf ;本中断例程需要原例程的入口地址保存在0:200处 ip:cs
call dword ptr cs:[200h] ;...不是[200h]
in al,60h
cmp al,1eh+80h
jne int9_ok
mov ax,0b800h
mov es,ax
mov di,0
mov cx,2000
int9_s: inc byte ptr es:[di]
add di,2
loop int9_s
int9_ok:pop es
pop di
pop cx
pop ax
iret
int9end: nop
code ends
end start
自己写的东西,这段代码我看了多次,也和其他同样功能的代码进行了对比,没有发现问题,但是运行时却不能输入任何字符,求大神帮助
------解决思路----------------------
installint9:push cx
push si
push di
push ds
push es
mov ax,0 ; 这里应该是 mov ax, cs 吧
mov ds,ax
mov si,offset int9