https://github.com/akkartik/mu/blob/master/apps/mu.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246 == data
247
248 Program:
249 0/imm32
250
251 Function-name:
252 0/imm32
253 Function-subx-name:
254 4/imm32
255 Function-inouts:
256 8/imm32
257 Function-outputs:
258 0xc/imm32
259 Function-body:
260 0x10/imm32
261 Function-next:
262 0x14/imm32
263 Function-size:
264 0x18/imm32/24
265
266 Primitive-name:
267 0/imm32
268 Primitive-inouts:
269 4/imm32
270 Primitive-outputs:
271 8/imm32
272 Primitive-subx-name:
273 0xc/imm32
274 Primitive-subx-rm32:
275 0x10/imm32
276 Primitive-subx-r32:
277 0x14/imm32
278 Primitive-subx-imm32:
279 0x18/imm32
280 Primitive-next:
281 0x1c/imm32
282 Primitive-size:
283 0x20/imm32/24
284
285 Stmt-tag:
286 0/imm32
287
288 Block-statements:
289 4/imm32
290
291 Stmt1-operation:
292 4/imm32
293 Stmt1-inouts:
294 8/imm32
295 Stmt1-outputs:
296 0xc/imm32
297
298 Vardef-name:
299 4/imm32
300 Vardef-type:
301 8/imm32
302
303 Regvardef-name:
304 4/imm32
305 Regvardef-type:
306 8/imm32
307 Regvardef-register:
308 0xc/imm32
309
310 Named-block-name:
311 4/imm32
312 Named-block-statements:
313 8/imm32
314
315 Stmt-size:
316 0x10/imm32
317
318 Var-name:
319 0/imm32
320 Var-type:
321 4/imm32
322 Var-block:
323 8/imm32
324 Var-stack-offset:
325 0xc/imm32
326 Var-register:
327 0x10/imm32
328 Var-size:
329 0x14/imm32
330
331 Any-register:
332
333 1/imm32
334
335 2a/asterisk
336
337 List-value:
338 0/imm32
339 List-next:
340 4/imm32
341 List-size:
342 8/imm32
343
344 == code
345
346 Entry:
347
348 89/<- %ebp 4/r32/esp
349 (new-segment *Heap-size Heap)
350
351 {
352
353 81 7/subop/compare *ebp 1/imm32
354 7e/jump-if-lesser-or-equal break/disp8
355
356 (kernel-string-equal? *(ebp+8) "test")
357 3d/compare-eax-and 0/imm32
358 74/jump-if-equal break/disp8
359
360 (run-tests)
361
362 8b/-> *Num-test-failures 3/r32/ebx
363 eb/jump $mu-main:end/disp8
364 }
365
366 (convert-mu Stdin Stdout)
367 (flush Stdout)
368
369 bb/copy-to-ebx 0/imm32
370 $mu-main:end:
371 b8/copy-to-eax 1/imm32/exit
372 cd/syscall 0x80/imm8
373
374 convert-mu:
375
376 55/push-ebp
377 89/<- %ebp 4/r32/esp
378
379 (parse-mu *(ebp+8))
380 (check-mu-types)
381 (emit-subx *(ebp+0xc))
382 $convert-mu:end:
383
384 89/<- %esp 5/r32/ebp
385 5d/pop-to-ebp
386 c3/return
387
388 test-convert-empty-input:
389
390
391 55/push-ebp
392 89/<- %ebp 4/r32/esp
393
394 (clear-stream _test-input-stream)
395 (clear-stream $_test-input-buffered-file->buffer)
396 (clear-stream _test-output-stream)
397 (clear-stream $_test-output-buffered-file->buffer)
398
399 (convert-mu _test-input-buffered-file _test-output-buffered-file)
400 (flush _test-output-buffered-file)
401 (check-stream-equal _test-output-stream "" "F - test-convert-empty-input")
402
403 89/<- %esp 5/r32/ebp
404 5d/pop-to-ebp
405 c3/return
406
407 test-convert-function-skeleton:
408
409
410
411
412
413
414
415
416
417
418
419
420
421 55/push-ebp
422 89/<- %ebp 4/r32/esp
423
424 (clear-stream _test-input-stream)
425 (clear-stream $_test-input-buffered-file->buffer)
426 (clear-stream _test-output-stream)
427 (clear-stream $_test-output-buffered-file->buffer)
428
429 (write _test-input-stream "fn foo {\n")
430 (write _test-input-stream "}\n")
431
432 (convert-mu _test-input-buffered-file _test-output-buffered-file)
433 (flush _test-output-buffered-file)
434 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
440
441 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-skeleton/0")
442 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-skeleton/1")
443 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-skeleton/2")
444 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-skeleton/3")
445 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-skeleton/4")
446 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-skeleton/5")
447 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-skeleton/6")
448 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-skeleton/7")
449
450 89/<- %esp 5/r32/ebp
451 5d/pop-to-ebp
452 c3/return
453
454 test-convert-multiple-function-skeletons:
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478 55/push-ebp
479 89/<- %ebp 4/r32/esp
480
481 (clear-stream _test-input-stream)
482 (clear-stream $_test-input-buffered-file->buffer)
483 (clear-stream _test-output-stream)
484 (clear-stream $_test-output-buffered-file->buffer)
485
486 (write _test-input-stream "fn foo {\n")
487 (write _test-input-stream "}\n")
488 (write _test-input-stream "fn bar {\n")
489 (write _test-input-stream "}\n")
490
491 (convert-mu _test-input-buffered-file _test-output-buffered-file)
492 (flush _test-output-buffered-file)
493 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
499
500 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-multiple-function-skeletons/0")
501 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/1")
502 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/2")
503 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/3")
504 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/4")
505 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/5")
506 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/6")
507 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/7")
508
509 (check-next-stream-line-equal _test-output-stream "bar:" "F - test-convert-multiple-function-skeletons/10")
510 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/11")
511 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/12")
512 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/13")
513 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/14")
514 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/15")
515 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/16")
516 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/17")
517
518 89/<- %esp 5/r32/ebp
519 5d/pop-to-ebp
520 c3/return
521
522 test-convert-function-with-arg:
523
524
525
526
527
528
529
530
531
532
533
534
535
536 55/push-ebp
537 89/<- %ebp 4/r32/esp
538
539 (clear-stream _test-input-stream)
540 (clear-stream $_test-input-buffered-file->buffer)
541 (clear-stream _test-output-stream)
542 (clear-stream $_test-output-buffered-file->buffer)
543
544 (write _test-input-stream "fn foo n : int {\n")
545 (write _test-input-stream "}\n")
546
547 (convert-mu _test-input-buffered-file _test-output-buffered-file)
548 (flush _test-output-buffered-file)
549 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
555
556 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-with-arg/0")
557 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-with-arg/1")
558 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-with-arg/2")
559 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-with-arg/3")
560 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-with-arg/4")
561 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-with-arg/5")
562 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-with-arg/6")
563 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-with-arg/7")
564
565 89/<- %esp 5/r32/ebp
566 5d/pop-to-ebp
567 c3/return
568
569 test-convert-function-with-arg-and-body:
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587 55/push-ebp
588 89/<- %ebp 4/r32/esp
589
590 (clear-stream _test-input-stream)
591 (clear-stream $_test-input-buffered-file->buffer)
592 (clear-stream _test-output-stream)
593 (clear-stream $_test-output-buffered-file->buffer)
594
595 (write _test-input-stream "fn foo n : int {\n")
596 (write _test-input-stream " increment n\n")
597 (write _test-input-stream "}\n")
598
599 (convert-mu _test-input-buffered-file _test-output-buffered-file)
600 (flush _test-output-buffered-file)
601 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
607
608 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-with-arg-and-body/0")
609 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-with-arg-and-body/1")
610 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-with-arg-and-body/2")
611 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-with-arg-and-body/3")
612 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-with-arg-and-body/4")
613 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0x00000008)" "F - test-convert-function-with-arg-and-body/5")
614 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-with-arg-and-body/6")
615 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-with-arg-and-body/7")
616 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-with-arg-and-body/8")
617 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-with-arg-and-body/9")
618 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-with-arg-and-body/10")
619
620 89/<- %esp 5/r32/ebp
621 5d/pop-to-ebp
622 c3/return
623
624
625
626
627
628 parse-mu:
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652 55/push-ebp
653 89/<- %ebp 4/r32/esp
654
655 50/push-eax
656 51/push-ecx
657 52/push-edx
658 57/push-edi
659
660 81 5/subop/subtract %esp 0x200/imm32
661 68/push 0x200/imm32/length
662 68/push 0/imm32/read
663 68/push 0/imm32/write
664 89/<- %ecx 4/r32/esp
665
666 68/push 0/imm32/end
667 68/push 0/imm32/start
668 89/<- %edx 4/r32/esp
669
670 bf/copy-to-edi Program/imm32
671 {
672 $parse-mu:line-loop:
673 (clear-stream %ecx)
674 (read-line-buffered *(ebp+8) %ecx)
675
676 81 7/subop/compare *ecx 0/imm32
677 0f 84/jump-if-equal break/disp32
678 +-- 6 lines: #? # dump line ---------------------------------------------------------------------------------------------------------------------------
684 (next-word-or-string %ecx %edx)
685
686 (slice-empty? %edx)
687 3d/compare-eax-and 0/imm32
688 0f 85/jump-if-not-equal loop/disp32
689
690
691 8b/-> *edx 0/r32/eax
692 8a/copy-byte *eax 0/r32/AL
693 81 4/subop/and %eax 0xff/imm32
694
695 3d/compare-eax-and 0x23/imm32/hash
696 0f 84/jump-if-equal loop/disp32
697
698 {
699 $parse-mu:fn:
700 (slice-equal? %edx "fn")
701 3d/compare-eax-and 0/imm32
702 0f 84/jump-if-equal break/disp32
703
704 (allocate Heap *Function-size)
705 (populate-mu-function-header %ecx %eax)
706 (populate-mu-function-body *(ebp+8) %eax)
707
708 89/<- *edi 0/r32/eax
709
710 8d/address-> *(eax+0x14) 7/r32/edi
711 e9/jump $parse-mu:line-loop/disp32
712 }
713
714 e9/jump $parse-mu:abort/disp32
715 }
716 $parse-mu:end:
717
718 81 0/subop/add %esp 0x214/imm32
719
720 5f/pop-to-edi
721 5a/pop-to-edx
722 59/pop-to-ecx
723 58/pop-to-eax
724
725 89/<- %esp 5/r32/ebp
726 5d/pop-to-ebp
727 c3/return
728
729 $parse-mu:abort:
730
731 (write-buffered Stderr "unexpected top-level command: ")
732 (write-slice-buffered Stderr %edx)
733 (write-buffered Stderr "\n")
734 (flush Stderr)
735
736 bb/copy-to-ebx 1/imm32
737 b8/copy-to-eax 1/imm32/exit
738 cd/syscall 0x80/imm8
739
740
741
742
743
744
745
746
747
748
749
750
751
752 populate-mu-function-header:
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777 55/push-ebp
778 89/<- %ebp 4/r32/esp
779
780 50/push-eax
781 51/push-ecx
782 57/push-edi
783
784 8b/-> *(ebp+0xc) 7/r32/edi
785
786 68/push 0/imm32/end
787 68/push 0/imm32/start
788 89/<- %ecx 4/r32/esp
789
790 (next-word *(ebp+8) %ecx)
791
792
793 (slice-equal? %ecx "{")
794 3d/compare-eax-and 0/imm32
795 0f 85/jump-if-not-equal $populate-mu-function-header:abort/disp32
796
797 (slice-equal? %ecx "->")
798 3d/compare-eax-and 0/imm32
799 0f 85/jump-if-not-equal $populate-mu-function-header:abort/disp32
800
801 (slice-equal? %ecx "}")
802 3d/compare-eax-and 0/imm32
803 0f 85/jump-if-not-equal $populate-mu-function-header:abort/disp32
804
805 (slice-to-string Heap %ecx)
806 89/<- *edi 0/r32/eax
807
808 {
809 (next-word *(ebp+8) %ecx)
810
811 (slice-equal? %ecx "{")
812 3d/compare-eax-and 0/imm32
813 0f 85/jump-if-not-equal $populate-mu-function-header:done/disp32
814
815 (slice-equal? %ecx "->")
816 3d/compare-eax-and 0/imm32
817 75/jump-if-not-equal break/disp8
818
819 (slice-equal? %ecx "}")
820 3d/compare-eax-and 0/imm32
821 0f 85/jump-if-not-equal $populate-mu-function-header:abort/disp32
822
823 (parse-var-with-type %ecx *(ebp+8))
824 (append-list Heap %eax *(edi+8))
825 89/<- *(edi+8) 0/r32/eax
826 e9/jump loop/disp32
827 }
828
829 {
830 (next-word *(ebp+8) %ecx)
831
832 (slice-equal? %ecx "{")
833 3d/compare-eax-and 0/imm32
834 75/jump-if-not-equal break/disp8
835
836 (slice-equal? %ecx "->")
837 3d/compare-eax-and 0/imm32
838 0f 85/jump-if-not-equal $populate-mu-function-header:abort/disp32
839
840 (slice-equal? %ecx "}")
841 3d/compare-eax-and 0/imm32
842 0f 85/jump-if-not-equal $populate-mu-function-header:abort/disp32
843
844 (parse-var-with-type %ecx *(ebp+8))
845 (append-list Heap %eax *(edi+0xc))
846 89/<- *(edi+0xc) 0/r32/eax
847 e9/jump loop/disp32
848 }
849 $populate-mu-function-header:done:
850 (check-no-tokens-left *(ebp+8))
851 $populate-mu-function-header:end:
852
853 81 0/subop/add %esp 8/imm32
854
855 5f/pop-to-edi
856 59/pop-to-ecx
857 58/pop-to-eax
858
859 89/<- %esp 5/r32/ebp
860 5d/pop-to-ebp
861 c3/return
862
863 $populate-mu-function-header:abort:
864
865 (write-buffered Stderr "function header not in form 'fn <name> [inouts] [-> outputs] {' -- '")
866 (flush Stderr)
867 (rewind-stream *(ebp+8))
868 (write-stream 2 *(ebp+8))
869 (write-buffered Stderr "'\n")
870 (flush Stderr)
871
872 bb/copy-to-ebx 1/imm32
873 b8/copy-to-eax 1/imm32/exit
874 cd/syscall 0x80/imm8
875
876
877 test-function-header-with-arg:
878
879
880 55/push-ebp
881 89/<- %ebp 4/r32/esp
882
883 (clear-stream _test-input-stream)
884 (write _test-input-stream "foo n : int {\n")
885
886 2b/subtract-> *Function-size 4/r32/esp
887 89/<- %ecx 4/r32/esp
888 (zero-out %ecx *Function-size)
889
890 (populate-mu-function-header _test-input-stream %ecx)
891
892 (check-strings-equal *ecx "foo" "F - test-function-header-with-arg/name")
893
894 8b/-> *(ecx+8) 2/r32/edx
895
896 8b/-> *edx 3/r32/ebx
897 (check-strings-equal *ebx "n" "F - test-function-header-with-arg/inout:0")
898 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:0/type")
899
900 89/<- %esp 5/r32/ebp
901 5d/pop-to-ebp
902 c3/return
903
904 test-function-header-with-multiple-args:
905
906
907 55/push-ebp
908 89/<- %ebp 4/r32/esp
909
910 (clear-stream _test-input-stream)
911 (write _test-input-stream "foo a: int, b: int c: int {\n")
912
913 2b/subtract-> *Function-size 4/r32/esp
914 89/<- %ecx 4/r32/esp
915 (zero-out %ecx *Function-size)
916
917 (populate-mu-function-header _test-input-stream %ecx)
918
919 (check-strings-equal *ecx "foo")
920
921 8b/-> *(ecx+8) 2/r32/edx
922
923 8b/-> *edx 3/r32/ebx
924 (check-strings-equal *ebx "a" "F - test-function-header-with-multiple-args/inout:0")
925 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:0/type")
926
927 8b/-> *(edx+4) 2/r32/edx
928
929 8b/-> *edx 3/r32/ebx
930 (check-strings-equal *ebx "b" "F - test-function-header-with-multiple-args/inout:1")
931 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:1/type")
932
933 8b/-> *(edx+4) 2/r32/edx
934
935 8b/-> *edx 3/r32/ebx
936 (check-strings-equal *ebx "c" "F - test-function-header-with-multiple-args/inout:2")
937 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:2/type")
938
939 89/<- %esp 5/r32/ebp
940 5d/pop-to-ebp
941 c3/return
942
943 test-function-with-multiple-args-and-outputs:
944
945
946 55/push-ebp
947 89/<- %ebp 4/r32/esp
948
949 (clear-stream _test-input-stream)
950 (write _test-input-stream "foo a: int, b: int, c: int -> x/ecx: int y/edx : int {\n")
951
952 2b/subtract-> *Function-size 4/r32/esp
953 89/<- %ecx 4/r32/esp
954 (zero-out %ecx *Function-size)
955
956 (populate-mu-function-header _test-input-stream %ecx)
957
958 (check-strings-equal *ecx "foo")
959
960 8b/-> *(ecx+8) 2/r32/edx
961
962 8b/-> *edx 3/r32/ebx
963 (check-strings-equal *ebx "a" "F - test-function-header-with-multiple-args/inout:0")
964 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:0/type")
965
966 8b/-> *(edx+4) 2/r32/edx
967
968 8b/-> *edx 3/r32/ebx
969 (check-strings-equal *ebx "b" "F - test-function-header-with-multiple-args/inout:1")
970 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:1/type")
971
972 8b/-> *(edx+4) 2/r32/edx
973
974 8b/-> *edx 3/r32/ebx
975 (check-strings-equal *ebx "c" "F - test-function-header-with-multiple-args/inout:2")
976 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:2/type")
977
978 8b/-> *(ecx+0xc) 2/r32/edx
979
980 8b/-> *edx 3/r32/ebx
981 (check-strings-equal *ebx "x" "F - test-function-header-with-multiple-args/output:0")
982 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/output:0/type")
983 (check-strings-equal *(ebx+0x10) "ecx" "F - test-function-header-with-arg/output:0/register")
984
985 8b/-> *(edx+4) 2/r32/edx
986
987 8b/-> *edx 3/r32/ebx
988 (check-strings-equal *ebx "y" "F - test-function-header-with-multiple-args/output:1")
989 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/output:1/type")
990 (check-strings-equal *(ebx+0x10) "edx" "F - test-function-header-with-arg/output:0/register")
991
992 89/<- %esp 5/r32/ebp
993 5d/pop-to-ebp
994 c3/return
995
996
997
998
999
1000
1001 parse-var-with-type:
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032 55/push-ebp
1033 89/<- %ebp 4/r32/esp
1034
1035 51/push-ecx
1036 52/push-edx
1037 53/push-ebx
1038 56/push-esi
1039 57/push-edi
1040
1041 (allocate Heap *Var-size)
1042 89/<- %edi 0/r32/eax
1043
1044 8b/-> *(ebp+8) 6/r32/esi
1045
1046 68/push 0/imm32/end
1047 68/push 0/imm32/start
1048 89/<- %ecx 4/r32/esp
1049
1050 (next-token-from-slice *esi *(esi+4) 0x2f %ecx)
1051
1052 8b/-> *(ecx+4) 2/r32/edx
1053
1054 {
1055 8b/-> *(ecx+4) 0/r32/eax
1056 48/decrement-eax
1057 8a/copy-byte *eax 3/r32/BL
1058 81 4/subop/and %ebx 0xff/imm32
1059 81 7/subop/compare %ebx 0x3a/imm32/colon
1060 75/jump-if-not-equal break/disp8
1061 89/<- *(ecx+4) 0/r32/eax
1062 }
1063
1064 {
1065 8b/-> *(ecx+4) 0/r32/eax
1066 48/decrement-eax
1067 8a/copy-byte *eax 3/r32/BL
1068 81 4/subop/and %ebx 0xff/imm32
1069 81 7/subop/compare %ebx 0x2c/imm32/comma
1070 75/jump-if-not-equal break/disp8
1071 89/<- *(ecx+4) 0/r32/eax
1072 }
1073 (slice-to-string Heap %ecx)
1074 89/<- *edi 0/r32/eax
1075
1076 (next-token-from-slice %edx *(esi+4) 0x2f %ecx)
1077
1078 {
1079 8b/-> *(ecx+4) 0/r32/eax
1080 48/decrement-eax
1081 8a/copy-byte *eax 3/r32/BL
1082 81 4/subop/and %ebx 0xff/imm32
1083 81 7/subop/compare %ebx 0x3a/imm32/colon
1084 75/jump-if-not-equal break/disp8
1085 89/<- *(ecx+4) 0/r32/eax
1086 }
1087
1088 {
1089 8b/-> *(ecx+4) 0/r32/eax
1090 48/decrement-eax
1091 8a/copy-byte *eax 3/r32/BL
1092 81 4/subop/and %ebx 0xff/imm32
1093 81 7/subop/compare %ebx 0x2c/imm32/comma
1094 75/jump-if-not-equal break/disp8
1095 89/<- *(ecx+4) 0/r32/eax
1096 }
1097
1098 {
1099 (slice-empty? %ecx)
1100 3d/compare-eax-and 0/imm32
1101 75/jump-if-not-equal break/disp8
1102 (slice-to-string Heap %ecx)
1103 89/<- *(edi+0x10) 0/r32/eax
1104 }
1105
1106 (next-mu-token *(ebp+0xc) %ecx)
1107
1108 (slice-equal? %ecx "{")
1109 3d/compare-eax-and 0/imm32
1110 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1111
1112 (slice-equal? %ecx "->")
1113 3d/compare-eax-and 0/imm32
1114 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1115
1116 (slice-equal? %ecx "}")
1117 3d/compare-eax-and 0/imm32
1118 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1119
1120 (slice-empty? %ecx)
1121 {
1122 3d/compare-eax-and 0/imm32
1123 0f 84/jump-if-equal break/disp32
1124 (next-mu-token *(ebp+0xc) %ecx)
1125
1126 (slice-equal? %ecx "{")
1127 3d/compare-eax-and 0/imm32
1128 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1129
1130 (slice-equal? %ecx "->")
1131 3d/compare-eax-and 0/imm32
1132 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1133
1134 (slice-equal? %ecx "}")
1135 3d/compare-eax-and 0/imm32
1136 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1137 }
1138 (type-for %ecx)
1139 89/<- *(edi+4) 0/r32/eax
1140 $parse-var-with-type:end:
1141
1142 89/<- %eax 7/r32/edi
1143
1144 81 0/subop/add %esp 8/imm32
1145
1146 5f/pop-to-edi
1147 5e/pop-to-esi
1148 5b/pop-to-ebx
1149 5a/pop-to-edx
1150 59/pop-to-ecx
1151
1152 89/<- %esp 5/r32/ebp
1153 5d/pop-to-ebp
1154 c3/return
1155
1156 $parse-var-with-type:abort:
1157
1158 (write-buffered Stderr "var should have form 'name: type' in '")
1159 (flush Stderr)
1160 (rewind-stream *(ebp+0xc))
1161 (write-stream 2 *(ebp+0xc))
1162 (write-buffered Stderr "'\n")
1163 (flush Stderr)
1164
1165 bb/copy-to-ebx 1/imm32
1166 b8/copy-to-eax 1/imm32/exit
1167 cd/syscall 0x80/imm8
1168
1169
1170 next-mu-token:
1171
1172 55/push-ebp
1173 89/<- %ebp 4/r32/esp
1174
1175 50/push-eax
1176 57/push-edi
1177
1178 8b/-> *(ebp+0xc) 7/r32/edi
1179
1180 (next-word *(ebp+8) %edi)
1181
1182 {
1183 8b/-> *(edi+4) 0/r32/eax
1184 48/decrement-eax
1185 8a/copy-byte *eax 3/r32/BL
1186 81 4/subop/and %ebx 0xff/imm32
1187 81 7/subop/compare %ebx 0x3a/imm32/colon
1188 75/jump-if-not-equal break/disp8
1189 89/<- *(edi+4) 0/r32/eax
1190 }
1191
1192 {
1193 8b/-> *(edi+4) 0/r32/eax
1194 48/decrement-eax
1195 8a/copy-byte *eax 3/r32/BL
1196 81 4/subop/and %ebx 0xff/imm32
1197 81 7/subop/compare %ebx 0x2c/imm32/comma
1198 75/jump-if-not-equal break/disp8
1199 89/<- *(edi+4) 0/r32/eax
1200 }
1201 $next-mu-token:end:
1202 b8/copy-to-eax 1/imm32/int
1203
1204 5f/pop-to-edi
1205 58/pop-to-eax
1206
1207 89/<- %esp 5/r32/ebp
1208 5d/pop-to-ebp
1209 c3/return
1210
1211 type-for:
1212
1213 55/push-ebp
1214 89/<- %ebp 4/r32/esp
1215
1216
1217
1218
1219
1220 $type-for:end:
1221 b8/copy-to-eax 1/imm32/int
1222
1223
1224 89/<- %esp 5/r32/ebp
1225 5d/pop-to-ebp
1226 c3/return
1227
1228 test-parse-var-with-type:
1229
1230 55/push-ebp
1231 89/<- %ebp 4/r32/esp
1232
1233 b8/copy-to-eax "x:"/imm32
1234 8b/-> *eax 1/r32/ecx
1235 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1236 05/add-to-eax 4/imm32
1237
1238 51/push-ecx
1239 50/push-eax
1240 89/<- %ecx 4/r32/esp
1241
1242 (clear-stream _test-input-stream)
1243 (write _test-input-stream "int")
1244
1245 (parse-var-with-type %ecx _test-input-stream)
1246 8b/-> *eax 2/r32/edx
1247 (check-strings-equal %edx "x" "F - test-var-with-type/name")
1248 8b/-> *(eax+4) 2/r32/edx
1249 (check-ints-equal %edx 1 "F - test-var-with-type/type")
1250
1251 89/<- %esp 5/r32/ebp
1252 5d/pop-to-ebp
1253 c3/return
1254
1255 test-parse-var-with-type-and-register:
1256
1257 55/push-ebp
1258 89/<- %ebp 4/r32/esp
1259
1260 b8/copy-to-eax "x/eax"/imm32
1261 8b/-> *eax 1/r32/ecx
1262 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1263 05/add-to-eax 4/imm32
1264
1265 51/push-ecx
1266 50/push-eax
1267 89/<- %ecx 4/r32/esp
1268
1269 (clear-stream _test-input-stream)
1270 (write _test-input-stream ": int")
1271
1272 (parse-var-with-type %ecx _test-input-stream)
1273 8b/-> *eax 2/r32/edx
1274 (check-strings-equal %edx "x" "F - test-var-with-type-and-register/name")
1275 8b/-> *(eax+0x10) 2/r32/edx
1276 (check-strings-equal %edx "eax" "F - test-var-with-type-and-register/register")
1277 8b/-> *(eax+4) 2/r32/edx
1278 (check-ints-equal %edx 1 "F - test-var-with-type-and-register/type")
1279
1280 89/<- %esp 5/r32/ebp
1281 5d/pop-to-ebp
1282 c3/return
1283
1284 test-parse-var-with-trailing-characters:
1285
1286 55/push-ebp
1287 89/<- %ebp 4/r32/esp
1288
1289 b8/copy-to-eax "x/eax:"/imm32
1290 8b/-> *eax 1/r32/ecx
1291 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1292 05/add-to-eax 4/imm32
1293
1294 51/push-ecx
1295 50/push-eax
1296 89/<- %ecx 4/r32/esp
1297
1298 (clear-stream _test-input-stream)
1299 (write _test-input-stream "int,")
1300
1301 (parse-var-with-type %ecx _test-input-stream)
1302 8b/-> *eax 2/r32/edx
1303 (check-strings-equal %edx "x" "F - test-var-with-trailing-characters/name")
1304 8b/-> *(eax+0x10) 2/r32/edx
1305 (check-strings-equal %edx "eax" "F - test-var-with-trailing-characters/register")
1306 8b/-> *(eax+4) 2/r32/edx
1307 (check-ints-equal %edx 1 "F - test-var-with-trailing-characters/type")
1308
1309 89/<- %esp 5/r32/ebp
1310 5d/pop-to-ebp
1311 c3/return
1312
1313
1314
1315
1316 is-identifier?:
1317
1318 55/push-ebp
1319 89/<- %ebp 4/r32/esp
1320
1321 (slice-empty? *(ebp+8))
1322 3d/compare-eax-and 0/imm32
1323 75/jump-if-not-equal $is-identifier?:false/disp8
1324
1325 8b/-> *(ebp+8) 0/r32/eax
1326 8b/-> *eax 0/r32/eax
1327 8a/copy-byte *eax 0/r32/AL
1328 81 4/subop/and %eax 0xff/imm32
1329
1330 3d/compare-eax-and 0x24/imm32/$
1331 74/jump-if-equal $is-identifier?:true/disp8
1332
1333 3d/compare-eax-and 0x5f/imm32/_
1334 74/jump-if-equal $is-identifier?:true/disp8
1335
1336 25/and-eax-with 0x5f/imm32
1337
1338 3d/compare-eax-and 0x41/imm32/A
1339 7c/jump-if-lesser $is-identifier?:false/disp8
1340
1341 3d/compare-eax-and 0x5a/imm32/Z
1342 7f/jump-if-greater $is-identifier?:false/disp8
1343
1344 $is-identifier?:true:
1345 b8/copy-to-eax 1/imm32/true
1346 eb/jump $is-identifier?:end/disp8
1347 $is-identifier?:false:
1348 b8/copy-to-eax 0/imm32/false
1349 $is-identifier?:end:
1350
1351 89/<- %esp 5/r32/ebp
1352 5d/pop-to-ebp
1353 c3/return
1354
1355 test-is-identifier-dollar:
1356
1357 55/push-ebp
1358 89/<- %ebp 4/r32/esp
1359
1360 b8/copy-to-eax "$a"/imm32
1361 8b/-> *eax 1/r32/ecx
1362 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1363 05/add-to-eax 4/imm32
1364
1365 51/push-ecx
1366 50/push-eax
1367 89/<- %ecx 4/r32/esp
1368
1369 (is-identifier? %ecx)
1370 (check-ints-equal %eax 1 "F - test-is-identifier-dollar")
1371
1372 89/<- %esp 5/r32/ebp
1373 5d/pop-to-ebp
1374 c3/return
1375
1376 test-is-identifier-underscore:
1377
1378 55/push-ebp
1379 89/<- %ebp 4/r32/esp
1380
1381 b8/copy-to-eax "_a"/imm32
1382 8b/-> *eax 1/r32/ecx
1383 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1384 05/add-to-eax 4/imm32
1385
1386 51/push-ecx
1387 50/push-eax
1388 89/<- %ecx 4/r32/esp
1389
1390 (is-identifier? %ecx)
1391 (check-ints-equal %eax 1 "F - test-is-identifier-underscore")
1392
1393 89/<- %esp 5/r32/ebp
1394 5d/pop-to-ebp
1395 c3/return
1396
1397 test-is-identifier-a:
1398
1399 55/push-ebp
1400 89/<- %ebp 4/r32/esp
1401
1402 b8/copy-to-eax "a$"/imm32
1403 8b/-> *eax 1/r32/ecx
1404 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1405 05/add-to-eax 4/imm32
1406
1407 51/push-ecx
1408 50/push-eax
1409 89/<- %ecx 4/r32/esp
1410
1411 (is-identifier? %ecx)
1412 (check-ints-equal %eax 1 "F - test-is-identifier-a")
1413
1414 89/<- %esp 5/r32/ebp
1415 5d/pop-to-ebp
1416 c3/return
1417
1418 test-is-identifier-z:
1419
1420 55/push-ebp
1421 89/<- %ebp 4/r32/esp
1422
1423 b8/copy-to-eax "z$"/imm32
1424 8b/-> *eax 1/r32/ecx
1425 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1426 05/add-to-eax 4/imm32
1427
1428 51/push-ecx
1429 50/push-eax
1430 89/<- %ecx 4/r32/esp
1431
1432 (is-identifier? %ecx)
1433 (check-ints-equal %eax 1 "F - test-is-identifier-z")
1434
1435 89/<- %esp 5/r32/ebp
1436 5d/pop-to-ebp
1437 c3/return
1438
1439 test-is-identifier-A:
1440
1441 55/push-ebp
1442 89/<- %ebp 4/r32/esp
1443
1444 b8/copy-to-eax "A$"/imm32
1445 8b/-> *eax 1/r32/ecx
1446 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1447 05/add-to-eax 4/imm32
1448
1449 51/push-ecx
1450 50/push-eax
1451 89/<- %ecx 4/r32/esp
1452
1453 (is-identifier? %ecx)
1454 (check-ints-equal %eax 1 "F - test-is-identifier-A")
1455
1456 89/<- %esp 5/r32/ebp
1457 5d/pop-to-ebp
1458 c3/return
1459
1460 test-is-identifier-Z:
1461
1462 55/push-ebp
1463 89/<- %ebp 4/r32/esp
1464
1465 b8/copy-to-eax "Z$"/imm32
1466 8b/-> *eax 1/r32/ecx
1467 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1468 05/add-to-eax 4/imm32
1469
1470 51/push-ecx
1471 50/push-eax
1472 89/<- %ecx 4/r32/esp
1473
1474 (is-identifier? %ecx)
1475 (check-ints-equal %eax 1 "F - test-is-identifier-Z")
1476
1477 89/<- %esp 5/r32/ebp
1478 5d/pop-to-ebp
1479 c3/return
1480
1481 test-is-identifier-@:
1482
1483
1484 55/push-ebp
1485 89/<- %ebp 4/r32/esp
1486
1487 b8/copy-to-eax "@a"/imm32
1488 8b/-> *eax 1/r32/ecx
1489 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1490 05/add-to-eax 4/imm32
1491
1492 51/push-ecx
1493 50/push-eax
1494 89/<- %ecx 4/r32/esp
1495
1496 (is-identifier? %ecx)
1497 (check-ints-equal %eax 0 "F - test-is-identifier-@")
1498
1499 89/<- %esp 5/r32/ebp
1500 5d/pop-to-ebp
1501 c3/return
1502
1503 test-is-identifier-square-bracket:
1504
1505
1506 55/push-ebp
1507 89/<- %ebp 4/r32/esp
1508
1509 b8/copy-to-eax "[a"/imm32
1510 8b/-> *eax 1/r32/ecx
1511 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1512 05/add-to-eax 4/imm32
1513
1514 51/push-ecx
1515 50/push-eax
1516 89/<- %ecx 4/r32/esp
1517
1518 (is-identifier? %ecx)
1519 (check-ints-equal %eax 0 "F - test-is-identifier-@")
1520
1521 89/<- %esp 5/r32/ebp
1522 5d/pop-to-ebp
1523 c3/return
1524
1525 test-is-identifier-backtick:
1526
1527
1528 55/push-ebp
1529 89/<- %ebp 4/r32/esp
1530
1531 b8/copy-to-eax "`a"/imm32
1532 8b/-> *eax 1/r32/ecx
1533 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1534 05/add-to-eax 4/imm32
1535
1536 51/push-ecx
1537 50/push-eax
1538 89/<- %ecx 4/r32/esp
1539
1540 (is-identifier? %ecx)
1541 (check-ints-equal %eax 0 "F - test-is-identifier-backtick")
1542
1543 89/<- %esp 5/r32/ebp
1544 5d/pop-to-ebp
1545 c3/return
1546
1547 test-is-identifier-curly-brace-open:
1548
1549
1550 55/push-ebp
1551 89/<- %ebp 4/r32/esp
1552
1553 b8/copy-to-eax "{a"/imm32
1554 8b/-> *eax 1/r32/ecx
1555 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1556 05/add-to-eax 4/imm32
1557
1558 51/push-ecx
1559 50/push-eax
1560 89/<- %ecx 4/r32/esp
1561
1562 (is-identifier? %ecx)
1563 (check-ints-equal %eax 0 "F - test-is-identifier-curly-brace-open")
1564
1565 89/<- %esp 5/r32/ebp
1566 5d/pop-to-ebp
1567 c3/return
1568
1569 test-is-identifier-curly-brace-close:
1570
1571 55/push-ebp
1572 89/<- %ebp 4/r32/esp
1573
1574 b8/copy-to-eax "}a"/imm32
1575 8b/-> *eax 1/r32/ecx
1576 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1577 05/add-to-eax 4/imm32
1578
1579 51/push-ecx
1580 50/push-eax
1581 89/<- %ecx 4/r32/esp
1582
1583 (is-identifier? %ecx)
1584 (check-ints-equal %eax 0 "F - test-is-identifier-curly-brace-close")
1585
1586 89/<- %esp 5/r32/ebp
1587 5d/pop-to-ebp
1588 c3/return
1589
1590 test-is-identifier-hyphen:
1591
1592
1593 55/push-ebp
1594 89/<- %ebp 4/r32/esp
1595
1596 b8/copy-to-eax "-a"/imm32
1597 8b/-> *eax 1/r32/ecx
1598 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1599 05/add-to-eax 4/imm32
1600
1601 51/push-ecx
1602 50/push-eax
1603 89/<- %ecx 4/r32/esp
1604
1605 (is-identifier? %ecx)
1606 (check-ints-equal %eax 0 "F - test-is-identifier-hyphen")
1607
1608 89/<- %esp 5/r32/ebp
1609 5d/pop-to-ebp
1610 c3/return
1611
1612 populate-mu-function-body:
1613
1614 55/push-ebp
1615 89/<- %ebp 4/r32/esp
1616
1617 50/push-eax
1618 56/push-esi
1619 57/push-edi
1620
1621 8b/-> *(ebp+8) 6/r32/esi
1622
1623 8b/-> *(ebp+0xc) 7/r32/edi
1624
1625 (parse-mu-block %esi)
1626
1627 89/<- *(edi+0x10) 0/r32/eax
1628 $populate-mu-function-body:end:
1629
1630 5f/pop-to-edi
1631 5e/pop-to-esi
1632 58/pop-to-eax
1633
1634 89/<- %esp 5/r32/ebp
1635 5d/pop-to-ebp
1636 c3/return
1637
1638
1639 parse-mu-block:
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672 55/push-ebp
1673 89/<- %ebp 4/r32/esp
1674
1675 51/push-ecx
1676 52/push-edx
1677 53/push-ebx
1678 56/push-esi
1679 57/push-edi
1680
1681 81 5/subop/subtract %esp 0x200/imm32
1682 68/push 0x200/imm32/length
1683 68/push 0/imm32/read
1684 68/push 0/imm32/write
1685 89/<- %ecx 4/r32/esp
1686
1687 68/push 0/imm32/end
1688 68/push 0/imm32/start
1689 89/<- %edx 4/r32/esp
1690
1691 (allocate Heap *Stmt-size)
1692 89/<- %edi 0/r32/eax
1693 {
1694 $parse-mu-block:line-loop:
1695
1696 (clear-stream %ecx)
1697 (read-line-buffered *(ebp+8) %ecx)
1698
1699
1700
1701
1702
1703 81 7/subop/compare *ecx 0/imm32
1704 0f 84/jump-if-equal break/disp32
1705
1706 (next-word %ecx %edx)
1707
1708
1709
1710
1711
1712 (slice-empty? %edx)
1713 3d/compare-eax-and 0/imm32
1714 0f 85/jump-if-not-equal loop/disp32
1715
1716
1717 8b/-> *edx 0/r32/eax
1718 8a/copy-byte *eax 0/r32/AL
1719 81 4/subop/and %eax 0xff/imm32
1720
1721 3d/compare-eax-and 0x23/imm32/hash
1722 0f 84/jump-if-equal loop/disp32
1723
1724 {
1725 $parse-mu-block:check-for-block:
1726 (slice-equal? %edx "{")
1727 3d/compare-eax-and 0/imm32
1728 74/jump-if-equal break/disp8
1729 (check-no-tokens-left %ecx)
1730
1731 (parse-mu-block *(ebp+8))
1732 (append-to-block %edi %eax)
1733 e9/jump $parse-mu-block:line-loop/disp32
1734 }
1735
1736 $parse-mu-block:check-for-end:
1737 (slice-equal? %edx "}")
1738 3d/compare-eax-and 0/imm32
1739 0f 85/jump-if-not-equal break/disp32
1740
1741 {
1742 $parse-mu-block:check-for-named-block:
1743
1744 8b/-> *(edx+4) 0/r32/eax
1745 8a/copy-byte *eax 0/r32/AL
1746 81 4/subop/and %eax 0xff/imm32
1747
1748 3d/compare-eax-and 0x23/imm32/hash
1749 0f 85/jump-if-not-equal break/disp32
1750
1751 (parse-mu-named-block %edx %ecx *(ebp+8))
1752 (append-to-block %edi %eax)
1753 e9/jump $parse-mu-block:line-loop/disp32
1754 }
1755
1756 {
1757 $parse-mu-block:check-for-var:
1758 (slice-equal? %edx "var")
1759 3d/compare-eax-and 0/imm32
1760 74/jump-if-equal break/disp8
1761
1762 (parse-mu-var-def %ecx)
1763 (append-to-block %edi %eax)
1764 e9/jump $parse-mu-block:line-loop/disp32
1765 }
1766 $parse-mu-block:regular-stmt:
1767
1768 (parse-mu-stmt %ecx)
1769 (append-to-block Heap %edi %eax)
1770 e9/jump loop/disp32
1771 }
1772
1773 89/<- %eax 7/r32/edi
1774 $parse-mu-block:end:
1775
1776 81 0/subop/add %esp 0x214/imm32
1777
1778 5f/pop-to-edi
1779 5e/pop-to-esi
1780 5b/pop-to-ebx
1781 5a/pop-to-edx
1782 59/pop-to-ecx
1783
1784 89/<- %esp 5/r32/ebp
1785 5d/pop-to-ebp
1786 c3/return
1787
1788 $parse-mu-block:abort:
1789
1790 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
1791 (rewind-stream %ecx)
1792 (write-stream 2 %ecx)
1793 (write-buffered Stderr "'\n")
1794 (flush Stderr)
1795
1796 bb/copy-to-ebx 1/imm32
1797 b8/copy-to-eax 1/imm32/exit
1798 cd/syscall 0x80/imm8
1799
1800
1801 check-no-tokens-left:
1802
1803 55/push-ebp
1804 89/<- %ebp 4/r32/esp
1805
1806 50/push-eax
1807 51/push-ecx
1808
1809 68/push 0/imm32/end
1810 68/push 0/imm32/start
1811 89/<- %ecx 4/r32/esp
1812
1813 (next-word *(ebp+8) %ecx)
1814
1815 (slice-empty? %ecx)
1816 3d/compare-eax-and 0/imm32
1817 75/jump-if-not-equal $check-no-tokens-left:end/disp8
1818
1819
1820 8b/-> *edx 0/r32/eax
1821 8a/copy-byte *eax 0/r32/AL
1822 81 4/subop/and %eax 0xff/imm32
1823
1824 3d/compare-eax-and 0x23/imm32/hash
1825 74/jump-if-equal $check-no-tokens-left:end/disp8
1826
1827 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
1828 (rewind-stream %ecx)
1829 (write-stream 2 %ecx)
1830 (write-buffered Stderr "'\n")
1831 (flush Stderr)
1832
1833 bb/copy-to-ebx 1/imm32
1834 b8/copy-to-eax 1/imm32/exit
1835 cd/syscall 0x80/imm8
1836
1837 $check-no-tokens-left:end:
1838
1839 81 0/subop/add %esp 8/imm32
1840
1841 59/pop-to-ecx
1842 58/pop-to-eax
1843
1844 89/<- %esp 5/r32/ebp
1845 5d/pop-to-ebp
1846 c3/return
1847
1848 parse-mu-named-block:
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881 55/push-ebp
1882 89/<- %ebp 4/r32/esp
1883
1884 $parse-mu-named-block:end:
1885
1886
1887
1888 89/<- %esp 5/r32/ebp
1889 5d/pop-to-ebp
1890 c3/return
1891
1892 parse-mu-var-def:
1893
1894
1895
1896 55/push-ebp
1897 89/<- %ebp 4/r32/esp
1898
1899 $parse-mu-var-def:end:
1900
1901
1902
1903 89/<- %esp 5/r32/ebp
1904 5d/pop-to-ebp
1905 c3/return
1906
1907 parse-mu-stmt:
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926 55/push-ebp
1927 89/<- %ebp 4/r32/esp
1928
1929 51/push-ecx
1930 57/push-edi
1931
1932 68/push 0/imm32/end
1933 68/push 0/imm32/start
1934 89/<- %ecx 4/r32/esp
1935
1936 (allocate Heap *Stmt-size)
1937 89/<- %edi 0/r32/eax
1938
1939 c7 0/subop/copy *edi 1/imm32/stmt1
1940 {
1941 (stmt-has-outputs? *(ebp+8))
1942 3d/compare-eax-and 0/imm32
1943 0f 84/jump-if-equal break/disp32
1944 {
1945 $parse-mu-stmt:read-outputs:
1946
1947 (next-word *(ebp+8) %ecx)
1948
1949 (slice-empty? %ecx)
1950 3d/compare-eax-and 0/imm32
1951 0f 85/jump-if-not-equal break/disp32
1952
1953 (slice-equal? %ecx "<-")
1954 3d/compare-eax-and 0/imm32
1955 75/jump-if-not-equal break/disp8
1956
1957 (is-identifier? %ecx)
1958 3d/compare-eax-and 0/imm32
1959 0f 84/jump-if-equal $parse-mu-stmt:abort/disp32
1960
1961 (parse-var Heap %ecx)
1962 (append-list Heap %eax *(edi+0xc))
1963 89/<- *(edi+0xc) 0/r32/eax
1964 e9/jump loop/disp32
1965 }
1966 }
1967 $parse-mu-stmt:read-operation:
1968 (next-word *(ebp+8) %ecx)
1969 (slice-to-string Heap %ecx)
1970 89/<- *(edi+4) 0/r32/eax
1971 {
1972 $parse-mu-stmt:read-inouts:
1973
1974 (next-word-or-string *(ebp+8) %ecx)
1975
1976 (slice-empty? %ecx)
1977 3d/compare-eax-and 0/imm32
1978 0f 85/jump-if-not-equal break/disp32
1979
1980 (slice-equal? %ecx "<-")
1981 3d/compare-eax-and 0/imm32
1982 0f 85/jump-if-not-equal $parse-mu-stmt:abort2/disp32
1983
1984 (parse-var Heap %ecx)
1985 (append-list Heap %eax *(edi+8))
1986 89/<- *(edi+8) 0/r32/eax
1987 e9/jump loop/disp32
1988 }
1989 $parse-mu-stmt:end:
1990
1991 89/<- %eax 7/r32/edi
1992
1993 81 0/subop/add %esp 8/imm32
1994
1995 5f/pop-to-edi
1996 59/pop-to-ecx
1997
1998 89/<- %esp 5/r32/ebp
1999 5d/pop-to-ebp
2000 c3/return
2001
2002 $parse-mu-stmt:abort:
2003
2004 (write-buffered Stderr "invalid identifier '")
2005 (write-slice-buffered Stderr %ecx)
2006 (write-buffered Stderr "'\n")
2007 (flush Stderr)
2008
2009 bb/copy-to-ebx 1/imm32
2010 b8/copy-to-eax 1/imm32/exit
2011 cd/syscall 0x80/imm8
2012
2013
2014 $parse-mu-stmt:abort2:
2015
2016 (rewind-stream *(ebp+8))
2017 (write-buffered Stderr "invalid identifier '")
2018 (write-stream Stderr *(ebp+8))
2019 (write-buffered Stderr "'\n")
2020 (flush Stderr)
2021
2022 bb/copy-to-ebx 1/imm32
2023 b8/copy-to-eax 1/imm32/exit
2024 cd/syscall 0x80/imm8
2025
2026
2027 stmt-has-outputs?:
2028
2029 55/push-ebp
2030 89/<- %ebp 4/r32/esp
2031
2032 51/push-ecx
2033
2034 68/push 0/imm32/end
2035 68/push 0/imm32/start
2036 89/<- %ecx 4/r32/esp
2037
2038 b8/copy-to-eax 0/imm32/false
2039 (rewind-stream *(ebp+8))
2040 {
2041 (next-word-or-string *(ebp+8) %ecx)
2042
2043 (slice-empty? %ecx)
2044 3d/compare-eax-and 0/imm32
2045 b8/copy-to-eax 0/imm32/false/result
2046 0f 85/jump-if-not-equal break/disp32
2047
2048
2049 8b/-> *ecx 0/r32/eax
2050 8a/copy-byte *eax 0/r32/AL
2051 81 4/subop/and %eax 0xff/imm32
2052
2053 3d/compare-eax-and 0x23/imm32/hash
2054 b8/copy-to-eax 0/imm32/false/result
2055 0f 84/jump-if-equal break/disp32
2056
2057 (slice-equal? %ecx "<-")
2058 3d/compare-eax-and 0/imm32
2059 74/jump-if-equal loop/disp8
2060 b8/copy-to-eax 1/imm32/true
2061 }
2062 $stmt-has-outputs:end:
2063 (rewind-stream *(ebp+8))
2064
2065 81 0/subop/add %esp 8/imm32
2066
2067 59/pop-to-ecx
2068
2069 89/<- %esp 5/r32/ebp
2070 5d/pop-to-ebp
2071 c3/return
2072
2073 parse-var:
2074
2075 55/push-ebp
2076 89/<- %ebp 4/r32/esp
2077
2078 51/push-ecx
2079
2080 8b/-> *(ebp+0xc) 1/r32/ecx
2081 (slice-to-string Heap %ecx)
2082 89/<- %ecx 0/r32/eax
2083 (allocate *(ebp+8) *Var-size)
2084 89/<- *eax 1/r32/ecx
2085
2086 c7 0/subop/copy *(eax+4) 1/imm32/int-type
2087
2088 c7 0/subop/copy *(eax+0xc) 8/imm32
2089 $parse-var:end:
2090
2091 59/pop-to-ecx
2092
2093 89/<- %esp 5/r32/ebp
2094 5d/pop-to-ebp
2095 c3/return
2096
2097 test-parse-mu-stmt:
2098
2099
2100 55/push-ebp
2101 89/<- %ebp 4/r32/esp
2102
2103 (clear-stream _test-input-stream)
2104 (write _test-input-stream "increment n\n")
2105
2106 (parse-mu-stmt _test-input-stream)
2107
2108 (check-strings-equal *(eax+4) "increment" "F - test-parse-mu-stmt/name")
2109
2110 8b/-> *(eax+8) 2/r32/edx
2111
2112 8b/-> *edx 3/r32/ebx
2113 (check-strings-equal *ebx "n" "F - test-parse-mu-stmt/inout:0")
2114
2115 89/<- %esp 5/r32/ebp
2116 5d/pop-to-ebp
2117 c3/return
2118
2119 new-function:
2120
2121 55/push-ebp
2122 89/<- %ebp 4/r32/esp
2123
2124 51/push-ecx
2125
2126 (allocate *(ebp+8) *Function-size)
2127 8b/-> *(ebp+0xc) 1/r32/ecx
2128 89/<- *eax 1/r32/ecx
2129 8b/-> *(ebp+0x10) 1/r32/ecx
2130 89/<- *(eax+4) 1/r32/ecx
2131 8b/-> *(ebp+0x14) 1/r32/ecx
2132 89/<- *(eax+8) 1/r32/ecx
2133 8b/-> *(ebp+0x18) 1/r32/ecx
2134 89/<- *(eax+0xc) 1/r32/ecx
2135 8b/-> *(ebp+0x1c) 1/r32/ecx
2136 89/<- *(eax+0x10) 1/r32/ecx
2137 8b/-> *(ebp+0x20) 1/r32/ecx
2138 89/<- *(eax+0x14) 1/r32/ecx
2139 $new-function:end:
2140
2141 59/pop-to-ecx
2142
2143 89/<- %esp 5/r32/ebp
2144 5d/pop-to-ebp
2145 c3/return
2146
2147 new-var:
2148
2149 55/push-ebp
2150 89/<- %ebp 4/r32/esp
2151
2152 51/push-ecx
2153
2154 (allocate *(ebp+8) *Var-size)
2155 8b/-> *(ebp+0xc) 1/r32/ecx
2156 89/<- *eax 1/r32/ecx
2157 8b/-> *(ebp+0x10) 1/r32/ecx
2158 89/<- *(eax+4) 1/r32/ecx
2159 8b/-> *(ebp+0x14) 1/r32/ecx
2160 89/<- *(eax+8) 1/r32/ecx
2161 8b/-> *(ebp+0x18) 1/r32/ecx
2162 89/<- *(eax+0xc) 1/r32/ecx
2163 8b/-> *(ebp+0x1c) 1/r32/ecx
2164 89/<- *(eax+0x10) 1/r32/ecx
2165 $new-var:end:
2166
2167 59/pop-to-ecx
2168
2169 89/<- %esp 5/r32/ebp
2170 5d/pop-to-ebp
2171 c3/return
2172
2173 new-block:
2174
2175 55/push-ebp
2176 89/<- %ebp 4/r32/esp
2177
2178 51/push-ecx
2179
2180 (allocate *(ebp+8) *Stmt-size)
2181 c7 0/subop/copy *eax 0/imm32/tag/block
2182 8b/-> *(ebp+0xc) 1/r32/ecx
2183 89/<- *(eax+4) 1/r32/ecx
2184 $new-block:end:
2185
2186 59/pop-to-ecx
2187
2188 89/<- %esp 5/r32/ebp
2189 5d/pop-to-ebp
2190 c3/return
2191
2192 new-stmt:
2193
2194 55/push-ebp
2195 89/<- %ebp 4/r32/esp
2196
2197 51/push-ecx
2198
2199 (allocate *(ebp+8) *Stmt-size)
2200 c7 0/subop/copy *eax 1/imm32/tag/regular-stmt
2201 8b/-> *(ebp+0xc) 1/r32/ecx
2202 89/<- *(eax+4) 1/r32/ecx
2203 8b/-> *(ebp+0x10) 1/r32/ecx
2204 89/<- *(eax+8) 1/r32/ecx
2205 8b/-> *(ebp+0x14) 1/r32/ecx
2206 89/<- *(eax+0xc) 1/r32/ecx
2207 $new-stmt:end:
2208
2209 59/pop-to-ecx
2210
2211 89/<- %esp 5/r32/ebp
2212 5d/pop-to-ebp
2213 c3/return
2214
2215 new-vardef:
2216
2217 55/push-ebp
2218 89/<- %ebp 4/r32/esp
2219
2220 51/push-ecx
2221
2222 (allocate *(ebp+8) *Stmt-size)
2223 c7 0/subop/copy *eax 2/imm32/tag/var-on-stack
2224 8b/-> *(ebp+0xc) 1/r32/ecx
2225 89/<- *(eax+4) 1/r32/ecx
2226 8b/-> *(ebp+0x10) 1/r32/ecx
2227 89/<- *(eax+8) 1/r32/ecx
2228 $new-vardef:end:
2229
2230 59/pop-to-ecx
2231
2232 89/<- %esp 5/r32/ebp
2233 5d/pop-to-ebp
2234 c3/return
2235
2236 new-regvardef:
2237
2238 55/push-ebp
2239 89/<- %ebp 4/r32/esp
2240
2241 51/push-ecx
2242
2243 (allocate *(ebp+8) *Stmt-size)
2244 c7 0/subop/copy *eax 3/imm32/tag/var-in-register
2245 8b/-> *(ebp+0xc) 1/r32/ecx
2246 89/<- *(eax+4) 1/r32/ecx
2247 8b/-> *(ebp+0x10) 1/r32/ecx
2248 89/<- *(eax+8) 1/r32/ecx
2249 8b/-> *(ebp+0x14) 1/r32/ecx
2250 89/<- *(eax+0xc) 1/r32/ecx
2251 $new-regvardef:end:
2252
2253 59/pop-to-ecx
2254
2255 89/<- %esp 5/r32/ebp
2256 5d/pop-to-ebp
2257 c3/return
2258
2259 new-named-block:
2260
2261 55/push-ebp
2262 89/<- %ebp 4/r32/esp
2263
2264 51/push-ecx
2265
2266 (allocate *(ebp+8) *Stmt-size)
2267 c7 0/subop/copy *eax 4/imm32/tag/named-block
2268 8b/-> *(ebp+0xc) 1/r32/ecx
2269 89/<- *(eax+4) 1/r32/ecx
2270 8b/-> *(ebp+0x10) 1/r32/ecx
2271 89/<- *(eax+8) 1/r32/ecx
2272 $new-named-block:end:
2273
2274 59/pop-to-ecx
2275
2276 89/<- %esp 5/r32/ebp
2277 5d/pop-to-ebp
2278 c3/return
2279
2280 new-list:
2281
2282 55/push-ebp
2283 89/<- %ebp 4/r32/esp
2284
2285 51/push-ecx
2286
2287 (allocate *(ebp+8) *List-size)
2288 8b/-> *(ebp+0xc) 1/r32/ecx
2289 89/<- *eax 1/r32/ecx
2290 8b/-> *(ebp+0x10) 1/r32/ecx
2291 89/<- *(eax+4) 1/r32/ecx
2292 $new-list:end:
2293
2294 59/pop-to-ecx
2295
2296 89/<- %esp 5/r32/ebp
2297 5d/pop-to-ebp
2298 c3/return
2299
2300 append-list:
2301
2302 55/push-ebp
2303 89/<- %ebp 4/r32/esp
2304
2305 51/push-ecx
2306
2307 (allocate *(ebp+8) *List-size)
2308 8b/-> *(ebp+0xc) 1/r32/ecx
2309 89/<- *eax 1/r32/ecx
2310
2311 81 7/subop/compare *(ebp+0x10) 0/imm32
2312 74/jump-if-equal $new-list:end/disp8
2313
2314
2315 8b/-> *(ebp+0x10) 1/r32/ecx
2316
2317 {
2318 81 7/subop/compare *(ecx+4) 0/imm32
2319 74/jump-if-equal break/disp8
2320
2321 8b/-> *(ecx+4) 1/r32/ecx
2322 eb/jump loop/disp8
2323 }
2324
2325 89/<- *(ecx+4) 0/r32/eax
2326
2327 8b/-> *(ebp+0x10) 0/r32/eax
2328 $append-list:end:
2329
2330 59/pop-to-ecx
2331
2332 89/<- %esp 5/r32/ebp
2333 5d/pop-to-ebp
2334 c3/return
2335
2336 append-to-block:
2337
2338 55/push-ebp
2339 89/<- %ebp 4/r32/esp
2340
2341 56/push-esi
2342
2343 8b/-> *(ebp+0xc) 6/r32/esi
2344 (append-list *(ebp+8) *(ebp+0x10) *(esi+4))
2345 89/<- *(esi+4) 0/r32/eax
2346 $append-to-block:end:
2347
2348 5e/pop-to-esi
2349
2350 89/<- %esp 5/r32/ebp
2351 5d/pop-to-ebp
2352 c3/return
2353
2354
2355
2356
2357
2358 check-mu-types:
2359
2360 55/push-ebp
2361 89/<- %ebp 4/r32/esp
2362
2363 $check-mu-types:end:
2364
2365 89/<- %esp 5/r32/ebp
2366 5d/pop-to-ebp
2367 c3/return
2368
2369
2370
2371
2372
2373 emit-subx:
2374
2375 55/push-ebp
2376 89/<- %ebp 4/r32/esp
2377
2378 50/push-eax
2379 51/push-ecx
2380 57/push-edi
2381
2382 8b/-> *(ebp+8) 7/r32/edi
2383
2384 8b/-> *Program 1/r32/ecx
2385 {
2386
2387 81 7/subop/compare %ecx 0/imm32
2388 0f 84/jump-if-equal break/disp32
2389 (emit-subx-function %edi %ecx)
2390
2391 8b/-> *(ecx+0x14) 1/r32/ecx
2392 e9/jump loop/disp32
2393 }
2394 $emit-subx:end:
2395
2396 5f/pop-to-edi
2397 59/pop-to-ecx
2398 58/pop-to-eax
2399
2400 89/<- %esp 5/r32/ebp
2401 5d/pop-to-ebp
2402 c3/return
2403
2404 emit-subx-function:
2405
2406 55/push-ebp
2407 89/<- %ebp 4/r32/esp
2408
2409 50/push-eax
2410 51/push-ecx
2411 57/push-edi
2412
2413 8b/-> *(ebp+8) 7/r32/edi
2414
2415 8b/-> *(ebp+0xc) 1/r32/ecx
2416
2417 (write-buffered %edi *ecx)
2418 (write-buffered %edi ":\n")
2419 (emit-subx-prologue %edi)
2420 (emit-subx-block %edi *(ecx+0x10))
2421 (emit-subx-epilogue %edi)
2422 $emit-subx-function:end:
2423
2424 5f/pop-to-edi
2425 59/pop-to-ecx
2426 58/pop-to-eax
2427
2428 89/<- %esp 5/r32/ebp
2429 5d/pop-to-ebp
2430 c3/return
2431
2432 emit-subx-block:
2433
2434 55/push-ebp
2435 89/<- %ebp 4/r32/esp
2436
2437 8b/-> *(ebp+0xc) 6/r32/esi
2438 8b/-> *(esi+4) 6/r32/esi
2439
2440 {
2441 $emit-subx-block:stmt:
2442 81 7/subop/compare %esi 0/imm32
2443 0f 84/jump-if-equal break/disp32
2444 (write-buffered *(ebp+8) "{\n")
2445 {
2446 81 7/subop/compare %esi 0/imm32
2447 74/jump-if-equal break/disp8
2448 (emit-subx-statement *(ebp+8) *esi 0 Primitives 0)
2449 (write-buffered *(ebp+8) Newline)
2450 8b/-> *(esi+4) 6/r32/esi
2451 eb/jump loop/disp8
2452 }
2453 (write-buffered *(ebp+8) "}\n")
2454 }
2455 $emit-subx-block:end:
2456
2457 89/<- %esp 5/r32/ebp
2458 5d/pop-to-ebp
2459 c3/return
2460
2461 emit-subx-statement:
2462
2463 55/push-ebp
2464 89/<- %ebp 4/r32/esp
2465
2466 50/push-eax
2467 51/push-ecx
2468
2469 {
2470 $emit-subx-statement:primitive:
2471 (find-matching-primitive *(ebp+0x14) *(ebp+0xc))
2472 3d/compare-eax-and 0/imm32
2473 74/jump-if-equal break/disp8
2474 (emit-subx-primitive *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax)
2475 e9/jump $emit-subx-statement:end/disp32
2476 }
2477
2478 {
2479 $emit-subx-statement:call:
2480 (find-matching-function *(ebp+0x18) *(ebp+0xc))
2481 3d/compare-eax-and 0/imm32
2482 74/jump-if-equal break/disp8
2483 (emit-subx-call *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax)
2484 e9/jump $emit-subx-statement:end/disp32
2485 }
2486
2487 e9/jump $emit-subx-statement:abort/disp32
2488 $emit-subx-statement:end:
2489
2490 59/pop-to-ecx
2491 58/pop-to-eax
2492
2493 89/<- %esp 5/r32/ebp
2494 5d/pop-to-ebp
2495 c3/return
2496
2497 $emit-subx-statement:abort:
2498
2499 (write-buffered Stderr "couldn't translate '")
2500
2501 (write-buffered Stderr "'\n")
2502 (flush Stderr)
2503
2504 bb/copy-to-ebx 1/imm32
2505 b8/copy-to-eax 1/imm32/exit
2506 cd/syscall 0x80/imm8
2507
2508
2509
2510 == data
2511 Primitives:
2512
2513 "increment"/imm32/name
2514 Single-int-var-on-stack/imm32/inouts
2515 0/imm32/no-outputs
2516 "ff 0/subop/increment"/imm32/subx-name
2517 1/imm32/rm32-is-first-inout
2518 0/imm32/no-r32
2519 0/imm32/no-imm32
2520 _Primitive-inc-reg/imm32/next
2521 _Primitive-inc-reg:
2522
2523 "increment"/imm32/name
2524 0/imm32/no-inouts
2525 Single-int-var-in-some-register/imm32/outputs
2526 "ff 0/subop/increment"/imm32/subx-name
2527 3/imm32/rm32-is-first-output
2528 0/imm32/no-r32
2529 0/imm32/no-imm32
2530 _Primitive-add-reg-to-reg/imm32/next
2531 _Primitive-add-reg-to-reg:
2532
2533 "add"/imm32/name
2534 Single-int-var-in-some-register/imm32/inouts
2535 Single-int-var-in-some-register/imm32/outputs
2536 "01"/imm32/subx-name
2537 3/imm32/rm32-is-first-output
2538 1/imm32/r32-is-first-inout
2539 0/imm32/no-imm32
2540 _Primitive-add-reg-to-mem/imm32/next
2541 _Primitive-add-reg-to-mem:
2542
2543 "add-to"/imm32/name
2544 Int-var-and-second-int-var-in-some-register/imm32/inouts
2545 0/imm32/outputs
2546 "01"/imm32/subx-name
2547 1/imm32/rm32-is-first-inout
2548 2/imm32/r32-is-second-inout
2549 0/imm32/no-imm32
2550 _Primitive-add-mem-to-reg/imm32/next
2551 _Primitive-add-mem-to-reg:
2552
2553 "add"/imm32/name
2554 Single-int-var-on-stack/imm32/inouts
2555 Single-int-var-in-some-register/imm32/outputs
2556 "03"/imm32/subx-name
2557 1/imm32/rm32-is-first-inout
2558 3/imm32/r32-is-first-output
2559 0/imm32/no-imm32
2560 _Primitive-add-lit-to-reg/imm32/next
2561 _Primitive-add-lit-to-reg:
2562
2563 "add"/imm32/name
2564 Single-lit-var/imm32/inouts
2565 Single-int-var-in-some-register/imm32/outputs
2566 "81 0/subop/add"/imm32/subx-name
2567 3/imm32/rm32-is-first-output
2568 0/imm32/no-r32
2569 1/imm32/imm32-is-first-inout
2570 _Primitive-add-lit-to-mem/imm32/next
2571 _Primitive-add-lit-to-mem:
2572
2573 "add-to"/imm32/name
2574 Int-var-and-literal/imm32/inouts
2575 0/imm32/outputs
2576 "81 0/subop/add"/imm32/subx-name
2577 1/imm32/rm32-is-first-inout
2578 0/imm32/no-r32
2579 2/imm32/imm32-is-first-inout
2580 0/imm32/next
2581
2582 Single-int-var-on-stack:
2583 Int-var-on-stack/imm32
2584 0/imm32/next
2585
2586 Int-var-on-stack:
2587 "arg1"/imm32/name
2588 1/imm32/type-int
2589 1/imm32/some-block-depth
2590 1/imm32/some-stack-offset
2591 0/imm32/no-register
2592
2593 Int-var-and-second-int-var-in-some-register:
2594 Int-var-on-stack/imm32
2595 Single-int-var-in-some-register/imm32/next
2596
2597 Int-var-and-literal:
2598 Int-var-on-stack/imm32
2599 Single-lit-var/imm32/next
2600
2601 Single-int-var-in-some-register:
2602 Int-var-in-some-register/imm32
2603 0/imm32/next
2604
2605 Int-var-in-some-register:
2606 "arg1"/imm32/name
2607 1/imm32/type-int
2608 1/imm32/some-block-depth
2609 0/imm32/no-stack-offset
2610 "*"/imm32/register
2611
2612 Single-lit-var:
2613 Lit-var/imm32
2614 0/imm32/next
2615
2616 Lit-var:
2617 "literal"/imm32/name
2618 0/imm32/type-literal
2619 1/imm32/some-block-depth
2620 0/imm32/no-stack-offset
2621 0/imm32/no-register
2622
2623 == code
2624 emit-subx-primitive:
2625
2626 55/push-ebp
2627 89/<- %ebp 4/r32/esp
2628
2629 50/push-eax
2630 51/push-ecx
2631
2632 8b/-> *(ebp+0x14) 1/r32/ecx
2633
2634 (write-buffered *(ebp+8) *(ecx+0xc))
2635
2636 (emit-subx-rm32 *(ebp+8) *(ecx+0x10) *(ebp+0xc))
2637
2638 (emit-subx-r32 *(ebp+8) *(ecx+0x14) *(ebp+0xc))
2639
2640 (emit-subx-imm32 *(ebp+8) *(ecx+0x18) *(ebp+0xc))
2641 $emit-subx-primitive:end:
2642
2643 59/pop-to-ecx
2644 58/pop-to-eax
2645
2646 89/<- %esp 5/r32/ebp
2647 5d/pop-to-ebp
2648 c3/return
2649
2650 emit-subx-rm32:
2651
2652 55/push-ebp
2653 89/<- %ebp 4/r32/esp
2654
2655 50/push-eax
2656
2657 81 7/subop/compare *(ebp+0xc) 0/imm32
2658 74/jump-if-equal $emit-subx-rm32:end/disp8
2659
2660 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
2661 (emit-subx-var-as-rm32 *(ebp+8) %eax)
2662 $emit-subx-rm32:end:
2663
2664 58/pop-to-eax
2665
2666 89/<- %esp 5/r32/ebp
2667 5d/pop-to-ebp
2668 c3/return
2669
2670 get-stmt-operand-from-arg-location:
2671
2672 55/push-ebp
2673 89/<- %ebp 4/r32/esp
2674
2675 51/push-ecx
2676
2677 8b/-> *(ebp+0xc) 0/r32/eax
2678
2679 8b/-> *(ebp+8) 1/r32/ecx
2680
2681 {
2682 3d/compare-eax-and 1/imm32
2683 75/jump-if-not-equal break/disp8
2684 $get-stmt-operand-from-arg-location:1:
2685 8b/-> *(ecx+8) 0/r32/eax
2686 8b/-> *eax 0/r32/eax
2687 eb/jump $get-stmt-operand-from-arg-location:end/disp8
2688 }
2689
2690 {
2691 3d/compare-eax-and 2/imm32
2692 75/jump-if-not-equal break/disp8
2693 $get-stmt-operand-from-arg-location:2:
2694 8b/-> *(ecx+8) 0/r32/eax
2695 8b/-> *(eax+4) 0/r32/eax
2696 8b/-> *eax 0/r32/eax
2697 eb/jump $get-stmt-operand-from-arg-location:end/disp8
2698 }
2699
2700 {
2701 3d/compare-eax-and 3/imm32
2702 75/jump-if-not-equal break/disp8
2703 $get-stmt-operand-from-arg-location:3:
2704 8b/-> *(ecx+0xc) 0/r32/eax
2705 8b/-> *eax 0/r32/eax
2706 eb/jump $get-stmt-operand-from-arg-location:end/disp8
2707 }
2708
2709 e9/jump $get-stmt-operand-from-arg-location:abort/disp32
2710 $get-stmt-operand-from-arg-location:end:
2711
2712 59/pop-to-ecx
2713
2714 89/<- %esp 5/r32/ebp
2715 5d/pop-to-ebp
2716 c3/return
2717
2718 $get-stmt-operand-from-arg-location:abort:
2719
2720 (write-buffered Stderr "invalid arg-location ")
2721 (print-int32-buffered Stderr %eax)
2722 (write-buffered Stderr "\n")
2723 (flush Stderr)
2724
2725 bb/copy-to-ebx 1/imm32
2726 b8/copy-to-eax 1/imm32/exit
2727 cd/syscall 0x80/imm8
2728
2729
2730 emit-subx-r32:
2731
2732 55/push-ebp
2733 89/<- %ebp 4/r32/esp
2734
2735 50/push-eax
2736 51/push-ecx
2737
2738 81 7/subop/compare *(ebp+0xc) 0/imm32
2739 0f 84/jump-if-equal $emit-subx-r32:end/disp32
2740
2741 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
2742 (maybe-get Registers *(eax+0x10) 8)
2743 (write-buffered *(ebp+8) Space)
2744 (print-int32-buffered *(ebp+8) *eax)
2745 (write-buffered *(ebp+8) "/r32")
2746 $emit-subx-r32:end:
2747
2748 59/pop-to-ecx
2749 58/pop-to-eax
2750
2751 89/<- %esp 5/r32/ebp
2752 5d/pop-to-ebp
2753 c3/return
2754
2755 emit-subx-imm32:
2756
2757 55/push-ebp
2758 89/<- %ebp 4/r32/esp
2759
2760 50/push-eax
2761 51/push-ecx
2762
2763 81 7/subop/compare *(ebp+0xc) 0/imm32
2764 74/jump-if-equal $emit-subx-imm32:end/disp8
2765
2766 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
2767 (write-buffered *(ebp+8) Space)
2768 (write-buffered *(ebp+8) *eax)
2769 (write-buffered *(ebp+8) "/imm32")
2770 $emit-subx-imm32:end:
2771
2772 59/pop-to-ecx
2773 58/pop-to-eax
2774
2775 89/<- %esp 5/r32/ebp
2776 5d/pop-to-ebp
2777 c3/return
2778
2779 emit-subx-call:
2780
2781 55/push-ebp
2782 89/<- %ebp 4/r32/esp
2783
2784 50/push-eax
2785 51/push-ecx
2786
2787 (write-buffered *(ebp+8) "(")
2788
2789 8b/-> *(ebp+0x14) 1/r32/ecx
2790 (write-buffered *(ebp+8) *(ecx+4))
2791
2792
2793 8b/-> *(ebp+0xc) 1/r32/ecx
2794 8b/-> *(ecx+8) 1/r32/ecx
2795 {
2796
2797 81 7/subop/compare %ecx 0/imm32
2798 74/jump-if-equal break/disp8
2799
2800 (emit-subx-call-operand *(ebp+8) *ecx)
2801
2802 8b/-> *(ecx+4) 1/r32/ecx
2803 }
2804
2805 (write-buffered *(ebp+8) ")")
2806 $emit-subx-call:end:
2807
2808 59/pop-to-ecx
2809 58/pop-to-eax
2810
2811 89/<- %esp 5/r32/ebp
2812 5d/pop-to-ebp
2813 c3/return
2814
2815 emit-subx-call-operand:
2816
2817 55/push-ebp
2818 89/<- %ebp 4/r32/esp
2819
2820 50/push-eax
2821
2822 8b/-> *(ebp+0xc) 0/r32/eax
2823
2824 (emit-subx-var-as-rm32 *(ebp+8) %eax)
2825
2826 {
2827 81 7/subop/compare *(eax+4) 0/imm32
2828 75/jump-if-not-equal break/disp8
2829 $emit-subx-call-operand:literal:
2830 (write-buffered *(ebp+8) Space)
2831 (write-buffered *(ebp+8) *eax)
2832 }
2833 $emit-subx-call-operand:end:
2834
2835 58/pop-to-eax
2836
2837 89/<- %esp 5/r32/ebp
2838 5d/pop-to-ebp
2839 c3/return
2840
2841 emit-subx-var-as-rm32:
2842
2843 55/push-ebp
2844 89/<- %ebp 4/r32/esp
2845
2846 50/push-eax
2847
2848 8b/-> *(ebp+0xc) 0/r32/eax
2849
2850 {
2851 81 7/subop/compare *(eax+0x10) 0/imm32
2852 74/jump-if-equal break/disp8
2853 $emit-subx-var-as-rm32:register:
2854 (write-buffered *(ebp+8) " %")
2855 (write-buffered *(ebp+8) *(eax+0x10))
2856 }
2857
2858 {
2859 81 7/subop/compare *(eax+0xc) 0/imm32
2860 74/jump-if-equal break/disp8
2861 $emit-subx-var-as-rm32:stack:
2862 (write-buffered *(ebp+8) Space)
2863 (write-buffered *(ebp+8) "*(ebp+")
2864 8b/-> *(ebp+0xc) 0/r32/eax
2865 (print-int32-buffered *(ebp+8) *(eax+0xc))
2866 (write-buffered *(ebp+8) ")")
2867 }
2868 $emit-subx-var-as-rm32:end:
2869
2870 58/pop-to-eax
2871
2872 89/<- %esp 5/r32/ebp
2873 5d/pop-to-ebp
2874 c3/return
2875
2876 find-matching-function:
2877
2878 55/push-ebp
2879 89/<- %ebp 4/r32/esp
2880
2881 51/push-ecx
2882
2883 8b/-> *(ebp+8) 1/r32/ecx
2884 {
2885
2886 81 7/subop/compare %ecx 0/imm32
2887 74/jump-if-equal break/disp8
2888
2889 {
2890 (mu-stmt-matches-function? *(ebp+0xc) %ecx)
2891 3d/compare-eax-and 0/imm32
2892 74/jump-if-equal break/disp8
2893 89/<- %eax 1/r32/ecx
2894 eb/jump $find-matching-function:end/disp8
2895 }
2896
2897 8b/-> *(ecx+0x10) 1/r32/ecx
2898 eb/jump loop/disp8
2899 }
2900
2901 b8/copy-to-eax 0/imm32
2902 $find-matching-function:end:
2903
2904 59/pop-to-ecx
2905
2906 89/<- %esp 5/r32/ebp
2907 5d/pop-to-ebp
2908 c3/return
2909
2910 find-matching-primitive:
2911
2912 55/push-ebp
2913 89/<- %ebp 4/r32/esp
2914
2915 51/push-ecx
2916
2917 8b/-> *(ebp+8) 1/r32/ecx
2918 {
2919 $find-matching-primitive:loop:
2920
2921 81 7/subop/compare %ecx 0/imm32
2922 74/jump-if-equal break/disp8
2923
2924 {
2925 (mu-stmt-matches-primitive? *(ebp+0xc) %ecx)
2926 3d/compare-eax-and 0/imm32
2927 74/jump-if-equal break/disp8
2928 89/<- %eax 1/r32/ecx
2929 eb/jump $find-matching-function:end/disp8
2930 }
2931 $find-matching-primitive:next-primitive:
2932
2933 8b/-> *(ecx+0x1c) 1/r32/ecx
2934 eb/jump loop/disp8
2935 }
2936
2937 b8/copy-to-eax 0/imm32
2938 $find-matching-primitive:end:
2939
2940 59/pop-to-ecx
2941
2942 89/<- %esp 5/r32/ebp
2943 5d/pop-to-ebp
2944 c3/return
2945
2946 mu-stmt-matches-function?:
2947
2948 55/push-ebp
2949 89/<- %ebp 4/r32/esp
2950
2951 51/push-ecx
2952
2953 8b/-> *(ebp+8) 1/r32/ecx
2954 8b/-> *(ebp+0xc) 0/r32/eax
2955 (string-equal? *(ecx+4) *eax)
2956 $mu-stmt-matches-function?:end:
2957
2958 59/pop-to-ecx
2959
2960 89/<- %esp 5/r32/ebp
2961 5d/pop-to-ebp
2962 c3/return
2963
2964 mu-stmt-matches-primitive?:
2965
2966
2967
2968
2969
2970
2971 55/push-ebp
2972 89/<- %ebp 4/r32/esp
2973
2974 51/push-ecx
2975 52/push-edx
2976 53/push-ebx
2977 56/push-esi
2978 57/push-edi
2979
2980 8b/-> *(ebp+8) 1/r32/ecx
2981
2982 8b/-> *(ebp+0xc) 2/r32/edx
2983 {
2984 $mu-stmt-matches-primitive?:check-name:
2985
2986 (string-equal? *(ecx+4) *edx)
2987 3d/compare-eax-and 0/imm32
2988 75/jump-if-not-equal break/disp8
2989 b8/copy-to-eax 0/imm32
2990 e9/jump $mu-stmt-matches-primitive?:end/disp32
2991 }
2992 $mu-stmt-matches-primitive?:check-inouts:
2993
2994 8b/-> *(ecx+8) 6/r32/esi
2995 8b/-> *(edx+4) 7/r32/edi
2996 {
2997
2998 {
2999 81 7/subop/compare %esi 0/imm32
3000 75/jump-if-not-equal break/disp8
3001 $mu-stmt-matches-primitive?:stmt-inout-is-null:
3002 {
3003 81 7/subop/compare %edi 0/imm32
3004 75/jump-if-not-equal break/disp8
3005
3006 b8/copy-to-eax 1/imm32/true
3007 e9/jump $mu-stmt-matches-primitive?:end/disp32
3008 }
3009
3010 b8/copy-to-eax 0/imm32/false
3011 e9/jump $mu-stmt-matches-primitive?:end/disp32
3012 }
3013
3014 {
3015 81 7/subop/compare %edi 0/imm32
3016 75/jump-if-not-equal break/disp8
3017 $mu-stmt-matches-primitive?:prim-inout-is-null:
3018 b8/copy-to-eax 0/imm32/false
3019 e9/jump $mu-stmt-matches-primitive?:end/disp32
3020 }
3021
3022 {
3023 (operand-matches-primitive? *esi *edi)
3024 3d/compare-eax-and 0/imm32
3025 75/jump-if-not-equal break/disp8
3026 b8/copy-to-eax 0/imm32/false
3027 e9/jump $mu-stmt-matches-primitive?:end/disp32
3028 }
3029
3030 8b/-> *(esi+4) 6/r32/esi
3031
3032 8b/-> *(edi+4) 7/r32/edi
3033 eb/jump loop/disp8
3034 }
3035 $mu-stmt-matches-primitive?:check-outputs:
3036
3037 8b/-> *(ecx+0xc) 6/r32/esi
3038 8b/-> *(edx+8) 7/r32/edi
3039 {
3040
3041 {
3042 81 7/subop/compare %esi 0/imm32
3043 75/jump-if-not-equal break/disp8
3044 {
3045 81 7/subop/compare %edi 0/imm32
3046 75/jump-if-not-equal break/disp8
3047
3048 b8/copy-to-eax 1/imm32
3049 e9/jump $mu-stmt-matches-primitive?:end/disp32
3050 }
3051
3052 b8/copy-to-eax 0/imm32
3053 e9/jump $mu-stmt-matches-primitive?:end/disp32
3054 }
3055
3056 {
3057 81 7/subop/compare %edi 0/imm32
3058 75/jump-if-not-equal break/disp8
3059 b8/copy-to-eax 0/imm32
3060 e9/jump $mu-stmt-matches-primitive?:end/disp32
3061 }
3062
3063 {
3064 (operand-matches-primitive? *esi *edi)
3065 3d/compare-eax-and 0/imm32
3066 75/jump-if-not-equal break/disp8
3067 b8/copy-to-eax 0/imm32
3068 e9/jump $mu-stmt-matches-primitive?:end/disp32
3069 }
3070
3071 8b/-> *(ecx+4) 1/r32/ecx
3072
3073 8b/-> *(edx+4) 2/r32/edx
3074 eb/jump loop/disp8
3075 }
3076 $mu-stmt-matches-primitive?:return-true:
3077 b8/copy-to-eax 1/imm32
3078 $mu-stmt-matches-primitive?:end:
3079
3080 5f/pop-to-edi
3081 5e/pop-to-esi
3082 5b/pop-to-ebx
3083 5a/pop-to-edx
3084 59/pop-to-ecx
3085
3086 89/<- %esp 5/r32/ebp
3087 5d/pop-to-ebp
3088 c3/return
3089
3090 operand-matches-primitive?:
3091
3092 55/push-ebp
3093 89/<- %ebp 4/r32/esp
3094
3095 56/push-esi
3096 57/push-edi
3097
3098 8b/-> *(ebp+8) 6/r32/esi
3099
3100 8b/-> *(ebp+0xc) 7/r32/edi
3101
3102 8b/-> *(esi+4) 0/r32/eax
3103 39/compare *(edi+4) 0/r32/eax
3104 b8/copy-to-eax 0/imm32/false
3105 75/jump-if-not-equal $operand-matches-primitive?:end/disp8
3106
3107 {
3108
3109 8b/-> *(esi+0x10) 0/r32/eax
3110 39/compare *(edi+0x10) 0/r32/eax
3111 74/jump-if-equal break/disp8
3112
3113 3d/compare-eax-and 0/imm32
3114 74/jump-if-equal $operand-matches-primitive?:end/disp8
3115 81 7/subop/compare *(edi+0x10) 0/imm32
3116 74/jump-if-equal $operand-matches-primitive?:end/disp8
3117
3118 (string-equal? *(edi+0x10) "*")
3119 3d/compare-eax-and 0/imm32
3120 b8/copy-to-eax 1/imm32/true
3121 75/jump-if-not-equal $operand-matches-primitive?:end/disp8
3122
3123 (string-equal? *(esi+0x10) *(edi+0x10))
3124 3d/compare-eax-and 0/imm32
3125 b8/copy-to-eax 0/imm32/false
3126 74/jump-if-equal $operand-matches-primitive?:end/disp8
3127 }
3128
3129 b8/copy-to-eax 1/imm32/true
3130 $operand-matches-primitive?:end:
3131
3132 5f/pop-to-edi
3133 5e/pop-to-esi
3134
3135 89/<- %esp 5/r32/ebp
3136 5d/pop-to-ebp
3137 c3/return
3138
3139 test-emit-subx-statement-primitive:
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158 55/push-ebp
3159 89/<- %ebp 4/r32/esp
3160
3161 (clear-stream _test-output-stream)
3162 (clear-stream $_test-output-buffered-file->buffer)
3163
3164 68/push 0/imm32/no-register
3165 68/push -8/imm32/stack-offset
3166 68/push 1/imm32/block-depth
3167 68/push 1/imm32/type-int
3168 68/push "foo"/imm32
3169 89/<- %ecx 4/r32/esp
3170
3171 51/push-ecx/var-foo
3172 68/push 1/imm32/data-length
3173 68/push 1/imm32/top
3174 89/<- %edx 4/r32/esp
3175
3176 68/push 0/imm32/next
3177 51/push-ecx/var-foo
3178 89/<- %ebx 4/r32/esp
3179
3180 68/push 0/imm32/next
3181 68/push 0/imm32/outputs
3182 53/push-ebx/operands
3183 68/push "increment"/imm32/operation
3184 68/push 1/imm32
3185 89/<- %esi 4/r32/esp
3186
3187 68/push 0/imm32/next
3188 68/push 0/imm32/no-imm32
3189 68/push 0/imm32/no-r32
3190 68/push 1/imm32/rm32-is-first-inout
3191 68/push "ff 0/subop/increment"/imm32/subx-name
3192 68/push 0/imm32/outputs
3193 53/push-ebx/inouts
3194 68/push "increment"/imm32/name
3195 89/<- %ebx 4/r32/esp
3196
3197 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3198 (flush _test-output-buffered-file)
3199 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3205
3206 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0xfffffff8)" "F - test-emit-subx-statement-primitive")
3207
3208 89/<- %esp 5/r32/ebp
3209 5d/pop-to-ebp
3210 c3/return
3211
3212 test-emit-subx-statement-primitive-register:
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231 55/push-ebp
3232 89/<- %ebp 4/r32/esp
3233
3234 (clear-stream _test-output-stream)
3235 (clear-stream $_test-output-buffered-file->buffer)
3236
3237 68/push "eax"/imm32/register
3238 68/push 0/imm32/no-stack-offset
3239 68/push 1/imm32/block-depth
3240 68/push 1/imm32/type-int
3241 68/push "foo"/imm32
3242 89/<- %ecx 4/r32/esp
3243
3244 51/push-ecx/var-foo
3245 68/push 1/imm32/data-length
3246 68/push 1/imm32/top
3247 89/<- %edx 4/r32/esp
3248
3249 68/push 0/imm32/next
3250 51/push-ecx/var-foo
3251 89/<- %ebx 4/r32/esp
3252
3253 68/push 0/imm32/next
3254 53/push-ebx/outputs
3255 68/push 0/imm32/inouts
3256 68/push "increment"/imm32/operation
3257 68/push 1/imm32
3258 89/<- %esi 4/r32/esp
3259
3260 68/push Any-register/imm32
3261 68/push 0/imm32/no-stack-offset
3262 68/push 1/imm32/block-depth
3263 68/push 1/imm32/type-int
3264 68/push "dummy"/imm32
3265 89/<- %ebx 4/r32/esp
3266
3267 68/push 0/imm32/next
3268 53/push-ebx/formal-var
3269 89/<- %ebx 4/r32/esp
3270
3271 68/push 0/imm32/next
3272 68/push 0/imm32/no-imm32
3273 68/push 0/imm32/no-r32
3274 68/push 3/imm32/rm32-in-first-output
3275 68/push "ff 0/subop/increment"/imm32/subx-name
3276 53/push-ebx/outputs
3277 68/push 0/imm32/inouts
3278 68/push "increment"/imm32/name
3279 89/<- %ebx 4/r32/esp
3280
3281 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3282 (flush _test-output-buffered-file)
3283 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3289
3290 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-primitive-register")
3291
3292 89/<- %esp 5/r32/ebp
3293 5d/pop-to-ebp
3294 c3/return
3295
3296 test-emit-subx-statement-select-primitive:
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318 55/push-ebp
3319 89/<- %ebp 4/r32/esp
3320
3321 (clear-stream _test-output-stream)
3322 (clear-stream $_test-output-buffered-file->buffer)
3323
3324 68/push "eax"/imm32/register
3325 68/push 0/imm32/no-stack-offset
3326 68/push 1/imm32/block-depth
3327 68/push 1/imm32/type-int
3328 68/push "foo"/imm32
3329 89/<- %ecx 4/r32/esp
3330
3331 51/push-ecx/var-foo
3332 68/push 1/imm32/data-length
3333 68/push 1/imm32/top
3334 89/<- %edx 4/r32/esp
3335
3336 68/push 0/imm32/next
3337 51/push-ecx/var-foo
3338 89/<- %edi 4/r32/esp
3339
3340 68/push 0/imm32/next
3341 57/push-edi/outputs
3342 68/push 0/imm32/inouts
3343 68/push "increment"/imm32/operation
3344 68/push 1/imm32
3345 89/<- %esi 4/r32/esp
3346
3347 68/push Any-register/imm32
3348 68/push 0/imm32/no-stack-offset
3349 68/push 1/imm32/block-depth
3350 68/push 1/imm32/type-int
3351 68/push "dummy"/imm32
3352 89/<- %ebx 4/r32/esp
3353
3354 68/push 0/imm32/next
3355 53/push-ebx/formal-var
3356 89/<- %ebx 4/r32/esp
3357
3358 68/push 0/imm32/next
3359 68/push 0/imm32/no-imm32
3360 68/push 0/imm32/no-r32
3361 68/push 3/imm32/rm32-in-first-output
3362 68/push "ff 0/subop/increment"/imm32/subx-name
3363 53/push-ebx/outputs/formal-outputs
3364 68/push 0/imm32/inouts
3365 68/push "increment"/imm32/name
3366 89/<- %ebx 4/r32/esp
3367
3368 53/push-ebx/next
3369 68/push 0/imm32/no-imm32
3370 68/push 0/imm32/no-r32
3371 68/push 1/imm32/rm32-is-first-inout
3372 68/push "ff 0/subop/increment"/imm32/subx-name
3373 68/push 0/imm32/outputs
3374 57/push-edi/inouts/real-outputs
3375 68/push "increment"/imm32/name
3376 89/<- %ebx 4/r32/esp
3377
3378 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3379 (flush _test-output-buffered-file)
3380 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3386
3387 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive")
3388
3389 89/<- %esp 5/r32/ebp
3390 5d/pop-to-ebp
3391 c3/return
3392
3393 test-emit-subx-statement-select-primitive-2:
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415 55/push-ebp
3416 89/<- %ebp 4/r32/esp
3417
3418 (clear-stream _test-output-stream)
3419 (clear-stream $_test-output-buffered-file->buffer)
3420
3421 68/push "eax"/imm32/register
3422 68/push 0/imm32/no-stack-offset
3423 68/push 1/imm32/block-depth
3424 68/push 1/imm32/type-int
3425 68/push "foo"/imm32
3426 89/<- %ecx 4/r32/esp
3427
3428 51/push-ecx/var-foo
3429 68/push 1/imm32/data-length
3430 68/push 1/imm32/top
3431 89/<- %edx 4/r32/esp
3432
3433 68/push 0/imm32/next
3434 51/push-ecx/var-foo
3435 89/<- %edi 4/r32/esp
3436
3437 68/push 0/imm32/next
3438 68/push 0/imm32/outputs
3439 57/push-edi/inouts
3440 68/push "increment"/imm32/operation
3441 68/push 1/imm32
3442 89/<- %esi 4/r32/esp
3443
3444 68/push Any-register/imm32
3445 68/push 0/imm32/no-stack-offset
3446 68/push 1/imm32/block-depth
3447 68/push 1/imm32/type-int
3448 68/push "dummy"/imm32
3449 89/<- %ebx 4/r32/esp
3450
3451 68/push 0/imm32/next
3452 53/push-ebx/formal-var
3453 89/<- %ebx 4/r32/esp
3454
3455 68/push 0/imm32/next
3456 68/push 0/imm32/no-imm32
3457 68/push 0/imm32/no-r32
3458 68/push 3/imm32/rm32-in-first-output
3459 68/push "ff 0/subop/increment"/imm32/subx-name
3460 53/push-ebx/outputs/formal-outputs
3461 68/push 0/imm32/inouts
3462 68/push "increment"/imm32/name
3463 89/<- %ebx 4/r32/esp
3464
3465 53/push-ebx/next
3466 68/push 0/imm32/no-imm32
3467 68/push 0/imm32/no-r32
3468 68/push 1/imm32/rm32-is-first-inout
3469 68/push "ff 0/subop/increment"/imm32/subx-name
3470 68/push 0/imm32/outputs
3471 57/push-edi/inouts/real-outputs
3472 68/push "increment"/imm32/name
3473 89/<- %ebx 4/r32/esp
3474
3475 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3476 (flush _test-output-buffered-file)
3477 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3483
3484 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive-2")
3485
3486 89/<- %esp 5/r32/ebp
3487 5d/pop-to-ebp
3488 c3/return
3489
3490 test-increment-register:
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506 55/push-ebp
3507 89/<- %ebp 4/r32/esp
3508
3509 (clear-stream _test-output-stream)
3510 (clear-stream $_test-output-buffered-file->buffer)
3511
3512 68/push "eax"/imm32/register
3513 68/push 0/imm32/no-stack-offset
3514 68/push 1/imm32/block-depth
3515 68/push 1/imm32/type-int
3516 68/push "foo"/imm32
3517 89/<- %ecx 4/r32/esp
3518
3519 51/push-ecx/var-foo
3520 68/push 1/imm32/data-length
3521 68/push 1/imm32/top
3522 89/<- %edx 4/r32/esp
3523
3524 68/push 0/imm32/next
3525 51/push-ecx/var-foo
3526 89/<- %edi 4/r32/esp
3527
3528 68/push 0/imm32/next
3529 57/push-edi/outputs
3530 68/push 0/imm32/inouts
3531 68/push "increment"/imm32/operation
3532 68/push 1/imm32
3533 89/<- %esi 4/r32/esp
3534
3535 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0)
3536 (flush _test-output-buffered-file)
3537 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3543
3544 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-register")
3545
3546 89/<- %esp 5/r32/ebp
3547 5d/pop-to-ebp
3548 c3/return
3549
3550 test-increment-var:
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566 55/push-ebp
3567 89/<- %ebp 4/r32/esp
3568
3569 (clear-stream _test-output-stream)
3570 (clear-stream $_test-output-buffered-file->buffer)
3571
3572 68/push "eax"/imm32/register
3573 68/push 0/imm32/no-stack-offset
3574 68/push 1/imm32/block-depth
3575 68/push 1/imm32/type-int
3576 68/push "foo"/imm32
3577 89/<- %ecx 4/r32/esp
3578
3579 51/push-ecx/var-foo
3580 68/push 1/imm32/data-length
3581 68/push 1/imm32/top
3582 89/<- %edx 4/r32/esp
3583
3584 68/push 0/imm32/next
3585 51/push-ecx/var-foo
3586 89/<- %edi 4/r32/esp
3587
3588 68/push 0/imm32/next
3589 68/push 0/imm32/outputs
3590 57/push-edi/inouts
3591 68/push "increment"/imm32/operation
3592 68/push 1/imm32
3593 89/<- %esi 4/r32/esp
3594
3595 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0)
3596 (flush _test-output-buffered-file)
3597 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3603
3604 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-var")
3605
3606 89/<- %esp 5/r32/ebp
3607 5d/pop-to-ebp
3608 c3/return
3609
3610 test-add-reg-to-reg:
3611
3612
3613
3614
3615
3616 55/push-ebp
3617 89/<- %ebp 4/r32/esp
3618
3619 (clear-stream _test-output-stream)
3620 (clear-stream $_test-output-buffered-file->buffer)
3621
3622 68/push "eax"/imm32/register
3623 68/push 0/imm32/no-stack-offset
3624 68/push 1/imm32/block-depth
3625 68/push 1/imm32/type-int
3626 68/push "var1"/imm32
3627 89/<- %ecx 4/r32/esp
3628
3629 68/push "ecx"/imm32/register
3630 68/push 0/imm32/no-stack-offset
3631 68/push 1/imm32/block-depth
3632 68/push 1/imm32/type-int
3633 68/push "var2"/imm32
3634 89/<- %edx 4/r32/esp
3635
3636 68/push 0/imm32/next
3637 52/push-edx/var-var2
3638 89/<- %esi 4/r32/esp
3639
3640 68/push 0/imm32/next
3641 51/push-ecx/var-var1
3642 89/<- %edi 4/r32/esp
3643
3644 68/push 0/imm32/next
3645 57/push-edi/outputs
3646 56/push-esi/inouts
3647 68/push "add"/imm32/operation
3648 68/push 1/imm32
3649 89/<- %esi 4/r32/esp
3650
3651 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3652 (flush _test-output-buffered-file)
3653 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3659
3660 (check-next-stream-line-equal _test-output-stream "01 %eax 0x00000001/r32" "F - test-add-reg-to-reg")
3661
3662 89/<- %esp 5/r32/ebp
3663 5d/pop-to-ebp
3664 c3/return
3665
3666 test-add-reg-to-mem:
3667
3668
3669
3670
3671
3672 55/push-ebp
3673 89/<- %ebp 4/r32/esp
3674
3675 (clear-stream _test-output-stream)
3676 (clear-stream $_test-output-buffered-file->buffer)
3677
3678 68/push 0/imm32/no-register
3679 68/push 8/imm32/stack-offset
3680 68/push 1/imm32/block-depth
3681 68/push 1/imm32/type-int
3682 68/push "var1"/imm32
3683 89/<- %ecx 4/r32/esp
3684
3685 68/push "ecx"/imm32/register
3686 68/push 0/imm32/no-stack-offset
3687 68/push 1/imm32/block-depth
3688 68/push 1/imm32/type-int
3689 68/push "var2"/imm32
3690 89/<- %edx 4/r32/esp
3691
3692 68/push 0/imm32/next
3693 52/push-edx/var-var2
3694 89/<- %esi 4/r32/esp
3695
3696 56/push-esi/next
3697 51/push-ecx/var-var1
3698 89/<- %esi 4/r32/esp
3699
3700 68/push 0/imm32/next
3701 68/push 0/imm32/outputs
3702 56/push-esi/inouts
3703 68/push "add-to"/imm32/operation
3704 68/push 1/imm32
3705 89/<- %esi 4/r32/esp
3706
3707 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3708 (flush _test-output-buffered-file)
3709 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3715
3716 (check-next-stream-line-equal _test-output-stream "01 *(ebp+0x00000008) 0x00000001/r32" "F - test-add-reg-to-mem")
3717
3718 89/<- %esp 5/r32/ebp
3719 5d/pop-to-ebp
3720 c3/return
3721
3722 test-add-mem-to-reg:
3723
3724
3725
3726
3727
3728 55/push-ebp
3729 89/<- %ebp 4/r32/esp
3730
3731 (clear-stream _test-output-stream)
3732 (clear-stream $_test-output-buffered-file->buffer)
3733
3734 68/push "eax"/imm32/register
3735 68/push 0/imm32/no-stack-offset
3736 68/push 1/imm32/block-depth
3737 68/push 1/imm32/type-int
3738 68/push "var1"/imm32
3739 89/<- %ecx 4/r32/esp
3740
3741 68/push 0/imm32/no-register
3742 68/push 8/imm32/stack-offset
3743 68/push 1/imm32/block-depth
3744 68/push 1/imm32/type-int
3745 68/push "var2"/imm32
3746 89/<- %edx 4/r32/esp
3747
3748 68/push 0/imm32/next
3749 52/push-edx/var-var2
3750 89/<- %esi 4/r32/esp
3751
3752 68/push 0/imm32/next
3753 51/push-ecx/var-var1
3754 89/<- %edi 4/r32/esp
3755
3756 68/push 0/imm32/next
3757 57/push-edi/outputs
3758 56/push-esi/inouts
3759 68/push "add"/imm32/operation
3760 68/push 1/imm32
3761 89/<- %esi 4/r32/esp
3762
3763 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3764 (flush _test-output-buffered-file)
3765 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3771
3772 (check-next-stream-line-equal _test-output-stream "03 *(ebp+0x00000008) 0x00000000/r32" "F - test-add-mem-to-reg")
3773
3774 89/<- %esp 5/r32/ebp
3775 5d/pop-to-ebp
3776 c3/return
3777
3778 test-add-literal-to-reg:
3779
3780
3781
3782
3783
3784 55/push-ebp
3785 89/<- %ebp 4/r32/esp
3786
3787 (clear-stream _test-output-stream)
3788 (clear-stream $_test-output-buffered-file->buffer)
3789
3790 68/push "eax"/imm32/register
3791 68/push 0/imm32/no-stack-offset
3792 68/push 1/imm32/block-depth
3793 68/push 1/imm32/type-int
3794 68/push "var1"/imm32
3795 89/<- %ecx 4/r32/esp
3796
3797 68/push 0/imm32/no-register
3798 68/push 0/imm32/no-stack-offset
3799 68/push 1/imm32/block-depth
3800 68/push 0/imm32/type-literal
3801 68/push "0x34"/imm32
3802 89/<- %edx 4/r32/esp
3803
3804 68/push 0/imm32/next
3805 52/push-edx/var-var2
3806 89/<- %esi 4/r32/esp
3807
3808 68/push 0/imm32/next
3809 51/push-ecx/var-var1
3810 89/<- %edi 4/r32/esp
3811
3812 68/push 0/imm32/next
3813 57/push-edi/outputs
3814 56/push-esi/inouts
3815 68/push "add"/imm32/operation
3816 68/push 1/imm32
3817 89/<- %esi 4/r32/esp
3818
3819 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3820 (flush _test-output-buffered-file)
3821 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3827
3828 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %eax 0x34/imm32" "F - test-add-literal-to-reg")
3829
3830 89/<- %esp 5/r32/ebp
3831 5d/pop-to-ebp
3832 c3/return
3833
3834 test-add-literal-to-mem:
3835
3836
3837
3838
3839
3840 55/push-ebp
3841 89/<- %ebp 4/r32/esp
3842
3843 (clear-stream _test-output-stream)
3844 (clear-stream $_test-output-buffered-file->buffer)
3845
3846 68/push 0/imm32/no-register
3847 68/push 8/imm32/stack-offset
3848 68/push 1/imm32/block-depth
3849 68/push 1/imm32/type-int
3850 68/push "var1"/imm32
3851 89/<- %ecx 4/r32/esp
3852
3853 68/push 0/imm32/no-register
3854 68/push 0/imm32/no-stack-offset
3855 68/push 1/imm32/block-depth
3856 68/push 0/imm32/type-literal
3857 68/push "0x34"/imm32
3858 89/<- %edx 4/r32/esp
3859
3860 68/push 0/imm32/next
3861 52/push-edx/var-var2
3862 89/<- %esi 4/r32/esp
3863
3864 56/push-esi/next
3865 51/push-ecx/var-var1
3866 89/<- %esi 4/r32/esp
3867
3868 68/push 0/imm32/next
3869 68/push 0/imm32/outputs
3870 56/push-esi/inouts
3871 68/push "add-to"/imm32/operation
3872 68/push 1/imm32
3873 89/<- %esi 4/r32/esp
3874
3875 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3876 (flush _test-output-buffered-file)
3877 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3883
3884 (check-next-stream-line-equal _test-output-stream "81 0/subop/add *(ebp+0x00000008) 0x34/imm32" "F - test-add-literal-to-mem")
3885
3886 89/<- %esp 5/r32/ebp
3887 5d/pop-to-ebp
3888 c3/return
3889
3890 test-emit-subx-statement-function-call:
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911 55/push-ebp
3912 89/<- %ebp 4/r32/esp
3913
3914 (clear-stream _test-output-stream)
3915 (clear-stream $_test-output-buffered-file->buffer)
3916
3917 68/push 0/imm32/no-register
3918 68/push -8/imm32/stack-offset
3919 68/push 0/imm32/block-depth
3920 68/push 1/imm32/type-int
3921 68/push "foo"/imm32
3922 89/<- %ecx 4/r32/esp
3923
3924 51/push-ecx/var-foo
3925 68/push 1/imm32/data-length
3926 68/push 1/imm32/top
3927 89/<- %edx 4/r32/esp
3928
3929 68/push 0/imm32/next
3930 51/push-ecx/var-foo
3931 89/<- %esi 4/r32/esp
3932
3933 68/push 0/imm32/next
3934 68/push 0/imm32/outputs
3935 56/push-esi/inouts
3936 68/push "f"/imm32/operation
3937 68/push 1/imm32
3938 89/<- %esi 4/r32/esp
3939
3940 68/push 0/imm32/next
3941 68/push 0/imm32/body
3942 68/push 0/imm32/outputs
3943 51/push-ecx/inouts
3944 68/push "f2"/imm32/subx-name
3945 68/push "f"/imm32/name
3946 89/<- %ebx 4/r32/esp
3947
3948 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx)
3949 (flush _test-output-buffered-file)
3950 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3956
3957 (check-next-stream-line-equal _test-output-stream "(f2 *(ebp+0xfffffff8))" "F - test-emit-subx-statement-function-call")
3958
3959 89/<- %esp 5/r32/ebp
3960 5d/pop-to-ebp
3961 c3/return
3962
3963 test-emit-subx-statement-function-call-with-literal-arg:
3964
3965
3966
3967
3968
3969
3970 55/push-ebp
3971 89/<- %ebp 4/r32/esp
3972
3973 (clear-stream _test-output-stream)
3974 (clear-stream $_test-output-buffered-file->buffer)
3975
3976 68/push 0/imm32/no-register
3977 68/push 0/imm32/no-stack-offset
3978 68/push 0/imm32/block-depth
3979 68/push 0/imm32/type-literal
3980 68/push "34"/imm32
3981 89/<- %ecx 4/r32/esp
3982
3983 51/push-ecx/var-foo
3984 68/push 1/imm32/data-length
3985 68/push 1/imm32/top
3986 89/<- %edx 4/r32/esp
3987
3988 68/push 0/imm32/next
3989 51/push-ecx/var-foo
3990 89/<- %esi 4/r32/esp
3991
3992 68/push 0/imm32/next
3993 68/push 0/imm32/outputs
3994 56/push-esi/inouts
3995 68/push "f"/imm32/operation
3996 68/push 1/imm32
3997 89/<- %esi 4/r32/esp
3998
3999 68/push 0/imm32/next
4000 68/push 0/imm32/body
4001 68/push 0/imm32/outputs
4002 51/push-ecx/inouts
4003 68/push "f2"/imm32/subx-name
4004 68/push "f"/imm32/name
4005 89/<- %ebx 4/r32/esp
4006
4007 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx)
4008 (flush _test-output-buffered-file)
4009 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4015
4016 (check-next-stream-line-equal _test-output-stream "(f2 34)" "F - test-emit-subx-statement-function-call-with-literal-arg")
4017
4018 89/<- %esp 5/r32/ebp
4019 5d/pop-to-ebp
4020 c3/return
4021
4022 emit-subx-prologue:
4023
4024 55/push-ebp
4025 89/<- %ebp 4/r32/esp
4026
4027 (write-buffered *(ebp+8) "# . prologue\n")
4028 (write-buffered *(ebp+8) "55/push-ebp\n")
4029 (write-buffered *(ebp+8) "89/<- %ebp 4/r32/esp\n")
4030 $emit-subx-prologue:end:
4031
4032 89/<- %esp 5/r32/ebp
4033 5d/pop-to-ebp
4034 c3/return
4035
4036 emit-subx-epilogue:
4037
4038 55/push-ebp
4039 89/<- %ebp 4/r32/esp
4040
4041 (write-buffered *(ebp+8) "# . epilogue\n")
4042 (write-buffered *(ebp+8) "89/<- %esp 5/r32/ebp\n")
4043 (write-buffered *(ebp+8) "5d/pop-to-ebp\n")
4044 (write-buffered *(ebp+8) "c3/return\n")
4045 $emit-subx-epilogue:end:
4046
4047 89/<- %esp 5/r32/ebp
4048 5d/pop-to-ebp
4049 c3/return