安装新的int 9 中断例程
要求:
安装一个新的int 9中断例程,功能:在DOS下,按下“A”键后,除非不松开,如果松开,就显示满屏幕的“A”,其他的键照常处理。
个人分析:
个人认为这个中断例程本质是判断原int 9处理后的扫描码是不是A的断码,如果是就显示满屏幕的“A”,如果不是照常处理,只不过有一个在意的地方:就是当A按下的时候是什么都不输出还是照常处理。由于语文水平的限制,这里不太肯定,我是照常处理的。请大牛如果发现错误留言,谢谢。
其他注意细节已经在检测点已经告知,这个不多废话。
汇编代码:
assume cs:code
code segment
start:
sli ;防止在设置中断向量表之前出现有键盘输入导致错误
mov ax, cs
mov ds, ax
mov si, offset int9
mov ax, 0
mov es, ax
mov di, 204h ;[200]与[202]要存放原int 9的IP和CS
mov cx, offset int9_end - offset int9
cld ;正向复制
rep movsb
mov ax, es:[9*4]
mov es:[200h], ax
mov ax, es:[9*4+2]
mov es:[202h], ax ;保存原int 9中断例程入口地址
mov word ptr es:[9*4], 204h
mov word ptr es:[9*4+2], 0 ;设置中断向量表
sti ;IF设置1
mov ax, 4c00h
int 21h
----------------------int9-------------------------
int9:
push ds
push ax
push cx
push si
in al, 60h ;接受60h来的扫描码
pushf
call dword ptr cs:[200h]
cmp al, 1eh+80h ;A是否被松开
jne int9_ok ;不是松开正常处理
mov ax, 0b800h
mov ds, ax
mov si, 0
mov cx, 2000 ;打满一屏是2000个字符
print_char:
mov byte ptr [si], 'A'
add si, 2
loop print_char
int9_ok:
pop si
pop cx
pop ax
pop ds
iret
int9_end:
nop
code ends
end start
运行结果:
其他字符照常处理:
松开A后的结果,按下A没法截图: