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