1.安装一个新的int9中断例程
2.在DOS下,按f1改变屏幕颜色,其它键不变
assume cs:code,ss:stk
stk segment
db 128 dup (0)
stk ends
code segment
start:
mov ax,stk
mov ss,ax
mov sp,128
mov ax,0
mov es,ax
push cs
pop ds
;将原中断保存至0:200h
push es:[4*9]
pop es:[200h]
push es:[4*9+2]
pop es:[202h]
;安装新程序
mov si,offset int9
mov di,204h
mov cx,offset int9end - offset int9
cld
rep movsb
;改变后中断的入口地址
cli
mov word ptr es:[9*4],204h
mov word ptr es:[9*4+2],0
sti
mov ax,4c00h
int 21h
;自定义int9中断
int9:
push ax
push bx
push cx
push es
in al,60h
pushf
call dword ptr cs:[200];此时cs为0
;处理f1
cmp al,3bh ;f1扫描码为3bh
jne int9ret
mov ax,0b800h
mov es,ax
mov bx,1
mov cx,2000
s:inc byte ptr es:[bx]
add bx,2
loop s
int9ret:
pop es
pop cx
pop bx
pop ax
iret
int9end:nop
code ends
end start