锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
2 ;涓ゅ彧鑰佽檸鐨勯煶涔愮▼搴?br> 3 date segment
4 freq dw 2 dup (262,294,330,262)
5 dw 2 dup (330,350,392)
6 dw 2 dup (392,440,392,349,330,262)
7 dw 2 dup(330,294,262),0ffffh
8 time dw 8 dup(500)
9 dw 2 dup (500,500,1000)
10 dw 2 dup(250,250,250,250,500,500)
11 dw 2 dup (500,500,1000)
12 date ends
13
14 code segment
15 assume cs:code,ds:date
16 begin: push ds
17 mov ax,0
18 push ax
19 mov ax,date
20 mov ds,ax
21 ;**************************
22 lea si,freq
23 lea bp,time
24 n0: mov ah,0bh
25 int 21h
26 cmp al,0ffh
27 je exit
28 mov di,[si]
29 cmp di,0ffffh
30 je n8
31
32 mov bx,ds:[bp]
33 call s_sound
34 add si,2
35 add bp,2
36 jmp n0
37 n8: lea si,freq
38 lea bp,time
39 jmp n0
40 exit:mov ah,4ch
41 int 21h
42 s_sound proc near
43 push bp
44 push si
45
46 mov al,0b6h
47 out 43h,al
48 mov dx,12h
49 mov ax,533h*896
50 div di
51 out 42h,al
52 mov al,ah
53 out 42h,al
54 in al,61h
55 mov ah,al
56 or al,3
57 out 61h,al
58
59 n1: mov cx,2801h
60 n2: loop n2
61
62 dec bx
63 jnz n1
64 mov al,ah
65 out 61h,al
66 pop si
67 pop bp
68 ret
69 s_sound endp
70 code ends
71 end begin
72
73
74
75
76
77
]]>
2
3 code segment
4 assume cs:code,ds:code
5 org 100h
6
7 begin:
8 jmp install
9 d1 db 'z'
10 old dd ?
11 c db 0
12 color db 0
13 pag db ?
14 line_23 db 10 dup(20h,0)
15 line db 'Z',0eh,'B',0eh,'.',0eh,20h,0
16 line_24 db 2 dup(20h,0ah,20h,0ah,':',8eh),20h,0ah,20h,0ah
17 start:
18 inc cs:[c]
19 cmp byte ptr cs:[c],8
20 je n1
21 jmp dword ptr cs:[old]
22 n1:
23 mov byte ptr cs:[c],0
24 push ax
25 push bx
26 push cx
27 push dx
28 push ds
29 push es
30 push di
31 push si
32
33 cmp byte ptr cs:[color],15
34 jae n3
35 inc cs:[color]
36 mov bh,cs:[color]
37 mov byte ptr cs:[line+1],bh
38 mov byte ptr cs:[line+3],bh
39 jmp n4
40 n3:
41 mov byte ptr cs:[color],0
42 n4:
43 mov ah,0fh
44 int 10h
45 ; mov ah,3
46 ; int 10h
47 ; push dx
48 mov cs:[pag],bh
49 mov ax,0b800h
50 mov es,ax
51 ; mov ax,4096
52 ; mov bh,pag
53 ; mul bh
54
55 ; mov di,ax
56 ; add di,140
57 mov ax,cs
58 mov ds,ax
59 ; lea si,line_23
60 cld
61 ; mov cx,20
62 ; rep movsb
63 mov ah,2
64 int 1ah
65 push cx
66 mov ah,ch
67 mov cl,4
68 shr ch,cl
69 add ch,30h
70 mov byte ptr cs:[line_24],ch
71 mov ch,ah
72 and ch,0fh
73 add ch,30h
74 mov byte ptr cs:[line_24+2],ch
75 pop bx
76 mov ah,bl
77 shr bl,cl
78 add bl,30h
79 mov byte ptr cs:[line_24+6],bl
80 and ah,0fh
81 add ah,30h
82 mov byte ptr cs:[line_24+8],ah
83 mov ah,dh
84 shr dh,cl
85 add dh,30h
86 mov byte ptr cs:[line_24+12],dh
87 and ah,0fh
88 add ah,30h
89 mov byte ptr cs:[line_24+14],ah
90 mov ax,4096
91 mov bh,pag
92 mul bh
93 mov di,ax
94 add di,134
95 lea si,line
96 mov cx,24
97 rep movsb
98
99 ; pop dx
100 ; mov bh,pag
101 ; mov ah,2
102 ; int 10h
103 pop si
104 pop di
105 pop es
106 pop ds
107 pop dx
108 pop cx
109 pop bx
110 pop ax
111 iret
112 install:
113 mov ax,351ch
114 int 21h
115 mov word ptr old,bx
116 mov word ptr old+2,es
117 mov si,80h
118 cmp byte ptr cs:[si],0
119 je next
120 cmp byte ptr es:[103h],'z'
121 jne error
122 push ds
123 push dx
124 push di
125 cli
126 lea di,old
127 mov ds,word ptr es:[di+2]
128 mov dx,word ptr es:[di]
129 mov ax,251ch
130 int 21h
131 sti
132 pop di
133 pop dx
134 pop ds
135 mov ah,49h
136 int 21h
137 jmp eexit
138 error:
139 lea dx, mess
140 mov ah,9
141 int 21h
142 eexit:
143 mov ah,4ch
144 int 21h
145 next:
146 mov ax,251ch
147 lea dx,start
148 int 21h
149 lea dx,install
150 int 27h
151 mess db ' the TSR program no find!$'
152
153 code ends
154 end begin
155
]]>
]]>
2 date segment
3 sum dw 0
4 s7 dw ?
5 s6 dw ?
6 s5 dw ?
7 s3 dw ?
8 s4 dw ?
9 buf1 db 103 dup (20h)
10 buf2 db 100 dup (310 dup(20h))
11 buf3 db 100 dup (20h)
12 s1 dw ?
13 s2 dw ?
14 flag1 db 100
15 flag2 db 10
16 file db 'input.txt',0
17 handle dw ?
18 leth dw ?
19 date ends
20 code segment
21 assume cs:code,ds:date,es:date
22 main proc far
23 ; *******************
24 push ds
25 mov ax,0
26 push ax
27 mov ax,date
28 mov ds,ax
29 mov es,ax
30 ;*************************
31 mov ah,3dh
32 lea dx,file
33 mov al,0
34 int 21h
35 mov handle,ax
36 mov bx,ax
37 mov ah,42h
38 mov al,2
39 mov cx,0
40 mov dx,0
41 int 21h
42
43 mov leth,ax
44 mov ah,42h
45 mov al,0
46 mov cx,0
47 mov dx,0
48 int 21h
49
50 mov ah,3fh
51 mov cx,leth
52 mov bx,handle
53 lea dx,buf2
54 int 21h
55
56 lea di,buf2
57 a2: cmp byte ptr [di],30h
58 jg a1
59 inc di
60 jmp a2
61 a1: mov s1,di
62 a3: inc di
63 cmp byte ptr [di],20h
64 jne a3
65 mov cx,di
66 sub cx,s1
67 call sec
68 mov dx,s4
69 mov s3,dx
70
71 add di,2
72 mov s1,di
73 a8: inc di
74 cmp byte ptr [di],30h
75 jge a8
76 mov cx,di
77 sub cx,s1
78 call sec
79
80 mov ah,3eh
81 mov bx,handle
82 int 21h
83 ;************
84 mov ax,s3
85 mov bx,s4
86 mul bx
87 mov s5,ax
88 mov si,0
89 mov cx,s3
90 n2: push cx
91 mov cx,s4
92 n1: cmp byte ptr [di],30h
93 jge n0
94 inc di
95 jmp n1
96 n0: mov bl,byte ptr [di]
97 mov buf2[si],bl
98 inc si
99 inc di
100 loop n1
101 mov buf2[si],0
102 mov buf2[si+1],0
103 add si,2
104 pop cx
105 loop n2
106 mov cx,s4
107 inc cx
108 n3: mov buf2[si],0
109 inc si
110 loop n3
111 mov cx,s5
112 lea di,buf2
113 n4: mov s7,di
114 cmp byte ptr [di],30h
115 jb c0
116 jmp c1
117 c0: inc di
118 jmp n4
119 c1: cmp byte ptr [di],30h
120 ja n5
121 n8: mov di,s7
122 inc di
123 loop n4
124 jmp next
125 n5: mov bx,s4
126 add bx,2
127 mov si,0ffffh
128 push si
129 n6: mov byte ptr [di],30h
130 mov s6,di
131 sub di,bx
132 push di
133 mov di,s6
134 dec di
135 push di
136 mov di,s6
137 add di,bx
138 push di
139 mov di,s6
140 inc di
141 push di
142 n7:
143 pop di
144 cmp di,0ffffh
145 je n9
146 cmp byte ptr [di],30h
147 jg n6
148 jmp n7
149 n9: mov si,1
150 add sum,si
151 jmp n8
152
153 next: mov bx,sum
154 call disp
155 mov ah,4ch
156 int 21h
157 main endp
158
159 sec proc near
160 cmp cx,3
161 je a4
162 cmp cx,2
163 je a5
164 mov al,byte ptr [di-1]
165 sub al,30h
166 mov ah,0
167 mov bx,ax
168 a6: mov s4,bx
169 jmp a7
170 a4: mov bx,100
171 jmp a6
172 a5: mov al,byte ptr [di-2]
173 sub al,30h
174 mov dl,10
175 mul dl
176 mov bx,ax
177 mov al,byte ptr [di-1]
178 sub al,30h
179 mov ah,0
180 add bx,ax
181 jmp a6
182 a7: ret
183 sec endp
184
185 disp proc near
186 mov cx,10000
187 call clu
188 mov cx,1000
189 call clu
190 mov cx,100
191 call clu
192 mov cx,10
193 call clu
194 mov cx,1
195 call clu
196 ret
197 disp endp
198 clu proc near
199 mov ax,bx
200 mov dx,0
201 div cx
202 mov bx,dx
203 mov dl,al
204 add dl,30h
205 cmp dl,30h
206 je f1
207 jmp f2
208 f1: ret
209 f2: mov ah,02h
210 int 21h
211 ret
212 clu endp
213 code ends
214 end main
215
216
217
]]>