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