https://github.com/akkartik/mu/blob/master/apps/subx-common.subx
1
2
3 == data
4
5
6 Heap-size:
7 0x200000/imm32/2MB
8
9
10 Segment-size:
11 0x80000/imm32/512KB
12
13
14 Input-size:
15 0x100000/imm32/1MB
16
17
18 Max-labels:
19 0x10000/imm32/4K-labels/64KB
20
21 == code
22
23
24
25
26
27
28 next-word:
29
30 55/push-ebp
31 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
32
33 50/push-eax
34 51/push-ecx
35 56/push-esi
36 57/push-edi
37
38 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
39
40 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 0xc/disp8 .
41
42
43 68/push 0x20/imm32/space
44 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
45
46 e8/call skip-chars-matching/disp32
47
48 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
49 $next-word:check0:
50
51
52 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
53
54 3b/compare 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
55 7c/jump-if-lesser $next-word:check-for-comment/disp8
56
57 c7 0/subop/copy 0/mod/direct 7/rm32/edi . . . . . 0/imm32
58 c7 0/subop/copy 1/mod/*+disp8 7/rm32/edi . . . . 4/disp8 0/imm32
59 eb/jump $next-word:end/disp8
60 $next-word:check-for-comment:
61
62 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
63 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/eax 0xc/disp8 .
64 89/copy 0/mod/indirect 7/rm32/edi . . . 0/r32/eax . .
65
66
67 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
68 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/AL 0xc/disp8 .
69
70 3d/compare-eax-and 0x23/imm32/pound
71 75/jump-if-not-equal $next-word:regular-word/disp8
72 $next-word:comment:
73
74 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
75 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax . 0/r32/eax 0xc/disp8 .
76 89/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
77
78 89/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
79
80 eb/jump $next-word:end/disp8
81 $next-word:regular-word:
82
83
84 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
85
86 e8/call skip-chars-not-matching-whitespace/disp32
87
88 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
89
90 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
91 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/eax 0xc/disp8 .
92 89/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
93 $next-word:end:
94
95 5f/pop-to-edi
96 5e/pop-to-esi
97 59/pop-to-ecx
98 58/pop-to-eax
99
100 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
101 5d/pop-to-ebp
102 c3/return
103
104 test-next-word:
105
106 55/push-ebp
107 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
108
109
110
111 68/push _test-stream/imm32
112
113 e8/call clear-stream/disp32
114
115 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
116
117 68/push 0/imm32/end
118 68/push 0/imm32/start
119 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
120
121
122 68/push " ab"/imm32
123 68/push _test-stream/imm32
124
125 e8/call write/disp32
126
127 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
128
129
130 51/push-ecx
131 68/push _test-stream/imm32
132
133 e8/call next-word/disp32
134
135 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
136
137
138
139 68/push "F - test-next-word: start"/imm32
140 68/push 0xe/imm32
141
142 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
143 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
144 50/push-eax
145
146 e8/call check-ints-equal/disp32
147
148 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
149
150
151
152 68/push "F - test-next-word: end"/imm32
153 68/push 0x10/imm32
154
155 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
156 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
157 50/push-eax
158
159 e8/call check-ints-equal/disp32
160
161 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
162
163 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
164 5d/pop-to-ebp
165 c3/return
166
167 test-next-word-returns-whole-comment:
168
169 55/push-ebp
170 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
171
172
173
174 68/push _test-stream/imm32
175
176 e8/call clear-stream/disp32
177
178 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
179
180 68/push 0/imm32/end
181 68/push 0/imm32/start
182 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
183
184
185 68/push " # a"/imm32
186 68/push _test-stream/imm32
187
188 e8/call write/disp32
189
190 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
191
192
193 51/push-ecx
194 68/push _test-stream/imm32
195
196 e8/call next-word/disp32
197
198 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
199
200
201
202 68/push "F - test-next-word-returns-whole-comment: start"/imm32
203 68/push 0xe/imm32
204
205 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
206 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
207 50/push-eax
208
209 e8/call check-ints-equal/disp32
210
211 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
212
213
214
215 68/push "F - test-next-word-returns-whole-comment: end"/imm32
216 68/push 0x11/imm32
217
218 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
219 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
220 50/push-eax
221
222 e8/call check-ints-equal/disp32
223
224 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
225
226 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
227 5d/pop-to-ebp
228 c3/return
229
230 test-next-word-returns-empty-string-on-eof:
231
232 55/push-ebp
233 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
234
235
236
237 68/push _test-stream/imm32
238
239 e8/call clear-stream/disp32
240
241 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
242
243 68/push 0/imm32/end
244 68/push 0/imm32/start
245 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
246
247
248
249 51/push-ecx
250 68/push _test-stream/imm32
251
252 e8/call next-word/disp32
253
254 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
255
256
257 68/push "F - test-next-word-returns-empty-string-on-eof"/imm32
258 68/push 0/imm32
259
260 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
261 2b/subtract 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
262 50/push-eax
263
264 e8/call check-ints-equal/disp32
265
266 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
267
268 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
269 5d/pop-to-ebp
270 c3/return
271
272
273
274
275
276
277 write-stream-data:
278
279 55/push-ebp
280 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
281
282 50/push-eax
283 51/push-ecx
284 56/push-esi
285
286 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0xc/disp8 .
287
288
289 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
290 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax . 0/r32/eax 0xc/disp8 .
291 50/push-eax
292
293 8d/copy-address 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 0xc/disp8 .
294 50/push-eax
295
296 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
297
298
299 51/push-ecx
300 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
301
302 e8/call write-slice-buffered/disp32
303
304 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
305 $write-stream-data:end:
306
307 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
308
309 5e/pop-to-esi
310 59/pop-to-ecx
311 58/pop-to-eax
312
313 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
314 5d/pop-to-ebp
315 c3/return
316
317 test-write-stream-data:
318
319 55/push-ebp
320 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
321
322
323
324 68/push _test-output-stream/imm32
325
326 e8/call clear-stream/disp32
327
328 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
329
330
331 b8/copy-to-eax _test-output-buffered-file/imm32
332 05/add-to-eax 4/imm32
333 50/push-eax
334
335 e8/call clear-stream/disp32
336
337 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
338
339
340 68/push _test-input-stream/imm32
341
342 e8/call clear-stream/disp32
343
344 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
345
346
347
348 68/push "abcd"/imm32
349 68/push _test-input-stream/imm32
350
351 e8/call write/disp32
352
353 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
354
355
356 68/push _test-input-stream/imm32
357 68/push _test-output-buffered-file/imm32
358
359 e8/call write-stream-data/disp32
360
361 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
362
363
364
365 68/push _test-output-buffered-file/imm32
366
367 e8/call flush/disp32
368
369 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
370
371
372 68/push "F - test-write-stream-data"/imm32
373 68/push "abcd"/imm32
374 68/push _test-output-stream/imm32
375
376 e8/call check-stream-equal/disp32
377
378 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
379
380 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
381 5d/pop-to-ebp
382 c3/return
383
384 has-metadata?:
385
386
387
388
389
390
391
392
393
394
395 55/push-ebp
396 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
397
398 51/push-ecx
399 52/push-edx
400 56/push-esi
401 57/push-edi
402
403 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
404
405 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 2/r32/edx 4/disp8 .
406
407 68/push 0/imm32/end
408 68/push 0/imm32/start
409 89/copy 3/mod/direct 7/rm32/edi . . . 4/r32/esp . .
410
411
412 57/push-edi
413 68/push 0x2f/imm32/slash
414 52/push-edx
415 ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . .
416
417 e8/call next-token-from-slice/disp32
418
419 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
420
421 8b/copy 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 4/disp8 .
422 $has-metadata?:loop:
423
424
425 57/push-edi
426 68/push 0x2f/imm32/slash
427 52/push-edx
428 51/push-ecx
429
430 e8/call next-token-from-slice/disp32
431
432 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
433
434
435
436 57/push-edi
437
438 e8/call slice-empty?/disp32
439
440 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
441
442 3d/compare-eax-and 0/imm32
443 75/jump-if-not-equal $has-metadata?:false/disp8
444
445
446
447 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
448 57/push-edi
449
450 e8/call slice-equal?/disp32
451
452 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
453
454 3d/compare-eax-and 0/imm32
455 75/jump-if-not-equal $has-metadata?:true/disp8
456
457 8b/copy 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 4/disp8 .
458 eb/jump $has-metadata?:loop/disp8
459 $has-metadata?:true:
460 b8/copy-to-eax 1/imm32/true
461 eb/jump $has-metadata?:end/disp8
462 $has-metadata?:false:
463 b8/copy-to-eax 0/imm32/false
464 $has-metadata?:end:
465
466 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
467
468 5f/pop-to-edi
469 5e/pop-to-esi
470 5a/pop-to-edx
471 59/pop-to-ecx
472
473 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
474 5d/pop-to-ebp
475 c3/return
476
477 test-has-metadata-true:
478
479 55/push-ebp
480 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
481
482 b8/copy-to-eax "ab/imm32"/imm32
483 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
484 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
485 05/add-to-eax 4/imm32
486
487 51/push-ecx
488 50/push-eax
489 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
490
491
492 68/push "imm32"/imm32
493 56/push-esi
494
495 e8/call has-metadata?/disp32
496
497 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
498
499
500 68/push "F - test-has-metadata-true"/imm32
501 68/push 1/imm32/true
502 50/push-eax
503
504 e8/call check-ints-equal/disp32
505
506 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
507
508 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
509 5d/pop-to-ebp
510 c3/return
511
512 test-has-metadata-false:
513
514 55/push-ebp
515 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
516
517 b8/copy-to-eax "ab/c"/imm32
518 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
519 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
520 05/add-to-eax 4/imm32
521
522 51/push-ecx
523 50/push-eax
524 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
525
526
527 68/push "d"/imm32
528 56/push-esi
529
530 e8/call has-metadata?/disp32
531
532 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
533
534
535 68/push "F - test-has-metadata-false"/imm32
536 68/push 0/imm32/false
537 50/push-eax
538
539 e8/call check-ints-equal/disp32
540
541 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
542
543 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
544 5d/pop-to-ebp
545 c3/return
546
547 test-has-metadata-ignore-name:
548
549 55/push-ebp
550 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
551
552 b8/copy-to-eax "a/b"/imm32
553 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
554 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
555 05/add-to-eax 4/imm32
556
557 51/push-ecx
558 50/push-eax
559 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
560
561
562 68/push "a"/imm32
563 56/push-esi
564
565 e8/call has-metadata?/disp32
566
567 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
568
569
570 68/push "F - test-has-metadata-ignore-name"/imm32
571 68/push 0/imm32/false
572 50/push-eax
573
574 e8/call check-ints-equal/disp32
575
576 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
577
578 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
579 5d/pop-to-ebp
580 c3/return
581
582 test-has-metadata-multiple-true:
583
584 55/push-ebp
585 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
586
587 b8/copy-to-eax "a/b/c"/imm32
588 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
589 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
590 05/add-to-eax 4/imm32
591
592 51/push-ecx
593 50/push-eax
594 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
595
596
597 68/push "c"/imm32
598 56/push-esi
599
600 e8/call has-metadata?/disp32
601
602 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
603
604
605 68/push "F - test-has-metadata-multiple-true"/imm32
606 68/push 1/imm32/true
607 50/push-eax
608
609 e8/call check-ints-equal/disp32
610
611 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
612
613 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
614 5d/pop-to-ebp
615 c3/return
616
617 test-has-metadata-multiple-false:
618
619 55/push-ebp
620 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
621
622 b8/copy-to-eax "a/b/c"/imm32
623 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
624 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
625 05/add-to-eax 4/imm32
626
627 51/push-ecx
628 50/push-eax
629 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
630
631
632 68/push "d"/imm32
633 56/push-esi
634
635 e8/call has-metadata?/disp32
636
637 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
638
639
640 68/push "F - test-has-metadata-multiple-false"/imm32
641 68/push 0/imm32/false
642 50/push-eax
643
644 e8/call check-ints-equal/disp32
645
646 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
647
648 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
649 5d/pop-to-ebp
650 c3/return
651
652
653
654
655
656 emit:
657
658 55/push-ebp
659 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
660
661 50/push-eax
662 56/push-esi
663 57/push-edi
664
665 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0xc/disp8 .
666
667 68/push 0/imm32/end
668 68/push 0/imm32/start
669 89/copy 3/mod/direct 7/rm32/edi . . . 4/r32/esp . .
670
671
672 57/push-edi
673 68/push 0x2f/imm32/slash
674 ff 6/subop/push 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 .
675 ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . .
676
677 e8/call next-token-from-slice/disp32
678
679 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
680
681
682
683 57/push-edi
684
685 e8/call is-valid-name?/disp32
686
687 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
688
689 3d/compare-eax-and 0/imm32
690 74/jump-if-equal $emit:hex-int/disp8
691 $emit:name:
692
693
694 56/push-esi
695 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
696
697 e8/call write-slice-buffered/disp32
698
699 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
700
701
702 68/push " "/imm32
703 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
704
705 e8/call write-buffered/disp32
706
707 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
708
709 eb/jump $emit:end/disp8
710
711
712
713
714
715 $emit:hex-int:
716
717
718 57/push-edi
719
720 e8/call parse-hex-int/disp32
721
722 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
723
724
725 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x10/disp8 .
726 50/push-eax
727 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
728
729 e8/call emit-hex/disp32
730
731 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
732 $emit:end:
733
734 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
735
736 5f/pop-to-edi
737 5e/pop-to-esi
738 58/pop-to-eax
739
740 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
741 5d/pop-to-ebp
742 c3/return
743
744 test-emit-number:
745
746 55/push-ebp
747 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
748
749
750
751 68/push _test-output-stream/imm32
752
753 e8/call clear-stream/disp32
754
755 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
756
757
758 b8/copy-to-eax _test-output-buffered-file/imm32
759 05/add-to-eax 4/imm32
760 50/push-eax
761
762 e8/call clear-stream/disp32
763
764 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
765
766 b8/copy-to-eax "30"/imm32
767 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
768 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
769 05/add-to-eax 4/imm32
770
771 51/push-ecx
772 50/push-eax
773 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
774
775
776 68/push 1/imm32
777 51/push-ecx
778 68/push _test-output-buffered-file/imm32
779
780 e8/call emit/disp32
781
782 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
783
784
785 68/push _test-output-buffered-file/imm32
786
787 e8/call flush/disp32
788
789 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
790
791
792 68/push "F - test-emit-number/1"/imm32
793 68/push "30 "/imm32
794 68/push _test-output-stream/imm32
795
796 e8/call check-stream-equal/disp32
797
798 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
799
800 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
801 5d/pop-to-ebp
802 c3/return
803
804 test-emit-negative-number:
805
806
807 55/push-ebp
808 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
809
810
811
812 68/push _test-output-stream/imm32
813
814 e8/call clear-stream/disp32
815
816 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
817
818
819 b8/copy-to-eax _test-output-buffered-file/imm32
820 05/add-to-eax 4/imm32
821 50/push-eax
822
823 e8/call clear-stream/disp32
824
825 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
826
827 b8/copy-to-eax "-2"/imm32
828 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
829 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
830 05/add-to-eax 4/imm32
831
832 51/push-ecx
833 50/push-eax
834 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
835
836
837 68/push 2/imm32
838 51/push-ecx
839 68/push _test-output-buffered-file/imm32
840
841 e8/call emit/disp32
842
843 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
844
845
846 68/push _test-output-buffered-file/imm32
847
848 e8/call flush/disp32
849
850 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
851
852
853 68/push "F - test-emit-number/1"/imm32
854 68/push "fe ff "/imm32
855 68/push _test-output-stream/imm32
856
857 e8/call check-stream-equal/disp32
858
859 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
860
861 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
862 5d/pop-to-ebp
863 c3/return
864
865 test-emit-number-with-metadata:
866
867 55/push-ebp
868 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
869
870
871
872 68/push _test-output-stream/imm32
873
874 e8/call clear-stream/disp32
875
876 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
877
878
879 b8/copy-to-eax _test-output-buffered-file/imm32
880 05/add-to-eax 4/imm32
881 50/push-eax
882
883 e8/call clear-stream/disp32
884
885 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
886
887 b8/copy-to-eax "-2/foo"/imm32
888 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
889 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
890 05/add-to-eax 4/imm32
891
892 51/push-ecx
893 50/push-eax
894 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
895
896
897 68/push 2/imm32
898 51/push-ecx
899 68/push _test-output-buffered-file/imm32
900
901 e8/call emit/disp32
902
903 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
904
905
906 68/push _test-output-buffered-file/imm32
907
908 e8/call flush/disp32
909
910 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
911
912
913
914 68/push "F - test-emit-number-with-metadata"/imm32
915 68/push "fe ff "/imm32
916 68/push _test-output-stream/imm32
917
918 e8/call check-stream-equal/disp32
919
920 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
921
922 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
923 5d/pop-to-ebp
924 c3/return
925
926 test-emit-non-number:
927
928 55/push-ebp
929 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
930
931
932
933 68/push _test-output-stream/imm32
934
935 e8/call clear-stream/disp32
936
937 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
938
939
940 b8/copy-to-eax _test-output-buffered-file/imm32
941 05/add-to-eax 4/imm32
942 50/push-eax
943
944 e8/call clear-stream/disp32
945
946 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
947
948 b8/copy-to-eax "xyz"/imm32
949 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
950 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
951 05/add-to-eax 4/imm32
952
953 51/push-ecx
954 50/push-eax
955 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
956
957
958 68/push 2/imm32
959 51/push-ecx
960 68/push _test-output-buffered-file/imm32
961
962 e8/call emit/disp32
963
964 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
965
966
967 68/push _test-output-buffered-file/imm32
968
969 e8/call flush/disp32
970
971 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
972
973
974 68/push "F - test-emit-non-number"/imm32
975 68/push "xyz "/imm32
976 68/push _test-output-stream/imm32
977
978 e8/call check-stream-equal/disp32
979
980 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
981
982 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
983 5d/pop-to-ebp
984 c3/return
985
986 test-emit-non-number-with-metadata:
987
988 55/push-ebp
989 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
990
991
992
993 68/push _test-output-stream/imm32
994
995 e8/call clear-stream/disp32
996
997 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
998
999
1000 b8/copy-to-eax _test-output-buffered-file/imm32
1001 05/add-to-eax 4/imm32
1002 50/push-eax
1003
1004 e8/call clear-stream/disp32
1005
1006 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1007
1008 b8/copy-to-eax "xyz/"/imm32
1009 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1010 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1011 05/add-to-eax 4/imm32
1012
1013 51/push-ecx
1014 50/push-eax
1015 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1016
1017
1018 68/push 2/imm32
1019 51/push-ecx
1020 68/push _test-output-buffered-file/imm32
1021
1022 e8/call emit/disp32
1023
1024 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1025
1026
1027 68/push _test-output-buffered-file/imm32
1028
1029 e8/call flush/disp32
1030
1031 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1032
1033
1034 68/push "F - test-emit-non-number-with-metadata"/imm32
1035 68/push "xyz/ "/imm32
1036 68/push _test-output-stream/imm32
1037
1038 e8/call check-stream-equal/disp32
1039
1040 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1041
1042 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1043 5d/pop-to-ebp
1044 c3/return
1045
1046 test-emit-non-number-with-all-hex-digits-and-metadata:
1047
1048 55/push-ebp
1049 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1050
1051
1052
1053 68/push _test-output-stream/imm32
1054
1055 e8/call clear-stream/disp32
1056
1057 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1058
1059
1060 b8/copy-to-eax _test-output-buffered-file/imm32
1061 05/add-to-eax 4/imm32
1062 50/push-eax
1063
1064 e8/call clear-stream/disp32
1065
1066 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1067
1068 b8/copy-to-eax "abcd/xyz"/imm32
1069 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1070 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1071 05/add-to-eax 4/imm32
1072
1073 51/push-ecx
1074 50/push-eax
1075 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1076
1077
1078 68/push 2/imm32
1079 51/push-ecx
1080 68/push _test-output-buffered-file/imm32
1081
1082 e8/call emit/disp32
1083
1084 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1085
1086
1087 68/push _test-output-buffered-file/imm32
1088
1089 e8/call flush/disp32
1090
1091 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1092 +-- 26 lines: #? # dump output ---------------------------------------------------------------------------------------------------------------------------
1118
1119
1120 68/push "F - test-emit-non-number-with-all-hex-digits"/imm32
1121 68/push "abcd/xyz "/imm32
1122 68/push _test-output-stream/imm32
1123
1124 e8/call check-stream-equal/disp32
1125
1126 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1127
1128 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1129 5d/pop-to-ebp
1130 c3/return
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140 is-valid-name?:
1141
1142 55/push-ebp
1143 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1144
1145 51/push-ecx
1146 56/push-esi
1147
1148 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
1149
1150 8b/copy 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . .
1151
1152 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
1153 $is-valid-name?:check0:
1154
1155 39/compare 3/mod/direct 1/rm32/ecx . . . 0/r32/eax . .
1156 73/jump-if-greater-or-equal-unsigned $is-valid-name?:false/disp8
1157 $is-valid-name?:check1:
1158
1159 29/subtract 3/mod/direct 0/rm32/eax . . . 1/r32/ecx . .
1160
1161 3d/compare-eax-and 2/imm32
1162 74/jump-if-equal $is-valid-name?:false/disp8
1163 $is-valid-name?:check2:
1164
1165 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
1166 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
1167
1168 3d/compare-eax-and 2d/imm32/-
1169 74/jump-if-equal $is-valid-name?:false/disp8
1170 $is-valid-name?:check3a:
1171
1172 3d/compare-eax-with 30/imm32/0
1173 7c/jump-if-lesser $is-valid-name?:true/disp8
1174 $is-valid-name?:check3b:
1175
1176 3d/compare-eax-with 39/imm32/9
1177 7f/jump-if-greater $is-valid-name?:true/disp8
1178 $is-valid-name?:false:
1179
1180 b8/copy-to-eax 0/imm32/false
1181 eb/jump $is-valid-name?:end/disp8
1182 $is-valid-name?:true:
1183
1184 b8/copy-to-eax 1/imm32/true
1185 $is-valid-name?:end:
1186
1187 5e/pop-to-esi
1188 59/pop-to-ecx
1189
1190 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1191 5d/pop-to-ebp
1192 c3/return
1193
1194 test-is-valid-name-digit-prefix:
1195
1196 55/push-ebp
1197 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1198
1199 b8/copy-to-eax "34"/imm32
1200 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1201 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1202 05/add-to-eax 4/imm32
1203
1204 51/push-ecx
1205 50/push-eax
1206 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1207
1208
1209 51/push-ecx
1210
1211 e8/call is-valid-name?/disp32
1212
1213 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1214
1215
1216 68/push "F - test-is-valid-name-digit-prefix"/imm32
1217 68/push 0/imm32/false
1218 50/push-eax
1219
1220 e8/call check-ints-equal/disp32
1221
1222 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1223
1224 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1225 5d/pop-to-ebp
1226 c3/return
1227
1228 test-is-valid-name-negative-prefix:
1229
1230 55/push-ebp
1231 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1232
1233 b8/copy-to-eax "-0x34"/imm32
1234 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1235 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1236 05/add-to-eax 4/imm32
1237
1238 51/push-ecx
1239 50/push-eax
1240 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1241
1242
1243 51/push-ecx
1244
1245 e8/call is-valid-name?/disp32
1246
1247 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1248
1249
1250 68/push "F - test-is-valid-name-negative-prefix"/imm32
1251 68/push 0/imm32/false
1252 50/push-eax
1253
1254 e8/call check-ints-equal/disp32
1255
1256 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1257
1258 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1259 5d/pop-to-ebp
1260 c3/return
1261
1262 test-is-valid-name-0x-prefix:
1263
1264 55/push-ebp
1265 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1266
1267 b8/copy-to-eax "0x34"/imm32
1268 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1269 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1270 05/add-to-eax 4/imm32
1271
1272 51/push-ecx
1273 50/push-eax
1274 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1275
1276
1277 51/push-ecx
1278
1279 e8/call is-valid-name?/disp32
1280
1281 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1282
1283
1284 68/push "F - test-is-valid-name-0x-prefix"/imm32
1285 68/push 0/imm32/false
1286 50/push-eax
1287
1288 e8/call check-ints-equal/disp32
1289
1290 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1291
1292 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1293 5d/pop-to-ebp
1294 c3/return
1295
1296 test-is-valid-name-starts-with-pre-digit:
1297
1298 55/push-ebp
1299 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1300
1301 b8/copy-to-eax "/03"/imm32
1302 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1303 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1304 05/add-to-eax 4/imm32
1305
1306 51/push-ecx
1307 50/push-eax
1308 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1309
1310
1311 51/push-ecx
1312
1313 e8/call is-valid-name?/disp32
1314
1315 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1316
1317
1318 68/push "F - test-is-valid-name-starts-with-pre-digit"/imm32
1319 68/push 1/imm32/true
1320 50/push-eax
1321
1322 e8/call check-ints-equal/disp32
1323
1324 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1325
1326 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1327 5d/pop-to-ebp
1328 c3/return
1329
1330 test-is-valid-name-starts-with-post-digit:
1331
1332 55/push-ebp
1333 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1334
1335 b8/copy-to-eax "q34"/imm32
1336 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1337 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1338 05/add-to-eax 4/imm32
1339
1340 51/push-ecx
1341 50/push-eax
1342 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1343
1344
1345 51/push-ecx
1346
1347 e8/call is-valid-name?/disp32
1348
1349 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1350
1351
1352 68/push "F - test-is-valid-name-starts-with-post-digit"/imm32
1353 68/push 1/imm32/true
1354 50/push-eax
1355
1356 e8/call check-ints-equal/disp32
1357
1358 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1359
1360 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1361 5d/pop-to-ebp
1362 c3/return
1363
1364 test-is-valid-name-starts-with-digit:
1365
1366 55/push-ebp
1367 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1368
1369 b8/copy-to-eax "0x34"/imm32
1370 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1371 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1372 05/add-to-eax 4/imm32
1373
1374 51/push-ecx
1375 50/push-eax
1376 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1377
1378
1379 51/push-ecx
1380
1381 e8/call is-valid-name?/disp32
1382
1383 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1384
1385
1386 68/push "F - test-is-valid-name-starts-with-digit"/imm32
1387 68/push 0/imm32/false
1388 50/push-eax
1389
1390 e8/call check-ints-equal/disp32
1391
1392 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1393
1394 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1395 5d/pop-to-ebp
1396 c3/return
1397
1398
1399 emit-hex:
1400
1401 55/push-ebp
1402 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1403
1404 50/push-eax
1405 51/push-ecx
1406 52/push-edx
1407 53/push-ebx
1408 57/push-edi
1409
1410 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
1411
1412 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 3/r32/ebx 0xc/disp8 .
1413
1414 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0x10/disp8 .
1415
1416 31/xor 3/mod/direct 1/rm32/ecx . . . 1/r32/ecx . .
1417 $emit-hex:loop:
1418
1419 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
1420 7d/jump-if-greater-or-equal $emit-hex:end/disp8
1421
1422
1423 53/push-ebx
1424 57/push-edi
1425
1426 e8/call print-byte-buffered/disp32
1427
1428 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1429
1430
1431 68/push 0x20/imm32/space
1432 57/push-edi
1433
1434 e8/call write-byte-buffered/disp32
1435
1436 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1437
1438 c1/shift 5/subop/logic-right 3/mod/direct 3/rm32/ebx . . . . . 8/imm8
1439 $emit-hex:continue:
1440
1441 41/increment-ecx
1442 eb/jump $emit-hex:loop/disp8
1443 $emit-hex:end:
1444
1445 5f/pop-to-edi
1446 5b/pop-to-ebx
1447 5a/pop-to-edx
1448 59/pop-to-ecx
1449 58/pop-to-eax
1450
1451 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1452 5d/pop-to-ebp
1453 c3/return
1454
1455 test-emit-hex-single-byte:
1456
1457
1458
1459 68/push _test-output-stream/imm32
1460
1461 e8/call clear-stream/disp32
1462
1463 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1464
1465
1466 b8/copy-to-eax _test-output-buffered-file/imm32
1467 05/add-to-eax 4/imm32
1468 50/push-eax
1469
1470 e8/call clear-stream/disp32
1471
1472 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1473
1474
1475 68/push 1/imm32
1476 68/push 0xab/imm32
1477 68/push _test-output-buffered-file/imm32
1478
1479 e8/call emit-hex/disp32
1480
1481 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1482
1483
1484 68/push _test-output-buffered-file/imm32
1485
1486 e8/call flush/disp32
1487
1488 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1489
1490
1491 68/push "F - test-emit-hex-single-byte"/imm32
1492 68/push 0x206261/imm32
1493
1494 b8/copy-to-eax _test-output-stream/imm32
1495 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 0xc/disp8 .
1496
1497 e8/call check-ints-equal/disp32
1498
1499 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1500
1501 c3/return
1502
1503 test-emit-hex-multiple-byte:
1504
1505
1506
1507 68/push _test-output-stream/imm32
1508
1509 e8/call clear-stream/disp32
1510
1511 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1512
1513
1514 b8/copy-to-eax _test-output-buffered-file/imm32
1515 05/add-to-eax 4/imm32
1516 50/push-eax
1517
1518 e8/call clear-stream/disp32
1519
1520 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1521
1522
1523 68/push 2/imm32
1524 68/push 0x1234/imm32
1525 68/push _test-output-buffered-file/imm32
1526
1527 e8/call emit-hex/disp32
1528
1529 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1530
1531
1532 68/push _test-output-buffered-file/imm32
1533
1534 e8/call flush/disp32
1535
1536 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1537
1538
1539 68/push "F - test-emit-hex-multiple-byte/1"/imm32
1540 68/push "34 12 "/imm32
1541 68/push _test-output-stream/imm32
1542
1543 e8/call check-stream-equal/disp32
1544
1545 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1546
1547 c3/return
1548
1549 test-emit-hex-zero-pad:
1550
1551
1552
1553 68/push _test-output-stream/imm32
1554
1555 e8/call clear-stream/disp32
1556
1557 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1558
1559
1560 b8/copy-to-eax _test-output-buffered-file/imm32
1561 05/add-to-eax 4/imm32
1562 50/push-eax
1563
1564 e8/call clear-stream/disp32
1565
1566 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1567
1568
1569 68/push 2/imm32
1570 68/push 0xab/imm32
1571 68/push _test-output-buffered-file/imm32
1572
1573 e8/call emit-hex/disp32
1574
1575 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1576
1577
1578 68/push _test-output-buffered-file/imm32
1579
1580 e8/call flush/disp32
1581
1582 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1583
1584
1585 68/push "F - test-emit-hex-zero-pad/1"/imm32
1586 68/push "ab 00 "/imm32
1587 68/push _test-output-stream/imm32
1588
1589 e8/call check-stream-equal/disp32
1590
1591 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1592
1593 c3/return
1594
1595 test-emit-hex-negative:
1596
1597
1598
1599 68/push _test-output-stream/imm32
1600
1601 e8/call clear-stream/disp32
1602
1603 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1604
1605
1606 b8/copy-to-eax _test-output-buffered-file/imm32
1607 05/add-to-eax 4/imm32
1608 50/push-eax
1609
1610 e8/call clear-stream/disp32
1611
1612 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1613
1614
1615 68/push 2/imm32
1616 68/push -1/imm32
1617 68/push _test-output-buffered-file/imm32
1618
1619 e8/call emit-hex/disp32
1620
1621 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1622
1623
1624 68/push _test-output-buffered-file/imm32
1625
1626 e8/call flush/disp32
1627
1628 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1629
1630
1631 68/push "F - test-emit-hex-negative/1"/imm32
1632 68/push "ff ff "/imm32
1633 68/push _test-output-stream/imm32
1634
1635 e8/call check-stream-equal/disp32
1636
1637 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1638
1639 c3/return
1640
1641
1642 emit-hex-array:
1643
1644 55/push-ebp
1645 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1646
1647 50/push-eax
1648 51/push-ecx
1649 52/push-edx
1650 57/push-edi
1651
1652 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
1653
1654 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
1655
1656 8d/copy-address 1/mod/*+disp8 2/rm32/edx . . . 1/r32/ecx 4/disp8 .
1657
1658 8b/copy 0/mod/indirect 2/rm32/edx . . . 2/r32/edx . .
1659 01/add 3/mod/direct 2/rm32/edx . . . 1/r32/ecx . .
1660
1661 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
1662 $emit-hex-array:loop:
1663
1664 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
1665 73/jump-if-greater-or-equal-unsigned $emit-hex-array:end/disp8
1666
1667
1668 68/push 1/imm32/width
1669 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
1670 50/push-eax
1671 57/push-edi
1672
1673 e8/call emit-hex/disp32
1674
1675 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1676
1677 41/increment-ecx
1678 eb/jump $emit-hex-array:loop/disp8
1679 $emit-hex-array:end:
1680
1681 5f/pop-to-edi
1682 5a/pop-to-edx
1683 59/pop-to-ecx
1684 58/pop-to-eax
1685
1686 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1687 5d/pop-to-ebp
1688 c3/return
1689
1690 test-emit-hex-array:
1691
1692 55/push-ebp
1693 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1694
1695
1696
1697 68/push _test-output-stream/imm32
1698
1699 e8/call clear-stream/disp32
1700
1701 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1702
1703
1704 b8/copy-to-eax _test-output-buffered-file/imm32
1705 05/add-to-eax 4/imm32
1706 50/push-eax
1707
1708 e8/call clear-stream/disp32
1709
1710 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1711
1712 68/push 0x00030201/imm32
1713 68/push 3/imm32/length
1714 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1715
1716
1717 51/push-ecx
1718 68/push _test-output-buffered-file/imm32
1719
1720 e8/call emit-hex-array/disp32
1721
1722 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1723
1724
1725 68/push _test-output-buffered-file/imm32
1726
1727 e8/call flush/disp32
1728
1729 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1730 +-- 33 lines: #? # dump output ---------------------------------------------------------------------------------------------------------------------------
1763
1764
1765 68/push "F - test-emit-hex-array"/imm32
1766 68/push "01 02 03 "/imm32
1767 68/push _test-output-stream/imm32
1768
1769 e8/call check-next-stream-line-equal/disp32
1770
1771 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1772
1773 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1774 5d/pop-to-ebp
1775 c3/return
1776
1777 compute-width:
1778
1779 55/push-ebp
1780 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1781
1782 51/push-ecx
1783
1784 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 8/disp8 .
1785
1786 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
1787 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
1788
1789 05/add-to-eax 4/imm32
1790
1791 51/push-ecx
1792 50/push-eax
1793 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
1794
1795
1796 51/push-ecx
1797
1798 e8/call compute-width-of-slice/disp32
1799
1800 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1801 $compute-width:end:
1802
1803 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1804
1805 59/pop-to-ecx
1806
1807 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1808 5d/pop-to-ebp
1809 c3/return
1810
1811 compute-width-of-slice:
1812
1813 55/push-ebp
1814 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1815
1816 51/push-ecx
1817
1818 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
1819
1820
1821
1822 68/push "imm32"/imm32
1823 51/push-ecx
1824
1825 e8/call has-metadata?/disp32
1826
1827 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1828
1829 3d/compare-eax-and 0/imm32
1830 b8/copy-to-eax 4/imm32
1831 75/jump-if-not-equal $compute-width-of-slice:end/disp8
1832
1833
1834
1835 68/push "disp32"/imm32
1836 51/push-ecx
1837
1838 e8/call has-metadata?/disp32
1839
1840 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1841
1842 3d/compare-eax-and 0/imm32
1843 b8/copy-to-eax 4/imm32
1844 75/jump-if-not-equal $compute-width-of-slice:end/disp8
1845
1846
1847
1848 68/push "imm16"/imm32
1849 51/push-ecx
1850
1851 e8/call has-metadata?/disp32
1852
1853 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1854
1855 3d/compare-eax-and 0/imm32
1856 b8/copy-to-eax 2/imm32
1857 75/jump-if-not-equal $compute-width-of-slice:end/disp8
1858
1859
1860
1861 68/push "disp16"/imm32
1862 51/push-ecx
1863
1864 e8/call has-metadata?/disp32
1865
1866 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
1867
1868 3d/compare-eax-and 0/imm32
1869 b8/copy-to-eax 2/imm32
1870 75/jump-if-not-equal $compute-width-of-slice:end/disp8
1871
1872 b8/copy-to-eax 1/imm32
1873 $compute-width-of-slice:end:
1874
1875 59/pop-to-ecx
1876
1877 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
1878 5d/pop-to-ebp
1879 c3/return
1880
1881 test-compute-width:
1882
1883 55/push-ebp
1884 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
1885 $test-compute-width:imm8:
1886
1887
1888 68/push "0x2/imm8"/imm32
1889
1890 e8/call compute-width/disp32
1891
1892 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1893
1894
1895 68/push "F - test-compute-width: 0x2/imm8"/imm32
1896 50/push-eax
1897 68/push 1/imm32
1898
1899 e8/call check-ints-equal/disp32
1900
1901 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1902 $test-compute-width:imm16:
1903
1904
1905 68/push "4/imm16"/imm32
1906
1907 e8/call compute-width/disp32
1908
1909 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1910
1911
1912 68/push "F - test-compute-width: 4/imm16"/imm32
1913 50/push-eax
1914 68/push 2/imm32
1915
1916 e8/call check-ints-equal/disp32
1917
1918 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1919 $test-compute-width:imm32:
1920
1921
1922 68/push "4/imm32"/imm32
1923
1924 e8/call compute-width/disp32
1925
1926 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1927
1928
1929 68/push "F - test-compute-width: 4/imm32"/imm32
1930 50/push-eax
1931 68/push 4/imm32
1932
1933 e8/call check-ints-equal/disp32
1934
1935 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1936 $test-compute-width:disp8:
1937
1938
1939 68/push "foo/disp8"/imm32
1940
1941 e8/call compute-width/disp32
1942
1943 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1944
1945
1946 68/push "F - test-compute-width: foo/disp8"/imm32
1947 50/push-eax
1948 68/push 1/imm32
1949
1950 e8/call check-ints-equal/disp32
1951
1952 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1953 $test-compute-width:disp16:
1954
1955
1956 68/push "foo/disp16"/imm32
1957
1958 e8/call compute-width/disp32
1959
1960 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1961
1962
1963 68/push "F - test-compute-width: foo/disp16"/imm32
1964 50/push-eax
1965 68/push 2/imm32
1966
1967 e8/call check-ints-equal/disp32
1968
1969 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1970 $test-compute-width:disp32:
1971
1972
1973 68/push "foo/disp32"/imm32
1974
1975 e8/call compute-width/disp32
1976
1977 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1978
1979
1980 68/push "F - test-compute-width: foo/disp32"/imm32
1981 50/push-eax
1982 68/push 4/imm32
1983
1984 e8/call check-ints-equal/disp32
1985
1986 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
1987 $test-compute-width:no-metadata:
1988
1989
1990 68/push "45"/imm32
1991
1992 e8/call compute-width/disp32
1993
1994 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
1995
1996
1997 68/push "F - test-compute-width: 45 (no metadata)"/imm32
1998 50/push-eax
1999 68/push 1/imm32
2000
2001 e8/call check-ints-equal/disp32
2002
2003 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
2004
2005 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
2006 5d/pop-to-ebp
2007 c3/return
2008
2009 is-label?:
2010
2011 55/push-ebp
2012 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
2013
2014 51/push-ecx
2015
2016 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
2017
2018 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 1/r32/ecx 4/disp8 .
2019
2020
2021 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
2022
2023 8a/copy-byte 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/AL -1/disp8 .
2024
2025 3d/compare-eax-and 0x3a/imm32/colon
2026 b8/copy-to-eax 1/imm32/true
2027 74/jump-if-equal $is-label?:end/disp8
2028 b8/copy-to-eax 0/imm32/false
2029 $is-label?:end:
2030
2031 59/pop-to-ecx
2032
2033 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
2034 5d/pop-to-ebp
2035 c3/return
2036
2037 test-is-label?:
2038
2039 55/push-ebp
2040 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
2041 $test-is-label?:true:
2042
2043 b8/copy-to-eax "AAA:"/imm32
2044 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
2045 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
2046 05/add-to-eax 4/imm32
2047
2048 51/push-ecx
2049 50/push-eax
2050 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
2051
2052
2053 51/push-ecx
2054
2055 e8/call is-label?/disp32
2056
2057 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
2058
2059
2060 68/push "F - test-is-label?:true"/imm32
2061 68/push 1/imm32
2062 50/push-eax
2063
2064 e8/call check-ints-equal/disp32
2065
2066 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
2067 $test-is-label?:false:
2068
2069 b8/copy-to-eax "AAA"/imm32
2070 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
2071 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
2072 05/add-to-eax 4/imm32
2073
2074 51/push-ecx
2075 50/push-eax
2076 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
2077
2078
2079 51/push-ecx
2080
2081 e8/call is-label?/disp32
2082
2083 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
2084
2085
2086 68/push "F - test-is-label?:false"/imm32
2087 68/push 0/imm32
2088 50/push-eax
2089
2090 e8/call check-ints-equal/disp32
2091
2092 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
2093
2094 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
2095 5d/pop-to-ebp
2096 c3/return
2097
2098 == data
2099
2100 _test-data-segment:
2101 64/d 61/a 74/t 61/a
2102 _test-data-segment-end:
2103
2104