汇编程序52:实验15 安装新的int9中断例程

 1 assume cs:code
 2 ;重写int9中断例程,当按住a后松开,便会产生满屏A
 3 stack segment
 4     dw 64 dup(0)
 5 stack ends
 6 
 7 code segment
 8     start:
 9           mov ax,stack
10           mov ss,ax
11           mov sp,80h
12 
13           mov ax,0
14           mov es,ax
15           
16           push cs
17           pop ds ;设置当前段地址
18 
19           mov si,offset int9;设置当前偏移地址
20           mov di,204h ;设置目的偏移地址
21           mov cx,offset int9end - int9 ;复制的执行代码长度
22           cld
23           rep movsb
24 
25           push es:[9*4]
26           pop es:[200h]
27           push es:[9*4+2]
28           pop es:[202h] ;把原int9入口地址储存到0020:0到0020:4处
29 
30           cli
31           mov word ptr es:[9*4],204h
32           mov word ptr es:[9*4+2],0 ;把信int9入口地址复制到中断向量表
33           sti
34 
35           mov ax,4c00h
36           int 21h
37      int9:
38           push ax
39           push bx
40           push cx
41           push es
42 
43           in al,60h
44 
45           pushf
46           call dword ptr cs:[200h]
47  
48           cmp al,1Eh
49           jne int9ret
50        s0: ;在按到a的可能上,确定放开才执行后面打印程序
51           in al,60h
52           cmp al,9Eh
53           jne s0  ;确定断开,才打印屏幕A
54           mov ax,0b800h
55           mov es,ax
56           mov bx,0
57           mov cx,2000
58         s:
59           mov byte ptr es:[bx],'A'
60           add bx,2
61           loop s
62   int9ret:
63           pop es
64           pop cx
65           pop bx
66           pop ax
67           iret
68   int9end:
69           nop
70 code ends
71 
72 end start

 

posted on 2018-02-05 10:28  叶倾仙  阅读(529)  评论(0编辑  收藏  举报

导航