aboutsummaryrefslogtreecommitdiffstats
path: root/lcc/x86/linux/tst/wf1.sbk
blob: 1c3ff042b57115078ea6e7e52c4b9ddd03ad3b6a (plain)
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
.globl main
.text
.align 16
.type main,@function
main:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
subl $24,%esp
movl $0,-24(%ebp)
movl $0,next
jmp .LC3
.LC2:
leal -24(%ebp),%edi
pushl %edi
leal -20(%ebp),%edi
pushl %edi
call lookup
addl $8,%esp
incl (,%eax)
.LC3:
leal -20(%ebp),%edi
pushl %edi
call getword
addl $4,%esp
cmpl $0,%eax
jne .LC2
pushl -24(%ebp)
call tprint
addl $4,%esp
movl $0,%eax
.LC1:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf5:
.size main,.Lf5-main
.globl err
.align 16
.type err,@function
err:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
pushl 20(%ebp)
pushl $.LC7
call printf
addl $8,%esp
pushl $1
call exit
addl $4,%esp
movl $0,%eax
.LC6:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf8:
.size err,.Lf8-err
.globl getword
.align 16
.type getword,@function
getword:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
subl $8,%esp
.LC10:
.LC11:
call getchar
movl %eax,%edi
movl %edi,-4(%ebp)
cmpl $-1,%edi
je .LC13
pushl -4(%ebp)
call isletter
addl $4,%esp
cmpl $0,%eax
je .LC10
.LC13:
movl 20(%ebp),%edi
movl %edi,-8(%ebp)
jmp .LC17
.LC14:
movl -8(%ebp),%edi
leal 1(%edi),%esi
movl %esi,-8(%ebp)
movl -4(%ebp),%esi
movl %esi,%ebx
movb %bl,(,%edi)
.LC15:
call getchar
movl %eax,-4(%ebp)
.LC17:
pushl -4(%ebp)
call isletter
addl $4,%esp
movl %eax,-4(%ebp)
cmpl $0,%eax
jne .LC14
movl -8(%ebp),%edi
movb $0,(,%edi)
movl -8(%ebp),%edi
movl 20(%ebp),%esi
cmpl %esi,%edi
jbe .LC18
movl $1,%eax
jmp .LC9
.LC18:
movl $0,%eax
.LC9:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf20:
.size getword,.Lf20-getword
.globl isletter
.align 16
.type isletter,@function
isletter:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
movl 20(%ebp),%edi
cmpl $65,%edi
jl .LC22
cmpl $90,%edi
jg .LC22
addl $32,20(%ebp)
.LC22:
movl 20(%ebp),%edi
cmpl $97,%edi
jl .LC24
cmpl $122,%edi
jg .LC24
movl 20(%ebp),%eax
jmp .LC21
.LC24:
movl $0,%eax
.LC21:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf26:
.size isletter,.Lf26-isletter
.globl lookup
.align 16
.type lookup,@function
lookup:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
subl $4,%esp
movl 24(%ebp),%edi
movl (,%edi),%edi
cmpl $0,%edi
je .LC28
movl 24(%ebp),%edi
movl (,%edi),%edi
pushl 12(%edi)
pushl 20(%ebp)
call strcmp
addl $8,%esp
movl %eax,-4(%ebp)
cmpl $0,-4(%ebp)
jge .LC30
movl 24(%ebp),%edi
movl (,%edi),%edi
leal 4(%edi),%edi
pushl %edi
pushl 20(%ebp)
call lookup
addl $8,%esp
movl %eax,%edi
jmp .LC27
.LC30:
cmpl $0,-4(%ebp)
jle .LC32
movl 24(%ebp),%edi
movl (,%edi),%edi
leal 8(%edi),%edi
pushl %edi
pushl 20(%ebp)
call lookup
addl $8,%esp
movl %eax,%edi
jmp .LC27
.LC32:
movl 24(%ebp),%edi
movl (,%edi),%eax
jmp .LC27
.LC28:
cmpl $2000,next
jl .LC34
pushl $.LC36
call err
addl $4,%esp
.LC34:
movl next,%edi
sall $4,%edi
movl $0,words(%edi)
movl next,%edi
sall $4,%edi
movl $0,words+8(%edi)
movl $0,words+4(%edi)
pushl 20(%ebp)
call strlen
addl $4,%esp
leal 1(%eax),%edi
pushl %edi
call malloc
addl $4,%esp
movl next,%esi
sall $4,%esi
movl %eax,words+12(%esi)
movl next,%edi
sall $4,%edi
movl words+12(%edi),%edi
cmpl $0,%edi
jne .LC40
pushl $.LC43
call err
addl $4,%esp
.LC40:
pushl 20(%ebp)
movl next,%edi
sall $4,%edi
pushl words+12(%edi)
call strcpy
addl $8,%esp
movl next,%edi
leal 1(%edi),%esi
movl %esi,next
sall $4,%edi
leal words(%edi),%edi
movl 24(%ebp),%esi
movl %edi,(,%esi)
movl %edi,%eax
.LC27:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf45:
.size lookup,.Lf45-lookup
.globl tprint
.align 16
.type tprint,@function
tprint:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
movl 20(%ebp),%edi
cmpl $0,%edi
je .LC47
movl 20(%ebp),%edi
pushl 4(%edi)
call tprint
addl $4,%esp
movl 20(%ebp),%edi
pushl 12(%edi)
pushl (,%edi)
pushl $.LC49
call printf
addl $12,%esp
movl 20(%ebp),%edi
pushl 8(%edi)
call tprint
addl $4,%esp
.LC47:
movl $0,%eax
.LC46:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf50:
.size tprint,.Lf50-tprint
.globl strcmp
.align 16
.type strcmp,@function
strcmp:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
jmp .LC53
.LC52:
movl 20(%ebp),%edi
leal 1(%edi),%esi
movl %esi,20(%ebp)
movsbl (,%edi),%edi
cmpl $0,%edi
jne .LC55
movl $0,%eax
jmp .LC51
.LC55:
incl 24(%ebp)
.LC53:
movl 20(%ebp),%edi
movsbl (,%edi),%edi
movl 24(%ebp),%esi
movsbl (,%esi),%esi
cmpl %esi,%edi
je .LC52
movl 20(%ebp),%edi
movsbl (,%edi),%edi
cmpl $0,%edi
jne .LC57
movl $-1,%eax
jmp .LC51
.LC57:
movl 24(%ebp),%edi
movsbl (,%edi),%edi
cmpl $0,%edi
jne .LC59
movl $1,%eax
jmp .LC51
.LC59:
movl 20(%ebp),%edi
movsbl (,%edi),%edi
movl 24(%ebp),%esi
movsbl (,%esi),%esi
movl %edi,%eax
subl %esi,%eax
.LC51:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf61:
.size strcmp,.Lf61-strcmp
.bss
.globl next
.align 4
.type next,@object
.size next,4
.comm next,4
.globl words
.align 4
.type words,@object
.size words,32000
.comm words,32000
.data
.align 1
.LC49:
.byte 37
.byte 100
.byte 9
.byte 37
.byte 115
.byte 10
.byte 0
.align 1
.LC43:
.byte 111
.byte 117
.byte 116
.byte 32
.byte 111
.byte 102
.byte 32
.byte 119
.byte 111
.byte 114
.byte 100
.byte 32
.byte 115
.byte 116
.byte 111
.byte 114
.byte 97
.byte 103
.byte 101
.byte 0
.align 1
.LC36:
.byte 111
.byte 117
.byte 116
.byte 32
.byte 111
.byte 102
.byte 32
.byte 110
.byte 111
.byte 100
.byte 101
.byte 32
.byte 115
.byte 116
.byte 111
.byte 114
.byte 97
.byte 103
.byte 101
.byte 0
.align 1
.LC7:
.byte 63
.byte 32
.byte 37
.byte 115
.byte 10
.byte 0
.text
.ident "LCC: 4.1"