-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr20-4.asm
129 lines (97 loc) · 1.65 KB
/
r20-4.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
assume cs:code,ss:stack,ds:data
data segment
db 128 dup(0)
data ends
stack segment stack
db 128 dup(0)
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,128
call cpy_new_int9
call sav_old_int9
call set_new_int9
mov ax,4c00h
int 21h
;==================================
set_new_int9:
push bx
push es
mov bx,0
mov es,bx
cli
mov word ptr es:[9*4],7e00h
mov word ptr es:[9*4+2],0
sti
pop es
pop bx
ret
;=================================
sav_old_int9:
mov bx,0
mov es,bx
cli
push es:[9*4]
pop es:[200h] ;int 9 ip
push es:[9*4+2]
pop es:[202h] ;int 9 cs
sti
ret
;=================================
new_int9:
push ax
in al,60h
pushf
call dword ptr cs:[200h] ;cs = 0
cmp al,48h
je isUp
cmp al,39h
jne int9Ret
call screen_color_change
int9Ret:
pop ax
iret
new_int9_end: nop
;=================================
isUp: mov bx,0b800h
mov es,bx
mov di,160*10+40*2
mov byte ptr es:[di],'U'
jmp int9Ret
;=================================
screen_color_change:
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,2000
changeColor: inc byte ptr es:[bx]
add bx,2
loop changeColor
pop es
pop cx
pop bx
ret
;=================================
init_reg:
mov bx,0b800h
mov es,bx
ret
;==================================
cpy_new_int9:
mov bx,cs
mov ds,bx
mov si,offset new_int9
mov bx,0
mov es,bx
mov di,7e00h
mov cx,offset new_int9_end - offset new_int9
cld
rep movsb
ret
code ends
end start