各位哥哥帮忙看一下我的程序!
一个重写键盘中断的程序,下面是简单结构,重新定义F10键,按下F10后显示
一句话,要求驻留内存中。写中断时没什么问题,但在驻留内存时始终有问题,
麻烦各位大虾帮忙看看我的程序,谢谢。小弟初学汇编,各位哥哥不要见笑。
data segment
assume cs:data
mes1 db 'Press F1--F9 to show message',0dh,0ah,'$'
mes2 db 'Press F10 to quit!',0dh,0ah,'$'
mes3 db 'Please input your choise from F1--F10:',0dh,0ah,'$'
mes4 db '***I love you!Do you love me too?',0dh,0ah,'$'
mes5 db 'Restain the program!',0dh,0ah,'$'
mes6 db 'System Restore!',0dh,0ah,'$'
old09ip dw ?
old09cs dw ?
Oldint9 dd ?
intsb proc near
sti
cld
in al,60h
mov bl,al
cmp bl,44h
jne aa
call F10sb
aa:call F19sb
intsb endp
F19sb proc near
sti
mov ah,9
mov dx,offset mes4
int 21h
call cs:Oldint9 想利用原来的中断响应代码,但好象没什么用?
iret
F19sb endp
F10sb proc near
cli
push ds ;restore old int 09
mov dx,old09ip
mov ax,old09cs
mov ds,ax
mov al,09h
mov ah,25h
int 21h
pop ds
sti
mov ah,9
mov dx,offset mes6
int 21h
mov ah,4ch ;return to DOS
int 21h
iret
F10sb endp
data ends
endresident segment
endresident ends
code segment
main proc far
assume cs:code,ds:data
PSP dw ?
start:
mov cs:PSP,ds
mov ax,data
mov ds,ax
;save old int
mov ds,ax
mov ax,0
mov es,ax
cli
mov ax,es:[9h*4]
mov word ptr Oldint9,ax
mov ax,es:[9h*4+2]
mov word ptr Oldint9+2,ax
mov al,09h
mov ah,35h
int 21h
mov old09ip,bx
mov old09cs,es
push ds ;save ds
;set new int vector
lea dx,intsb
mov ax,seg intsb
mov ds,ax
mov al,09h
mov ah,25h
int 21h
pop ds ;restore ds
;set mask bits
in al,21h
and al,0fdh
out 21h,al
sti
mov ah,9
mov dx,offset mes1
int 21h
mov ah,9
mov dx,offset mes2
int 21h
mov ah,9
mov dx,offset mes3
int 21h
mov di,20000
a: mov si,30000
b: dec si
jnz b
dec di
jnz a
mov dx,endresident
sub dx,cs:PSP
mov cl,4
shr dx,cl /这里不知道对不对,因为程序运行时
mov ax,3100h 中断是可响应的,但程序结束后按键却出来
int 21h 一堆乱码。
code ends
end main