-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.asm
176 lines (146 loc) · 3.06 KB
/
test.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
data segment
file db 'oh\0001.txt',0;文件名
buf db 2000 dup(?);缓存区
fh dw ?
error_msg db 0dh,0ah,'error!','$'
success_msg db 0dh,0ah,'done!','$'
data ends
stack segment stack
dw 20h dup(?)
top label word;堆栈
stack ends
code segment
assume ds:data,cs:code,ss:stack
main proc far;主过程
start:
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
lea sp,top
;mov dl,file[3] ;字符存入寄存器
;mov ah,02h ;调用2号功能输出单个字符
;int 21h ;int 21h调用功能
;mov file[3], 32H
mov bx, 1;bx, bp, si, di四位数,一共7777
mov bp, 1
mov si, 1
mov di, 1
mov al, 0;ascii
;把屏幕搞干净clear
mov ah, 0fh
int 10h
mov ah, 0
int 10h
;clear准备,这仨参数不会变,直接覆盖清屏
mov bh, 0
mov dh, 0
mov dl, 0
L1:;主体就是这个四层循环,分别对应四位数bx, bp, si, di四位数,一共7777
mov ax, di;di->ah, ascii
add al, 30H;ascii number
mov byte ptr file[6], al;写入文件名,通过改变文件名来达到模拟动画逐帧播放效果
;mov dl,al;字符存入寄存器
;mov ah,02h;调用2号功能输出单个字符
;int 21h;int 21h调用功能
;invoke Sleep,1000让他停一会
mov cx, 65535
subLoop:
dec cx
jnz subLoop
call near ptr print;显示
;clear
mov dl, 0
mov ah, 02h
int 10h
;mov al, 0
;mov ah, 06h
;int 10h
add di, 1;每次加5
cmp di, 0ah;进位
jb L1;cf of?
L2:
mov di, 0
mov ax, si
add al, 30H
mov byte ptr file[5], al
inc si
cmp si, 0ah
jb L1
L3:
mov si, 0
mov ax, bp
add al, 30H
mov byte ptr file[4], al
inc bp
cmp bp, 0ah
jb L1
L4:
mov bp, 0
mov ax, bx
add al, 30H
mov byte ptr file[3], al
inc bx;最大就7777
cmp bx, 7
jle L1
exit:
;把屏幕搞干净clear
mov ah, 0fh
int 10h
mov ah, 0
int 10h
mov ah,4ch
int 21h
main endp
print proc near;读取文件并打印出来
;打印文件名,bug了,我在找bug
; mov dx, offset file;将串的段内地址装入DX
; mov ah, 09h;调用DOS的09H号功能,传入参数DS:DX=串地址,'$'结束字符串
; int 21h
push bx
push bp
push si
push di
;open file
lea dx,file
mov al,0
mov ah,3dh
int 21h
jc error
mov fh,ax
;read file
lea dx,buf
mov cx,2000
mov bx,fh
mov ah,3fh
int 21h
jc error
mov cx,ax
lea si,buf
LS:mov dl,[si]
inc si
mov ah,02h
int 21h
loop LS
jmp exitsub
error:
lea dx,error_msg
mov ah,09h
int 21h
;打印文件名,bug了,我在找bug
mov dx, offset file;将串的段内地址装入DX
mov ah, 09h;调用DOS的09H号功能,传入参数DS:DX=串地址,'$'结束字符串
int 21h
jmp exit
exitsub:
mov bx, fh;句柄
mov ah, 3eh;关闭文件
int 21h;不关闭只能读取16个,很怪
pop di
pop si
pop bp
pop bx
ret
print endp
code ends
end start