https://github.com/akkartik/mu/blob/master/subx/055trace.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 == data
23
24
25 Trace-stream:
26 00 00 00 00
27
28
29
30 _test-trace-stream:
31
32 00 00 00 00
33
34 00 00 00 00
35
36 08 00 00 00
37
38 00 00 00 00 00 00 00 00
39
40 == code
41
42
43
44
45
46
47 e8/call run-tests/disp32
48
49 8b/copy 0/mod/indirect 5/rm32/.disp32 3/r32/EBX Num-test-failures/disp32
50 b8/copy-to-EAX 1/imm32
51 cd/syscall 0x80/imm8
52
53
54
55 initialize-trace-stream:
56
57
58 68/push 0x1000/imm32/N
59
60 e8/call new-segment/disp32
61
62 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
63
64 89/copy 0/mod/indirect 5/rm32/.disp32 0/r32/EAX Trace-stream/disp32
65
66 c7 0/copy 1/mod/*+disp8 0/rm32/EAX 8/disp8 0xff4/imm32
67 c3/return
68
69
70
71 trace:
72
73 55/push-EBP
74 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
75
76 50/push-EAX
77 51/push-ECX
78 52/push-EDX
79 53/push-EBX
80 56/push-ESI
81 57/push-EDI
82
83 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 7/r32/EDI 8/disp8
84
85 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 6/r32/ESI 0xc/disp8
86
87 8b/copy 0/mod/indirect 7/rm32/EDI 1/r32/ECX
88
89 8b/copy 1/mod/*+disp8 7/rm32/EDI 2/r32/EDX 8/disp8
90
91
92 56/push-ESI
93
94 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX 3/r32/EBX 0xc/disp8
95 53/push-EBX
96
97 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX 3/r32/EBX 0xc/disp8
98 53/push-EBX
99
100 e8/call _append-3/disp32
101
102 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
103
104 81 7/subop/compare 3/mod/direct 0/rm32/EAX 0/imm32
105 74/jump-if-equal $trace:end/disp8
106
107 01/add 0/mod/indirect 7/rm32/EDI 0/r32/EAX
108
109 8b/copy 0/mod/indirect 7/rm32/EDI 1/r32/ECX
110
111
112 68/push Newline/imm32
113
114 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX 3/r32/EBX 0xc/disp8
115 53/push-EBX
116
117 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX 3/r32/EBX 0xc/disp8
118 53/push-EBX
119
120 e8/call _append-3/disp32
121
122 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
123
124 01/add 0/mod/indirect 7/rm32/EDI 0/r32/EAX
125 $trace:end:
126
127 5f/pop-to-EDI
128 5e/pop-to-ESI
129 5b/pop-to-EBX
130 5a/pop-to-EDX
131 59/pop-to-ECX
132 58/pop-to-EAX
133
134 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
135 5d/pop-to-EBP
136 c3/return
137
138 clear-trace-stream:
139
140 55/push-EBP
141 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
142
143 50/push-EAX
144 51/push-ECX
145
146 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8
147
148 8b/copy 1/mod/*+disp8 0/rm32/EAX 1/r32/ECX 8/disp8
149
150 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX 1/r32/ECX 0xc/disp8
151
152 c7/copy 0/mod/direct 0/rm32/EAX 0/imm32
153
154 c7/copy 1/mod/*+disp8 0/rm32/EAX 4/disp8 0/imm32
155
156 81 0/subop/add 3/mod/direct 0/rm32/EAX 0xc/imm32
157
158 $clear-trace-stream:loop:
159
160 39/compare 3/mod/direct 0/rm32/EAX 1/r32/ECX
161 7d/jump-if-greater-or-equal $clear-trace-stream:end/disp8
162
163 c7/copy 0/mod/direct 0/rm32/EAX 0/imm32
164
165 81 0/subop/add 3/mod/direct 0/rm32/EAX 4/imm32
166 eb/jump $clear-trace-stream:loop/disp8
167 $clear-trace-stream:end:
168
169 59/pop-to-ECX
170 58/pop-to-EAX
171
172 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
173 5d/pop-to-EBP
174 c3/return
175
176
177
178 test-trace-single:
179
180
181 68/push _test-trace-stream/imm32
182
183 e8/call clear-trace-stream/disp32
184
185 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
186
187
188 68/push "Ab"/imm32
189 68/push _test-trace-stream/imm32
190
191 e8/call trace/disp32
192
193 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
194
195
196 68/push "F - test-trace-single"/imm32
197 68/push 0x0a6241/imm32/Ab-newline
198
199 b8/copy-to-EAX _test-trace-stream/imm32
200 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
201
202 e8/call check-ints-equal/disp32
203
204 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
205
206 c3/return
207
208 test-trace-appends:
209
210
211 68/push _test-trace-stream/imm32
212
213 e8/call clear-trace-stream/disp32
214
215 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
216
217
218 68/push "C"/imm32
219 68/push _test-trace-stream/imm32
220
221 e8/call trace/disp32
222
223 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
224
225
226 68/push "D"/imm32
227 68/push _test-trace-stream/imm32
228
229 e8/call trace/disp32
230
231 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
232
233
234 68/push "F - test-trace-appends"/imm32
235 68/push 0x0a440a43/imm32/C-newline-D-newline
236
237 b8/copy-to-EAX _test-trace-stream/imm32
238 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
239
240 e8/call check-ints-equal/disp32
241
242 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
243
244 c3/return
245
246 test-trace-empty-line:
247
248
249 68/push _test-trace-stream/imm32
250
251 e8/call clear-trace-stream/disp32
252
253 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
254
255
256 68/push ""/imm32
257 68/push _test-trace-stream/imm32
258
259 e8/call trace/disp32
260
261 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
262
263
264 68/push "F - test-trace-empty-line"/imm32
265 68/push 0/imm32
266
267 b8/copy-to-EAX _test-trace-stream/imm32
268 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
269
270 e8/call check-ints-equal/disp32
271
272 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
273
274 c3/return
275
276
277
278
279 _append-3:
280
281 55/push-EBP
282 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
283
284 51/push-ECX
285
286
287 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 0x10/disp8
288 8b/copy 0/mod/indirect 0/rm32/EAX 1/r32/ECX
289 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX 1/r32/ECX 4/disp8
290 51/push-ECX
291
292 8d/copy-address 1/mod/*+disp8 0/rm32/EAX 1/r32/ECX 4/disp8
293 51/push-ECX
294
295 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0xc/disp8
296
297 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8
298
299 e8/call _append-4/disp32
300
301 81 0/subop/add 3/mod/direct 4/rm32/ESP 0x10/imm32
302 $_append-3:end:
303
304 59/pop-to-ECX
305
306 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
307 5d/pop-to-EBP
308 c3/return
309
310
311 _append-4:
312
313 55/push-EBP
314 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
315
316 51/push-ECX
317 52/push-EDX
318 53/push-EBX
319 56/push-ESI
320 57/push-EDI
321
322 b8/copy-to-EAX 0/imm32
323
324 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 7/r32/EDI 8/disp8
325
326 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 2/r32/EDX 0xc/disp8
327
328 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 6/r32/ESI 0x10/disp8
329
330 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 1/r32/ECX 0x14/disp8
331 $_append-4:loop:
332
333 39/compare 3/mod/direct 6/rm32/ESI 1/r32/ECX
334 7d/jump-if-greater-or-equal $_append-4:end/disp8
335
336 39/compare 3/mod/direct 7/rm32/EDI 2/r32/EDX
337 7d/jump-if-greater-or-equal $_append-4:end/disp8
338
339 8a/copy-byte 0/mod/indirect 6/rm32/ESI 3/r32/BL
340 88/copy-byte 0/mod/indirect 7/rm32/EDI 3/r32/BL
341
342 40/increment-EAX
343 46/increment-ESI
344 47/increment-EDI
345 eb/jump $_append-4:loop/disp8
346 $_append-4:end:
347
348 5f/pop-to-EDI
349 5e/pop-to-ESI
350 5b/pop-to-EBX
351 5a/pop-to-EDX
352 59/pop-to-ECX
353
354 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
355 5d/pop-to-EBP
356 c3/return
357
358