-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShadow.asm
258 lines (230 loc) · 4.67 KB
/
Shadow.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
.model small
.586
public display_Shandow
extrn assc:far,clear_screen:far,display_eax:far,first_screen:far
.data
es_seg dw 0c000H
bx_seg dd 0H
not_find db 'not find string ','$'
address db 'find string [_SM_], and have use string [_MS_] replace it',0dh,0ah,' address is:','$'
mesg_recover db 'you can chose 1 to recover String [_SM_]','$'
fuhao db ':','$'
help_text_shadow DB 'QUIT: Q','$'
si_string db '_SM_','$'
di_string db '_MS_','$'
.code
.startup
display_Shandow:
init:
include MACRO_zifu.MAC
call clear_screen
PUSHA
mov bh,0
mov dh,23 ;放入行号
mov dl,3 ;放入列号
mov ah,02h
int 10h
POPA
msg help_text_shadow
MOV AX,es_seg
mov es,AX
mov bx,word ptr bx_seg
mov si,0
mov di,0
;mov cx,256
mov cx,3
add_es:
mov ax,es
add ax,1000h
mov es,ax
cheak_sm:
push cx
mov cx,65536
cheak_S:
mov al,es:[bx+si]
cmp al,si_string[di]
JZ cheak_2
jmp next_char
;-----------------------
cheak_2:
; mov
inc si
inc di
mov al,es:[bx+si]
cmp al,si_string[di]
jz cheak_3
;JZ display_address
dec si
dec di
jmp next_char
cheak_3:
inc si
inc di
mov al,es:[bx+si]
cmp al,si_string[di]
jz cheak_4
dec si
;dec si
dec di
dec di
jmp next_char
cheak_4:
inc si
inc di
mov al,es:[bx+si]
cmp al,si_string[di]
jz display_address
dec si
dec di
dec di
dec di
; cheak_M
next_char:
INC SI
loop cheak_S
pop cx
loop add_es
PUSHA
mov bh,0
mov dh,3 ;放入行号
mov dl,3 ;放入列号
mov ah,02h
int 10h
POPA
msg not_find
jmp stop
display_address:
dec si
PUSHA
mov bh,0
mov dh,3 ;放入行号
mov dl,3 ;放入列号
mov ah,02h
int 10h
POPA
msg address
pusha
mov ax,si
add bx,ax
mov bx_seg,ebx
popa
xor eax,eax
mov eax,es
shl eax,16
add eax, bx_seg
sub eax,2
call display_eax_s
call write_enable
mov bx,word ptr bx_seg
sub bx,2
mov si,0
mov di,0
mov cx,4
write_again:
mov al,di_string[di]
mov es:[bx+si],al
inc si
inc di
loop write_again
stop:
NO_INPUT_SHADOW:
mov ah,11H
int 16H ;检测按键是有否按下,有则判断按键是否是ESC,否则继续刷新
jz NO_INPUT_SHADOW
mov ah,0
int 16h
cmp al,'q' ;若为Q\q 键则退出
jz first_screen
cmp al,'Q' ;若为Q\q 键则退出
jz first_screen
jmp NO_INPUT_SHADOW
.exit
write_enable proc
pusha
xor eax,eax
mov al,90h
or eax,80000000h
mov dx,0cf8h
out dx,eax
mov eax,33333333h
mov dx,0cfch
out dx,eax
xor eax,eax
mov al,94h
or eax,80000000h
mov dx,0cf8h
out dx,eax
mov eax,33333333h
mov dx,0cfch
out dx,eax
popa
ret
write_enable endp
display_eax_s proc far
pusha
mov cx,4
;and eax,eax
display_al:
rol eax,8
call assc
cmp cx,3
jnz continue_al
msg fuhao
continue_al:
loop display_al
popa
ret
display_eax_s endp
; assc proc far ;hex to asscii from al
; PUSHA
; ; cmp al,0ffh
; ; jz
; mov bl,al ;reserve al_high
; shr al,4
; add al,30h ;将高四位转换成对应的十六进制数字
; cmp al,'9' ;判断位数是否大于 9 大于则对其ASCII码值加7转换成16进制
; jLE next11
; add al,7
; next11:
; mov dl,al
; mov ah,2 ;调用DOS功能显示高四位对应的数字
; int 21h
; and bl,0fh
; mov dl,bl
; add dl,30h
; cmp Dl,'9' ;调用DOS功能显示低四位对应的数字
; jLE next22
; add Dl,7
; next22:
; mov ah,2
; int 21h
; popa
; ret
; assc endp
; clear_screen proc far
; ; protec registers
; push ax
; push bx
; push cx
; push dx
; ;clear_screen
; mov ah,6
; mov al,0
; mov bh,27h
; mov ch,0
; mov cl,0
; mov dh,24
; mov dl,79
; int 10h
; ;locate_cussor
; mov dx,0
; mov ah,2
; int 10h
; ;restore registers
; pop dx
; pop cx
; pop bx
; pop ax
; ret
; clear_screen endp
end