https://github.com/akkartik/mu/blob/master/apps/mu.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247 == data
248
249 Program:
250 0/imm32
251
252 Function-name:
253 0/imm32
254 Function-subx-name:
255 4/imm32
256 Function-inouts:
257 8/imm32
258 Function-outputs:
259 0xc/imm32
260 Function-body:
261 0x10/imm32
262 Function-next:
263 0x14/imm32
264 Function-size:
265 0x18/imm32/24
266
267 Primitive-name:
268 0/imm32
269 Primitive-inouts:
270 4/imm32
271 Primitive-outputs:
272 8/imm32
273 Primitive-subx-name:
274 0xc/imm32
275 Primitive-subx-rm32:
276 0x10/imm32
277 Primitive-subx-r32:
278 0x14/imm32
279 Primitive-subx-imm32:
280 0x18/imm32
281 Primitive-write-only-output:
282 0x1c/imm32
283 Primitive-next:
284 0x20/imm32
285 Primitive-size:
286 0x24/imm32/36
287
288 Stmt-tag:
289 0/imm32
290
291 Block-statements:
292 4/imm32
293
294 Stmt1-operation:
295 4/imm32
296 Stmt1-inouts:
297 8/imm32
298 Stmt1-outputs:
299 0xc/imm32
300
301 Vardef-name:
302 4/imm32
303 Vardef-type:
304 8/imm32
305
306 Regvardef-name:
307 4/imm32
308 Regvardef-type:
309 8/imm32
310 Regvardef-register:
311 0xc/imm32
312 Regvardef-operation:
313 0x10/imm32
314 Regvardef-inputs:
315 0x14/imm32
316
317 Named-block-name:
318 4/imm32
319 Named-block-statements:
320 8/imm32
321
322 Stmt-size:
323 0x18/imm32
324
325 Var-name:
326 0/imm32
327 Var-type:
328 4/imm32
329 Var-block:
330 8/imm32
331 Var-stack-offset:
332 0xc/imm32
333 Var-register:
334 0x10/imm32
335 Var-size:
336 0x14/imm32
337
338 Any-register:
339
340 1/imm32
341
342 2a/asterisk
343
344 List-value:
345 0/imm32
346 List-next:
347 4/imm32
348 List-size:
349 8/imm32
350
351 == code
352
353 Entry:
354
355 89/<- %ebp 4/r32/esp
356 (new-segment *Heap-size Heap)
357
358 {
359
360 81 7/subop/compare *ebp 1/imm32
361 7e/jump-if-lesser-or-equal break/disp8
362
363 (kernel-string-equal? *(ebp+8) "test")
364 3d/compare-eax-and 0/imm32
365 74/jump-if-equal break/disp8
366
367 (run-tests)
368
369 8b/-> *Num-test-failures 3/r32/ebx
370 eb/jump $mu-main:end/disp8
371 }
372
373 (convert-mu Stdin Stdout)
374 (flush Stdout)
375
376 bb/copy-to-ebx 0/imm32
377 $mu-main:end:
378 b8/copy-to-eax 1/imm32/exit
379 cd/syscall 0x80/imm8
380
381 convert-mu:
382
383 55/push-ebp
384 89/<- %ebp 4/r32/esp
385
386 (parse-mu *(ebp+8))
387 (check-mu-types)
388 (emit-subx *(ebp+0xc))
389 $convert-mu:end:
390
391 89/<- %esp 5/r32/ebp
392 5d/pop-to-ebp
393 c3/return
394
395 test-convert-empty-input:
396
397
398 55/push-ebp
399 89/<- %ebp 4/r32/esp
400
401 (clear-stream _test-input-stream)
402 (clear-stream $_test-input-buffered-file->buffer)
403 (clear-stream _test-output-stream)
404 (clear-stream $_test-output-buffered-file->buffer)
405
406 (convert-mu _test-input-buffered-file _test-output-buffered-file)
407 (flush _test-output-buffered-file)
408 (check-stream-equal _test-output-stream "" "F - test-convert-empty-input")
409
410 89/<- %esp 5/r32/ebp
411 5d/pop-to-ebp
412 c3/return
413
414 test-convert-function-skeleton:
415
416
417
418
419
420
421
422
423
424
425
426
427
428 55/push-ebp
429 89/<- %ebp 4/r32/esp
430
431 (clear-stream _test-input-stream)
432 (clear-stream $_test-input-buffered-file->buffer)
433 (clear-stream _test-output-stream)
434 (clear-stream $_test-output-buffered-file->buffer)
435
436 (write _test-input-stream "fn foo {\n")
437 (write _test-input-stream "}\n")
438
439 (convert-mu _test-input-buffered-file _test-output-buffered-file)
440 (flush _test-output-buffered-file)
441 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
447
448 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-skeleton/0")
449 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-skeleton/1")
450 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-skeleton/2")
451 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-skeleton/3")
452 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-skeleton/4")
453 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-skeleton/5")
454 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-skeleton/6")
455 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-skeleton/7")
456
457 89/<- %esp 5/r32/ebp
458 5d/pop-to-ebp
459 c3/return
460
461 test-convert-multiple-function-skeletons:
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485 55/push-ebp
486 89/<- %ebp 4/r32/esp
487
488 (clear-stream _test-input-stream)
489 (clear-stream $_test-input-buffered-file->buffer)
490 (clear-stream _test-output-stream)
491 (clear-stream $_test-output-buffered-file->buffer)
492
493 (write _test-input-stream "fn foo {\n")
494 (write _test-input-stream "}\n")
495 (write _test-input-stream "fn bar {\n")
496 (write _test-input-stream "}\n")
497
498 (convert-mu _test-input-buffered-file _test-output-buffered-file)
499 (flush _test-output-buffered-file)
500 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
506
507 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-multiple-function-skeletons/0")
508 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/1")
509 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/2")
510 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/3")
511 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/4")
512 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/5")
513 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/6")
514 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/7")
515
516 (check-next-stream-line-equal _test-output-stream "bar:" "F - test-convert-multiple-function-skeletons/10")
517 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-multiple-function-skeletons/11")
518 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-multiple-function-skeletons/12")
519 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-multiple-function-skeletons/13")
520 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-multiple-function-skeletons/14")
521 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-multiple-function-skeletons/15")
522 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-multiple-function-skeletons/16")
523 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-multiple-function-skeletons/17")
524
525 89/<- %esp 5/r32/ebp
526 5d/pop-to-ebp
527 c3/return
528
529 test-convert-function-with-arg:
530
531
532
533
534
535
536
537
538
539
540
541
542
543 55/push-ebp
544 89/<- %ebp 4/r32/esp
545
546 (clear-stream _test-input-stream)
547 (clear-stream $_test-input-buffered-file->buffer)
548 (clear-stream _test-output-stream)
549 (clear-stream $_test-output-buffered-file->buffer)
550
551 (write _test-input-stream "fn foo n : int {\n")
552 (write _test-input-stream "}\n")
553
554 (convert-mu _test-input-buffered-file _test-output-buffered-file)
555 (flush _test-output-buffered-file)
556 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
562
563 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-with-arg/0")
564 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-with-arg/1")
565 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-with-arg/2")
566 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-with-arg/3")
567 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-with-arg/4")
568 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-with-arg/5")
569 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-with-arg/6")
570 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-with-arg/7")
571
572 89/<- %esp 5/r32/ebp
573 5d/pop-to-ebp
574 c3/return
575
576 test-convert-function-with-arg-and-body:
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594 55/push-ebp
595 89/<- %ebp 4/r32/esp
596
597 (clear-stream _test-input-stream)
598 (clear-stream $_test-input-buffered-file->buffer)
599 (clear-stream _test-output-stream)
600 (clear-stream $_test-output-buffered-file->buffer)
601
602 (write _test-input-stream "fn foo n : int {\n")
603 (write _test-input-stream " increment n\n")
604 (write _test-input-stream "}\n")
605
606 (convert-mu _test-input-buffered-file _test-output-buffered-file)
607 (flush _test-output-buffered-file)
608 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
614
615 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-with-arg-and-body/0")
616 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-with-arg-and-body/1")
617 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-with-arg-and-body/2")
618 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-with-arg-and-body/3")
619 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-with-arg-and-body/4")
620 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0x00000008)" "F - test-convert-function-with-arg-and-body/5")
621 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-with-arg-and-body/6")
622 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-with-arg-and-body/7")
623 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-with-arg-and-body/8")
624 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-with-arg-and-body/9")
625 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-with-arg-and-body/10")
626
627 89/<- %esp 5/r32/ebp
628 5d/pop-to-ebp
629 c3/return
630
631 test-convert-function-distinguishes-args:
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649 55/push-ebp
650 89/<- %ebp 4/r32/esp
651
652 (clear-stream _test-input-stream)
653 (clear-stream $_test-input-buffered-file->buffer)
654 (clear-stream _test-output-stream)
655 (clear-stream $_test-output-buffered-file->buffer)
656
657 (write _test-input-stream "fn foo a: int, b: int {\n")
658 (write _test-input-stream " increment b\n")
659 (write _test-input-stream "}\n")
660
661 (convert-mu _test-input-buffered-file _test-output-buffered-file)
662 (flush _test-output-buffered-file)
663 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
669
670 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-distinguishes-args/0")
671 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-distinguishes-args/1")
672 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-distinguishes-args/2")
673 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-distinguishes-args/3")
674 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-distinguishes-args/4")
675 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0x0000000c)" "F - test-convert-function-distinguishes-args/5")
676 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-distinguishes-args/6")
677 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-distinguishes-args/7")
678 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-distinguishes-args/8")
679 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-distinguishes-args/9")
680 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-distinguishes-args/10")
681
682 89/<- %esp 5/r32/ebp
683 5d/pop-to-ebp
684 c3/return
685
686 test-convert-function-returns-result:
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706 55/push-ebp
707 89/<- %ebp 4/r32/esp
708
709 (clear-stream _test-input-stream)
710 (clear-stream $_test-input-buffered-file->buffer)
711 (clear-stream _test-output-stream)
712 (clear-stream $_test-output-buffered-file->buffer)
713
714 (write _test-input-stream "fn foo a: int, b: int -> result/eax: int {\n")
715 (write _test-input-stream " result <- copy a\n")
716 (write _test-input-stream " result <- increment\n")
717 (write _test-input-stream "}\n")
718
719 (convert-mu _test-input-buffered-file _test-output-buffered-file)
720 (flush _test-output-buffered-file)
721 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
727
728 (check-next-stream-line-equal _test-output-stream "foo:" "F - test-convert-function-returns-result/0")
729 (check-next-stream-line-equal _test-output-stream "# . prologue" "F - test-convert-function-returns-result/1")
730 (check-next-stream-line-equal _test-output-stream "55/push-ebp" "F - test-convert-function-returns-result/2")
731 (check-next-stream-line-equal _test-output-stream "89/<- %ebp 4/r32/esp" "F - test-convert-function-returns-result/3")
732 (check-next-stream-line-equal _test-output-stream "{" "F - test-convert-function-returns-result/4")
733 (check-next-stream-line-equal _test-output-stream "8b/copy-from *(ebp+0x00000008) 0x00000000/r32" "F - test-convert-function-returns-result/5")
734 (check-next-stream-line-equal _test-output-stream "40/increment-eax" "F - test-convert-function-returns-result/6")
735 (check-next-stream-line-equal _test-output-stream "}" "F - test-convert-function-returns-result/7")
736 (check-next-stream-line-equal _test-output-stream "# . epilogue" "F - test-convert-function-returns-result/8")
737 (check-next-stream-line-equal _test-output-stream "89/<- %esp 5/r32/ebp" "F - test-convert-function-returns-result/9")
738 (check-next-stream-line-equal _test-output-stream "5d/pop-to-ebp" "F - test-convert-function-returns-result/10")
739 (check-next-stream-line-equal _test-output-stream "c3/return" "F - test-convert-function-returns-result/11")
740
741 89/<- %esp 5/r32/ebp
742 5d/pop-to-ebp
743 c3/return
744
745
746
747
748
749 parse-mu:
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775 55/push-ebp
776 89/<- %ebp 4/r32/esp
777
778 50/push-eax
779 51/push-ecx
780 52/push-edx
781 53/push-ebx
782 57/push-edi
783
784 81 5/subop/subtract %esp 0x200/imm32
785 68/push 0x200/imm32/length
786 68/push 0/imm32/read
787 68/push 0/imm32/write
788 89/<- %ecx 4/r32/esp
789
790 68/push 0/imm32/end
791 68/push 0/imm32/start
792 89/<- %edx 4/r32/esp
793
794 bf/copy-to-edi Program/imm32
795
796 81 5/subop/subtract %esp 0x400/imm32
797 68/push 0x400/imm32/length
798 68/push 0/imm32/top
799 89/<- %ebx 4/r32/esp
800 {
801 $parse-mu:line-loop:
802 (clear-stream %ecx)
803 (read-line-buffered *(ebp+8) %ecx)
804
805 81 7/subop/compare *ecx 0/imm32
806 0f 84/jump-if-equal break/disp32
807 +-- 6 lines: #? # dump line ---------------------------------------------------------------------------------------------------------------------------
813 (next-word-or-string %ecx %edx)
814
815 (slice-empty? %edx)
816 3d/compare-eax-and 0/imm32
817 0f 85/jump-if-not-equal loop/disp32
818
819
820 8b/-> *edx 0/r32/eax
821 8a/copy-byte *eax 0/r32/AL
822 81 4/subop/and %eax 0xff/imm32
823
824 3d/compare-eax-and 0x23/imm32/hash
825 0f 84/jump-if-equal loop/disp32
826
827 {
828 $parse-mu:fn:
829 (slice-equal? %edx "fn")
830 3d/compare-eax-and 0/imm32
831 0f 84/jump-if-equal break/disp32
832
833 (allocate Heap *Function-size)
834 (zero-out %eax *Function-size)
835 (clear-stack %ebx)
836 (populate-mu-function-header %ecx %eax %ebx)
837 (populate-mu-function-body *(ebp+8) %eax %ebx)
838
839 89/<- *edi 0/r32/eax
840
841 8d/address-> *(eax+0x14) 7/r32/edi
842 e9/jump $parse-mu:line-loop/disp32
843 }
844
845 e9/jump $parse-mu:error1/disp32
846 }
847 $parse-mu:end:
848
849 81 0/subop/add %esp 0x630/imm32
850
851 5f/pop-to-edi
852 5b/pop-to-ebx
853 5a/pop-to-edx
854 59/pop-to-ecx
855 58/pop-to-eax
856
857 89/<- %esp 5/r32/ebp
858 5d/pop-to-ebp
859 c3/return
860
861 $parse-mu:error1:
862
863 (write-buffered Stderr "unexpected top-level command: ")
864 (write-slice-buffered Stderr %edx)
865 (write-buffered Stderr "\n")
866 (flush Stderr)
867
868 bb/copy-to-ebx 1/imm32
869 b8/copy-to-eax 1/imm32/exit
870 cd/syscall 0x80/imm8
871
872
873 $parse-mu:error2:
874
875 (print-int32-buffered Stderr *ebx)
876 (write-buffered Stderr " vars not reclaimed after fn '")
877 (write-slice-buffered Stderr *eax)
878 (write-buffered Stderr "'\n")
879 (flush Stderr)
880
881 bb/copy-to-ebx 1/imm32
882 b8/copy-to-eax 1/imm32/exit
883 cd/syscall 0x80/imm8
884
885
886
887
888
889
890
891
892
893
894
895
896
897 populate-mu-function-header:
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928 55/push-ebp
929 89/<- %ebp 4/r32/esp
930
931 50/push-eax
932 51/push-ecx
933 52/push-edx
934 53/push-ebx
935 57/push-edi
936
937 8b/-> *(ebp+0xc) 7/r32/edi
938
939 68/push 0/imm32/end
940 68/push 0/imm32/start
941 89/<- %ecx 4/r32/esp
942
943 ba/copy-to-edx 8/imm32
944
945 (next-word *(ebp+8) %ecx)
946
947
948 (slice-equal? %ecx "{")
949 3d/compare-eax-and 0/imm32
950 0f 85/jump-if-not-equal $populate-mu-function-header:error1/disp32
951
952 (slice-equal? %ecx "->")
953 3d/compare-eax-and 0/imm32
954 0f 85/jump-if-not-equal $populate-mu-function-header:error1/disp32
955
956 (slice-equal? %ecx "}")
957 3d/compare-eax-and 0/imm32
958 0f 85/jump-if-not-equal $populate-mu-function-header:error1/disp32
959
960 (slice-to-string Heap %ecx)
961 89/<- *edi 0/r32/eax
962
963 {
964 $populate-mu-function-header:check-for-inout:
965 (next-word *(ebp+8) %ecx)
966
967 (slice-equal? %ecx "{")
968 3d/compare-eax-and 0/imm32
969 0f 85/jump-if-not-equal $populate-mu-function-header:done/disp32
970
971 (slice-equal? %ecx "->")
972 3d/compare-eax-and 0/imm32
973 0f 85/jump-if-not-equal break/disp32
974
975 (slice-equal? %ecx "}")
976 3d/compare-eax-and 0/imm32
977 0f 85/jump-if-not-equal $populate-mu-function-header:error1/disp32
978
979 (parse-var-with-type %ecx *(ebp+8))
980 89/<- %ebx 0/r32/eax
981
982 81 7/subop/compare *(ebx+0x10) 0/imm32
983 0f 85/jump-if-not-equal $populate-mu-function-header:error2/disp32
984
985 89/<- *(ebx+0xc) 2/r32/edx
986
987 (size-of %ebx)
988 01/add %edx 0/r32/eax
989
990 (append-list Heap %ebx *(edi+8))
991 89/<- *(edi+8) 0/r32/eax
992 (push *(ebp+0x10) %ebx)
993
994 e9/jump loop/disp32
995 }
996
997 {
998 $parse-var-with-type:check-for-out:
999 (next-word *(ebp+8) %ecx)
1000
1001 (slice-equal? %ecx "{")
1002 3d/compare-eax-and 0/imm32
1003 0f 85/jump-if-not-equal break/disp32
1004
1005 (slice-equal? %ecx "->")
1006 3d/compare-eax-and 0/imm32
1007 0f 85/jump-if-not-equal $populate-mu-function-header:error1/disp32
1008
1009 (slice-equal? %ecx "}")
1010 3d/compare-eax-and 0/imm32
1011 0f 85/jump-if-not-equal $populate-mu-function-header:error1/disp32
1012
1013 (parse-var-with-type %ecx *(ebp+8))
1014 89/<- %ebx 0/r32/eax
1015
1016 81 7/subop/compare *(ebx+0x10) 0/imm32
1017 0f 84/jump-if-equal $populate-mu-function-header:error3/disp32
1018 (append-list Heap %ebx *(edi+0xc))
1019 89/<- *(edi+0xc) 0/r32/eax
1020 e9/jump loop/disp32
1021 }
1022 $populate-mu-function-header:done:
1023 (check-no-tokens-left *(ebp+8))
1024 $populate-mu-function-header:end:
1025
1026 81 0/subop/add %esp 8/imm32
1027
1028 5f/pop-to-edi
1029 5b/pop-to-ebx
1030 5a/pop-to-edx
1031 59/pop-to-ecx
1032 58/pop-to-eax
1033
1034 89/<- %esp 5/r32/ebp
1035 5d/pop-to-ebp
1036 c3/return
1037
1038 $populate-mu-function-header:error1:
1039
1040 (write-buffered Stderr "function header not in form 'fn <name> [inouts] [-> outputs] {' -- '")
1041 (flush Stderr)
1042 (rewind-stream *(ebp+8))
1043 (write-stream 2 *(ebp+8))
1044 (write-buffered Stderr "'\n")
1045 (flush Stderr)
1046
1047 bb/copy-to-ebx 1/imm32
1048 b8/copy-to-eax 1/imm32/exit
1049 cd/syscall 0x80/imm8
1050
1051
1052 $populate-mu-function-header:error2:
1053
1054 (write-buffered Stderr "function input '")
1055 (write-buffered Stderr *ebx)
1056 (write-buffered Stderr "' cannot be in a register")
1057 (flush Stderr)
1058
1059 bb/copy-to-ebx 1/imm32
1060 b8/copy-to-eax 1/imm32/exit
1061 cd/syscall 0x80/imm8
1062
1063
1064 $populate-mu-function-header:error3:
1065
1066 (write-buffered Stderr "function input '")
1067 (write-buffered Stderr *eax)
1068 (write-buffered Stderr " must be in a register'")
1069 (flush Stderr)
1070 (rewind-stream *(ebp+8))
1071 (write-stream 2 *(ebp+8))
1072 (write-buffered Stderr "'\n")
1073 (flush Stderr)
1074
1075 bb/copy-to-ebx 1/imm32
1076 b8/copy-to-eax 1/imm32/exit
1077 cd/syscall 0x80/imm8
1078
1079
1080 test-function-header-with-arg:
1081
1082
1083 55/push-ebp
1084 89/<- %ebp 4/r32/esp
1085
1086 (clear-stream _test-input-stream)
1087 (write _test-input-stream "foo n : int {\n")
1088
1089 2b/subtract-> *Function-size 4/r32/esp
1090 89/<- %ecx 4/r32/esp
1091 (zero-out %ecx *Function-size)
1092
1093 81 5/subop/subtract %esp 0x10/imm32
1094 68/push 0x10/imm32/length
1095 68/push 0/imm32/top
1096 89/<- %ebx 4/r32/esp
1097
1098 (populate-mu-function-header _test-input-stream %ecx %ebx)
1099
1100 (check-strings-equal *ecx "foo" "F - test-function-header-with-arg/name")
1101
1102 8b/-> *(ecx+8) 2/r32/edx
1103
1104 8b/-> *edx 3/r32/ebx
1105 (check-strings-equal *ebx "n" "F - test-function-header-with-arg/inout:0")
1106 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:0/type")
1107
1108 89/<- %esp 5/r32/ebp
1109 5d/pop-to-ebp
1110 c3/return
1111
1112 test-function-header-with-multiple-args:
1113
1114
1115 55/push-ebp
1116 89/<- %ebp 4/r32/esp
1117
1118 (clear-stream _test-input-stream)
1119 (write _test-input-stream "foo a: int, b: int c: int {\n")
1120
1121 2b/subtract-> *Function-size 4/r32/esp
1122 89/<- %ecx 4/r32/esp
1123 (zero-out %ecx *Function-size)
1124
1125 81 5/subop/subtract %esp 0x10/imm32
1126 68/push 0x10/imm32/length
1127 68/push 0/imm32/top
1128 89/<- %ebx 4/r32/esp
1129
1130 (populate-mu-function-header _test-input-stream %ecx %ebx)
1131
1132 (check-strings-equal *ecx "foo")
1133
1134 8b/-> *(ecx+8) 2/r32/edx
1135 $test-function-header-with-multiple-args:inout0:
1136
1137 8b/-> *edx 3/r32/ebx
1138 (check-strings-equal *ebx "a" "F - test-function-header-with-multiple-args/inout:0")
1139 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-multiple-args/inout:0/type")
1140
1141 8b/-> *(edx+4) 2/r32/edx
1142 $test-function-header-with-multiple-args:inout1:
1143
1144 8b/-> *edx 3/r32/ebx
1145 (check-strings-equal *ebx "b" "F - test-function-header-with-multiple-args/inout:1")
1146 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-multiple-args/inout:1/type")
1147
1148 8b/-> *(edx+4) 2/r32/edx
1149 $test-function-header-with-multiple-args:inout2:
1150
1151 8b/-> *edx 3/r32/ebx
1152 (check-strings-equal *ebx "c" "F - test-function-header-with-multiple-args/inout:2")
1153 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-multiple-args/inout:2/type")
1154
1155 89/<- %esp 5/r32/ebp
1156 5d/pop-to-ebp
1157 c3/return
1158
1159 test-function-with-multiple-args-and-outputs:
1160
1161
1162 55/push-ebp
1163 89/<- %ebp 4/r32/esp
1164
1165 (clear-stream _test-input-stream)
1166 (write _test-input-stream "foo a: int, b: int, c: int -> x/ecx: int y/edx : int {\n")
1167
1168 2b/subtract-> *Function-size 4/r32/esp
1169 89/<- %ecx 4/r32/esp
1170 (zero-out %ecx *Function-size)
1171
1172 81 5/subop/subtract %esp 0x10/imm32
1173 68/push 0x10/imm32/length
1174 68/push 0/imm32/top
1175 89/<- %ebx 4/r32/esp
1176
1177 (populate-mu-function-header _test-input-stream %ecx %ebx)
1178
1179 (check-strings-equal *ecx "foo")
1180
1181 8b/-> *(ecx+8) 2/r32/edx
1182
1183 8b/-> *edx 3/r32/ebx
1184 (check-strings-equal *ebx "a" "F - test-function-header-with-multiple-args/inout:0")
1185 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:0/type")
1186
1187 8b/-> *(edx+4) 2/r32/edx
1188
1189 8b/-> *edx 3/r32/ebx
1190 (check-strings-equal *ebx "b" "F - test-function-header-with-multiple-args/inout:1")
1191 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:1/type")
1192
1193 8b/-> *(edx+4) 2/r32/edx
1194
1195 8b/-> *edx 3/r32/ebx
1196 (check-strings-equal *ebx "c" "F - test-function-header-with-multiple-args/inout:2")
1197 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/inout:2/type")
1198
1199 8b/-> *(ecx+0xc) 2/r32/edx
1200
1201 8b/-> *edx 3/r32/ebx
1202 (check-strings-equal *ebx "x" "F - test-function-header-with-multiple-args/output:0")
1203 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/output:0/type")
1204 (check-strings-equal *(ebx+0x10) "ecx" "F - test-function-header-with-arg/output:0/register")
1205
1206 8b/-> *(edx+4) 2/r32/edx
1207
1208 8b/-> *edx 3/r32/ebx
1209 (check-strings-equal *ebx "y" "F - test-function-header-with-multiple-args/output:1")
1210 (check-ints-equal *(ebx+4) 1 "F - test-function-header-with-arg/output:1/type")
1211 (check-strings-equal *(ebx+0x10) "edx" "F - test-function-header-with-arg/output:0/register")
1212
1213 89/<- %esp 5/r32/ebp
1214 5d/pop-to-ebp
1215 c3/return
1216
1217
1218
1219
1220
1221
1222 parse-var-with-type:
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253 55/push-ebp
1254 89/<- %ebp 4/r32/esp
1255
1256 51/push-ecx
1257 52/push-edx
1258 53/push-ebx
1259 56/push-esi
1260 57/push-edi
1261
1262 (allocate Heap *Var-size)
1263 (zero-out %eax *Var-size)
1264 89/<- %edi 0/r32/eax
1265
1266 8b/-> *(ebp+8) 6/r32/esi
1267
1268 68/push 0/imm32/end
1269 68/push 0/imm32/start
1270 89/<- %ecx 4/r32/esp
1271 $parse-var-with-type:save-name:
1272
1273 (next-token-from-slice *esi *(esi+4) 0x2f %ecx)
1274
1275 8b/-> *(ecx+4) 2/r32/edx
1276
1277 {
1278 8b/-> *(ecx+4) 0/r32/eax
1279 48/decrement-eax
1280 8a/copy-byte *eax 3/r32/BL
1281 81 4/subop/and %ebx 0xff/imm32
1282 81 7/subop/compare %ebx 0x3a/imm32/colon
1283 75/jump-if-not-equal break/disp8
1284 89/<- *(ecx+4) 0/r32/eax
1285 }
1286
1287 {
1288 8b/-> *(ecx+4) 0/r32/eax
1289 48/decrement-eax
1290 8a/copy-byte *eax 3/r32/BL
1291 81 4/subop/and %ebx 0xff/imm32
1292 81 7/subop/compare %ebx 0x2c/imm32/comma
1293 75/jump-if-not-equal break/disp8
1294 89/<- *(ecx+4) 0/r32/eax
1295 }
1296 $parse-var-with-type:write-name:
1297 (slice-to-string Heap %ecx)
1298 89/<- *edi 0/r32/eax
1299
1300 $parse-var-with-type:save-register:
1301 (next-token-from-slice %edx *(esi+4) 0x2f %ecx)
1302
1303 {
1304 8b/-> *(ecx+4) 0/r32/eax
1305 48/decrement-eax
1306 8a/copy-byte *eax 3/r32/BL
1307 81 4/subop/and %ebx 0xff/imm32
1308 81 7/subop/compare %ebx 0x3a/imm32/colon
1309 75/jump-if-not-equal break/disp8
1310 89/<- *(ecx+4) 0/r32/eax
1311 }
1312
1313 {
1314 8b/-> *(ecx+4) 0/r32/eax
1315 48/decrement-eax
1316 8a/copy-byte *eax 3/r32/BL
1317 81 4/subop/and %ebx 0xff/imm32
1318 81 7/subop/compare %ebx 0x2c/imm32/comma
1319 75/jump-if-not-equal break/disp8
1320 89/<- *(ecx+4) 0/r32/eax
1321 }
1322
1323 {
1324 $parse-var-with-type:write-register:
1325
1326
1327 8b/-> *ecx 0/r32/eax
1328 39/compare 0/r32/eax *(ecx+4)
1329 76/jump-if-lesser-or-equal break/disp8
1330 (slice-to-string Heap %ecx)
1331 89/<- *(edi+0x10) 0/r32/eax
1332 }
1333
1334 (next-mu-token *(ebp+0xc) %ecx)
1335
1336 (slice-equal? %ecx "{")
1337 3d/compare-eax-and 0/imm32
1338 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1339
1340 (slice-equal? %ecx "->")
1341 3d/compare-eax-and 0/imm32
1342 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1343
1344 (slice-equal? %ecx "}")
1345 3d/compare-eax-and 0/imm32
1346 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1347
1348 (slice-empty? %ecx)
1349 {
1350 3d/compare-eax-and 0/imm32
1351 0f 84/jump-if-equal break/disp32
1352 (next-mu-token *(ebp+0xc) %ecx)
1353
1354 (slice-equal? %ecx "{")
1355 3d/compare-eax-and 0/imm32
1356 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1357
1358 (slice-equal? %ecx "->")
1359 3d/compare-eax-and 0/imm32
1360 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1361
1362 (slice-equal? %ecx "}")
1363 3d/compare-eax-and 0/imm32
1364 0f 85/jump-if-not-equal $parse-var-with-type:abort/disp32
1365 }
1366 (type-for %ecx)
1367 89/<- *(edi+4) 0/r32/eax
1368 $parse-var-with-type:end:
1369
1370 89/<- %eax 7/r32/edi
1371
1372 81 0/subop/add %esp 8/imm32
1373
1374 5f/pop-to-edi
1375 5e/pop-to-esi
1376 5b/pop-to-ebx
1377 5a/pop-to-edx
1378 59/pop-to-ecx
1379
1380 89/<- %esp 5/r32/ebp
1381 5d/pop-to-ebp
1382 c3/return
1383
1384 $parse-var-with-type:abort:
1385
1386 (write-buffered Stderr "var should have form 'name: type' in '")
1387 (flush Stderr)
1388 (rewind-stream *(ebp+0xc))
1389 (write-stream 2 *(ebp+0xc))
1390 (write-buffered Stderr "'\n")
1391 (flush Stderr)
1392
1393 bb/copy-to-ebx 1/imm32
1394 b8/copy-to-eax 1/imm32/exit
1395 cd/syscall 0x80/imm8
1396
1397
1398 next-mu-token:
1399
1400 55/push-ebp
1401 89/<- %ebp 4/r32/esp
1402
1403 50/push-eax
1404 57/push-edi
1405
1406 8b/-> *(ebp+0xc) 7/r32/edi
1407
1408 (next-word *(ebp+8) %edi)
1409
1410 {
1411 8b/-> *(edi+4) 0/r32/eax
1412 48/decrement-eax
1413 8a/copy-byte *eax 3/r32/BL
1414 81 4/subop/and %ebx 0xff/imm32
1415 81 7/subop/compare %ebx 0x3a/imm32/colon
1416 75/jump-if-not-equal break/disp8
1417 89/<- *(edi+4) 0/r32/eax
1418 }
1419
1420 {
1421 8b/-> *(edi+4) 0/r32/eax
1422 48/decrement-eax
1423 8a/copy-byte *eax 3/r32/BL
1424 81 4/subop/and %ebx 0xff/imm32
1425 81 7/subop/compare %ebx 0x2c/imm32/comma
1426 75/jump-if-not-equal break/disp8
1427 89/<- *(edi+4) 0/r32/eax
1428 }
1429 $next-mu-token:end:
1430 b8/copy-to-eax 1/imm32/int
1431
1432 5f/pop-to-edi
1433 58/pop-to-eax
1434
1435 89/<- %esp 5/r32/ebp
1436 5d/pop-to-ebp
1437 c3/return
1438
1439 type-for:
1440
1441 55/push-ebp
1442 89/<- %ebp 4/r32/esp
1443
1444
1445
1446
1447
1448 $type-for:end:
1449 b8/copy-to-eax 1/imm32/int
1450
1451
1452 89/<- %esp 5/r32/ebp
1453 5d/pop-to-ebp
1454 c3/return
1455
1456 test-parse-var-with-type:
1457
1458 55/push-ebp
1459 89/<- %ebp 4/r32/esp
1460
1461 b8/copy-to-eax "x:"/imm32
1462 8b/-> *eax 1/r32/ecx
1463 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1464 05/add-to-eax 4/imm32
1465
1466 51/push-ecx
1467 50/push-eax
1468 89/<- %ecx 4/r32/esp
1469
1470 (clear-stream _test-input-stream)
1471 (write _test-input-stream "int")
1472
1473 (parse-var-with-type %ecx _test-input-stream)
1474 8b/-> *eax 2/r32/edx
1475 (check-strings-equal %edx "x" "F - test-var-with-type/name")
1476 8b/-> *(eax+4) 2/r32/edx
1477 (check-ints-equal %edx 1 "F - test-var-with-type/type")
1478
1479 89/<- %esp 5/r32/ebp
1480 5d/pop-to-ebp
1481 c3/return
1482
1483 test-parse-var-with-type-and-register:
1484
1485 55/push-ebp
1486 89/<- %ebp 4/r32/esp
1487
1488 b8/copy-to-eax "x/eax"/imm32
1489 8b/-> *eax 1/r32/ecx
1490 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1491 05/add-to-eax 4/imm32
1492
1493 51/push-ecx
1494 50/push-eax
1495 89/<- %ecx 4/r32/esp
1496
1497 (clear-stream _test-input-stream)
1498 (write _test-input-stream ": int")
1499
1500 (parse-var-with-type %ecx _test-input-stream)
1501 8b/-> *eax 2/r32/edx
1502 (check-strings-equal %edx "x" "F - test-var-with-type-and-register/name")
1503 8b/-> *(eax+0x10) 2/r32/edx
1504 (check-strings-equal %edx "eax" "F - test-var-with-type-and-register/register")
1505 8b/-> *(eax+4) 2/r32/edx
1506 (check-ints-equal %edx 1 "F - test-var-with-type-and-register/type")
1507
1508 89/<- %esp 5/r32/ebp
1509 5d/pop-to-ebp
1510 c3/return
1511
1512 test-parse-var-with-trailing-characters:
1513
1514 55/push-ebp
1515 89/<- %ebp 4/r32/esp
1516
1517 b8/copy-to-eax "x:"/imm32
1518 8b/-> *eax 1/r32/ecx
1519 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1520 05/add-to-eax 4/imm32
1521
1522 51/push-ecx
1523 50/push-eax
1524 89/<- %ecx 4/r32/esp
1525
1526 (clear-stream _test-input-stream)
1527 (write _test-input-stream "int,")
1528
1529 (parse-var-with-type %ecx _test-input-stream)
1530 8b/-> *eax 2/r32/edx
1531 (check-strings-equal %edx "x" "F - test-var-with-trailing-characters/name")
1532 8b/-> *(eax+0x10) 2/r32/edx
1533 (check-ints-equal %edx 0 "F - test-var-with-trailing-characters/register")
1534 8b/-> *(eax+4) 2/r32/edx
1535 (check-ints-equal %edx 1 "F - test-var-with-trailing-characters/type")
1536
1537 89/<- %esp 5/r32/ebp
1538 5d/pop-to-ebp
1539 c3/return
1540
1541 test-parse-var-with-register-and-trailing-characters:
1542
1543 55/push-ebp
1544 89/<- %ebp 4/r32/esp
1545
1546 b8/copy-to-eax "x/eax:"/imm32
1547 8b/-> *eax 1/r32/ecx
1548 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1549 05/add-to-eax 4/imm32
1550
1551 51/push-ecx
1552 50/push-eax
1553 89/<- %ecx 4/r32/esp
1554
1555 (clear-stream _test-input-stream)
1556 (write _test-input-stream "int,")
1557
1558 (parse-var-with-type %ecx _test-input-stream)
1559 8b/-> *eax 2/r32/edx
1560 (check-strings-equal %edx "x" "F - test-var-with-register-and-trailing-characters/name")
1561 8b/-> *(eax+0x10) 2/r32/edx
1562 (check-strings-equal %edx "eax" "F - test-var-with-register-and-trailing-characters/register")
1563 8b/-> *(eax+4) 2/r32/edx
1564 (check-ints-equal %edx 1 "F - test-var-with-register-and-trailing-characters/type")
1565
1566 89/<- %esp 5/r32/ebp
1567 5d/pop-to-ebp
1568 c3/return
1569
1570
1571
1572
1573 is-identifier?:
1574
1575 55/push-ebp
1576 89/<- %ebp 4/r32/esp
1577
1578 (slice-empty? *(ebp+8))
1579 3d/compare-eax-and 0/imm32
1580 75/jump-if-not-equal $is-identifier?:false/disp8
1581
1582 8b/-> *(ebp+8) 0/r32/eax
1583 8b/-> *eax 0/r32/eax
1584 8a/copy-byte *eax 0/r32/AL
1585 81 4/subop/and %eax 0xff/imm32
1586
1587 3d/compare-eax-and 0x24/imm32/$
1588 74/jump-if-equal $is-identifier?:true/disp8
1589
1590 3d/compare-eax-and 0x5f/imm32/_
1591 74/jump-if-equal $is-identifier?:true/disp8
1592
1593 25/and-eax-with 0x5f/imm32
1594
1595 3d/compare-eax-and 0x41/imm32/A
1596 7c/jump-if-lesser $is-identifier?:false/disp8
1597
1598 3d/compare-eax-and 0x5a/imm32/Z
1599 7f/jump-if-greater $is-identifier?:false/disp8
1600
1601 $is-identifier?:true:
1602 b8/copy-to-eax 1/imm32/true
1603 eb/jump $is-identifier?:end/disp8
1604 $is-identifier?:false:
1605 b8/copy-to-eax 0/imm32/false
1606 $is-identifier?:end:
1607
1608 89/<- %esp 5/r32/ebp
1609 5d/pop-to-ebp
1610 c3/return
1611
1612 test-is-identifier-dollar:
1613
1614 55/push-ebp
1615 89/<- %ebp 4/r32/esp
1616
1617 b8/copy-to-eax "$a"/imm32
1618 8b/-> *eax 1/r32/ecx
1619 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1620 05/add-to-eax 4/imm32
1621
1622 51/push-ecx
1623 50/push-eax
1624 89/<- %ecx 4/r32/esp
1625
1626 (is-identifier? %ecx)
1627 (check-ints-equal %eax 1 "F - test-is-identifier-dollar")
1628
1629 89/<- %esp 5/r32/ebp
1630 5d/pop-to-ebp
1631 c3/return
1632
1633 test-is-identifier-underscore:
1634
1635 55/push-ebp
1636 89/<- %ebp 4/r32/esp
1637
1638 b8/copy-to-eax "_a"/imm32
1639 8b/-> *eax 1/r32/ecx
1640 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1641 05/add-to-eax 4/imm32
1642
1643 51/push-ecx
1644 50/push-eax
1645 89/<- %ecx 4/r32/esp
1646
1647 (is-identifier? %ecx)
1648 (check-ints-equal %eax 1 "F - test-is-identifier-underscore")
1649
1650 89/<- %esp 5/r32/ebp
1651 5d/pop-to-ebp
1652 c3/return
1653
1654 test-is-identifier-a:
1655
1656 55/push-ebp
1657 89/<- %ebp 4/r32/esp
1658
1659 b8/copy-to-eax "a$"/imm32
1660 8b/-> *eax 1/r32/ecx
1661 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1662 05/add-to-eax 4/imm32
1663
1664 51/push-ecx
1665 50/push-eax
1666 89/<- %ecx 4/r32/esp
1667
1668 (is-identifier? %ecx)
1669 (check-ints-equal %eax 1 "F - test-is-identifier-a")
1670
1671 89/<- %esp 5/r32/ebp
1672 5d/pop-to-ebp
1673 c3/return
1674
1675 test-is-identifier-z:
1676
1677 55/push-ebp
1678 89/<- %ebp 4/r32/esp
1679
1680 b8/copy-to-eax "z$"/imm32
1681 8b/-> *eax 1/r32/ecx
1682 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1683 05/add-to-eax 4/imm32
1684
1685 51/push-ecx
1686 50/push-eax
1687 89/<- %ecx 4/r32/esp
1688
1689 (is-identifier? %ecx)
1690 (check-ints-equal %eax 1 "F - test-is-identifier-z")
1691
1692 89/<- %esp 5/r32/ebp
1693 5d/pop-to-ebp
1694 c3/return
1695
1696 test-is-identifier-A:
1697
1698 55/push-ebp
1699 89/<- %ebp 4/r32/esp
1700
1701 b8/copy-to-eax "A$"/imm32
1702 8b/-> *eax 1/r32/ecx
1703 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1704 05/add-to-eax 4/imm32
1705
1706 51/push-ecx
1707 50/push-eax
1708 89/<- %ecx 4/r32/esp
1709
1710 (is-identifier? %ecx)
1711 (check-ints-equal %eax 1 "F - test-is-identifier-A")
1712
1713 89/<- %esp 5/r32/ebp
1714 5d/pop-to-ebp
1715 c3/return
1716
1717 test-is-identifier-Z:
1718
1719 55/push-ebp
1720 89/<- %ebp 4/r32/esp
1721
1722 b8/copy-to-eax "Z$"/imm32
1723 8b/-> *eax 1/r32/ecx
1724 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1725 05/add-to-eax 4/imm32
1726
1727 51/push-ecx
1728 50/push-eax
1729 89/<- %ecx 4/r32/esp
1730
1731 (is-identifier? %ecx)
1732 (check-ints-equal %eax 1 "F - test-is-identifier-Z")
1733
1734 89/<- %esp 5/r32/ebp
1735 5d/pop-to-ebp
1736 c3/return
1737
1738 test-is-identifier-@:
1739
1740
1741 55/push-ebp
1742 89/<- %ebp 4/r32/esp
1743
1744 b8/copy-to-eax "@a"/imm32
1745 8b/-> *eax 1/r32/ecx
1746 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1747 05/add-to-eax 4/imm32
1748
1749 51/push-ecx
1750 50/push-eax
1751 89/<- %ecx 4/r32/esp
1752
1753 (is-identifier? %ecx)
1754 (check-ints-equal %eax 0 "F - test-is-identifier-@")
1755
1756 89/<- %esp 5/r32/ebp
1757 5d/pop-to-ebp
1758 c3/return
1759
1760 test-is-identifier-square-bracket:
1761
1762
1763 55/push-ebp
1764 89/<- %ebp 4/r32/esp
1765
1766 b8/copy-to-eax "[a"/imm32
1767 8b/-> *eax 1/r32/ecx
1768 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1769 05/add-to-eax 4/imm32
1770
1771 51/push-ecx
1772 50/push-eax
1773 89/<- %ecx 4/r32/esp
1774
1775 (is-identifier? %ecx)
1776 (check-ints-equal %eax 0 "F - test-is-identifier-@")
1777
1778 89/<- %esp 5/r32/ebp
1779 5d/pop-to-ebp
1780 c3/return
1781
1782 test-is-identifier-backtick:
1783
1784
1785 55/push-ebp
1786 89/<- %ebp 4/r32/esp
1787
1788 b8/copy-to-eax "`a"/imm32
1789 8b/-> *eax 1/r32/ecx
1790 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1791 05/add-to-eax 4/imm32
1792
1793 51/push-ecx
1794 50/push-eax
1795 89/<- %ecx 4/r32/esp
1796
1797 (is-identifier? %ecx)
1798 (check-ints-equal %eax 0 "F - test-is-identifier-backtick")
1799
1800 89/<- %esp 5/r32/ebp
1801 5d/pop-to-ebp
1802 c3/return
1803
1804 test-is-identifier-curly-brace-open:
1805
1806
1807 55/push-ebp
1808 89/<- %ebp 4/r32/esp
1809
1810 b8/copy-to-eax "{a"/imm32
1811 8b/-> *eax 1/r32/ecx
1812 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1813 05/add-to-eax 4/imm32
1814
1815 51/push-ecx
1816 50/push-eax
1817 89/<- %ecx 4/r32/esp
1818
1819 (is-identifier? %ecx)
1820 (check-ints-equal %eax 0 "F - test-is-identifier-curly-brace-open")
1821
1822 89/<- %esp 5/r32/ebp
1823 5d/pop-to-ebp
1824 c3/return
1825
1826 test-is-identifier-curly-brace-close:
1827
1828 55/push-ebp
1829 89/<- %ebp 4/r32/esp
1830
1831 b8/copy-to-eax "}a"/imm32
1832 8b/-> *eax 1/r32/ecx
1833 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1834 05/add-to-eax 4/imm32
1835
1836 51/push-ecx
1837 50/push-eax
1838 89/<- %ecx 4/r32/esp
1839
1840 (is-identifier? %ecx)
1841 (check-ints-equal %eax 0 "F - test-is-identifier-curly-brace-close")
1842
1843 89/<- %esp 5/r32/ebp
1844 5d/pop-to-ebp
1845 c3/return
1846
1847 test-is-identifier-hyphen:
1848
1849
1850 55/push-ebp
1851 89/<- %ebp 4/r32/esp
1852
1853 b8/copy-to-eax "-a"/imm32
1854 8b/-> *eax 1/r32/ecx
1855 8d/copy-address *(eax+ecx+4) 1/r32/ecx
1856 05/add-to-eax 4/imm32
1857
1858 51/push-ecx
1859 50/push-eax
1860 89/<- %ecx 4/r32/esp
1861
1862 (is-identifier? %ecx)
1863 (check-ints-equal %eax 0 "F - test-is-identifier-hyphen")
1864
1865 89/<- %esp 5/r32/ebp
1866 5d/pop-to-ebp
1867 c3/return
1868
1869 populate-mu-function-body:
1870
1871 55/push-ebp
1872 89/<- %ebp 4/r32/esp
1873
1874 50/push-eax
1875 56/push-esi
1876 57/push-edi
1877
1878 8b/-> *(ebp+8) 6/r32/esi
1879
1880 8b/-> *(ebp+0xc) 7/r32/edi
1881
1882 (parse-mu-block %esi *(ebp+0x10) %edi)
1883
1884 89/<- *(edi+0x10) 0/r32/eax
1885 $populate-mu-function-body:end:
1886
1887 5f/pop-to-edi
1888 5e/pop-to-esi
1889 58/pop-to-eax
1890
1891 89/<- %esp 5/r32/ebp
1892 5d/pop-to-ebp
1893 c3/return
1894
1895
1896 parse-mu-block:
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929 55/push-ebp
1930 89/<- %ebp 4/r32/esp
1931
1932 51/push-ecx
1933 52/push-edx
1934 53/push-ebx
1935 57/push-edi
1936
1937 81 5/subop/subtract %esp 0x200/imm32
1938 68/push 0x200/imm32/length
1939 68/push 0/imm32/read
1940 68/push 0/imm32/write
1941 89/<- %ecx 4/r32/esp
1942
1943 68/push 0/imm32/end
1944 68/push 0/imm32/start
1945 89/<- %edx 4/r32/esp
1946
1947 (allocate Heap *Stmt-size)
1948 (zero-out %eax *Stmt-size)
1949 89/<- %edi 0/r32/eax
1950 {
1951 $parse-mu-block:line-loop:
1952
1953 (clear-stream %ecx)
1954 (read-line-buffered *(ebp+8) %ecx)
1955
1956
1957
1958
1959
1960 81 7/subop/compare *ecx 0/imm32
1961 0f 84/jump-if-equal break/disp32
1962
1963 (next-word %ecx %edx)
1964
1965
1966
1967
1968
1969 (slice-empty? %edx)
1970 3d/compare-eax-and 0/imm32
1971 0f 85/jump-if-not-equal loop/disp32
1972
1973
1974 8b/-> *edx 0/r32/eax
1975 8a/copy-byte *eax 0/r32/AL
1976 81 4/subop/and %eax 0xff/imm32
1977
1978 3d/compare-eax-and 0x23/imm32/hash
1979 0f 84/jump-if-equal loop/disp32
1980
1981 {
1982 $parse-mu-block:check-for-block:
1983 (slice-equal? %edx "{")
1984 3d/compare-eax-and 0/imm32
1985 74/jump-if-equal break/disp8
1986 (check-no-tokens-left %ecx)
1987
1988 (parse-mu-block *(ebp+8) *(ebp+0xc) *(ebp+0x10))
1989 (append-to-block %edi %eax)
1990 e9/jump $parse-mu-block:line-loop/disp32
1991 }
1992
1993 $parse-mu-block:check-for-end:
1994 (slice-equal? %edx "}")
1995 3d/compare-eax-and 0/imm32
1996 0f 85/jump-if-not-equal break/disp32
1997
1998 {
1999 $parse-mu-block:check-for-named-block:
2000
2001 8b/-> *(edx+4) 0/r32/eax
2002 8a/copy-byte *eax 0/r32/AL
2003 81 4/subop/and %eax 0xff/imm32
2004
2005 3d/compare-eax-and 0x23/imm32/hash
2006 0f 85/jump-if-not-equal break/disp32
2007
2008 (parse-mu-named-block %edx %ecx *(ebp+8) *(ebp+0xc) *(ebp+0x10))
2009 (append-to-block %edi %eax)
2010 e9/jump $parse-mu-block:line-loop/disp32
2011 }
2012
2013 {
2014 $parse-mu-block:check-for-var:
2015 (slice-equal? %edx "var")
2016 3d/compare-eax-and 0/imm32
2017 74/jump-if-equal break/disp8
2018
2019 (parse-mu-var-def %ecx *(ebp+0xc))
2020 (append-to-block %edi %eax)
2021 e9/jump $parse-mu-block:line-loop/disp32
2022 }
2023 $parse-mu-block:regular-stmt:
2024
2025 (parse-mu-stmt %ecx *(ebp+0xc) *(ebp+0x10))
2026 (append-to-block Heap %edi %eax)
2027 e9/jump loop/disp32
2028 }
2029
2030 89/<- %eax 7/r32/edi
2031 $parse-mu-block:end:
2032
2033 81 0/subop/add %esp 0x214/imm32
2034
2035 5f/pop-to-edi
2036 5b/pop-to-ebx
2037 5a/pop-to-edx
2038 59/pop-to-ecx
2039
2040 89/<- %esp 5/r32/ebp
2041 5d/pop-to-ebp
2042 c3/return
2043
2044 $parse-mu-block:abort:
2045
2046 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
2047 (rewind-stream %ecx)
2048 (write-stream 2 %ecx)
2049 (write-buffered Stderr "'\n")
2050 (flush Stderr)
2051
2052 bb/copy-to-ebx 1/imm32
2053 b8/copy-to-eax 1/imm32/exit
2054 cd/syscall 0x80/imm8
2055
2056
2057 check-no-tokens-left:
2058
2059 55/push-ebp
2060 89/<- %ebp 4/r32/esp
2061
2062 50/push-eax
2063 51/push-ecx
2064
2065 68/push 0/imm32/end
2066 68/push 0/imm32/start
2067 89/<- %ecx 4/r32/esp
2068
2069 (next-word *(ebp+8) %ecx)
2070
2071 (slice-empty? %ecx)
2072 3d/compare-eax-and 0/imm32
2073 75/jump-if-not-equal $check-no-tokens-left:end/disp8
2074
2075
2076 8b/-> *edx 0/r32/eax
2077 8a/copy-byte *eax 0/r32/AL
2078 81 4/subop/and %eax 0xff/imm32
2079
2080 3d/compare-eax-and 0x23/imm32/hash
2081 74/jump-if-equal $check-no-tokens-left:end/disp8
2082
2083 (write-buffered Stderr "'{' or '}' should be on its own line, but got '")
2084 (rewind-stream %ecx)
2085 (write-stream 2 %ecx)
2086 (write-buffered Stderr "'\n")
2087 (flush Stderr)
2088
2089 bb/copy-to-ebx 1/imm32
2090 b8/copy-to-eax 1/imm32/exit
2091 cd/syscall 0x80/imm8
2092
2093 $check-no-tokens-left:end:
2094
2095 81 0/subop/add %esp 8/imm32
2096
2097 59/pop-to-ecx
2098 58/pop-to-eax
2099
2100 89/<- %esp 5/r32/ebp
2101 5d/pop-to-ebp
2102 c3/return
2103
2104 parse-mu-named-block:
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137 55/push-ebp
2138 89/<- %ebp 4/r32/esp
2139
2140 $parse-mu-named-block:end:
2141
2142
2143
2144 89/<- %esp 5/r32/ebp
2145 5d/pop-to-ebp
2146 c3/return
2147
2148 parse-mu-var-def:
2149
2150
2151
2152 55/push-ebp
2153 89/<- %ebp 4/r32/esp
2154
2155 $parse-mu-var-def:end:
2156
2157
2158
2159 89/<- %esp 5/r32/ebp
2160 5d/pop-to-ebp
2161 c3/return
2162
2163 parse-mu-stmt:
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181 55/push-ebp
2182 89/<- %ebp 4/r32/esp
2183
2184 51/push-ecx
2185 57/push-edi
2186
2187 68/push 0/imm32/end
2188 68/push 0/imm32/start
2189 89/<- %ecx 4/r32/esp
2190
2191 (allocate Heap *Stmt-size)
2192 (zero-out %eax *Stmt-size)
2193 89/<- %edi 0/r32/eax
2194
2195 c7 0/subop/copy *edi 1/imm32/stmt1
2196 {
2197 (stmt-has-outputs? *(ebp+8))
2198 3d/compare-eax-and 0/imm32
2199 0f 84/jump-if-equal break/disp32
2200 {
2201 $parse-mu-stmt:read-outputs:
2202
2203 (next-word *(ebp+8) %ecx)
2204
2205 (slice-empty? %ecx)
2206 3d/compare-eax-and 0/imm32
2207 0f 85/jump-if-not-equal break/disp32
2208
2209 (slice-equal? %ecx "<-")
2210 3d/compare-eax-and 0/imm32
2211 75/jump-if-not-equal break/disp8
2212
2213 (is-identifier? %ecx)
2214 3d/compare-eax-and 0/imm32
2215 0f 84/jump-if-equal $parse-mu-stmt:abort/disp32
2216
2217 (lookup-or-define-var %ecx *(ebp+0xc) *(ebp+0x10))
2218 (append-list Heap %eax *(edi+0xc))
2219 89/<- *(edi+0xc) 0/r32/eax
2220 e9/jump loop/disp32
2221 }
2222 }
2223 $parse-mu-stmt:read-operation:
2224 (next-word *(ebp+8) %ecx)
2225 (slice-to-string Heap %ecx)
2226 89/<- *(edi+4) 0/r32/eax
2227 {
2228 $parse-mu-stmt:read-inouts:
2229
2230 (next-word-or-string *(ebp+8) %ecx)
2231
2232 (slice-empty? %ecx)
2233 3d/compare-eax-and 0/imm32
2234 0f 85/jump-if-not-equal break/disp32
2235
2236 (slice-equal? %ecx "<-")
2237 3d/compare-eax-and 0/imm32
2238 0f 85/jump-if-not-equal $parse-mu-stmt:abort2/disp32
2239
2240 (lookup-var %ecx *(ebp+0xc))
2241 (append-list Heap %eax *(edi+8))
2242 89/<- *(edi+8) 0/r32/eax
2243 e9/jump loop/disp32
2244 }
2245 $parse-mu-stmt:end:
2246
2247 89/<- %eax 7/r32/edi
2248
2249 81 0/subop/add %esp 8/imm32
2250
2251 5f/pop-to-edi
2252 59/pop-to-ecx
2253
2254 89/<- %esp 5/r32/ebp
2255 5d/pop-to-ebp
2256 c3/return
2257
2258 $parse-mu-stmt:abort:
2259
2260 (write-buffered Stderr "invalid identifier '")
2261 (write-slice-buffered Stderr %ecx)
2262 (write-buffered Stderr "'\n")
2263 (flush Stderr)
2264
2265 bb/copy-to-ebx 1/imm32
2266 b8/copy-to-eax 1/imm32/exit
2267 cd/syscall 0x80/imm8
2268
2269
2270 $parse-mu-stmt:abort2:
2271
2272 (rewind-stream *(ebp+8))
2273 (write-buffered Stderr "invalid identifier '")
2274 (write-stream Stderr *(ebp+8))
2275 (write-buffered Stderr "'\n")
2276 (flush Stderr)
2277
2278 bb/copy-to-ebx 1/imm32
2279 b8/copy-to-eax 1/imm32/exit
2280 cd/syscall 0x80/imm8
2281
2282
2283 stmt-has-outputs?:
2284
2285 55/push-ebp
2286 89/<- %ebp 4/r32/esp
2287
2288 51/push-ecx
2289
2290 68/push 0/imm32/end
2291 68/push 0/imm32/start
2292 89/<- %ecx 4/r32/esp
2293
2294 b8/copy-to-eax 0/imm32/false
2295 (rewind-stream *(ebp+8))
2296 {
2297 (next-word-or-string *(ebp+8) %ecx)
2298
2299 (slice-empty? %ecx)
2300 3d/compare-eax-and 0/imm32
2301 b8/copy-to-eax 0/imm32/false/result
2302 0f 85/jump-if-not-equal break/disp32
2303
2304
2305 8b/-> *ecx 0/r32/eax
2306 8a/copy-byte *eax 0/r32/AL
2307 81 4/subop/and %eax 0xff/imm32
2308
2309 3d/compare-eax-and 0x23/imm32/hash
2310 b8/copy-to-eax 0/imm32/false/result
2311 0f 84/jump-if-equal break/disp32
2312
2313 (slice-equal? %ecx "<-")
2314 3d/compare-eax-and 0/imm32
2315 74/jump-if-equal loop/disp8
2316 b8/copy-to-eax 1/imm32/true
2317 }
2318 $stmt-has-outputs:end:
2319 (rewind-stream *(ebp+8))
2320
2321 81 0/subop/add %esp 8/imm32
2322
2323 59/pop-to-ecx
2324
2325 89/<- %esp 5/r32/ebp
2326 5d/pop-to-ebp
2327 c3/return
2328
2329 lookup-var:
2330
2331 55/push-ebp
2332 89/<- %ebp 4/r32/esp
2333
2334 (slice-to-string Heap *(ebp+8))
2335
2336 (lookup-var-helper %eax *(ebp+0xc))
2337
2338 3d/compare-eax-and 0/imm32
2339 74/jump-if-equal $lookup-var:abort/disp8
2340 $lookup-var:end:
2341
2342 89/<- %esp 5/r32/ebp
2343 5d/pop-to-ebp
2344 c3/return
2345
2346 $lookup-var:abort:
2347 (write-buffered Stderr "unknown variable '")
2348 (write-slice-buffered Stderr *(ebp+8))
2349 (write-buffered Stderr "'\n")
2350 (flush Stderr)
2351
2352 bb/copy-to-ebx 1/imm32
2353 b8/copy-to-eax 1/imm32/exit
2354 cd/syscall 0x80/imm8
2355
2356
2357 lookup-var-helper:
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368 55/push-ebp
2369 89/<- %ebp 4/r32/esp
2370
2371 52/push-edx
2372 53/push-ebx
2373 56/push-esi
2374
2375 8b/-> *(ebp+0xc) 6/r32/esi
2376
2377 8b/-> *esi 3/r32/ebx
2378
2379 3b/compare 0/r32/eax *(esi+4)
2380 0f 8f/jump-if-greater $lookup-var-helper:error1/disp32
2381
2382 8d/copy-address *(esi+8) 2/r32/edx
2383
2384 81 5/subop/subtract %ebx 4/imm32
2385 8d/copy-address *(esi+ebx+8) 3/r32/ebx
2386 {
2387
2388 39/compare %ebx 2/r32/edx
2389 b8/copy-to-eax 0/imm32
2390 0f 82/jump-if-lesser-unsigned break/disp32
2391
2392 8b/-> *ebx 0/r32/eax
2393
2394 (string-equal? *eax *(ebp+8))
2395 3d/compare-eax-and 0/imm32
2396 8b/-> *ebx 0/r32/eax
2397 75/jump-if-not-equal break/disp8
2398
2399 81 5/subop/subtract %ebx 4/imm32
2400 e9/jump loop/disp32
2401 }
2402 $lookup-var-helper:end:
2403
2404 5e/pop-to-esi
2405 5b/pop-to-ebx
2406 5a/pop-to-edx
2407
2408 89/<- %esp 5/r32/ebp
2409 5d/pop-to-ebp
2410 c3/return
2411
2412 $lookup-var-helper:error1:
2413 (write-buffered Stderr "malformed stack when looking up '")
2414 (write-slice-buffered Stderr *(ebp+8))
2415 (write-buffered Stderr "'\n")
2416 (flush Stderr)
2417
2418 bb/copy-to-ebx 1/imm32
2419 b8/copy-to-eax 1/imm32/exit
2420 cd/syscall 0x80/imm8
2421
2422
2423 lookup-or-define-var:
2424
2425 55/push-ebp
2426 89/<- %ebp 4/r32/esp
2427
2428 51/push-ecx
2429
2430 (slice-to-string Heap *(ebp+8))
2431 89/<- %ecx 0/r32/eax
2432
2433 (lookup-var-helper *(ebp+8) *(ebp+0xc))
2434 {
2435
2436 3d/compare-eax-and 0/imm32
2437 75/jump-if-not-equal break/disp8
2438
2439 {
2440 (find-in-function-outputs *(ebp+0x10) %ecx)
2441 3d/compare-eax-and 0/imm32
2442
2443 0f 84/jump-if-not-equal $lookup-var:abort/disp32
2444 }
2445 }
2446 $lookup-or-define-var:end:
2447
2448 59/pop-to-ecx
2449
2450 89/<- %esp 5/r32/ebp
2451 5d/pop-to-ebp
2452 c3/return
2453
2454 find-in-function-outputs:
2455
2456 55/push-ebp
2457 89/<- %ebp 4/r32/esp
2458
2459 51/push-ecx
2460
2461 8b/-> *(ebp+8) 1/r32/ecx
2462 8b/-> *(ecx+0xc) 1/r32/ecx
2463
2464 {
2465 81 7/subop/compare %ecx 0/imm32
2466 74/jump-if-equal break/disp8
2467
2468 8b/-> *ecx 0/r32/eax
2469
2470 50/push-eax
2471 (string-equal? *eax *(ebp+0xc))
2472 3d/compare-eax-and 0/imm32
2473 58/pop-to-eax
2474 75/jump-if-not-equal $find-in-function-outputs:end/disp8
2475
2476 8b/-> *(ecx+4) 1/r32/ecx
2477 eb/jump loop/disp8
2478 }
2479 b8/copy-to-eax 0/imm32
2480 $find-in-function-outputs:end:
2481
2482 59/pop-to-ecx
2483
2484 89/<- %esp 5/r32/ebp
2485 5d/pop-to-ebp
2486 c3/return
2487
2488 test-parse-mu-stmt:
2489
2490
2491 55/push-ebp
2492 89/<- %ebp 4/r32/esp
2493
2494 (clear-stream _test-input-stream)
2495 (write _test-input-stream "increment n\n")
2496
2497 81 5/subop/subtract %esp 0x10/imm32
2498 68/push 0x10/imm32/length
2499 68/push 0/imm32/top
2500 89/<- %ecx 4/r32/esp
2501 (clear-stack %ecx)
2502
2503 81 5/subop/subtract %esp 0x14/imm32
2504 89/<- %edx 4/r32/esp
2505 (zero-out %edx 0x14)
2506
2507 c7 0/subop/copy *edx "n"/imm32
2508
2509 (push %ecx %edx)
2510
2511 (parse-mu-stmt _test-input-stream %ecx)
2512
2513 (check-strings-equal *(eax+4) "increment" "F - test-parse-mu-stmt/name")
2514
2515 8b/-> *(eax+8) 2/r32/edx
2516
2517 8b/-> *edx 3/r32/ebx
2518 (check-strings-equal *ebx "n" "F - test-parse-mu-stmt/inout:0")
2519
2520 89/<- %esp 5/r32/ebp
2521 5d/pop-to-ebp
2522 c3/return
2523
2524 new-function:
2525
2526 55/push-ebp
2527 89/<- %ebp 4/r32/esp
2528
2529 51/push-ecx
2530
2531 (allocate *(ebp+8) *Function-size)
2532 8b/-> *(ebp+0xc) 1/r32/ecx
2533 89/<- *eax 1/r32/ecx
2534 8b/-> *(ebp+0x10) 1/r32/ecx
2535 89/<- *(eax+4) 1/r32/ecx
2536 8b/-> *(ebp+0x14) 1/r32/ecx
2537 89/<- *(eax+8) 1/r32/ecx
2538 8b/-> *(ebp+0x18) 1/r32/ecx
2539 89/<- *(eax+0xc) 1/r32/ecx
2540 8b/-> *(ebp+0x1c) 1/r32/ecx
2541 89/<- *(eax+0x10) 1/r32/ecx
2542 8b/-> *(ebp+0x20) 1/r32/ecx
2543 89/<- *(eax+0x14) 1/r32/ecx
2544 $new-function:end:
2545
2546 59/pop-to-ecx
2547
2548 89/<- %esp 5/r32/ebp
2549 5d/pop-to-ebp
2550 c3/return
2551
2552 new-var:
2553
2554 55/push-ebp
2555 89/<- %ebp 4/r32/esp
2556
2557 51/push-ecx
2558
2559 (allocate *(ebp+8) *Var-size)
2560 8b/-> *(ebp+0xc) 1/r32/ecx
2561 89/<- *eax 1/r32/ecx
2562 8b/-> *(ebp+0x10) 1/r32/ecx
2563 89/<- *(eax+4) 1/r32/ecx
2564 8b/-> *(ebp+0x14) 1/r32/ecx
2565 89/<- *(eax+8) 1/r32/ecx
2566 8b/-> *(ebp+0x18) 1/r32/ecx
2567 89/<- *(eax+0xc) 1/r32/ecx
2568 8b/-> *(ebp+0x1c) 1/r32/ecx
2569 89/<- *(eax+0x10) 1/r32/ecx
2570 $new-var:end:
2571
2572 59/pop-to-ecx
2573
2574 89/<- %esp 5/r32/ebp
2575 5d/pop-to-ebp
2576 c3/return
2577
2578 new-block:
2579
2580 55/push-ebp
2581 89/<- %ebp 4/r32/esp
2582
2583 51/push-ecx
2584
2585 (allocate *(ebp+8) *Stmt-size)
2586 (zero-out %eax *Stmt-size)
2587 c7 0/subop/copy *eax 0/imm32/tag/block
2588 8b/-> *(ebp+0xc) 1/r32/ecx
2589 89/<- *(eax+4) 1/r32/ecx
2590 $new-block:end:
2591
2592 59/pop-to-ecx
2593
2594 89/<- %esp 5/r32/ebp
2595 5d/pop-to-ebp
2596 c3/return
2597
2598 new-stmt:
2599
2600 55/push-ebp
2601 89/<- %ebp 4/r32/esp
2602
2603 51/push-ecx
2604
2605 (allocate *(ebp+8) *Stmt-size)
2606 (zero-out %eax *Stmt-size)
2607 c7 0/subop/copy *eax 1/imm32/tag/regular-stmt
2608 8b/-> *(ebp+0xc) 1/r32/ecx
2609 89/<- *(eax+4) 1/r32/ecx
2610 8b/-> *(ebp+0x10) 1/r32/ecx
2611 89/<- *(eax+8) 1/r32/ecx
2612 8b/-> *(ebp+0x14) 1/r32/ecx
2613 89/<- *(eax+0xc) 1/r32/ecx
2614 $new-stmt:end:
2615
2616 59/pop-to-ecx
2617
2618 89/<- %esp 5/r32/ebp
2619 5d/pop-to-ebp
2620 c3/return
2621
2622 new-vardef:
2623
2624 55/push-ebp
2625 89/<- %ebp 4/r32/esp
2626
2627 51/push-ecx
2628
2629 (allocate *(ebp+8) *Stmt-size)
2630 (zero-out %eax *Stmt-size)
2631 c7 0/subop/copy *eax 2/imm32/tag/var-on-stack
2632 8b/-> *(ebp+0xc) 1/r32/ecx
2633 89/<- *(eax+4) 1/r32/ecx
2634 8b/-> *(ebp+0x10) 1/r32/ecx
2635 89/<- *(eax+8) 1/r32/ecx
2636 $new-vardef:end:
2637
2638 59/pop-to-ecx
2639
2640 89/<- %esp 5/r32/ebp
2641 5d/pop-to-ebp
2642 c3/return
2643
2644 new-regvardef:
2645
2646 55/push-ebp
2647 89/<- %ebp 4/r32/esp
2648
2649 51/push-ecx
2650
2651 (allocate *(ebp+8) *Stmt-size)
2652 (zero-out %eax *Stmt-size)
2653 c7 0/subop/copy *eax 3/imm32/tag/var-in-register
2654 8b/-> *(ebp+0xc) 1/r32/ecx
2655 89/<- *(eax+4) 1/r32/ecx
2656 8b/-> *(ebp+0x10) 1/r32/ecx
2657 89/<- *(eax+8) 1/r32/ecx
2658 8b/-> *(ebp+0x14) 1/r32/ecx
2659 89/<- *(eax+0xc) 1/r32/ecx
2660 $new-regvardef:end:
2661
2662 59/pop-to-ecx
2663
2664 89/<- %esp 5/r32/ebp
2665 5d/pop-to-ebp
2666 c3/return
2667
2668 new-named-block:
2669
2670 55/push-ebp
2671 89/<- %ebp 4/r32/esp
2672
2673 51/push-ecx
2674
2675 (allocate *(ebp+8) *Stmt-size)
2676 (zero-out %eax *Stmt-size)
2677 c7 0/subop/copy *eax 4/imm32/tag/named-block
2678 8b/-> *(ebp+0xc) 1/r32/ecx
2679 89/<- *(eax+4) 1/r32/ecx
2680 8b/-> *(ebp+0x10) 1/r32/ecx
2681 89/<- *(eax+8) 1/r32/ecx
2682 $new-named-block:end:
2683
2684 59/pop-to-ecx
2685
2686 89/<- %esp 5/r32/ebp
2687 5d/pop-to-ebp
2688 c3/return
2689
2690 new-list:
2691
2692 55/push-ebp
2693 89/<- %ebp 4/r32/esp
2694
2695 51/push-ecx
2696
2697 (allocate *(ebp+8) *List-size)
2698 8b/-> *(ebp+0xc) 1/r32/ecx
2699 89/<- *eax 1/r32/ecx
2700 8b/-> *(ebp+0x10) 1/r32/ecx
2701 89/<- *(eax+4) 1/r32/ecx
2702 $new-list:end:
2703
2704 59/pop-to-ecx
2705
2706 89/<- %esp 5/r32/ebp
2707 5d/pop-to-ebp
2708 c3/return
2709
2710 append-list:
2711
2712 55/push-ebp
2713 89/<- %ebp 4/r32/esp
2714
2715 51/push-ecx
2716
2717 (allocate *(ebp+8) *List-size)
2718 8b/-> *(ebp+0xc) 1/r32/ecx
2719 89/<- *eax 1/r32/ecx
2720
2721 81 7/subop/compare *(ebp+0x10) 0/imm32
2722 74/jump-if-equal $new-list:end/disp8
2723
2724
2725 8b/-> *(ebp+0x10) 1/r32/ecx
2726
2727 {
2728 81 7/subop/compare *(ecx+4) 0/imm32
2729 74/jump-if-equal break/disp8
2730
2731 8b/-> *(ecx+4) 1/r32/ecx
2732 eb/jump loop/disp8
2733 }
2734
2735 89/<- *(ecx+4) 0/r32/eax
2736
2737 8b/-> *(ebp+0x10) 0/r32/eax
2738 $append-list:end:
2739
2740 59/pop-to-ecx
2741
2742 89/<- %esp 5/r32/ebp
2743 5d/pop-to-ebp
2744 c3/return
2745
2746 append-to-block:
2747
2748 55/push-ebp
2749 89/<- %ebp 4/r32/esp
2750
2751 56/push-esi
2752
2753 8b/-> *(ebp+0xc) 6/r32/esi
2754 (append-list *(ebp+8) *(ebp+0x10) *(esi+4))
2755 89/<- *(esi+4) 0/r32/eax
2756 $append-to-block:end:
2757
2758 5e/pop-to-esi
2759
2760 89/<- %esp 5/r32/ebp
2761 5d/pop-to-ebp
2762 c3/return
2763
2764
2765
2766
2767
2768 check-mu-types:
2769
2770 55/push-ebp
2771 89/<- %ebp 4/r32/esp
2772
2773 $check-mu-types:end:
2774
2775 89/<- %esp 5/r32/ebp
2776 5d/pop-to-ebp
2777 c3/return
2778
2779 size-of:
2780
2781 55/push-ebp
2782 89/<- %ebp 4/r32/esp
2783
2784 b8/copy-to-eax 4/imm32
2785 $size-of:end:
2786
2787 89/<- %esp 5/r32/ebp
2788 5d/pop-to-ebp
2789 c3/return
2790
2791
2792
2793
2794
2795 emit-subx:
2796
2797 55/push-ebp
2798 89/<- %ebp 4/r32/esp
2799
2800 50/push-eax
2801 51/push-ecx
2802 57/push-edi
2803
2804 8b/-> *(ebp+8) 7/r32/edi
2805
2806 8b/-> *Program 1/r32/ecx
2807 {
2808
2809 81 7/subop/compare %ecx 0/imm32
2810 0f 84/jump-if-equal break/disp32
2811 (emit-subx-function %edi %ecx)
2812
2813 8b/-> *(ecx+0x14) 1/r32/ecx
2814 e9/jump loop/disp32
2815 }
2816 $emit-subx:end:
2817
2818 5f/pop-to-edi
2819 59/pop-to-ecx
2820 58/pop-to-eax
2821
2822 89/<- %esp 5/r32/ebp
2823 5d/pop-to-ebp
2824 c3/return
2825
2826 emit-subx-function:
2827
2828 55/push-ebp
2829 89/<- %ebp 4/r32/esp
2830
2831 50/push-eax
2832 51/push-ecx
2833 57/push-edi
2834
2835 8b/-> *(ebp+8) 7/r32/edi
2836
2837 8b/-> *(ebp+0xc) 1/r32/ecx
2838
2839 (write-buffered %edi *ecx)
2840 (write-buffered %edi ":\n")
2841 (emit-subx-prologue %edi)
2842 (emit-subx-block %edi *(ecx+0x10))
2843 (emit-subx-epilogue %edi)
2844 $emit-subx-function:end:
2845
2846 5f/pop-to-edi
2847 59/pop-to-ecx
2848 58/pop-to-eax
2849
2850 89/<- %esp 5/r32/ebp
2851 5d/pop-to-ebp
2852 c3/return
2853
2854 emit-subx-block:
2855
2856 55/push-ebp
2857 89/<- %ebp 4/r32/esp
2858
2859 8b/-> *(ebp+0xc) 6/r32/esi
2860 8b/-> *(esi+4) 6/r32/esi
2861
2862 {
2863 $emit-subx-block:check-empty:
2864 81 7/subop/compare %esi 0/imm32
2865 0f 84/jump-if-equal break/disp32
2866 (write-buffered *(ebp+8) "{\n")
2867 {
2868 $emit-subx-block:stmt:
2869 81 7/subop/compare %esi 0/imm32
2870 74/jump-if-equal break/disp8
2871 (emit-subx-statement *(ebp+8) *esi Primitives 0)
2872 (write-buffered *(ebp+8) Newline)
2873 8b/-> *(esi+4) 6/r32/esi
2874 eb/jump loop/disp8
2875 }
2876 (write-buffered *(ebp+8) "}\n")
2877 }
2878 $emit-subx-block:end:
2879
2880 89/<- %esp 5/r32/ebp
2881 5d/pop-to-ebp
2882 c3/return
2883
2884 emit-subx-statement:
2885
2886 55/push-ebp
2887 89/<- %ebp 4/r32/esp
2888
2889 50/push-eax
2890 51/push-ecx
2891
2892 {
2893 $emit-subx-statement:primitive:
2894 (find-matching-primitive *(ebp+0x10) *(ebp+0xc))
2895 3d/compare-eax-and 0/imm32
2896 74/jump-if-equal break/disp8
2897 (emit-subx-primitive *(ebp+8) *(ebp+0xc) %eax)
2898 e9/jump $emit-subx-statement:end/disp32
2899 }
2900
2901 {
2902 $emit-subx-statement:call:
2903 (find-matching-function *(ebp+0x14) *(ebp+0xc))
2904 3d/compare-eax-and 0/imm32
2905 74/jump-if-equal break/disp8
2906 (emit-subx-call *(ebp+8) *(ebp+0xc) %eax)
2907 e9/jump $emit-subx-statement:end/disp32
2908 }
2909
2910 e9/jump $emit-subx-statement:abort/disp32
2911 $emit-subx-statement:end:
2912
2913 59/pop-to-ecx
2914 58/pop-to-eax
2915
2916 89/<- %esp 5/r32/ebp
2917 5d/pop-to-ebp
2918 c3/return
2919
2920 $emit-subx-statement:abort:
2921
2922 (write-buffered Stderr "couldn't translate '")
2923
2924 (write-buffered Stderr "'\n")
2925 (flush Stderr)
2926
2927 bb/copy-to-ebx 1/imm32
2928 b8/copy-to-eax 1/imm32/exit
2929 cd/syscall 0x80/imm8
2930
2931
2932
2933
2934 == data
2935 Primitives:
2936
2937 _Primitive-inc-eax:
2938
2939 "increment"/imm32/name
2940 0/imm32/no-inouts
2941 Single-int-var-in-eax/imm32/outputs
2942 "40/increment-eax"/imm32/subx-name
2943 0/imm32/no-rm32
2944 0/imm32/no-r32
2945 0/imm32/no-imm32
2946 0/imm32/output-is-write-only
2947 _Primitive-inc-ecx/imm32/next
2948 _Primitive-inc-ecx:
2949
2950 "increment"/imm32/name
2951 0/imm32/no-inouts
2952 Single-int-var-in-ecx/imm32/outputs
2953 "41/increment-ecx"/imm32/subx-name
2954 0/imm32/no-rm32
2955 0/imm32/no-r32
2956 0/imm32/no-imm32
2957 0/imm32/output-is-write-only
2958 _Primitive-inc-edx/imm32/next
2959 _Primitive-inc-edx:
2960
2961 "increment"/imm32/name
2962 0/imm32/no-inouts
2963 Single-int-var-in-edx/imm32/outputs
2964 "42/increment-edx"/imm32/subx-name
2965 0/imm32/no-rm32
2966 0/imm32/no-r32
2967 0/imm32/no-imm32
2968 0/imm32/output-is-write-only
2969 _Primitive-inc-ebx/imm32/next
2970 _Primitive-inc-ebx:
2971
2972 "increment"/imm32/name
2973 0/imm32/no-inouts
2974 Single-int-var-in-ebx/imm32/outputs
2975 "43/increment-ebx"/imm32/subx-name
2976 0/imm32/no-rm32
2977 0/imm32/no-r32
2978 0/imm32/no-imm32
2979 0/imm32/output-is-write-only
2980 _Primitive-inc-esi/imm32/next
2981 _Primitive-inc-esi:
2982
2983 "increment"/imm32/name
2984 0/imm32/no-inouts
2985 Single-int-var-in-esi/imm32/outputs
2986 "46/increment-esi"/imm32/subx-name
2987 0/imm32/no-rm32
2988 0/imm32/no-r32
2989 0/imm32/no-imm32
2990 0/imm32/output-is-write-only
2991 _Primitive-inc-edi/imm32/next
2992 _Primitive-inc-edi:
2993
2994 "increment"/imm32/name
2995 0/imm32/no-inouts
2996 Single-int-var-in-edi/imm32/outputs
2997 "47/increment-edi"/imm32/subx-name
2998 0/imm32/no-rm32
2999 0/imm32/no-r32
3000 0/imm32/no-imm32
3001 0/imm32/output-is-write-only
3002 _Primitive-dec-eax/imm32/next
3003 _Primitive-dec-eax:
3004
3005 "decrement"/imm32/name
3006 0/imm32/no-inouts
3007 Single-int-var-in-eax/imm32/outputs
3008 "48/decrement-eax"/imm32/subx-name
3009 0/imm32/no-rm32
3010 0/imm32/no-r32
3011 0/imm32/no-imm32
3012 0/imm32/output-is-write-only
3013 _Primitive-dec-ecx/imm32/next
3014 _Primitive-dec-ecx:
3015
3016 "decrement"/imm32/name
3017 0/imm32/no-inouts
3018 Single-int-var-in-ecx/imm32/outputs
3019 "49/decrement-ecx"/imm32/subx-name
3020 0/imm32/no-rm32
3021 0/imm32/no-r32
3022 0/imm32/no-imm32
3023 0/imm32/output-is-write-only
3024 _Primitive-dec-edx/imm32/next
3025 _Primitive-dec-edx:
3026
3027 "decrement"/imm32/name
3028 0/imm32/no-inouts
3029 Single-int-var-in-edx/imm32/outputs
3030 "4a/decrement-edx"/imm32/subx-name
3031 0/imm32/no-rm32
3032 0/imm32/no-r32
3033 0/imm32/no-imm32
3034 0/imm32/output-is-write-only
3035 _Primitive-dec-ebx/imm32/next
3036 _Primitive-dec-ebx:
3037
3038 "decrement"/imm32/name
3039 0/imm32/no-inouts
3040 Single-int-var-in-ebx/imm32/outputs
3041 "4b/decrement-ebx"/imm32/subx-name
3042 0/imm32/no-rm32
3043 0/imm32/no-r32
3044 0/imm32/no-imm32
3045 0/imm32/output-is-write-only
3046 _Primitive-dec-esi/imm32/next
3047 _Primitive-dec-esi:
3048
3049 "decrement"/imm32/name
3050 0/imm32/no-inouts
3051 Single-int-var-in-esi/imm32/outputs
3052 "4e/decrement-esi"/imm32/subx-name
3053 0/imm32/no-rm32
3054 0/imm32/no-r32
3055 0/imm32/no-imm32
3056 0/imm32/output-is-write-only
3057 _Primitive-dec-edi/imm32/next
3058 _Primitive-dec-edi:
3059
3060 "decrement"/imm32/name
3061 0/imm32/no-inouts
3062 Single-int-var-in-edi/imm32/outputs
3063 "4f/decrement-edi"/imm32/subx-name
3064 0/imm32/no-rm32
3065 0/imm32/no-r32
3066 0/imm32/no-imm32
3067 0/imm32/output-is-write-only
3068 _Primitive-inc-mem/imm32/next
3069 _Primitive-inc-mem:
3070
3071 "increment"/imm32/name
3072 Single-int-var-on-stack/imm32/inouts
3073 0/imm32/no-outputs
3074 "ff 0/subop/increment"/imm32/subx-name
3075 1/imm32/rm32-is-first-inout
3076 0/imm32/no-r32
3077 0/imm32/no-imm32
3078 0/imm32/output-is-write-only
3079 _Primitive-inc-reg/imm32/next
3080 _Primitive-inc-reg:
3081
3082 "increment"/imm32/name
3083 0/imm32/no-inouts
3084 Single-int-var-in-some-register/imm32/outputs
3085 "ff 0/subop/increment"/imm32/subx-name
3086 3/imm32/rm32-is-first-output
3087 0/imm32/no-r32
3088 0/imm32/no-imm32
3089 0/imm32/output-is-write-only
3090 _Primitive-dec-mem/imm32/next
3091 _Primitive-dec-mem:
3092
3093 "decrement"/imm32/name
3094 Single-int-var-on-stack/imm32/inouts
3095 0/imm32/no-outputs
3096 "ff 1/subop/decrement"/imm32/subx-name
3097 1/imm32/rm32-is-first-inout
3098 0/imm32/no-r32
3099 0/imm32/no-imm32
3100 0/imm32/output-is-write-only
3101 _Primitive-dec-reg/imm32/next
3102 _Primitive-dec-reg:
3103
3104 "decrement"/imm32/name
3105 0/imm32/no-inouts
3106 Single-int-var-in-some-register/imm32/outputs
3107 "ff 1/subop/decrement"/imm32/subx-name
3108 3/imm32/rm32-is-first-output
3109 0/imm32/no-r32
3110 0/imm32/no-imm32
3111 0/imm32/output-is-write-only
3112 _Primitive-add-to-eax/imm32/next
3113
3114 _Primitive-add-to-eax:
3115
3116 "add"/imm32/name
3117 Single-lit-var/imm32/inouts
3118 Single-int-var-in-eax/imm32/outputs
3119 "05/add-to-eax"/imm32/subx-name
3120 0/imm32/no-rm32
3121 0/imm32/no-r32
3122 1/imm32/imm32-is-first-inout
3123 0/imm32/output-is-write-only
3124 _Primitive-add-reg-to-reg/imm32/next
3125 _Primitive-add-reg-to-reg:
3126
3127 "add"/imm32/name
3128 Single-int-var-in-some-register/imm32/inouts
3129 Single-int-var-in-some-register/imm32/outputs
3130 "01/add-to"/imm32/subx-name
3131 3/imm32/rm32-is-first-output
3132 1/imm32/r32-is-first-inout
3133 0/imm32/no-imm32
3134 0/imm32/output-is-write-only
3135 _Primitive-add-reg-to-mem/imm32/next
3136 _Primitive-add-reg-to-mem:
3137
3138 "add-to"/imm32/name
3139 Int-var-and-second-int-var-in-some-register/imm32/inouts
3140 0/imm32/outputs
3141 "01/add-to"/imm32/subx-name
3142 1/imm32/rm32-is-first-inout
3143 2/imm32/r32-is-second-inout
3144 0/imm32/no-imm32
3145 0/imm32/output-is-write-only
3146 _Primitive-add-mem-to-reg/imm32/next
3147 _Primitive-add-mem-to-reg:
3148
3149 "add"/imm32/name
3150 Single-int-var-on-stack/imm32/inouts
3151 Single-int-var-in-some-register/imm32/outputs
3152 "03/add"/imm32/subx-name
3153 1/imm32/rm32-is-first-inout
3154 3/imm32/r32-is-first-output
3155 0/imm32/no-imm32
3156 0/imm32/output-is-write-only
3157 _Primitive-add-lit-to-reg/imm32/next
3158 _Primitive-add-lit-to-reg:
3159
3160 "add"/imm32/name
3161 Single-lit-var/imm32/inouts
3162 Single-int-var-in-some-register/imm32/outputs
3163 "81 0/subop/add"/imm32/subx-name
3164 3/imm32/rm32-is-first-output
3165 0/imm32/no-r32
3166 1/imm32/imm32-is-first-inout
3167 0/imm32/output-is-write-only
3168 _Primitive-add-lit-to-mem/imm32/next
3169 _Primitive-add-lit-to-mem:
3170
3171 "add-to"/imm32/name
3172 Int-var-and-literal/imm32/inouts
3173 0/imm32/outputs
3174 "81 0/subop/add"/imm32/subx-name
3175 1/imm32/rm32-is-first-inout
3176 0/imm32/no-r32
3177 2/imm32/imm32-is-first-inout
3178 0/imm32/output-is-write-only
3179 _Primitive-subtract-from-eax/imm32/next
3180
3181 _Primitive-subtract-from-eax:
3182
3183 "subtract"/imm32/name
3184 Single-lit-var/imm32/inouts
3185 Single-int-var-in-eax/imm32/outputs
3186 "2d/subtract-from-eax"/imm32/subx-name
3187 0/imm32/no-rm32
3188 0/imm32/no-r32
3189 1/imm32/imm32-is-first-inout
3190 0/imm32/output-is-write-only
3191 _Primitive-subtract-reg-from-reg/imm32/next
3192 _Primitive-subtract-reg-from-reg:
3193
3194 "subtract"/imm32/name
3195 Single-int-var-in-some-register/imm32/inouts
3196 Single-int-var-in-some-register/imm32/outputs
3197 "29/subtract-from"/imm32/subx-name
3198 3/imm32/rm32-is-first-output
3199 1/imm32/r32-is-first-inout
3200 0/imm32/no-imm32
3201 0/imm32/output-is-write-only
3202 _Primitive-subtract-reg-from-mem/imm32/next
3203 _Primitive-subtract-reg-from-mem:
3204
3205 "subtract-from"/imm32/name
3206 Int-var-and-second-int-var-in-some-register/imm32/inouts
3207 0/imm32/outputs
3208 "29/subtract-from"/imm32/subx-name
3209 1/imm32/rm32-is-first-inout
3210 2/imm32/r32-is-second-inout
3211 0/imm32/no-imm32
3212 0/imm32/output-is-write-only
3213 _Primitive-subtract-mem-from-reg/imm32/next
3214 _Primitive-subtract-mem-from-reg:
3215
3216 "subtract"/imm32/name
3217 Single-int-var-on-stack/imm32/inouts
3218 Single-int-var-in-some-register/imm32/outputs
3219 "2b/subtract"/imm32/subx-name
3220 1/imm32/rm32-is-first-inout
3221 3/imm32/r32-is-first-output
3222 0/imm32/no-imm32
3223 0/imm32/output-is-write-only
3224 _Primitive-subtract-lit-from-reg/imm32/next
3225 _Primitive-subtract-lit-from-reg:
3226
3227 "subtract"/imm32/name
3228 Single-lit-var/imm32/inouts
3229 Single-int-var-in-some-register/imm32/outputs
3230 "81 5/subop/subtract"/imm32/subx-name
3231 3/imm32/rm32-is-first-output
3232 0/imm32/no-r32
3233 1/imm32/imm32-is-first-inout
3234 0/imm32/output-is-write-only
3235 _Primitive-subtract-lit-from-mem/imm32/next
3236 _Primitive-subtract-lit-from-mem:
3237
3238 "subtract-from"/imm32/name
3239 Int-var-and-literal/imm32/inouts
3240 0/imm32/outputs
3241 "81 5/subop/subtract"/imm32/subx-name
3242 1/imm32/rm32-is-first-inout
3243 0/imm32/no-r32
3244 2/imm32/imm32-is-first-inout
3245 0/imm32/output-is-write-only
3246 _Primitive-and-with-eax/imm32/next
3247
3248 _Primitive-and-with-eax:
3249
3250 "and"/imm32/name
3251 Single-lit-var/imm32/inouts
3252 Single-int-var-in-eax/imm32/outputs
3253 "25/and-with-eax"/imm32/subx-name
3254 0/imm32/no-rm32
3255 0/imm32/no-r32
3256 1/imm32/imm32-is-first-inout
3257 0/imm32/output-is-write-only
3258 _Primitive-and-reg-with-reg/imm32/next
3259 _Primitive-and-reg-with-reg:
3260
3261 "and"/imm32/name
3262 Single-int-var-in-some-register/imm32/inouts
3263 Single-int-var-in-some-register/imm32/outputs
3264 "21/and-with"/imm32/subx-name
3265 3/imm32/rm32-is-first-output
3266 1/imm32/r32-is-first-inout
3267 0/imm32/no-imm32
3268 0/imm32/output-is-write-only
3269 _Primitive-and-reg-with-mem/imm32/next
3270 _Primitive-and-reg-with-mem:
3271
3272 "and-with"/imm32/name
3273 Int-var-and-second-int-var-in-some-register/imm32/inouts
3274 0/imm32/outputs
3275 "21/and-with"/imm32/subx-name
3276 1/imm32/rm32-is-first-inout
3277 2/imm32/r32-is-second-inout
3278 0/imm32/no-imm32
3279 0/imm32/output-is-write-only
3280 _Primitive-and-mem-with-reg/imm32/next
3281 _Primitive-and-mem-with-reg:
3282
3283 "and"/imm32/name
3284 Single-int-var-on-stack/imm32/inouts
3285 Single-int-var-in-some-register/imm32/outputs
3286 "23/and"/imm32/subx-name
3287 1/imm32/rm32-is-first-inout
3288 3/imm32/r32-is-first-output
3289 0/imm32/no-imm32
3290 0/imm32/output-is-write-only
3291 _Primitive-and-lit-with-reg/imm32/next
3292 _Primitive-and-lit-with-reg:
3293
3294 "and"/imm32/name
3295 Single-lit-var/imm32/inouts
3296 Single-int-var-in-some-register/imm32/outputs
3297 "81 4/subop/and"/imm32/subx-name
3298 3/imm32/rm32-is-first-output
3299 0/imm32/no-r32
3300 1/imm32/imm32-is-first-inout
3301 0/imm32/output-is-write-only
3302 _Primitive-and-lit-with-mem/imm32/next
3303 _Primitive-and-lit-with-mem:
3304
3305 "and-with"/imm32/name
3306 Int-var-and-literal/imm32/inouts
3307 0/imm32/outputs
3308 "81 4/subop/and"/imm32/subx-name
3309 1/imm32/rm32-is-first-inout
3310 0/imm32/no-r32
3311 2/imm32/imm32-is-first-inout
3312 0/imm32/output-is-write-only
3313 _Primitive-or-with-eax/imm32/next
3314
3315 _Primitive-or-with-eax:
3316
3317 "or"/imm32/name
3318 Single-lit-var/imm32/inouts
3319 Single-int-var-in-eax/imm32/outputs
3320 "0d/or-with-eax"/imm32/subx-name
3321 0/imm32/no-rm32
3322 0/imm32/no-r32
3323 1/imm32/imm32-is-first-inout
3324 0/imm32/output-is-write-only
3325 _Primitive-or-reg-with-reg/imm32/next
3326 _Primitive-or-reg-with-reg:
3327
3328 "or"/imm32/name
3329 Single-int-var-in-some-register/imm32/inouts
3330 Single-int-var-in-some-register/imm32/outputs
3331 "09/or-with"/imm32/subx-name
3332 3/imm32/rm32-is-first-output
3333 1/imm32/r32-is-first-inout
3334 0/imm32/no-imm32
3335 0/imm32/output-is-write-only
3336 _Primitive-or-reg-with-mem/imm32/next
3337 _Primitive-or-reg-with-mem:
3338
3339 "or-with"/imm32/name
3340 Int-var-and-second-int-var-in-some-register/imm32/inouts
3341 0/imm32/outputs
3342 "09/or-with"/imm32/subx-name
3343 1/imm32/rm32-is-first-inout
3344 2/imm32/r32-is-second-inout
3345 0/imm32/no-imm32
3346 0/imm32/output-is-write-only
3347 _Primitive-or-mem-with-reg/imm32/next
3348 _Primitive-or-mem-with-reg:
3349
3350 "or"/imm32/name
3351 Single-int-var-on-stack/imm32/inouts
3352 Single-int-var-in-some-register/imm32/outputs
3353 "0b/or"/imm32/subx-name
3354 1/imm32/rm32-is-first-inout
3355 3/imm32/r32-is-first-output
3356 0/imm32/no-imm32
3357 0/imm32/output-is-write-only
3358 _Primitive-or-lit-with-reg/imm32/next
3359 _Primitive-or-lit-with-reg:
3360
3361 "or"/imm32/name
3362 Single-lit-var/imm32/inouts
3363 Single-int-var-in-some-register/imm32/outputs
3364 "81 4/subop/or"/imm32/subx-name
3365 3/imm32/rm32-is-first-output
3366 0/imm32/no-r32
3367 1/imm32/imm32-is-first-inout
3368 0/imm32/output-is-write-only
3369 _Primitive-or-lit-with-mem/imm32/next
3370 _Primitive-or-lit-with-mem:
3371
3372 "or-with"/imm32/name
3373 Int-var-and-literal/imm32/inouts
3374 0/imm32/outputs
3375 "81 4/subop/or"/imm32/subx-name
3376 1/imm32/rm32-is-first-inout
3377 0/imm32/no-r32
3378 2/imm32/imm32-is-first-inout
3379 0/imm32/output-is-write-only
3380 _Primitive-xor-with-eax/imm32/next
3381
3382 _Primitive-xor-with-eax:
3383
3384 "xor"/imm32/name
3385 Single-lit-var/imm32/inouts
3386 Single-int-var-in-eax/imm32/outputs
3387 "35/xor-with-eax"/imm32/subx-name
3388 0/imm32/no-rm32
3389 0/imm32/no-r32
3390 1/imm32/imm32-is-first-inout
3391 0/imm32/output-is-write-only
3392 _Primitive-xor-reg-with-reg/imm32/next
3393 _Primitive-xor-reg-with-reg:
3394
3395 "xor"/imm32/name
3396 Single-int-var-in-some-register/imm32/inouts
3397 Single-int-var-in-some-register/imm32/outputs
3398 "31/xor-with"/imm32/subx-name
3399 3/imm32/rm32-is-first-output
3400 1/imm32/r32-is-first-inout
3401 0/imm32/no-imm32
3402 0/imm32/output-is-write-only
3403 _Primitive-xor-reg-with-mem/imm32/next
3404 _Primitive-xor-reg-with-mem:
3405
3406 "xor-with"/imm32/name
3407 Int-var-and-second-int-var-in-some-register/imm32/inouts
3408 0/imm32/outputs
3409 "31/xor-with"/imm32/subx-name
3410 1/imm32/rm32-is-first-inout
3411 2/imm32/r32-is-second-inout
3412 0/imm32/no-imm32
3413 0/imm32/output-is-write-only
3414 _Primitive-xor-mem-with-reg/imm32/next
3415 _Primitive-xor-mem-with-reg:
3416
3417 "xor"/imm32/name
3418 Single-int-var-on-stack/imm32/inouts
3419 Single-int-var-in-some-register/imm32/outputs
3420 "33/xor"/imm32/subx-name
3421 1/imm32/rm32-is-first-inout
3422 3/imm32/r32-is-first-output
3423 0/imm32/no-imm32
3424 0/imm32/output-is-write-only
3425 _Primitive-xor-lit-with-reg/imm32/next
3426 _Primitive-xor-lit-with-reg:
3427
3428 "xor"/imm32/name
3429 Single-lit-var/imm32/inouts
3430 Single-int-var-in-some-register/imm32/outputs
3431 "81 4/subop/xor"/imm32/subx-name
3432 3/imm32/rm32-is-first-output
3433 0/imm32/no-r32
3434 1/imm32/imm32-is-first-inout
3435 0/imm32/output-is-write-only
3436 _Primitive-xor-lit-with-mem/imm32/next
3437 _Primitive-xor-lit-with-mem:
3438
3439 "xor-with"/imm32/name
3440 Int-var-and-literal/imm32/inouts
3441 0/imm32/outputs
3442 "81 4/subop/xor"/imm32/subx-name
3443 1/imm32/rm32-is-first-inout
3444 0/imm32/no-r32
3445 2/imm32/imm32-is-first-inout
3446 0/imm32/output-is-write-only
3447 _Primitive-copy-to-eax/imm32/next
3448
3449 _Primitive-copy-to-eax:
3450
3451 "copy"/imm32/name
3452 Single-lit-var/imm32/inouts
3453 Single-int-var-in-eax/imm32/outputs
3454 "b8/copy-to-eax"/imm32/subx-name
3455 0/imm32/no-rm32
3456 0/imm32/no-r32
3457 1/imm32/imm32-is-first-inout
3458 1/imm32/output-is-write-only
3459 _Primitive-copy-to-ecx/imm32/next
3460 _Primitive-copy-to-ecx:
3461
3462 "copy"/imm32/name
3463 Single-lit-var/imm32/inouts
3464 Single-int-var-in-ecx/imm32/outputs
3465 "b9/copy-to-ecx"/imm32/subx-name
3466 0/imm32/no-rm32
3467 0/imm32/no-r32
3468 1/imm32/imm32-is-first-inout
3469 1/imm32/output-is-write-only
3470 _Primitive-copy-to-edx/imm32/next
3471 _Primitive-copy-to-edx:
3472
3473 "copy"/imm32/name
3474 Single-lit-var/imm32/inouts
3475 Single-int-var-in-edx/imm32/outputs
3476 "ba/copy-to-edx"/imm32/subx-name
3477 0/imm32/no-rm32
3478 0/imm32/no-r32
3479 1/imm32/imm32-is-first-inout
3480 1/imm32/output-is-write-only
3481 _Primitive-copy-to-ebx/imm32/next
3482 _Primitive-copy-to-ebx:
3483
3484 "copy"/imm32/name
3485 Single-lit-var/imm32/inouts
3486 Single-int-var-in-ebx/imm32/outputs
3487 "bb/copy-to-ebx"/imm32/subx-name
3488 0/imm32/no-rm32
3489 0/imm32/no-r32
3490 1/imm32/imm32-is-first-inout
3491 1/imm32/output-is-write-only
3492 _Primitive-copy-to-esi/imm32/next
3493 _Primitive-copy-to-esi:
3494
3495 "copy"/imm32/name
3496 Single-lit-var/imm32/inouts
3497 Single-int-var-in-esi/imm32/outputs
3498 "be/copy-to-esi"/imm32/subx-name
3499 0/imm32/no-rm32
3500 0/imm32/no-r32
3501 1/imm32/imm32-is-first-inout
3502 1/imm32/output-is-write-only
3503 _Primitive-copy-to-edi/imm32/next
3504 _Primitive-copy-to-edi:
3505
3506 "copy"/imm32/name
3507 Single-lit-var/imm32/inouts
3508 Single-int-var-in-edi/imm32/outputs
3509 "bf/copy-to-edi"/imm32/subx-name
3510 0/imm32/no-rm32
3511 0/imm32/no-r32
3512 1/imm32/imm32-is-first-inout
3513 1/imm32/output-is-write-only
3514 _Primitive-copy-reg-to-reg/imm32/next
3515 _Primitive-copy-reg-to-reg:
3516
3517 "copy"/imm32/name
3518 Single-int-var-in-some-register/imm32/inouts
3519 Single-int-var-in-some-register/imm32/outputs
3520 "89/copy-to"/imm32/subx-name
3521 3/imm32/rm32-is-first-output
3522 1/imm32/r32-is-first-inout
3523 0/imm32/no-imm32
3524 1/imm32/output-is-write-only
3525 _Primitive-copy-reg-to-mem/imm32/next
3526 _Primitive-copy-reg-to-mem:
3527
3528 "copy-to"/imm32/name
3529 Int-var-and-second-int-var-in-some-register/imm32/inouts
3530 0/imm32/outputs
3531 "89/copy-to"/imm32/subx-name
3532 1/imm32/rm32-is-first-inout
3533 2/imm32/r32-is-second-inout
3534 0/imm32/no-imm32
3535 1/imm32/output-is-write-only
3536 _Primitive-copy-mem-to-reg/imm32/next
3537 _Primitive-copy-mem-to-reg:
3538
3539 "copy"/imm32/name
3540 Single-int-var-on-stack/imm32/inouts
3541 Single-int-var-in-some-register/imm32/outputs
3542 "8b/copy-from"/imm32/subx-name
3543 1/imm32/rm32-is-first-inout
3544 3/imm32/r32-is-first-output
3545 0/imm32/no-imm32
3546 1/imm32/output-is-write-only
3547 _Primitive-copy-lit-to-reg/imm32/next
3548 _Primitive-copy-lit-to-reg:
3549
3550 "copy"/imm32/name
3551 Single-lit-var/imm32/inouts
3552 Single-int-var-in-some-register/imm32/outputs
3553 "c7 0/subop/copy"/imm32/subx-name
3554 3/imm32/rm32-is-first-output
3555 0/imm32/no-r32
3556 1/imm32/imm32-is-first-inout
3557 1/imm32/output-is-write-only
3558 _Primitive-copy-lit-to-mem/imm32/next
3559 _Primitive-copy-lit-to-mem:
3560
3561 "copy-to"/imm32/name
3562 Int-var-and-literal/imm32/inouts
3563 0/imm32/outputs
3564 "c7 0/subop/copy"/imm32/subx-name
3565 1/imm32/rm32-is-first-inout
3566 0/imm32/no-r32
3567 2/imm32/imm32-is-first-inout
3568 1/imm32/output-is-write-only
3569 0/imm32/next
3570
3571 Single-int-var-on-stack:
3572 Int-var-on-stack/imm32
3573 0/imm32/next
3574
3575 Int-var-on-stack:
3576 "arg1"/imm32/name
3577 1/imm32/type-int
3578 1/imm32/some-block-depth
3579 1/imm32/some-stack-offset
3580 0/imm32/no-register
3581
3582 Int-var-and-second-int-var-in-some-register:
3583 Int-var-on-stack/imm32
3584 Single-int-var-in-some-register/imm32/next
3585
3586 Int-var-and-literal:
3587 Int-var-on-stack/imm32
3588 Single-lit-var/imm32/next
3589
3590 Single-int-var-in-some-register:
3591 Int-var-in-some-register/imm32
3592 0/imm32/next
3593
3594 Int-var-in-some-register:
3595 "arg1"/imm32/name
3596 1/imm32/type-int
3597 1/imm32/some-block-depth
3598 0/imm32/no-stack-offset
3599 "*"/imm32/register
3600
3601 Single-int-var-in-eax:
3602 Int-var-in-eax/imm32
3603 0/imm32/next
3604
3605 Int-var-in-eax:
3606 "arg1"/imm32/name
3607 1/imm32/type-int
3608 1/imm32/some-block-depth
3609 0/imm32/no-stack-offset
3610 "eax"/imm32/register
3611
3612 Single-int-var-in-ecx:
3613 Int-var-in-ecx/imm32
3614 0/imm32/next
3615
3616 Int-var-in-ecx:
3617 "arg1"/imm32/name
3618 1/imm32/type-int
3619 1/imm32/some-block-depth
3620 0/imm32/no-stack-offset
3621 "ecx"/imm32/register
3622
3623 Single-int-var-in-edx:
3624 Int-var-in-edx/imm32
3625 0/imm32/next
3626
3627 Int-var-in-edx:
3628 "arg1"/imm32/name
3629 1/imm32/type-int
3630 1/imm32/some-block-depth
3631 0/imm32/no-stack-offset
3632 "edx"/imm32/register
3633
3634 Single-int-var-in-ebx:
3635 Int-var-in-ebx/imm32
3636 0/imm32/next
3637
3638 Int-var-in-ebx:
3639 "arg1"/imm32/name
3640 1/imm32/type-int
3641 1/imm32/some-block-depth
3642 0/imm32/no-stack-offset
3643 "ebx"/imm32/register
3644
3645 Single-int-var-in-esi:
3646 Int-var-in-esi/imm32
3647 0/imm32/next
3648
3649 Int-var-in-esi:
3650 "arg1"/imm32/name
3651 1/imm32/type-int
3652 1/imm32/some-block-depth
3653 0/imm32/no-stack-offset
3654 "esi"/imm32/register
3655
3656 Single-int-var-in-edi:
3657 Int-var-in-edi/imm32
3658 0/imm32/next
3659
3660 Int-var-in-edi:
3661 "arg1"/imm32/name
3662 1/imm32/type-int
3663 1/imm32/some-block-depth
3664 0/imm32/no-stack-offset
3665 "edi"/imm32/register
3666
3667 Single-lit-var:
3668 Lit-var/imm32
3669 0/imm32/next
3670
3671 Lit-var:
3672 "literal"/imm32/name
3673 0/imm32/type-literal
3674 1/imm32/some-block-depth
3675 0/imm32/no-stack-offset
3676 0/imm32/no-register
3677
3678 == code
3679 emit-subx-primitive:
3680
3681 55/push-ebp
3682 89/<- %ebp 4/r32/esp
3683
3684 50/push-eax
3685 51/push-ecx
3686
3687 8b/-> *(ebp+0x10) 1/r32/ecx
3688
3689 (write-buffered *(ebp+8) *(ecx+0xc))
3690
3691 (emit-subx-rm32 *(ebp+8) *(ecx+0x10) *(ebp+0xc))
3692
3693 (emit-subx-r32 *(ebp+8) *(ecx+0x14) *(ebp+0xc))
3694
3695 (emit-subx-imm32 *(ebp+8) *(ecx+0x18) *(ebp+0xc))
3696 $emit-subx-primitive:end:
3697
3698 59/pop-to-ecx
3699 58/pop-to-eax
3700
3701 89/<- %esp 5/r32/ebp
3702 5d/pop-to-ebp
3703 c3/return
3704
3705 emit-subx-rm32:
3706
3707 55/push-ebp
3708 89/<- %ebp 4/r32/esp
3709
3710 50/push-eax
3711
3712 81 7/subop/compare *(ebp+0xc) 0/imm32
3713 74/jump-if-equal $emit-subx-rm32:end/disp8
3714
3715 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
3716 (emit-subx-var-as-rm32 *(ebp+8) %eax)
3717 $emit-subx-rm32:end:
3718
3719 58/pop-to-eax
3720
3721 89/<- %esp 5/r32/ebp
3722 5d/pop-to-ebp
3723 c3/return
3724
3725 get-stmt-operand-from-arg-location:
3726
3727 55/push-ebp
3728 89/<- %ebp 4/r32/esp
3729
3730 51/push-ecx
3731
3732 8b/-> *(ebp+0xc) 0/r32/eax
3733
3734 8b/-> *(ebp+8) 1/r32/ecx
3735
3736 {
3737 3d/compare-eax-and 1/imm32
3738 75/jump-if-not-equal break/disp8
3739 $get-stmt-operand-from-arg-location:1:
3740 8b/-> *(ecx+8) 0/r32/eax
3741 8b/-> *eax 0/r32/eax
3742 eb/jump $get-stmt-operand-from-arg-location:end/disp8
3743 }
3744
3745 {
3746 3d/compare-eax-and 2/imm32
3747 75/jump-if-not-equal break/disp8
3748 $get-stmt-operand-from-arg-location:2:
3749 8b/-> *(ecx+8) 0/r32/eax
3750 8b/-> *(eax+4) 0/r32/eax
3751 8b/-> *eax 0/r32/eax
3752 eb/jump $get-stmt-operand-from-arg-location:end/disp8
3753 }
3754
3755 {
3756 3d/compare-eax-and 3/imm32
3757 75/jump-if-not-equal break/disp8
3758 $get-stmt-operand-from-arg-location:3:
3759 8b/-> *(ecx+0xc) 0/r32/eax
3760 8b/-> *eax 0/r32/eax
3761 eb/jump $get-stmt-operand-from-arg-location:end/disp8
3762 }
3763
3764 e9/jump $get-stmt-operand-from-arg-location:abort/disp32
3765 $get-stmt-operand-from-arg-location:end:
3766
3767 59/pop-to-ecx
3768
3769 89/<- %esp 5/r32/ebp
3770 5d/pop-to-ebp
3771 c3/return
3772
3773 $get-stmt-operand-from-arg-location:abort:
3774
3775 (write-buffered Stderr "invalid arg-location ")
3776 (print-int32-buffered Stderr %eax)
3777 (write-buffered Stderr "\n")
3778 (flush Stderr)
3779
3780 bb/copy-to-ebx 1/imm32
3781 b8/copy-to-eax 1/imm32/exit
3782 cd/syscall 0x80/imm8
3783
3784
3785 emit-subx-r32:
3786
3787 55/push-ebp
3788 89/<- %ebp 4/r32/esp
3789
3790 50/push-eax
3791 51/push-ecx
3792
3793 81 7/subop/compare *(ebp+0xc) 0/imm32
3794 0f 84/jump-if-equal $emit-subx-r32:end/disp32
3795
3796 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
3797 (maybe-get Registers *(eax+0x10) 8)
3798 (write-buffered *(ebp+8) Space)
3799 (print-int32-buffered *(ebp+8) *eax)
3800 (write-buffered *(ebp+8) "/r32")
3801 $emit-subx-r32:end:
3802
3803 59/pop-to-ecx
3804 58/pop-to-eax
3805
3806 89/<- %esp 5/r32/ebp
3807 5d/pop-to-ebp
3808 c3/return
3809
3810 emit-subx-imm32:
3811
3812 55/push-ebp
3813 89/<- %ebp 4/r32/esp
3814
3815 50/push-eax
3816 51/push-ecx
3817
3818 81 7/subop/compare *(ebp+0xc) 0/imm32
3819 74/jump-if-equal $emit-subx-imm32:end/disp8
3820
3821 (get-stmt-operand-from-arg-location *(ebp+0x10) *(ebp+0xc))
3822 (write-buffered *(ebp+8) Space)
3823 (write-buffered *(ebp+8) *eax)
3824 (write-buffered *(ebp+8) "/imm32")
3825 $emit-subx-imm32:end:
3826
3827 59/pop-to-ecx
3828 58/pop-to-eax
3829
3830 89/<- %esp 5/r32/ebp
3831 5d/pop-to-ebp
3832 c3/return
3833
3834 emit-subx-call:
3835
3836 55/push-ebp
3837 89/<- %ebp 4/r32/esp
3838
3839 50/push-eax
3840 51/push-ecx
3841
3842 (write-buffered *(ebp+8) "(")
3843
3844 8b/-> *(ebp+0x10) 1/r32/ecx
3845 (write-buffered *(ebp+8) *(ecx+4))
3846
3847
3848 8b/-> *(ebp+0xc) 1/r32/ecx
3849 8b/-> *(ecx+8) 1/r32/ecx
3850 {
3851
3852 81 7/subop/compare %ecx 0/imm32
3853 74/jump-if-equal break/disp8
3854
3855 (emit-subx-call-operand *(ebp+8) *ecx)
3856
3857 8b/-> *(ecx+4) 1/r32/ecx
3858 }
3859
3860 (write-buffered *(ebp+8) ")")
3861 $emit-subx-call:end:
3862
3863 59/pop-to-ecx
3864 58/pop-to-eax
3865
3866 89/<- %esp 5/r32/ebp
3867 5d/pop-to-ebp
3868 c3/return
3869
3870 emit-subx-call-operand:
3871
3872 55/push-ebp
3873 89/<- %ebp 4/r32/esp
3874
3875 50/push-eax
3876
3877 8b/-> *(ebp+0xc) 0/r32/eax
3878
3879 (emit-subx-var-as-rm32 *(ebp+8) %eax)
3880
3881 {
3882 81 7/subop/compare *(eax+4) 0/imm32
3883 75/jump-if-not-equal break/disp8
3884 $emit-subx-call-operand:literal:
3885 (write-buffered *(ebp+8) Space)
3886 (write-buffered *(ebp+8) *eax)
3887 }
3888 $emit-subx-call-operand:end:
3889
3890 58/pop-to-eax
3891
3892 89/<- %esp 5/r32/ebp
3893 5d/pop-to-ebp
3894 c3/return
3895
3896 emit-subx-var-as-rm32:
3897
3898 55/push-ebp
3899 89/<- %ebp 4/r32/esp
3900
3901 50/push-eax
3902
3903 8b/-> *(ebp+0xc) 0/r32/eax
3904
3905 {
3906 81 7/subop/compare *(eax+0x10) 0/imm32
3907 74/jump-if-equal break/disp8
3908 $emit-subx-var-as-rm32:register:
3909 (write-buffered *(ebp+8) " %")
3910 (write-buffered *(ebp+8) *(eax+0x10))
3911 }
3912
3913 {
3914 81 7/subop/compare *(eax+0xc) 0/imm32
3915 74/jump-if-equal break/disp8
3916 $emit-subx-var-as-rm32:stack:
3917 (write-buffered *(ebp+8) Space)
3918 (write-buffered *(ebp+8) "*(ebp+")
3919 8b/-> *(ebp+0xc) 0/r32/eax
3920 (print-int32-buffered *(ebp+8) *(eax+0xc))
3921 (write-buffered *(ebp+8) ")")
3922 }
3923 $emit-subx-var-as-rm32:end:
3924
3925 58/pop-to-eax
3926
3927 89/<- %esp 5/r32/ebp
3928 5d/pop-to-ebp
3929 c3/return
3930
3931 find-matching-function:
3932
3933 55/push-ebp
3934 89/<- %ebp 4/r32/esp
3935
3936 51/push-ecx
3937
3938 8b/-> *(ebp+8) 1/r32/ecx
3939 {
3940
3941 81 7/subop/compare %ecx 0/imm32
3942 74/jump-if-equal break/disp8
3943
3944 {
3945 (mu-stmt-matches-function? *(ebp+0xc) %ecx)
3946 3d/compare-eax-and 0/imm32
3947 74/jump-if-equal break/disp8
3948 89/<- %eax 1/r32/ecx
3949 eb/jump $find-matching-function:end/disp8
3950 }
3951
3952 8b/-> *(ecx+0x10) 1/r32/ecx
3953 eb/jump loop/disp8
3954 }
3955
3956 b8/copy-to-eax 0/imm32
3957 $find-matching-function:end:
3958
3959 59/pop-to-ecx
3960
3961 89/<- %esp 5/r32/ebp
3962 5d/pop-to-ebp
3963 c3/return
3964
3965 find-matching-primitive:
3966
3967 55/push-ebp
3968 89/<- %ebp 4/r32/esp
3969
3970 51/push-ecx
3971
3972 8b/-> *(ebp+8) 1/r32/ecx
3973 {
3974 $find-matching-primitive:loop:
3975
3976 81 7/subop/compare %ecx 0/imm32
3977 0f 84/jump-if-equal break/disp32
3978
3979
3980
3981
3982
3983
3984
3985 {
3986 (mu-stmt-matches-primitive? *(ebp+0xc) %ecx)
3987 3d/compare-eax-and 0/imm32
3988 74/jump-if-equal break/disp8
3989 89/<- %eax 1/r32/ecx
3990 eb/jump $find-matching-primitive:end/disp8
3991 }
3992 $find-matching-primitive:next-primitive:
3993
3994 8b/-> *(ecx+0x20) 1/r32/ecx
3995 e9/jump loop/disp32
3996 }
3997
3998 b8/copy-to-eax 0/imm32
3999 $find-matching-primitive:end:
4000
4001 59/pop-to-ecx
4002
4003 89/<- %esp 5/r32/ebp
4004 5d/pop-to-ebp
4005 c3/return
4006
4007 mu-stmt-matches-function?:
4008
4009 55/push-ebp
4010 89/<- %ebp 4/r32/esp
4011
4012 51/push-ecx
4013
4014 8b/-> *(ebp+8) 1/r32/ecx
4015 8b/-> *(ebp+0xc) 0/r32/eax
4016 (string-equal? *(ecx+4) *eax)
4017 $mu-stmt-matches-function?:end:
4018
4019 59/pop-to-ecx
4020
4021 89/<- %esp 5/r32/ebp
4022 5d/pop-to-ebp
4023 c3/return
4024
4025 mu-stmt-matches-primitive?:
4026
4027
4028
4029
4030
4031
4032 55/push-ebp
4033 89/<- %ebp 4/r32/esp
4034
4035 51/push-ecx
4036 52/push-edx
4037 53/push-ebx
4038 56/push-esi
4039 57/push-edi
4040
4041 8b/-> *(ebp+8) 1/r32/ecx
4042
4043 8b/-> *(ebp+0xc) 2/r32/edx
4044 {
4045 $mu-stmt-matches-primitive?:check-name:
4046
4047 (string-equal? *(ecx+4) *edx)
4048 3d/compare-eax-and 0/imm32
4049 75/jump-if-not-equal break/disp8
4050 b8/copy-to-eax 0/imm32
4051 e9/jump $mu-stmt-matches-primitive?:end/disp32
4052 }
4053 $mu-stmt-matches-primitive?:check-inouts:
4054
4055 8b/-> *(ecx+8) 6/r32/esi
4056 8b/-> *(edx+4) 7/r32/edi
4057 {
4058
4059 {
4060 81 7/subop/compare %esi 0/imm32
4061 75/jump-if-not-equal break/disp8
4062 $mu-stmt-matches-primitive?:stmt-inout-is-null:
4063 {
4064 81 7/subop/compare %edi 0/imm32
4065 75/jump-if-not-equal break/disp8
4066
4067 e9/jump $mu-stmt-matches-primitive?:check-outputs/disp32
4068 }
4069
4070 b8/copy-to-eax 0/imm32/false
4071 e9/jump $mu-stmt-matches-primitive?:end/disp32
4072 }
4073
4074 {
4075 81 7/subop/compare %edi 0/imm32
4076 75/jump-if-not-equal break/disp8
4077 $mu-stmt-matches-primitive?:prim-inout-is-null:
4078 b8/copy-to-eax 0/imm32/false
4079 e9/jump $mu-stmt-matches-primitive?:end/disp32
4080 }
4081
4082 {
4083 (operand-matches-primitive? *esi *edi)
4084 3d/compare-eax-and 0/imm32
4085 75/jump-if-not-equal break/disp8
4086 b8/copy-to-eax 0/imm32/false
4087 e9/jump $mu-stmt-matches-primitive?:end/disp32
4088 }
4089
4090 8b/-> *(esi+4) 6/r32/esi
4091
4092 8b/-> *(edi+4) 7/r32/edi
4093 eb/jump loop/disp8
4094 }
4095 $mu-stmt-matches-primitive?:check-outputs:
4096
4097 8b/-> *(ecx+0xc) 6/r32/esi
4098 8b/-> *(edx+8) 7/r32/edi
4099 {
4100
4101 {
4102 $mu-stmt-matches-primitive?:check-output:
4103 81 7/subop/compare %esi 0/imm32
4104 75/jump-if-not-equal break/disp8
4105 {
4106 81 7/subop/compare %edi 0/imm32
4107 75/jump-if-not-equal break/disp8
4108
4109 b8/copy-to-eax 1/imm32
4110 e9/jump $mu-stmt-matches-primitive?:end/disp32
4111 }
4112
4113 b8/copy-to-eax 0/imm32
4114 e9/jump $mu-stmt-matches-primitive?:end/disp32
4115 }
4116
4117 {
4118 81 7/subop/compare %edi 0/imm32
4119 75/jump-if-not-equal break/disp8
4120 b8/copy-to-eax 0/imm32
4121 e9/jump $mu-stmt-matches-primitive?:end/disp32
4122 }
4123
4124 {
4125 (operand-matches-primitive? *esi *edi)
4126 3d/compare-eax-and 0/imm32
4127 75/jump-if-not-equal break/disp8
4128 b8/copy-to-eax 0/imm32
4129 e9/jump $mu-stmt-matches-primitive?:end/disp32
4130 }
4131
4132 8b/-> *(esi+4) 6/r32/esi
4133
4134 8b/-> *(edi+4) 7/r32/edi
4135 eb/jump loop/disp8
4136 }
4137 $mu-stmt-matches-primitive?:return-true:
4138 b8/copy-to-eax 1/imm32
4139 $mu-stmt-matches-primitive?:end:
4140
4141 5f/pop-to-edi
4142 5e/pop-to-esi
4143 5b/pop-to-ebx
4144 5a/pop-to-edx
4145 59/pop-to-ecx
4146
4147 89/<- %esp 5/r32/ebp
4148 5d/pop-to-ebp
4149 c3/return
4150
4151 operand-matches-primitive?:
4152
4153 55/push-ebp
4154 89/<- %ebp 4/r32/esp
4155
4156 56/push-esi
4157 57/push-edi
4158
4159 8b/-> *(ebp+8) 6/r32/esi
4160
4161 8b/-> *(ebp+0xc) 7/r32/edi
4162
4163 8b/-> *(esi+4) 0/r32/eax
4164 39/compare *(edi+4) 0/r32/eax
4165 b8/copy-to-eax 0/imm32/false
4166 75/jump-if-not-equal $operand-matches-primitive?:end/disp8
4167
4168 {
4169
4170 8b/-> *(esi+0x10) 0/r32/eax
4171 39/compare *(edi+0x10) 0/r32/eax
4172 74/jump-if-equal break/disp8
4173
4174 3d/compare-eax-and 0/imm32
4175 74/jump-if-equal $operand-matches-primitive?:end/disp8
4176 81 7/subop/compare *(edi+0x10) 0/imm32
4177 74/jump-if-equal $operand-matches-primitive?:end/disp8
4178
4179 (string-equal? *(edi+0x10) "*")
4180 3d/compare-eax-and 0/imm32
4181 b8/copy-to-eax 1/imm32/true
4182 75/jump-if-not-equal $operand-matches-primitive?:end/disp8
4183
4184 (string-equal? *(esi+0x10) *(edi+0x10))
4185 3d/compare-eax-and 0/imm32
4186 b8/copy-to-eax 0/imm32/false
4187 74/jump-if-equal $operand-matches-primitive?:end/disp8
4188 }
4189
4190 b8/copy-to-eax 1/imm32/true
4191 $operand-matches-primitive?:end:
4192
4193 5f/pop-to-edi
4194 5e/pop-to-esi
4195
4196 89/<- %esp 5/r32/ebp
4197 5d/pop-to-ebp
4198 c3/return
4199
4200 test-emit-subx-statement-primitive:
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219 55/push-ebp
4220 89/<- %ebp 4/r32/esp
4221
4222 (clear-stream _test-output-stream)
4223 (clear-stream $_test-output-buffered-file->buffer)
4224
4225 68/push 0/imm32/no-register
4226 68/push -8/imm32/stack-offset
4227 68/push 1/imm32/block-depth
4228 68/push 1/imm32/type-int
4229 68/push "foo"/imm32
4230 89/<- %ecx 4/r32/esp
4231
4232 68/push 0/imm32/next
4233 51/push-ecx/var-foo
4234 89/<- %ebx 4/r32/esp
4235
4236 68/push 0/imm32/next
4237 68/push 0/imm32/outputs
4238 53/push-ebx/operands
4239 68/push "increment"/imm32/operation
4240 68/push 1/imm32
4241 89/<- %esi 4/r32/esp
4242
4243 68/push 0/imm32/next
4244 68/push 0/imm32/output-is-write-only
4245 68/push 0/imm32/no-imm32
4246 68/push 0/imm32/no-r32
4247 68/push 1/imm32/rm32-is-first-inout
4248 68/push "ff 0/subop/increment"/imm32/subx-name
4249 68/push 0/imm32/outputs
4250 53/push-ebx/inouts
4251 68/push "increment"/imm32/name
4252 89/<- %ebx 4/r32/esp
4253
4254 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
4255 (flush _test-output-buffered-file)
4256 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4262
4263 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment *(ebp+0xfffffff8)" "F - test-emit-subx-statement-primitive")
4264
4265 89/<- %esp 5/r32/ebp
4266 5d/pop-to-ebp
4267 c3/return
4268
4269 test-emit-subx-statement-primitive-register:
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288 55/push-ebp
4289 89/<- %ebp 4/r32/esp
4290
4291 (clear-stream _test-output-stream)
4292 (clear-stream $_test-output-buffered-file->buffer)
4293
4294 68/push "eax"/imm32/register
4295 68/push 0/imm32/no-stack-offset
4296 68/push 1/imm32/block-depth
4297 68/push 1/imm32/type-int
4298 68/push "foo"/imm32
4299 89/<- %ecx 4/r32/esp
4300
4301 68/push 0/imm32/next
4302 51/push-ecx/var-foo
4303 89/<- %ebx 4/r32/esp
4304
4305 68/push 0/imm32/next
4306 53/push-ebx/outputs
4307 68/push 0/imm32/inouts
4308 68/push "increment"/imm32/operation
4309 68/push 1/imm32
4310 89/<- %esi 4/r32/esp
4311
4312 68/push Any-register/imm32
4313 68/push 0/imm32/no-stack-offset
4314 68/push 1/imm32/block-depth
4315 68/push 1/imm32/type-int
4316 68/push "dummy"/imm32
4317 89/<- %ebx 4/r32/esp
4318
4319 68/push 0/imm32/next
4320 53/push-ebx/formal-var
4321 89/<- %ebx 4/r32/esp
4322
4323 68/push 0/imm32/next
4324 68/push 0/imm32/output-is-write-only
4325 68/push 0/imm32/no-imm32
4326 68/push 0/imm32/no-r32
4327 68/push 3/imm32/rm32-in-first-output
4328 68/push "ff 0/subop/increment"/imm32/subx-name
4329 53/push-ebx/outputs
4330 68/push 0/imm32/inouts
4331 68/push "increment"/imm32/name
4332 89/<- %ebx 4/r32/esp
4333
4334 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
4335 (flush _test-output-buffered-file)
4336 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4342
4343 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-primitive-register")
4344
4345 89/<- %esp 5/r32/ebp
4346 5d/pop-to-ebp
4347 c3/return
4348
4349 test-emit-subx-statement-select-primitive:
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371 55/push-ebp
4372 89/<- %ebp 4/r32/esp
4373
4374 (clear-stream _test-output-stream)
4375 (clear-stream $_test-output-buffered-file->buffer)
4376
4377 68/push "eax"/imm32/register
4378 68/push 0/imm32/no-stack-offset
4379 68/push 1/imm32/block-depth
4380 68/push 1/imm32/type-int
4381 68/push "foo"/imm32
4382 89/<- %ecx 4/r32/esp
4383
4384 68/push 0/imm32/next
4385 51/push-ecx/var-foo
4386 89/<- %edi 4/r32/esp
4387
4388 68/push 0/imm32/next
4389 57/push-edi/outputs
4390 68/push 0/imm32/inouts
4391 68/push "increment"/imm32/operation
4392 68/push 1/imm32
4393 89/<- %esi 4/r32/esp
4394
4395 68/push Any-register/imm32
4396 68/push 0/imm32/no-stack-offset
4397 68/push 1/imm32/block-depth
4398 68/push 1/imm32/type-int
4399 68/push "dummy"/imm32
4400 89/<- %ebx 4/r32/esp
4401
4402 68/push 0/imm32/next
4403 53/push-ebx/formal-var
4404 89/<- %ebx 4/r32/esp
4405
4406 68/push 0/imm32/next
4407 68/push 0/imm32/output-is-write-only
4408 68/push 0/imm32/no-imm32
4409 68/push 0/imm32/no-r32
4410 68/push 3/imm32/rm32-in-first-output
4411 68/push "ff 0/subop/increment"/imm32/subx-name
4412 53/push-ebx/outputs/formal-outputs
4413 68/push 0/imm32/inouts
4414 68/push "increment"/imm32/name
4415 89/<- %ebx 4/r32/esp
4416
4417 53/push-ebx/next
4418 68/push 0/imm32/output-is-write-only
4419 68/push 0/imm32/no-imm32
4420 68/push 0/imm32/no-r32
4421 68/push 1/imm32/rm32-is-first-inout
4422 68/push "ff 0/subop/increment"/imm32/subx-name
4423 68/push 0/imm32/outputs
4424 57/push-edi/inouts/real-outputs
4425 68/push "increment"/imm32/name
4426 89/<- %ebx 4/r32/esp
4427
4428 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
4429 (flush _test-output-buffered-file)
4430 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4436
4437 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive")
4438
4439 89/<- %esp 5/r32/ebp
4440 5d/pop-to-ebp
4441 c3/return
4442
4443 test-emit-subx-statement-select-primitive-2:
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465 55/push-ebp
4466 89/<- %ebp 4/r32/esp
4467
4468 (clear-stream _test-output-stream)
4469 (clear-stream $_test-output-buffered-file->buffer)
4470
4471 68/push "eax"/imm32/register
4472 68/push 0/imm32/no-stack-offset
4473 68/push 1/imm32/block-depth
4474 68/push 1/imm32/type-int
4475 68/push "foo"/imm32
4476 89/<- %ecx 4/r32/esp
4477
4478 68/push 0/imm32/next
4479 51/push-ecx/var-foo
4480 89/<- %edi 4/r32/esp
4481
4482 68/push 0/imm32/next
4483 68/push 0/imm32/outputs
4484 57/push-edi/inouts
4485 68/push "increment"/imm32/operation
4486 68/push 1/imm32
4487 89/<- %esi 4/r32/esp
4488
4489 68/push Any-register/imm32
4490 68/push 0/imm32/no-stack-offset
4491 68/push 1/imm32/block-depth
4492 68/push 1/imm32/type-int
4493 68/push "dummy"/imm32
4494 89/<- %ebx 4/r32/esp
4495
4496 68/push 0/imm32/next
4497 53/push-ebx/formal-var
4498 89/<- %ebx 4/r32/esp
4499
4500 68/push 0/imm32/next
4501 68/push 0/imm32/output-is-write-only
4502 68/push 0/imm32/no-imm32
4503 68/push 0/imm32/no-r32
4504 68/push 3/imm32/rm32-in-first-output
4505 68/push "ff 0/subop/increment"/imm32/subx-name
4506 53/push-ebx/outputs/formal-outputs
4507 68/push 0/imm32/inouts
4508 68/push "increment"/imm32/name
4509 89/<- %ebx 4/r32/esp
4510
4511 53/push-ebx/next
4512 68/push 0/imm32/output-is-write-only
4513 68/push 0/imm32/no-imm32
4514 68/push 0/imm32/no-r32
4515 68/push 1/imm32/rm32-is-first-inout
4516 68/push "ff 0/subop/increment"/imm32/subx-name
4517 68/push 0/imm32/outputs
4518 57/push-edi/inouts/real-outputs
4519 68/push "increment"/imm32/name
4520 89/<- %ebx 4/r32/esp
4521
4522 (emit-subx-statement _test-output-buffered-file %esi %ebx 0)
4523 (flush _test-output-buffered-file)
4524 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4530
4531 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-emit-subx-statement-select-primitive-2")
4532
4533 89/<- %esp 5/r32/ebp
4534 5d/pop-to-ebp
4535 c3/return
4536
4537 test-increment-register:
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553 55/push-ebp
4554 89/<- %ebp 4/r32/esp
4555
4556 (clear-stream _test-output-stream)
4557 (clear-stream $_test-output-buffered-file->buffer)
4558
4559 68/push "eax"/imm32/register
4560 68/push 0/imm32/no-stack-offset
4561 68/push 1/imm32/block-depth
4562 68/push 1/imm32/type-int
4563 68/push "foo"/imm32
4564 89/<- %ecx 4/r32/esp
4565
4566 68/push 0/imm32/next
4567 51/push-ecx/var-foo
4568 89/<- %edi 4/r32/esp
4569
4570 68/push 0/imm32/next
4571 57/push-edi/outputs
4572 68/push 0/imm32/inouts
4573 68/push "increment"/imm32/operation
4574 68/push 1/imm32
4575 89/<- %esi 4/r32/esp
4576
4577 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4578 (flush _test-output-buffered-file)
4579 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4585
4586 (check-next-stream-line-equal _test-output-stream "40/increment-eax" "F - test-increment-register")
4587
4588 89/<- %esp 5/r32/ebp
4589 5d/pop-to-ebp
4590 c3/return
4591
4592 test-increment-var:
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608 55/push-ebp
4609 89/<- %ebp 4/r32/esp
4610
4611 (clear-stream _test-output-stream)
4612 (clear-stream $_test-output-buffered-file->buffer)
4613
4614 68/push "eax"/imm32/register
4615 68/push 0/imm32/no-stack-offset
4616 68/push 1/imm32/block-depth
4617 68/push 1/imm32/type-int
4618 68/push "foo"/imm32
4619 89/<- %ecx 4/r32/esp
4620
4621 68/push 0/imm32/next
4622 51/push-ecx/var-foo
4623 89/<- %edi 4/r32/esp
4624
4625 68/push 0/imm32/next
4626 68/push 0/imm32/outputs
4627 57/push-edi/inouts
4628 68/push "increment"/imm32/operation
4629 68/push 1/imm32
4630 89/<- %esi 4/r32/esp
4631
4632 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4633 (flush _test-output-buffered-file)
4634 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4640
4641 (check-next-stream-line-equal _test-output-stream "ff 0/subop/increment %eax" "F - test-increment-var")
4642
4643 89/<- %esp 5/r32/ebp
4644 5d/pop-to-ebp
4645 c3/return
4646
4647 test-add-reg-to-reg:
4648
4649
4650
4651
4652
4653 55/push-ebp
4654 89/<- %ebp 4/r32/esp
4655
4656 (clear-stream _test-output-stream)
4657 (clear-stream $_test-output-buffered-file->buffer)
4658
4659 68/push "eax"/imm32/register
4660 68/push 0/imm32/no-stack-offset
4661 68/push 1/imm32/block-depth
4662 68/push 1/imm32/type-int
4663 68/push "var1"/imm32
4664 89/<- %ecx 4/r32/esp
4665
4666 68/push "ecx"/imm32/register
4667 68/push 0/imm32/no-stack-offset
4668 68/push 1/imm32/block-depth
4669 68/push 1/imm32/type-int
4670 68/push "var2"/imm32
4671 89/<- %edx 4/r32/esp
4672
4673 68/push 0/imm32/next
4674 52/push-edx/var-var2
4675 89/<- %esi 4/r32/esp
4676
4677 68/push 0/imm32/next
4678 51/push-ecx/var-var1
4679 89/<- %edi 4/r32/esp
4680
4681 68/push 0/imm32/next
4682 57/push-edi/outputs
4683 56/push-esi/inouts
4684 68/push "add"/imm32/operation
4685 68/push 1/imm32
4686 89/<- %esi 4/r32/esp
4687
4688 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4689 (flush _test-output-buffered-file)
4690 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4696
4697 (check-next-stream-line-equal _test-output-stream "01/add-to %eax 0x00000001/r32" "F - test-add-reg-to-reg")
4698
4699 89/<- %esp 5/r32/ebp
4700 5d/pop-to-ebp
4701 c3/return
4702
4703 test-add-reg-to-mem:
4704
4705
4706
4707
4708
4709 55/push-ebp
4710 89/<- %ebp 4/r32/esp
4711
4712 (clear-stream _test-output-stream)
4713 (clear-stream $_test-output-buffered-file->buffer)
4714
4715 68/push 0/imm32/no-register
4716 68/push 8/imm32/stack-offset
4717 68/push 1/imm32/block-depth
4718 68/push 1/imm32/type-int
4719 68/push "var1"/imm32
4720 89/<- %ecx 4/r32/esp
4721
4722 68/push "ecx"/imm32/register
4723 68/push 0/imm32/no-stack-offset
4724 68/push 1/imm32/block-depth
4725 68/push 1/imm32/type-int
4726 68/push "var2"/imm32
4727 89/<- %edx 4/r32/esp
4728
4729 68/push 0/imm32/next
4730 52/push-edx/var-var2
4731 89/<- %esi 4/r32/esp
4732
4733 56/push-esi/next
4734 51/push-ecx/var-var1
4735 89/<- %esi 4/r32/esp
4736
4737 68/push 0/imm32/next
4738 68/push 0/imm32/outputs
4739 56/push-esi/inouts
4740 68/push "add-to"/imm32/operation
4741 68/push 1/imm32
4742 89/<- %esi 4/r32/esp
4743
4744 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4745 (flush _test-output-buffered-file)
4746 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4752
4753 (check-next-stream-line-equal _test-output-stream "01/add-to *(ebp+0x00000008) 0x00000001/r32" "F - test-add-reg-to-mem")
4754
4755 89/<- %esp 5/r32/ebp
4756 5d/pop-to-ebp
4757 c3/return
4758
4759 test-add-mem-to-reg:
4760
4761
4762
4763
4764
4765 55/push-ebp
4766 89/<- %ebp 4/r32/esp
4767
4768 (clear-stream _test-output-stream)
4769 (clear-stream $_test-output-buffered-file->buffer)
4770
4771 68/push "eax"/imm32/register
4772 68/push 0/imm32/no-stack-offset
4773 68/push 1/imm32/block-depth
4774 68/push 1/imm32/type-int
4775 68/push "var1"/imm32
4776 89/<- %ecx 4/r32/esp
4777
4778 68/push 0/imm32/no-register
4779 68/push 8/imm32/stack-offset
4780 68/push 1/imm32/block-depth
4781 68/push 1/imm32/type-int
4782 68/push "var2"/imm32
4783 89/<- %edx 4/r32/esp
4784
4785 68/push 0/imm32/next
4786 52/push-edx/var-var2
4787 89/<- %esi 4/r32/esp
4788
4789 68/push 0/imm32/next
4790 51/push-ecx/var-var1
4791 89/<- %edi 4/r32/esp
4792
4793 68/push 0/imm32/next
4794 57/push-edi/outputs
4795 56/push-esi/inouts
4796 68/push "add"/imm32/operation
4797 68/push 1/imm32
4798 89/<- %esi 4/r32/esp
4799
4800 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4801 (flush _test-output-buffered-file)
4802 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4808
4809 (check-next-stream-line-equal _test-output-stream "03/add *(ebp+0x00000008) 0x00000000/r32" "F - test-add-mem-to-reg")
4810
4811 89/<- %esp 5/r32/ebp
4812 5d/pop-to-ebp
4813 c3/return
4814
4815 test-add-literal-to-eax:
4816
4817
4818
4819
4820
4821 55/push-ebp
4822 89/<- %ebp 4/r32/esp
4823
4824 (clear-stream _test-output-stream)
4825 (clear-stream $_test-output-buffered-file->buffer)
4826
4827 68/push "eax"/imm32/register
4828 68/push 0/imm32/no-stack-offset
4829 68/push 1/imm32/block-depth
4830 68/push 1/imm32/type-int
4831 68/push "var1"/imm32
4832 89/<- %ecx 4/r32/esp
4833
4834 68/push 0/imm32/no-register
4835 68/push 0/imm32/no-stack-offset
4836 68/push 1/imm32/block-depth
4837 68/push 0/imm32/type-literal
4838 68/push "0x34"/imm32
4839 89/<- %edx 4/r32/esp
4840
4841 68/push 0/imm32/next
4842 52/push-edx/var-var2
4843 89/<- %esi 4/r32/esp
4844
4845 68/push 0/imm32/next
4846 51/push-ecx/var-var1
4847 89/<- %edi 4/r32/esp
4848
4849 68/push 0/imm32/next
4850 57/push-edi/outputs
4851 56/push-esi/inouts
4852 68/push "add"/imm32/operation
4853 68/push 1/imm32
4854 89/<- %esi 4/r32/esp
4855
4856 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4857 (flush _test-output-buffered-file)
4858 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4864
4865 (check-next-stream-line-equal _test-output-stream "05/add-to-eax 0x34/imm32" "F - test-add-literal-to-eax")
4866
4867 89/<- %esp 5/r32/ebp
4868 5d/pop-to-ebp
4869 c3/return
4870
4871 test-add-literal-to-reg:
4872
4873
4874
4875
4876
4877 55/push-ebp
4878 89/<- %ebp 4/r32/esp
4879
4880 (clear-stream _test-output-stream)
4881 (clear-stream $_test-output-buffered-file->buffer)
4882
4883 68/push "ecx"/imm32/register
4884 68/push 0/imm32/no-stack-offset
4885 68/push 1/imm32/block-depth
4886 68/push 1/imm32/type-int
4887 68/push "var1"/imm32
4888 89/<- %ecx 4/r32/esp
4889
4890 68/push 0/imm32/no-register
4891 68/push 0/imm32/no-stack-offset
4892 68/push 1/imm32/block-depth
4893 68/push 0/imm32/type-literal
4894 68/push "0x34"/imm32
4895 89/<- %edx 4/r32/esp
4896
4897 68/push 0/imm32/next
4898 52/push-edx/var-var2
4899 89/<- %esi 4/r32/esp
4900
4901 68/push 0/imm32/next
4902 51/push-ecx/var-var1
4903 89/<- %edi 4/r32/esp
4904
4905 68/push 0/imm32/next
4906 57/push-edi/outputs
4907 56/push-esi/inouts
4908 68/push "add"/imm32/operation
4909 68/push 1/imm32
4910 89/<- %esi 4/r32/esp
4911
4912 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4913 (flush _test-output-buffered-file)
4914 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4920
4921 (check-next-stream-line-equal _test-output-stream "81 0/subop/add %ecx 0x34/imm32" "F - test-add-literal-to-reg")
4922
4923 89/<- %esp 5/r32/ebp
4924 5d/pop-to-ebp
4925 c3/return
4926
4927 test-add-literal-to-mem:
4928
4929
4930
4931
4932
4933 55/push-ebp
4934 89/<- %ebp 4/r32/esp
4935
4936 (clear-stream _test-output-stream)
4937 (clear-stream $_test-output-buffered-file->buffer)
4938
4939 68/push 0/imm32/no-register
4940 68/push 8/imm32/stack-offset
4941 68/push 1/imm32/block-depth
4942 68/push 1/imm32/type-int
4943 68/push "var1"/imm32
4944 89/<- %ecx 4/r32/esp
4945
4946 68/push 0/imm32/no-register
4947 68/push 0/imm32/no-stack-offset
4948 68/push 1/imm32/block-depth
4949 68/push 0/imm32/type-literal
4950 68/push "0x34"/imm32
4951 89/<- %edx 4/r32/esp
4952
4953 68/push 0/imm32/next
4954 52/push-edx/var-var2
4955 89/<- %esi 4/r32/esp
4956
4957 56/push-esi/next
4958 51/push-ecx/var-var1
4959 89/<- %esi 4/r32/esp
4960
4961 68/push 0/imm32/next
4962 68/push 0/imm32/outputs
4963 56/push-esi/inouts
4964 68/push "add-to"/imm32/operation
4965 68/push 1/imm32
4966 89/<- %esi 4/r32/esp
4967
4968 (emit-subx-statement _test-output-buffered-file %esi Primitives 0)
4969 (flush _test-output-buffered-file)
4970 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
4976
4977 (check-next-stream-line-equal _test-output-stream "81 0/subop/add *(ebp+0x00000008) 0x34/imm32" "F - test-add-literal-to-mem")
4978
4979 89/<- %esp 5/r32/ebp
4980 5d/pop-to-ebp
4981 c3/return
4982
4983 test-emit-subx-statement-function-call:
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004 55/push-ebp
5005 89/<- %ebp 4/r32/esp
5006
5007 (clear-stream _test-output-stream)
5008 (clear-stream $_test-output-buffered-file->buffer)
5009
5010 68/push 0/imm32/no-register
5011 68/push -8/imm32/stack-offset
5012 68/push 0/imm32/block-depth
5013 68/push 1/imm32/type-int
5014 68/push "foo"/imm32
5015 89/<- %ecx 4/r32/esp
5016
5017 68/push 0/imm32/next
5018 51/push-ecx/var-foo
5019 89/<- %esi 4/r32/esp
5020
5021 68/push 0/imm32/next
5022 68/push 0/imm32/outputs
5023 56/push-esi/inouts
5024 68/push "f"/imm32/operation
5025 68/push 1/imm32
5026 89/<- %esi 4/r32/esp
5027
5028 68/push 0/imm32/next
5029 68/push 0/imm32/body
5030 68/push 0/imm32/outputs
5031 51/push-ecx/inouts
5032 68/push "f2"/imm32/subx-name
5033 68/push "f"/imm32/name
5034 89/<- %ebx 4/r32/esp
5035
5036 (emit-subx-statement _test-output-buffered-file %esi 0 %ebx)
5037 (flush _test-output-buffered-file)
5038 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5044
5045 (check-next-stream-line-equal _test-output-stream "(f2 *(ebp+0xfffffff8))" "F - test-emit-subx-statement-function-call")
5046
5047 89/<- %esp 5/r32/ebp
5048 5d/pop-to-ebp
5049 c3/return
5050
5051 test-emit-subx-statement-function-call-with-literal-arg:
5052
5053
5054
5055
5056
5057
5058 55/push-ebp
5059 89/<- %ebp 4/r32/esp
5060
5061 (clear-stream _test-output-stream)
5062 (clear-stream $_test-output-buffered-file->buffer)
5063
5064 68/push 0/imm32/no-register
5065 68/push 0/imm32/no-stack-offset
5066 68/push 0/imm32/block-depth
5067 68/push 0/imm32/type-literal
5068 68/push "34"/imm32
5069 89/<- %ecx 4/r32/esp
5070
5071 68/push 0/imm32/next
5072 51/push-ecx/var-foo
5073 89/<- %esi 4/r32/esp
5074
5075 68/push 0/imm32/next
5076 68/push 0/imm32/outputs
5077 56/push-esi/inouts
5078 68/push "f"/imm32/operation
5079 68/push 1/imm32
5080 89/<- %esi 4/r32/esp
5081
5082 68/push 0/imm32/next
5083 68/push 0/imm32/body
5084 68/push 0/imm32/outputs
5085 51/push-ecx/inouts
5086 68/push "f2"/imm32/subx-name
5087 68/push "f"/imm32/name
5088 89/<- %ebx 4/r32/esp
5089
5090 (emit-subx-statement _test-output-buffered-file %esi 0 %ebx)
5091 (flush _test-output-buffered-file)
5092 +-- 6 lines: #? # dump _test-output-stream --------------------------------------------------------------------------------------------------------------
5098
5099 (check-next-stream-line-equal _test-output-stream "(f2 34)" "F - test-emit-subx-statement-function-call-with-literal-arg")
5100
5101 89/<- %esp 5/r32/ebp
5102 5d/pop-to-ebp
5103 c3/return
5104
5105 emit-subx-prologue:
5106
5107 55/push-ebp
5108 89/<- %ebp 4/r32/esp
5109
5110 (write-buffered *(ebp+8) "# . prologue\n")
5111 (write-buffered *(ebp+8) "55/push-ebp\n")
5112 (write-buffered *(ebp+8) "89/<- %ebp 4/r32/esp\n")
5113 $emit-subx-prologue:end:
5114
5115 89/<- %esp 5/r32/ebp
5116 5d/pop-to-ebp
5117 c3/return
5118
5119 emit-subx-epilogue:
5120
5121 55/push-ebp
5122 89/<- %ebp 4/r32/esp
5123
5124 (write-buffered *(ebp+8) "# . epilogue\n")
5125 (write-buffered *(ebp+8) "89/<- %esp 5/r32/ebp\n")
5126 (write-buffered *(ebp+8) "5d/pop-to-ebp\n")
5127 (write-buffered *(ebp+8) "c3/return\n")
5128 $emit-subx-epilogue:end:
5129
5130 89/<- %esp 5/r32/ebp
5131 5d/pop-to-ebp
5132 c3/return