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 == data
211
212 Program:
213 0/imm32
214
215 Function-name:
216 0/imm32
217 Function-subx-name:
218 4/imm32
219 Function-inouts:
220 8/imm32
221 Function-outputs:
222 0xc/imm32
223 Function-body:
224 0x10/imm32
225 Function-next:
226 0x14/imm32
227 Function-size:
228 0x18/imm32/24
229
230 Primitive-name:
231 0/imm32
232 Primitive-inouts:
233 4/imm32
234 Primitive-outputs:
235 8/imm32
236 Primitive-subx-name:
237 0xc/imm32
238 Primitive-subx-rm32:
239 0x10/imm32
240 Primitive-subx-r32:
241 0x14/imm32
242 Primitive-subx-imm32:
243 0x18/imm32
244 Primitive-next:
245 0x1c/imm32
246 Primitive-size:
247 0x20/imm32/24
248
249 Stmt-operation:
250 0/imm32
251 Stmt-inouts:
252 4/imm32
253 Stmt-outputs:
254 8/imm32
255 Stmt-next:
256 0xc/imm32
257 Stmt-size:
258 0x10/imm32
259
260 Var-name:
261 0/imm32
262 Var-type:
263 4/imm32
264 Var-block:
265 8/imm32
266 Var-stack-offset:
267 0xc/imm32
268 Var-register:
269 0x10/imm32
270 Var-size:
271 0x14/imm32
272
273 Any-register:
274
275 1/imm32
276
277 2a/asterisk
278
279 == code
280
281 Entry:
282
283 89/<- %ebp 4/r32/esp
284 (new-segment Heap-size Heap)
285
286 {
287
288 81 7/subop/compare *ebp 1/imm32
289 7e/jump-if-lesser-or-equal break/disp8
290
291 (kernel-string-equal? *(ebp+8) "test")
292 3d/compare-eax-and 0/imm32
293 74/jump-if-equal break/disp8
294
295 (run-tests)
296
297 8b/-> *Num-test-failures 3/r32/ebx
298 eb/jump $mu-main:end/disp8
299 }
300
301 (convert-mu Stdin Stdout)
302 (flush Stdout)
303
304 bb/copy-to-ebx 0/imm32
305 $mu-main:end:
306 b8/copy-to-eax 1/imm32/exit
307 cd/syscall 0x80/imm8
308
309 convert-mu:
310
311 55/push-ebp
312 89/<- %ebp 4/r32/esp
313
314 (parse-mu *(ebp+8))
315 (check-mu-types)
316 (emit-subx *(ebp+0xc))
317 $convert-mu:end:
318
319 89/<- %esp 5/r32/ebp
320 5d/pop-to-ebp
321 c3/return
322
323 test-convert-empty-input:
324
325
326 55/push-ebp
327 89/<- %ebp 4/r32/esp
328
329 (clear-stream _test-input-stream)
330 (clear-stream _test-input-buffered-file->buffer)
331 (clear-stream _test-output-stream)
332 (clear-stream _test-output-buffered-file->buffer)
333
334 (convert-mu _test-input-buffered-file _test-output-buffered-file)
335 (flush _test-output-buffered-file)
336 (check-stream-equal _test-output-stream "" "F - test-convert-empty-input")
337
338 89/<- %esp 5/r32/ebp
339 5d/pop-to-ebp
340 c3/return
341
342 test-convert-function-skeleton:
343
344
345
346
347
348
349
350
351
352
353
354
355
356 55/push-ebp
357 89/<- %ebp 4/r32/esp
358
359 (clear-stream _test-input-stream)
360 (clear-stream _test-input-buffered-file->buffer)
361 (clear-stream _test-output-stream)
362 (clear-stream _test-output-buffered-file->buffer)
363
364 (write _test-input-stream "fn foo {\n")
365 (write _test-input-stream "}\n")
366
367 (convert-mu _test-input-buffered-file _test-output-buffered-file)
368 (flush _test-output-buffered-file)
369 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
375
376 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-skeleton/0")
377 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-skeleton/1")
378 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-skeleton/2")
379 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-skeleton/3")
380 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-skeleton/4")
381 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-skeleton/5")
382 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-skeleton/6")
383 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-skeleton/7")
384
385 89/<- %esp 5/r32/ebp
386 5d/pop-to-ebp
387 c3/return
388
389 test-convert-multiple-function-skeletons:
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413 55/push-ebp
414 89/<- %ebp 4/r32/esp
415
416 (clear-stream _test-input-stream)
417 (clear-stream _test-input-buffered-file->buffer)
418 (clear-stream _test-output-stream)
419 (clear-stream _test-output-buffered-file->buffer)
420
421 (write _test-input-stream "fn foo {\n")
422 (write _test-input-stream "}\n")
423 (write _test-input-stream "fn bar {\n")
424 (write _test-input-stream "}\n")
425
426 (convert-mu _test-input-buffered-file _test-output-buffered-file)
427 (flush _test-output-buffered-file)
428 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
434
435 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-multiple-function-skeletons/0")
436 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/1")
437 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/2")
438 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/3")
439 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/4")
440 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/5")
441 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/6")
442 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/7")
443
444 (check-next-stream-line-equal _test-output-stream "bar:" "F - test-convert-multiple-function-skeletons/10")
445 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/11")
446 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/12")
447 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/13")
448 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/14")
449 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/15")
450 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/16")
451 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/17")
452
453 89/<- %esp 5/r32/ebp
454 5d/pop-to-ebp
455 c3/return
456
457 test-convert-function-with-arg:
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476 55/push-ebp
477 89/<- %ebp 4/r32/esp
478
479 (clear-stream _test-input-stream)
480 (clear-stream _test-input-buffered-file->buffer)
481 (clear-stream _test-output-stream)
482 (clear-stream _test-output-buffered-file->buffer)
483
484 (write _test-input-stream "fn foo {\n")
485 (write _test-input-stream "}\n")
486
487 (convert-mu _test-input-buffered-file _test-output-buffered-file)
488 (flush _test-output-buffered-file)
489 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
495
496 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-skeleton/0")
497 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-skeleton/1")
498 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-skeleton/2")
499 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-skeleton/3")
500 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-skeleton/4")
501 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-skeleton/5")
502 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-skeleton/6")
503 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-skeleton/7")
504
505 89/<- %esp 5/r32/ebp
506 5d/pop-to-ebp
507 c3/return
508
509 parse-mu:
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533 55/push-ebp
534 89/<- %ebp 4/r32/esp
535
536 50/push-eax
537 51/push-ecx
538 52/push-edx
539 57/push-edi
540
541 81 5/subop/subtract %esp 0x200/imm32
542 68/push 0x200/imm32/length
543 68/push 0/imm32/read
544 68/push 0/imm32/write
545 89/<- %ecx 4/r32/esp
546
547 68/push 0/imm32/end
548 68/push 0/imm32/start
549 89/<- %edx 4/r32/esp
550
551 bf/copy-to-edi Program/imm32
552 {
553 $parse-mu:line-loop:
554 (clear-stream %ecx)
555 (read-line-buffered *(ebp+8) %ecx)
556
557 81 7/subop/compare *ecx 0/imm32
558 0f 84/jump-if-equal break/disp32
559 +-- 6 lines: #? # dump line ---------------------------------------------------------------------------------------------------------------------------
565 {
566 $parse-mu:word-loop:
567 (next-word-or-string %ecx %edx)
568
569 (slice-empty? %edx)
570 3d/compare-eax-and 0/imm32
571 0f 85/jump-if-not-equal break/disp32
572
573
574 8b/-> *edx 0/r32/eax
575 8a/copy-byte *eax 0/r32/AL
576 81 4/subop/and %eax 0xff/imm32
577
578 3d/compare-eax-and 0x23/imm32/hash
579 0f 84/jump-if-equal break/disp32
580
581 {
582 (slice-equal? %edx "fn")
583 3d/compare-eax-and 0/imm32
584 0f 84/jump-if-equal break/disp32
585
586 (allocate Heap *Function-size)
587 (populate-mu-function-header %ecx %eax)
588 (populate-mu-function-body *(ebp+8) %eax)
589
590 89/<- *edi 0/r32/eax
591
592 8d/address-> *(eax+0x10) 7/r32/edi
593 e9/jump $parse-mu:word-loop/disp32
594 }
595
596 e9/jump $parse-mu:abort/disp32
597 }
598 e9/jump loop/disp32
599 }
600 $parse-mu:end:
601
602 81 0/subop/add %esp 0x214/imm32
603
604 5f/pop-to-edi
605 5a/pop-to-edx
606 59/pop-to-ecx
607 58/pop-to-eax
608
609 89/<- %esp 5/r32/ebp
610 5d/pop-to-ebp
611 c3/return
612
613 $parse-mu:abort:
614
615 (write-buffered Stderr "unexpected top-level command: ")
616 (write-buffered Stderr %edx)
617 (write-buffered Stderr "\n")
618 (flush Stderr)
619
620 bb/copy-to-ebx 1/imm32
621 b8/copy-to-eax 1/imm32/exit
622 cd/syscall 0x80/imm8
623
624
625
626
627
628
629
630 populate-mu-function-header:
631
632 55/push-ebp
633 89/<- %ebp 4/r32/esp
634
635 50/push-eax
636 51/push-ecx
637 57/push-edi
638
639 8b/-> *(ebp+0xc) 7/r32/edi
640
641 68/push 0/imm32/end
642 68/push 0/imm32/start
643 89/<- %ecx 4/r32/esp
644
645 (next-word *(ebp+8) %ecx)
646 (slice-to-string Heap %ecx)
647 89/<- *edi 0/r32/eax
648
649 (next-word *(ebp+8) %ecx)
650 (slice-equal? %ecx "{")
651 3d/compare-eax-and 0/imm32
652 74/jump-if-equal $populate-mu-function-header:abort/disp8
653
654 {
655
656 (next-word *(ebp+8) %ecx)
657
658 (slice-empty? %ecx)
659 3d/compare-eax-and 0/imm32
660 75/jump-if-not-equal break/disp8
661
662
663 8b/-> *edx 0/r32/eax
664 8a/copy-byte *eax 0/r32/AL
665 81 4/subop/and %eax 0xff/imm32
666
667 3d/compare-eax-and 0x23/imm32/hash
668 74/jump-if-equal break/disp8
669
670 eb/jump $populate-mu-function-header:abort/disp8
671 }
672 $populate-mu-function-header:end:
673
674 81 0/subop/add %esp 8/imm32
675
676 5f/pop-to-edi
677 59/pop-to-ecx
678 58/pop-to-eax
679
680 89/<- %esp 5/r32/ebp
681 5d/pop-to-ebp
682 c3/return
683
684 $populate-mu-function-header:abort:
685
686 (write-buffered Stderr "function header not in form 'fn <name> {' -- '")
687 (rewind-stream *(ebp+8))
688 (write-stream 2 *(ebp+8))
689 (write-buffered Stderr "'\n")
690 (flush Stderr)
691
692 bb/copy-to-ebx 1/imm32
693 b8/copy-to-eax 1/imm32/exit
694 cd/syscall 0x80/imm8
695
696
697
698
699 populate-mu-function-body:
700
701 55/push-ebp
702 89/<- %ebp 4/r32/esp
703
704 50/push-eax
705 51/push-ecx
706 52/push-edx
707 53/push-ebx
708
709 81 5/subop/subtract %esp 0x200/imm32
710 68/push 0x200/imm32/length
711 68/push 0/imm32/read
712 68/push 0/imm32/write
713 89/<- %ecx 4/r32/esp
714
715 68/push 0/imm32/end
716 68/push 0/imm32/start
717 89/<- %edx 4/r32/esp
718
719 bb/copy-to-ebx 1/imm32
720 {
721 $populate-mu-function-body:line-loop:
722
723 81 7/subop/compare %ebx 0/imm32
724 0f 84/jump-if-equal break/disp32
725
726 (clear-stream %ecx)
727 (read-line-buffered *(ebp+8) %ecx)
728
729 81 7/subop/compare *ecx 0/imm32
730 0f 84/jump-if-equal break/disp32
731
732 (next-word %ecx %edx)
733
734 (slice-empty? %ecx)
735 3d/compare-eax-and 0/imm32
736 75/jump-if-not-equal loop/disp8
737
738
739 8b/-> *edx 0/r32/eax
740 8a/copy-byte *eax 0/r32/AL
741 81 4/subop/and %eax 0xff/imm32
742
743 3d/compare-eax-and 0x23/imm32/hash
744 74/jump-if-equal loop/disp8
745 {
746
747 {
748 (slice-equal? %ecx "{")
749 3d/compare-eax-and 0/imm32
750 74/jump-if-equal break/disp8
751 43/increment-ebx
752 eb/jump $curly-found:end/disp8
753 }
754
755 {
756 (slice-equal? %ecx "}")
757 3d/compare-eax-and 0/imm32
758 74/jump-if-equal break/disp8
759 4b/decrement-ebx
760 eb/jump $curly-found:end/disp8
761 }
762
763 eb/jump $populate-mu-function-body:end/disp8
764 }
765
766 $curly-found:end:
767
768 (next-word %ecx %edx)
769
770 (slice-empty? %ecx)
771 3d/compare-eax-and 0/imm32
772 0f 85/jump-if-not-equal loop/disp32
773
774
775 8b/-> *edx 0/r32/eax
776 8a/copy-byte *eax 0/r32/AL
777 81 4/subop/and %eax 0xff/imm32
778
779 3d/compare-eax-and 0x23/imm32/hash
780 0f 84/jump-if-equal loop/disp32
781
782 eb/jump $populate-mu-function-body:abort/disp8
783 }
784 $populate-mu-function-body:end:
785
786 81 0/subop/add %esp 0x214/imm32
787
788 5b/pop-to-ebx
789 5a/pop-to-edx
790 59/pop-to-ecx
791 58/pop-to-eax
792
793 89/<- %esp 5/r32/ebp
794 5d/pop-to-ebp
795 c3/return
796
797 $populate-mu-function-body:abort:
798
799 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
800 (rewind-stream %ecx)
801 (write-stream 2 %ecx)
802 (write-buffered Stderr "'\n")
803 (flush Stderr)
804
805 bb/copy-to-ebx 1/imm32
806 b8/copy-to-eax 1/imm32/exit
807 cd/syscall 0x80/imm8
808
809
810 check-mu-types:
811
812 55/push-ebp
813 89/<- %ebp 4/r32/esp
814
815 $check-types:end:
816
817 89/<- %esp 5/r32/ebp
818 5d/pop-to-ebp
819 c3/return
820
821 emit-subx:
822
823 55/push-ebp
824 89/<- %ebp 4/r32/esp
825
826 50/push-eax
827 51/push-ecx
828 57/push-edi
829
830 8b/-> *(ebp+8) 7/r32/edi
831
832 8b/-> *Program 1/r32/ecx
833 {
834
835 81 7/subop/compare %ecx 0/imm32
836 0f 84/jump-if-equal break/disp32
837 (emit-subx-function %edi %ecx)
838
839 8b/-> *(ecx+0x10) 1/r32/ecx
840 e9/jump loop/disp32
841 }
842 $emit-subx:end:
843
844 5f/pop-to-edi
845 59/pop-to-ecx
846 58/pop-to-eax
847
848 89/<- %esp 5/r32/ebp
849 5d/pop-to-ebp
850 c3/return
851
852
853
854
855
856
857
858 emit-subx-function:
859
860 55/push-ebp
861 89/<- %ebp 4/r32/esp
862
863 50/push-eax
864 51/push-ecx
865 57/push-edi
866
867 8b/-> *(ebp+8) 7/r32/edi
868
869 8b/-> *(ebp+0xc) 1/r32/ecx
870
871 (write-buffered %edi *ecx)
872 (write-buffered %edi ":\n")
873 (emit-subx-prologue %edi)
874 (emit-subx-block %edi *(ecx+0x10))
875 (emit-subx-epilogue %edi)
876 $emit-subx-function:end:
877
878 5f/pop-to-edi
879 59/pop-to-ecx
880 58/pop-to-eax
881
882 89/<- %esp 5/r32/ebp
883 5d/pop-to-ebp
884 c3/return
885
886 emit-subx-block:
887
888 55/push-ebp
889 89/<- %ebp 4/r32/esp
890
891 $emit-subx-block:end:
892
893 89/<- %esp 5/r32/ebp
894 5d/pop-to-ebp
895 c3/return
896
897 emit-subx-statement:
898
899 55/push-ebp
900 89/<- %ebp 4/r32/esp
901
902 50/push-eax
903 51/push-ecx
904
905 {
906 $emit-subx-statement:primitive:
907 (find-matching-primitive *(ebp+0x14) *(ebp+0xc))
908 3d/compare-eax-and 0/imm32
909 74/jump-if-equal break/disp8
910 (emit-subx-primitive *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax)
911 e9/jump $emit-subx-statement:end/disp32
912 }
913
914 {
915 $emit-subx-statement:call:
916 (find-matching-function *(ebp+0x18) *(ebp+0xc))
917 3d/compare-eax-and 0/imm32
918 74/jump-if-equal break/disp8
919 (emit-subx-call *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax)
920 e9/jump $emit-subx-statement:end/disp32
921 }
922
923 e9/jump $emit-subx-statement:abort/disp32
924 $emit-subx-statement:end:
925
926 59/pop-to-ecx
927 58/pop-to-eax
928
929 89/<- %esp 5/r32/ebp
930 5d/pop-to-ebp
931 c3/return
932
933 $emit-subx-statement:abort:
934
935 (write-buffered Stderr "couldn't translate '")
936
937 (write-buffered Stderr "'\n")
938 (flush Stderr)
939
940 bb/copy-to-ebx 1/imm32
941 b8/copy-to-eax 1/imm32/exit
942 cd/syscall 0x80/imm8
943
944
945
946 == data
947 Primitives:
948
949 "increment"/imm32/name
950 Single-int-var-on-stack/imm32/inouts
951 0/imm32/no-outputs
952 "ff 0/subop/increment"/imm32/subx-name
953 1/imm32/rm32-is-first-inout
954 0/imm32/no-r32
955 0/imm32/no-imm32
956 _Primitive-inc-reg/imm32
957 _Primitive-inc-reg:
958
959 "increment"/imm32/name
960 0/imm32/no-inouts
961 Single-var-in-some-register/imm32/outputs
962 "ff 0/subop/increment"/imm32/subx-name
963 3/imm32/rm32-is-first-output
964 0/imm32/no-r32
965 0/imm32/no-imm32
966 0/imm32/next
967
968 Single-int-var-on-stack:
969 Int-var-on-stack/imm32
970 0/imm32/next
971
972 Int-var-on-stack:
973 "arg1"/imm32/name
974 1/imm32/type-int
975 1/imm32/some-block-depth
976 1/imm32/some-stack-offset
977 0/imm32/no-register
978
979 Single-var-in-some-register:
980 Int-var-in-some-register/imm32
981 0/imm32/next
982
983 Int-var-in-some-register:
984 "arg1"/imm32/name
985 1/imm32/type-int
986 1/imm32/some-block-depth
987 0/imm32/some-stack-offset
988 "*"/imm32/register
989
990 == code
991 emit-subx-primitive:
992
993 55/push-ebp
994 89/<- %ebp 4/r32/esp
995
996 50/push-eax
997 51/push-ecx
998
999 8b/-> *(ebp+0x14) 1/r32/ecx
1000
1001 (write-buffered *(ebp+8) *(ecx+0xc))
1002
1003 (emit-subx-rm32 *(ebp+8) *(ecx+0x10) *(ebp+0xc))
1004
1005
1006
1007
1008 $emit-subx-primitive:end:
1009
1010 59/pop-to-ecx
1011 58/pop-to-eax
1012
1013 89/<- %esp 5/r32/ebp
1014 5d/pop-to-ebp
1015 c3/return
1016
1017 emit-subx-rm32:
1018
1019 55/push-ebp
1020 89/<- %ebp 4/r32/esp
1021
1022 50/push-eax
1023
1024 81 7/subop/compare *(ebp+0xc) 0/imm32
1025 74/jump-if-equal $emit-subx-rm32:end/disp8
1026
1027 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
1028 (emit-subx-call-operand *(ebp+8) %eax)
1029 $emit-subx-rm32:end:
1030
1031 58/pop-to-eax
1032
1033 89/<- %esp 5/r32/ebp
1034 5d/pop-to-ebp
1035 c3/return
1036
1037 get-stmt-operand-from-arg-location:
1038
1039 55/push-ebp
1040 89/<- %ebp 4/r32/esp
1041
1042 51/push-ecx
1043
1044 8b/-> *(ebp+0xc) 0/r32/eax
1045
1046 8b/-> *(ebp+8) 1/r32/ecx
1047
1048 {
1049 3d/compare-eax-and 1/imm32
1050 75/jump-if-not-equal break/disp8
1051 $get-stmt-operand-from-arg-location:1:
1052 8b/-> *(ecx+4) 0/r32/eax
1053 8b/-> *eax 0/r32/eax
1054 eb/jump $get-stmt-operand-from-arg-location:end/disp8
1055 }
1056
1057 {
1058 3d/compare-eax-and 2/imm32
1059 75/jump-if-not-equal break/disp8
1060 $get-stmt-operand-from-arg-location:2:
1061 8b/-> *(ecx+4) 0/r32/eax
1062 8b/-> *(eax+4) 0/r32/eax
1063 8b/-> *eax 0/r32/eax
1064 eb/jump $get-stmt-operand-from-arg-location:end/disp8
1065 }
1066
1067 {
1068 3d/compare-eax-and 3/imm32
1069 75/jump-if-not-equal break/disp8
1070 $get-stmt-operand-from-arg-location:3:
1071 8b/-> *(ecx+8) 0/r32/eax
1072 8b/-> *eax 0/r32/eax
1073 eb/jump $get-stmt-operand-from-arg-location:end/disp8
1074 }
1075
1076 e9/jump $get-stmt-operand-from-arg-location:abort/disp32
1077 $get-stmt-operand-from-arg-location:end:
1078
1079 59/pop-to-ecx
1080
1081 89/<- %esp 5/r32/ebp
1082 5d/pop-to-ebp
1083 c3/return
1084
1085 $get-stmt-operand-from-arg-location:abort:
1086
1087 (write-buffered Stderr "invalid arg-location ")
1088 (print-int32-buffered Stderr %eax)
1089 (write-buffered Stderr "\n")
1090 (flush Stderr)
1091
1092 bb/copy-to-ebx 1/imm32
1093 b8/copy-to-eax 1/imm32/exit
1094 cd/syscall 0x80/imm8
1095
1096
1097 emit-subx-r32:
1098
1099 55/push-ebp
1100 89/<- %ebp 4/r32/esp
1101
1102 50/push-eax
1103 51/push-ecx
1104
1105
1106
1107
1108 $emit-subx-r32:end:
1109
1110 59/pop-to-ecx
1111 58/pop-to-eax
1112
1113 89/<- %esp 5/r32/ebp
1114 5d/pop-to-ebp
1115 c3/return
1116
1117 emit-subx-imm32:
1118
1119 55/push-ebp
1120 89/<- %ebp 4/r32/esp
1121
1122 50/push-eax
1123 51/push-ecx
1124
1125
1126 $emit-subx-imm32:end:
1127
1128 59/pop-to-ecx
1129 58/pop-to-eax
1130
1131 89/<- %esp 5/r32/ebp
1132 5d/pop-to-ebp
1133 c3/return
1134
1135 emit-subx-call:
1136
1137 55/push-ebp
1138 89/<- %ebp 4/r32/esp
1139
1140 50/push-eax
1141 51/push-ecx
1142
1143 (write-buffered *(ebp+8) "(")
1144
1145 8b/-> *(ebp+0x14) 1/r32/ecx
1146 (write-buffered *(ebp+8) *(ecx+4))
1147
1148
1149 8b/-> *(ebp+0xc) 1/r32/ecx
1150 8b/-> *(ecx+4) 1/r32/ecx
1151 {
1152
1153 81 7/subop/compare %ecx 0/imm32
1154 74/jump-if-equal break/disp8
1155
1156 (emit-subx-call-operand *(ebp+8) *ecx)
1157
1158 8b/-> *(ecx+4) 1/r32/ecx
1159 }
1160
1161 (write-buffered *(ebp+8) ")")
1162 $emit-subx-call:end:
1163
1164 59/pop-to-ecx
1165 58/pop-to-eax
1166
1167 89/<- %esp 5/r32/ebp
1168 5d/pop-to-ebp
1169 c3/return
1170
1171 emit-subx-call-operand:
1172
1173 55/push-ebp
1174 89/<- %ebp 4/r32/esp
1175
1176 50/push-eax
1177
1178 8b/-> *(ebp+0xc) 0/r32/eax
1179
1180 {
1181 81 7/subop/compare *(eax+0x10) 0/imm32
1182 74/jump-if-equal break/disp8
1183 $emit-subx-call-operand:register:
1184 (write-buffered *(ebp+8) " %")
1185 (write-buffered *(ebp+8) *(eax+0x10))
1186 }
1187
1188 {
1189 81 7/subop/compare *(eax+0xc) 0/imm32
1190 74/jump-if-equal break/disp8
1191 $emit-subx-call-operand:stack:
1192 (write-buffered *(ebp+8) Space)
1193 (write-buffered *(ebp+8) "*(ebp+")
1194 8b/-> *(ebp+0xc) 0/r32/eax
1195 (print-int32-buffered *(ebp+8) *(eax+0xc))
1196 (write-buffered *(ebp+8) ")")
1197 }
1198 $emit-subx-call-operand:end:
1199
1200 58/pop-to-eax
1201
1202 89/<- %esp 5/r32/ebp
1203 5d/pop-to-ebp
1204 c3/return
1205
1206 find-matching-function:
1207
1208 55/push-ebp
1209 89/<- %ebp 4/r32/esp
1210
1211 51/push-ecx
1212
1213 8b/-> *(ebp+8) 1/r32/ecx
1214 {
1215
1216 81 7/subop/compare %ecx 0/imm32
1217 74/jump-if-equal break/disp8
1218
1219 {
1220 (mu-stmt-matches-function? *(ebp+0xc) %ecx)
1221 3d/compare-eax-and 0/imm32
1222 74/jump-if-equal break/disp8
1223 89/<- %eax 1/r32/ecx
1224 eb/jump $find-matching-function:end/disp8
1225 }
1226
1227 8b/-> *(ecx+0x10) 1/r32/ecx
1228 eb/jump loop/disp8
1229 }
1230
1231 b8/copy-to-eax 0/imm32
1232 $find-matching-function:end:
1233
1234 59/pop-to-ecx
1235
1236 89/<- %esp 5/r32/ebp
1237 5d/pop-to-ebp
1238 c3/return
1239
1240 find-matching-primitive:
1241
1242 55/push-ebp
1243 89/<- %ebp 4/r32/esp
1244
1245 51/push-ecx
1246
1247 8b/-> *(ebp+8) 1/r32/ecx
1248 {
1249 $find-matching-primitive:loop:
1250
1251 81 7/subop/compare %ecx 0/imm32
1252 74/jump-if-equal break/disp8
1253
1254 {
1255 (mu-stmt-matches-primitive? *(ebp+0xc) %ecx)
1256 3d/compare-eax-and 0/imm32
1257 74/jump-if-equal break/disp8
1258 89/<- %eax 1/r32/ecx
1259 eb/jump $find-matching-function:end/disp8
1260 }
1261 $find-matching-primitive:next-primitive:
1262
1263 8b/-> *(ecx+0x1c) 1/r32/ecx
1264 eb/jump loop/disp8
1265 }
1266
1267 b8/copy-to-eax 0/imm32
1268 $find-matching-primitive:end:
1269
1270 59/pop-to-ecx
1271
1272 89/<- %esp 5/r32/ebp
1273 5d/pop-to-ebp
1274 c3/return
1275
1276 mu-stmt-matches-function?:
1277
1278 55/push-ebp
1279 89/<- %ebp 4/r32/esp
1280
1281 51/push-ecx
1282
1283 8b/-> *(ebp+8) 1/r32/ecx
1284 8b/-> *(ebp+0xc) 0/r32/eax
1285 (string-equal? *ecx *eax)
1286 $mu-stmt-matches-function?:end:
1287
1288 59/pop-to-ecx
1289
1290 89/<- %esp 5/r32/ebp
1291 5d/pop-to-ebp
1292 c3/return
1293
1294 mu-stmt-matches-primitive?:
1295
1296
1297
1298
1299
1300
1301 55/push-ebp
1302 89/<- %ebp 4/r32/esp
1303
1304 51/push-ecx
1305 52/push-edx
1306 53/push-ebx
1307 56/push-esi
1308 57/push-edi
1309
1310 8b/-> *(ebp+8) 1/r32/ecx
1311
1312 8b/-> *(ebp+0xc) 2/r32/edx
1313 {
1314 $mu-stmt-matches-primitive?:check-name:
1315
1316 (string-equal? *ecx *edx)
1317 3d/compare-eax-and 0/imm32
1318 75/jump-if-not-equal break/disp8
1319 b8/copy-to-eax 0/imm32
1320 e9/jump $mu-stmt-matches-primitive?:end/disp32
1321 }
1322 $mu-stmt-matches-primitive?:check-inouts:
1323
1324 8b/-> *(ecx+4) 6/r32/esi
1325
1326 8b/-> *(edx+4) 7/r32/edi
1327 {
1328
1329 {
1330 81 7/subop/compare %esi 0/imm32
1331 75/jump-if-not-equal break/disp8
1332 {
1333 81 7/subop/compare %edi 0/imm32
1334 75/jump-if-not-equal break/disp8
1335
1336 b8/copy-to-eax 1/imm32
1337 e9/jump $mu-stmt-matches-primitive?:end/disp32
1338 }
1339
1340 b8/copy-to-eax 0/imm32
1341 e9/jump $mu-stmt-matches-primitive?:end/disp32
1342 }
1343
1344 {
1345 81 7/subop/compare %edi 0/imm32
1346 75/jump-if-not-equal break/disp8
1347 b8/copy-to-eax 0/imm32
1348 e9/jump $mu-stmt-matches-primitive?:end/disp32
1349 }
1350
1351 {
1352 (operand-matches-primitive? *esi *edi)
1353 3d/compare-eax-and 0/imm32
1354 75/jump-if-not-equal break/disp8
1355 b8/copy-to-eax 0/imm32
1356 e9/jump $mu-stmt-matches-primitive?:end/disp32
1357 }
1358
1359 8b/-> *(ecx+4) 1/r32/ecx
1360
1361 8b/-> *(edx+4) 2/r32/edx
1362 }
1363 $mu-stmt-matches-primitive?:check-outputs:
1364
1365 8b/-> *(ebp+8) 1/r32/ecx
1366
1367 8b/-> *(ebp+0xc) 2/r32/edx
1368
1369 8b/-> *(ecx+8) 6/r32/esi
1370
1371 8b/-> *(edx+8) 7/r32/edi
1372 {
1373
1374 {
1375 81 7/subop/compare %esi 0/imm32
1376 75/jump-if-not-equal break/disp8
1377 {
1378 81 7/subop/compare %edi 0/imm32
1379 75/jump-if-not-equal break/disp8
1380
1381 b8/copy-to-eax 1/imm32
1382 e9/jump $mu-stmt-matches-primitive?:end/disp32
1383 }
1384
1385 b8/copy-to-eax 0/imm32
1386 e9/jump $mu-stmt-matches-primitive?:end/disp32
1387 }
1388
1389 {
1390 81 7/subop/compare %edi 0/imm32
1391 75/jump-if-not-equal break/disp8
1392 b8/copy-to-eax 0/imm32
1393 e9/jump $mu-stmt-matches-primitive?:end/disp32
1394 }
1395
1396 {
1397 (output-operand-matches-primitive? *esi *edi)
1398 3d/compare-eax-and 0/imm32
1399 75/jump-if-not-equal break/disp8
1400 b8/copy-to-eax 0/imm32
1401 e9/jump $mu-stmt-matches-primitive?:end/disp32
1402 }
1403
1404 8b/-> *(ecx+4) 1/r32/ecx
1405
1406 8b/-> *(edx+4) 2/r32/edx
1407 }
1408 $mu-stmt-matches-primitive?:return-true:
1409 b8/copy-to-eax 1/imm32
1410 $mu-stmt-matches-primitive?:end:
1411
1412 5f/pop-to-edi
1413 5e/pop-to-esi
1414 5b/pop-to-ebx
1415 5a/pop-to-edx
1416 59/pop-to-ecx
1417
1418 89/<- %esp 5/r32/ebp
1419 5d/pop-to-ebp
1420 c3/return
1421
1422 operand-matches-primitive?:
1423
1424 55/push-ebp
1425 89/<- %ebp 4/r32/esp
1426
1427 56/push-esi
1428 57/push-edi
1429
1430 8b/-> *(ebp+8) 6/r32/esi
1431
1432 8b/-> *(ebp+0xc) 7/r32/edi
1433
1434
1435 {
1436
1437 8b/-> *(esi+0x10) 0/r32/eax
1438 39/compare *(edi+0x10) 0/r32/eax
1439 74/jump-if-equal break/disp8
1440
1441 3d/compare-eax-and 0/imm32
1442 74/jump-if-equal $operand-matches-primitive?:end/disp8
1443 81 7/subop/compare *(edi+0x10) 0/imm32
1444 74/jump-if-equal $operand-matches-primitive?:end/disp8
1445
1446 (string-equal? *(esi+0x10) *(edi+0x10))
1447 3d/compare-eax-and 0/imm32
1448 b8/copy-to-eax 0/imm32/false
1449 74/jump-if-equal $operand-matches-primitive?:end/disp8
1450 }
1451
1452 b8/copy-to-eax 1/imm32/true
1453 $operand-matches-primitive?:end:
1454
1455 5f/pop-to-edi
1456 5e/pop-to-esi
1457
1458 89/<- %esp 5/r32/ebp
1459 5d/pop-to-ebp
1460 c3/return
1461
1462
1463 output-operand-matches-primitive?:
1464
1465 55/push-ebp
1466 89/<- %ebp 4/r32/esp
1467
1468 56/push-esi
1469 57/push-edi
1470
1471 8b/-> *(ebp+8) 6/r32/esi
1472
1473 8b/-> *(ebp+0xc) 7/r32/edi
1474
1475
1476 {
1477
1478 8b/-> *(esi+0x10) 0/r32/eax
1479 39/compare *(edi+0x10) 0/r32/eax
1480 74/jump-if-equal break/disp8
1481
1482 3d/compare-eax-and 0/imm32
1483 74/jump-if-equal $operand-matches-primitive?:end/disp8
1484 81 7/subop/compare *(edi+0x10) 0/imm32
1485 74/jump-if-equal $operand-matches-primitive?:end/disp8
1486
1487 (string-equal? *(edi+0x10) "*")
1488 3d/compare-eax-and 0/imm32
1489 b8/copy-to-eax 1/imm32/true
1490 75/jump-if-not-equal $operand-matches-primitive?:end/disp8
1491
1492 (string-equal? *(esi+0x10) *(edi+0x10))
1493 3d/compare-eax-and 0/imm32
1494 b8/copy-to-eax 0/imm32/false
1495 74/jump-if-equal $operand-matches-primitive?:end/disp8
1496 }
1497
1498 b8/copy-to-eax 1/imm32/true
1499 $output-operand-matches-primitive?:end:
1500
1501 5f/pop-to-edi
1502 5e/pop-to-esi
1503
1504 89/<- %esp 5/r32/ebp
1505 5d/pop-to-ebp
1506 c3/return
1507
1508 test-emit-subx-statement-primitive:
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527 55/push-ebp
1528 89/<- %ebp 4/r32/esp
1529
1530 (clear-stream _test-output-stream)
1531 (clear-stream _test-output-buffered-file->buffer)
1532
1533 68/push 0/imm32/no-register
1534 68/push -8/imm32/stack-offset
1535 68/push 1/imm32/block-depth
1536 68/push 1/imm32/type-int
1537 68/push "foo"/imm32
1538 89/<- %ecx 4/r32/esp
1539
1540
1541 51/push-ecx/var-foo
1542 68/push 1/imm32/data-length
1543 68/push 1/imm32/top
1544 89/<- %edx 4/r32/esp
1545
1546
1547 68/push 0/imm32/next
1548 51/push-ecx/var-foo
1549 89/<- %ebx 4/r32/esp
1550
1551
1552 68/push 0/imm32/next
1553 68/push 0/imm32/outputs
1554 53/push-ebx/operands
1555 68/push "increment"/imm32/operation
1556 89/<- %esi 4/r32/esp
1557
1558
1559 68/push 0/imm32/next
1560 68/push 0/imm32/no-imm32
1561 68/push 0/imm32/no-r32
1562 68/push 1/imm32/rm32-is-first-inout
1563 68/push "ff 0/subop/increment"/imm32/subx-name
1564 68/push 0/imm32/outputs
1565 53/push-ebx/inouts
1566 68/push "increment"/imm32/name
1567 89/<- %ebx 4/r32/esp
1568 $aa-primitive-in-ebx:
1569
1570 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
1571 (flush _test-output-buffered-file)
1572 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
1578
1579 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0xfffffff8)" "F - test-emit-subx-statement-primitive/0")
1580
1581 81 0/subop/add %esp 0x48/imm32
1582
1583 89/<- %esp 5/r32/ebp
1584 5d/pop-to-ebp
1585 c3/return
1586
1587 test-emit-subx-statement-primitive-register:
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606 55/push-ebp
1607 89/<- %ebp 4/r32/esp
1608
1609 (clear-stream _test-output-stream)
1610 (clear-stream _test-output-buffered-file->buffer)
1611
1612 68/push "eax"/imm32/register
1613 68/push 0/imm32/no-stack-offset
1614 68/push 1/imm32/block-depth
1615 68/push 1/imm32/type-int
1616 68/push "foo"/imm32
1617 89/<- %ecx 4/r32/esp
1618
1619 51/push-ecx/var-foo
1620 68/push 1/imm32/data-length
1621 68/push 1/imm32/top
1622 89/<- %edx 4/r32/esp
1623
1624 68/push 0/imm32/next
1625 51/push-ecx/var-foo
1626 89/<- %ebx 4/r32/esp
1627
1628 68/push 0/imm32/next
1629 53/push-ebx/outputs
1630 68/push 0/imm32/inouts
1631 68/push "increment"/imm32/operation
1632 89/<- %esi 4/r32/esp
1633
1634 68/push Any-register/imm32
1635 68/push 0/imm32/no-stack-offset
1636 68/push 1/imm32/block-depth
1637 68/push 1/imm32/type-int
1638 68/push "dummy"/imm32
1639 89/<- %ebx 4/r32/esp
1640
1641 68/push 0/imm32/next
1642 53/push-ebx/formal-var
1643 89/<- %ebx 4/r32/esp
1644
1645 68/push 0/imm32/next
1646 68/push 0/imm32/no-imm32
1647 68/push 0/imm32/no-r32
1648 68/push 3/imm32/rm32-in-first-output
1649 68/push "ff 0/subop/increment"/imm32/subx-name
1650 53/push-ebx/outputs
1651 68/push 0/imm32/inouts
1652 68/push "increment"/imm32/name
1653 89/<- %ebx 4/r32/esp
1654
1655 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
1656 (flush _test-output-buffered-file)
1657 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
1663
1664 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-primitive-register/0")
1665
1666 81 0/subop/add %esp 0x48/imm32
1667
1668 89/<- %esp 5/r32/ebp
1669 5d/pop-to-ebp
1670 c3/return
1671
1672 test-emit-subx-statement-select-primitive:
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694 55/push-ebp
1695 89/<- %ebp 4/r32/esp
1696
1697 (clear-stream _test-output-stream)
1698 (clear-stream _test-output-buffered-file->buffer)
1699
1700 68/push "eax"/imm32/register
1701 68/push 0/imm32/no-stack-offset
1702 68/push 1/imm32/block-depth
1703 68/push 1/imm32/type-int
1704 68/push "foo"/imm32
1705 89/<- %ecx 4/r32/esp
1706
1707 51/push-ecx/var-foo
1708 68/push 1/imm32/data-length
1709 68/push 1/imm32/top
1710 89/<- %edx 4/r32/esp
1711
1712 68/push 0/imm32/next
1713 51/push-ecx/var-foo
1714 89/<- %edi 4/r32/esp
1715
1716 68/push 0/imm32/next
1717 57/push-edi/outputs
1718 68/push 0/imm32/inouts
1719 68/push "increment"/imm32/operation
1720 89/<- %esi 4/r32/esp
1721
1722 68/push Any-register/imm32
1723 68/push 0/imm32/no-stack-offset
1724 68/push 1/imm32/block-depth
1725 68/push 1/imm32/type-int
1726 68/push "dummy"/imm32
1727 89/<- %ebx 4/r32/esp
1728
1729 68/push 0/imm32/next
1730 53/push-ebx/formal-var
1731 89/<- %ebx 4/r32/esp
1732
1733 68/push 0/imm32/next
1734 68/push 0/imm32/no-imm32
1735 68/push 0/imm32/no-r32
1736 68/push 3/imm32/rm32-in-first-output
1737 68/push "ff 0/subop/increment"/imm32/subx-name
1738 53/push-ebx/outputs/formal-outputs
1739 68/push 0/imm32/inouts
1740 68/push "increment"/imm32/name
1741 89/<- %ebx 4/r32/esp
1742
1743 53/push-ebx/next
1744 68/push 0/imm32/no-imm32
1745 68/push 0/imm32/no-r32
1746 68/push 1/imm32/rm32-is-first-inout
1747 68/push "ff 0/subop/increment"/imm32/subx-name
1748 68/push 0/imm32/outputs
1749 57/push-edi/inouts/real-outputs
1750 68/push "increment"/imm32/name
1751 89/<- %ebx 4/r32/esp
1752
1753 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
1754 (flush _test-output-buffered-file)
1755 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
1761
1762 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive/0")
1763
1764 81 0/subop/add %esp 0x48/imm32
1765
1766 89/<- %esp 5/r32/ebp
1767 5d/pop-to-ebp
1768 c3/return
1769
1770 test-emit-subx-statement-select-primitive-2:
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792 55/push-ebp
1793 89/<- %ebp 4/r32/esp
1794
1795 (clear-stream _test-output-stream)
1796 (clear-stream _test-output-buffered-file->buffer)
1797
1798 68/push "eax"/imm32/register
1799 68/push 0/imm32/no-stack-offset
1800 68/push 1/imm32/block-depth
1801 68/push 1/imm32/type-int
1802 68/push "foo"/imm32
1803 89/<- %ecx 4/r32/esp
1804
1805 51/push-ecx/var-foo
1806 68/push 1/imm32/data-length
1807 68/push 1/imm32/top
1808 89/<- %edx 4/r32/esp
1809
1810 68/push 0/imm32/next
1811 51/push-ecx/var-foo
1812 89/<- %edi 4/r32/esp
1813
1814 68/push 0/imm32/next
1815 68/push 0/imm32/outputs
1816 57/push-edi/inouts
1817 68/push "increment"/imm32/operation
1818 89/<- %esi 4/r32/esp
1819
1820 68/push Any-register/imm32
1821 68/push 0/imm32/no-stack-offset
1822 68/push 1/imm32/block-depth
1823 68/push 1/imm32/type-int
1824 68/push "dummy"/imm32
1825 89/<- %ebx 4/r32/esp
1826
1827 68/push 0/imm32/next
1828 53/push-ebx/formal-var
1829 89/<- %ebx 4/r32/esp
1830
1831 68/push 0/imm32/next
1832 68/push 0/imm32/no-imm32
1833 68/push 0/imm32/no-r32
1834 68/push 3/imm32/rm32-in-first-output
1835 68/push "ff 0/subop/increment"/imm32/subx-name
1836 53/push-ebx/outputs/formal-outputs
1837 68/push 0/imm32/inouts
1838 68/push "increment"/imm32/name
1839 89/<- %ebx 4/r32/esp
1840
1841 53/push-ebx/next
1842 68/push 0/imm32/no-imm32
1843 68/push 0/imm32/no-r32
1844 68/push 1/imm32/rm32-is-first-inout
1845 68/push "ff 0/subop/increment"/imm32/subx-name
1846 68/push 0/imm32/outputs
1847 57/push-edi/inouts/real-outputs
1848 68/push "increment"/imm32/name
1849 89/<- %ebx 4/r32/esp
1850
1851 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
1852 (flush _test-output-buffered-file)
1853 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
1859
1860 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive-2/0")
1861
1862 81 0/subop/add %esp 0x48/imm32
1863
1864 89/<- %esp 5/r32/ebp
1865 5d/pop-to-ebp
1866 c3/return
1867
1868 test-emit-subx-statement-select-primitive-using-global-primitives:
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884 55/push-ebp
1885 89/<- %ebp 4/r32/esp
1886
1887 (clear-stream _test-output-stream)
1888 (clear-stream _test-output-buffered-file->buffer)
1889
1890 68/push "eax"/imm32/register
1891 68/push 0/imm32/no-stack-offset
1892 68/push 1/imm32/block-depth
1893 68/push 1/imm32/type-int
1894 68/push "foo"/imm32
1895 89/<- %ecx 4/r32/esp
1896
1897 51/push-ecx/var-foo
1898 68/push 1/imm32/data-length
1899 68/push 1/imm32/top
1900 89/<- %edx 4/r32/esp
1901
1902 68/push 0/imm32/next
1903 51/push-ecx/var-foo
1904 89/<- %edi 4/r32/esp
1905
1906 68/push 0/imm32/next
1907 57/push-edi/outputs
1908 68/push 0/imm32/inouts
1909 68/push "increment"/imm32/operation
1910 89/<- %esi 4/r32/esp
1911
1912 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0)
1913 (flush _test-output-buffered-file)
1914 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
1920
1921 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive/0")
1922
1923 81 0/subop/add %esp 0x48/imm32
1924
1925 89/<- %esp 5/r32/ebp
1926 5d/pop-to-ebp
1927 c3/return
1928
1929 test-emit-subx-statement-select-primitive-using-global-primitives-2:
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945 55/push-ebp
1946 89/<- %ebp 4/r32/esp
1947
1948 (clear-stream _test-output-stream)
1949 (clear-stream _test-output-buffered-file->buffer)
1950
1951 68/push "eax"/imm32/register
1952 68/push 0/imm32/no-stack-offset
1953 68/push 1/imm32/block-depth
1954 68/push 1/imm32/type-int
1955 68/push "foo"/imm32
1956 89/<- %ecx 4/r32/esp
1957
1958 51/push-ecx/var-foo
1959 68/push 1/imm32/data-length
1960 68/push 1/imm32/top
1961 89/<- %edx 4/r32/esp
1962
1963 68/push 0/imm32/next
1964 51/push-ecx/var-foo
1965 89/<- %edi 4/r32/esp
1966
1967 68/push 0/imm32/next
1968 68/push 0/imm32/outputs
1969 57/push-edi/inouts
1970 68/push "increment"/imm32/operation
1971 89/<- %esi 4/r32/esp
1972
1973 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0)
1974 (flush _test-output-buffered-file)
1975 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
1981
1982 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive-2/0")
1983
1984 81 0/subop/add %esp 0x48/imm32
1985
1986 89/<- %esp 5/r32/ebp
1987 5d/pop-to-ebp
1988 c3/return
1989
1990 test-emit-subx-statement-function-call:
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011 55/push-ebp
2012 89/<- %ebp 4/r32/esp
2013
2014 (clear-stream _test-output-stream)
2015 (clear-stream _test-output-buffered-file->buffer)
2016
2017 68/push 0/imm32/no-register
2018 68/push -8/imm32/stack-offset
2019 68/push 0/imm32/block-depth
2020 68/push 1/imm32/type-int
2021 68/push "foo"/imm32
2022 89/<- %ecx 4/r32/esp
2023
2024 51/push-ecx/var-foo
2025 68/push 1/imm32/data-length
2026 68/push 1/imm32/top
2027 89/<- %edx 4/r32/esp
2028
2029 68/push 0/imm32/next
2030 51/push-ecx/var-foo
2031 89/<- %esi 4/r32/esp
2032
2033 68/push 0/imm32/next
2034 68/push 0/imm32/outputs
2035 56/push-esi/inouts
2036 68/push "f"/imm32/operation
2037 89/<- %esi 4/r32/esp
2038
2039 68/push 0/imm32/next
2040 68/push 0/imm32/body
2041 68/push 0/imm32/outputs
2042 51/push-ecx/inouts
2043 68/push "f2"/imm32/subx-name
2044 68/push "f"/imm32/name
2045 89/<- %ebx 4/r32/esp
2046
2047 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx)
2048 (flush _test-output-buffered-file)
2049 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
2055
2056 (check-next-stream-line-equal _test-output-stream "(f2 *(ebp+0xfffffff8))" "F - test-emit-subx-statement-function-call/0")
2057
2058 81 0/subop/add %esp 0x3c/imm32
2059
2060 89/<- %esp 5/r32/ebp
2061 5d/pop-to-ebp
2062 c3/return
2063
2064 emit-subx-prologue:
2065
2066 55/push-ebp
2067 89/<- %ebp 4/r32/esp
2068
2069 (write-buffered *(ebp+8) "# . prologue\n")
2070 (write-buffered *(ebp+8) "55/push-ebp\n")
2071 (write-buffered *(ebp+8) "89/<- %ebp 4/r32/esp\n")
2072 $emit-subx-prologue:end:
2073
2074 89/<- %esp 5/r32/ebp
2075 5d/pop-to-ebp
2076 c3/return
2077
2078 emit-subx-epilogue:
2079
2080 55/push-ebp
2081 89/<- %ebp 4/r32/esp
2082
2083 (write-buffered *(ebp+8) "# . epilogue\n")
2084 (write-buffered *(ebp+8) "89/<- %esp 5/r32/ebp\n")
2085 (write-buffered *(ebp+8) "5d/pop-to-ebp\n")
2086 (write-buffered *(ebp+8) "c3/return\n")
2087 $emit-subx-epilogue:end:
2088
2089 89/<- %esp 5/r32/ebp
2090 5d/pop-to-ebp
2091 c3/return