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