1 ;细胞问题解决方案 1997 zbin
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