-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.s
381 lines (381 loc) · 5.38 KB
/
test.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
.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_const9:
.word 5
.word 5
.word String_dispTab
.word int_const0
.byte 0
.align 2
.word -1
str_const8:
.word 5
.word 6
.word String_dispTab
.word int_const1
.ascii "String"
.byte 0
.align 2
.word -1
str_const7:
.word 5
.word 6
.word String_dispTab
.word int_const2
.ascii "Bool"
.byte 0
.align 2
.word -1
str_const6:
.word 5
.word 5
.word String_dispTab
.word int_const3
.ascii "Int"
.byte 0
.align 2
.word -1
str_const5:
.word 5
.word 6
.word String_dispTab
.word int_const2
.ascii "Main"
.byte 0
.align 2
.word -1
str_const4:
.word 5
.word 5
.word String_dispTab
.word int_const4
.ascii "IO"
.byte 0
.align 2
.word -1
str_const3:
.word 5
.word 6
.word String_dispTab
.word int_const1
.ascii "Object"
.byte 0
.align 2
.word -1
str_const2:
.word 5
.word 8
.word String_dispTab
.word int_const5
.ascii "<basic class>"
.byte 0
.align 2
.word -1
str_const1:
.word 5
.word 6
.word String_dispTab
.word int_const6
.ascii "test.cl"
.byte 0
.align 2
.word -1
str_const0:
.word 5
.word 8
.word String_dispTab
.word int_const7
.ascii "Helloworld!\n"
.byte 0
.align 2
.word -1
int_const7:
.word 3
.word 4
.word Int_dispTab
.word 12
.word -1
int_const6:
.word 3
.word 4
.word Int_dispTab
.word 7
.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 4
.word -1
int_const1:
.word 3
.word 4
.word Int_dispTab
.word 6
.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_const3
.word str_const4
.word str_const5
.word str_const6
.word str_const7
.word str_const8
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
Object_dispTab:
.word Object.abort
.word Object.type_name
.word Object.copy
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
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
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
Main.main:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
sw $ra 4($sp)
addiu $fp $sp 4
move $s0 $a0
la $a0 str_const0
sw $a0 0($sp)
addiu $sp $sp -4
move $a0 $s0
bne $a0 $zero label0
la $a0 str_const1
li $t1 1
jal _dispatch_abort
label0:
lw $t1 8($a0)
lw $t1 12($t1)
jalr $t1
lw $fp 12($sp)
lw $s0 8($sp)
lw $ra 4($sp)
addiu $sp $sp 12
jr $ra