https://github.com/akkartik/mu/blob/master/apps/mu.subx
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 == data
248
249 Program:
250 0/imm32
251
252 Function-name:
253 0/imm32
254 Function-subx-name:
255 4/imm32
256 Function-inouts:
257 8/imm32
258 Function-outputs:
259 0xc/imm32
260 Function-body:
261 0x10/imm32
262 Function-next:
263 0x14/imm32
264 Function-size:
265 0x18/imm32/24
266
267 Primitive-name:
268 0/imm32
269 Primitive-inouts:
270 4/imm32
271 Primitive-outputs:
272 8/imm32
273 Primitive-subx-name:
274 0xc/imm32
275 Primitive-subx-rm32:
276 0x10/imm32
277 Primitive-subx-r32:
278 0x14/imm32
279 Primitive-subx-imm32:
280 0x18/imm32
281 Primitive-write-only-output:
282 0x1c/imm32
283 Primitive-next:
284 0x20/imm32
285 Primitive-size:
286 0x24/imm32/36
287
288 Stmt-tag:
289 0/imm32
290
291 Block-statements:
292 4/imm32
293
294 Stmt1-operation:
295 4/imm32
296 Stmt1-inouts:
297 8/imm32
298 Stmt1-outputs:
299 0xc/imm32
300
301 Vardef-var:
302 4/imm32
303
304 Regvardef-operation:
305 4/imm32
306 Regvardef-inouts:
307 8/imm32
308 Regvardef-var:
309 0xc/imm32
310
311 Named-block-name:
312 4/imm32
313 Named-block-statements:
314 8/imm32
315
316 Stmt-size:
317 0x10/imm32
318
319 Var-name:
320 0/imm32
321 Var-type:
322 4/imm32
323 Var-block:
324 8/imm32
325 Var-stack-offset:
326 0xc/imm32
327 Var-register:
328 0x10/imm32
329 Var-size:
330 0x14/imm32
331
332 Any-register:
333
334 1/imm32
335
336 2a/asterisk
337
338 List-value:
339 0/imm32
340 List-next:
341 4/imm32
342 List-size:
343 8/imm32
344
345
346
347
348
349
350
351 Tree-left:
352 0/imm32
353 Tree-right:
354 4/imm32
355 Tree-size:
356 8/imm32
357
358 Max-type-id:
359 0x10000/imm32
360
361 == code
362
363 Entry:
364
365 89/<- %ebp 4/r32/esp
366 (new-segment *Heap-size Heap)
367
368 {
369
370 81 7/subop/compare *ebp 1/imm32
371 7e/jump-if-<= break/disp8
372
373 (kernel-string-equal? *(ebp+8) "test")
374 3d/compare-eax-and 0/imm32
375 74/jump-if-= break/disp8
376
377 (run-tests)
378
379 8b/-> *Num-test-failures 3/r32/ebx
380 eb/jump $mu-main:end/disp8
381 }
382
383 (convert-mu Stdin Stdout)
384 (flush Stdout)
385
386 bb/copy-to-ebx 0/imm32
387 $mu-main:end:
388 b8/copy-to-eax 1/imm32/exit
389 cd/syscall 0x80/imm8
390
391 convert-mu:
392
393 55/push-ebp
394 89/<- %ebp 4/r32/esp
395
396 (parse-mu *(ebp+8))
397 (check-mu-types)
398 (emit-subx *(ebp+0xc))
399 $convert-mu:end:
400
401 89/<- %esp 5/r32/ebp
402 5d/pop-to-ebp
403 c3/return
404
405 test-convert-empty-input:
406
407
408 55/push-ebp
409 89/<- %ebp 4/r32/esp
410
411 (clear-stream _test-input-stream)
412 (clear-stream $_test-input-buffered-file->buffer)
413 (clear-stream _test-output-stream)
414 (clear-stream $_test-output-buffered-file->buffer)
415
416 (convert-mu _test-input-buffered-file _test-output-buffered-file)
417 (flush _test-output-buffered-file)
418 (check-stream-equal _test-output-stream "" "F - test-convert-empty-input")
419
420 89/<- %esp 5/r32/ebp
421 5d/pop-to-ebp
422 c3/return
423
424 test-convert-function-skeleton:
425
426
427
428
429
430
431
432
433
434
435
436
437
438 55/push-ebp
439 89/<- %ebp 4/r32/esp
440
441 (clear-stream _test-input-stream)
442 (clear-stream $_test-input-buffered-file->buffer)
443 (clear-stream _test-output-stream)
444 (clear-stream $_test-output-buffered-file->buffer)
445
446 (write _test-input-stream "fn foo {\n")
447 (write _test-input-stream "}\n")
448
449 (convert-mu _test-input-buffered-file _test-output-buffered-file)
450 (flush _test-output-buffered-file)
451 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
457
458 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-skeleton/0")
459 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-skeleton/1")
460 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-skeleton/2")
461 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-skeleton/3")
462 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-skeleton/4")
463 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-skeleton/5")
464 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-skeleton/6")
465 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-skeleton/7")
466
467 89/<- %esp 5/r32/ebp
468 5d/pop-to-ebp
469 c3/return
470
471 test-convert-multiple-function-skeletons:
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495 55/push-ebp
496 89/<- %ebp 4/r32/esp
497
498 (clear-stream _test-input-stream)
499 (clear-stream $_test-input-buffered-file->buffer)
500 (clear-stream _test-output-stream)
501 (clear-stream $_test-output-buffered-file->buffer)
502
503 (write _test-input-stream "fn foo {\n")
504 (write _test-input-stream "}\n")
505 (write _test-input-stream "fn bar {\n")
506 (write _test-input-stream "}\n")
507
508 (convert-mu _test-input-buffered-file _test-output-buffered-file)
509 (flush _test-output-buffered-file)
510 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
516
517 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-multiple-function-skeletons/0")
518 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/1")
519 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/2")
520 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/3")
521 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/4")
522 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/5")
523 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/6")
524 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/7")
525
526 (check-next-stream-line-equal _test-output-stream "bar:" "F - test-convert-multiple-function-skeletons/10")
527 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/11")
528 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/12")
529 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/13")
530 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/14")
531 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/15")
532 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/16")
533 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/17")
534
535 89/<- %esp 5/r32/ebp
536 5d/pop-to-ebp
537 c3/return
538
539 test-convert-function-with-arg:
540
541
542
543
544
545
546
547
548
549
550
551
552
553 55/push-ebp
554 89/<- %ebp 4/r32/esp
555
556 (clear-stream _test-input-stream)
557 (clear-stream $_test-input-buffered-file->buffer)
558 (clear-stream _test-output-stream)
559 (clear-stream $_test-output-buffered-file->buffer)
560
561 (write _test-input-stream "fn foo n : int {\n")
562 (write _test-input-stream "}\n")
563
564 (convert-mu _test-input-buffered-file _test-output-buffered-file)
565 (flush _test-output-buffered-file)
566 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
572
573 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-with-arg/0")
574 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-with-arg/1")
575 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-with-arg/2")
576 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-with-arg/3")
577 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-with-arg/4")
578 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-with-arg/5")
579 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-with-arg/6")
580 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-with-arg/7")
581
582 89/<- %esp 5/r32/ebp
583 5d/pop-to-ebp
584 c3/return
585
586 test-convert-function-with-arg-and-body:
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604 55/push-ebp
605 89/<- %ebp 4/r32/esp
606
607 (clear-stream _test-input-stream)
608 (clear-stream $_test-input-buffered-file->buffer)
609 (clear-stream _test-output-stream)
610 (clear-stream $_test-output-buffered-file->buffer)
611
612 (write _test-input-stream "fn foo n : int {\n")
613 (write _test-input-stream " increment n\n")
614 (write _test-input-stream "}\n")
615
616 (convert-mu _test-input-buffered-file _test-output-buffered-file)
617 (flush _test-output-buffered-file)
618 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
624
625 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-with-arg-and-body/0")
626 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-with-arg-and-body/1")
627 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-with-arg-and-body/2")
628 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-with-arg-and-body/3")
629 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-with-arg-and-body/4")
630 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0x00000008)" "F - test-convert-function-with-arg-and-body/5")
631 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-with-arg-and-body/6")
632 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-with-arg-and-body/7")
633 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-with-arg-and-body/8")
634 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-with-arg-and-body/9")
635 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-with-arg-and-body/10")
636
637 89/<- %esp 5/r32/ebp
638 5d/pop-to-ebp
639 c3/return
640
641 test-convert-function-distinguishes-args:
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659 55/push-ebp
660 89/<- %ebp 4/r32/esp
661
662 (clear-stream _test-input-stream)
663 (clear-stream $_test-input-buffered-file->buffer)
664 (clear-stream _test-output-stream)
665 (clear-stream $_test-output-buffered-file->buffer)
666
667 (write _test-input-stream "fn foo a: int, b: int {\n")
668 (write _test-input-stream " increment b\n")
669 (write _test-input-stream "}\n")
670
671 (convert-mu _test-input-buffered-file _test-output-buffered-file)
672 (flush _test-output-buffered-file)
673 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
679
680 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-distinguishes-args/0")
681 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-distinguishes-args/1")
682 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-distinguishes-args/2")
683 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-distinguishes-args/3")
684 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-distinguishes-args/4")
685 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0x0000000c)" "F - test-convert-function-distinguishes-args/5")
686 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-distinguishes-args/6")
687 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-distinguishes-args/7")
688 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-distinguishes-args/8")
689 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-distinguishes-args/9")
690 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-distinguishes-args/10")
691
692 89/<- %esp 5/r32/ebp
693 5d/pop-to-ebp
694 c3/return
695
696 test-convert-function-returns-result:
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716 55/push-ebp
717 89/<- %ebp 4/r32/esp
718
719 (clear-stream _test-input-stream)
720 (clear-stream $_test-input-buffered-file->buffer)
721 (clear-stream _test-output-stream)
722 (clear-stream $_test-output-buffered-file->buffer)
723
724 (write _test-input-stream "fn foo a: int, b: int -> result/eax: int {\n")
725 (write _test-input-stream " result <- copy a\n")
726 (write _test-input-stream " result <- increment\n")
727 (write _test-input-stream "}\n")
728
729 (convert-mu _test-input-buffered-file _test-output-buffered-file)
730 (flush _test-output-buffered-file)
731 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
737
738 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-returns-result/0")
739 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-returns-result/1")
740 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-returns-result/2")
741 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-returns-result/3")
742 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-returns-result/4")
743 (check-next-stream-line-equal _test-output-stream "8b/copy-from *(ebp+0x00000008) 0x00000000/r32" "F - test-convert-function-returns-result/5")
744 (check-next-stream-line-equal _test-output-stream "40/increment-eax" "F - test-convert-function-returns-result/6")
745 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-returns-result/7")
746 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-returns-result/8")
747 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-returns-result/9")
748 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-returns-result/10")
749 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-returns-result/11")
750
751 89/<- %esp 5/r32/ebp
752 5d/pop-to-ebp
753 c3/return
754
755 test-convert-function-literal-arg:
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775 55/push-ebp
776 89/<- %ebp 4/r32/esp
777
778 (clear-stream _test-input-stream)
779 (clear-stream $_test-input-buffered-file->buffer)
780 (clear-stream _test-output-stream)
781 (clear-stream $_test-output-buffered-file->buffer)
782
783 (write _test-input-stream "fn foo a: int, b: int -> result/eax: int {\n")
784 (write _test-input-stream " result <- copy a\n")
785 (write _test-input-stream " result <- add 1\n")
786 (write _test-input-stream "}\n")
787
788 (convert-mu _test-input-buffered-file _test-output-buffered-file)
789 (flush _test-output-buffered-file)
790 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
796
797 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-literal-arg/0")
798 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-literal-arg/1")
799 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-literal-arg/2")
800 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-literal-arg/3")
801 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-literal-arg/4")
802 (check-next-stream-line-equal _test-output-stream "8b/copy-from *(ebp+0x00000008) 0x00000000/r32" "F - test-convert-function-literal-arg/5")
803 (check-next-stream-line-equal _test-output-stream "05/add-to-eax 1/imm32" "F - test-convert-function-literal-arg/6")
804 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-literal-arg/7")
805 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-literal-arg/8")
806 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-literal-arg/9")
807 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-literal-arg/10")
808 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-literal-arg/11")
809
810 89/<- %esp 5/r32/ebp
811 5d/pop-to-ebp
812 c3/return
813
814 test-convert-function-literal-arg-2:
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834 55/push-ebp
835 89/<- %ebp 4/r32/esp
836
837 (clear-stream _test-input-stream)
838 (clear-stream $_test-input-buffered-file->buffer)
839 (clear-stream _test-output-stream)
840 (clear-stream $_test-output-buffered-file->buffer)
841
842 (write _test-input-stream "fn foo a: int, b: int -> result/ebx: int {\n")
843 (write _test-input-stream " result <- copy a\n")
844 (write _test-input-stream " result <- add 1\n")
845 (write _test-input-stream "}\n")
846
847 (convert-mu _test-input-buffered-file _test-output-buffered-file)
848 (flush _test-output-buffered-file)
849 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
855
856 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-literal-arg-2/0")
857 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-literal-arg-2/1")
858 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-literal-arg-2/2")
859 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-literal-arg-2/3")
860 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-literal-arg-2/4")
861 (check-next-stream-line-equal _test-output-stream "8b/copy-from *(ebp+0x00000008) 0x00000003/r32" "F - test-convert-function-literal-arg-2/5")
862 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %ebx 1/imm32" "F - test-convert-function-literal-arg-2/6")
863 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-literal-arg-2/7")
864 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-literal-arg-2/8")
865 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-literal-arg-2/9")
866 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-literal-arg-2/10")
867 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-literal-arg-2/11")
868
869 89/<- %esp 5/r32/ebp
870 5d/pop-to-ebp
871 c3/return
872
873 test-convert-function-call-with-literal-arg:
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908 55/push-ebp
909 89/<- %ebp 4/r32/esp
910
911 (clear-stream _test-input-stream)
912 (clear-stream $_test-input-buffered-file->buffer)
913 (clear-stream _test-output-stream)
914 (clear-stream $_test-output-buffered-file->buffer)
915
916 (write _test-input-stream "fn main -> result/ebx: int {\n")
917 (write _test-input-stream " result <- do-add 3 4\n")
918 (write _test-input-stream "}\n")
919 (write _test-input-stream "fn do-add a: int, b: int -> result/ebx: int {\n")
920 (write _test-input-stream " result <- copy a\n")
921 (write _test-input-stream " result <- add b\n")
922 (write _test-input-stream "}\n")
923
924 (convert-mu _test-input-buffered-file _test-output-buffered-file)
925 (flush _test-output-buffered-file)
926 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
932
933 (check-next-stream-line-equal _test-output-stream "main:" "F - test-convert-function-call-with-literal-arg/0")
934 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-call-with-literal-arg/1")
935 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-call-with-literal-arg/2")
936 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-call-with-literal-arg/3")
937 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-call-with-literal-arg/4")
938 (check-next-stream-line-equal _test-output-stream "(do-add 3 4)" "F - test-convert-function-call-with-literal-arg/5")
939 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-call-with-literal-arg/6")
940 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-call-with-literal-arg/7")
941 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-call-with-literal-arg/8")
942 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-call-with-literal-arg/9")
943 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-call-with-literal-arg/10")
944 (check-next-stream-line-equal _test-output-stream "do-add:" "F - test-convert-function-call-with-literal-arg/11")
945 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-call-with-literal-arg/12")
946 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-call-with-literal-arg/13")
947 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-call-with-literal-arg/14")
948 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-call-with-literal-arg/15")
949 (check-next-stream-line-equal _test-output-stream "8b/copy-from *(ebp+0x00000008) 0x00000003/r32" "F - test-convert-function-call-with-literal-arg/16")
950 (check-next-stream-line-equal _test-output-stream "03/add *(ebp+0x0000000c) 0x00000003/r32" "F - test-convert-function-call-with-literal-arg/17")
951 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-call-with-literal-arg/18")
952 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-call-with-literal-arg/19")
953 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-call-with-literal-arg/20")
954 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-call-with-literal-arg/21")
955 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-call-with-literal-arg/22")
956
957 89/<- %esp 5/r32/ebp
958 5d/pop-to-ebp
959 c3/return
960
961 test-convert-function-with-local-var-in-mem:
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982 55/push-ebp
983 89/<- %ebp 4/r32/esp
984
985 (clear-stream _test-input-stream)
986 (clear-stream $_test-input-buffered-file->buffer)
987 (clear-stream _test-output-stream)
988 (clear-stream $_test-output-buffered-file->buffer)
989
990 (write _test-input-stream "fn foo {\n")
991 (write _test-input-stream "var x: int\n")
992 (write _test-input-stream "increment x\n")
993 (write _test-input-stream "}\n")
994
995 (convert-mu _test-input-buffered-file _test-output-buffered-file)
996 (flush _test-output-buffered-file)
997 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
1003
1004 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-with-local-var-in-mem/0")
1005 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-with-local-var-in-mem/1")
1006 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-with-local-var-in-mem/2")
1007 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-with-local-var-in-mem/3")
1008 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-with-local-var-in-mem/4")
1009 (check-next-stream-line-equal _test-output-stream "68/push 0/imm32" "F - test-convert-function-with-local-var-in-mem/5")
1010 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0xfffffffc)" "F - test-convert-function-with-local-var-in-mem/6")
1011 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %esp 0x00000004/imm32" "F - test-convert-function-with-local-var-in-mem/7")
1012 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-with-local-var-in-mem/8")
1013 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-with-local-var-in-mem/9")
1014 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-with-local-var-in-mem/10")
1015 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-with-local-var-in-mem/11")
1016 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-with-local-var-in-mem/12")
1017
1018 89/<- %esp 5/r32/ebp
1019 5d/pop-to-ebp
1020 c3/return
1021
1022
1023
1024
1025
1026 parse-mu:
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052 55/push-ebp
1053 89/<- %ebp 4/r32/esp
1054
1055 50/push-eax
1056 51/push-ecx
1057 52/push-edx
1058 53/push-ebx
1059 57/push-edi
1060
1061 81 5/subop/subtract %esp 0x200/imm32
1062 68/push 0x200/imm32/length
1063 68/push 0/imm32/read
1064 68/push 0/imm32/write
1065 89/<- %ecx 4/r32/esp
1066
1067 68/push 0/imm32/end
1068 68/push 0/imm32/start
1069 89/<- %edx 4/r32/esp
1070
1071 bf/copy-to-edi Program/imm32
1072
1073 81 5/subop/subtract %esp 0x400/imm32
1074 68/push 0x400/imm32/length
1075 68/push 0/imm32/top
1076 89/<- %ebx 4/r32/esp
1077 {
1078 $parse-mu:line-loop:
1079 (clear-stream %ecx)
1080 (read-line-buffered *(ebp+8) %ecx)
1081
1082 81 7/subop/compare *ecx 0/imm32
1083 0f 84/jump-if-= break/disp32
1084 +-- 6 lines: #? # dump line ---------------------------------------------------------------------------------------------------------------------------
1090 (next-mu-token %ecx %edx)
1091
1092 (slice-empty? %edx)
1093 3d/compare-eax-and 0/imm32
1094 0f 85/jump-if-!= loop/disp32
1095
1096
1097 8b/-> *edx 0/r32/eax
1098 8a/copy-byte *eax 0/r32/AL
1099 81 4/subop/and %eax 0xff/imm32
1100
1101 3d/compare-eax-and 0x23/imm32/hash
1102 0f 84/jump-if-= loop/disp32
1103
1104 {
1105 $parse-mu:fn:
1106 (slice-equal? %edx "fn")
1107 3d/compare-eax-and 0/imm32
1108 0f 84/jump-if-= break/disp32
1109
1110 (allocate Heap *Function-size)
1111 (zero-out %eax *Function-size)
1112 (clear-stack %ebx)
1113 (populate-mu-function-header %ecx %eax %ebx)
1114 (populate-mu-function-body *(ebp+8) %eax %ebx)
1115
1116 89/<- *edi 0/r32/eax
1117
1118 8d/address-> *(eax+0x14) 7/r32/edi
1119 e9/jump $parse-mu:line-loop/disp32
1120 }
1121
1122 e9/jump $parse-mu:error1/disp32
1123 }
1124 $parse-mu:end:
1125
1126 81 0/subop/add %esp 0x630/imm32
1127
1128 5f/pop-to-edi
1129 5b/pop-to-ebx
1130 5a/pop-to-edx
1131 59/pop-to-ecx
1132 58/pop-to-eax
1133
1134 89/<- %esp 5/r32/ebp
1135 5d/pop-to-ebp
1136 c3/return
1137
1138 $parse-mu:error1:
1139
1140 (write-buffered Stderr "unexpected top-level command: ")
1141 (write-slice-buffered Stderr %edx)
1142 (write-buffered Stderr "\n")
1143 (flush Stderr)
1144
1145 bb/copy-to-ebx 1/imm32
1146 b8/copy-to-eax 1/imm32/exit
1147 cd/syscall 0x80/imm8
1148
1149
1150 $parse-mu:error2:
1151
1152 (print-int32-buffered Stderr *ebx)
1153 (write-buffered Stderr " vars not reclaimed after fn '")
1154 (write-slice-buffered Stderr *eax)
1155 (write-buffered Stderr "'\n")
1156 (flush Stderr)
1157
1158 bb/copy-to-ebx 1/imm32
1159 b8/copy-to-eax 1/imm32/exit
1160 cd/syscall 0x80/imm8
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174 populate-mu-function-header:
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205 55/push-ebp
1206 89/<- %ebp 4/r32/esp
1207
1208 50/push-eax
1209 51/push-ecx
1210 52/push-edx
1211 53/push-ebx
1212 57/push-edi
1213
1214 8b/-> *(ebp+0xc) 7/r32/edi
1215
1216 68/push 0/imm32/end
1217 68/push 0/imm32/start
1218 89/<- %ecx 4/r32/esp
1219
1220 ba/copy-to-edx 8/imm32
1221
1222 (next-word *(ebp+8) %ecx)
1223
1224
1225 (slice-equal? %ecx "{")
1226 3d/compare-eax-and 0/imm32
1227 0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
1228
1229 (slice-equal? %ecx "->")
1230 3d/compare-eax-and 0/imm32
1231 0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
1232
1233 (slice-equal? %ecx "}")
1234 3d/compare-eax-and 0/imm32
1235 0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
1236
1237 (slice-to-string Heap %ecx)
1238 89/<- *edi 0/r32/eax
1239
1240 89/<- *(edi+4) 0/r32/eax
1241
1242 {
1243 $populate-mu-function-header:check-for-inout:
1244 (next-word *(ebp+8) %ecx)
1245
1246 (slice-equal? %ecx "{")
1247 3d/compare-eax-and 0/imm32
1248 0f 85/jump-if-!= $populate-mu-function-header:done/disp32
1249
1250 (slice-equal? %ecx "->")
1251 3d/compare-eax-and 0/imm32
1252 0f 85/jump-if-!= break/disp32
1253
1254 (slice-equal? %ecx "}")
1255 3d/compare-eax-and 0/imm32
1256 0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
1257
1258 (parse-var-with-type %ecx *(ebp+8))
1259 89/<- %ebx 0/r32/eax
1260
1261 81 7/subop/compare *(ebx+0x10) 0/imm32
1262 0f 85/jump-if-!= $populate-mu-function-header:error2/disp32
1263
1264 89/<- *(ebx+0xc) 2/r32/edx
1265
1266 (size-of %ebx)
1267 01/add %edx 0/r32/eax
1268
1269 (append-list Heap %ebx *(edi+8))
1270 89/<- *(edi+8) 0/r32/eax
1271 (push *(ebp+0x10) %ebx)
1272
1273 e9/jump loop/disp32
1274 }
1275
1276 {
1277 $parse-var-with-type:check-for-out:
1278 (next-word *(ebp+8) %ecx)
1279
1280 (slice-equal? %ecx "{")
1281 3d/compare-eax-and 0/imm32
1282 0f 85/jump-if-!= break/disp32
1283
1284 (slice-equal? %ecx "->")
1285 3d/compare-eax-and 0/imm32
1286 0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
1287
1288 (slice-equal? %ecx "}")
1289 3d/compare-eax-and 0/imm32
1290 0f 85/jump-if-!= $populate-mu-function-header:error1/disp32
1291
1292 (parse-var-with-type %ecx *(ebp+8))
1293 89/<- %ebx 0/r32/eax
1294
1295 81 7/subop/compare *(ebx+0x10) 0/imm32
1296 0f 84/jump-if-= $populate-mu-function-header:error3/disp32
1297 (append-list Heap %ebx *(edi+0xc))
1298 89/<- *(edi+0xc) 0/r32/eax
1299 e9/jump loop/disp32
1300 }
1301 $populate-mu-function-header:done:
1302 (check-no-tokens-left *(ebp+8))
1303 $populate-mu-function-header:end:
1304
1305 81 0/subop/add %esp 8/imm32
1306
1307 5f/pop-to-edi
1308 5b/pop-to-ebx
1309 5a/pop-to-edx
1310 59/pop-to-ecx
1311 58/pop-to-eax
1312
1313 89/<- %esp 5/r32/ebp
1314 5d/pop-to-ebp
1315 c3/return
1316
1317 $populate-mu-function-header:error1:
1318
1319 (write-buffered Stderr "function header not in form 'fn <name> [inouts] [-> outputs] {' -- '")
1320 (flush Stderr)
1321 (rewind-stream *(ebp+8))
1322 (write-stream 2 *(ebp+8))
1323 (write-buffered Stderr "'\n")
1324 (flush Stderr)
1325
1326 bb/copy-to-ebx 1/imm32
1327 b8/copy-to-eax 1/imm32/exit
1328 cd/syscall 0x80/imm8
1329
1330
1331 $populate-mu-function-header:error2:
1332
1333 (write-buffered Stderr "function input '")
1334 (write-buffered Stderr *ebx)
1335 (write-buffered Stderr "' cannot be in a register")
1336 (flush Stderr)
1337
1338 bb/copy-to-ebx 1/imm32
1339 b8/copy-to-eax 1/imm32/exit
1340 cd/syscall 0x80/imm8
1341
1342
1343 $populate-mu-function-header:error3:
1344
1345 (write-buffered Stderr "function input '")
1346 (write-buffered Stderr *eax)
1347 (write-buffered Stderr " must be in a register'")
1348 (flush Stderr)
1349 (rewind-stream *(ebp+8))
1350 (write-stream 2 *(ebp+8))
1351 (write-buffered Stderr "'\n")
1352 (flush Stderr)
1353
1354 bb/copy-to-ebx 1/imm32
1355 b8/copy-to-eax 1/imm32/exit
1356 cd/syscall 0x80/imm8
1357
1358
1359 test-function-header-with-arg:
1360
1361
1362 55/push-ebp
1363 89/<- %ebp 4/r32/esp
1364
1365 (clear-stream _test-input-stream)
1366 (write _test-input-stream "foo n : int {\n")
1367
1368 2b/subtract-> *Function-size 4/r32/esp
1369 89/<- %ecx 4/r32/esp
1370 (zero-out %ecx *Function-size)
1371
1372 81 5/subop/subtract %esp 0x10/imm32
1373 68/push 0x10/imm32/length
1374 68/push 0/imm32/top
1375 89/<- %ebx 4/r32/esp
1376
1377 (populate-mu-function-header _test-input-stream %ecx %ebx)
1378
1379 (check-strings-equal *ecx "foo" "F - test-function-header-with-arg/name")
1380
1381 8b/-> *(ecx+8) 2/r32/edx
1382
1383 8b/-> *edx 3/r32/ebx
1384 (check-strings-equal *ebx "n" "F - test-function-header-with-arg/inout:0")
1385 8b/-> *(ebx+4) 3/r32/ebx
1386 (check-ints-equal *ebx 1 "F - test-function-header-with-arg/inout:0/type:0")
1387 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-arg/inout:0/type:1")
1388
1389 89/<- %esp 5/r32/ebp
1390 5d/pop-to-ebp
1391 c3/return
1392
1393 test-function-header-with-multiple-args:
1394
1395
1396 55/push-ebp
1397 89/<- %ebp 4/r32/esp
1398
1399 (clear-stream _test-input-stream)
1400 (write _test-input-stream "foo a: int, b: int c: int {\n")
1401
1402 2b/subtract-> *Function-size 4/r32/esp
1403 89/<- %ecx 4/r32/esp
1404 (zero-out %ecx *Function-size)
1405
1406 81 5/subop/subtract %esp 0x10/imm32
1407 68/push 0x10/imm32/length
1408 68/push 0/imm32/top
1409 89/<- %ebx 4/r32/esp
1410
1411 (populate-mu-function-header _test-input-stream %ecx %ebx)
1412
1413 (check-strings-equal *ecx "foo")
1414
1415 8b/-> *(ecx+8) 2/r32/edx
1416 $test-function-header-with-multiple-args:inout0:
1417
1418 8b/-> *edx 3/r32/ebx
1419 (check-strings-equal *ebx "a" "F - test-function-header-with-multiple-args/inout:0")
1420 8b/-> *(ebx+4) 3/r32/ebx
1421 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args/inout:0/type:0")
1422 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args/inout:0/type:1")
1423
1424 8b/-> *(edx+4) 2/r32/edx
1425 $test-function-header-with-multiple-args:inout1:
1426
1427 8b/-> *edx 3/r32/ebx
1428 (check-strings-equal *ebx "b" "F - test-function-header-with-multiple-args/inout:1")
1429 8b/-> *(ebx+4) 3/r32/ebx
1430 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args/inout:1/type:0")
1431 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args/inout:1/type:1")
1432
1433 8b/-> *(edx+4) 2/r32/edx
1434 $test-function-header-with-multiple-args:inout2:
1435
1436 8b/-> *edx 3/r32/ebx
1437 (check-strings-equal *ebx "c" "F - test-function-header-with-multiple-args/inout:2")
1438 8b/-> *(ebx+4) 3/r32/ebx
1439 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args/inout:2/type:0")
1440 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args/inout:2/type:1")
1441
1442 89/<- %esp 5/r32/ebp
1443 5d/pop-to-ebp
1444 c3/return
1445
1446 test-function-with-multiple-args-and-outputs:
1447
1448
1449 55/push-ebp
1450 89/<- %ebp 4/r32/esp
1451
1452 (clear-stream _test-input-stream)
1453 (write _test-input-stream "foo a: int, b: int, c: int -> x/ecx: int y/edx: int {\n")
1454
1455 2b/subtract-> *Function-size 4/r32/esp
1456 89/<- %ecx 4/r32/esp
1457 (zero-out %ecx *Function-size)
1458
1459 81 5/subop/subtract %esp 0x10/imm32
1460 68/push 0x10/imm32/length
1461 68/push 0/imm32/top
1462 89/<- %ebx 4/r32/esp
1463
1464 (populate-mu-function-header _test-input-stream %ecx %ebx)
1465
1466 (check-strings-equal *ecx "foo")
1467
1468 8b/-> *(ecx+8) 2/r32/edx
1469
1470 8b/-> *edx 3/r32/ebx
1471 (check-strings-equal *ebx "a" "F - test-function-header-with-multiple-args-and-outputs/inout:0")
1472 8b/-> *(ebx+4) 3/r32/ebx
1473 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args-and-outputs/inout:0/type:0")
1474 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args-and-outputs/inout:0/type:1")
1475
1476 8b/-> *(edx+4) 2/r32/edx
1477
1478 8b/-> *edx 3/r32/ebx
1479 (check-strings-equal *ebx "b" "F - test-function-header-with-multiple-args-and-outputs/inout:1")
1480 8b/-> *(ebx+4) 3/r32/ebx
1481 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args-and-outputs/inout:1/type:0")
1482 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args-and-outputs/inout:1/type:1")
1483
1484 8b/-> *(edx+4) 2/r32/edx
1485
1486 8b/-> *edx 3/r32/ebx
1487 (check-strings-equal *ebx "c" "F - test-function-header-with-multiple-args-and-outputs/inout:2")
1488 8b/-> *(ebx+4) 3/r32/ebx
1489 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args-and-outputs/inout:2/type:0")
1490 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args-and-outputs/inout:2/type:1")
1491
1492 8b/-> *(ecx+0xc) 2/r32/edx
1493
1494 8b/-> *edx 3/r32/ebx
1495 (check-strings-equal *ebx "x" "F - test-function-header-with-multiple-args-and-outputs/output:0")
1496 (check-strings-equal *(ebx+0x10) "ecx" "F - test-function-header-with-multiple-args-and-outputs/output:0/register")
1497 8b/-> *(ebx+4) 3/r32/ebx
1498 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args-and-outputs/output:0/type:1")
1499 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args-and-outputs/output:0/type:1")
1500
1501 8b/-> *(edx+4) 2/r32/edx
1502
1503 8b/-> *edx 3/r32/ebx
1504 (check-strings-equal *ebx "y" "F - test-function-header-with-multiple-args-and-outputs/output:1")
1505 (check-strings-equal *(ebx+0x10) "edx" "F - test-function-header-with-multiple-args-and-outputs/output:0/register")
1506 8b/-> *(ebx+4) 3/r32/ebx
1507 (check-ints-equal *ebx 1 "F - test-function-header-with-multiple-args-and-outputs/output:1/type:1")
1508 (check-ints-equal *(ebx+4) 0 "F - test-function-header-with-multiple-args-and-outputs/output:1/type:1")
1509
1510 89/<- %esp 5/r32/ebp
1511 5d/pop-to-ebp
1512 c3/return
1513
1514
1515
1516
1517
1518
1519 parse-var-with-type:
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544 55/push-ebp
1545 89/<- %ebp 4/r32/esp
1546
1547 51/push-ecx
1548 52/push-edx
1549 53/push-ebx
1550 56/push-esi
1551 57/push-edi
1552
1553 (allocate Heap *Var-size)
1554 (zero-out %eax *Var-size)
1555 89/<- %edi 0/r32/eax
1556
1557 8b/-> *(ebp+8) 6/r32/esi
1558
1559 68/push 0/imm32/end
1560 68/push 0/imm32/start
1561 89/<- %ecx 4/r32/esp
1562 $parse-var-with-type:save-name:
1563
1564 (next-token-from-slice *esi *(esi+4) 0x2f %ecx)
1565
1566 8b/-> *(ecx+4) 2/r32/edx
1567
1568 {
1569 8b/-> *(ecx+4) 0/r32/eax
1570 48/decrement-eax
1571 8a/copy-byte *eax 3/r32/BL
1572 81 4/subop/and %ebx 0xff/imm32
1573 81 7/subop/compare %ebx 0x3a/imm32/colon
1574 75/jump-if-!= break/disp8
1575 89/<- *(ecx+4) 0/r32/eax
1576 }
1577
1578 {
1579 8b/-> *(ecx+4) 0/r32/eax
1580 48/decrement-eax
1581 8a/copy-byte *eax 3/r32/BL
1582 81 4/subop/and %ebx 0xff/imm32
1583 81 7/subop/compare %ebx 0x2c/imm32/comma
1584 75/jump-if-!= break/disp8
1585 89/<- *(ecx+4) 0/r32/eax
1586 }
1587 $parse-var-with-type:write-name:
1588 (slice-to-string Heap %ecx)
1589 89/<- *edi 0/r32/eax
1590
1591 $parse-var-with-type:save-register:
1592 (next-token-from-slice %edx *(esi+4) 0x2f %ecx)
1593
1594 {
1595 8b/-> *(ecx+4) 0/r32/eax
1596 48/decrement-eax
1597 8a/copy-byte *eax 3/r32/BL
1598 81 4/subop/and %ebx 0xff/imm32
1599 81 7/subop/compare %ebx 0x3a/imm32/colon
1600 75/jump-if-!= break/disp8
1601 89/<- *(ecx+4) 0/r32/eax
1602 }
1603
1604 {
1605 8b/-> *(ecx+4) 0/r32/eax
1606 48/decrement-eax
1607 8a/copy-byte *eax 3/r32/BL
1608 81 4/subop/and %ebx 0xff/imm32
1609 81 7/subop/compare %ebx 0x2c/imm32/comma
1610 75/jump-if-!= break/disp8
1611 89/<- *(ecx+4) 0/r32/eax
1612 }
1613
1614 {
1615 $parse-var-with-type:write-register:
1616
1617
1618 8b/-> *ecx 0/r32/eax
1619 39/compare 0/r32/eax *(ecx+4)
1620 76/jump-if-<= break/disp8
1621 (slice-to-string Heap %ecx)
1622 89/<- *(edi+0x10) 0/r32/eax
1623 }
1624 $parse-var-with-type:save-type:
1625 (parse-type Heap *(ebp+0xc))
1626 89/<- *(edi+4) 0/r32/eax
1627 $parse-var-with-type:end:
1628
1629 89/<- %eax 7/r32/edi
1630
1631 81 0/subop/add %esp 8/imm32
1632
1633 5f/pop-to-edi
1634 5e/pop-to-esi
1635 5b/pop-to-ebx
1636 5a/pop-to-edx
1637 59/pop-to-ecx
1638
1639 89/<- %esp 5/r32/ebp
1640 5d/pop-to-ebp
1641 c3/return
1642
1643 $parse-var-with-type:abort:
1644
1645 (write-buffered Stderr "var should have form 'name: type' in '")
1646 (flush Stderr)
1647 (rewind-stream *(ebp+0xc))
1648 (write-stream 2 *(ebp+0xc))
1649 (write-buffered Stderr "'\n")
1650 (flush Stderr)
1651
1652 bb/copy-to-ebx 1/imm32
1653 b8/copy-to-eax 1/imm32/exit
1654 cd/syscall 0x80/imm8
1655
1656
1657 parse-type:
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675 55/push-ebp
1676 89/<- %ebp 4/r32/esp
1677
1678 51/push-ecx
1679 52/push-edx
1680
1681 68/push 0/imm32
1682 68/push 0/imm32
1683 89/<- %ecx 4/r32/esp
1684
1685 (next-mu-token *(ebp+0xc) %ecx)
1686
1687
1688
1689
1690
1691 (slice-equal? %ecx "")
1692 3d/compare-eax-and 0/imm32
1693 0f 85/jump-if-!= $parse-type:abort/disp32
1694
1695 (slice-equal? %ecx "{")
1696 3d/compare-eax-and 0/imm32
1697 0f 85/jump-if-!= $parse-type:abort/disp32
1698
1699 (slice-equal? %ecx "}")
1700 3d/compare-eax-and 0/imm32
1701 0f 85/jump-if-!= $parse-type:abort/disp32
1702
1703 (slice-equal? %ecx "->")
1704 3d/compare-eax-and 0/imm32
1705 0f 85/jump-if-!= $parse-type:abort/disp32
1706
1707 (slice-equal? %ecx ")")
1708 3d/compare-eax-and 0/imm32
1709 b8/copy-to-eax 0/imm32
1710 0f 85/jump-if-!= $parse-type:end/disp32
1711
1712 (allocate *(ebp+8) *Tree-size)
1713 (zero-out %eax *Tree-size)
1714 89/<- %edx 0/r32/eax
1715 {
1716
1717 (slice-equal? %ecx "(")
1718 3d/compare-eax-and 0/imm32
1719 75/jump-if-!= break/disp8
1720
1721 (pos-slice Type-id %ecx)
1722
1723
1724
1725
1726 89/<- *edx 0/r32/eax
1727 e9/jump $parse-type:return-edx/disp32
1728 }
1729
1730
1731 (parse-type *(ebp+8) *(ebp+0xc))
1732
1733
1734 89/<- *edx 0/r32/eax
1735
1736 (parse-type-tree *(ebp+8) *(ebp+0xc))
1737
1738
1739
1740
1741 89/<- *(edx+4) 0/r32/eax
1742 $parse-type:return-edx:
1743 89/<- %eax 2/r32/edx
1744 $parse-type:end:
1745
1746 81 0/subop/add %esp 8/imm32
1747
1748 5a/pop-to-edx
1749 59/pop-to-ecx
1750
1751 89/<- %esp 5/r32/ebp
1752 5d/pop-to-ebp
1753 c3/return
1754
1755 $parse-type:abort:
1756
1757 (write-buffered Stderr "unexpected token when parsing type: '")
1758 (write-slice-buffered Stderr %ecx)
1759 (write-buffered Stderr "'\n")
1760 (flush Stderr)
1761
1762 bb/copy-to-ebx 1/imm32
1763 b8/copy-to-eax 1/imm32/exit
1764 cd/syscall 0x80/imm8
1765
1766
1767 parse-type-tree:
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778 55/push-ebp
1779 89/<- %ebp 4/r32/esp
1780
1781 51/push-ecx
1782 52/push-edx
1783
1784 (parse-type *(ebp+8) *(ebp+0xc))
1785
1786 3d/compare-eax-and 0/imm32
1787 74/jump-if-= $parse-type-tree:end/disp8
1788
1789 89/<- %ecx 0/r32/eax
1790
1791 (allocate *(ebp+8) *Tree-size)
1792 (zero-out %eax *Tree-size)
1793 89/<- %edx 0/r32/eax
1794
1795 89/<- *edx 1/r32/ecx
1796
1797 (parse-type-tree *(ebp+8) *(ebp+0xc))
1798 89/<- *(edx+4) 0/r32/eax
1799 $parse-type-tree:return-edx:
1800 89/<- %eax 2/r32/edx
1801 $parse-type-tree:end:
1802
1803 5a/pop-to-edx
1804 59/pop-to-ecx
1805
1806 89/<- %esp 5/r32/ebp
1807 5d/pop-to-ebp
1808 c3/return
1809
1810 next-mu-token:
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873 55/push-ebp
1874 89/<- %ebp 4/r32/esp
1875
1876 50/push-eax
1877 51/push-ecx
1878 56/push-esi
1879 57/push-edi
1880
1881 8b/-> *(ebp+8) 6/r32/esi
1882
1883 8b/-> *(ebp+0xc) 7/r32/edi
1884 $next-mu-token:start:
1885 (skip-chars-matching-whitespace %esi)
1886 $next-mu-token:check0:
1887
1888
1889 8b/-> *(esi+4) 1/r32/ecx
1890
1891 3b/compare 1/r32/ecx *esi
1892 c7 0/subop/copy *edi 0/imm32
1893 c7 0/subop/copy *(edi+4) 0/imm32
1894 0f 8d/jump-if->= $next-mu-token:end/disp32
1895
1896 8d/copy-address *(esi+ecx+0xc) 0/r32/eax
1897 89/<- *edi 0/r32/eax
1898
1899 31/xor %eax 0/r32/eax
1900 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
1901 {
1902 $next-mu-token:check-for-colon:
1903
1904 3d/compare-eax-and 0x3a/imm32/colon
1905 75/jump-if-!= break/disp8
1906
1907 ff 0/subop/increment *(esi+4)
1908
1909 e9/jump $next-mu-token:start/disp32
1910 }
1911 {
1912 $next-mu-token:check-for-comma:
1913
1914 3d/compare-eax-and 0x2c/imm32/comma
1915 75/jump-if-!= break/disp8
1916
1917 ff 0/subop/increment *(esi+4)
1918
1919 e9/jump $next-mu-token:start/disp32
1920 }
1921 {
1922 $next-mu-token:check-for-comment:
1923
1924 3d/compare-eax-and 0x23/imm32/pound
1925 75/jump-if-!= break/disp8
1926
1927 8b/-> *esi 0/r32/eax
1928 89/<- *(esi+4) 0/r32/eax
1929
1930 e9/jump $next-mu-token:done/disp32
1931 }
1932 {
1933 $next-mu-token:check-for-string-literal:
1934
1935 3d/compare-eax-and 0x22/imm32/dquote
1936 75/jump-if-!= break/disp8
1937 (skip-string %esi)
1938
1939 e9/jump $next-mu-token:done/disp32
1940 }
1941 {
1942 $next-mu-token:check-for-open-paren:
1943
1944 3d/compare-eax-and 0x28/imm32/open-paren
1945 75/jump-if-!= break/disp8
1946
1947 ff 0/subop/increment *(esi+4)
1948
1949 e9/jump $next-mu-token:done/disp32
1950 }
1951 {
1952 $next-mu-token:check-for-close-paren:
1953
1954 3d/compare-eax-and 0x29/imm32/close-paren
1955 75/jump-if-!= break/disp8
1956
1957 ff 0/subop/increment *(esi+4)
1958
1959 e9/jump $next-mu-token:done/disp32
1960 }
1961 {
1962 $next-mu-token:regular-word-without-metadata:
1963
1964
1965 8b/-> *(esi+4) 1/r32/ecx
1966
1967 3b/compare *esi 1/r32/ecx
1968 7d/jump-if->= break/disp8
1969
1970 31/xor %eax 0/r32/eax
1971 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
1972
1973 3d/compare-eax-and 0x20/imm32/space
1974 74/jump-if-= break/disp8
1975
1976 3d/compare-eax-and 0xd/imm32/carriage-return
1977 74/jump-if-= break/disp8
1978
1979 3d/compare-eax-and 0xa/imm32/newline
1980 74/jump-if-= break/disp8
1981
1982 3d/compare-eax-and 0x28/imm32/open-paren
1983 0f 84/jump-if-= break/disp32
1984
1985 3d/compare-eax-and 0x29/imm32/close-paren
1986 0f 84/jump-if-= break/disp32
1987
1988 3d/compare-eax-and 0x3a/imm32/colon
1989 0f 84/jump-if-= break/disp32
1990
1991 3d/compare-eax-and 0x2c/imm32/comma
1992 0f 84/jump-if-= break/disp32
1993
1994 ff 0/subop/increment *(esi+4)
1995
1996 e9/jump loop/disp32
1997 }
1998 $next-mu-token:done:
1999
2000 8b/-> *(esi+4) 1/r32/ecx
2001 8d/copy-address *(esi+ecx+0xc) 0/r32/eax
2002 89/<- *(edi+4) 0/r32/eax
2003 {
2004 $next-mu-token:skip-trailing-delimiters:
2005
2006
2007 8b/-> *(esi+4) 1/r32/ecx
2008
2009 3b/compare *esi 1/r32/ecx
2010 7d/jump-if->= break/disp8
2011
2012 31/xor %eax 0/r32/eax
2013 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
2014
2015 {
2016 3d/compare-eax-and 0x3a/imm32/colon
2017 75/jump-if-!= break/disp8
2018
2019 ff 0/subop/increment *(esi+4)
2020
2021 eb/jump $next-mu-token:skip-trailing-delimiters/disp8
2022 }
2023
2024 {
2025 3d/compare-eax-and 0x2c/imm32/comma
2026 75/jump-if-!= break/disp8
2027
2028 ff 0/subop/increment *(esi+4)
2029
2030 eb/jump $next-mu-token:skip-trailing-delimiters/disp8
2031 }
2032
2033 }
2034 $next-mu-token:end:
2035
2036 5f/pop-to-edi
2037 5e/pop-to-esi
2038 59/pop-to-ecx
2039 58/pop-to-eax
2040
2041 89/<- %esp 5/r32/ebp
2042 5d/pop-to-ebp
2043 c3/return
2044
2045
2046
2047 pos-slice:
2048
2049 55/push-ebp
2050 89/<- %ebp 4/r32/esp
2051
2052 51/push-ecx
2053 52/push-edx
2054 53/push-ebx
2055 56/push-esi
2056
2057
2058
2059
2060
2061 8b/-> *(ebp+8) 6/r32/esi
2062
2063 b9/copy-to-ecx 0/imm32
2064
2065 8d/copy-address *(esi+0xc) 2/r32/edx
2066
2067 8b/-> *esi 3/r32/ebx
2068 8d/copy-address *(esi+ebx+0xc) 3/r32/ebx
2069 {
2070
2071
2072
2073
2074
2075 39/compare %edx 3/r32/ebx
2076 b8/copy-to-eax -1/imm32
2077 73/jump-if-addr>= $pos-slice:end/disp8
2078
2079 (slice-equal? *(ebp+0xc) *edx)
2080 3d/compare-eax-and 0/imm32
2081 75/jump-if-!= break/disp8
2082
2083 41/increment-ecx
2084
2085 81 0/subop/add %edx 4/imm32
2086
2087 eb/jump loop/disp8
2088 }
2089
2090 89/<- %eax 1/r32/ecx
2091 $pos-slice:end:
2092
2093
2094
2095
2096 5e/pop-to-esi
2097 5b/pop-to-ebx
2098 5a/pop-to-edx
2099 59/pop-to-ecx
2100
2101 89/<- %esp 5/r32/ebp
2102 5d/pop-to-ebp
2103 c3/return
2104
2105 == data
2106
2107 Type-id:
2108 0x18/imm32/write
2109 0/imm32/read
2110 0x100/imm32/length
2111
2112 "literal"/imm32
2113 "int"/imm32
2114 "addr"/imm32
2115 "array"/imm32
2116 "handle"/imm32
2117 "bool"/imm32
2118 0/imm32
2119 0/imm32
2120
2121 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
2122 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
2123 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
2124 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
2125 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
2126 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
2127 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
2128
2129 == code
2130
2131 test-parse-var-with-type:
2132
2133 55/push-ebp
2134 89/<- %ebp 4/r32/esp
2135
2136 b8/copy-to-eax "x:"/imm32
2137 8b/-> *eax 1/r32/ecx
2138 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2139 05/add-to-eax 4/imm32
2140
2141 51/push-ecx
2142 50/push-eax
2143 89/<- %ecx 4/r32/esp
2144
2145 (clear-stream _test-input-stream)
2146 (write _test-input-stream "int")
2147
2148 (parse-var-with-type %ecx _test-input-stream)
2149 8b/-> *eax 2/r32/edx
2150 (check-strings-equal %edx "x" "F - test-var-with-type/name")
2151 8b/-> *(eax+4) 2/r32/edx
2152 (check-ints-equal *edx 1 "F - test-var-with-type/type")
2153 (check-ints-equal *(edx+4) 0 "F - test-var-with-type/type")
2154
2155 89/<- %esp 5/r32/ebp
2156 5d/pop-to-ebp
2157 c3/return
2158
2159 test-parse-var-with-type-and-register:
2160
2161 55/push-ebp
2162 89/<- %ebp 4/r32/esp
2163
2164 b8/copy-to-eax "x/eax"/imm32
2165 8b/-> *eax 1/r32/ecx
2166 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2167 05/add-to-eax 4/imm32
2168
2169 51/push-ecx
2170 50/push-eax
2171 89/<- %ecx 4/r32/esp
2172
2173 (clear-stream _test-input-stream)
2174 (write _test-input-stream ": int")
2175
2176 (parse-var-with-type %ecx _test-input-stream)
2177 8b/-> *eax 2/r32/edx
2178 (check-strings-equal %edx "x" "F - test-var-with-type-and-register/name")
2179 8b/-> *(eax+0x10) 2/r32/edx
2180 (check-strings-equal %edx "eax" "F - test-var-with-type-and-register/register")
2181 8b/-> *(eax+4) 2/r32/edx
2182 (check-ints-equal *edx 1 "F - test-var-with-type-and-register/type")
2183 (check-ints-equal *(edx+4) 0 "F - test-var-with-type-and-register/type")
2184
2185 89/<- %esp 5/r32/ebp
2186 5d/pop-to-ebp
2187 c3/return
2188
2189 test-parse-var-with-trailing-characters:
2190
2191 55/push-ebp
2192 89/<- %ebp 4/r32/esp
2193
2194 b8/copy-to-eax "x:"/imm32
2195 8b/-> *eax 1/r32/ecx
2196 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2197 05/add-to-eax 4/imm32
2198
2199 51/push-ecx
2200 50/push-eax
2201 89/<- %ecx 4/r32/esp
2202
2203 (clear-stream _test-input-stream)
2204 (write _test-input-stream "int,")
2205
2206 (parse-var-with-type %ecx _test-input-stream)
2207 8b/-> *eax 2/r32/edx
2208 (check-strings-equal %edx "x" "F - test-var-with-trailing-characters/name")
2209 8b/-> *(eax+0x10) 2/r32/edx
2210 (check-ints-equal %edx 0 "F - test-var-with-trailing-characters/register")
2211 8b/-> *(eax+4) 2/r32/edx
2212 (check-ints-equal *edx 1 "F - test-var-with-trailing-characters/type")
2213 (check-ints-equal *(edx+4) 0 "F - test-var-with-trailing-characters/type")
2214
2215 89/<- %esp 5/r32/ebp
2216 5d/pop-to-ebp
2217 c3/return
2218
2219 test-parse-var-with-register-and-trailing-characters:
2220
2221 55/push-ebp
2222 89/<- %ebp 4/r32/esp
2223
2224 b8/copy-to-eax "x/eax:"/imm32
2225 8b/-> *eax 1/r32/ecx
2226 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2227 05/add-to-eax 4/imm32
2228
2229 51/push-ecx
2230 50/push-eax
2231 89/<- %ecx 4/r32/esp
2232
2233 (clear-stream _test-input-stream)
2234 (write _test-input-stream "int,")
2235
2236 (parse-var-with-type %ecx _test-input-stream)
2237 8b/-> *eax 2/r32/edx
2238 (check-strings-equal %edx "x" "F - test-var-with-register-and-trailing-characters/name")
2239 8b/-> *(eax+0x10) 2/r32/edx
2240 (check-strings-equal %edx "eax" "F - test-var-with-register-and-trailing-characters/register")
2241 8b/-> *(eax+4) 2/r32/edx
2242 (check-ints-equal *edx 1 "F - test-var-with-register-and-trailing-characters/type")
2243 (check-ints-equal *(edx+4) 0 "F - test-var-with-register-and-trailing-characters/type")
2244
2245 89/<- %esp 5/r32/ebp
2246 5d/pop-to-ebp
2247 c3/return
2248
2249 test-parse-var-with-compound-type:
2250
2251 55/push-ebp
2252 89/<- %ebp 4/r32/esp
2253
2254 b8/copy-to-eax "x:"/imm32
2255 8b/-> *eax 1/r32/ecx
2256 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2257 05/add-to-eax 4/imm32
2258
2259 51/push-ecx
2260 50/push-eax
2261 89/<- %ecx 4/r32/esp
2262
2263 (clear-stream _test-input-stream)
2264 (write _test-input-stream "(addr int)")
2265
2266 (parse-var-with-type %ecx _test-input-stream)
2267 8b/-> *eax 2/r32/edx
2268 (check-strings-equal %edx "x" "F - test-var-with-compound-type/name")
2269 8b/-> *(eax+0x10) 2/r32/edx
2270 (check-ints-equal %edx 0 "F - test-var-with-compound-type/register")
2271
2272 8b/-> *(eax+4) 2/r32/edx
2273
2274 8b/-> *edx 0/r32/eax
2275 (check-ints-equal *eax 2 "F - test-var-with-compound-type/type:0")
2276
2277 8b/-> *(edx+4) 2/r32/edx
2278 8b/-> *edx 0/r32/eax
2279 (check-ints-equal *eax 1 "F - test-var-with-compound-type/type:1")
2280
2281 (check-ints-equal *(edx+4) 0 "F - test-var-with-compound-type/type:2")
2282
2283 89/<- %esp 5/r32/ebp
2284 5d/pop-to-ebp
2285 c3/return
2286
2287
2288
2289
2290 is-identifier?:
2291
2292 55/push-ebp
2293 89/<- %ebp 4/r32/esp
2294
2295 (slice-empty? *(ebp+8))
2296 3d/compare-eax-and 0/imm32
2297 75/jump-if-!= $is-identifier?:false/disp8
2298
2299 8b/-> *(ebp+8) 0/r32/eax
2300 8b/-> *eax 0/r32/eax
2301 8a/copy-byte *eax 0/r32/AL
2302 81 4/subop/and %eax 0xff/imm32
2303
2304 3d/compare-eax-and 0x24/imm32/$
2305 74/jump-if-= $is-identifier?:true/disp8
2306
2307 3d/compare-eax-and 0x5f/imm32/_
2308 74/jump-if-= $is-identifier?:true/disp8
2309
2310 25/and-eax-with 0x5f/imm32
2311
2312 3d/compare-eax-and 0x41/imm32/A
2313 7c/jump-if-< $is-identifier?:false/disp8
2314
2315 3d/compare-eax-and 0x5a/imm32/Z
2316 7f/jump-if-> $is-identifier?:false/disp8
2317
2318 $is-identifier?:true:
2319 b8/copy-to-eax 1/imm32/true
2320 eb/jump $is-identifier?:end/disp8
2321 $is-identifier?:false:
2322 b8/copy-to-eax 0/imm32/false
2323 $is-identifier?:end:
2324
2325 89/<- %esp 5/r32/ebp
2326 5d/pop-to-ebp
2327 c3/return
2328
2329 test-is-identifier-dollar:
2330
2331 55/push-ebp
2332 89/<- %ebp 4/r32/esp
2333
2334 b8/copy-to-eax "$a"/imm32
2335 8b/-> *eax 1/r32/ecx
2336 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2337 05/add-to-eax 4/imm32
2338
2339 51/push-ecx
2340 50/push-eax
2341 89/<- %ecx 4/r32/esp
2342
2343 (is-identifier? %ecx)
2344 (check-ints-equal %eax 1 "F - test-is-identifier-dollar")
2345
2346 89/<- %esp 5/r32/ebp
2347 5d/pop-to-ebp
2348 c3/return
2349
2350 test-is-identifier-underscore:
2351
2352 55/push-ebp
2353 89/<- %ebp 4/r32/esp
2354
2355 b8/copy-to-eax "_a"/imm32
2356 8b/-> *eax 1/r32/ecx
2357 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2358 05/add-to-eax 4/imm32
2359
2360 51/push-ecx
2361 50/push-eax
2362 89/<- %ecx 4/r32/esp
2363
2364 (is-identifier? %ecx)
2365 (check-ints-equal %eax 1 "F - test-is-identifier-underscore")
2366
2367 89/<- %esp 5/r32/ebp
2368 5d/pop-to-ebp
2369 c3/return
2370
2371 test-is-identifier-a:
2372
2373 55/push-ebp
2374 89/<- %ebp 4/r32/esp
2375
2376 b8/copy-to-eax "a$"/imm32
2377 8b/-> *eax 1/r32/ecx
2378 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2379 05/add-to-eax 4/imm32
2380
2381 51/push-ecx
2382 50/push-eax
2383 89/<- %ecx 4/r32/esp
2384
2385 (is-identifier? %ecx)
2386 (check-ints-equal %eax 1 "F - test-is-identifier-a")
2387
2388 89/<- %esp 5/r32/ebp
2389 5d/pop-to-ebp
2390 c3/return
2391
2392 test-is-identifier-z:
2393
2394 55/push-ebp
2395 89/<- %ebp 4/r32/esp
2396
2397 b8/copy-to-eax "z$"/imm32
2398 8b/-> *eax 1/r32/ecx
2399 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2400 05/add-to-eax 4/imm32
2401
2402 51/push-ecx
2403 50/push-eax
2404 89/<- %ecx 4/r32/esp
2405
2406 (is-identifier? %ecx)
2407 (check-ints-equal %eax 1 "F - test-is-identifier-z")
2408
2409 89/<- %esp 5/r32/ebp
2410 5d/pop-to-ebp
2411 c3/return
2412
2413 test-is-identifier-A:
2414
2415 55/push-ebp
2416 89/<- %ebp 4/r32/esp
2417
2418 b8/copy-to-eax "A$"/imm32
2419 8b/-> *eax 1/r32/ecx
2420 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2421 05/add-to-eax 4/imm32
2422
2423 51/push-ecx
2424 50/push-eax
2425 89/<- %ecx 4/r32/esp
2426
2427 (is-identifier? %ecx)
2428 (check-ints-equal %eax 1 "F - test-is-identifier-A")
2429
2430 89/<- %esp 5/r32/ebp
2431 5d/pop-to-ebp
2432 c3/return
2433
2434 test-is-identifier-Z:
2435
2436 55/push-ebp
2437 89/<- %ebp 4/r32/esp
2438
2439 b8/copy-to-eax "Z$"/imm32
2440 8b/-> *eax 1/r32/ecx
2441 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2442 05/add-to-eax 4/imm32
2443
2444 51/push-ecx
2445 50/push-eax
2446 89/<- %ecx 4/r32/esp
2447
2448 (is-identifier? %ecx)
2449 (check-ints-equal %eax 1 "F - test-is-identifier-Z")
2450
2451 89/<- %esp 5/r32/ebp
2452 5d/pop-to-ebp
2453 c3/return
2454
2455 test-is-identifier-@:
2456
2457
2458 55/push-ebp
2459 89/<- %ebp 4/r32/esp
2460
2461 b8/copy-to-eax "@a"/imm32
2462 8b/-> *eax 1/r32/ecx
2463 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2464 05/add-to-eax 4/imm32
2465
2466 51/push-ecx
2467 50/push-eax
2468 89/<- %ecx 4/r32/esp
2469
2470 (is-identifier? %ecx)
2471 (check-ints-equal %eax 0 "F - test-is-identifier-@")
2472
2473 89/<- %esp 5/r32/ebp
2474 5d/pop-to-ebp
2475 c3/return
2476
2477 test-is-identifier-square-bracket:
2478
2479
2480 55/push-ebp
2481 89/<- %ebp 4/r32/esp
2482
2483 b8/copy-to-eax "[a"/imm32
2484 8b/-> *eax 1/r32/ecx
2485 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2486 05/add-to-eax 4/imm32
2487
2488 51/push-ecx
2489 50/push-eax
2490 89/<- %ecx 4/r32/esp
2491
2492 (is-identifier? %ecx)
2493 (check-ints-equal %eax 0 "F - test-is-identifier-@")
2494
2495 89/<- %esp 5/r32/ebp
2496 5d/pop-to-ebp
2497 c3/return
2498
2499 test-is-identifier-backtick:
2500
2501
2502 55/push-ebp
2503 89/<- %ebp 4/r32/esp
2504
2505 b8/copy-to-eax "`a"/imm32
2506 8b/-> *eax 1/r32/ecx
2507 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2508 05/add-to-eax 4/imm32
2509
2510 51/push-ecx
2511 50/push-eax
2512 89/<- %ecx 4/r32/esp
2513
2514 (is-identifier? %ecx)
2515 (check-ints-equal %eax 0 "F - test-is-identifier-backtick")
2516
2517 89/<- %esp 5/r32/ebp
2518 5d/pop-to-ebp
2519 c3/return
2520
2521 test-is-identifier-curly-brace-open:
2522
2523
2524 55/push-ebp
2525 89/<- %ebp 4/r32/esp
2526
2527 b8/copy-to-eax "{a"/imm32
2528 8b/-> *eax 1/r32/ecx
2529 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2530 05/add-to-eax 4/imm32
2531
2532 51/push-ecx
2533 50/push-eax
2534 89/<- %ecx 4/r32/esp
2535
2536 (is-identifier? %ecx)
2537 (check-ints-equal %eax 0 "F - test-is-identifier-curly-brace-open")
2538
2539 89/<- %esp 5/r32/ebp
2540 5d/pop-to-ebp
2541 c3/return
2542
2543 test-is-identifier-curly-brace-close:
2544
2545 55/push-ebp
2546 89/<- %ebp 4/r32/esp
2547
2548 b8/copy-to-eax "}a"/imm32
2549 8b/-> *eax 1/r32/ecx
2550 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2551 05/add-to-eax 4/imm32
2552
2553 51/push-ecx
2554 50/push-eax
2555 89/<- %ecx 4/r32/esp
2556
2557 (is-identifier? %ecx)
2558 (check-ints-equal %eax 0 "F - test-is-identifier-curly-brace-close")
2559
2560 89/<- %esp 5/r32/ebp
2561 5d/pop-to-ebp
2562 c3/return
2563
2564 test-is-identifier-hyphen:
2565
2566
2567 55/push-ebp
2568 89/<- %ebp 4/r32/esp
2569
2570 b8/copy-to-eax "-a"/imm32
2571 8b/-> *eax 1/r32/ecx
2572 8d/copy-address *(eax+ecx+4) 1/r32/ecx
2573 05/add-to-eax 4/imm32
2574
2575 51/push-ecx
2576 50/push-eax
2577 89/<- %ecx 4/r32/esp
2578
2579 (is-identifier? %ecx)
2580 (check-ints-equal %eax 0 "F - test-is-identifier-hyphen")
2581
2582 89/<- %esp 5/r32/ebp
2583 5d/pop-to-ebp
2584 c3/return
2585
2586 populate-mu-function-body:
2587
2588 55/push-ebp
2589 89/<- %ebp 4/r32/esp
2590
2591 50/push-eax
2592 56/push-esi
2593 57/push-edi
2594
2595 8b/-> *(ebp+8) 6/r32/esi
2596
2597 8b/-> *(ebp+0xc) 7/r32/edi
2598
2599 c7 0/subop/copy *Curr-block-depth 0/imm32
2600 c7 0/subop/copy *Next-local-stack-offset -4/imm32
2601
2602 (parse-mu-block %esi *(ebp+0x10) %edi)
2603
2604 89/<- *(edi+0x10) 0/r32/eax
2605 $populate-mu-function-body:end:
2606
2607 5f/pop-to-edi
2608 5e/pop-to-esi
2609 58/pop-to-eax
2610
2611 89/<- %esp 5/r32/ebp
2612 5d/pop-to-ebp
2613 c3/return
2614
2615 == data
2616
2617
2618 Curr-block-depth:
2619 0/imm32
2620 Next-local-stack-offset:
2621 -4/imm32
2622
2623 == code
2624
2625
2626 parse-mu-block:
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660 55/push-ebp
2661 89/<- %ebp 4/r32/esp
2662
2663 51/push-ecx
2664 52/push-edx
2665 53/push-ebx
2666 57/push-edi
2667
2668 81 5/subop/subtract %esp 0x200/imm32
2669 68/push 0x200/imm32/length
2670 68/push 0/imm32/read
2671 68/push 0/imm32/write
2672 89/<- %ecx 4/r32/esp
2673
2674 68/push 0/imm32/end
2675 68/push 0/imm32/start
2676 89/<- %edx 4/r32/esp
2677
2678 (allocate Heap *Stmt-size)
2679 (zero-out %eax *Stmt-size)
2680 89/<- %edi 0/r32/eax
2681 {
2682 $parse-mu-block:line-loop:
2683
2684 (clear-stream %ecx)
2685 (read-line-buffered *(ebp+8) %ecx)
2686
2687
2688
2689
2690
2691 81 7/subop/compare *ecx 0/imm32
2692 0f 84/jump-if-= break/disp32
2693
2694 (next-word %ecx %edx)
2695
2696
2697
2698
2699
2700 (slice-empty? %edx)
2701 3d/compare-eax-and 0/imm32
2702 0f 85/jump-if-!= loop/disp32
2703
2704
2705 8b/-> *edx 0/r32/eax
2706 8a/copy-byte *eax 0/r32/AL
2707 81 4/subop/and %eax 0xff/imm32
2708
2709 3d/compare-eax-and 0x23/imm32/hash
2710 0f 84/jump-if-= loop/disp32
2711
2712 {
2713 $parse-mu-block:check-for-block:
2714 (slice-equal? %edx "{")
2715 3d/compare-eax-and 0/imm32
2716 74/jump-if-= break/disp8
2717 (check-no-tokens-left %ecx)
2718
2719 (parse-mu-block *(ebp+8) *(ebp+0xc) *(ebp+0x10))
2720 (append-to-block Heap %edi %eax)
2721 e9/jump $parse-mu-block:line-loop/disp32
2722 }
2723
2724 $parse-mu-block:check-for-end:
2725 (slice-equal? %edx "}")
2726 3d/compare-eax-and 0/imm32
2727 0f 85/jump-if-!= break/disp32
2728
2729 {
2730 $parse-mu-block:check-for-named-block:
2731
2732 8b/-> *(edx+4) 0/r32/eax
2733 8a/copy-byte *eax 0/r32/AL
2734 81 4/subop/and %eax 0xff/imm32
2735
2736 3d/compare-eax-and 0x23/imm32/hash
2737 0f 85/jump-if-!= break/disp32
2738
2739 (parse-mu-named-block %edx %ecx *(ebp+8) *(ebp+0xc) *(ebp+0x10))
2740 (append-to-block Heap %edi %eax)
2741 e9/jump $parse-mu-block:line-loop/disp32
2742 }
2743
2744 {
2745 $parse-mu-block:check-for-var:
2746 (slice-equal? %edx "var")
2747 3d/compare-eax-and 0/imm32
2748 74/jump-if-= break/disp8
2749
2750 (parse-mu-var-def %ecx *(ebp+0xc))
2751 (append-to-block Heap %edi %eax)
2752 e9/jump $parse-mu-block:line-loop/disp32
2753 }
2754 $parse-mu-block:regular-stmt:
2755
2756 (parse-mu-stmt %ecx *(ebp+0xc) *(ebp+0x10))
2757 (append-to-block Heap %edi %eax)
2758 e9/jump loop/disp32
2759 }
2760
2761 89/<- %eax 7/r32/edi
2762 $parse-mu-block:end:
2763
2764 81 0/subop/add %esp 0x214/imm32
2765
2766 5f/pop-to-edi
2767 5b/pop-to-ebx
2768 5a/pop-to-edx
2769 59/pop-to-ecx
2770
2771 89/<- %esp 5/r32/ebp
2772 5d/pop-to-ebp
2773 c3/return
2774
2775 $parse-mu-block:abort:
2776
2777 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
2778 (rewind-stream %ecx)
2779 (write-stream 2 %ecx)
2780 (write-buffered Stderr "'\n")
2781 (flush Stderr)
2782
2783 bb/copy-to-ebx 1/imm32
2784 b8/copy-to-eax 1/imm32/exit
2785 cd/syscall 0x80/imm8
2786
2787
2788 check-no-tokens-left:
2789
2790 55/push-ebp
2791 89/<- %ebp 4/r32/esp
2792
2793 50/push-eax
2794 51/push-ecx
2795
2796 68/push 0/imm32/end
2797 68/push 0/imm32/start
2798 89/<- %ecx 4/r32/esp
2799
2800 (next-word *(ebp+8) %ecx)
2801
2802 (slice-empty? %ecx)
2803 3d/compare-eax-and 0/imm32
2804 75/jump-if-!= $check-no-tokens-left:end/disp8
2805
2806
2807 8b/-> *edx 0/r32/eax
2808 8a/copy-byte *eax 0/r32/AL
2809 81 4/subop/and %eax 0xff/imm32
2810
2811 3d/compare-eax-and 0x23/imm32/hash
2812 74/jump-if-= $check-no-tokens-left:end/disp8
2813
2814 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
2815 (rewind-stream %ecx)
2816 (write-stream 2 %ecx)
2817 (write-buffered Stderr "'\n")
2818 (flush Stderr)
2819
2820 bb/copy-to-ebx 1/imm32
2821 b8/copy-to-eax 1/imm32/exit
2822 cd/syscall 0x80/imm8
2823
2824 $check-no-tokens-left:end:
2825
2826 81 0/subop/add %esp 8/imm32
2827
2828 59/pop-to-ecx
2829 58/pop-to-eax
2830
2831 89/<- %esp 5/r32/ebp
2832 5d/pop-to-ebp
2833 c3/return
2834
2835 parse-mu-named-block:
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868 55/push-ebp
2869 89/<- %ebp 4/r32/esp
2870
2871 $parse-mu-named-block:end:
2872
2873
2874
2875 89/<- %esp 5/r32/ebp
2876 5d/pop-to-ebp
2877 c3/return
2878
2879 parse-mu-var-def:
2880
2881 55/push-ebp
2882 89/<- %ebp 4/r32/esp
2883
2884 51/push-ecx
2885 52/push-edx
2886
2887 68/push 0/imm32/end
2888 68/push 0/imm32/start
2889 89/<- %ecx 4/r32/esp
2890
2891 (next-word *(ebp+8) %ecx)
2892 (parse-var-with-type %ecx *(ebp+8))
2893 89/<- %edx 0/r32/eax
2894
2895 8b/-> *Next-local-stack-offset 0/r32/eax
2896 89/<- *(edx+0xc) 0/r32/eax
2897
2898 (size-of %edx)
2899 29/subtract-from *Next-local-stack-offset 0/r32/eax
2900
2901 (push *(ebp+0xc) %edx)
2902
2903 8b/-> *(edx+0x10) 0/r32/eax
2904 3d/compare-eax-and 0/imm32
2905 {
2906 75/jump-if-!= break/disp8
2907
2908 (new-vardef Heap %edx)
2909 eb/jump $parse-mu-var-def:end/disp8
2910 }
2911
2912 {
2913 74/jump-if-= break/disp8
2914
2915 (next-word *(ebp+8) %ecx)
2916 (slice-equal? %ecx "<-")
2917 3d/compare-eax-and 0/imm32
2918 74/jump-if-= $parse-mu-var-def:abort/disp8
2919
2920 (new-regvardef Heap %edx)
2921 (add-operation-and-inputs-to-stmt %eax *(ebp+8) *(ebp+0xc))
2922 }
2923 $parse-mu-var-def:end:
2924
2925 81 0/subop/add %esp 8/imm32
2926
2927 5a/pop-to-edx
2928 59/pop-to-ecx
2929
2930 89/<- %esp 5/r32/ebp
2931 5d/pop-to-ebp
2932 c3/return
2933
2934 $parse-mu-var-def:abort:
2935 (rewind-stream *(ebp+8))
2936
2937 (write-buffered Stderr "register variable requires a valid instruction to initialize but got '")
2938 (flush Stderr)
2939 (write-stream 2 *(ebp+8))
2940 (write-buffered Stderr "'\n")
2941 (flush Stderr)
2942
2943 bb/copy-to-ebx 1/imm32
2944 b8/copy-to-eax 1/imm32/exit
2945 cd/syscall 0x80/imm8
2946
2947
2948 test-parse-mu-var-def:
2949
2950
2951 55/push-ebp
2952 89/<- %ebp 4/r32/esp
2953
2954 (clear-stream _test-input-stream)
2955 (write _test-input-stream "n: int\n")
2956
2957 81 5/subop/subtract %esp 0x10/imm32
2958 68/push 0x10/imm32/length
2959 68/push 0/imm32/top
2960 89/<- %ecx 4/r32/esp
2961 (clear-stack %ecx)
2962
2963 (parse-mu-var-def _test-input-stream %ecx)
2964
2965 (check-ints-equal *eax 2 "F - test-parse-mu-var-def/tag")
2966 8b/-> *(eax+4) 0/r32/eax
2967 (check-strings-equal *eax "n" "F - test-parse-mu-var-def/var-name")
2968 (check-ints-equal *(eax+0x10) 0 "F - test-parse-mu-var-def/var-register")
2969
2970
2971
2972 8b/-> *(eax+4) 0/r32/eax
2973 (check-ints-equal *eax 1 "F - test-parse-mu-var-def/var-type:0")
2974 (check-ints-equal *(eax+4) 0 "F - test-parse-mu-var-def/var-type:0")
2975
2976 89/<- %esp 5/r32/ebp
2977 5d/pop-to-ebp
2978 c3/return
2979
2980 test-parse-mu-reg-var-def:
2981
2982
2983 55/push-ebp
2984 89/<- %ebp 4/r32/esp
2985
2986 (clear-stream _test-input-stream)
2987 (write _test-input-stream "n/eax: int <- copy 0\n")
2988
2989 81 5/subop/subtract %esp 0x10/imm32
2990 68/push 0x10/imm32/length
2991 68/push 0/imm32/top
2992 89/<- %ecx 4/r32/esp
2993 (clear-stack %ecx)
2994
2995 (parse-mu-var-def _test-input-stream %ecx)
2996
2997 (check-ints-equal *eax 3 "F - test-parse-mu-reg-var-def/tag")
2998 8b/-> *(eax+0xc) 0/r32/eax
2999 (check-strings-equal *eax "n" "F - test-parse-mu-reg-var-def/var-name")
3000 (check-strings-equal *(eax+0x10) "eax" "F - test-parse-mu-reg-var-def/var-register")
3001
3002
3003
3004 8b/-> *(eax+4) 0/r32/eax
3005 (check-ints-equal *eax 1 "F - test-parse-mu-reg-var-def/var-type:0")
3006 (check-ints-equal *(eax+4) 0 "F - test-parse-mu-reg-var-def/var-type:0")
3007
3008 89/<- %esp 5/r32/ebp
3009 5d/pop-to-ebp
3010 c3/return
3011
3012 parse-mu-stmt:
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026 55/push-ebp
3027 89/<- %ebp 4/r32/esp
3028
3029 51/push-ecx
3030 57/push-edi
3031
3032 68/push 0/imm32/end
3033 68/push 0/imm32/start
3034 89/<- %ecx 4/r32/esp
3035
3036 (allocate Heap *Stmt-size)
3037 (zero-out %eax *Stmt-size)
3038 89/<- %edi 0/r32/eax
3039
3040 c7 0/subop/copy *edi 1/imm32/stmt1
3041 {
3042 (stmt-has-outputs? *(ebp+8))
3043 3d/compare-eax-and 0/imm32
3044 0f 84/jump-if-= break/disp32
3045 {
3046 $parse-mu-stmt:read-outputs:
3047
3048 (next-mu-token *(ebp+8) %ecx)
3049
3050
3051
3052
3053 (slice-empty? %ecx)
3054 3d/compare-eax-and 0/imm32
3055 0f 85/jump-if-!= break/disp32
3056
3057 (slice-equal? %ecx "<-")
3058 3d/compare-eax-and 0/imm32
3059 75/jump-if-!= break/disp8
3060
3061 (is-identifier? %ecx)
3062 3d/compare-eax-and 0/imm32
3063 0f 84/jump-if-= $parse-mu-stmt:abort/disp32
3064
3065 (lookup-or-define-var %ecx *(ebp+0xc) *(ebp+0x10))
3066 (append-list Heap %eax *(edi+0xc))
3067 89/<- *(edi+0xc) 0/r32/eax
3068 e9/jump loop/disp32
3069 }
3070 }
3071 (add-operation-and-inputs-to-stmt %edi *(ebp+8) *(ebp+0xc))
3072 $parse-mu-stmt:end:
3073
3074 89/<- %eax 7/r32/edi
3075
3076 81 0/subop/add %esp 8/imm32
3077
3078 5f/pop-to-edi
3079 59/pop-to-ecx
3080
3081 89/<- %esp 5/r32/ebp
3082 5d/pop-to-ebp
3083 c3/return
3084
3085 $parse-mu-stmt:abort:
3086
3087 (write-buffered Stderr "invalid identifier '")
3088 (write-slice-buffered Stderr %ecx)
3089 (write-buffered Stderr "'\n")
3090 (flush Stderr)
3091
3092 bb/copy-to-ebx 1/imm32
3093 b8/copy-to-eax 1/imm32/exit
3094 cd/syscall 0x80/imm8
3095
3096
3097 add-operation-and-inputs-to-stmt:
3098
3099
3100
3101
3102
3103
3104
3105
3106 55/push-ebp
3107 89/<- %ebp 4/r32/esp
3108
3109 50/push-eax
3110 51/push-ecx
3111 57/push-edi
3112
3113 8b/-> *(ebp+8) 7/r32/edi
3114
3115 68/push 0/imm32/end
3116 68/push 0/imm32/start
3117 89/<- %ecx 4/r32/esp
3118 $add-operation-and-inputs-to-stmt:read-operation:
3119 (next-mu-token *(ebp+0xc) %ecx)
3120 (slice-to-string Heap %ecx)
3121 89/<- *(edi+4) 0/r32/eax
3122 {
3123 $add-operation-and-inputs-to-stmt:read-inouts:
3124
3125 (next-mu-token *(ebp+0xc) %ecx)
3126
3127 (slice-empty? %ecx)
3128 3d/compare-eax-and 0/imm32
3129 0f 85/jump-if-!= break/disp32
3130
3131 (slice-equal? %ecx "<-")
3132 3d/compare-eax-and 0/imm32
3133 0f 85/jump-if-!= $add-operation-and-inputs-to-stmt:abort/disp32
3134
3135 (lookup-var-or-literal %ecx *(ebp+0x10))
3136 (append-list Heap %eax *(edi+8))
3137 89/<- *(edi+8) 0/r32/eax
3138 e9/jump loop/disp32
3139 }
3140 $add-operation-and-inputs-to-stmt:end:
3141
3142 81 0/subop/add %esp 8/imm32
3143
3144 5f/pop-to-edi
3145 59/pop-to-ecx
3146 58/pop-to-eax
3147
3148 89/<- %esp 5/r32/ebp
3149 5d/pop-to-ebp
3150 c3/return
3151
3152 $add-operation-and-inputs-to-stmt:abort:
3153
3154 (rewind-stream *(ebp+8))
3155 (write-buffered Stderr "invalid identifier '")
3156 (flush Stderr)
3157 (write-stream 2 *(ebp+8))
3158 (write-buffered Stderr "'\n")
3159 (flush Stderr)
3160
3161 bb/copy-to-ebx 1/imm32
3162 b8/copy-to-eax 1/imm32/exit
3163 cd/syscall 0x80/imm8
3164
3165
3166 stmt-has-outputs?:
3167
3168 55/push-ebp
3169 89/<- %ebp 4/r32/esp
3170
3171 51/push-ecx
3172
3173 68/push 0/imm32/end
3174 68/push 0/imm32/start
3175 89/<- %ecx 4/r32/esp
3176
3177 b8/copy-to-eax 0/imm32/false
3178 (rewind-stream *(ebp+8))
3179 {
3180 (next-mu-token *(ebp+8) %ecx)
3181
3182 (slice-empty? %ecx)
3183 3d/compare-eax-and 0/imm32
3184 b8/copy-to-eax 0/imm32/false/result
3185 0f 85/jump-if-!= break/disp32
3186
3187
3188 8b/-> *ecx 0/r32/eax
3189 8a/copy-byte *eax 0/r32/AL
3190 81 4/subop/and %eax 0xff/imm32
3191
3192 3d/compare-eax-and 0x23/imm32/hash
3193 b8/copy-to-eax 0/imm32/false/result
3194 0f 84/jump-if-= break/disp32
3195
3196 (slice-equal? %ecx "<-")
3197 3d/compare-eax-and 0/imm32
3198 74/jump-if-= loop/disp8
3199 b8/copy-to-eax 1/imm32/true
3200 }
3201 $stmt-has-outputs:end:
3202 (rewind-stream *(ebp+8))
3203
3204 81 0/subop/add %esp 8/imm32
3205
3206 59/pop-to-ecx
3207
3208 89/<- %esp 5/r32/ebp
3209 5d/pop-to-ebp
3210 c3/return
3211
3212
3213
3214 lookup-var-or-literal:
3215
3216 55/push-ebp
3217 89/<- %ebp 4/r32/esp
3218
3219 51/push-ecx
3220 56/push-esi
3221
3222 8b/-> *(ebp+8) 6/r32/esi
3223
3224 (slice-empty? %esi)
3225 3d/compare-eax-and 0/imm32
3226 0f 85/jump-if-!= $lookup-var-or-literal:abort/disp32
3227
3228 8b/-> *esi 1/r32/ecx
3229 8a/copy-byte *ecx 1/r32/CL
3230 81 4/subop/and %ecx 0xff/imm32
3231
3232 (is-decimal-digit? %ecx)
3233 81 7/subop/compare %eax 0/imm32
3234 {
3235 74/jump-if-= break/disp8
3236 (new-literal-integer Heap %esi)
3237 }
3238
3239 {
3240 75/jump-if-!= break/disp8
3241 (lookup-var %esi *(ebp+0xc))
3242 }
3243 $lookup-var-or-literal:end:
3244
3245 5e/pop-to-esi
3246 59/pop-to-ecx
3247
3248 89/<- %esp 5/r32/ebp
3249 5d/pop-to-ebp
3250 c3/return
3251
3252 $lookup-var-or-literal:abort:
3253 (write-buffered Stderr "empty variable!")
3254 (flush Stderr)
3255
3256 bb/copy-to-ebx 1/imm32
3257 b8/copy-to-eax 1/imm32/exit
3258 cd/syscall 0x80/imm8
3259
3260
3261
3262 lookup-var:
3263
3264 55/push-ebp
3265 89/<- %ebp 4/r32/esp
3266
3267 (slice-to-string Heap *(ebp+8))
3268
3269 (lookup-var-helper %eax *(ebp+0xc))
3270
3271 3d/compare-eax-and 0/imm32
3272 74/jump-if-= $lookup-var:abort/disp8
3273 $lookup-var:end:
3274
3275 89/<- %esp 5/r32/ebp
3276 5d/pop-to-ebp
3277 c3/return
3278
3279 $lookup-var:abort:
3280 (write-buffered Stderr "unknown variable '")
3281 (write-slice-buffered Stderr *(ebp+8))
3282 (write-buffered Stderr "'\n")
3283 (flush Stderr)
3284
3285 bb/copy-to-ebx 1/imm32
3286 b8/copy-to-eax 1/imm32/exit
3287 cd/syscall 0x80/imm8
3288
3289
3290
3291 lookup-var-helper:
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302 55/push-ebp
3303 89/<- %ebp 4/r32/esp
3304
3305 52/push-edx
3306 53/push-ebx
3307 56/push-esi
3308
3309 8b/-> *(ebp+0xc) 6/r32/esi
3310
3311 8b/-> *esi 3/r32/ebx
3312
3313 3b/compare 0/r32/eax *(esi+4)
3314 0f 8f/jump-if-> $lookup-var-helper:error1/disp32
3315
3316 8d/copy-address *(esi+8) 2/r32/edx
3317
3318 81 5/subop/subtract %ebx 4/imm32
3319 8d/copy-address *(esi+ebx+8) 3/r32/ebx
3320 {
3321
3322 39/compare %ebx 2/r32/edx
3323 b8/copy-to-eax 0/imm32
3324 0f 82/jump-if-addr< break/disp32
3325
3326 8b/-> *ebx 0/r32/eax
3327
3328 (string-equal? *eax *(ebp+8))
3329 3d/compare-eax-and 0/imm32
3330 8b/-> *ebx 0/r32/eax
3331 75/jump-if-!= break/disp8
3332
3333 81 5/subop/subtract %ebx 4/imm32
3334 e9/jump loop/disp32
3335 }
3336 $lookup-var-helper:end:
3337
3338 5e/pop-to-esi
3339 5b/pop-to-ebx
3340 5a/pop-to-edx
3341
3342 89/<- %esp 5/r32/ebp
3343 5d/pop-to-ebp
3344 c3/return
3345
3346 $lookup-var-helper:error1:
3347 (write-buffered Stderr "malformed stack when looking up '")
3348 (write-slice-buffered Stderr *(ebp+8))
3349 (write-buffered Stderr "'\n")
3350 (flush Stderr)
3351
3352 bb/copy-to-ebx 1/imm32
3353 b8/copy-to-eax 1/imm32/exit
3354 cd/syscall 0x80/imm8
3355
3356
3357
3358 lookup-or-define-var:
3359
3360 55/push-ebp
3361 89/<- %ebp 4/r32/esp
3362
3363 51/push-ecx
3364
3365 (slice-to-string Heap *(ebp+8))
3366 89/<- %ecx 0/r32/eax
3367
3368 (lookup-var-helper *(ebp+8) *(ebp+0xc))
3369 {
3370
3371 3d/compare-eax-and 0/imm32
3372 75/jump-if-!= break/disp8
3373
3374 {
3375 (find-in-function-outputs *(ebp+0x10) %ecx)
3376 3d/compare-eax-and 0/imm32
3377
3378 0f 84/jump-if-!= $lookup-var:abort/disp32
3379 }
3380 }
3381 $lookup-or-define-var:end:
3382
3383 59/pop-to-ecx
3384
3385 89/<- %esp 5/r32/ebp
3386 5d/pop-to-ebp
3387 c3/return
3388
3389 find-in-function-outputs:
3390
3391 55/push-ebp
3392 89/<- %ebp 4/r32/esp
3393
3394 51/push-ecx
3395
3396 8b/-> *(ebp+8) 1/r32/ecx
3397 8b/-> *(ecx+0xc) 1/r32/ecx
3398
3399 {
3400 81 7/subop/compare %ecx 0/imm32
3401 74/jump-if-= break/disp8
3402
3403 8b/-> *ecx 0/r32/eax
3404
3405 50/push-eax
3406 (string-equal? *eax *(ebp+0xc))
3407 3d/compare-eax-and 0/imm32
3408 58/pop-to-eax
3409 75/jump-if-!= $find-in-function-outputs:end/disp8
3410
3411 8b/-> *(ecx+4) 1/r32/ecx
3412 eb/jump loop/disp8
3413 }
3414 b8/copy-to-eax 0/imm32
3415 $find-in-function-outputs:end:
3416
3417 59/pop-to-ecx
3418
3419 89/<- %esp 5/r32/ebp
3420 5d/pop-to-ebp
3421 c3/return
3422
3423 test-parse-mu-stmt:
3424
3425
3426 55/push-ebp
3427 89/<- %ebp 4/r32/esp
3428
3429 (clear-stream _test-input-stream)
3430 (write _test-input-stream "increment n\n")
3431
3432 81 5/subop/subtract %esp 0x10/imm32
3433 68/push 0x10/imm32/length
3434 68/push 0/imm32/top
3435 89/<- %ecx 4/r32/esp
3436 (clear-stack %ecx)
3437
3438 81 5/subop/subtract %esp 0x14/imm32
3439 89/<- %edx 4/r32/esp
3440 (zero-out %edx 0x14)
3441
3442 c7 0/subop/copy *edx "n"/imm32
3443
3444 (push %ecx %edx)
3445
3446 (parse-mu-stmt _test-input-stream %ecx)
3447
3448 (check-ints-equal *eax 1 "F - test-parse-mu-stmt/tag")
3449 (check-strings-equal *(eax+4) "increment" "F - test-parse-mu-stmt/name")
3450
3451 8b/-> *(eax+8) 2/r32/edx
3452
3453 8b/-> *edx 3/r32/ebx
3454 (check-strings-equal *ebx "n" "F - test-parse-mu-stmt/inout:0")
3455
3456 89/<- %esp 5/r32/ebp
3457 5d/pop-to-ebp
3458 c3/return
3459
3460 test-parse-mu-stmt-with-comma:
3461
3462
3463 55/push-ebp
3464 89/<- %ebp 4/r32/esp
3465
3466 (clear-stream _test-input-stream)
3467 (write _test-input-stream "copy-to n, 3\n")
3468
3469 81 5/subop/subtract %esp 0x10/imm32
3470 68/push 0x10/imm32/length
3471 68/push 0/imm32/top
3472 89/<- %ecx 4/r32/esp
3473 (clear-stack %ecx)
3474
3475 81 5/subop/subtract %esp 0x14/imm32
3476 89/<- %edx 4/r32/esp
3477 (zero-out %edx 0x14)
3478
3479 c7 0/subop/copy *edx "n"/imm32
3480
3481 (push %ecx %edx)
3482
3483 (parse-mu-stmt _test-input-stream %ecx)
3484
3485 (check-ints-equal *eax 1 "F - test-parse-mu-stmt-with-comma/tag")
3486 (check-strings-equal *(eax+4) "copy-to" "F - test-parse-mu-stmt-with-comma/name")
3487
3488 8b/-> *(eax+8) 2/r32/edx
3489
3490 8b/-> *edx 3/r32/ebx
3491 (check-strings-equal *ebx "n" "F - test-parse-mu-stmt-with-comma/inout:0")
3492
3493 89/<- %esp 5/r32/ebp
3494 5d/pop-to-ebp
3495 c3/return
3496
3497 new-function:
3498
3499 55/push-ebp
3500 89/<- %ebp 4/r32/esp
3501
3502 51/push-ecx
3503
3504 (allocate *(ebp+8) *Function-size)
3505 8b/-> *(ebp+0xc) 1/r32/ecx
3506 89/<- *eax 1/r32/ecx
3507 8b/-> *(ebp+0x10) 1/r32/ecx
3508 89/<- *(eax+4) 1/r32/ecx
3509 8b/-> *(ebp+0x14) 1/r32/ecx
3510 89/<- *(eax+8) 1/r32/ecx
3511 8b/-> *(ebp+0x18) 1/r32/ecx
3512 89/<- *(eax+0xc) 1/r32/ecx
3513 8b/-> *(ebp+0x1c) 1/r32/ecx
3514 89/<- *(eax+0x10) 1/r32/ecx
3515 8b/-> *(ebp+0x20) 1/r32/ecx
3516 89/<- *(eax+0x14) 1/r32/ecx
3517 $new-function:end:
3518
3519 59/pop-to-ecx
3520
3521 89/<- %esp 5/r32/ebp
3522 5d/pop-to-ebp
3523 c3/return
3524
3525 new-var:
3526
3527 55/push-ebp
3528 89/<- %ebp 4/r32/esp
3529
3530 51/push-ecx
3531
3532 (allocate *(ebp+8) *Var-size)
3533 8b/-> *(ebp+0xc) 1/r32/ecx
3534 89/<- *eax 1/r32/ecx
3535 8b/-> *(ebp+0x10) 1/r32/ecx
3536 89/<- *(eax+4) 1/r32/ecx
3537 8b/-> *(ebp+0x14) 1/r32/ecx
3538 89/<- *(eax+8) 1/r32/ecx
3539 8b/-> *(ebp+0x18) 1/r32/ecx
3540 89/<- *(eax+0xc) 1/r32/ecx
3541 8b/-> *(ebp+0x1c) 1/r32/ecx
3542 89/<- *(eax+0x10) 1/r32/ecx
3543 $new-var:end:
3544
3545 59/pop-to-ecx
3546
3547 89/<- %esp 5/r32/ebp
3548 5d/pop-to-ebp
3549 c3/return
3550
3551 new-literal-integer:
3552
3553 55/push-ebp
3554 89/<- %ebp 4/r32/esp
3555
3556 51/push-ecx
3557
3558 (is-hex-int? *(ebp+0xc))
3559 3d/compare-eax-and 0/imm32
3560 0f 84/jump-if-= $new-literal-integer:abort/disp32
3561
3562 (slice-to-string Heap *(ebp+0xc))
3563 89/<- %ecx 0/r32/eax
3564
3565 (allocate *(ebp+8) *Var-size)
3566 89/<- *eax 1/r32/ecx
3567 89/<- %ecx 0/r32/eax
3568 (allocate *(ebp+8) *Tree-size)
3569 89/<- *(ecx+4) 0/r32/eax
3570 89/<- %eax 1/r32/ecx
3571 c7 0/subop/copy *(eax+8) 0/imm32
3572 c7 0/subop/copy *(eax+0xc) 0/imm32
3573 c7 0/subop/copy *(eax+0x10) 0/imm32
3574 $new-literal-integer:end:
3575
3576 59/pop-to-ecx
3577
3578 89/<- %esp 5/r32/ebp
3579 5d/pop-to-ebp
3580 c3/return
3581
3582 $new-literal-integer:abort:
3583 (write-buffered Stderr "variable cannot begin with a digit '")
3584 (write-slice-buffered Stderr *(ebp+0xc))
3585 (write-buffered Stderr "'\n")
3586 (flush Stderr)
3587
3588 bb/copy-to-ebx 1/imm32
3589 b8/copy-to-eax 1/imm32/exit
3590 cd/syscall 0x80/imm8
3591
3592
3593 new-block:
3594
3595 55/push-ebp
3596 89/<- %ebp 4/r32/esp
3597
3598 51/push-ecx
3599
3600 (allocate *(ebp+8) *Stmt-size)
3601 (zero-out %eax *Stmt-size)
3602 c7 0/subop/copy *eax 0/imm32/tag/block
3603 8b/-> *(ebp+0xc) 1/r32/ecx
3604 89/<- *(eax+4) 1/r32/ecx
3605 $new-block:end:
3606
3607 59/pop-to-ecx
3608
3609 89/<- %esp 5/r32/ebp
3610 5d/pop-to-ebp
3611 c3/return
3612
3613 new-vardef:
3614
3615 55/push-ebp
3616 89/<- %ebp 4/r32/esp
3617
3618 51/push-ecx
3619
3620 (allocate *(ebp+8) *Stmt-size)
3621 (zero-out %eax *Stmt-size)
3622 c7 0/subop/copy *eax 2/imm32/tag/var-on-stack
3623
3624 8b/-> *(ebp+0xc) 1/r32/ecx
3625 89/<- *(eax+4) 1/r32/ecx
3626 $new-vardef:end:
3627
3628 59/pop-to-ecx
3629
3630 89/<- %esp 5/r32/ebp
3631 5d/pop-to-ebp
3632 c3/return
3633
3634 new-regvardef:
3635
3636 55/push-ebp
3637 89/<- %ebp 4/r32/esp
3638
3639 51/push-ecx
3640
3641 (allocate *(ebp+8) *Stmt-size)
3642 (zero-out %eax *Stmt-size)
3643 c7 0/subop/copy *eax 3/imm32/tag/var-in-register
3644 8b/-> *(ebp+0xc) 1/r32/ecx
3645 89/<- *(eax+0xc) 1/r32/ecx
3646 $new-regvardef:end:
3647
3648 59/pop-to-ecx
3649
3650 89/<- %esp 5/r32/ebp
3651 5d/pop-to-ebp
3652 c3/return
3653
3654 new-named-block:
3655
3656 55/push-ebp
3657 89/<- %ebp 4/r32/esp
3658
3659 51/push-ecx
3660
3661 (allocate *(ebp+8) *Stmt-size)
3662 (zero-out %eax *Stmt-size)
3663 c7 0/subop/copy *eax 4/imm32/tag/named-block
3664 8b/-> *(ebp+0xc) 1/r32/ecx
3665 89/<- *(eax+4) 1/r32/ecx
3666 8b/-> *(ebp+0x10) 1/r32/ecx
3667 89/<- *(eax+8) 1/r32/ecx
3668 $new-named-block:end:
3669
3670 59/pop-to-ecx
3671
3672 89/<- %esp 5/r32/ebp
3673 5d/pop-to-ebp
3674 c3/return
3675
3676 new-list:
3677
3678 55/push-ebp
3679 89/<- %ebp 4/r32/esp
3680
3681 51/push-ecx
3682
3683 (allocate *(ebp+8) *List-size)
3684 8b/-> *(ebp+0xc) 1/r32/ecx
3685 89/<- *eax 1/r32/ecx
3686 8b/-> *(ebp+0x10) 1/r32/ecx
3687 89/<- *(eax+4) 1/r32/ecx
3688 $new-list:end:
3689
3690 59/pop-to-ecx
3691
3692 89/<- %esp 5/r32/ebp
3693 5d/pop-to-ebp
3694 c3/return
3695
3696 append-list:
3697
3698 55/push-ebp
3699 89/<- %ebp 4/r32/esp
3700
3701 51/push-ecx
3702
3703 (allocate *(ebp+8) *List-size)
3704 8b/-> *(ebp+0xc) 1/r32/ecx
3705 89/<- *eax 1/r32/ecx
3706
3707 81 7/subop/compare *(ebp+0x10) 0/imm32
3708 74/jump-if-= $new-list:end/disp8
3709
3710
3711 8b/-> *(ebp+0x10) 1/r32/ecx
3712
3713 {
3714 81 7/subop/compare *(ecx+4) 0/imm32
3715 74/jump-if-= break/disp8
3716
3717 8b/-> *(ecx+4) 1/r32/ecx
3718 eb/jump loop/disp8
3719 }
3720
3721 89/<- *(ecx+4) 0/r32/eax
3722
3723 8b/-> *(ebp+0x10) 0/r32/eax
3724 $append-list:end:
3725
3726 59/pop-to-ecx
3727
3728 89/<- %esp 5/r32/ebp
3729 5d/pop-to-ebp
3730 c3/return
3731
3732 append-to-block:
3733
3734 55/push-ebp
3735 89/<- %ebp 4/r32/esp
3736
3737 56/push-esi
3738
3739 8b/-> *(ebp+0xc) 6/r32/esi
3740 (append-list *(ebp+8) *(ebp+0x10) *(esi+4))
3741 89/<- *(esi+4) 0/r32/eax
3742 $append-to-block:end:
3743
3744 5e/pop-to-esi
3745
3746 89/<- %esp 5/r32/ebp
3747 5d/pop-to-ebp
3748 c3/return
3749
3750
3751
3752
3753
3754 check-mu-types:
3755
3756 55/push-ebp
3757 89/<- %ebp 4/r32/esp
3758
3759 $check-mu-types:end:
3760
3761 89/<- %esp 5/r32/ebp
3762 5d/pop-to-ebp
3763 c3/return
3764
3765 size-of:
3766
3767 55/push-ebp
3768 89/<- %ebp 4/r32/esp
3769
3770 b8/copy-to-eax 4/imm32
3771 $size-of:end:
3772
3773 89/<- %esp 5/r32/ebp
3774 5d/pop-to-ebp
3775 c3/return
3776
3777 == data
3778
3779
3780 Type-size:
3781 0x18/imm32/write
3782 0/imm32/read
3783 0x100/imm32/length
3784
3785 4/imm32
3786 4/imm32
3787 4/imm32
3788 0/imm32
3789 8/imm32
3790 4/imm32
3791 0/imm32
3792 0/imm32
3793
3794 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
3795 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
3796 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
3797 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
3798 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
3799 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
3800 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32 0/imm32
3801
3802 == code
3803
3804
3805
3806
3807
3808 emit-subx:
3809
3810 55/push-ebp
3811 89/<- %ebp 4/r32/esp
3812
3813 50/push-eax
3814 51/push-ecx
3815 57/push-edi
3816
3817 8b/-> *(ebp+8) 7/r32/edi
3818
3819 8b/-> *Program 1/r32/ecx
3820 {
3821
3822 81 7/subop/compare %ecx 0/imm32
3823 0f 84/jump-if-= break/disp32
3824 (emit-subx-function %edi %ecx)
3825
3826 8b/-> *(ecx+0x14) 1/r32/ecx
3827 e9/jump loop/disp32
3828 }
3829 $emit-subx:end:
3830
3831 5f/pop-to-edi
3832 59/pop-to-ecx
3833 58/pop-to-eax
3834
3835 89/<- %esp 5/r32/ebp
3836 5d/pop-to-ebp
3837 c3/return
3838
3839 emit-subx-function:
3840
3841 55/push-ebp
3842 89/<- %ebp 4/r32/esp
3843
3844 50/push-eax
3845 51/push-ecx
3846 52/push-edx
3847 57/push-edi
3848
3849 8b/-> *(ebp+8) 7/r32/edi
3850
3851 8b/-> *(ebp+0xc) 1/r32/ecx
3852
3853 81 5/subop/subtract %esp 0x400/imm32
3854 68/push 0x400/imm32/length
3855 68/push 0/imm32/top
3856 89/<- %edx 4/r32/esp
3857
3858 (write-buffered %edi *ecx)
3859 (write-buffered %edi ":\n")
3860 (emit-subx-prologue %edi)
3861 (emit-subx-block %edi *(ecx+0x10) %edx)
3862 (emit-subx-epilogue %edi)
3863 $emit-subx-function:end:
3864
3865 81 0/subop/add %esp 408/imm32
3866
3867 5f/pop-to-edi
3868 5a/pop-to-edx
3869 59/pop-to-ecx
3870 58/pop-to-eax
3871
3872 89/<- %esp 5/r32/ebp
3873 5d/pop-to-ebp
3874 c3/return
3875
3876 emit-subx-block:
3877
3878 55/push-ebp
3879 89/<- %ebp 4/r32/esp
3880
3881 50/push-eax
3882 56/push-esi
3883
3884 8b/-> *(ebp+0xc) 6/r32/esi
3885 8b/-> *(esi+4) 6/r32/esi
3886
3887 {
3888 $emit-subx-block:check-empty:
3889 81 7/subop/compare %esi 0/imm32
3890 0f 84/jump-if-= break/disp32
3891 (write-buffered *(ebp+8) "{\n")
3892 {
3893 $emit-subx-block:loop:
3894 81 7/subop/compare %esi 0/imm32
3895 0f 84/jump-if-= break/disp32
3896
3897 8b/-> *esi 0/r32/eax
3898 {
3899 $emit-subx-block:check-for-block:
3900 81 7/subop/compare *eax 0/imm32/block
3901 75/jump-if-!= break/disp8
3902 $emit-subx-block:block:
3903
3904 }
3905 {
3906 $emit-subx-block:check-for-stmt:
3907 81 7/subop/compare *eax 1/imm32/stmt1
3908 75/jump-if-!= break/disp8
3909 $emit-subx-block:stmt:
3910 (emit-subx-statement *(ebp+8) %eax Primitives *Program)
3911 }
3912 {
3913 $emit-subx-block:check-for-vardef:
3914 81 7/subop/compare *eax 2/imm32/vardef
3915 75/jump-if-!= break/disp8
3916 $emit-subx-block:vardef:
3917 (emit-subx-var-def *(ebp+8) %eax)
3918 (push *(ebp+0x10) %eax)
3919 }
3920 {
3921 $emit-subx-block:check-for-regvardef:
3922 81 7/subop/compare *eax 3/imm32/regvardef
3923 75/jump-if-!= break/disp8
3924 $emit-subx-block:regvardef:
3925
3926 }
3927 {
3928 $emit-subx-block:check-for-named-block:
3929 81 7/subop/compare *eax 4/imm32/named-block
3930 75/jump-if-!= break/disp8
3931 $emit-subx-block:named-block:
3932
3933 }
3934 (write-buffered *(ebp+8) Newline)
3935 8b/-> *(esi+4) 6/r32/esi
3936 e9/jump loop/disp32
3937 }
3938
3939
3940 {
3941 8b/-> *(ebp+0x10) 0/r32/eax)
3942 81 7/subop/compare *eax 0/imm32
3943 74/jump-if-= break/disp8
3944 (top %eax)
3945 (size-of %eax)
3946 01/add *Next-local-stack-offset 0/r32/eax
3947 (write-buffered *(ebp+8) "81 0/subop/add %esp ")
3948 (print-int32-buffered *(ebp+8) %eax)
3949 (write-buffered *(ebp+8) "/imm32\n")
3950
3951 (pop *(ebp+0x10))
3952 e9/jump loop/disp32
3953 }
3954
3955 (write-buffered *(ebp+8) "}\n")
3956 }
3957 $emit-subx-block:end:
3958
3959 5e/pop-to-esi
3960 58/pop-to-eax
3961
3962 89/<- %esp 5/r32/ebp
3963 5d/pop-to-ebp
3964 c3/return
3965
3966 emit-subx-var-def:
3967
3968 55/push-ebp
3969 89/<- %ebp 4/r32/esp
3970
3971
3972 8b/-> *(ebp+0xc) 0/r32/eax
3973
3974 (size-of *(eax+4))
3975
3976 {
3977 3d/compare-eax-with 0/imm32
3978 7e/jump-if-<= break/disp8
3979 (write-buffered *(ebp+8) "68/push 0/imm32")
3980
3981 2d/subtract-from-eax 4/imm32
3982
3983 eb/jump loop/disp8
3984 }
3985 $emit-subx-var-def:end:
3986
3987 59/pop-to-ecx
3988 58/pop-to-eax
3989
3990 89/<- %esp 5/r32/ebp
3991 5d/pop-to-ebp
3992 c3/return
3993
3994 emit-subx-statement:
3995
3996 55/push-ebp
3997 89/<- %ebp 4/r32/esp
3998
3999 50/push-eax
4000 51/push-ecx
4001
4002 {
4003 $emit-subx-statement:primitive:
4004 (find-matching-primitive *(ebp+0x10) *(ebp+0xc))
4005 3d/compare-eax-and 0/imm32
4006 74/jump-if-= break/disp8
4007 (emit-subx-primitive *(ebp+8) *(ebp+0xc) %eax)
4008 e9/jump $emit-subx-statement:end/disp32
4009 }
4010
4011 {
4012 $emit-subx-statement:call:
4013 (find-matching-function *(ebp+0x14) *(ebp+0xc))
4014 3d/compare-eax-and 0/imm32
4015 74/jump-if-= break/disp8
4016 (emit-subx-call *(ebp+8) *(ebp+0xc) %eax)
4017 e9/jump $emit-subx-statement:end/disp32
4018 }
4019
4020 e9/jump $emit-subx-statement:abort/disp32
4021 $emit-subx-statement:end:
4022
4023 59/pop-to-ecx
4024 58/pop-to-eax
4025
4026 89/<- %esp 5/r32/ebp
4027 5d/pop-to-ebp
4028 c3/return
4029
4030 $emit-subx-statement:abort:
4031
4032 (write-buffered Stderr "couldn't translate '")
4033
4034 (write-buffered Stderr "'\n")
4035 (flush Stderr)
4036
4037 bb/copy-to-ebx 1/imm32
4038 b8/copy-to-eax 1/imm32/exit
4039 cd/syscall 0x80/imm8
4040
4041
4042
4043
4044 == data
4045 Primitives:
4046
4047 _Primitive-inc-eax:
4048
4049 "increment"/imm32/name
4050 0/imm32/no-inouts
4051 Single-int-var-in-eax/imm32/outputs
4052 "40/increment-eax"/imm32/subx-name
4053 0/imm32/no-rm32
4054 0/imm32/no-r32
4055 0/imm32/no-imm32
4056 0/imm32/output-is-write-only
4057 _Primitive-inc-ecx/imm32/next
4058 _Primitive-inc-ecx:
4059
4060 "increment"/imm32/name
4061 0/imm32/no-inouts
4062 Single-int-var-in-ecx/imm32/outputs
4063 "41/increment-ecx"/imm32/subx-name
4064 0/imm32/no-rm32
4065 0/imm32/no-r32
4066 0/imm32/no-imm32
4067 0/imm32/output-is-write-only
4068 _Primitive-inc-edx/imm32/next
4069 _Primitive-inc-edx:
4070
4071 "increment"/imm32/name
4072 0/imm32/no-inouts
4073 Single-int-var-in-edx/imm32/outputs
4074 "42/increment-edx"/imm32/subx-name
4075 0/imm32/no-rm32
4076 0/imm32/no-r32
4077 0/imm32/no-imm32
4078 0/imm32/output-is-write-only
4079 _Primitive-inc-ebx/imm32/next
4080 _Primitive-inc-ebx:
4081
4082 "increment"/imm32/name
4083 0/imm32/no-inouts
4084 Single-int-var-in-ebx/imm32/outputs
4085 "43/increment-ebx"/imm32/subx-name
4086 0/imm32/no-rm32
4087 0/imm32/no-r32
4088 0/imm32/no-imm32
4089 0/imm32/output-is-write-only
4090 _Primitive-inc-esi/imm32/next
4091 _Primitive-inc-esi:
4092
4093 "increment"/imm32/name
4094 0/imm32/no-inouts
4095 Single-int-var-in-esi/imm32/outputs
4096 "46/increment-esi"/imm32/subx-name
4097 0/imm32/no-rm32
4098 0/imm32/no-r32
4099 0/imm32/no-imm32
4100 0/imm32/output-is-write-only
4101 _Primitive-inc-edi/imm32/next
4102 _Primitive-inc-edi:
4103
4104 "increment"/imm32/name
4105 0/imm32/no-inouts
4106 Single-int-var-in-edi/imm32/outputs
4107 "47/increment-edi"/imm32/subx-name
4108 0/imm32/no-rm32
4109 0/imm32/no-r32
4110 0/imm32/no-imm32
4111 0/imm32/output-is-write-only
4112 _Primitive-dec-eax/imm32/next
4113 _Primitive-dec-eax:
4114
4115 "decrement"/imm32/name
4116 0/imm32/no-inouts
4117 Single-int-var-in-eax/imm32/outputs
4118 "48/decrement-eax"/imm32/subx-name
4119 0/imm32/no-rm32
4120 0/imm32/no-r32
4121 0/imm32/no-imm32
4122 0/imm32/output-is-write-only
4123 _Primitive-dec-ecx/imm32/next
4124 _Primitive-dec-ecx:
4125
4126 "decrement"/imm32/name
4127 0/imm32/no-inouts
4128 Single-int-var-in-ecx/imm32/outputs
4129 "49/decrement-ecx"/imm32/subx-name
4130 0/imm32/no-rm32
4131 0/imm32/no-r32
4132 0/imm32/no-imm32
4133 0/imm32/output-is-write-only
4134 _Primitive-dec-edx/imm32/next
4135 _Primitive-dec-edx:
4136
4137 "decrement"/imm32/name
4138 0/imm32/no-inouts
4139 Single-int-var-in-edx/imm32/outputs
4140 "4a/decrement-edx"/imm32/subx-name
4141 0/imm32/no-rm32
4142 0/imm32/no-r32
4143 0/imm32/no-imm32
4144 0/imm32/output-is-write-only
4145 _Primitive-dec-ebx/imm32/next
4146 _Primitive-dec-ebx:
4147
4148 "decrement"/imm32/name
4149 0/imm32/no-inouts
4150 Single-int-var-in-ebx/imm32/outputs
4151 "4b/decrement-ebx"/imm32/subx-name
4152 0/imm32/no-rm32
4153 0/imm32/no-r32
4154 0/imm32/no-imm32
4155 0/imm32/output-is-write-only
4156 _Primitive-dec-esi/imm32/next
4157 _Primitive-dec-esi:
4158
4159 "decrement"/imm32/name
4160 0/imm32/no-inouts
4161 Single-int-var-in-esi/imm32/outputs
4162 "4e/decrement-esi"/imm32/subx-name
4163 0/imm32/no-rm32
4164 0/imm32/no-r32
4165 0/imm32/no-imm32
4166 0/imm32/output-is-write-only
4167 _Primitive-dec-edi/imm32/next
4168 _Primitive-dec-edi:
4169
4170 "decrement"/imm32/name
4171 0/imm32/no-inouts
4172 Single-int-var-in-edi/imm32/outputs
4173 "4f/decrement-edi"/imm32/subx-name
4174 0/imm32/no-rm32
4175 0/imm32/no-r32
4176 0/imm32/no-imm32
4177 0/imm32/output-is-write-only
4178 _Primitive-inc-mem/imm32/next
4179 _Primitive-inc-mem:
4180
4181 "increment"/imm32/name
4182 Single-int-var-on-stack/imm32/inouts
4183 0/imm32/no-outputs
4184 "ff 0/subop/increment"/imm32/subx-name
4185 1/imm32/rm32-is-first-inout
4186 0/imm32/no-r32
4187 0/imm32/no-imm32
4188 0/imm32/output-is-write-only
4189 _Primitive-inc-reg/imm32/next
4190 _Primitive-inc-reg:
4191
4192 "increment"/imm32/name
4193 0/imm32/no-inouts
4194 Single-int-var-in-some-register/imm32/outputs
4195 "ff 0/subop/increment"/imm32/subx-name
4196 3/imm32/rm32-is-first-output
4197 0/imm32/no-r32
4198 0/imm32/no-imm32
4199 0/imm32/output-is-write-only
4200 _Primitive-dec-mem/imm32/next
4201 _Primitive-dec-mem:
4202
4203 "decrement"/imm32/name
4204 Single-int-var-on-stack/imm32/inouts
4205 0/imm32/no-outputs
4206 "ff 1/subop/decrement"/imm32/subx-name
4207 1/imm32/rm32-is-first-inout
4208 0/imm32/no-r32
4209 0/imm32/no-imm32
4210 0/imm32/output-is-write-only
4211 _Primitive-dec-reg/imm32/next
4212 _Primitive-dec-reg:
4213
4214 "decrement"/imm32/name
4215 0/imm32/no-inouts
4216 Single-int-var-in-some-register/imm32/outputs
4217 "ff 1/subop/decrement"/imm32/subx-name
4218 3/imm32/rm32-is-first-output
4219 0/imm32/no-r32
4220 0/imm32/no-imm32
4221 0/imm32/output-is-write-only
4222 _Primitive-add-to-eax/imm32/next
4223
4224 _Primitive-add-to-eax:
4225
4226 "add"/imm32/name
4227 Single-lit-var/imm32/inouts
4228 Single-int-var-in-eax/imm32/outputs
4229 "05/add-to-eax"/imm32/subx-name
4230 0/imm32/no-rm32
4231 0/imm32/no-r32
4232 1/imm32/imm32-is-first-inout
4233 0/imm32/output-is-write-only
4234 _Primitive-add-reg-to-reg/imm32/next
4235 _Primitive-add-reg-to-reg:
4236
4237 "add"/imm32/name
4238 Single-int-var-in-some-register/imm32/inouts
4239 Single-int-var-in-some-register/imm32/outputs
4240 "01/add-to"/imm32/subx-name
4241 3/imm32/rm32-is-first-output
4242 1/imm32/r32-is-first-inout
4243 0/imm32/no-imm32
4244 0/imm32/output-is-write-only
4245 _Primitive-add-reg-to-mem/imm32/next
4246 _Primitive-add-reg-to-mem:
4247
4248 "add-to"/imm32/name
4249 Int-var-and-second-int-var-in-some-register/imm32/inouts
4250 0/imm32/outputs
4251 "01/add-to"/imm32/subx-name
4252 1/imm32/rm32-is-first-inout
4253 2/imm32/r32-is-second-inout
4254 0/imm32/no-imm32
4255 0/imm32/output-is-write-only
4256 _Primitive-add-mem-to-reg/imm32/next
4257 _Primitive-add-mem-to-reg:
4258
4259 "add"/imm32/name
4260 Single-int-var-on-stack/imm32/inouts
4261 Single-int-var-in-some-register/imm32/outputs
4262 "03/add"/imm32/subx-name
4263 1/imm32/rm32-is-first-inout
4264 3/imm32/r32-is-first-output
4265 0/imm32/no-imm32
4266 0/imm32/output-is-write-only
4267 _Primitive-add-lit-to-reg/imm32/next
4268 _Primitive-add-lit-to-reg:
4269
4270 "add"/imm32/name
4271 Single-lit-var/imm32/inouts
4272 Single-int-var-in-some-register/imm32/outputs
4273 "81 0/subop/add"/imm32/subx-name
4274 3/imm32/rm32-is-first-output
4275 0/imm32/no-r32
4276 1/imm32/imm32-is-first-inout
4277 0/imm32/output-is-write-only
4278 _Primitive-add-lit-to-mem/imm32/next
4279 _Primitive-add-lit-to-mem:
4280
4281 "add-to"/imm32/name
4282 Int-var-and-literal/imm32/inouts
4283 0/imm32/outputs
4284 "81 0/subop/add"/imm32/subx-name
4285 1/imm32/rm32-is-first-inout
4286 0/imm32/no-r32
4287 2/imm32/imm32-is-first-inout
4288 0/imm32/output-is-write-only
4289 _Primitive-subtract-from-eax/imm32/next
4290
4291 _Primitive-subtract-from-eax:
4292
4293 "subtract"/imm32/name
4294 Single-lit-var/imm32/inouts
4295 Single-int-var-in-eax/imm32/outputs
4296 "2d/subtract-from-eax"/imm32/subx-name
4297 0/imm32/no-rm32
4298 0/imm32/no-r32
4299 1/imm32/imm32-is-first-inout
4300 0/imm32/output-is-write-only
4301 _Primitive-subtract-reg-from-reg/imm32/next
4302 _Primitive-subtract-reg-from-reg:
4303
4304 "subtract"/imm32/name
4305 Single-int-var-in-some-register/imm32/inouts
4306 Single-int-var-in-some-register/imm32/outputs
4307 "29/subtract-from"/imm32/subx-name
4308 3/imm32/rm32-is-first-output
4309 1/imm32/r32-is-first-inout
4310 0/imm32/no-imm32
4311 0/imm32/output-is-write-only
4312 _Primitive-subtract-reg-from-mem/imm32/next
4313 _Primitive-subtract-reg-from-mem:
4314
4315 "subtract-from"/imm32/name
4316 Int-var-and-second-int-var-in-some-register/imm32/inouts
4317 0/imm32/outputs
4318 "29/subtract-from"/imm32/subx-name
4319 1/imm32/rm32-is-first-inout
4320 2/imm32/r32-is-second-inout
4321 0/imm32/no-imm32
4322 0/imm32/output-is-write-only
4323 _Primitive-subtract-mem-from-reg/imm32/next
4324 _Primitive-subtract-mem-from-reg:
4325
4326 "subtract"/imm32/name
4327 Single-int-var-on-stack/imm32/inouts
4328 Single-int-var-in-some-register/imm32/outputs
4329 "2b/subtract"/imm32/subx-name
4330 1/imm32/rm32-is-first-inout
4331 3/imm32/r32-is-first-output
4332 0/imm32/no-imm32
4333 0/imm32/output-is-write-only
4334 _Primitive-subtract-lit-from-reg/imm32/next
4335 _Primitive-subtract-lit-from-reg:
4336
4337 "subtract"/imm32/name
4338 Single-lit-var/imm32/inouts
4339 Single-int-var-in-some-register/imm32/outputs
4340 "81 5/subop/subtract"/imm32/subx-name
4341 3/imm32/rm32-is-first-output
4342 0/imm32/no-r32
4343 1/imm32/imm32-is-first-inout
4344 0/imm32/output-is-write-only
4345 _Primitive-subtract-lit-from-mem/imm32/next
4346 _Primitive-subtract-lit-from-mem:
4347
4348 "subtract-from"/imm32/name
4349 Int-var-and-literal/imm32/inouts
4350 0/imm32/outputs
4351 "81 5/subop/subtract"/imm32/subx-name
4352 1/imm32/rm32-is-first-inout
4353 0/imm32/no-r32
4354 2/imm32/imm32-is-first-inout
4355 0/imm32/output-is-write-only
4356 _Primitive-and-with-eax/imm32/next
4357
4358 _Primitive-and-with-eax:
4359
4360 "and"/imm32/name
4361 Single-lit-var/imm32/inouts
4362 Single-int-var-in-eax/imm32/outputs
4363 "25/and-with-eax"/imm32/subx-name
4364 0/imm32/no-rm32
4365 0/imm32/no-r32
4366 1/imm32/imm32-is-first-inout
4367 0/imm32/output-is-write-only
4368 _Primitive-and-reg-with-reg/imm32/next
4369 _Primitive-and-reg-with-reg:
4370
4371 "and"/imm32/name
4372 Single-int-var-in-some-register/imm32/inouts
4373 Single-int-var-in-some-register/imm32/outputs
4374 "21/and-with"/imm32/subx-name
4375 3/imm32/rm32-is-first-output
4376 1/imm32/r32-is-first-inout
4377 0/imm32/no-imm32
4378 0/imm32/output-is-write-only
4379 _Primitive-and-reg-with-mem/imm32/next
4380 _Primitive-and-reg-with-mem:
4381
4382 "and-with"/imm32/name
4383 Int-var-and-second-int-var-in-some-register/imm32/inouts
4384 0/imm32/outputs
4385 "21/and-with"/imm32/subx-name
4386 1/imm32/rm32-is-first-inout
4387 2/imm32/r32-is-second-inout
4388 0/imm32/no-imm32
4389 0/imm32/output-is-write-only
4390 _Primitive-and-mem-with-reg/imm32/next
4391 _Primitive-and-mem-with-reg:
4392
4393 "and"/imm32/name
4394 Single-int-var-on-stack/imm32/inouts
4395 Single-int-var-in-some-register/imm32/outputs
4396 "23/and"/imm32/subx-name
4397 1/imm32/rm32-is-first-inout
4398 3/imm32/r32-is-first-output
4399 0/imm32/no-imm32
4400 0/imm32/output-is-write-only
4401 _Primitive-and-lit-with-reg/imm32/next
4402 _Primitive-and-lit-with-reg:
4403
4404 "and"/imm32/name
4405 Single-lit-var/imm32/inouts
4406 Single-int-var-in-some-register/imm32/outputs
4407 "81 4/subop/and"/imm32/subx-name
4408 3/imm32/rm32-is-first-output
4409 0/imm32/no-r32
4410 1/imm32/imm32-is-first-inout
4411 0/imm32/output-is-write-only
4412 _Primitive-and-lit-with-mem/imm32/next
4413 _Primitive-and-lit-with-mem:
4414
4415 "and-with"/imm32/name
4416 Int-var-and-literal/imm32/inouts
4417 0/imm32/outputs
4418 "81 4/subop/and"/imm32/subx-name
4419 1/imm32/rm32-is-first-inout
4420 0/imm32/no-r32
4421 2/imm32/imm32-is-first-inout
4422 0/imm32/output-is-write-only
4423 _Primitive-or-with-eax/imm32/next
4424
4425 _Primitive-or-with-eax:
4426
4427 "or"/imm32/name
4428 Single-lit-var/imm32/inouts
4429 Single-int-var-in-eax/imm32/outputs
4430 "0d/or-with-eax"/imm32/subx-name
4431 0/imm32/no-rm32
4432 0/imm32/no-r32
4433 1/imm32/imm32-is-first-inout
4434 0/imm32/output-is-write-only
4435 _Primitive-or-reg-with-reg/imm32/next
4436 _Primitive-or-reg-with-reg:
4437
4438 "or"/imm32/name
4439 Single-int-var-in-some-register/imm32/inouts
4440 Single-int-var-in-some-register/imm32/outputs
4441 "09/or-with"/imm32/subx-name
4442 3/imm32/rm32-is-first-output
4443 1/imm32/r32-is-first-inout
4444 0/imm32/no-imm32
4445 0/imm32/output-is-write-only
4446 _Primitive-or-reg-with-mem/imm32/next
4447 _Primitive-or-reg-with-mem:
4448
4449 "or-with"/imm32/name
4450 Int-var-and-second-int-var-in-some-register/imm32/inouts
4451 0/imm32/outputs
4452 "09/or-with"/imm32/subx-name
4453 1/imm32/rm32-is-first-inout
4454 2/imm32/r32-is-second-inout
4455 0/imm32/no-imm32
4456 0/imm32/output-is-write-only
4457 _Primitive-or-mem-with-reg/imm32/next
4458 _Primitive-or-mem-with-reg:
4459
4460 "or"/imm32/name
4461 Single-int-var-on-stack/imm32/inouts
4462 Single-int-var-in-some-register/imm32/outputs
4463 "0b/or"/imm32/subx-name
4464 1/imm32/rm32-is-first-inout
4465 3/imm32/r32-is-first-output
4466 0/imm32/no-imm32
4467 0/imm32/output-is-write-only
4468 _Primitive-or-lit-with-reg/imm32/next
4469 _Primitive-or-lit-with-reg:
4470
4471 "or"/imm32/name
4472 Single-lit-var/imm32/inouts
4473 Single-int-var-in-some-register/imm32/outputs
4474 "81 4/subop/or"/imm32/subx-name
4475 3/imm32/rm32-is-first-output
4476 0/imm32/no-r32
4477 1/imm32/imm32-is-first-inout
4478 0/imm32/output-is-write-only
4479 _Primitive-or-lit-with-mem/imm32/next
4480 _Primitive-or-lit-with-mem:
4481
4482 "or-with"/imm32/name
4483 Int-var-and-literal/imm32/inouts
4484 0/imm32/outputs
4485 "81 4/subop/or"/imm32/subx-name
4486 1/imm32/rm32-is-first-inout
4487 0/imm32/no-r32
4488 2/imm32/imm32-is-first-inout
4489 0/imm32/output-is-write-only
4490 _Primitive-xor-with-eax/imm32/next
4491
4492 _Primitive-xor-with-eax:
4493
4494 "xor"/imm32/name
4495 Single-lit-var/imm32/inouts
4496 Single-int-var-in-eax/imm32/outputs
4497 "35/xor-with-eax"/imm32/subx-name
4498 0/imm32/no-rm32
4499 0/imm32/no-r32
4500 1/imm32/imm32-is-first-inout
4501 0/imm32/output-is-write-only
4502 _Primitive-xor-reg-with-reg/imm32/next
4503 _Primitive-xor-reg-with-reg:
4504
4505 "xor"/imm32/name
4506 Single-int-var-in-some-register/imm32/inouts
4507 Single-int-var-in-some-register/imm32/outputs
4508 "31/xor-with"/imm32/subx-name
4509 3/imm32/rm32-is-first-output
4510 1/imm32/r32-is-first-inout
4511 0/imm32/no-imm32
4512 0/imm32/output-is-write-only
4513 _Primitive-xor-reg-with-mem/imm32/next
4514 _Primitive-xor-reg-with-mem:
4515
4516 "xor-with"/imm32/name
4517 Int-var-and-second-int-var-in-some-register/imm32/inouts
4518 0/imm32/outputs
4519 "31/xor-with"/imm32/subx-name
4520 1/imm32/rm32-is-first-inout
4521 2/imm32/r32-is-second-inout
4522 0/imm32/no-imm32
4523 0/imm32/output-is-write-only
4524 _Primitive-xor-mem-with-reg/imm32/next
4525 _Primitive-xor-mem-with-reg:
4526
4527 "xor"/imm32/name
4528 Single-int-var-on-stack/imm32/inouts
4529 Single-int-var-in-some-register/imm32/outputs
4530 "33/xor"/imm32/subx-name
4531 1/imm32/rm32-is-first-inout
4532 3/imm32/r32-is-first-output
4533 0/imm32/no-imm32
4534 0/imm32/output-is-write-only
4535 _Primitive-xor-lit-with-reg/imm32/next
4536 _Primitive-xor-lit-with-reg:
4537
4538 "xor"/imm32/name
4539 Single-lit-var/imm32/inouts
4540 Single-int-var-in-some-register/imm32/outputs
4541 "81 4/subop/xor"/imm32/subx-name
4542 3/imm32/rm32-is-first-output
4543 0/imm32/no-r32
4544 1/imm32/imm32-is-first-inout
4545 0/imm32/output-is-write-only
4546 _Primitive-xor-lit-with-mem/imm32/next
4547 _Primitive-xor-lit-with-mem:
4548
4549 "xor-with"/imm32/name
4550 Int-var-and-literal/imm32/inouts
4551 0/imm32/outputs
4552 "81 4/subop/xor"/imm32/subx-name
4553 1/imm32/rm32-is-first-inout
4554 0/imm32/no-r32
4555 2/imm32/imm32-is-first-inout
4556 0/imm32/output-is-write-only
4557 _Primitive-copy-to-eax/imm32/next
4558
4559 _Primitive-copy-to-eax:
4560
4561 "copy"/imm32/name
4562 Single-lit-var/imm32/inouts
4563 Single-int-var-in-eax/imm32/outputs
4564 "b8/copy-to-eax"/imm32/subx-name
4565 0/imm32/no-rm32
4566 0/imm32/no-r32
4567 1/imm32/imm32-is-first-inout
4568 1/imm32/output-is-write-only
4569 _Primitive-copy-to-ecx/imm32/next
4570 _Primitive-copy-to-ecx:
4571
4572 "copy"/imm32/name
4573 Single-lit-var/imm32/inouts
4574 Single-int-var-in-ecx/imm32/outputs
4575 "b9/copy-to-ecx"/imm32/subx-name
4576 0/imm32/no-rm32
4577 0/imm32/no-r32
4578 1/imm32/imm32-is-first-inout
4579 1/imm32/output-is-write-only
4580 _Primitive-copy-to-edx/imm32/next
4581 _Primitive-copy-to-edx:
4582
4583 "copy"/imm32/name
4584 Single-lit-var/imm32/inouts
4585 Single-int-var-in-edx/imm32/outputs
4586 "ba/copy-to-edx"/imm32/subx-name
4587 0/imm32/no-rm32
4588 0/imm32/no-r32
4589 1/imm32/imm32-is-first-inout
4590 1/imm32/output-is-write-only
4591 _Primitive-copy-to-ebx/imm32/next
4592 _Primitive-copy-to-ebx:
4593
4594 "copy"/imm32/name
4595 Single-lit-var/imm32/inouts
4596 Single-int-var-in-ebx/imm32/outputs
4597 "bb/copy-to-ebx"/imm32/subx-name
4598 0/imm32/no-rm32
4599 0/imm32/no-r32
4600 1/imm32/imm32-is-first-inout
4601 1/imm32/output-is-write-only
4602 _Primitive-copy-to-esi/imm32/next
4603 _Primitive-copy-to-esi:
4604
4605 "copy"/imm32/name
4606 Single-lit-var/imm32/inouts
4607 Single-int-var-in-esi/imm32/outputs
4608 "be/copy-to-esi"/imm32/subx-name
4609 0/imm32/no-rm32
4610 0/imm32/no-r32
4611 1/imm32/imm32-is-first-inout
4612 1/imm32/output-is-write-only
4613 _Primitive-copy-to-edi/imm32/next
4614 _Primitive-copy-to-edi:
4615
4616 "copy"/imm32/name
4617 Single-lit-var/imm32/inouts
4618 Single-int-var-in-edi/imm32/outputs
4619 "bf/copy-to-edi"/imm32/subx-name
4620 0/imm32/no-rm32
4621 0/imm32/no-r32
4622 1/imm32/imm32-is-first-inout
4623 1/imm32/output-is-write-only
4624 _Primitive-copy-reg-to-reg/imm32/next
4625 _Primitive-copy-reg-to-reg:
4626
4627 "copy"/imm32/name
4628 Single-int-var-in-some-register/imm32/inouts
4629 Single-int-var-in-some-register/imm32/outputs
4630 "89/copy-to"/imm32/subx-name
4631 3/imm32/rm32-is-first-output
4632 1/imm32/r32-is-first-inout
4633 0/imm32/no-imm32
4634 1/imm32/output-is-write-only
4635 _Primitive-copy-reg-to-mem/imm32/next
4636 _Primitive-copy-reg-to-mem:
4637
4638 "copy-to"/imm32/name
4639 Int-var-and-second-int-var-in-some-register/imm32/inouts
4640 0/imm32/outputs
4641 "89/copy-to"/imm32/subx-name
4642 1/imm32/rm32-is-first-inout
4643 2/imm32/r32-is-second-inout
4644 0/imm32/no-imm32
4645 1/imm32/output-is-write-only
4646 _Primitive-copy-mem-to-reg/imm32/next
4647 _Primitive-copy-mem-to-reg:
4648
4649 "copy"/imm32/name
4650 Single-int-var-on-stack/imm32/inouts
4651 Single-int-var-in-some-register/imm32/outputs
4652 "8b/copy-from"/imm32/subx-name
4653 1/imm32/rm32-is-first-inout
4654 3/imm32/r32-is-first-output
4655 0/imm32/no-imm32
4656 1/imm32/output-is-write-only
4657 _Primitive-copy-lit-to-reg/imm32/next
4658 _Primitive-copy-lit-to-reg:
4659
4660 "copy"/imm32/name
4661 Single-lit-var/imm32/inouts
4662 Single-int-var-in-some-register/imm32/outputs
4663 "c7 0/subop/copy"/imm32/subx-name
4664 3/imm32/rm32-is-first-output
4665 0/imm32/no-r32
4666 1/imm32/imm32-is-first-inout
4667 1/imm32/output-is-write-only
4668 _Primitive-copy-lit-to-mem/imm32/next
4669 _Primitive-copy-lit-to-mem:
4670
4671 "copy-to"/imm32/name
4672 Int-var-and-literal/imm32/inouts
4673 0/imm32/outputs
4674 "c7 0/subop/copy"/imm32/subx-name
4675 1/imm32/rm32-is-first-inout
4676 0/imm32/no-r32
4677 2/imm32/imm32-is-first-inout
4678 1/imm32/output-is-write-only
4679 0/imm32/next
4680
4681 Single-int-var-on-stack:
4682 Int-var-on-stack/imm32
4683 0/imm32/next
4684
4685 Int-var-on-stack:
4686 "arg1"/imm32/name
4687 Type-int/imm32
4688 1/imm32/some-block-depth
4689 1/imm32/some-stack-offset
4690 0/imm32/no-register
4691
4692 Int-var-and-second-int-var-in-some-register:
4693 Int-var-on-stack/imm32
4694 Single-int-var-in-some-register/imm32/next
4695
4696 Int-var-and-literal:
4697 Int-var-on-stack/imm32
4698 Single-lit-var/imm32/next
4699
4700 Single-int-var-in-some-register:
4701 Int-var-in-some-register/imm32
4702 0/imm32/next
4703
4704 Int-var-in-some-register:
4705 "arg1"/imm32/name
4706 Type-int/imm32
4707 1/imm32/some-block-depth
4708 0/imm32/no-stack-offset
4709 "*"/imm32/register
4710
4711 Single-int-var-in-eax:
4712 Int-var-in-eax/imm32
4713 0/imm32/next
4714
4715 Int-var-in-eax:
4716 "arg1"/imm32/name
4717 Type-int/imm32
4718 1/imm32/some-block-depth
4719 0/imm32/no-stack-offset
4720 "eax"/imm32/register
4721
4722 Single-int-var-in-ecx:
4723 Int-var-in-ecx/imm32
4724 0/imm32/next
4725
4726 Int-var-in-ecx:
4727 "arg1"/imm32/name
4728 Type-int/imm32
4729 1/imm32/some-block-depth
4730 0/imm32/no-stack-offset
4731 "ecx"/imm32/register
4732
4733 Single-int-var-in-edx:
4734 Int-var-in-edx/imm32
4735 0/imm32/next
4736
4737 Int-var-in-edx:
4738 "arg1"/imm32/name
4739 Type-int/imm32
4740 1/imm32/some-block-depth
4741 0/imm32/no-stack-offset
4742 "edx"/imm32/register
4743
4744 Single-int-var-in-ebx:
4745 Int-var-in-ebx/imm32
4746 0/imm32/next
4747
4748 Int-var-in-ebx:
4749 "arg1"/imm32/name
4750 Type-int/imm32
4751 1/imm32/some-block-depth
4752 0/imm32/no-stack-offset
4753 "ebx"/imm32/register
4754
4755 Single-int-var-in-esi:
4756 Int-var-in-esi/imm32
4757 0/imm32/next
4758
4759 Int-var-in-esi:
4760 "arg1"/imm32/name
4761 Type-int/imm32
4762 1/imm32/some-block-depth
4763 0/imm32/no-stack-offset
4764 "esi"/imm32/register
4765
4766 Single-int-var-in-edi:
4767 Int-var-in-edi/imm32
4768 0/imm32/next
4769
4770 Int-var-in-edi:
4771 "arg1"/imm32/name
4772 Type-int/imm32
4773 1/imm32/some-block-depth
4774 0/imm32/no-stack-offset
4775 "edi"/imm32/register
4776
4777 Single-lit-var:
4778 Lit-var/imm32
4779 0/imm32/next
4780
4781 Lit-var:
4782 "literal"/imm32/name
4783 Type-literal/imm32
4784 1/imm32/some-block-depth
4785 0/imm32/no-stack-offset
4786 0/imm32/no-register
4787
4788 Type-int:
4789 1/imm32/left/int
4790 0/imm32/right/null
4791
4792 Type-literal:
4793 0/imm32/left/literal
4794 0/imm32/right/null
4795
4796 == code
4797 emit-subx-primitive:
4798
4799 55/push-ebp
4800 89/<- %ebp 4/r32/esp
4801
4802 50/push-eax
4803 51/push-ecx
4804
4805 8b/-> *(ebp+0x10) 1/r32/ecx
4806
4807 (write-buffered *(ebp+8) *(ecx+0xc))
4808
4809 (emit-subx-rm32 *(ebp+8) *(ecx+0x10) *(ebp+0xc))
4810
4811 (emit-subx-r32 *(ebp+8) *(ecx+0x14) *(ebp+0xc))
4812
4813 (emit-subx-imm32 *(ebp+8) *(ecx+0x18) *(ebp+0xc))
4814 $emit-subx-primitive:end:
4815
4816 59/pop-to-ecx
4817 58/pop-to-eax
4818
4819 89/<- %esp 5/r32/ebp
4820 5d/pop-to-ebp
4821 c3/return
4822
4823 emit-subx-rm32:
4824
4825 55/push-ebp
4826 89/<- %ebp 4/r32/esp
4827
4828 50/push-eax
4829
4830 81 7/subop/compare *(ebp+0xc) 0/imm32
4831 74/jump-if-= $emit-subx-rm32:end/disp8
4832
4833 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
4834 (emit-subx-var-as-rm32 *(ebp+8) %eax)
4835 $emit-subx-rm32:end:
4836
4837 58/pop-to-eax
4838
4839 89/<- %esp 5/r32/ebp
4840 5d/pop-to-ebp
4841 c3/return
4842
4843 get-stmt-operand-from-arg-location:
4844
4845 55/push-ebp
4846 89/<- %ebp 4/r32/esp
4847
4848 51/push-ecx
4849
4850 8b/-> *(ebp+0xc) 0/r32/eax
4851
4852 8b/-> *(ebp+8) 1/r32/ecx
4853
4854 {
4855 3d/compare-eax-and 1/imm32
4856 75/jump-if-!= break/disp8
4857 $get-stmt-operand-from-arg-location:1:
4858 8b/-> *(ecx+8) 0/r32/eax
4859 8b/-> *eax 0/r32/eax
4860 eb/jump $get-stmt-operand-from-arg-location:end/disp8
4861 }
4862
4863 {
4864 3d/compare-eax-and 2/imm32
4865 75/jump-if-!= break/disp8
4866 $get-stmt-operand-from-arg-location:2:
4867 8b/-> *(ecx+8) 0/r32/eax
4868 8b/-> *(eax+4) 0/r32/eax
4869 8b/-> *eax 0/r32/eax
4870 eb/jump $get-stmt-operand-from-arg-location:end/disp8
4871 }
4872
4873 {
4874 3d/compare-eax-and 3/imm32
4875 75/jump-if-!= break/disp8
4876 $get-stmt-operand-from-arg-location:3:
4877 8b/-> *(ecx+0xc) 0/r32/eax
4878 8b/-> *eax 0/r32/eax
4879 eb/jump $get-stmt-operand-from-arg-location:end/disp8
4880 }
4881
4882 e9/jump $get-stmt-operand-from-arg-location:abort/disp32
4883 $get-stmt-operand-from-arg-location:end:
4884
4885 59/pop-to-ecx
4886
4887 89/<- %esp 5/r32/ebp
4888 5d/pop-to-ebp
4889 c3/return
4890
4891 $get-stmt-operand-from-arg-location:abort:
4892
4893 (write-buffered Stderr "invalid arg-location ")
4894 (print-int32-buffered Stderr %eax)
4895 (write-buffered Stderr Newline)
4896 (flush Stderr)
4897
4898 bb/copy-to-ebx 1/imm32
4899 b8/copy-to-eax 1/imm32/exit
4900 cd/syscall 0x80/imm8
4901
4902
4903 emit-subx-r32:
4904
4905 55/push-ebp
4906 89/<- %ebp 4/r32/esp
4907
4908 50/push-eax
4909 51/push-ecx
4910
4911 81 7/subop/compare *(ebp+0xc) 0/imm32
4912 0f 84/jump-if-= $emit-subx-r32:end/disp32
4913
4914 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
4915 (maybe-get Registers *(eax+0x10) 8)
4916 (write-buffered *(ebp+8) Space)
4917 (print-int32-buffered *(ebp+8) *eax)
4918 (write-buffered *(ebp+8) "/r32")
4919 $emit-subx-r32:end:
4920
4921 59/pop-to-ecx
4922 58/pop-to-eax
4923
4924 89/<- %esp 5/r32/ebp
4925 5d/pop-to-ebp
4926 c3/return
4927
4928 emit-subx-imm32:
4929
4930 55/push-ebp
4931 89/<- %ebp 4/r32/esp
4932
4933 50/push-eax
4934 51/push-ecx
4935
4936 81 7/subop/compare *(ebp+0xc) 0/imm32
4937 74/jump-if-= $emit-subx-imm32:end/disp8
4938
4939 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
4940 (write-buffered *(ebp+8) Space)
4941 (write-buffered *(ebp+8) *eax)
4942 (write-buffered *(ebp+8) "/imm32")
4943 $emit-subx-imm32:end:
4944
4945 59/pop-to-ecx
4946 58/pop-to-eax
4947
4948 89/<- %esp 5/r32/ebp
4949 5d/pop-to-ebp
4950 c3/return
4951
4952 emit-subx-call:
4953
4954 55/push-ebp
4955 89/<- %ebp 4/r32/esp
4956
4957 50/push-eax
4958 51/push-ecx
4959
4960 (write-buffered *(ebp+8) "(")
4961
4962 8b/-> *(ebp+0x10) 1/r32/ecx
4963 (write-buffered *(ebp+8) *(ecx+4))
4964
4965
4966 8b/-> *(ebp+0xc) 1/r32/ecx
4967 8b/-> *(ecx+8) 1/r32/ecx
4968 {
4969
4970 81 7/subop/compare %ecx 0/imm32
4971 74/jump-if-= break/disp8
4972
4973 (emit-subx-call-operand *(ebp+8) *ecx)
4974
4975 8b/-> *(ecx+4) 1/r32/ecx
4976 eb/jump loop/disp8
4977 }
4978
4979 (write-buffered *(ebp+8) ")")
4980 $emit-subx-call:end:
4981
4982 59/pop-to-ecx
4983 58/pop-to-eax
4984
4985 89/<- %esp 5/r32/ebp
4986 5d/pop-to-ebp
4987 c3/return
4988
4989 emit-subx-call-operand:
4990
4991 55/push-ebp
4992 89/<- %ebp 4/r32/esp
4993
4994 50/push-eax
4995
4996 8b/-> *(ebp+0xc) 0/r32/eax
4997
4998 {
4999 81 7/subop/compare *(eax+0x10) 0/imm32
5000 74/jump-if-= break/disp8
5001 $emit-subx-call-operand:register:
5002 (write-buffered *(ebp+8) " %")
5003 (write-buffered *(ebp+8) *(eax+0x10))
5004 e9/jump $emit-subx-call-operand:end/disp32
5005 }
5006
5007 {
5008 81 7/subop/compare *(eax+0xc) 0/imm32
5009 74/jump-if-= break/disp8
5010 $emit-subx-call-operand:stack:
5011 (write-buffered *(ebp+8) Space)
5012 (write-buffered *(ebp+8) "*(ebp+")
5013 8b/-> *(ebp+0xc) 0/r32/eax
5014 (print-int32-buffered *(ebp+8) *(eax+0xc))
5015 (write-buffered *(ebp+8) ")")
5016 e9/jump $emit-subx-call-operand:end/disp32
5017 }
5018
5019 {
5020 50/push-eax
5021 8b/-> *(eax+4) 0/r32/eax
5022 81 7/subop/compare *eax 0/imm32
5023 58/pop-to-eax
5024 75/jump-if-!= break/disp8
5025 $emit-subx-call-operand:literal:
5026 (write-buffered *(ebp+8) Space)
5027 (write-buffered *(ebp+8) *eax)
5028 }
5029 $emit-subx-call-operand:end:
5030
5031 58/pop-to-eax
5032
5033 89/<- %esp 5/r32/ebp
5034 5d/pop-to-ebp
5035 c3/return
5036
5037 emit-subx-var-as-rm32:
5038
5039 55/push-ebp
5040 89/<- %ebp 4/r32/esp
5041
5042 50/push-eax
5043
5044 8b/-> *(ebp+0xc) 0/r32/eax
5045
5046 {
5047 81 7/subop/compare *(eax+0x10) 0/imm32
5048 74/jump-if-= break/disp8
5049 $emit-subx-var-as-rm32:register:
5050 (write-buffered *(ebp+8) " %")
5051 (write-buffered *(ebp+8) *(eax+0x10))
5052 }
5053
5054 {
5055 81 7/subop/compare *(eax+0xc) 0/imm32
5056 74/jump-if-= break/disp8
5057 $emit-subx-var-as-rm32:stack:
5058 (write-buffered *(ebp+8) Space)
5059 (write-buffered *(ebp+8) "*(ebp+")
5060 8b/-> *(ebp+0xc) 0/r32/eax
5061 (print-int32-buffered *(ebp+8) *(eax+0xc))
5062 (write-buffered *(ebp+8) ")")
5063 }
5064 $emit-subx-var-as-rm32:end:
5065
5066 58/pop-to-eax
5067
5068 89/<- %esp 5/r32/ebp
5069 5d/pop-to-ebp
5070 c3/return
5071
5072 find-matching-function:
5073
5074 55/push-ebp
5075 89/<- %ebp 4/r32/esp
5076
5077 51/push-ecx
5078
5079 8b/-> *(ebp+8) 1/r32/ecx
5080 {
5081
5082 81 7/subop/compare %ecx 0/imm32
5083 74/jump-if-= break/disp8
5084
5085 {
5086 (mu-stmt-matches-function? *(ebp+0xc) %ecx)
5087 3d/compare-eax-and 0/imm32
5088 74/jump-if-= break/disp8
5089 89/<- %eax 1/r32/ecx
5090 eb/jump $find-matching-function:end/disp8
5091 }
5092
5093 8b/-> *(ecx+0x14) 1/r32/ecx
5094 eb/jump loop/disp8
5095 }
5096
5097 b8/copy-to-eax 0/imm32
5098 $find-matching-function:end:
5099
5100 59/pop-to-ecx
5101
5102 89/<- %esp 5/r32/ebp
5103 5d/pop-to-ebp
5104 c3/return
5105
5106 find-matching-primitive:
5107
5108 55/push-ebp
5109 89/<- %ebp 4/r32/esp
5110
5111 51/push-ecx
5112
5113 8b/-> *(ebp+8) 1/r32/ecx
5114 {
5115 $find-matching-primitive:loop:
5116
5117 81 7/subop/compare %ecx 0/imm32
5118 0f 84/jump-if-= break/disp32
5119
5120
5121
5122
5123
5124
5125
5126 {
5127 (mu-stmt-matches-primitive? *(ebp+0xc) %ecx)
5128 3d/compare-eax-and 0/imm32
5129 74/jump-if-= break/disp8
5130 89/<- %eax 1/r32/ecx
5131 eb/jump $find-matching-primitive:end/disp8
5132 }
5133 $find-matching-primitive:next-primitive:
5134
5135 8b/-> *(ecx+0x20) 1/r32/ecx
5136 e9/jump loop/disp32
5137 }
5138
5139 b8/copy-to-eax 0/imm32
5140 $find-matching-primitive:end:
5141
5142 59/pop-to-ecx
5143
5144 89/<- %esp 5/r32/ebp
5145 5d/pop-to-ebp
5146 c3/return
5147
5148 mu-stmt-matches-function?:
5149
5150 55/push-ebp
5151 89/<- %ebp 4/r32/esp
5152
5153 51/push-ecx
5154
5155 8b/-> *(ebp+8) 1/r32/ecx
5156 8b/-> *(ebp+0xc) 0/r32/eax
5157 (string-equal? *(ecx+4) *eax)
5158 $mu-stmt-matches-function?:end:
5159
5160 59/pop-to-ecx
5161
5162 89/<- %esp 5/r32/ebp
5163 5d/pop-to-ebp
5164 c3/return
5165
5166 mu-stmt-matches-primitive?:
5167
5168
5169
5170
5171
5172
5173 55/push-ebp
5174 89/<- %ebp 4/r32/esp
5175
5176 51/push-ecx
5177 52/push-edx
5178 53/push-ebx
5179 56/push-esi
5180 57/push-edi
5181
5182 8b/-> *(ebp+8) 1/r32/ecx
5183
5184 8b/-> *(ebp+0xc) 2/r32/edx
5185 {
5186 $mu-stmt-matches-primitive?:check-name:
5187
5188 (string-equal? *(ecx+4) *edx)
5189 3d/compare-eax-and 0/imm32
5190 75/jump-if-!= break/disp8
5191 b8/copy-to-eax 0/imm32
5192 e9/jump $mu-stmt-matches-primitive?:end/disp32
5193 }
5194 $mu-stmt-matches-primitive?:check-inouts:
5195
5196 8b/-> *(ecx+8) 6/r32/esi
5197 8b/-> *(edx+4) 7/r32/edi
5198 {
5199
5200 {
5201 81 7/subop/compare %esi 0/imm32
5202 75/jump-if-!= break/disp8
5203 $mu-stmt-matches-primitive?:stmt-inout-is-null:
5204 {
5205 81 7/subop/compare %edi 0/imm32
5206 75/jump-if-!= break/disp8
5207
5208 e9/jump $mu-stmt-matches-primitive?:check-outputs/disp32
5209 }
5210
5211 b8/copy-to-eax 0/imm32/false
5212 e9/jump $mu-stmt-matches-primitive?:end/disp32
5213 }
5214
5215 {
5216 81 7/subop/compare %edi 0/imm32
5217 75/jump-if-!= break/disp8
5218 $mu-stmt-matches-primitive?:prim-inout-is-null:
5219 b8/copy-to-eax 0/imm32/false
5220 e9/jump $mu-stmt-matches-primitive?:end/disp32
5221 }
5222
5223 {
5224 (operand-matches-primitive? *esi *edi)
5225 3d/compare-eax-and 0/imm32
5226 75/jump-if-!= break/disp8
5227 b8/copy-to-eax 0/imm32/false
5228 e9/jump $mu-stmt-matches-primitive?:end/disp32
5229 }
5230
5231 8b/-> *(esi+4) 6/r32/esi
5232
5233 8b/-> *(edi+4) 7/r32/edi
5234 eb/jump loop/disp8
5235 }
5236 $mu-stmt-matches-primitive?:check-outputs:
5237
5238 8b/-> *(ecx+0xc) 6/r32/esi
5239 8b/-> *(edx+8) 7/r32/edi
5240 {
5241
5242 {
5243 $mu-stmt-matches-primitive?:check-output:
5244 81 7/subop/compare %esi 0/imm32
5245 75/jump-if-!= break/disp8
5246 {
5247 81 7/subop/compare %edi 0/imm32
5248 75/jump-if-!= break/disp8
5249
5250 b8/copy-to-eax 1/imm32
5251 e9/jump $mu-stmt-matches-primitive?:end/disp32
5252 }
5253
5254 b8/copy-to-eax 0/imm32
5255 e9/jump $mu-stmt-matches-primitive?:end/disp32
5256 }
5257
5258 {
5259 81 7/subop/compare %edi 0/imm32
5260 75/jump-if-!= break/disp8
5261 b8/copy-to-eax 0/imm32
5262 e9/jump $mu-stmt-matches-primitive?:end/disp32
5263 }
5264
5265 {
5266 (operand-matches-primitive? *esi *edi)
5267 3d/compare-eax-and 0/imm32
5268 75/jump-if-!= break/disp8
5269 b8/copy-to-eax 0/imm32
5270 e9/jump $mu-stmt-matches-primitive?:end/disp32
5271 }
5272
5273 8b/-> *(esi+4) 6/r32/esi
5274
5275 8b/-> *(edi+4) 7/r32/edi
5276 eb/jump loop/disp8
5277 }
5278 $mu-stmt-matches-primitive?:return-true:
5279 b8/copy-to-eax 1/imm32
5280 $mu-stmt-matches-primitive?:end:
5281
5282 5f/pop-to-edi
5283 5e/pop-to-esi
5284 5b/pop-to-ebx
5285 5a/pop-to-edx
5286 59/pop-to-ecx
5287
5288 89/<- %esp 5/r32/ebp
5289 5d/pop-to-ebp
5290 c3/return
5291
5292 operand-matches-primitive?:
5293
5294 55/push-ebp
5295 89/<- %ebp 4/r32/esp
5296
5297 56/push-esi
5298 57/push-edi
5299
5300 8b/-> *(ebp+8) 6/r32/esi
5301
5302 8b/-> *(ebp+0xc) 7/r32/edi
5303
5304 (type-equal? *(esi+4) *(edi+4))
5305 3d/compare-eax-and 0/imm32
5306 b8/copy-to-eax 0/imm32/false
5307 74/jump-if-= $operand-matches-primitive?:end/disp8
5308
5309 {
5310
5311 8b/-> *(esi+0x10) 0/r32/eax
5312 39/compare *(edi+0x10) 0/r32/eax
5313 74/jump-if-= break/disp8
5314
5315 3d/compare-eax-and 0/imm32
5316 74/jump-if-= $operand-matches-primitive?:end/disp8
5317 81 7/subop/compare *(edi+0x10) 0/imm32
5318 74/jump-if-= $operand-matches-primitive?:end/disp8
5319
5320 (string-equal? *(edi+0x10) "*")
5321 3d/compare-eax-and 0/imm32
5322 b8/copy-to-eax 1/imm32/true
5323 75/jump-if-!= $operand-matches-primitive?:end/disp8
5324
5325 (string-equal? *(esi+0x10) *(edi+0x10))
5326 3d/compare-eax-and 0/imm32
5327 b8/copy-to-eax 0/imm32/false
5328 74/jump-if-= $operand-matches-primitive?:end/disp8
5329 }
5330
5331 b8/copy-to-eax 1/imm32/true
5332 $operand-matches-primitive?:end:
5333
5334 5f/pop-to-edi
5335 5e/pop-to-esi
5336
5337 89/<- %esp 5/r32/ebp
5338 5d/pop-to-ebp
5339 c3/return
5340
5341 type-equal?:
5342
5343 55/push-ebp
5344 89/<- %ebp 4/r32/esp
5345
5346 51/push-ecx
5347 52/push-edx
5348
5349 8b/-> *(ebp+8) 1/r32/ecx
5350
5351 8b/-> *(ebp+0xc) 2/r32/edx
5352
5353 8b/-> %ecx 0/r32/eax
5354 39/compare %edx 0/r32/eax
5355 b8/copy-to-eax 1/imm32/true
5356 74/jump-if-= $type-equal?:end/disp8
5357
5358 81 7/subop/compare %ecx 0x10000/imm32
5359 b8/copy-to-eax 0/imm32/false
5360 72/jump-if-addr< $type-equal?:end/disp8
5361
5362 81 7/subop/compare %edx 0x10000/imm32
5363 b8/copy-to-eax 0/imm32/false
5364 72/jump-if-addr< $type-equal?:end/disp8
5365
5366 (type-equal? *ecx *edx)
5367 3d/compare-eax-and 0/imm32
5368 74/jump-if-= $type-equal?:end/disp8
5369
5370 (type-equal? *(ecx+4) *(edx+4))
5371 $type-equal?:end:
5372
5373 5a/pop-to-edx
5374 59/pop-to-ecx
5375
5376 89/<- %esp 5/r32/ebp
5377 5d/pop-to-ebp
5378 c3/return
5379
5380 test-emit-subx-statement-primitive:
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399 55/push-ebp
5400 89/<- %ebp 4/r32/esp
5401
5402 (clear-stream _test-output-stream)
5403 (clear-stream $_test-output-buffered-file->buffer)
5404
5405 68/push 0/imm32/right/null
5406 68/push 1/imm32/left/int
5407 89/<- %ecx 4/r32/esp
5408
5409 68/push 0/imm32/no-register
5410 68/push -8/imm32/stack-offset
5411 68/push 1/imm32/block-depth
5412 51/push-ecx
5413 68/push "foo"/imm32
5414 89/<- %ecx 4/r32/esp
5415
5416 68/push 0/imm32/next
5417 51/push-ecx/var-foo
5418 89/<- %ebx 4/r32/esp
5419
5420 68/push 0/imm32/next
5421 68/push 0/imm32/outputs
5422 53/push-ebx/operands
5423 68/push "increment"/imm32/operation
5424 68/push 1/imm32
5425 89/<- %esi 4/r32/esp
5426
5427 68/push 0/imm32/next
5428 68/push 0/imm32/output-is-write-only
5429 68/push 0/imm32/no-imm32
5430 68/push 0/imm32/no-r32
5431 68/push 1/imm32/rm32-is-first-inout
5432 68/push "ff 0/subop/increment"/imm32/subx-name
5433 68/push 0/imm32/outputs
5434 53/push-ebx/inouts
5435 68/push "increment"/imm32/name
5436 89/<- %ebx 4/r32/esp
5437
5438 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
5439 (flush _test-output-buffered-file)
5440 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5446
5447 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0xfffffff8)" "F - test-emit-subx-statement-primitive")
5448
5449 89/<- %esp 5/r32/ebp
5450 5d/pop-to-ebp
5451 c3/return
5452
5453 test-emit-subx-statement-primitive-register:
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472 55/push-ebp
5473 89/<- %ebp 4/r32/esp
5474
5475 (clear-stream _test-output-stream)
5476 (clear-stream $_test-output-buffered-file->buffer)
5477
5478 68/push 0/imm32/right/null
5479 68/push 1/imm32/left/int
5480 89/<- %ecx 4/r32/esp
5481
5482 68/push "eax"/imm32/register
5483 68/push 0/imm32/no-stack-offset
5484 68/push 1/imm32/block-depth
5485 51/push-ecx
5486 68/push "foo"/imm32
5487 89/<- %ecx 4/r32/esp
5488
5489 68/push 0/imm32/next
5490 51/push-ecx/var-foo
5491 89/<- %ebx 4/r32/esp
5492
5493 68/push 0/imm32/next
5494 53/push-ebx/outputs
5495 68/push 0/imm32/inouts
5496 68/push "increment"/imm32/operation
5497 68/push 1/imm32
5498 89/<- %esi 4/r32/esp
5499
5500 68/push Any-register/imm32
5501 68/push 0/imm32/no-stack-offset
5502 68/push 1/imm32/block-depth
5503 ff 6/subop/push *(ecx+4)
5504 68/push "dummy"/imm32
5505 89/<- %ebx 4/r32/esp
5506
5507 68/push 0/imm32/next
5508 53/push-ebx/formal-var
5509 89/<- %ebx 4/r32/esp
5510
5511 68/push 0/imm32/next
5512 68/push 0/imm32/output-is-write-only
5513 68/push 0/imm32/no-imm32
5514 68/push 0/imm32/no-r32
5515 68/push 3/imm32/rm32-in-first-output
5516 68/push "ff 0/subop/increment"/imm32/subx-name
5517 53/push-ebx/outputs
5518 68/push 0/imm32/inouts
5519 68/push "increment"/imm32/name
5520 89/<- %ebx 4/r32/esp
5521
5522 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
5523 (flush _test-output-buffered-file)
5524 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5530
5531 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-primitive-register")
5532
5533 89/<- %esp 5/r32/ebp
5534 5d/pop-to-ebp
5535 c3/return
5536
5537 test-emit-subx-statement-select-primitive:
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559 55/push-ebp
5560 89/<- %ebp 4/r32/esp
5561
5562 (clear-stream _test-output-stream)
5563 (clear-stream $_test-output-buffered-file->buffer)
5564
5565 68/push 0/imm32/right/null
5566 68/push 1/imm32/left/int
5567 89/<- %ecx 4/r32/esp
5568
5569 68/push "eax"/imm32/register
5570 68/push 0/imm32/no-stack-offset
5571 68/push 1/imm32/block-depth
5572 51/push-ecx
5573 68/push "foo"/imm32
5574 89/<- %ecx 4/r32/esp
5575
5576 68/push 0/imm32/next
5577 51/push-ecx/var-foo
5578 89/<- %edi 4/r32/esp
5579
5580 68/push 0/imm32/next
5581 57/push-edi/outputs
5582 68/push 0/imm32/inouts
5583 68/push "increment"/imm32/operation
5584 68/push 1/imm32
5585 89/<- %esi 4/r32/esp
5586
5587 68/push Any-register/imm32
5588 68/push 0/imm32/no-stack-offset
5589 68/push 1/imm32/block-depth
5590 ff 6/subop/push *(ecx+4)
5591 68/push "dummy"/imm32
5592 89/<- %ebx 4/r32/esp
5593
5594 68/push 0/imm32/next
5595 53/push-ebx/formal-var
5596 89/<- %ebx 4/r32/esp
5597
5598 68/push 0/imm32/next
5599 68/push 0/imm32/output-is-write-only
5600 68/push 0/imm32/no-imm32
5601 68/push 0/imm32/no-r32
5602 68/push 3/imm32/rm32-in-first-output
5603 68/push "ff 0/subop/increment"/imm32/subx-name
5604 53/push-ebx/outputs/formal-outputs
5605 68/push 0/imm32/inouts
5606 68/push "increment"/imm32/name
5607 89/<- %ebx 4/r32/esp
5608
5609 53/push-ebx/next
5610 68/push 0/imm32/output-is-write-only
5611 68/push 0/imm32/no-imm32
5612 68/push 0/imm32/no-r32
5613 68/push 1/imm32/rm32-is-first-inout
5614 68/push "ff 0/subop/increment"/imm32/subx-name
5615 68/push 0/imm32/outputs
5616 57/push-edi/inouts/real-outputs
5617 68/push "increment"/imm32/name
5618 89/<- %ebx 4/r32/esp
5619
5620 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
5621 (flush _test-output-buffered-file)
5622 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5628
5629 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive")
5630
5631 89/<- %esp 5/r32/ebp
5632 5d/pop-to-ebp
5633 c3/return
5634
5635 test-emit-subx-statement-select-primitive-2:
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657 55/push-ebp
5658 89/<- %ebp 4/r32/esp
5659
5660 (clear-stream _test-output-stream)
5661 (clear-stream $_test-output-buffered-file->buffer)
5662
5663 68/push 0/imm32/right/null
5664 68/push 1/imm32/left/int
5665 89/<- %ecx 4/r32/esp
5666
5667 68/push "eax"/imm32/register
5668 68/push 0/imm32/no-stack-offset
5669 68/push 1/imm32/block-depth
5670 51/push-ecx
5671 68/push "foo"/imm32
5672 89/<- %ecx 4/r32/esp
5673
5674 68/push 0/imm32/next
5675 51/push-ecx/var-foo
5676 89/<- %edi 4/r32/esp
5677
5678 68/push 0/imm32/next
5679 68/push 0/imm32/outputs
5680 57/push-edi/inouts
5681 68/push "increment"/imm32/operation
5682 68/push 1/imm32
5683 89/<- %esi 4/r32/esp
5684
5685 68/push Any-register/imm32
5686 68/push 0/imm32/no-stack-offset
5687 68/push 1/imm32/block-depth
5688 ff 6/subop/push *(ecx+4)
5689 68/push "dummy"/imm32
5690 89/<- %ebx 4/r32/esp
5691
5692 68/push 0/imm32/next
5693 53/push-ebx/formal-var
5694 89/<- %ebx 4/r32/esp
5695
5696 68/push 0/imm32/next
5697 68/push 0/imm32/output-is-write-only
5698 68/push 0/imm32/no-imm32
5699 68/push 0/imm32/no-r32
5700 68/push 3/imm32/rm32-in-first-output
5701 68/push "ff 0/subop/increment"/imm32/subx-name
5702 53/push-ebx/outputs/formal-outputs
5703 68/push 0/imm32/inouts
5704 68/push "increment"/imm32/name
5705 89/<- %ebx 4/r32/esp
5706
5707 53/push-ebx/next
5708 68/push 0/imm32/output-is-write-only
5709 68/push 0/imm32/no-imm32
5710 68/push 0/imm32/no-r32
5711 68/push 1/imm32/rm32-is-first-inout
5712 68/push "ff 0/subop/increment"/imm32/subx-name
5713 68/push 0/imm32/outputs
5714 57/push-edi/inouts/real-outputs
5715 68/push "increment"/imm32/name
5716 89/<- %ebx 4/r32/esp
5717
5718 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
5719 (flush _test-output-buffered-file)
5720 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5726
5727 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive-2")
5728
5729 89/<- %esp 5/r32/ebp
5730 5d/pop-to-ebp
5731 c3/return
5732
5733 test-increment-register:
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749 55/push-ebp
5750 89/<- %ebp 4/r32/esp
5751
5752 (clear-stream _test-output-stream)
5753 (clear-stream $_test-output-buffered-file->buffer)
5754
5755 68/push 0/imm32/right/null
5756 68/push 1/imm32/left/int
5757 89/<- %ecx 4/r32/esp
5758
5759 68/push "eax"/imm32/register
5760 68/push 0/imm32/no-stack-offset
5761 68/push 1/imm32/block-depth
5762 51/push-ecx
5763 68/push "foo"/imm32
5764 89/<- %ecx 4/r32/esp
5765
5766 68/push 0/imm32/next
5767 51/push-ecx/var-foo
5768 89/<- %edi 4/r32/esp
5769
5770 68/push 0/imm32/next
5771 57/push-edi/outputs
5772 68/push 0/imm32/inouts
5773 68/push "increment"/imm32/operation
5774 68/push 1/imm32/regular-statement
5775 89/<- %esi 4/r32/esp
5776
5777 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
5778 (flush _test-output-buffered-file)
5779 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5785
5786 (check-next-stream-line-equal _test-output-stream "40/increment-eax" "F - test-increment-register")
5787
5788 89/<- %esp 5/r32/ebp
5789 5d/pop-to-ebp
5790 c3/return
5791
5792 test-increment-var:
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808 55/push-ebp
5809 89/<- %ebp 4/r32/esp
5810
5811 (clear-stream _test-output-stream)
5812 (clear-stream $_test-output-buffered-file->buffer)
5813
5814 68/push 0/imm32/right/null
5815 68/push 1/imm32/left/int
5816 89/<- %ecx 4/r32/esp
5817
5818 68/push "eax"/imm32/register
5819 68/push 0/imm32/no-stack-offset
5820 68/push 1/imm32/block-depth
5821 51/push-ecx
5822 68/push "foo"/imm32
5823 89/<- %ecx 4/r32/esp
5824
5825 68/push 0/imm32/next
5826 51/push-ecx/var-foo
5827 89/<- %edi 4/r32/esp
5828
5829 68/push 0/imm32/next
5830 68/push 0/imm32/outputs
5831 57/push-edi/inouts
5832 68/push "increment"/imm32/operation
5833 68/push 1/imm32
5834 89/<- %esi 4/r32/esp
5835
5836 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
5837 (flush _test-output-buffered-file)
5838 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5844
5845 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-var")
5846
5847 89/<- %esp 5/r32/ebp
5848 5d/pop-to-ebp
5849 c3/return
5850
5851 test-add-reg-to-reg:
5852
5853
5854
5855
5856
5857 55/push-ebp
5858 89/<- %ebp 4/r32/esp
5859
5860 (clear-stream _test-output-stream)
5861 (clear-stream $_test-output-buffered-file->buffer)
5862
5863 68/push 0/imm32/right/null
5864 68/push 1/imm32/left/int
5865 89/<- %ecx 4/r32/esp
5866
5867 68/push "eax"/imm32/register
5868 68/push 0/imm32/no-stack-offset
5869 68/push 1/imm32/block-depth
5870 51/push-ecx
5871 68/push "var1"/imm32
5872 89/<- %ecx 4/r32/esp
5873
5874 68/push "ecx"/imm32/register
5875 68/push 0/imm32/no-stack-offset
5876 68/push 1/imm32/block-depth
5877 ff 6/subop/push *(ecx+4)
5878 68/push "var2"/imm32
5879 89/<- %edx 4/r32/esp
5880
5881 68/push 0/imm32/next
5882 52/push-edx/var-var2
5883 89/<- %esi 4/r32/esp
5884
5885 68/push 0/imm32/next
5886 51/push-ecx/var-var1
5887 89/<- %edi 4/r32/esp
5888
5889 68/push 0/imm32/next
5890 57/push-edi/outputs
5891 56/push-esi/inouts
5892 68/push "add"/imm32/operation
5893 68/push 1/imm32
5894 89/<- %esi 4/r32/esp
5895
5896 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
5897 (flush _test-output-buffered-file)
5898 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5904
5905 (check-next-stream-line-equal _test-output-stream "01/add-to %eax 0x00000001/r32" "F - test-add-reg-to-reg")
5906
5907 89/<- %esp 5/r32/ebp
5908 5d/pop-to-ebp
5909 c3/return
5910
5911 test-add-reg-to-mem:
5912
5913
5914
5915
5916
5917 55/push-ebp
5918 89/<- %ebp 4/r32/esp
5919
5920 (clear-stream _test-output-stream)
5921 (clear-stream $_test-output-buffered-file->buffer)
5922
5923 68/push 0/imm32/right/null
5924 68/push 1/imm32/left/int
5925 89/<- %ecx 4/r32/esp
5926
5927 68/push 0/imm32/no-register
5928 68/push 8/imm32/stack-offset
5929 68/push 1/imm32/block-depth
5930 51/push-ecx
5931 68/push "var1"/imm32
5932 89/<- %ecx 4/r32/esp
5933
5934 68/push "ecx"/imm32/register
5935 68/push 0/imm32/no-stack-offset
5936 68/push 1/imm32/block-depth
5937 ff 6/subop/push *(ecx+4)
5938 68/push "var2"/imm32
5939 89/<- %edx 4/r32/esp
5940
5941 68/push 0/imm32/next
5942 52/push-edx/var-var2
5943 89/<- %esi 4/r32/esp
5944
5945 56/push-esi/next
5946 51/push-ecx/var-var1
5947 89/<- %esi 4/r32/esp
5948
5949 68/push 0/imm32/next
5950 68/push 0/imm32/outputs
5951 56/push-esi/inouts
5952 68/push "add-to"/imm32/operation
5953 68/push 1/imm32
5954 89/<- %esi 4/r32/esp
5955
5956 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
5957 (flush _test-output-buffered-file)
5958 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5964
5965 (check-next-stream-line-equal _test-output-stream "01/add-to *(ebp+0x00000008) 0x00000001/r32" "F - test-add-reg-to-mem")
5966
5967 89/<- %esp 5/r32/ebp
5968 5d/pop-to-ebp
5969 c3/return
5970
5971 test-add-mem-to-reg:
5972
5973
5974
5975
5976
5977 55/push-ebp
5978 89/<- %ebp 4/r32/esp
5979
5980 (clear-stream _test-output-stream)
5981 (clear-stream $_test-output-buffered-file->buffer)
5982
5983 68/push 0/imm32/right/null
5984 68/push 1/imm32/left/int
5985 89/<- %ecx 4/r32/esp
5986
5987 68/push "eax"/imm32/register
5988 68/push 0/imm32/no-stack-offset
5989 68/push 1/imm32/block-depth
5990 51/push-ecx
5991 68/push "var1"/imm32
5992 89/<- %ecx 4/r32/esp
5993
5994 68/push 0/imm32/no-register
5995 68/push 8/imm32/stack-offset
5996 68/push 1/imm32/block-depth
5997 ff 6/subop/push *(ecx+4)
5998 68/push "var2"/imm32
5999 89/<- %edx 4/r32/esp
6000
6001 68/push 0/imm32/next
6002 52/push-edx/var-var2
6003 89/<- %esi 4/r32/esp
6004
6005 68/push 0/imm32/next
6006 51/push-ecx/var-var1
6007 89/<- %edi 4/r32/esp
6008
6009 68/push 0/imm32/next
6010 57/push-edi/outputs
6011 56/push-esi/inouts
6012 68/push "add"/imm32/operation
6013 68/push 1/imm32
6014 89/<- %esi 4/r32/esp
6015
6016 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
6017 (flush _test-output-buffered-file)
6018 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
6024
6025 (check-next-stream-line-equal _test-output-stream "03/add *(ebp+0x00000008) 0x00000000/r32" "F - test-add-mem-to-reg")
6026
6027 89/<- %esp 5/r32/ebp
6028 5d/pop-to-ebp
6029 c3/return
6030
6031 test-add-literal-to-eax:
6032
6033
6034
6035
6036
6037 55/push-ebp
6038 89/<- %ebp 4/r32/esp
6039
6040 (clear-stream _test-output-stream)
6041 (clear-stream $_test-output-buffered-file->buffer)
6042
6043 68/push 0/imm32/right/null
6044 68/push 1/imm32/left/int
6045 89/<- %ecx 4/r32/esp
6046
6047 68/push "eax"/imm32/register
6048 68/push 0/imm32/no-stack-offset
6049 68/push 1/imm32/block-depth
6050 51/push-ecx
6051 68/push "var1"/imm32
6052 89/<- %ecx 4/r32/esp
6053
6054 68/push 0/imm32/right/null
6055 68/push 0/imm32/left/literal
6056 89/<- %edx 4/r32/esp
6057
6058 68/push 0/imm32/no-register
6059 68/push 0/imm32/no-stack-offset
6060 68/push 1/imm32/block-depth
6061 52/push-edx
6062 68/push "0x34"/imm32
6063 89/<- %edx 4/r32/esp
6064
6065 68/push 0/imm32/next
6066 52/push-edx/var-var2
6067 89/<- %esi 4/r32/esp
6068
6069 68/push 0/imm32/next
6070 51/push-ecx/var-var1
6071 89/<- %edi 4/r32/esp
6072
6073 68/push 0/imm32/next
6074 57/push-edi/outputs
6075 56/push-esi/inouts
6076 68/push "add"/imm32/operation
6077 68/push 1/imm32
6078 89/<- %esi 4/r32/esp
6079
6080 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
6081 (flush _test-output-buffered-file)
6082 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
6088
6089 (check-next-stream-line-equal _test-output-stream "05/add-to-eax 0x34/imm32" "F - test-add-literal-to-eax")
6090
6091 89/<- %esp 5/r32/ebp
6092 5d/pop-to-ebp
6093 c3/return
6094
6095 test-add-literal-to-reg:
6096
6097
6098
6099
6100
6101 55/push-ebp
6102 89/<- %ebp 4/r32/esp
6103
6104 (clear-stream _test-output-stream)
6105 (clear-stream $_test-output-buffered-file->buffer)
6106
6107 68/push 0/imm32/right/null
6108 68/push 1/imm32/left/int
6109 89/<- %ecx 4/r32/esp
6110
6111 68/push "ecx"/imm32/register
6112 68/push 0/imm32/no-stack-offset
6113 68/push 1/imm32/block-depth
6114 51/push-ecx
6115 68/push "var1"/imm32
6116 89/<- %ecx 4/r32/esp
6117
6118 68/push 0/imm32/right/null
6119 68/push 0/imm32/left/literal
6120 89/<- %edx 4/r32/esp
6121
6122 68/push 0/imm32/no-register
6123 68/push 0/imm32/no-stack-offset
6124 68/push 1/imm32/block-depth
6125 52/push-edx
6126 68/push "0x34"/imm32
6127 89/<- %edx 4/r32/esp
6128
6129 68/push 0/imm32/next
6130 52/push-edx/var-var2
6131 89/<- %esi 4/r32/esp
6132
6133 68/push 0/imm32/next
6134 51/push-ecx/var-var1
6135 89/<- %edi 4/r32/esp
6136
6137 68/push 0/imm32/next
6138 57/push-edi/outputs
6139 56/push-esi/inouts
6140 68/push "add"/imm32/operation
6141 68/push 1/imm32
6142 89/<- %esi 4/r32/esp
6143
6144 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
6145 (flush _test-output-buffered-file)
6146 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
6152
6153 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %ecx 0x34/imm32" "F - test-add-literal-to-reg")
6154
6155 89/<- %esp 5/r32/ebp
6156 5d/pop-to-ebp
6157 c3/return
6158
6159 test-add-literal-to-mem:
6160
6161
6162
6163
6164
6165 55/push-ebp
6166 89/<- %ebp 4/r32/esp
6167
6168 (clear-stream _test-output-stream)
6169 (clear-stream $_test-output-buffered-file->buffer)
6170
6171 68/push 0/imm32/right/null
6172 68/push 1/imm32/left/int
6173 89/<- %ecx 4/r32/esp
6174
6175 68/push 0/imm32/no-register
6176 68/push 8/imm32/stack-offset
6177 68/push 1/imm32/block-depth
6178 51/push-ecx
6179 68/push "var1"/imm32
6180 89/<- %ecx 4/r32/esp
6181
6182 68/push 0/imm32/right/null
6183 68/push 0/imm32/left/literal
6184 89/<- %edx 4/r32/esp
6185
6186 68/push 0/imm32/no-register
6187 68/push 0/imm32/no-stack-offset
6188 68/push 1/imm32/block-depth
6189 52/push-edx
6190 68/push "0x34"/imm32
6191 89/<- %edx 4/r32/esp
6192
6193 68/push 0/imm32/next
6194 52/push-edx/var-var2
6195 89/<- %esi 4/r32/esp
6196
6197 56/push-esi/next
6198 51/push-ecx/var-var1
6199 89/<- %esi 4/r32/esp
6200
6201 68/push 0/imm32/next
6202 68/push 0/imm32/outputs
6203 56/push-esi/inouts
6204 68/push "add-to"/imm32/operation
6205 68/push 1/imm32
6206 89/<- %esi 4/r32/esp
6207
6208 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
6209 (flush _test-output-buffered-file)
6210 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
6216
6217 (check-next-stream-line-equal _test-output-stream "81 0/subop/add *(ebp+0x00000008) 0x34/imm32" "F - test-add-literal-to-mem")
6218
6219 89/<- %esp 5/r32/ebp
6220 5d/pop-to-ebp
6221 c3/return
6222
6223 test-emit-subx-statement-function-call:
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244 55/push-ebp
6245 89/<- %ebp 4/r32/esp
6246
6247 (clear-stream _test-output-stream)
6248 (clear-stream $_test-output-buffered-file->buffer)
6249
6250 68/push 0/imm32/right/null
6251 68/push 1/imm32/left/int
6252 89/<- %ecx 4/r32/esp
6253
6254 68/push 0/imm32/no-register
6255 68/push -8/imm32/stack-offset
6256 68/push 0/imm32/block-depth
6257 51/push-ecx
6258 68/push "foo"/imm32
6259 89/<- %ecx 4/r32/esp
6260
6261 68/push 0/imm32/next
6262 51/push-ecx/var-foo
6263 89/<- %esi 4/r32/esp
6264
6265 68/push 0/imm32/next
6266 68/push 0/imm32/outputs
6267 56/push-esi/inouts
6268 68/push "f"/imm32/operation
6269 68/push 1/imm32
6270 89/<- %esi 4/r32/esp
6271
6272 68/push 0/imm32/next
6273 68/push 0/imm32/body
6274 68/push 0/imm32/outputs
6275 51/push-ecx/inouts
6276 68/push "f2"/imm32/subx-name
6277 68/push "f"/imm32/name
6278 89/<- %ebx 4/r32/esp
6279
6280 (emit-subx-statement _test-output-buffered-file %esi 0 %ebx)
6281 (flush _test-output-buffered-file)
6282 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
6288
6289 (check-next-stream-line-equal _test-output-stream "(f2 *(ebp+0xfffffff8))" "F - test-emit-subx-statement-function-call")
6290
6291 89/<- %esp 5/r32/ebp
6292 5d/pop-to-ebp
6293 c3/return
6294
6295 test-emit-subx-statement-function-call-with-literal-arg:
6296
6297
6298
6299
6300
6301
6302 55/push-ebp
6303 89/<- %ebp 4/r32/esp
6304
6305 (clear-stream _test-output-stream)
6306 (clear-stream $_test-output-buffered-file->buffer)
6307
6308 68/push 0/imm32/right/null
6309 68/push 0/imm32/left/literal
6310 89/<- %ecx 4/r32/esp
6311
6312 68/push 0/imm32/no-register
6313 68/push 0/imm32/no-stack-offset
6314 68/push 0/imm32/block-depth
6315 51/push-ecx
6316 68/push "34"/imm32
6317 89/<- %ecx 4/r32/esp
6318
6319 68/push 0/imm32/next
6320 51/push-ecx/var-foo
6321 89/<- %esi 4/r32/esp
6322
6323 68/push 0/imm32/next
6324 68/push 0/imm32/outputs
6325 56/push-esi/inouts
6326 68/push "f"/imm32/operation
6327 68/push 1/imm32
6328 89/<- %esi 4/r32/esp
6329
6330 68/push 0/imm32/next
6331 68/push 0/imm32/body
6332 68/push 0/imm32/outputs
6333 51/push-ecx/inouts
6334 68/push "f2"/imm32/subx-name
6335 68/push "f"/imm32/name
6336 89/<- %ebx 4/r32/esp
6337
6338 (emit-subx-statement _test-output-buffered-file %esi 0 %ebx)
6339 (flush _test-output-buffered-file)
6340 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
6346
6347 (check-next-stream-line-equal _test-output-stream "(f2 34)" "F - test-emit-subx-statement-function-call-with-literal-arg")
6348
6349 89/<- %esp 5/r32/ebp
6350 5d/pop-to-ebp
6351 c3/return
6352
6353 emit-subx-prologue:
6354
6355 55/push-ebp
6356 89/<- %ebp 4/r32/esp
6357
6358 (write-buffered *(ebp+8) "# . prologue\n")
6359 (write-buffered *(ebp+8) "55/push-ebp\n")
6360 (write-buffered *(ebp+8) "89/<- %ebp 4/r32/esp\n")
6361 $emit-subx-prologue:end:
6362
6363 89/<- %esp 5/r32/ebp
6364 5d/pop-to-ebp
6365 c3/return
6366
6367 emit-subx-epilogue:
6368
6369 55/push-ebp
6370 89/<- %ebp 4/r32/esp
6371
6372 (write-buffered *(ebp+8) "# . epilogue\n")
6373 (write-buffered *(ebp+8) "89/<- %esp 5/r32/ebp\n")
6374 (write-buffered *(ebp+8) "5d/pop-to-ebp\n")
6375 (write-buffered *(ebp+8) "c3/return\n")
6376 $emit-subx-epilogue:end:
6377
6378 89/<- %esp 5/r32/ebp
6379 5d/pop-to-ebp
6380 c3/return