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 57/push-edi
1609
1610 8b/-> *(ebp+8) 6/r32/esi
1611
1612 8b/-> *(ebp+0xc) 7/r32/edi
1613
1614 (parse-mu-block %esi)
1615
1616 89/<- *(edi+0x10) 0/r32/eax
1617 $populate-mu-function-body:end:
1618
1619 5f/pop-to-edi
1620 5e/pop-to-esi
1621 58/pop-to-eax
1622
1623 89/<- %esp 5/r32/ebp
1624 5d/pop-to-ebp
1625 c3/return
1626
1627
1628 parse-mu-block:
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
1658
1659
1660
1661 55/push-ebp
1662 89/<- %ebp 4/r32/esp
1663
1664 51/push-ecx
1665 52/push-edx
1666 53/push-ebx
1667 56/push-esi
1668 57/push-edi
1669
1670 81 5/subop/subtract %esp 0x200/imm32
1671 68/push 0x200/imm32/length
1672 68/push 0/imm32/read
1673 68/push 0/imm32/write
1674 89/<- %ecx 4/r32/esp
1675
1676 68/push 0/imm32/end
1677 68/push 0/imm32/start
1678 89/<- %edx 4/r32/esp
1679
1680 (allocate Heap *Stmt-size)
1681 89/<- %edi 0/r32/eax
1682 {
1683 $parse-mu-block:line-loop:
1684
1685 (clear-stream %ecx)
1686 (read-line-buffered *(ebp+8) %ecx)
1687
1688
1689
1690
1691
1692 81 7/subop/compare *ecx 0/imm32
1693 0f 84/jump-if-equal break/disp32
1694
1695 (next-word %ecx %edx)
1696
1697
1698
1699
1700
1701 (slice-empty? %edx)
1702 3d/compare-eax-and 0/imm32
1703 0f 85/jump-if-not-equal loop/disp32
1704
1705
1706 8b/-> *edx 0/r32/eax
1707 8a/copy-byte *eax 0/r32/AL
1708 81 4/subop/and %eax 0xff/imm32
1709
1710 3d/compare-eax-and 0x23/imm32/hash
1711 0f 84/jump-if-equal loop/disp32
1712
1713 {
1714 $parse-mu-block:check-for-block:
1715 (slice-equal? %edx "{")
1716 3d/compare-eax-and 0/imm32
1717 74/jump-if-equal break/disp8
1718 (check-no-tokens-left %ecx)
1719
1720 (parse-mu-block *(ebp+8))
1721 (append-to-block %edi %eax)
1722 e9/jump $parse-mu-block:line-loop/disp32
1723 }
1724
1725 $parse-mu-block:check-for-end:
1726 (slice-equal? %edx "}")
1727 3d/compare-eax-and 0/imm32
1728 0f 85/jump-if-not-equal break/disp32
1729
1730 {
1731 $parse-mu-block:check-for-named-block:
1732
1733 8b/-> *(edx+4) 0/r32/eax
1734 8a/copy-byte *eax 0/r32/AL
1735 81 4/subop/and %eax 0xff/imm32
1736
1737 3d/compare-eax-and 0x23/imm32/hash
1738 0f 85/jump-if-not-equal break/disp32
1739
1740 (parse-mu-named-block %edx %ecx *(ebp+8))
1741 (append-to-block %edi %eax)
1742 e9/jump $parse-mu-block:line-loop/disp32
1743 }
1744
1745 {
1746 $parse-mu-block:check-for-var:
1747 (slice-equal? %edx "var")
1748 3d/compare-eax-and 0/imm32
1749 74/jump-if-equal break/disp8
1750
1751 (parse-mu-var-def %ecx)
1752 (append-to-block %edi %eax)
1753 e9/jump $parse-mu-block:line-loop/disp32
1754 }
1755 $parse-mu-block:regular-stmt:
1756
1757 (parse-mu-stmt %ecx)
1758 (append-to-block Heap %edi %eax)
1759 e9/jump loop/disp32
1760 }
1761
1762 89/<- %eax 7/r32/edi
1763 $parse-mu-block:end:
1764
1765 81 0/subop/add %esp 0x214/imm32
1766
1767 5f/pop-to-edi
1768 5e/pop-to-esi
1769 5b/pop-to-ebx
1770 5a/pop-to-edx
1771 59/pop-to-ecx
1772
1773 89/<- %esp 5/r32/ebp
1774 5d/pop-to-ebp
1775 c3/return
1776
1777 $parse-mu-block:abort:
1778
1779 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
1780 (rewind-stream %ecx)
1781 (write-stream 2 %ecx)
1782 (write-buffered Stderr "'\n")
1783 (flush Stderr)
1784
1785 bb/copy-to-ebx 1/imm32
1786 b8/copy-to-eax 1/imm32/exit
1787 cd/syscall 0x80/imm8
1788
1789
1790 check-no-tokens-left:
1791
1792 55/push-ebp
1793 89/<- %ebp 4/r32/esp
1794
1795 50/push-eax
1796 51/push-ecx
1797
1798 68/push 0/imm32/end
1799 68/push 0/imm32/start
1800 89/<- %ecx 4/r32/esp
1801
1802 (next-word *(ebp+8) %ecx)
1803
1804 (slice-empty? %ecx)
1805 3d/compare-eax-and 0/imm32
1806 75/jump-if-not-equal $check-no-tokens-left:end/disp8
1807
1808
1809 8b/-> *edx 0/r32/eax
1810 8a/copy-byte *eax 0/r32/AL
1811 81 4/subop/and %eax 0xff/imm32
1812
1813 3d/compare-eax-and 0x23/imm32/hash
1814 74/jump-if-equal $check-no-tokens-left:end/disp8
1815
1816 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
1817 (rewind-stream %ecx)
1818 (write-stream 2 %ecx)
1819 (write-buffered Stderr "'\n")
1820 (flush Stderr)
1821
1822 bb/copy-to-ebx 1/imm32
1823 b8/copy-to-eax 1/imm32/exit
1824 cd/syscall 0x80/imm8
1825
1826 $check-no-tokens-left:end:
1827
1828 81 0/subop/add %esp 8/imm32
1829
1830 59/pop-to-ecx
1831 58/pop-to-eax
1832
1833 89/<- %esp 5/r32/ebp
1834 5d/pop-to-ebp
1835 c3/return
1836
1837 parse-mu-named-block:
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870 55/push-ebp
1871 89/<- %ebp 4/r32/esp
1872
1873 $parse-mu-named-block:end:
1874
1875
1876
1877 89/<- %esp 5/r32/ebp
1878 5d/pop-to-ebp
1879 c3/return
1880
1881 parse-mu-var-def:
1882
1883
1884
1885 55/push-ebp
1886 89/<- %ebp 4/r32/esp
1887
1888 $parse-mu-var-def:end:
1889
1890
1891
1892 89/<- %esp 5/r32/ebp
1893 5d/pop-to-ebp
1894 c3/return
1895
1896 parse-mu-stmt:
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915 55/push-ebp
1916 89/<- %ebp 4/r32/esp
1917
1918 51/push-ecx
1919 57/push-edi
1920
1921 68/push 0/imm32/end
1922 68/push 0/imm32/start
1923 89/<- %ecx 4/r32/esp
1924
1925 (allocate Heap *Stmt-size)
1926 89/<- %edi 0/r32/eax
1927
1928 c7 0/subop/copy *edi 1/imm32/stmt1
1929 {
1930 (stmt-has-outputs? *(ebp+8))
1931 3d/compare-eax-and 0/imm32
1932 0f 84/jump-if-equal break/disp32
1933 {
1934 $parse-mu-stmt:read-outputs:
1935
1936 (next-word *(ebp+8) %ecx)
1937
1938 (slice-empty? %ecx)
1939 3d/compare-eax-and 0/imm32
1940 0f 85/jump-if-not-equal break/disp32
1941
1942 (slice-equal? %ecx "<-")
1943 3d/compare-eax-and 0/imm32
1944 75/jump-if-not-equal break/disp8
1945
1946 (is-identifier? %ecx)
1947 3d/compare-eax-and 0/imm32
1948 0f 84/jump-if-equal $parse-mu-stmt:abort/disp32
1949
1950 (parse-var Heap %ecx)
1951 (append-list Heap %eax *(edi+0xc))
1952 89/<- *(edi+0xc) 0/r32/eax
1953 e9/jump loop/disp32
1954 }
1955 }
1956 $parse-mu-stmt:read-operation:
1957 (next-word *(ebp+8) %ecx)
1958 (slice-to-string Heap %ecx)
1959 89/<- *(edi+4) 0/r32/eax
1960 {
1961 $parse-mu-stmt:read-inouts:
1962
1963 (next-word-or-string *(ebp+8) %ecx)
1964
1965 (slice-empty? %ecx)
1966 3d/compare-eax-and 0/imm32
1967 0f 85/jump-if-not-equal break/disp32
1968
1969 (slice-equal? %ecx "<-")
1970 3d/compare-eax-and 0/imm32
1971 0f 85/jump-if-not-equal $parse-mu-stmt:abort2/disp32
1972
1973 (parse-var Heap %ecx)
1974 (append-list Heap %eax *(edi+8))
1975 89/<- *(edi+8) 0/r32/eax
1976 e9/jump loop/disp32
1977 }
1978 $parse-mu-stmt:end:
1979
1980 89/<- %eax 7/r32/edi
1981
1982 81 0/subop/add %esp 8/imm32
1983
1984 5f/pop-to-edi
1985 59/pop-to-ecx
1986
1987 89/<- %esp 5/r32/ebp
1988 5d/pop-to-ebp
1989 c3/return
1990
1991 $parse-mu-stmt:abort:
1992
1993 (write-buffered Stderr "invalid identifier '")
1994 (write-slice-buffered Stderr %ecx)
1995 (write-buffered Stderr "'\n")
1996 (flush Stderr)
1997
1998 bb/copy-to-ebx 1/imm32
1999 b8/copy-to-eax 1/imm32/exit
2000 cd/syscall 0x80/imm8
2001
2002
2003 $parse-mu-stmt:abort2:
2004
2005 (rewind-stream *(ebp+8))
2006 (write-buffered Stderr "invalid identifier '")
2007 (write-stream Stderr *(ebp+8))
2008 (write-buffered Stderr "'\n")
2009 (flush Stderr)
2010
2011 bb/copy-to-ebx 1/imm32
2012 b8/copy-to-eax 1/imm32/exit
2013 cd/syscall 0x80/imm8
2014
2015
2016 stmt-has-outputs?:
2017
2018 55/push-ebp
2019 89/<- %ebp 4/r32/esp
2020
2021 51/push-ecx
2022
2023 68/push 0/imm32/end
2024 68/push 0/imm32/start
2025 89/<- %ecx 4/r32/esp
2026
2027 b8/copy-to-eax 0/imm32/false
2028 (rewind-stream *(ebp+8))
2029 {
2030 (next-word-or-string *(ebp+8) %ecx)
2031
2032 (slice-empty? %ecx)
2033 3d/compare-eax-and 0/imm32
2034 b8/copy-to-eax 0/imm32/false/result
2035 0f 85/jump-if-not-equal break/disp32
2036
2037
2038 8b/-> *ecx 0/r32/eax
2039 8a/copy-byte *eax 0/r32/AL
2040 81 4/subop/and %eax 0xff/imm32
2041
2042 3d/compare-eax-and 0x23/imm32/hash
2043 b8/copy-to-eax 0/imm32/false/result
2044 0f 84/jump-if-equal break/disp32
2045
2046 (slice-equal? %ecx "<-")
2047 3d/compare-eax-and 0/imm32
2048 74/jump-if-equal loop/disp8
2049 b8/copy-to-eax 1/imm32/true
2050 }
2051 $stmt-has-outputs:end:
2052 (rewind-stream *(ebp+8))
2053
2054 81 0/subop/add %esp 8/imm32
2055
2056 59/pop-to-ecx
2057
2058 89/<- %esp 5/r32/ebp
2059 5d/pop-to-ebp
2060 c3/return
2061
2062 parse-var:
2063
2064 55/push-ebp
2065 89/<- %ebp 4/r32/esp
2066
2067 51/push-ecx
2068
2069 8b/-> *(ebp+0xc) 1/r32/ecx
2070 (slice-to-string Heap %ecx)
2071 89/<- %ecx 0/r32/eax
2072 (allocate *(ebp+8) *Var-size)
2073 89/<- *eax 1/r32/ecx
2074
2075 c7 0/subop/copy *(eax+4) 1/imm32/int-type
2076
2077 c7 0/subop/copy *(eax+0xc) 8/imm32
2078 $parse-var:end:
2079
2080 59/pop-to-ecx
2081
2082 89/<- %esp 5/r32/ebp
2083 5d/pop-to-ebp
2084 c3/return
2085
2086 test-parse-mu-stmt:
2087
2088
2089 55/push-ebp
2090 89/<- %ebp 4/r32/esp
2091
2092 (clear-stream _test-input-stream)
2093 (write _test-input-stream "increment n\n")
2094
2095 (parse-mu-stmt _test-input-stream)
2096
2097 (check-strings-equal *(eax+4) "increment" "F - test-parse-mu-stmt/name")
2098
2099 8b/-> *(eax+8) 2/r32/edx
2100
2101 8b/-> *edx 3/r32/ebx
2102 (check-strings-equal *ebx "n" "F - test-parse-mu-stmt/inout:0")
2103
2104 89/<- %esp 5/r32/ebp
2105 5d/pop-to-ebp
2106 c3/return
2107
2108 new-function:
2109
2110 55/push-ebp
2111 89/<- %ebp 4/r32/esp
2112
2113 51/push-ecx
2114
2115 (allocate *(ebp+8) *Function-size)
2116 8b/-> *(ebp+0xc) 1/r32/ecx
2117 89/<- *eax 1/r32/ecx
2118 8b/-> *(ebp+0x10) 1/r32/ecx
2119 89/<- *(eax+4) 1/r32/ecx
2120 8b/-> *(ebp+0x14) 1/r32/ecx
2121 89/<- *(eax+8) 1/r32/ecx
2122 8b/-> *(ebp+0x18) 1/r32/ecx
2123 89/<- *(eax+0xc) 1/r32/ecx
2124 8b/-> *(ebp+0x1c) 1/r32/ecx
2125 89/<- *(eax+0x10) 1/r32/ecx
2126 8b/-> *(ebp+0x20) 1/r32/ecx
2127 89/<- *(eax+0x14) 1/r32/ecx
2128 $new-function:end:
2129
2130 59/pop-to-ecx
2131
2132 89/<- %esp 5/r32/ebp
2133 5d/pop-to-ebp
2134 c3/return
2135
2136 new-var:
2137
2138 55/push-ebp
2139 89/<- %ebp 4/r32/esp
2140
2141 51/push-ecx
2142
2143 (allocate *(ebp+8) *Var-size)
2144 8b/-> *(ebp+0xc) 1/r32/ecx
2145 89/<- *eax 1/r32/ecx
2146 8b/-> *(ebp+0x10) 1/r32/ecx
2147 89/<- *(eax+4) 1/r32/ecx
2148 8b/-> *(ebp+0x14) 1/r32/ecx
2149 89/<- *(eax+8) 1/r32/ecx
2150 8b/-> *(ebp+0x18) 1/r32/ecx
2151 89/<- *(eax+0xc) 1/r32/ecx
2152 8b/-> *(ebp+0x1c) 1/r32/ecx
2153 89/<- *(eax+0x10) 1/r32/ecx
2154 $new-var:end:
2155
2156 59/pop-to-ecx
2157
2158 89/<- %esp 5/r32/ebp
2159 5d/pop-to-ebp
2160 c3/return
2161
2162 new-block:
2163
2164 55/push-ebp
2165 89/<- %ebp 4/r32/esp
2166
2167 51/push-ecx
2168
2169 (allocate *(ebp+8) *Stmt-size)
2170 c7 0/subop/copy *eax 0/imm32/tag/block
2171 8b/-> *(ebp+0xc) 1/r32/ecx
2172 89/<- *(eax+4) 1/r32/ecx
2173 $new-block:end:
2174
2175 59/pop-to-ecx
2176
2177 89/<- %esp 5/r32/ebp
2178 5d/pop-to-ebp
2179 c3/return
2180
2181 new-stmt:
2182
2183 55/push-ebp
2184 89/<- %ebp 4/r32/esp
2185
2186 51/push-ecx
2187
2188 (allocate *(ebp+8) *Stmt-size)
2189 c7 0/subop/copy *eax 1/imm32/tag/regular-stmt
2190 8b/-> *(ebp+0xc) 1/r32/ecx
2191 89/<- *(eax+4) 1/r32/ecx
2192 8b/-> *(ebp+0x10) 1/r32/ecx
2193 89/<- *(eax+8) 1/r32/ecx
2194 8b/-> *(ebp+0x14) 1/r32/ecx
2195 89/<- *(eax+0xc) 1/r32/ecx
2196 $new-stmt:end:
2197
2198 59/pop-to-ecx
2199
2200 89/<- %esp 5/r32/ebp
2201 5d/pop-to-ebp
2202 c3/return
2203
2204 new-vardef:
2205
2206 55/push-ebp
2207 89/<- %ebp 4/r32/esp
2208
2209 51/push-ecx
2210
2211 (allocate *(ebp+8) *Stmt-size)
2212 c7 0/subop/copy *eax 2/imm32/tag/var-on-stack
2213 8b/-> *(ebp+0xc) 1/r32/ecx
2214 89/<- *(eax+4) 1/r32/ecx
2215 8b/-> *(ebp+0x10) 1/r32/ecx
2216 89/<- *(eax+8) 1/r32/ecx
2217 $new-vardef:end:
2218
2219 59/pop-to-ecx
2220
2221 89/<- %esp 5/r32/ebp
2222 5d/pop-to-ebp
2223 c3/return
2224
2225 new-regvardef:
2226
2227 55/push-ebp
2228 89/<- %ebp 4/r32/esp
2229
2230 51/push-ecx
2231
2232 (allocate *(ebp+8) *Stmt-size)
2233 c7 0/subop/copy *eax 3/imm32/tag/var-in-register
2234 8b/-> *(ebp+0xc) 1/r32/ecx
2235 89/<- *(eax+4) 1/r32/ecx
2236 8b/-> *(ebp+0x10) 1/r32/ecx
2237 89/<- *(eax+8) 1/r32/ecx
2238 8b/-> *(ebp+0x14) 1/r32/ecx
2239 89/<- *(eax+0xc) 1/r32/ecx
2240 $new-regvardef:end:
2241
2242 59/pop-to-ecx
2243
2244 89/<- %esp 5/r32/ebp
2245 5d/pop-to-ebp
2246 c3/return
2247
2248 new-named-block:
2249
2250 55/push-ebp
2251 89/<- %ebp 4/r32/esp
2252
2253 51/push-ecx
2254
2255 (allocate *(ebp+8) *Stmt-size)
2256 c7 0/subop/copy *eax 4/imm32/tag/named-block
2257 8b/-> *(ebp+0xc) 1/r32/ecx
2258 89/<- *(eax+4) 1/r32/ecx
2259 8b/-> *(ebp+0x10) 1/r32/ecx
2260 89/<- *(eax+8) 1/r32/ecx
2261 $new-named-block:end:
2262
2263 59/pop-to-ecx
2264
2265 89/<- %esp 5/r32/ebp
2266 5d/pop-to-ebp
2267 c3/return
2268
2269 new-list:
2270
2271 55/push-ebp
2272 89/<- %ebp 4/r32/esp
2273
2274 51/push-ecx
2275
2276 (allocate *(ebp+8) *List-size)
2277 8b/-> *(ebp+0xc) 1/r32/ecx
2278 89/<- *eax 1/r32/ecx
2279 8b/-> *(ebp+0x10) 1/r32/ecx
2280 89/<- *(eax+4) 1/r32/ecx
2281 $new-list:end:
2282
2283 59/pop-to-ecx
2284
2285 89/<- %esp 5/r32/ebp
2286 5d/pop-to-ebp
2287 c3/return
2288
2289 append-list:
2290
2291 55/push-ebp
2292 89/<- %ebp 4/r32/esp
2293
2294 51/push-ecx
2295
2296 (allocate *(ebp+8) *List-size)
2297 8b/-> *(ebp+0xc) 1/r32/ecx
2298 89/<- *eax 1/r32/ecx
2299
2300 81 7/subop/compare *(ebp+0x10) 0/imm32
2301 74/jump-if-equal $new-list:end/disp8
2302
2303
2304 8b/-> *(ebp+0x10) 1/r32/ecx
2305
2306 {
2307 81 7/subop/compare *(ecx+4) 0/imm32
2308 74/jump-if-equal break/disp8
2309
2310 8b/-> *(ecx+4) 1/r32/ecx
2311 eb/jump loop/disp8
2312 }
2313
2314 89/<- *(ecx+4) 0/r32/eax
2315
2316 8b/-> *(ebp+0x10) 0/r32/eax
2317 $append-list:end:
2318
2319 59/pop-to-ecx
2320
2321 89/<- %esp 5/r32/ebp
2322 5d/pop-to-ebp
2323 c3/return
2324
2325 append-to-block:
2326
2327 55/push-ebp
2328 89/<- %ebp 4/r32/esp
2329
2330 56/push-esi
2331
2332 8b/-> *(ebp+0xc) 6/r32/esi
2333 (append-list *(ebp+8) *(ebp+0x10) *(esi+4))
2334 89/<- *(esi+4) 0/r32/eax
2335 $append-to-block:end:
2336
2337 5e/pop-to-esi
2338
2339 89/<- %esp 5/r32/ebp
2340 5d/pop-to-ebp
2341 c3/return
2342
2343
2344
2345
2346
2347 check-mu-types:
2348
2349 55/push-ebp
2350 89/<- %ebp 4/r32/esp
2351
2352 $check-mu-types:end:
2353
2354 89/<- %esp 5/r32/ebp
2355 5d/pop-to-ebp
2356 c3/return
2357
2358
2359
2360
2361
2362 emit-subx:
2363
2364 55/push-ebp
2365 89/<- %ebp 4/r32/esp
2366
2367 50/push-eax
2368 51/push-ecx
2369 57/push-edi
2370
2371 8b/-> *(ebp+8) 7/r32/edi
2372
2373 8b/-> *Program 1/r32/ecx
2374 {
2375
2376 81 7/subop/compare %ecx 0/imm32
2377 0f 84/jump-if-equal break/disp32
2378 (emit-subx-function %edi %ecx)
2379
2380 8b/-> *(ecx+0x14) 1/r32/ecx
2381 e9/jump loop/disp32
2382 }
2383 $emit-subx:end:
2384
2385 5f/pop-to-edi
2386 59/pop-to-ecx
2387 58/pop-to-eax
2388
2389 89/<- %esp 5/r32/ebp
2390 5d/pop-to-ebp
2391 c3/return
2392
2393 emit-subx-function:
2394
2395 55/push-ebp
2396 89/<- %ebp 4/r32/esp
2397
2398 50/push-eax
2399 51/push-ecx
2400 57/push-edi
2401
2402 8b/-> *(ebp+8) 7/r32/edi
2403
2404 8b/-> *(ebp+0xc) 1/r32/ecx
2405
2406 (write-buffered %edi *ecx)
2407 (write-buffered %edi ":\n")
2408 (emit-subx-prologue %edi)
2409 (emit-subx-block %edi *(ecx+0x10))
2410 (emit-subx-epilogue %edi)
2411 $emit-subx-function:end:
2412
2413 5f/pop-to-edi
2414 59/pop-to-ecx
2415 58/pop-to-eax
2416
2417 89/<- %esp 5/r32/ebp
2418 5d/pop-to-ebp
2419 c3/return
2420
2421 emit-subx-block:
2422
2423 55/push-ebp
2424 89/<- %ebp 4/r32/esp
2425
2426 8b/-> *(ebp+0xc) 6/r32/esi
2427 8b/-> *(esi+4) 6/r32/esi
2428
2429 {
2430 $emit-subx-block:stmt:
2431 81 7/subop/compare %esi 0/imm32
2432 0f 84/jump-if-equal break/disp32
2433 (write-buffered *(ebp+8) "{\n")
2434 {
2435 81 7/subop/compare %esi 0/imm32
2436 74/jump-if-equal break/disp8
2437 (emit-subx-statement *(ebp+8) *esi 0 Primitives 0)
2438 (write-buffered *(ebp+8) Newline)
2439 8b/-> *(esi+4) 6/r32/esi
2440 eb/jump loop/disp8
2441 }
2442 (write-buffered *(ebp+8) "}\n")
2443 }
2444 $emit-subx-block:end:
2445
2446 89/<- %esp 5/r32/ebp
2447 5d/pop-to-ebp
2448 c3/return
2449
2450 emit-subx-statement:
2451
2452 55/push-ebp
2453 89/<- %ebp 4/r32/esp
2454
2455 50/push-eax
2456 51/push-ecx
2457
2458 {
2459 $emit-subx-statement:primitive:
2460 (find-matching-primitive *(ebp+0x14) *(ebp+0xc))
2461 3d/compare-eax-and 0/imm32
2462 74/jump-if-equal break/disp8
2463 (emit-subx-primitive *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax)
2464 e9/jump $emit-subx-statement:end/disp32
2465 }
2466
2467 {
2468 $emit-subx-statement:call:
2469 (find-matching-function *(ebp+0x18) *(ebp+0xc))
2470 3d/compare-eax-and 0/imm32
2471 74/jump-if-equal break/disp8
2472 (emit-subx-call *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax)
2473 e9/jump $emit-subx-statement:end/disp32
2474 }
2475
2476 e9/jump $emit-subx-statement:abort/disp32
2477 $emit-subx-statement:end:
2478
2479 59/pop-to-ecx
2480 58/pop-to-eax
2481
2482 89/<- %esp 5/r32/ebp
2483 5d/pop-to-ebp
2484 c3/return
2485
2486 $emit-subx-statement:abort:
2487
2488 (write-buffered Stderr "couldn't translate '")
2489
2490 (write-buffered Stderr "'\n")
2491 (flush Stderr)
2492
2493 bb/copy-to-ebx 1/imm32
2494 b8/copy-to-eax 1/imm32/exit
2495 cd/syscall 0x80/imm8
2496
2497
2498
2499 == data
2500 Primitives:
2501
2502 "increment"/imm32/name
2503 Single-int-var-on-stack/imm32/inouts
2504 0/imm32/no-outputs
2505 "ff 0/subop/increment"/imm32/subx-name
2506 1/imm32/rm32-is-first-inout
2507 0/imm32/no-r32
2508 0/imm32/no-imm32
2509 _Primitive-inc-reg/imm32/next
2510 _Primitive-inc-reg:
2511
2512 "increment"/imm32/name
2513 0/imm32/no-inouts
2514 Single-int-var-in-some-register/imm32/outputs
2515 "ff 0/subop/increment"/imm32/subx-name
2516 3/imm32/rm32-is-first-output
2517 0/imm32/no-r32
2518 0/imm32/no-imm32
2519 _Primitive-add-reg-to-reg/imm32/next
2520 _Primitive-add-reg-to-reg:
2521
2522 "add"/imm32/name
2523 Single-int-var-in-some-register/imm32/inouts
2524 Single-int-var-in-some-register/imm32/outputs
2525 "01"/imm32/subx-name
2526 3/imm32/rm32-is-first-output
2527 1/imm32/r32-is-first-inout
2528 0/imm32/no-imm32
2529 _Primitive-add-reg-to-mem/imm32/next
2530 _Primitive-add-reg-to-mem:
2531
2532 "add-to"/imm32/name
2533 Int-var-and-second-int-var-in-some-register/imm32/inouts
2534 0/imm32/outputs
2535 "01"/imm32/subx-name
2536 1/imm32/rm32-is-first-inout
2537 2/imm32/r32-is-second-inout
2538 0/imm32/no-imm32
2539 _Primitive-add-mem-to-reg/imm32/next
2540 _Primitive-add-mem-to-reg:
2541
2542 "add"/imm32/name
2543 Single-int-var-on-stack/imm32/inouts
2544 Single-int-var-in-some-register/imm32/outputs
2545 "03"/imm32/subx-name
2546 1/imm32/rm32-is-first-inout
2547 3/imm32/r32-is-first-output
2548 0/imm32/no-imm32
2549 _Primitive-add-lit-to-reg/imm32/next
2550 _Primitive-add-lit-to-reg:
2551
2552 "add"/imm32/name
2553 Single-lit-var/imm32/inouts
2554 Single-int-var-in-some-register/imm32/outputs
2555 "81 0/subop/add"/imm32/subx-name
2556 3/imm32/rm32-is-first-output
2557 0/imm32/no-r32
2558 1/imm32/imm32-is-first-inout
2559 _Primitive-add-lit-to-mem/imm32/next
2560 _Primitive-add-lit-to-mem:
2561
2562 "add-to"/imm32/name
2563 Int-var-and-literal/imm32/inouts
2564 0/imm32/outputs
2565 "81 0/subop/add"/imm32/subx-name
2566 1/imm32/rm32-is-first-inout
2567 0/imm32/no-r32
2568 2/imm32/imm32-is-first-inout
2569 0/imm32/next
2570
2571 Single-int-var-on-stack:
2572 Int-var-on-stack/imm32
2573 0/imm32/next
2574
2575 Int-var-on-stack:
2576 "arg1"/imm32/name
2577 1/imm32/type-int
2578 1/imm32/some-block-depth
2579 1/imm32/some-stack-offset
2580 0/imm32/no-register
2581
2582 Int-var-and-second-int-var-in-some-register:
2583 Int-var-on-stack/imm32
2584 Single-int-var-in-some-register/imm32/next
2585
2586 Int-var-and-literal:
2587 Int-var-on-stack/imm32
2588 Single-lit-var/imm32/next
2589
2590 Single-int-var-in-some-register:
2591 Int-var-in-some-register/imm32
2592 0/imm32/next
2593
2594 Int-var-in-some-register:
2595 "arg1"/imm32/name
2596 1/imm32/type-int
2597 1/imm32/some-block-depth
2598 0/imm32/no-stack-offset
2599 "*"/imm32/register
2600
2601 Single-lit-var:
2602 Lit-var/imm32
2603 0/imm32/next
2604
2605 Lit-var:
2606 "literal"/imm32/name
2607 0/imm32/type-literal
2608 1/imm32/some-block-depth
2609 0/imm32/no-stack-offset
2610 0/imm32/no-register
2611
2612 == code
2613 emit-subx-primitive:
2614
2615 55/push-ebp
2616 89/<- %ebp 4/r32/esp
2617
2618 50/push-eax
2619 51/push-ecx
2620
2621 8b/-> *(ebp+0x14) 1/r32/ecx
2622
2623 (write-buffered *(ebp+8) *(ecx+0xc))
2624
2625 (emit-subx-rm32 *(ebp+8) *(ecx+0x10) *(ebp+0xc))
2626
2627 (emit-subx-r32 *(ebp+8) *(ecx+0x14) *(ebp+0xc))
2628
2629 (emit-subx-imm32 *(ebp+8) *(ecx+0x18) *(ebp+0xc))
2630 $emit-subx-primitive:end:
2631
2632 59/pop-to-ecx
2633 58/pop-to-eax
2634
2635 89/<- %esp 5/r32/ebp
2636 5d/pop-to-ebp
2637 c3/return
2638
2639 emit-subx-rm32:
2640
2641 55/push-ebp
2642 89/<- %ebp 4/r32/esp
2643
2644 50/push-eax
2645
2646 81 7/subop/compare *(ebp+0xc) 0/imm32
2647 74/jump-if-equal $emit-subx-rm32:end/disp8
2648
2649 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
2650 (emit-subx-var-as-rm32 *(ebp+8) %eax)
2651 $emit-subx-rm32:end:
2652
2653 58/pop-to-eax
2654
2655 89/<- %esp 5/r32/ebp
2656 5d/pop-to-ebp
2657 c3/return
2658
2659 get-stmt-operand-from-arg-location:
2660
2661 55/push-ebp
2662 89/<- %ebp 4/r32/esp
2663
2664 51/push-ecx
2665
2666 8b/-> *(ebp+0xc) 0/r32/eax
2667
2668 8b/-> *(ebp+8) 1/r32/ecx
2669
2670 {
2671 3d/compare-eax-and 1/imm32
2672 75/jump-if-not-equal break/disp8
2673 $get-stmt-operand-from-arg-location:1:
2674 8b/-> *(ecx+8) 0/r32/eax
2675 8b/-> *eax 0/r32/eax
2676 eb/jump $get-stmt-operand-from-arg-location:end/disp8
2677 }
2678
2679 {
2680 3d/compare-eax-and 2/imm32
2681 75/jump-if-not-equal break/disp8
2682 $get-stmt-operand-from-arg-location:2:
2683 8b/-> *(ecx+8) 0/r32/eax
2684 8b/-> *(eax+4) 0/r32/eax
2685 8b/-> *eax 0/r32/eax
2686 eb/jump $get-stmt-operand-from-arg-location:end/disp8
2687 }
2688
2689 {
2690 3d/compare-eax-and 3/imm32
2691 75/jump-if-not-equal break/disp8
2692 $get-stmt-operand-from-arg-location:3:
2693 8b/-> *(ecx+0xc) 0/r32/eax
2694 8b/-> *eax 0/r32/eax
2695 eb/jump $get-stmt-operand-from-arg-location:end/disp8
2696 }
2697
2698 e9/jump $get-stmt-operand-from-arg-location:abort/disp32
2699 $get-stmt-operand-from-arg-location:end:
2700
2701 59/pop-to-ecx
2702
2703 89/<- %esp 5/r32/ebp
2704 5d/pop-to-ebp
2705 c3/return
2706
2707 $get-stmt-operand-from-arg-location:abort:
2708
2709 (write-buffered Stderr "invalid arg-location ")
2710 (print-int32-buffered Stderr %eax)
2711 (write-buffered Stderr "\n")
2712 (flush Stderr)
2713
2714 bb/copy-to-ebx 1/imm32
2715 b8/copy-to-eax 1/imm32/exit
2716 cd/syscall 0x80/imm8
2717
2718
2719 emit-subx-r32:
2720
2721 55/push-ebp
2722 89/<- %ebp 4/r32/esp
2723
2724 50/push-eax
2725 51/push-ecx
2726
2727 81 7/subop/compare *(ebp+0xc) 0/imm32
2728 0f 84/jump-if-equal $emit-subx-r32:end/disp32
2729
2730 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
2731 (maybe-get Registers *(eax+0x10) 8)
2732 (write-buffered *(ebp+8) Space)
2733 (print-int32-buffered *(ebp+8) *eax)
2734 (write-buffered *(ebp+8) "/r32")
2735 $emit-subx-r32:end:
2736
2737 59/pop-to-ecx
2738 58/pop-to-eax
2739
2740 89/<- %esp 5/r32/ebp
2741 5d/pop-to-ebp
2742 c3/return
2743
2744 emit-subx-imm32:
2745
2746 55/push-ebp
2747 89/<- %ebp 4/r32/esp
2748
2749 50/push-eax
2750 51/push-ecx
2751
2752 81 7/subop/compare *(ebp+0xc) 0/imm32
2753 74/jump-if-equal $emit-subx-imm32:end/disp8
2754
2755 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
2756 (write-buffered *(ebp+8) Space)
2757 (write-buffered *(ebp+8) *eax)
2758 (write-buffered *(ebp+8) "/imm32")
2759 $emit-subx-imm32:end:
2760
2761 59/pop-to-ecx
2762 58/pop-to-eax
2763
2764 89/<- %esp 5/r32/ebp
2765 5d/pop-to-ebp
2766 c3/return
2767
2768 emit-subx-call:
2769
2770 55/push-ebp
2771 89/<- %ebp 4/r32/esp
2772
2773 50/push-eax
2774 51/push-ecx
2775
2776 (write-buffered *(ebp+8) "(")
2777
2778 8b/-> *(ebp+0x14) 1/r32/ecx
2779 (write-buffered *(ebp+8) *(ecx+4))
2780
2781
2782 8b/-> *(ebp+0xc) 1/r32/ecx
2783 8b/-> *(ecx+8) 1/r32/ecx
2784 {
2785
2786 81 7/subop/compare %ecx 0/imm32
2787 74/jump-if-equal break/disp8
2788
2789 (emit-subx-call-operand *(ebp+8) *ecx)
2790
2791 8b/-> *(ecx+4) 1/r32/ecx
2792 }
2793
2794 (write-buffered *(ebp+8) ")")
2795 $emit-subx-call:end:
2796
2797 59/pop-to-ecx
2798 58/pop-to-eax
2799
2800 89/<- %esp 5/r32/ebp
2801 5d/pop-to-ebp
2802 c3/return
2803
2804 emit-subx-call-operand:
2805
2806 55/push-ebp
2807 89/<- %ebp 4/r32/esp
2808
2809 50/push-eax
2810
2811 8b/-> *(ebp+0xc) 0/r32/eax
2812
2813 (emit-subx-var-as-rm32 *(ebp+8) %eax)
2814
2815 {
2816 81 7/subop/compare *(eax+4) 0/imm32
2817 75/jump-if-not-equal break/disp8
2818 $emit-subx-call-operand:literal:
2819 (write-buffered *(ebp+8) Space)
2820 (write-buffered *(ebp+8) *eax)
2821 }
2822 $emit-subx-call-operand:end:
2823
2824 58/pop-to-eax
2825
2826 89/<- %esp 5/r32/ebp
2827 5d/pop-to-ebp
2828 c3/return
2829
2830 emit-subx-var-as-rm32:
2831
2832 55/push-ebp
2833 89/<- %ebp 4/r32/esp
2834
2835 50/push-eax
2836
2837 8b/-> *(ebp+0xc) 0/r32/eax
2838
2839 {
2840 81 7/subop/compare *(eax+0x10) 0/imm32
2841 74/jump-if-equal break/disp8
2842 $emit-subx-var-as-rm32:register:
2843 (write-buffered *(ebp+8) " %")
2844 (write-buffered *(ebp+8) *(eax+0x10))
2845 }
2846
2847 {
2848 81 7/subop/compare *(eax+0xc) 0/imm32
2849 74/jump-if-equal break/disp8
2850 $emit-subx-var-as-rm32:stack:
2851 (write-buffered *(ebp+8) Space)
2852 (write-buffered *(ebp+8) "*(ebp+")
2853 8b/-> *(ebp+0xc) 0/r32/eax
2854 (print-int32-buffered *(ebp+8) *(eax+0xc))
2855 (write-buffered *(ebp+8) ")")
2856 }
2857 $emit-subx-var-as-rm32:end:
2858
2859 58/pop-to-eax
2860
2861 89/<- %esp 5/r32/ebp
2862 5d/pop-to-ebp
2863 c3/return
2864
2865 find-matching-function:
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
2875 81 7/subop/compare %ecx 0/imm32
2876 74/jump-if-equal break/disp8
2877
2878 {
2879 (mu-stmt-matches-function? *(ebp+0xc) %ecx)
2880 3d/compare-eax-and 0/imm32
2881 74/jump-if-equal break/disp8
2882 89/<- %eax 1/r32/ecx
2883 eb/jump $find-matching-function:end/disp8
2884 }
2885
2886 8b/-> *(ecx+0x10) 1/r32/ecx
2887 eb/jump loop/disp8
2888 }
2889
2890 b8/copy-to-eax 0/imm32
2891 $find-matching-function:end:
2892
2893 59/pop-to-ecx
2894
2895 89/<- %esp 5/r32/ebp
2896 5d/pop-to-ebp
2897 c3/return
2898
2899 find-matching-primitive:
2900
2901 55/push-ebp
2902 89/<- %ebp 4/r32/esp
2903
2904 51/push-ecx
2905
2906 8b/-> *(ebp+8) 1/r32/ecx
2907 {
2908 $find-matching-primitive:loop:
2909
2910 81 7/subop/compare %ecx 0/imm32
2911 74/jump-if-equal break/disp8
2912
2913 {
2914 (mu-stmt-matches-primitive? *(ebp+0xc) %ecx)
2915 3d/compare-eax-and 0/imm32
2916 74/jump-if-equal break/disp8
2917 89/<- %eax 1/r32/ecx
2918 eb/jump $find-matching-function:end/disp8
2919 }
2920 $find-matching-primitive:next-primitive:
2921
2922 8b/-> *(ecx+0x1c) 1/r32/ecx
2923 eb/jump loop/disp8
2924 }
2925
2926 b8/copy-to-eax 0/imm32
2927 $find-matching-primitive:end:
2928
2929 59/pop-to-ecx
2930
2931 89/<- %esp 5/r32/ebp
2932 5d/pop-to-ebp
2933 c3/return
2934
2935 mu-stmt-matches-function?:
2936
2937 55/push-ebp
2938 89/<- %ebp 4/r32/esp
2939
2940 51/push-ecx
2941
2942 8b/-> *(ebp+8) 1/r32/ecx
2943 8b/-> *(ebp+0xc) 0/r32/eax
2944 (string-equal? *(ecx+4) *eax)
2945 $mu-stmt-matches-function?:end:
2946
2947 59/pop-to-ecx
2948
2949 89/<- %esp 5/r32/ebp
2950 5d/pop-to-ebp
2951 c3/return
2952
2953 mu-stmt-matches-primitive?:
2954
2955
2956
2957
2958
2959
2960 55/push-ebp
2961 89/<- %ebp 4/r32/esp
2962
2963 51/push-ecx
2964 52/push-edx
2965 53/push-ebx
2966 56/push-esi
2967 57/push-edi
2968
2969 8b/-> *(ebp+8) 1/r32/ecx
2970
2971 8b/-> *(ebp+0xc) 2/r32/edx
2972 {
2973 $mu-stmt-matches-primitive?:check-name:
2974
2975 (string-equal? *(ecx+4) *edx)
2976 3d/compare-eax-and 0/imm32
2977 75/jump-if-not-equal break/disp8
2978 b8/copy-to-eax 0/imm32
2979 e9/jump $mu-stmt-matches-primitive?:end/disp32
2980 }
2981 $mu-stmt-matches-primitive?:check-inouts:
2982
2983 8b/-> *(ecx+8) 6/r32/esi
2984 8b/-> *(edx+4) 7/r32/edi
2985 {
2986
2987 {
2988 81 7/subop/compare %esi 0/imm32
2989 75/jump-if-not-equal break/disp8
2990 $mu-stmt-matches-primitive?:stmt-inout-is-null:
2991 {
2992 81 7/subop/compare %edi 0/imm32
2993 75/jump-if-not-equal break/disp8
2994
2995 b8/copy-to-eax 1/imm32/true
2996 e9/jump $mu-stmt-matches-primitive?:end/disp32
2997 }
2998
2999 b8/copy-to-eax 0/imm32/false
3000 e9/jump $mu-stmt-matches-primitive?:end/disp32
3001 }
3002
3003 {
3004 81 7/subop/compare %edi 0/imm32
3005 75/jump-if-not-equal break/disp8
3006 $mu-stmt-matches-primitive?:prim-inout-is-null:
3007 b8/copy-to-eax 0/imm32/false
3008 e9/jump $mu-stmt-matches-primitive?:end/disp32
3009 }
3010
3011 {
3012 (operand-matches-primitive? *esi *edi)
3013 3d/compare-eax-and 0/imm32
3014 75/jump-if-not-equal break/disp8
3015 b8/copy-to-eax 0/imm32/false
3016 e9/jump $mu-stmt-matches-primitive?:end/disp32
3017 }
3018
3019 8b/-> *(esi+4) 6/r32/esi
3020
3021 8b/-> *(edi+4) 7/r32/edi
3022 eb/jump loop/disp8
3023 }
3024 $mu-stmt-matches-primitive?:check-outputs:
3025
3026 8b/-> *(ecx+0xc) 6/r32/esi
3027 8b/-> *(edx+8) 7/r32/edi
3028 {
3029
3030 {
3031 81 7/subop/compare %esi 0/imm32
3032 75/jump-if-not-equal break/disp8
3033 {
3034 81 7/subop/compare %edi 0/imm32
3035 75/jump-if-not-equal break/disp8
3036
3037 b8/copy-to-eax 1/imm32
3038 e9/jump $mu-stmt-matches-primitive?:end/disp32
3039 }
3040
3041 b8/copy-to-eax 0/imm32
3042 e9/jump $mu-stmt-matches-primitive?:end/disp32
3043 }
3044
3045 {
3046 81 7/subop/compare %edi 0/imm32
3047 75/jump-if-not-equal break/disp8
3048 b8/copy-to-eax 0/imm32
3049 e9/jump $mu-stmt-matches-primitive?:end/disp32
3050 }
3051
3052 {
3053 (operand-matches-primitive? *esi *edi)
3054 3d/compare-eax-and 0/imm32
3055 75/jump-if-not-equal break/disp8
3056 b8/copy-to-eax 0/imm32
3057 e9/jump $mu-stmt-matches-primitive?:end/disp32
3058 }
3059
3060 8b/-> *(ecx+4) 1/r32/ecx
3061
3062 8b/-> *(edx+4) 2/r32/edx
3063 eb/jump loop/disp8
3064 }
3065 $mu-stmt-matches-primitive?:return-true:
3066 b8/copy-to-eax 1/imm32
3067 $mu-stmt-matches-primitive?:end:
3068
3069 5f/pop-to-edi
3070 5e/pop-to-esi
3071 5b/pop-to-ebx
3072 5a/pop-to-edx
3073 59/pop-to-ecx
3074
3075 89/<- %esp 5/r32/ebp
3076 5d/pop-to-ebp
3077 c3/return
3078
3079 operand-matches-primitive?:
3080
3081 55/push-ebp
3082 89/<- %ebp 4/r32/esp
3083
3084 56/push-esi
3085 57/push-edi
3086
3087 8b/-> *(ebp+8) 6/r32/esi
3088
3089 8b/-> *(ebp+0xc) 7/r32/edi
3090
3091 8b/-> *(esi+4) 0/r32/eax
3092 39/compare *(edi+4) 0/r32/eax
3093 b8/copy-to-eax 0/imm32/false
3094 75/jump-if-not-equal $operand-matches-primitive?:end/disp8
3095
3096 {
3097
3098 8b/-> *(esi+0x10) 0/r32/eax
3099 39/compare *(edi+0x10) 0/r32/eax
3100 74/jump-if-equal break/disp8
3101
3102 3d/compare-eax-and 0/imm32
3103 74/jump-if-equal $operand-matches-primitive?:end/disp8
3104 81 7/subop/compare *(edi+0x10) 0/imm32
3105 74/jump-if-equal $operand-matches-primitive?:end/disp8
3106
3107 (string-equal? *(edi+0x10) "*")
3108 3d/compare-eax-and 0/imm32
3109 b8/copy-to-eax 1/imm32/true
3110 75/jump-if-not-equal $operand-matches-primitive?:end/disp8
3111
3112 (string-equal? *(esi+0x10) *(edi+0x10))
3113 3d/compare-eax-and 0/imm32
3114 b8/copy-to-eax 0/imm32/false
3115 74/jump-if-equal $operand-matches-primitive?:end/disp8
3116 }
3117
3118 b8/copy-to-eax 1/imm32/true
3119 $operand-matches-primitive?:end:
3120
3121 5f/pop-to-edi
3122 5e/pop-to-esi
3123
3124 89/<- %esp 5/r32/ebp
3125 5d/pop-to-ebp
3126 c3/return
3127
3128 test-emit-subx-statement-primitive:
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147 55/push-ebp
3148 89/<- %ebp 4/r32/esp
3149
3150 (clear-stream _test-output-stream)
3151 (clear-stream _test-output-buffered-file->buffer)
3152
3153 68/push 0/imm32/no-register
3154 68/push -8/imm32/stack-offset
3155 68/push 1/imm32/block-depth
3156 68/push 1/imm32/type-int
3157 68/push "foo"/imm32
3158 89/<- %ecx 4/r32/esp
3159
3160 51/push-ecx/var-foo
3161 68/push 1/imm32/data-length
3162 68/push 1/imm32/top
3163 89/<- %edx 4/r32/esp
3164
3165 68/push 0/imm32/next
3166 51/push-ecx/var-foo
3167 89/<- %ebx 4/r32/esp
3168
3169 68/push 0/imm32/next
3170 68/push 0/imm32/outputs
3171 53/push-ebx/operands
3172 68/push "increment"/imm32/operation
3173 68/push 1/imm32
3174 89/<- %esi 4/r32/esp
3175
3176 68/push 0/imm32/next
3177 68/push 0/imm32/no-imm32
3178 68/push 0/imm32/no-r32
3179 68/push 1/imm32/rm32-is-first-inout
3180 68/push "ff 0/subop/increment"/imm32/subx-name
3181 68/push 0/imm32/outputs
3182 53/push-ebx/inouts
3183 68/push "increment"/imm32/name
3184 89/<- %ebx 4/r32/esp
3185
3186 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3187 (flush _test-output-buffered-file)
3188 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3194
3195 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0xfffffff8)" "F - test-emit-subx-statement-primitive")
3196
3197 89/<- %esp 5/r32/ebp
3198 5d/pop-to-ebp
3199 c3/return
3200
3201 test-emit-subx-statement-primitive-register:
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220 55/push-ebp
3221 89/<- %ebp 4/r32/esp
3222
3223 (clear-stream _test-output-stream)
3224 (clear-stream _test-output-buffered-file->buffer)
3225
3226 68/push "eax"/imm32/register
3227 68/push 0/imm32/no-stack-offset
3228 68/push 1/imm32/block-depth
3229 68/push 1/imm32/type-int
3230 68/push "foo"/imm32
3231 89/<- %ecx 4/r32/esp
3232
3233 51/push-ecx/var-foo
3234 68/push 1/imm32/data-length
3235 68/push 1/imm32/top
3236 89/<- %edx 4/r32/esp
3237
3238 68/push 0/imm32/next
3239 51/push-ecx/var-foo
3240 89/<- %ebx 4/r32/esp
3241
3242 68/push 0/imm32/next
3243 53/push-ebx/outputs
3244 68/push 0/imm32/inouts
3245 68/push "increment"/imm32/operation
3246 68/push 1/imm32
3247 89/<- %esi 4/r32/esp
3248
3249 68/push Any-register/imm32
3250 68/push 0/imm32/no-stack-offset
3251 68/push 1/imm32/block-depth
3252 68/push 1/imm32/type-int
3253 68/push "dummy"/imm32
3254 89/<- %ebx 4/r32/esp
3255
3256 68/push 0/imm32/next
3257 53/push-ebx/formal-var
3258 89/<- %ebx 4/r32/esp
3259
3260 68/push 0/imm32/next
3261 68/push 0/imm32/no-imm32
3262 68/push 0/imm32/no-r32
3263 68/push 3/imm32/rm32-in-first-output
3264 68/push "ff 0/subop/increment"/imm32/subx-name
3265 53/push-ebx/outputs
3266 68/push 0/imm32/inouts
3267 68/push "increment"/imm32/name
3268 89/<- %ebx 4/r32/esp
3269
3270 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3271 (flush _test-output-buffered-file)
3272 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3278
3279 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-primitive-register")
3280
3281 89/<- %esp 5/r32/ebp
3282 5d/pop-to-ebp
3283 c3/return
3284
3285 test-emit-subx-statement-select-primitive:
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307 55/push-ebp
3308 89/<- %ebp 4/r32/esp
3309
3310 (clear-stream _test-output-stream)
3311 (clear-stream _test-output-buffered-file->buffer)
3312
3313 68/push "eax"/imm32/register
3314 68/push 0/imm32/no-stack-offset
3315 68/push 1/imm32/block-depth
3316 68/push 1/imm32/type-int
3317 68/push "foo"/imm32
3318 89/<- %ecx 4/r32/esp
3319
3320 51/push-ecx/var-foo
3321 68/push 1/imm32/data-length
3322 68/push 1/imm32/top
3323 89/<- %edx 4/r32/esp
3324
3325 68/push 0/imm32/next
3326 51/push-ecx/var-foo
3327 89/<- %edi 4/r32/esp
3328
3329 68/push 0/imm32/next
3330 57/push-edi/outputs
3331 68/push 0/imm32/inouts
3332 68/push "increment"/imm32/operation
3333 68/push 1/imm32
3334 89/<- %esi 4/r32/esp
3335
3336 68/push Any-register/imm32
3337 68/push 0/imm32/no-stack-offset
3338 68/push 1/imm32/block-depth
3339 68/push 1/imm32/type-int
3340 68/push "dummy"/imm32
3341 89/<- %ebx 4/r32/esp
3342
3343 68/push 0/imm32/next
3344 53/push-ebx/formal-var
3345 89/<- %ebx 4/r32/esp
3346
3347 68/push 0/imm32/next
3348 68/push 0/imm32/no-imm32
3349 68/push 0/imm32/no-r32
3350 68/push 3/imm32/rm32-in-first-output
3351 68/push "ff 0/subop/increment"/imm32/subx-name
3352 53/push-ebx/outputs/formal-outputs
3353 68/push 0/imm32/inouts
3354 68/push "increment"/imm32/name
3355 89/<- %ebx 4/r32/esp
3356
3357 53/push-ebx/next
3358 68/push 0/imm32/no-imm32
3359 68/push 0/imm32/no-r32
3360 68/push 1/imm32/rm32-is-first-inout
3361 68/push "ff 0/subop/increment"/imm32/subx-name
3362 68/push 0/imm32/outputs
3363 57/push-edi/inouts/real-outputs
3364 68/push "increment"/imm32/name
3365 89/<- %ebx 4/r32/esp
3366
3367 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3368 (flush _test-output-buffered-file)
3369 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3375
3376 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive")
3377
3378 89/<- %esp 5/r32/ebp
3379 5d/pop-to-ebp
3380 c3/return
3381
3382 test-emit-subx-statement-select-primitive-2:
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404 55/push-ebp
3405 89/<- %ebp 4/r32/esp
3406
3407 (clear-stream _test-output-stream)
3408 (clear-stream _test-output-buffered-file->buffer)
3409
3410 68/push "eax"/imm32/register
3411 68/push 0/imm32/no-stack-offset
3412 68/push 1/imm32/block-depth
3413 68/push 1/imm32/type-int
3414 68/push "foo"/imm32
3415 89/<- %ecx 4/r32/esp
3416
3417 51/push-ecx/var-foo
3418 68/push 1/imm32/data-length
3419 68/push 1/imm32/top
3420 89/<- %edx 4/r32/esp
3421
3422 68/push 0/imm32/next
3423 51/push-ecx/var-foo
3424 89/<- %edi 4/r32/esp
3425
3426 68/push 0/imm32/next
3427 68/push 0/imm32/outputs
3428 57/push-edi/inouts
3429 68/push "increment"/imm32/operation
3430 68/push 1/imm32
3431 89/<- %esi 4/r32/esp
3432
3433 68/push Any-register/imm32
3434 68/push 0/imm32/no-stack-offset
3435 68/push 1/imm32/block-depth
3436 68/push 1/imm32/type-int
3437 68/push "dummy"/imm32
3438 89/<- %ebx 4/r32/esp
3439
3440 68/push 0/imm32/next
3441 53/push-ebx/formal-var
3442 89/<- %ebx 4/r32/esp
3443
3444 68/push 0/imm32/next
3445 68/push 0/imm32/no-imm32
3446 68/push 0/imm32/no-r32
3447 68/push 3/imm32/rm32-in-first-output
3448 68/push "ff 0/subop/increment"/imm32/subx-name
3449 53/push-ebx/outputs/formal-outputs
3450 68/push 0/imm32/inouts
3451 68/push "increment"/imm32/name
3452 89/<- %ebx 4/r32/esp
3453
3454 53/push-ebx/next
3455 68/push 0/imm32/no-imm32
3456 68/push 0/imm32/no-r32
3457 68/push 1/imm32/rm32-is-first-inout
3458 68/push "ff 0/subop/increment"/imm32/subx-name
3459 68/push 0/imm32/outputs
3460 57/push-edi/inouts/real-outputs
3461 68/push "increment"/imm32/name
3462 89/<- %ebx 4/r32/esp
3463
3464 (emit-subx-statement _test-output-buffered-file %esi %edx %ebx 0)
3465 (flush _test-output-buffered-file)
3466 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3472
3473 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive-2")
3474
3475 89/<- %esp 5/r32/ebp
3476 5d/pop-to-ebp
3477 c3/return
3478
3479 test-increment-register:
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495 55/push-ebp
3496 89/<- %ebp 4/r32/esp
3497
3498 (clear-stream _test-output-stream)
3499 (clear-stream _test-output-buffered-file->buffer)
3500
3501 68/push "eax"/imm32/register
3502 68/push 0/imm32/no-stack-offset
3503 68/push 1/imm32/block-depth
3504 68/push 1/imm32/type-int
3505 68/push "foo"/imm32
3506 89/<- %ecx 4/r32/esp
3507
3508 51/push-ecx/var-foo
3509 68/push 1/imm32/data-length
3510 68/push 1/imm32/top
3511 89/<- %edx 4/r32/esp
3512
3513 68/push 0/imm32/next
3514 51/push-ecx/var-foo
3515 89/<- %edi 4/r32/esp
3516
3517 68/push 0/imm32/next
3518 57/push-edi/outputs
3519 68/push 0/imm32/inouts
3520 68/push "increment"/imm32/operation
3521 68/push 1/imm32
3522 89/<- %esi 4/r32/esp
3523
3524 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0)
3525 (flush _test-output-buffered-file)
3526 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3532
3533 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-register")
3534
3535 89/<- %esp 5/r32/ebp
3536 5d/pop-to-ebp
3537 c3/return
3538
3539 test-increment-var:
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555 55/push-ebp
3556 89/<- %ebp 4/r32/esp
3557
3558 (clear-stream _test-output-stream)
3559 (clear-stream _test-output-buffered-file->buffer)
3560
3561 68/push "eax"/imm32/register
3562 68/push 0/imm32/no-stack-offset
3563 68/push 1/imm32/block-depth
3564 68/push 1/imm32/type-int
3565 68/push "foo"/imm32
3566 89/<- %ecx 4/r32/esp
3567
3568 51/push-ecx/var-foo
3569 68/push 1/imm32/data-length
3570 68/push 1/imm32/top
3571 89/<- %edx 4/r32/esp
3572
3573 68/push 0/imm32/next
3574 51/push-ecx/var-foo
3575 89/<- %edi 4/r32/esp
3576
3577 68/push 0/imm32/next
3578 68/push 0/imm32/outputs
3579 57/push-edi/inouts
3580 68/push "increment"/imm32/operation
3581 68/push 1/imm32
3582 89/<- %esi 4/r32/esp
3583
3584 (emit-subx-statement _test-output-buffered-file %esi %edx Primitives 0)
3585 (flush _test-output-buffered-file)
3586 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3592
3593 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-var")
3594
3595 89/<- %esp 5/r32/ebp
3596 5d/pop-to-ebp
3597 c3/return
3598
3599 test-add-reg-to-reg:
3600
3601
3602
3603
3604
3605 55/push-ebp
3606 89/<- %ebp 4/r32/esp
3607
3608 (clear-stream _test-output-stream)
3609 (clear-stream _test-output-buffered-file->buffer)
3610
3611 68/push "eax"/imm32/register
3612 68/push 0/imm32/no-stack-offset
3613 68/push 1/imm32/block-depth
3614 68/push 1/imm32/type-int
3615 68/push "var1"/imm32
3616 89/<- %ecx 4/r32/esp
3617
3618 68/push "ecx"/imm32/register
3619 68/push 0/imm32/no-stack-offset
3620 68/push 1/imm32/block-depth
3621 68/push 1/imm32/type-int
3622 68/push "var2"/imm32
3623 89/<- %edx 4/r32/esp
3624
3625 68/push 0/imm32/next
3626 52/push-edx/var-var2
3627 89/<- %esi 4/r32/esp
3628
3629 68/push 0/imm32/next
3630 51/push-ecx/var-var1
3631 89/<- %edi 4/r32/esp
3632
3633 68/push 0/imm32/next
3634 57/push-edi/outputs
3635 56/push-esi/inouts
3636 68/push "add"/imm32/operation
3637 68/push 1/imm32
3638 89/<- %esi 4/r32/esp
3639
3640 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3641 (flush _test-output-buffered-file)
3642 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3648
3649 (check-next-stream-line-equal _test-output-stream "01 %eax 0x00000001/r32" "F - test-add-reg-to-reg")
3650
3651 89/<- %esp 5/r32/ebp
3652 5d/pop-to-ebp
3653 c3/return
3654
3655 test-add-reg-to-mem:
3656
3657
3658
3659
3660
3661 55/push-ebp
3662 89/<- %ebp 4/r32/esp
3663
3664 (clear-stream _test-output-stream)
3665 (clear-stream _test-output-buffered-file->buffer)
3666
3667 68/push 0/imm32/no-register
3668 68/push 8/imm32/stack-offset
3669 68/push 1/imm32/block-depth
3670 68/push 1/imm32/type-int
3671 68/push "var1"/imm32
3672 89/<- %ecx 4/r32/esp
3673
3674 68/push "ecx"/imm32/register
3675 68/push 0/imm32/no-stack-offset
3676 68/push 1/imm32/block-depth
3677 68/push 1/imm32/type-int
3678 68/push "var2"/imm32
3679 89/<- %edx 4/r32/esp
3680
3681 68/push 0/imm32/next
3682 52/push-edx/var-var2
3683 89/<- %esi 4/r32/esp
3684
3685 56/push-esi/next
3686 51/push-ecx/var-var1
3687 89/<- %esi 4/r32/esp
3688
3689 68/push 0/imm32/next
3690 68/push 0/imm32/outputs
3691 56/push-esi/inouts
3692 68/push "add-to"/imm32/operation
3693 68/push 1/imm32
3694 89/<- %esi 4/r32/esp
3695
3696 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3697 (flush _test-output-buffered-file)
3698 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3704
3705 (check-next-stream-line-equal _test-output-stream "01 *(ebp+0x00000008) 0x00000001/r32" "F - test-add-reg-to-mem")
3706
3707 89/<- %esp 5/r32/ebp
3708 5d/pop-to-ebp
3709 c3/return
3710
3711 test-add-mem-to-reg:
3712
3713
3714
3715
3716
3717 55/push-ebp
3718 89/<- %ebp 4/r32/esp
3719
3720 (clear-stream _test-output-stream)
3721 (clear-stream _test-output-buffered-file->buffer)
3722
3723 68/push "eax"/imm32/register
3724 68/push 0/imm32/no-stack-offset
3725 68/push 1/imm32/block-depth
3726 68/push 1/imm32/type-int
3727 68/push "var1"/imm32
3728 89/<- %ecx 4/r32/esp
3729
3730 68/push 0/imm32/no-register
3731 68/push 8/imm32/stack-offset
3732 68/push 1/imm32/block-depth
3733 68/push 1/imm32/type-int
3734 68/push "var2"/imm32
3735 89/<- %edx 4/r32/esp
3736
3737 68/push 0/imm32/next
3738 52/push-edx/var-var2
3739 89/<- %esi 4/r32/esp
3740
3741 68/push 0/imm32/next
3742 51/push-ecx/var-var1
3743 89/<- %edi 4/r32/esp
3744
3745 68/push 0/imm32/next
3746 57/push-edi/outputs
3747 56/push-esi/inouts
3748 68/push "add"/imm32/operation
3749 68/push 1/imm32
3750 89/<- %esi 4/r32/esp
3751
3752 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3753 (flush _test-output-buffered-file)
3754 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3760
3761 (check-next-stream-line-equal _test-output-stream "03 *(ebp+0x00000008) 0x00000000/r32" "F - test-add-mem-to-reg")
3762
3763 89/<- %esp 5/r32/ebp
3764 5d/pop-to-ebp
3765 c3/return
3766
3767 test-add-literal-to-reg:
3768
3769
3770
3771
3772
3773 55/push-ebp
3774 89/<- %ebp 4/r32/esp
3775
3776 (clear-stream _test-output-stream)
3777 (clear-stream _test-output-buffered-file->buffer)
3778
3779 68/push "eax"/imm32/register
3780 68/push 0/imm32/no-stack-offset
3781 68/push 1/imm32/block-depth
3782 68/push 1/imm32/type-int
3783 68/push "var1"/imm32
3784 89/<- %ecx 4/r32/esp
3785
3786 68/push 0/imm32/no-register
3787 68/push 0/imm32/no-stack-offset
3788 68/push 1/imm32/block-depth
3789 68/push 0/imm32/type-literal
3790 68/push "0x34"/imm32
3791 89/<- %edx 4/r32/esp
3792
3793 68/push 0/imm32/next
3794 52/push-edx/var-var2
3795 89/<- %esi 4/r32/esp
3796
3797 68/push 0/imm32/next
3798 51/push-ecx/var-var1
3799 89/<- %edi 4/r32/esp
3800
3801 68/push 0/imm32/next
3802 57/push-edi/outputs
3803 56/push-esi/inouts
3804 68/push "add"/imm32/operation
3805 68/push 1/imm32
3806 89/<- %esi 4/r32/esp
3807
3808 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3809 (flush _test-output-buffered-file)
3810 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3816
3817 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %eax 0x34/imm32" "F - test-add-literal-to-reg")
3818
3819 89/<- %esp 5/r32/ebp
3820 5d/pop-to-ebp
3821 c3/return
3822
3823 test-add-literal-to-mem:
3824
3825
3826
3827
3828
3829 55/push-ebp
3830 89/<- %ebp 4/r32/esp
3831
3832 (clear-stream _test-output-stream)
3833 (clear-stream _test-output-buffered-file->buffer)
3834
3835 68/push 0/imm32/no-register
3836 68/push 8/imm32/stack-offset
3837 68/push 1/imm32/block-depth
3838 68/push 1/imm32/type-int
3839 68/push "var1"/imm32
3840 89/<- %ecx 4/r32/esp
3841
3842 68/push 0/imm32/no-register
3843 68/push 0/imm32/no-stack-offset
3844 68/push 1/imm32/block-depth
3845 68/push 0/imm32/type-literal
3846 68/push "0x34"/imm32
3847 89/<- %edx 4/r32/esp
3848
3849 68/push 0/imm32/next
3850 52/push-edx/var-var2
3851 89/<- %esi 4/r32/esp
3852
3853 56/push-esi/next
3854 51/push-ecx/var-var1
3855 89/<- %esi 4/r32/esp
3856
3857 68/push 0/imm32/next
3858 68/push 0/imm32/outputs
3859 56/push-esi/inouts
3860 68/push "add-to"/imm32/operation
3861 68/push 1/imm32
3862 89/<- %esi 4/r32/esp
3863
3864 (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0)
3865 (flush _test-output-buffered-file)
3866 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3872
3873 (check-next-stream-line-equal _test-output-stream "81 0/subop/add *(ebp+0x00000008) 0x34/imm32" "F - test-add-literal-to-mem")
3874
3875 89/<- %esp 5/r32/ebp
3876 5d/pop-to-ebp
3877 c3/return
3878
3879 test-emit-subx-statement-function-call:
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900 55/push-ebp
3901 89/<- %ebp 4/r32/esp
3902
3903 (clear-stream _test-output-stream)
3904 (clear-stream _test-output-buffered-file->buffer)
3905
3906 68/push 0/imm32/no-register
3907 68/push -8/imm32/stack-offset
3908 68/push 0/imm32/block-depth
3909 68/push 1/imm32/type-int
3910 68/push "foo"/imm32
3911 89/<- %ecx 4/r32/esp
3912
3913 51/push-ecx/var-foo
3914 68/push 1/imm32/data-length
3915 68/push 1/imm32/top
3916 89/<- %edx 4/r32/esp
3917
3918 68/push 0/imm32/next
3919 51/push-ecx/var-foo
3920 89/<- %esi 4/r32/esp
3921
3922 68/push 0/imm32/next
3923 68/push 0/imm32/outputs
3924 56/push-esi/inouts
3925 68/push "f"/imm32/operation
3926 68/push 1/imm32
3927 89/<- %esi 4/r32/esp
3928
3929 68/push 0/imm32/next
3930 68/push 0/imm32/body
3931 68/push 0/imm32/outputs
3932 51/push-ecx/inouts
3933 68/push "f2"/imm32/subx-name
3934 68/push "f"/imm32/name
3935 89/<- %ebx 4/r32/esp
3936
3937 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx)
3938 (flush _test-output-buffered-file)
3939 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
3945
3946 (check-next-stream-line-equal _test-output-stream "(f2 *(ebp+0xfffffff8))" "F - test-emit-subx-statement-function-call")
3947
3948 89/<- %esp 5/r32/ebp
3949 5d/pop-to-ebp
3950 c3/return
3951
3952 test-emit-subx-statement-function-call-with-literal-arg:
3953
3954
3955
3956
3957
3958
3959 55/push-ebp
3960 89/<- %ebp 4/r32/esp
3961
3962 (clear-stream _test-output-stream)
3963 (clear-stream _test-output-buffered-file->buffer)
3964
3965 68/push 0/imm32/no-register
3966 68/push 0/imm32/no-stack-offset
3967 68/push 0/imm32/block-depth
3968 68/push 0/imm32/type-literal
3969 68/push "34"/imm32
3970 89/<- %ecx 4/r32/esp
3971
3972 51/push-ecx/var-foo
3973 68/push 1/imm32/data-length
3974 68/push 1/imm32/top
3975 89/<- %edx 4/r32/esp
3976
3977 68/push 0/imm32/next
3978 51/push-ecx/var-foo
3979 89/<- %esi 4/r32/esp
3980
3981 68/push 0/imm32/next
3982 68/push 0/imm32/outputs
3983 56/push-esi/inouts
3984 68/push "f"/imm32/operation
3985 68/push 1/imm32
3986 89/<- %esi 4/r32/esp
3987
3988 68/push 0/imm32/next
3989 68/push 0/imm32/body
3990 68/push 0/imm32/outputs
3991 51/push-ecx/inouts
3992 68/push "f2"/imm32/subx-name
3993 68/push "f"/imm32/name
3994 89/<- %ebx 4/r32/esp
3995
3996 (emit-subx-statement _test-output-buffered-file %esi %edx 0 %ebx)
3997 (flush _test-output-buffered-file)
3998 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4004
4005 (check-next-stream-line-equal _test-output-stream "(f2 34)" "F - test-emit-subx-statement-function-call-with-literal-arg")
4006
4007 89/<- %esp 5/r32/ebp
4008 5d/pop-to-ebp
4009 c3/return
4010
4011 emit-subx-prologue:
4012
4013 55/push-ebp
4014 89/<- %ebp 4/r32/esp
4015
4016 (write-buffered *(ebp+8) "# . prologue\n")
4017 (write-buffered *(ebp+8) "55/push-ebp\n")
4018 (write-buffered *(ebp+8) "89/<- %ebp 4/r32/esp\n")
4019 $emit-subx-prologue:end:
4020
4021 89/<- %esp 5/r32/ebp
4022 5d/pop-to-ebp
4023 c3/return
4024
4025 emit-subx-epilogue:
4026
4027 55/push-ebp
4028 89/<- %ebp 4/r32/esp
4029
4030 (write-buffered *(ebp+8) "# . epilogue\n")
4031 (write-buffered *(ebp+8) "89/<- %esp 5/r32/ebp\n")
4032 (write-buffered *(ebp+8) "5d/pop-to-ebp\n")
4033 (write-buffered *(ebp+8) "c3/return\n")
4034 $emit-subx-epilogue:end:
4035
4036 89/<- %esp 5/r32/ebp
4037 5d/pop-to-ebp
4038 c3/return