aboutsummaryrefslogtreecommitdiff
path: root/lib.s
blob: 6e219b06d0500c517754053183f89144536dff3e (plain) (blame)
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
_func_printf:
	addiu $sp, $sp, -88
	sw $31, 84($sp) #printf
# load fmt_0
# load arg_0
# load len_0
# load ch_0
# load x_0
# t0 = addr fmt_0
	addiu $2, $sp, 88
	sw $2, 80($sp)	#t0
# arg_1 = t0 + 4
	lw $2, 80($sp)	#t0
	addiu $2, $2, 4
	sw $2, 16($sp)	#arg
# goto __L2
	j __L2
__L1:
# t3 = ch_2 == 37
	lb $2, 12($sp)	#ch
	li $3, 37
	seq $2, $2, $3
	sw $2, 76($sp)	#t3
# if not (t3) goto __L20
	lw $2, 76($sp)	#t3
	beqz $2, __L20
# fmt_4 = fmt_1 + 1
	lw $2, 88($sp)	#fmt
	addiu $2, $2, 1
	sw $2, 88($sp)	#fmt
# ch_4 = fmt_4[0]
	lw $2, 88($sp)	#fmt
	lb $3, 0($2)
	sb $3, 12($sp)	#ch
# t5 = ch_4 == 100
	lb $2, 12($sp)	#ch
	li $3, 100
	seq $2, $2, $3
	sw $2, 72($sp)	#t5
# if not (t5) goto __L6
	lw $2, 72($sp)	#t5
	beqz $2, __L6
# t7 = arg_2[0]
	lw $2, 16($sp)	#arg
	lw $3, 0($2)
	sw $3, 68($sp)	#t7
# push t7
	lw $2, 68($sp)	#t7
	sw $2, 0($sp) # push
# t6 = call __print_int
	jal _func___print_int
	sw $2, 64($sp)	#t6
# goto __L19
	j __L19
__L6:
# t8 = ch_4 == 99
	lb $2, 12($sp)	#ch
	li $3, 99
	seq $2, $2, $3
	sw $2, 60($sp)	#t8
# if not (t8) goto __L8
	lw $2, 60($sp)	#t8
	beqz $2, __L8
# t10 = arg_2[0]
	lw $2, 16($sp)	#arg
	lw $3, 0($2)
	sb $3, 56($sp)	#t10
# push t10
	lb $2, 56($sp)	#t10
	sw $2, 0($sp) # push
# t9 = call __print_char
	jal _func___print_char
	sw $2, 52($sp)	#t9
# goto __L19
	j __L19
__L8:
# t11 = ch_4 == 115
	lb $2, 12($sp)	#ch
	li $3, 115
	seq $2, $2, $3
	sw $2, 48($sp)	#t11
# if not (t11) goto __L10
	lw $2, 48($sp)	#t11
	beqz $2, __L10
# t13 = arg_2[0]
	lw $2, 16($sp)	#arg
	lw $3, 0($2)
	sw $3, 44($sp)	#t13
# push t13
	lw $2, 44($sp)	#t13
	sw $2, 0($sp) # push
# t12 = call __print_string
	jal _func___print_string
	sw $2, 40($sp)	#t12
# goto __L19
	j __L19
__L10:
# x_4 = arg_2[0]
	lw $2, 16($sp)	#arg
	lw $3, 0($2)
	sw $3, 4($sp)	#x
# t15 = x_4 == 0
	lw $2, 4($sp)	#x
	li $3, 0
	seq $2, $2, $3
	sw $2, 36($sp)	#t15
# if not (t15) goto __L12
	lw $2, 36($sp)	#t15
	beqz $2, __L12
# len_11 = 1
	li $2, 1
	sw $2, 8($sp)	#len
# goto __L15
	j __L15
__L12:
# len_8 = 0
	li $2, 0
	sw $2, 8($sp)	#len
# goto __L14
	j __L14
__L13:
# x_7 = x_6 / 10
	lw $2, 4($sp)	#x
	li $3, 10
	divu $2, $2, $3
	sw $2, 4($sp)	#x
# len_10 = len_9 + 1
	lw $2, 8($sp)	#len
	addiu $2, $2, 1
	sw $2, 8($sp)	#len
__L14:
# if (x_6) goto __L13
	lw $2, 4($sp)	#x
	bnez $2, __L13
__L15:
# len_5 = 4 - len_4
	li $2, 4
	lw $3, 8($sp)	#len
	subu $2, $2, $3
	sw $2, 8($sp)	#len
# goto __L17
	j __L17
__L16:
# push 48
	li $2, 48
	sw $2, 0($sp) # push
# t17 = call __print_char
	jal _func___print_char
	sw $2, 32($sp)	#t17
# len_7 = len_6 - 1
	lw $2, 8($sp)	#len
	li $3, 1
	subu $2, $2, $3
	sw $2, 8($sp)	#len
__L17:
# if (len_6) goto __L16
	lw $2, 8($sp)	#len
	bnez $2, __L16
# t19 = arg_2[0]
	lw $2, 16($sp)	#arg
	lw $3, 0($2)
	sw $3, 28($sp)	#t19
# push t19
	lw $2, 28($sp)	#t19
	sw $2, 0($sp) # push
# t18 = call __print_int
	jal _func___print_int
	sw $2, 24($sp)	#t18
# fmt_6 = fmt_4 + 2
	lw $2, 88($sp)	#fmt
	addiu $2, $2, 2
	sw $2, 88($sp)	#fmt
__L19:
# arg_4 = arg_2 + 4
	lw $2, 16($sp)	#arg
	addiu $2, $2, 4
	sw $2, 16($sp)	#arg
# goto __L21
	j __L21
__L20:
# push ch_2
	lb $2, 12($sp)	#ch
	sw $2, 0($sp) # push
# t20 = call __print_char
	jal _func___print_char
	sw $2, 20($sp)	#t20
__L21:
# fmt_3 = fmt_2 + 1
	lw $2, 88($sp)	#fmt
	addiu $2, $2, 1
	sw $2, 88($sp)	#fmt
__L2:
# ch_2 = fmt_1[0]
	lw $2, 88($sp)	#fmt
	lb $3, 0($2)
	sb $3, 12($sp)	#ch
# if (ch_2) goto __L1
	lb $2, 12($sp)	#ch
	bnez $2, __L1
_ret_printf:
	lw $31, 84($sp)
	addiu $sp, $sp, 88
	jr $31
_func___print_int:
    lw $a0, 0($sp)
    li $2, 1
    syscall
    jr $31
_func___print_char:
    lb $a0, 0($sp)
    li $2, 11
    syscall
    jr $31
_func___print_string:
    lw $a0, 0($sp)
    li $2, 4
    syscall
    jr $31
_func_malloc:
    lw $a0, 0($sp)
    li $2, 9
    syscall
    jr $31