https://github.com/akkartik/mu/blob/master/subx/056trace.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 == data
16
17
18 Trace-stream:
19 0/imm32
20
21 Trace-segment:
22 0/imm32/curr
23 0/imm32/limit
24
25
26
27 _test-trace-stream:
28
29 0/imm32
30
31 0/imm32
32
33 8/imm32
34
35 00 00 00 00 00 00 00 00
36
37 == code
38
39
40
41
42
43
44 initialize-trace-stream:
45
46 55/push-EBP
47 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
48
49 50/push-EAX
50 51/push-ECX
51
52 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 .
53
54
55 68/push Trace-segment/imm32
56 51/push-ECX
57
58 e8/call new-segment/disp32
59
60 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
61
62 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-segment/disp32
63
64
65 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
66
67
68 81 5/subop/subtract 3/mod/direct 1/rm32/ECX . . . . . 0xc/imm32
69
70 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 8/disp8 .
71 $initialize-trace-stream:end:
72
73 59/pop-to-ECX
74 58/pop-to-EAX
75
76 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
77 5d/pop-to-EBP
78 c3/return
79
80
81
82 trace:
83
84 55/push-EBP
85 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
86
87 50/push-EAX
88 51/push-ECX
89 52/push-EDX
90 53/push-EBX
91 56/push-ESI
92 57/push-EDI
93
94 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 7/r32/EDI Trace-stream/disp32
95
96 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 6/r32/ESI 8/disp8 .
97
98 8b/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . .
99
100 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 2/r32/EDX 8/disp8 .
101
102
103 56/push-ESI
104
105 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 3/r32/EBX 0xc/disp8 .
106 53/push-EBX
107
108 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX . 3/r32/EBX 0xc/disp8 .
109 53/push-EBX
110
111 e8/call _append-3/disp32
112
113 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
114
115 3d/compare-EAX-and 0/imm32
116 74/jump-if-equal $trace:end/disp8
117
118 01/add 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . .
119
120 8b/copy 0/mod/indirect 7/rm32/EDI . . . 1/r32/ECX . .
121
122
123 68/push Newline/imm32
124
125 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 3/r32/EBX 0xc/disp8 .
126 53/push-EBX
127
128 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX . 3/r32/EBX 0xc/disp8 .
129 53/push-EBX
130
131 e8/call _append-3/disp32
132
133 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
134
135 01/add 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . .
136 $trace:end:
137
138 5f/pop-to-EDI
139 5e/pop-to-ESI
140 5b/pop-to-EBX
141 5a/pop-to-EDX
142 59/pop-to-ECX
143 58/pop-to-EAX
144
145 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
146 5d/pop-to-EBP
147 c3/return
148
149 test-trace-single:
150
151 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
152
153 b8/copy-to-EAX _test-trace-stream/imm32
154 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
155
156 e8/call clear-trace-stream/disp32
157
158
159 68/push "Ab"/imm32
160
161 e8/call trace/disp32
162
163 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
164
165
166 68/push "F - test-trace-single"/imm32
167 68/push 0x0a6241/imm32/Ab-newline
168
169 b8/copy-to-EAX _test-trace-stream/imm32
170 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 .
171
172 e8/call check-ints-equal/disp32
173
174 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
175
176 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
177
178 c3/return
179
180 test-trace-appends:
181
182 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
183
184 b8/copy-to-EAX _test-trace-stream/imm32
185 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
186
187 e8/call clear-trace-stream/disp32
188
189
190 68/push "C"/imm32
191
192 e8/call trace/disp32
193
194 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
195
196
197 68/push "D"/imm32
198
199 e8/call trace/disp32
200
201 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
202
203
204 68/push "F - test-trace-appends"/imm32
205 68/push 0x0a440a43/imm32/C-newline-D-newline
206
207 b8/copy-to-EAX _test-trace-stream/imm32
208 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 .
209
210 e8/call check-ints-equal/disp32
211
212 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
213
214 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
215
216 c3/return
217
218 test-trace-empty-line:
219
220 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
221
222 b8/copy-to-EAX _test-trace-stream/imm32
223 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
224
225 e8/call clear-trace-stream/disp32
226
227
228 68/push ""/imm32
229
230 e8/call trace/disp32
231
232 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
233
234
235 68/push "F - test-trace-empty-line"/imm32
236 68/push 0/imm32
237
238 b8/copy-to-EAX _test-trace-stream/imm32
239 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 .
240
241 e8/call check-ints-equal/disp32
242
243 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
244
245 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
246
247 c3/return
248
249 check-trace-contains:
250
251 55/push-EBP
252 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
253
254
255 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
256
257 e8/call rewind-stream/disp32
258
259 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
260
261
262 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
263 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
264
265 e8/call check-trace-scans-to/disp32
266
267 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
268 $check-trace-contains:end:
269
270 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
271 5d/pop-to-EBP
272 c3/return
273
274 check-trace-scans-to:
275
276 55/push-EBP
277 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
278
279 50/push-EAX
280
281
282 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
283
284 e8/call trace-scan/disp32
285
286 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
287
288
289 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
290 68/push 1/imm32
291 50/push-EAX
292
293 e8/call check-ints-equal/disp32
294
295 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
296 $check-trace-scans-to:end:
297
298 58/pop-to-EAX
299
300 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
301 5d/pop-to-EBP
302 c3/return
303
304
305 trace-scan:
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320 55/push-EBP
321 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
322
323 51/push-ECX
324 56/push-ESI
325
326 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 6/r32/ESI Trace-stream/disp32
327
328 8b/copy 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX .
329
330 ff 6/subop/push 1/mod/*+disp8 6/rm32/ESI . . . . 4/disp8 .
331 $trace-scan:loop:
332
333 39/compare 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 .
334 7d/jump-if-greater-or-equal $trace-scan:false/disp8
335
336
337 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
338 56/push-ESI
339
340 e8/call next-line-matches?/disp32
341
342 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
343
344 3d/compare-EAX-and 0/imm32
345 74/jump-if-equal $trace-scan:continue/disp8
346 $trace-scan:true:
347
348
349 56/push-ESI
350
351 e8/call skip-next-line/disp32
352
353 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
354
355 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
356
357 b8/copy-to-EAX 1/imm32/true
358 eb/jump $trace-scan:end/disp8
359 $trace-scan:continue:
360
361
362 56/push-ESI
363
364 e8/call skip-next-line/disp32
365
366 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
367 eb/jump $trace-scan:loop/disp8
368 $trace-scan:false:
369
370 8f 0/subop/pop 1/mod/*+disp8 6/rm32/ESI . . . . 4/disp8 .
371
372 b8/copy-to-EAX 0/imm32/false
373 $trace-scan:end:
374
375 59/pop-to-ECX
376
377 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
378 5d/pop-to-EBP
379 c3/return
380
381 test-trace-scan-first:
382
383 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
384
385
386 b8/copy-to-EAX _test-trace-stream/imm32
387 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
388
389 e8/call clear-trace-stream/disp32
390
391
392 68/push "Ab"/imm32
393
394 e8/call trace/disp32
395
396 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
397
398
399 68/push "Ab"/imm32
400
401 e8/call trace-scan/disp32
402
403 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
404
405
406 68/push "F - test-trace-scan-first"/imm32
407 68/push 1/imm32
408 50/push-EAX
409
410 e8/call check-ints-equal/disp32
411
412 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
413
414 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
415
416 c3/return
417
418 test-trace-scan-skips-lines-until-found:
419
420 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
421
422
423 b8/copy-to-EAX _test-trace-stream/imm32
424 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
425
426 e8/call clear-trace-stream/disp32
427
428
429 68/push "Ab"/imm32
430
431 e8/call trace/disp32
432
433 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
434
435
436 68/push "cd"/imm32
437
438 e8/call trace/disp32
439
440 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
441
442
443 68/push "cd"/imm32
444
445 e8/call trace-scan/disp32
446
447 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
448
449
450 68/push "F - test-trace-scan-skips-lines-until-found"/imm32
451 68/push 1/imm32
452 50/push-EAX
453
454 e8/call check-ints-equal/disp32
455
456 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
457
458 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
459
460 c3/return
461
462 test-trace-second-scan-starts-where-first-left-off:
463
464 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
465
466
467 b8/copy-to-EAX _test-trace-stream/imm32
468 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
469
470 e8/call clear-trace-stream/disp32
471
472
473 68/push "Ab"/imm32
474
475 e8/call trace/disp32
476
477 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
478
479
480 68/push "Ab"/imm32
481
482 e8/call trace-scan/disp32
483
484 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
485
486
487
488 68/push "Ab"/imm32
489
490 e8/call trace-scan/disp32
491
492 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
493
494
495 68/push "F - test-trace-second-scan-starts-where-first-left-off"/imm32
496 68/push 0/imm32
497 50/push-EAX
498
499 e8/call check-ints-equal/disp32
500
501 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
502
503 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
504
505 c3/return
506
507 test-trace-scan-failure-leaves-read-index-untouched:
508
509 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
510
511
512 b8/copy-to-EAX _test-trace-stream/imm32
513 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
514
515 e8/call clear-trace-stream/disp32
516
517
518 68/push "Ab"/imm32
519
520 e8/call trace/disp32
521
522 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
523
524
525 68/push "F - test-trace-second-scan-starts-where-first-left-off/precondition-failure"/imm32
526 68/push 0/imm32
527 b8/copy-to-EAX _test-trace-stream/imm32
528 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 .
529
530 e8/call check-ints-equal/disp32
531
532 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
533
534
535
536 68/push "Ax"/imm32
537
538 e8/call trace-scan/disp32
539
540 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
541
542
543
544 68/push "F - test-trace-second-scan-starts-where-first-left-off"/imm32
545 68/push 0/imm32
546 b8/copy-to-EAX _test-trace-stream/imm32
547 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 .
548
549 e8/call check-ints-equal/disp32
550
551 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
552
553 8f 0/subop/pop 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
554
555 c3/return
556
557 next-line-matches?:
558
559
560
561
562
563
564
565
566
567
568 55/push-EBP
569 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
570
571 51/push-ECX
572 52/push-EDX
573 53/push-EBX
574 56/push-ESI
575 57/push-EDI
576
577 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 2/r32/EDX 0xc/disp8 .
578
579
580 8d/copy-address 1/mod/*+disp8 2/rm32/EDX . . . 6/r32/ESI 4/disp8 .
581
582
583 8b/copy 0/mod/indirect 2/rm32/EDX . . 0/r32/EAX . .
584
585 8d/copy-address 0/mod/indirect 4/rm32/sib 6/base/ESI 0/index/EAX . 1/r32/ECX . .
586
587 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 7/r32/EDI 8/disp8 .
588
589 8d/copy-address 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 0xc/disp8 .
590
591
592 8b/copy 0/mod/indirect 7/rm32/EDI . . 0/r32/EAX . .
593
594 8d/copy-address 0/mod/indirect 4/rm32/sib 3/base/EBX 0/index/EAX . 2/r32/EDX . .
595
596
597 8b/copy 1/mod/*+disp8 7/rm32/EDI . . 0/r32/EAX 4/disp8 .
598
599 8d/copy-address 0/mod/indirect 4/rm32/sib 3/base/EBX 0/index/EAX . 7/r32/EDI . .
600 $next-line-matches?:loop:
601
602 39/compare 3/mod/direct 6/rm32/ESI . . . 1/r32/ECX . .
603 73/jump-if-greater-or-equal-unsigned $next-line-matches?:break/disp8
604
605
606 b8/copy-to-EAX 0/imm32/false
607 39/compare 3/mod/direct 7/rm32/EDI . . . 2/r32/EDX . .
608 73/jump-if-greater-or-equal-unsigned $next-line-matches?:end/disp8
609
610 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
611 31/xor 3/mod/direct 3/rm32/EAX . . . 3/r32/EAX . .
612
613 8a/copy-byte 0/mod/indirect 7/rm32/EDI . . 0/r32/EAX . .
614
615 8a/copy-byte 0/mod/indirect 6/rm32/ESI . . 3/r32/EBX . .
616
617 39/compare 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
618
619 b8/copy-to-EAX 0/imm32/false
620 75/jump-if-not-equal $next-line-matches?:end/disp8
621
622 47/increment-EDI
623
624 46/increment-ESI
625 eb/jump $next-line-matches?:loop/disp8
626 $next-line-matches?:break:
627
628 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
629
630 8a/copy-byte 0/mod/indirect 7/rm32/EDI . . 0/r32/EAX . .
631 3d/compare-EAX-and 0xa/imm32/newline
632
633 b8/copy-to-EAX 1/imm32/true
634 74/jump-if-equal $next-line-matches?:end/disp8
635 b8/copy-to-EAX 0/imm32/true
636 $next-line-matches?:end:
637
638 5f/pop-to-EDI
639 5e/pop-to-ESI
640 5b/pop-to-EBX
641 5a/pop-to-EDX
642 59/pop-to-ECX
643
644 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
645 5d/pop-to-EBP
646 c3/return
647
648 test-next-line-matches?-no-match-1:
649
650
651
652 68/push "blah blah"/imm32
653 68/push _test-stream-line-ABABA/imm32
654
655 e8/call next-line-matches?/disp32
656
657 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
658
659
660 68/push "F - test-next-line-matches?-no-match-1"/imm32
661 68/push 0/imm32
662 50/push-EAX
663
664 e8/call check-ints-equal/disp32
665
666 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
667 c3/return
668
669 test-next-line-matches?-no-match-2:
670
671
672
673 68/push ""/imm32
674 68/push _test-stream-line-ABABA/imm32
675
676 e8/call next-line-matches?/disp32
677
678 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
679
680
681 68/push "F - test-next-line-matches?-no-match-2"/imm32
682 68/push 0/imm32
683 50/push-EAX
684
685 e8/call check-ints-equal/disp32
686
687 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
688 c3/return
689
690 test-next-line-matches?-no-match-3:
691
692
693
694 68/push "AA"/imm32
695 68/push _test-stream-line-ABABA/imm32
696
697 e8/call next-line-matches?/disp32
698
699 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
700
701
702 68/push "F - test-next-line-matches?-no-match-3"/imm32
703 68/push 0/imm32
704 50/push-EAX
705
706 e8/call check-ints-equal/disp32
707
708 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
709 c3/return
710
711 test-next-line-matches?-match:
712
713
714
715 68/push "ABABA"/imm32
716 68/push _test-stream-line-ABABA/imm32
717
718 e8/call next-line-matches?/disp32
719
720 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
721
722
723 68/push "F - test-next-line-matches?-match"/imm32
724 68/push 1/imm32
725 50/push-EAX
726
727 e8/call check-ints-equal/disp32
728
729 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
730 c3/return
731
732
733 skip-next-line:
734
735
736
737
738
739
740
741
742
743
744
745
746 55/push-EBP
747 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
748
749 50/push-EAX
750 51/push-ECX
751 52/push-EDX
752 53/push-EBX
753
754 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 1/r32/ECX 8/disp8 .
755
756 8d/copy-address 1/mod/*+disp8 1/rm32/ECX . . . 2/r32/EDX 0xc/disp8 .
757
758 8b/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
759
760 8d/copy-address 0/mod/indirect 4/rm32/sib 2/base/EDX 0/index/EAX . 3/r32/EBX . .
761
762 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 4/disp8 .
763
764 8d/copy-address 0/mod/indirect 4/rm32/sib 2/base/EDX 0/index/EAX . 1/r32/ECX . .
765
766 8b/copy 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . .
767 $skip-next-line:loop:
768
769 39/compare 3/mod/direct 1/rm32/ECX . . . 3/r32/EBX . .
770 73/jump-if-greater-or-equal-unsigned $skip-next-line:end/disp8
771
772 42/increment-EDX
773
774 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
775 8a/copy-byte 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
776 3d/compare-EAX-and 0a/imm32/newline
777 74/jump-if-equal $skip-next-line:end/disp8
778
779 41/increment-ECX
780
781 eb/jump $skip-next-line:loop/disp8
782 $skip-next-line:end:
783
784 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 1/r32/ECX 8/disp8 .
785
786 89/copy 1/mod/*+disp8 1/rm32/ECX . . . 2/r32/EDX 4/disp8 .
787
788 5b/pop-to-EBX
789 5a/pop-to-EDX
790 59/pop-to-ECX
791 58/pop-to-EAX
792
793 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
794 5d/pop-to-EBP
795 c3/return
796
797 test-skip-next-line-empty:
798
799
800
801 68/push _test-stream-empty/imm32
802
803 e8/call skip-next-line/disp32
804
805 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
806
807
808 68/push "F - test-skip-next-line-empty"/imm32
809 68/push 0/imm32
810 b8/copy-to-EAX _test-stream-empty/imm32
811 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 0/r32/EAX 4/disp8 .
812 50/push-EAX
813
814 e8/call check-ints-equal/disp32
815
816 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
817 c3/return
818
819 test-skip-next-line-filled:
820
821
822
823 68/push _test-stream-filled/imm32
824
825 e8/call skip-next-line/disp32
826
827 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
828
829
830 68/push "F - test-skip-next-line-filled"/imm32
831 68/push 5/imm32
832 b8/copy-to-EAX _test-stream-filled/imm32
833 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 0/r32/EAX 4/disp8 .
834 50/push-EAX
835
836 e8/call check-ints-equal/disp32
837
838 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
839 c3/return
840
841 clear-trace-stream:
842
843 55/push-EBP
844 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
845
846 50/push-EAX
847 51/push-ECX
848
849 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
850
851 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 8/disp8 .
852
853 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 0xc/disp8 .
854
855 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
856
857 c7 0/subop/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32
858
859 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 0xc/imm32
860 $clear-trace-stream:loop:
861
862 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
863 73/jump-if-greater-or-equal-unsigned $clear-trace-stream:end/disp8
864
865 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
866
867 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 4/imm32
868 eb/jump $clear-trace-stream:loop/disp8
869 $clear-trace-stream:end:
870
871 59/pop-to-ECX
872 58/pop-to-EAX
873
874 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
875 5d/pop-to-EBP
876 c3/return
877
878
879
880
881 _append-3:
882
883 55/push-EBP
884 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
885
886 51/push-ECX
887
888
889 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 0/r32/EAX 0x10/disp8 .
890 8b/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
891 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 4/disp8 .
892 51/push-ECX
893
894 8d/copy-address 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 4/disp8 .
895 51/push-ECX
896
897 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
898
899 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
900
901 e8/call _append-4/disp32
902
903 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
904 $_append-3:end:
905
906 59/pop-to-ECX
907
908 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
909 5d/pop-to-EBP
910 c3/return
911
912
913 _append-4:
914
915 55/push-EBP
916 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
917
918 51/push-ECX
919 52/push-EDX
920 53/push-EBX
921 56/push-ESI
922 57/push-EDI
923
924 b8/copy-to-EAX 0/imm32
925
926 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 8/disp8 .
927
928 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 2/r32/EDX 0xc/disp8 .
929
930 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0x10/disp8 .
931
932 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 0x14/disp8 .
933 $_append-4:loop:
934
935 39/compare 3/mod/direct 6/rm32/ESI . . . 1/r32/ECX . .
936 73/jump-if-greater-or-equal-unsigned $_append-4:end/disp8
937
938 39/compare 3/mod/direct 7/rm32/EDI . . . 2/r32/EDX . .
939 73/jump-if-greater-or-equal-unsigned $_append-4:abort/disp8
940
941 8a/copy-byte 0/mod/indirect 6/rm32/ESI . . . 3/r32/BL . .
942 88/copy-byte 0/mod/indirect 7/rm32/EDI . . . 3/r32/BL . .
943
944 40/increment-EAX
945
946 46/increment-ESI
947
948 47/increment-EDI
949 eb/jump $_append-4:loop/disp8
950 $_append-4:end:
951
952 5f/pop-to-EDI
953 5e/pop-to-ESI
954 5b/pop-to-EBX
955 5a/pop-to-EDX
956 59/pop-to-ECX
957
958 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
959 5d/pop-to-EBP
960 c3/return
961
962 $_append-4:abort:
963
964
965 68/push "stream overflow\n"/imm32
966 68/push 2/imm32/stderr
967
968 e8/call _write/disp32
969
970 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
971
972 bb/copy-to-EBX 1/imm32
973 b8/copy-to-EAX 1/imm32/exit
974 cd/syscall 0x80/imm8
975
976
977 == data
978
979 _test-stream-line-ABABA:
980
981 8/imm32
982
983 0/imm32
984
985 8/imm32
986
987 41 42 41 42 41 0a 00 00
988
989 _test-stream-empty:
990
991 0/imm32
992
993 0/imm32
994
995 8/imm32
996
997 00 00 00 00 00 00 00 00
998
999 _test-stream-filled:
1000
1001 8/imm32
1002
1003 0/imm32
1004
1005 8/imm32
1006
1007 41 41 41 41 0a 41 41 41
1008
1009