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