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