aboutsummaryrefslogtreecommitdiffstats
path: root/code/tools/lcc/mips/irix/tst/wf1.sbk
blob: 7313c01832195880e82726836e839ac01560858f (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
.set reorder
.globl main
.text
.text
.align 2
.ent main
main:
.frame $sp,48,$31
.set noreorder
.cpload $25
.set reorder
addu $sp,$sp,-48
.mask 0x82000000,-28
.cprestore 16
sw $31,20($sp)
sw $0,-24+48($sp)
sw $0,next
b L.3
L.2:
la $4,-20+48($sp)
la $5,-24+48($sp)
jal lookup
lw $15,($2)
la $15,1($15)
sw $15,($2)
L.3:
la $4,-20+48($sp)
jal getword
bne $2,$0,L.2
lw $4,-24+48($sp)
jal tprint
move $2,$0
L.1:
lw $25,16($sp)
lw $31,20($sp)
addu $sp,$sp,48
j $31
.end main
.globl err
.text
.align 2
.ent err
err:
.frame $sp,24,$31
.set noreorder
.cpload $25
.set reorder
addu $sp,$sp,-24
.mask 0x82000000,-4
.cprestore 16
sw $31,20($sp)
sw $4,24($sp)
la $4,L.6
lw $5,0+24($sp)
jal printf
la $4,1
jal exit
move $2,$0
L.5:
lw $25,16($sp)
lw $31,20($sp)
addu $sp,$sp,24
j $31
.end err
.globl getword
.text
.align 2
.ent getword
getword:
.frame $sp,32,$31
.set noreorder
.cpload $25
.set reorder
addu $sp,$sp,-32
.mask 0xc2800000,-4
sw $23,16($sp)
.cprestore 20
sw $30,24($sp)
sw $31,28($sp)
sw $4,32($sp)
L.8:
L.9:
jal getchar
move $24,$2
move $30,$24
la $15,-1
beq $24,$15,L.11
move $4,$30
jal isletter
beq $2,$0,L.8
L.11:
lw $23,0+32($sp)
b L.15
L.12:
move $24,$23
la $23,1($24)
move $15,$30
sb $15,($24)
L.13:
jal getchar
move $30,$2
L.15:
move $4,$30
jal isletter
move $30,$2
bne $2,$0,L.12
sb $0,($23)
move $24,$23
lw $15,0+32($sp)
bleu $24,$15,L.16
la $2,1
b L.7
L.16:
move $2,$0
L.7:
lw $23,16($sp)
lw $25,20($sp)
lw $30,24($sp)
lw $31,28($sp)
addu $sp,$sp,32
j $31
.end getword
.globl isletter
.text
.align 2
.ent isletter
isletter:
.frame $sp,0,$31
.set noreorder
.cpload $25
.set reorder
la $24,65
blt $4,$24,L.19
la $24,90
bgt $4,$24,L.19
la $4,32($4)
L.19:
la $24,97
blt $4,$24,L.21
la $24,122
bgt $4,$24,L.21
move $2,$4
b L.18
L.21:
move $2,$0
L.18:
j $31
.end isletter
.globl lookup
.text
.align 2
.ent lookup
lookup:
.frame $sp,32,$31
.set noreorder
.cpload $25
.set reorder
addu $sp,$sp,-32
.mask 0xc2000000,-8
.cprestore 16
sw $30,20($sp)
sw $31,24($sp)
sw $4,32($sp)
move $30,$5
lw $24,($30)
beq $24,$0,L.24
lw $4,0+32($sp)
lw $24,($30)
lw $5,12($24)
jal strcmp
sw $2,-4+32($sp)
lw $24,-4+32($sp)
bge $24,$0,L.26
lw $4,0+32($sp)
lw $24,($30)
la $5,4($24)
jal lookup
move $24,$2
b L.23
L.26:
lw $24,-4+32($sp)
ble $24,$0,L.28
lw $4,0+32($sp)
lw $24,($30)
la $5,8($24)
jal lookup
move $24,$2
b L.23
L.28:
lw $2,($30)
b L.23
L.24:
lw $24,next
la $15,2000
blt $24,$15,L.30
la $4,L.32
jal err
L.30:
lw $24,next
sll $24,$24,4
sw $0,words($24)
lw $24,next
sll $24,$24,4
sw $0,words+8($24)
sw $0,words+4($24)
lw $4,0+32($sp)
jal strlen
move $24,$2
la $4,1($24)
jal malloc
lw $15,next
sll $15,$15,4
sw $2,words+12($15)
lw $24,next
sll $24,$24,4
lw $24,words+12($24)
bne $24,$0,L.36
la $4,L.39
jal err
L.36:
lw $24,next
sll $24,$24,4
lw $4,words+12($24)
lw $5,0+32($sp)
jal strcpy
lw $24,next
la $15,1($24)
sw $15,next
sll $24,$24,4
la $24,words($24)
sw $24,($30)
move $2,$24
L.23:
lw $25,16($sp)
lw $30,20($sp)
lw $31,24($sp)
addu $sp,$sp,32
j $31
.end lookup
.globl tprint
.text
.align 2
.ent tprint
tprint:
.frame $sp,32,$31
.set noreorder
.cpload $25
.set reorder
addu $sp,$sp,-32
.mask 0xc2000000,-8
.cprestore 16
sw $30,20($sp)
sw $31,24($sp)
move $30,$4
move $24,$30
beq $24,$0,L.42
lw $4,4($30)
jal tprint
la $4,L.44
lw $5,($30)
lw $6,12($30)
jal printf
lw $4,8($30)
jal tprint
L.42:
move $2,$0
L.41:
lw $25,16($sp)
lw $30,20($sp)
lw $31,24($sp)
addu $sp,$sp,32
j $31
.end tprint
.globl strcmp
.text
.align 2
.ent strcmp
strcmp:
.frame $sp,0,$31
.set noreorder
.cpload $25
.set reorder
b L.47
L.46:
move $24,$4
la $4,1($24)
lb $24,($24)
bne $24,$0,L.49
move $2,$0
b L.45
L.49:
la $5,1($5)
L.47:
lb $24,($4)
lb $15,($5)
beq $24,$15,L.46
lb $24,($4)
bne $24,$0,L.51
la $2,-1
b L.45
L.51:
lb $24,($5)
bne $24,$0,L.53
la $2,1
b L.45
L.53:
lb $24,($4)
lb $15,($5)
subu $2,$24,$15
L.45:
j $31
.end strcmp
.globl next
.comm next,4
.globl words
.comm words,32000
.rdata
.align 0
L.44:
.byte 37
.byte 100
.byte 9
.byte 37
.byte 115
.byte 10
.byte 0
.align 0
L.39:
.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 0
L.32:
.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 0
L.6:
.byte 63
.byte 32
.byte 37
.byte 115
.byte 10
.byte 0