-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.s
625 lines (625 loc) · 8.99 KB
/
list.s
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
.data
.align 2
.globl class_nameTab
.globl Main_protObj
.globl Int_protObj
.globl String_protObj
.globl bool_const0
.globl bool_const1
.globl _int_tag
.globl _bool_tag
.globl _string_tag
_int_tag:
.word 3
_bool_tag:
.word 4
_string_tag:
.word 5
.globl _MemMgr_INITIALIZER
_MemMgr_INITIALIZER:
.word _NoGC_Init
.globl _MemMgr_COLLECTOR
_MemMgr_COLLECTOR:
.word _NoGC_Collect
.globl _MemMgr_TEST
_MemMgr_TEST:
.word 0
.word -1
str_const12:
.word 5
.word 5
.word String_dispTab
.word int_const0
.byte 0
.align 2
.word -1
str_const11:
.word 5
.word 6
.word String_dispTab
.word int_const1
.ascii "List"
.byte 0
.align 2
.word -1
str_const10:
.word 5
.word 6
.word String_dispTab
.word int_const2
.ascii "String"
.byte 0
.align 2
.word -1
str_const9:
.word 5
.word 6
.word String_dispTab
.word int_const1
.ascii "Bool"
.byte 0
.align 2
.word -1
str_const8:
.word 5
.word 5
.word String_dispTab
.word int_const3
.ascii "Int"
.byte 0
.align 2
.word -1
str_const7:
.word 5
.word 6
.word String_dispTab
.word int_const1
.ascii "Main"
.byte 0
.align 2
.word -1
str_const6:
.word 5
.word 5
.word String_dispTab
.word int_const4
.ascii "IO"
.byte 0
.align 2
.word -1
str_const5:
.word 5
.word 6
.word String_dispTab
.word int_const2
.ascii "Object"
.byte 0
.align 2
.word -1
str_const4:
.word 5
.word 8
.word String_dispTab
.word int_const5
.ascii "<basic class>"
.byte 0
.align 2
.word -1
str_const3:
.word 5
.word 5
.word String_dispTab
.word int_const6
.ascii "\n"
.byte 0
.align 2
.word -1
str_const2:
.word 5
.word 6
.word String_dispTab
.word int_const2
.ascii "World!"
.byte 0
.align 2
.word -1
str_const1:
.word 5
.word 6
.word String_dispTab
.word int_const2
.ascii "Hello "
.byte 0
.align 2
.word -1
str_const0:
.word 5
.word 6
.word String_dispTab
.word int_const7
.ascii "list.cl"
.byte 0
.align 2
.word -1
int_const7:
.word 3
.word 4
.word Int_dispTab
.word 7
.word -1
int_const6:
.word 3
.word 4
.word Int_dispTab
.word 1
.word -1
int_const5:
.word 3
.word 4
.word Int_dispTab
.word 13
.word -1
int_const4:
.word 3
.word 4
.word Int_dispTab
.word 2
.word -1
int_const3:
.word 3
.word 4
.word Int_dispTab
.word 3
.word -1
int_const2:
.word 3
.word 4
.word Int_dispTab
.word 6
.word -1
int_const1:
.word 3
.word 4
.word Int_dispTab
.word 4
.word -1
int_const0:
.word 3
.word 4
.word Int_dispTab
.word 0
.word -1
bool_const0:
.word 4
.word 4
.word Bool_dispTab
.word 0
.word -1
bool_const1:
.word 4
.word 4
.word Bool_dispTab
.word 1
class_nameTab:
.word str_const5
.word str_const6
.word str_const7
.word str_const8
.word str_const9
.word str_const10
.word str_const11
class_objTab:
.word Object_protObj
.word Object_init
.word IO_protObj
.word IO_init
.word Main_protObj
.word Main_init
.word Int_protObj
.word Int_init
.word Bool_protObj
.word Bool_init
.word String_protObj
.word String_init
.word List_protObj
.word List_init
Object_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
List_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
.word List.init
.word List.flatten
String_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
.word String.length
.word String.concat
.word String.substr
Bool_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
Int_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
IO_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
.word IO.out_string
.word IO.out_int
.word IO.in_string
.word IO.in_int
Main_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
.word IO.out_string
.word IO.out_int
.word IO.in_string
.word IO.in_int
.word Main.main
.word -1
Object_protObj:
.word 0
.word 3
.word Object_dispTab
.word -1
List_protObj:
.word 6
.word 5
.word List_dispTab
.word str_const12
.word 0
.word -1
String_protObj:
.word 5
.word 5
.word String_dispTab
.word int_const0
.word 0
.word -1
Bool_protObj:
.word 4
.word 4
.word Bool_dispTab
.word 0
.word -1
Int_protObj:
.word 3
.word 4
.word Int_dispTab
.word 0
.word -1
IO_protObj:
.word 1
.word 3
.word IO_dispTab
.word -1
Main_protObj:
.word 2
.word 3
.word Main_dispTab
.globl heap_start
heap_start:
.word 0
.text
.globl Main_init
.globl Int_init
.globl String_init
.globl Bool_init
.globl Main.main
Object_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
List_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
jal Object_init
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
String_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
jal Object_init
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
Bool_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
jal Object_init
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
Int_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
jal Object_init
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
IO_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
jal Object_init
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
Main_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
jal IO_init
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
List.init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
lw $a0 16($fp)
sw $a0 12($s0)
lw $a0 12($fp)
sw $a0 16($s0)
move $a0 $s0
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 20
jr $ra
List.flatten:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
lw $a0 16($s0)
move $t1 $a0
la $a0 bool_const1
beqz $t1 label2
la $a0 bool_const0
label2:
lw $t1 12($a0)
beqz $t1 label0
lw $a0 12($s0)
b label1
label0:
lw $a0 16($s0)
bne $a0 $zero label3
la $a0 str_const0
li $t1 1
jal _dispatch_abort
label3:
lw $t1 8($a0)
lw $t1 16($t1)
jalr $t1
sw $a0 0($sp)
addiu $sp $sp -4
lw $a0 12($s0)
bne $a0 $zero label4
la $a0 str_const0
li $t1 1
jal _dispatch_abort
label4:
lw $t1 8($a0)
lw $t1 16($t1)
jalr $t1
label1:
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra
Main.main:
addiu $sp $sp -32
sw $fp 32($sp)
sw $s0 28($sp)
sw $ra 24($sp)
addiu $fp $sp 4
move $s0 $a0
la $s1 str_const1
la $s2 str_const2
la $s3 str_const3
move $s4 $zero
sw $s1 0($sp)
addiu $sp $sp -4
sw $s2 0($sp)
addiu $sp $sp -4
sw $s3 0($sp)
addiu $sp $sp -4
sw $s4 0($sp)
addiu $sp $sp -4
la $a0 List_protObj
jal Object.copy
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
jal List_init
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
bne $a0 $zero label5
la $a0 str_const0
li $t1 1
jal _dispatch_abort
label5:
lw $t1 8($a0)
lw $t1 12($t1)
jalr $t1
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
sw $a0 0($sp)
addiu $sp $sp -4
la $a0 List_protObj
jal Object.copy
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
jal List_init
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
bne $a0 $zero label6
la $a0 str_const0
li $t1 1
jal _dispatch_abort
label6:
lw $t1 8($a0)
lw $t1 12($t1)
jalr $t1
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
sw $a0 0($sp)
addiu $sp $sp -4
la $a0 List_protObj
jal Object.copy
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
jal List_init
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
bne $a0 $zero label7
la $a0 str_const0
li $t1 1
jal _dispatch_abort
label7:
lw $t1 8($a0)
lw $t1 12($t1)
jalr $t1
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
move $s5 $a0
move $a0 $s5
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
sw $s5 16($fp)
bne $a0 $zero label8
la $a0 str_const0
li $t1 1
jal _dispatch_abort
label8:
lw $t1 8($a0)
lw $t1 16($t1)
jalr $t1
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
lw $s5 16($fp)
sw $a0 0($sp)
addiu $sp $sp -4
move $a0 $s0
sw $s1 0($fp)
sw $s2 4($fp)
sw $s3 8($fp)
sw $s4 12($fp)
sw $s5 16($fp)
bne $a0 $zero label9
la $a0 str_const0
li $t1 1
jal _dispatch_abort
label9:
lw $t1 8($a0)
lw $t1 12($t1)
jalr $t1
lw $s1 0($fp)
lw $s2 4($fp)
lw $s3 8($fp)
lw $s4 12($fp)
lw $s5 16($fp)
lw $fp 32($sp)
lw $s0 28($sp)
lw $ra 24($sp)
addiu $sp $sp 32
jr $ra