-
Notifications
You must be signed in to change notification settings - Fork 0
/
testcode.x86
305 lines (305 loc) · 8.34 KB
/
testcode.x86
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
(DATA a)
(FUNCTION addThem [(int d) (int e)]
(BB 2
(OPER 8 Mov [(r 1)] [(m EDI)])
(OPER 9 Mov [(r 2)] [(m ESI)])
)
(BB 3
(OPER 10 Mov [(r 4)] [(r 1)])
(OPER 4 Add_I [(r 4)] [(r 4)(r 2)])
(OPER 5 Mov [(r 3)] [(r 4)])
(OPER 6 Mov [(m EAX)] [(r 3)])
)
(BB 1
(OPER 2 Return [] [(m EAX)])
)
)
(FUNCTION putDigit [(int s)]
(BB 2
(OPER 7 Mov [(r 1)] [(m EDI)])
)
(BB 3
(OPER 8 Mov [(r 2)] [(i 48)])
(OPER 5 Add_I [(r 2)] [(r 2)(r 1)])
(OPER 9 Mov [(m EDI)] [(r 2)])
(OPER 6 JSR [] [(s putchar)])
)
(BB 1
(OPER 2 Return [] [(m EAX)])
)
)
(FUNCTION printInt [(int r)]
(BB 2
(OPER 54 Mov [(r 1)] [(m EDI)])
)
(BB 3
(OPER 4 Mov [(r 3)] [(i 0)])
(OPER 55 Cmp [(m Flags)] [(r 1)(i 10000)])
(OPER 56 BLT [] [(bb 6)(m Flags)])
)
(BB 4
(OPER 57 Mov [(m EDI)] [(i 45)])
(OPER 8 JSR [] [(s putchar)])
(OPER 58 Mov [(m EDI)] [(i 1)])
(OPER 10 JSR [] [(s putDigit)])
)
(BB 1
(OPER 2 Return [] [(m EAX)])
)
(BB 11
(OPER 59 Cmp [(m Flags)] [(r 3)(i 1)])
(OPER 60 BNE [] [(bb 10)(m Flags)])
)
(BB 12
(OPER 61 Mov [(m EDI)] [(i 0)])
(OPER 35 JSR [] [(s putDigit)])
)
(BB 13
(OPER 36 Jmp [] [(bb 10)])
)
(BB 16
(OPER 62 Cmp [(m Flags)] [(r 3)(i 1)])
(OPER 63 BNE [] [(bb 15)(m Flags)])
)
(BB 17
(OPER 64 Mov [(m EDI)] [(i 0)])
(OPER 49 JSR [] [(s putDigit)])
)
(BB 18
(OPER 50 Jmp [] [(bb 15)])
)
(BB 6
(OPER 65 Cmp [(m Flags)] [(r 1)(i 1000)])
(OPER 66 BLT [] [(bb 8)(m Flags)])
)
(BB 7
(OPER 67 Mov [(m EDX)] [(i 0)])
(OPER 68 Mov [(m EAX)] [(r 1)])
(OPER 69 Mov [(r 19)] [(i 1000)])
(OPER 14 Div [(m EAX)(m EDX)] [(m EAX)(r 19)(m EDX)])
(OPER 70 Mov [(r 6)] [(m EAX)])
(OPER 15 Mov [(r 2)] [(r 6)])
(OPER 71 Mov [(m EDI)] [(r 2)])
(OPER 17 JSR [] [(s putDigit)])
(OPER 72 Mov [(m EAX)] [(r 2)])
(OPER 73 Mov [(r 20)] [(i 1000)])
(OPER 18 Mul [(m EAX)(m EDX)] [(m EAX)(r 20)])
(OPER 74 Mov [(r 7)] [(m EAX)])
(OPER 75 Mov [(r 8)] [(r 1)])
(OPER 19 Sub_I [(r 8)] [(r 8)(r 7)])
(OPER 20 Mov [(r 1)] [(r 8)])
(OPER 21 Mov [(r 3)] [(i 1)])
)
(BB 8
(OPER 76 Cmp [(m Flags)] [(r 1)(i 100)])
(OPER 77 BLT [] [(bb 11)(m Flags)])
)
(BB 9
(OPER 78 Mov [(m EDX)] [(i 0)])
(OPER 79 Mov [(m EAX)] [(r 1)])
(OPER 80 Mov [(r 22)] [(i 100)])
(OPER 24 Div [(m EAX)(m EDX)] [(m EAX)(r 22)(m EDX)])
(OPER 81 Mov [(r 10)] [(m EAX)])
(OPER 25 Mov [(r 2)] [(r 10)])
(OPER 82 Mov [(m EDI)] [(r 2)])
(OPER 27 JSR [] [(s putDigit)])
(OPER 83 Mov [(m EAX)] [(r 2)])
(OPER 84 Mov [(r 23)] [(i 100)])
(OPER 28 Mul [(m EAX)(m EDX)] [(m EAX)(r 23)])
(OPER 85 Mov [(r 11)] [(m EAX)])
(OPER 86 Mov [(r 12)] [(r 1)])
(OPER 29 Sub_I [(r 12)] [(r 12)(r 11)])
(OPER 30 Mov [(r 1)] [(r 12)])
(OPER 31 Mov [(r 3)] [(i 1)])
)
(BB 10
(OPER 87 Cmp [(m Flags)] [(r 1)(i 10)])
(OPER 88 BLT [] [(bb 16)(m Flags)])
)
(BB 14
(OPER 89 Mov [(m EDX)] [(i 0)])
(OPER 90 Mov [(m EAX)] [(r 1)])
(OPER 91 Mov [(r 25)] [(i 10)])
(OPER 39 Div [(m EAX)(m EDX)] [(m EAX)(r 25)(m EDX)])
(OPER 92 Mov [(r 15)] [(m EAX)])
(OPER 40 Mov [(r 2)] [(r 15)])
(OPER 93 Mov [(m EDI)] [(r 2)])
(OPER 42 JSR [] [(s putDigit)])
(OPER 94 Mov [(m EAX)] [(r 2)])
(OPER 95 Mov [(r 26)] [(i 10)])
(OPER 43 Mul [(m EAX)(m EDX)] [(m EAX)(r 26)])
(OPER 96 Mov [(r 16)] [(m EAX)])
(OPER 97 Mov [(r 17)] [(r 1)])
(OPER 44 Sub_I [(r 17)] [(r 17)(r 16)])
(OPER 45 Mov [(r 1)] [(r 17)])
)
(BB 15
(OPER 98 Mov [(m EDI)] [(r 1)])
(OPER 52 JSR [] [(s putDigit)])
(OPER 53 Jmp [] [(bb 1)])
)
)
(FUNCTION main []
(BB 2
)
(BB 3
(OPER 4 Mov [(r 2)] [(i 5)])
(OPER 5 Mov [(r 1)] [(r 2)])
(OPER 106 Cmp [(m Flags)] [(r 1)(i 5)])
(OPER 107 BNE [] [(bb 6)(m Flags)])
)
(BB 4
(OPER 8 Store [] [(i 3)(s a)(i 0)])
)
(BB 5
(OPER 11 Mov [(r 3)] [(i 0)])
(OPER 12 Mov [(r 5)] [(i 1)])
(OPER 108 Cmp [(m Flags)] [(r 5)(i 8)])
(OPER 109 BGT [] [(bb 8)(m Flags)])
)
(BB 7
(OPER 110 Mov [(r 8)] [(r 3)])
(OPER 15 Add_I [(r 8)] [(r 8)(r 5)])
(OPER 16 Mov [(r 3)] [(r 8)])
(OPER 111 Mov [(r 9)] [(r 5)])
(OPER 17 Add_I [(r 9)] [(r 9)(i 1)])
(OPER 18 Mov [(r 5)] [(r 9)])
(OPER 112 Cmp [(m Flags)] [(r 5)(i 8)])
(OPER 113 BLE [] [(bb 7)(m Flags)])
)
(BB 8
(OPER 114 Mov [(m EDX)] [(i 0)])
(OPER 115 Mov [(m EAX)] [(r 3)])
(OPER 116 Mov [(r 26)] [(i 3)])
(OPER 21 Div [(m EAX)(m EDX)] [(m EAX)(r 26)(m EDX)])
(OPER 117 Mov [(r 11)] [(m EAX)])
(OPER 22 Mov [(r 4)] [(r 11)])
(OPER 118 Mov [(m EAX)] [(r 4)])
(OPER 119 Mov [(r 27)] [(i 4)])
(OPER 23 Mul [(m EAX)(m EDX)] [(m EAX)(r 27)])
(OPER 120 Mov [(r 12)] [(m EAX)])
(OPER 24 Mov [(r 3)] [(r 12)])
(OPER 26 Load [(r 13)] [(s a)(i 0)])
(OPER 121 Mov [(m EDI)] [(r 13)])
(OPER 122 Mov [(m ESI)] [(r 1)])
(OPER 28 JSR [] [(s addThem)])
(OPER 29 Mov [(r 2)] [(m EAX)])
(OPER 123 Mov [(m EDI)] [(i 56)])
(OPER 31 JSR [] [(s putchar)])
(OPER 124 Mov [(m EDI)] [(i 61)])
(OPER 33 JSR [] [(s putchar)])
(OPER 125 Mov [(r 14)] [(r 2)])
(OPER 35 Add_I [(r 14)] [(r 14)(r 3)])
(OPER 126 Mov [(m EDI)] [(r 14)])
(OPER 36 JSR [] [(s putchar)])
(OPER 127 Mov [(m EDI)] [(i 10)])
(OPER 38 JSR [] [(s putchar)])
(OPER 39 Mov [(r 5)] [(i 0)])
(OPER 128 Cmp [(m Flags)] [(r 5)(i 10)])
(OPER 129 BGE [] [(bb 10)(m Flags)])
)
(BB 9
(OPER 130 Mov [(r 16)] [(i 48)])
(OPER 43 Add_I [(r 16)] [(r 16)(r 5)])
(OPER 131 Mov [(m EDI)] [(r 16)])
(OPER 44 JSR [] [(s putchar)])
(OPER 132 Mov [(r 17)] [(r 5)])
(OPER 45 Add_I [(r 17)] [(r 17)(i 1)])
(OPER 46 Mov [(r 5)] [(r 17)])
(OPER 133 Cmp [(m Flags)] [(r 5)(i 10)])
(OPER 134 BLT [] [(bb 9)(m Flags)])
)
(BB 10
(OPER 135 Mov [(m EDI)] [(i 10)])
(OPER 50 JSR [] [(s putchar)])
(OPER 136 Mov [(m EDI)] [(i 67)])
(OPER 52 JSR [] [(s putchar)])
(OPER 137 Mov [(m EDI)] [(i 83)])
(OPER 54 JSR [] [(s putchar)])
(OPER 138 Mov [(m EDI)] [(i 3510)])
(OPER 56 JSR [] [(s printInt)])
(OPER 139 Mov [(m EDI)] [(i 10)])
(OPER 58 JSR [] [(s putchar)])
(OPER 59 Mov [(r 1)] [(i 0)])
(OPER 60 Mov [(r 2)] [(i 1)])
(OPER 61 Mov [(r 3)] [(i 1)])
(OPER 62 Mov [(r 4)] [(i 0)])
(OPER 63 Mov [(r 5)] [(i 0)])
(OPER 140 Cmp [(m Flags)] [(r 1)(i 0)])
(OPER 141 BNE [] [(bb 13)(m Flags)])
)
(BB 11
(OPER 142 Cmp [(m Flags)] [(r 2)(i 0)])
(OPER 143 BNE [] [(bb 16)(m Flags)])
)
(BB 14
(OPER 68 Mov [(r 5)] [(i 1)])
)
(BB 12
(OPER 144 Cmp [(m Flags)] [(r 5)(i 10)])
(OPER 145 BNE [] [(bb 25)(m Flags)])
)
(BB 23
(OPER 146 Mov [(m EDI)] [(i 99)])
(OPER 84 JSR [] [(s putchar)])
(OPER 147 Mov [(m EDI)] [(i 0)])
(OPER 86 JSR [] [(s putDigit)])
(OPER 148 Mov [(m EDI)] [(i 0)])
(OPER 88 JSR [] [(s putDigit)])
(OPER 149 Mov [(m EDI)] [(i 108)])
(OPER 90 JSR [] [(s putchar)])
)
(BB 24
(OPER 150 Mov [(m EDI)] [(i 10)])
(OPER 103 JSR [] [(s putchar)])
(OPER 104 Mov [(m EAX)] [(i 0)])
)
(BB 1
(OPER 2 Return [] [(m EAX)])
)
(BB 6
(OPER 9 Store [] [(i 4)(s a)(i 0)])
(OPER 10 Jmp [] [(bb 5)])
)
(BB 22
(OPER 75 Mov [(r 5)] [(i 3)])
(OPER 76 Jmp [] [(bb 12)])
)
(BB 19
(OPER 151 Cmp [(m Flags)] [(r 4)(i 0)])
(OPER 152 BNE [] [(bb 22)(m Flags)])
)
(BB 20
(OPER 74 Mov [(r 5)] [(i 10)])
)
(BB 21
(OPER 77 Jmp [] [(bb 12)])
)
(BB 16
(OPER 153 Cmp [(m Flags)] [(r 3)(i 0)])
(OPER 154 BNE [] [(bb 19)(m Flags)])
)
(BB 17
(OPER 71 Mov [(r 5)] [(i 2)])
)
(BB 18
(OPER 78 Jmp [] [(bb 12)])
)
(BB 13
(OPER 79 Mov [(r 5)] [(i 0)])
(OPER 80 Jmp [] [(bb 12)])
)
(BB 25
(OPER 155 Mov [(m EDI)] [(i 98)])
(OPER 92 JSR [] [(s putchar)])
(OPER 156 Mov [(m EDI)] [(i 97)])
(OPER 94 JSR [] [(s putchar)])
(OPER 157 Mov [(m EDI)] [(i 100)])
(OPER 96 JSR [] [(s putchar)])
(OPER 158 Mov [(m EDI)] [(i 61)])
(OPER 98 JSR [] [(s putchar)])
(OPER 159 Mov [(m EDI)] [(r 5)])
(OPER 100 JSR [] [(s printInt)])
(OPER 101 Jmp [] [(bb 24)])
)
)