安装新的int 9中断例程2

    安装一个新的 int 9 中断例程,功能:在 DOS 下,按下 "A" 键后,除非不再松开,如果松开,就显示满屏幕的 "A";其他的键照常处理。
        提示:按下一个键时产生的扫描码称为通码,松开一个键产生的扫描码称为断码。断码=通码+80h。
A 的通码:1Eh        断码:9Eh
assume cs:code
stack segment
        db 128 dup (0)
stack ends
code segment
start:        mov ax , stack
        mov ss , ax
        mov sp , 128

        push cs
        pop ds
        mov ax , 0
        mov es , ax
        mov si , offset int9
        mov di , 204h
        mov cx , offset int9end - offset int9
        cld
        rep movsb

        push es:[4*9]        ; 保存原int 9中断例程入口地址
        pop es:[200h]
        push es:[4*9+2]
        pop es:[202h]

        cli
        mov word ptr es:[4*9] , 204h        ; 设置新的int 9中断入口地址
        mov word ptr es:[4*9+2] , 0h
        sti

        mov ax , 4c00h
        int 21h
int9:        push ax
        push bx
        push cx
        push es

        in al , 60h

        pushf
        call dword ptr cs:[200h]

        cmp al , 9eh        ; 'A' 的断码
        jne int9ret

        mov ax , 0b800h
        mov es , ax
        mov bx , 0
        mov cx , 2000        ; 25*80=2000 一页可以存2000个字符,每个字符要存一个字符属性,25*160=4000
s:        mov byte ptr es:[bx] , 'A'
        mov byte ptr es:[bx+1] , 00000100b
        add bx , 2
        loop s

int9ret:        pop es
        pop cx
        pop bx
        pop ax
        iret
int9end:        nop

code ends
end start
 // 按其他键没事,按下 'A' 键松开后全屏幕变红色 'A' ;  


原文地址:https://www.cnblogs.com/meihao1203/p/8023365.html