-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_example.tm
More file actions
4031 lines (4031 loc) · 144 KB
/
list_example.tm
File metadata and controls
4031 lines (4031 loc) · 144 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
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
998
999
1000
* File: list_example.tm
* Standard prelude:
0: LDC 6,65535(0) load mp adress
1: ST 0,0(0) clear location 0
2: LDC 5,4095(0) load gp adress from location 1
3: ST 0,1(0) clear location 1
4: LDC 4,2000(0) load gp adress from location 1
5: LDC 2,60000(0) load first fp from location 2
6: LDC 3,60000(0) load first sp from location 2
7: ST 0,2(0) clear location 2
* End of standard prelude.
8: LDA 3,-1(3) stack expand
9: LDC 0,0(0) load integer const
10: PUSH 0,0(6) store exp
11: LDA 0,-5(5) load id adress
12: PUSH 0,0(6) push array adress to mp
13: POP 1,0(6) move the adress of ID
14: POP 0,0(6) copy bytes
15: ST 0,0(1) copy bytes
* function entry:
* malloc
16: LDA 3,-1(3) stack expand for function variable
17: LDC 0,20(0) get function adress
18: ST 0,-6(5) set function adress
19: GO 7,0,0 go to label
20: MOV 1,2,0 store the caller fp temporarily
21: MOV 2,3,0 exchang the stack(context)
22: PUSH 1,0(3) push the caller fp
23: PUSH 0,0(3) push the return adress
24: LD 0,2(2) load id value
25: PUSH 0,0(6) store exp
26: POP 0,0(6) get malloc parameters
27: MALLOC 0,0(0) system call for malloc
28: MOV 3,2,0 restore the caller sp
29: LD 2,0(2) resotre the caller fp
30: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
31: LABEL 7,0,0 generate label
* function entry:
* free
32: LDA 3,-1(3) stack expand for function variable
33: LDC 0,36(0) get function adress
34: ST 0,-7(5) set function adress
35: GO 8,0,0 go to label
36: MOV 1,2,0 store the caller fp temporarily
37: MOV 2,3,0 exchang the stack(context)
38: PUSH 1,0(3) push the caller fp
39: PUSH 0,0(3) push the return adress
40: LD 0,2(2) load id value
41: PUSH 0,0(6) store exp
42: POP 0,0(6) get free parameters
43: FREE 0,0(0) system call for free
44: MOV 3,2,0 restore the caller sp
45: LD 2,0(2) resotre the caller fp
46: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
47: LABEL 8,0,0 generate label
* function entry:
* printStr
48: LDA 3,-1(3) stack expand for function variable
49: LDC 0,52(0) get function adress
50: ST 0,-8(5) set function adress
51: GO 9,0,0 go to label
52: MOV 1,2,0 store the caller fp temporarily
53: MOV 2,3,0 exchang the stack(context)
54: PUSH 1,0(3) push the caller fp
55: PUSH 0,0(3) push the return adress
* while stmt:
56: LABEL 10,0,0 generate label
57: LD 0,2(2) load id value
58: PUSH 0,0(6) store exp
59: POP 0,0(6) pop the adress
60: LD 1,0(0) load bytes
61: PUSH 1,0(6) push bytes
62: LDC 0,0(0) load integer const
63: PUSH 0,0(6) store exp
64: POP 1,0(6) pop right
65: POP 0,0(6) pop left
66: SUB 0,0,1 op ==, convertd_type
67: JNE 0,2(7) br if true
68: LDC 0,0(0) false case
69: LDA 7,1(7) unconditional jmp
70: LDC 0,1(0) true case
71: PUSH 0,0(6)
72: POP 0,0(6) pop from the mp
73: JNE 0,1,7 true case:, skip the break, execute the block code
74: GO 11,0,0 go to label
75: LD 0,2(2) load id value
76: PUSH 0,0(6) store exp
77: POP 0,0(6) pop right
78: LD 0,2(2) load id value
79: PUSH 0,0(6) store exp
80: LD 0,2(2) load id value
81: PUSH 0,0(6) store exp
82: LDC 0,1(0) load integer const
83: PUSH 0,0(6) store exp
84: POP 0,0(6) load index value to ac
85: LDC 1,1,0 load pointkind size
86: MUL 0,1,0 compute the offset
87: POP 1,0(6) load lhs adress to ac1
88: ADD 0,1,0 compute the real index adress
89: PUSH 0,0(6) op: load left
90: LDA 0,2(2) load id adress
91: PUSH 0,0(6) push array adress to mp
92: POP 1,0(6) move the adress of ID
93: POP 0,0(6) copy bytes
94: ST 0,0(1) copy bytes
95: POP 0,0(6) pop the adress
96: LD 1,0(0) load bytes
97: PUSH 1,0(6) push bytes
98: POP 0,0(6) move result to register
99: OUT 0,1,0 output value in register[ac / fac]
100: GO 10,0,0 go to label
174: LABEL 11,0,0 generate label
175: MOV 3,2,0 restore the caller sp
176: LD 2,0(2) resotre the caller fp
177: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
178: LABEL 9,0,0 generate label
* call main function
* File: list_example.tm
* Standard prelude:
179: LDC 6,65535(0) load mp adress
180: ST 0,0(0) clear location 0
181: LDC 5,4095(0) load gp adress from location 1
182: ST 0,1(0) clear location 1
183: LDC 4,2000(0) load gp adress from location 1
184: LDC 2,60000(0) load first fp from location 2
185: LDC 3,60000(0) load first sp from location 2
186: ST 0,2(0) clear location 2
* End of standard prelude.
187: LDA 3,-1(3) stack expand
188: LDA 3,-1(3) stack expand
189: LDA 3,-1(3) stack expand
190: LDA 3,-1(3) stack expand
191: LDA 3,-1(3) stack expand
192: LDA 3,-1(3) stack expand
* function entry:
* dup
193: LDA 3,-1(3) stack expand for function variable
194: GO 12,0,0 go to label
195: MOV 1,2,0 store the caller fp temporarily
196: MOV 2,3,0 exchang the stack(context)
197: PUSH 1,0(3) push the caller fp
198: PUSH 0,0(3) push the return adress
199: MOV 3,2,0 restore the caller sp
200: LD 2,0(2) resotre the caller fp
201: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
202: LABEL 12,0,0 generate label
* function entry:
* freeList
203: LDA 3,-1(3) stack expand for function variable
204: GO 13,0,0 go to label
205: MOV 1,2,0 store the caller fp temporarily
206: MOV 2,3,0 exchang the stack(context)
207: PUSH 1,0(3) push the caller fp
208: PUSH 0,0(3) push the return adress
209: MOV 3,2,0 restore the caller sp
210: LD 2,0(2) resotre the caller fp
211: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
212: LABEL 13,0,0 generate label
* function entry:
* match
213: LDA 3,-1(3) stack expand for function variable
214: GO 14,0,0 go to label
215: MOV 1,2,0 store the caller fp temporarily
216: MOV 2,3,0 exchang the stack(context)
217: PUSH 1,0(3) push the caller fp
218: PUSH 0,0(3) push the return adress
219: MOV 3,2,0 restore the caller sp
220: LD 2,0(2) resotre the caller fp
221: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
222: LABEL 14,0,0 generate label
* function entry:
* removeList
223: LDA 3,-1(3) stack expand for function variable
224: GO 15,0,0 go to label
225: MOV 1,2,0 store the caller fp temporarily
226: MOV 2,3,0 exchang the stack(context)
227: PUSH 1,0(3) push the caller fp
228: PUSH 0,0(3) push the return adress
229: LD 0,2(2) load id value
230: PUSH 0,0(6) store exp
231: POP 1,0,6 load adress of lhs struct
232: LDC 0,2,0 load offset of member
233: ADD 0,0,1 compute the real adress if pointK
234: PUSH 0,0(6)
235: POP 0,0(6) load adress from mp
236: LD 1,0(0) copy bytes
237: PUSH 1,0(6) push a.x value into tmp
238: LDC 0,0(0) load integer const
239: PUSH 0,0(6) store exp
240: POP 1,0(6) pop right
241: POP 0,0(6) pop left
242: SUB 0,0,1 op <
243: JLE 0,2(7) br if true
244: LDC 0,0(0) false case
245: LDA 7,1(7) unconditional jmp
246: LDC 0,1(0) true case
247: PUSH 0,0(6)
248: POP 0,0(6) pop from the mp
249: JNE 0,1,7 true case:, execute if part
250: GO 16,0,0 go to label
251: MOV 3,2,0 restore the caller sp
252: LD 2,0(2) resotre the caller fp
253: RETURN 0,-1,3 return to the caller
254: GO 17,0,0 go to label
255: LABEL 16,0,0 generate label
* if: jump to else
256: LABEL 17,0,0 generate label
257: LD 0,2(2) load id value
258: PUSH 0,0(6) store exp
259: POP 1,0,6 load adress of lhs struct
260: LDC 0,2,0 load offset of member
261: ADD 0,0,1 compute the real adress if pointK
262: PUSH 0,0(6)
263: POP 0,0(6) load adress from mp
264: LD 1,0(0) copy bytes
265: PUSH 1,0(6) push a.x value into tmp
266: POP 0,0(6) pop right
267: LD 0,2(2) load id value
268: PUSH 0,0(6) store exp
269: POP 1,0,6 load adress of lhs struct
270: LDC 0,2,0 load offset of member
271: ADD 0,0,1 compute the real adress if pointK
272: PUSH 0,0(6)
273: POP 0,0(6) load adress from mp
274: LD 1,0(0) copy bytes
275: PUSH 1,0(6) push a.x value into tmp
276: LDC 0,1(0) load integer const
277: PUSH 0,0(6) store exp
278: POP 1,0(6) pop right
279: POP 0,0(6) pop left
280: SUB 0,0,1 op -
281: PUSH 0,0(6) op: load left
282: LD 0,2(2) load id value
283: PUSH 0,0(6) store exp
284: POP 1,0,6 load adress of lhs struct
285: LDC 0,2,0 load offset of member
286: ADD 0,0,1 compute the real adress if pointK
287: PUSH 0,0(6)
288: POP 1,0(6) move the adress of referenced
289: POP 0,0(6) copy bytes
290: ST 0,0(1) copy bytes
291: LDA 3,-1(3) stack expand
292: LD 0,2(2) load id value
293: PUSH 0,0(6) store exp
294: POP 1,0,6 load adress of lhs struct
295: LDC 0,0,0 load offset of member
296: ADD 0,0,1 compute the real adress if pointK
297: PUSH 0,0(6)
298: POP 0,0(6) load adress from mp
299: LD 1,0(0) copy bytes
300: PUSH 1,0(6) push a.x value into tmp
301: POP 1,0,6 load adress of lhs struct
302: LDC 0,1,0 load offset of member
303: ADD 0,0,1 compute the real adress if pointK
304: PUSH 0,0(6)
305: POP 0,0(6) load adress from mp
306: LD 1,0(0) copy bytes
307: PUSH 1,0(6) push a.x value into tmp
308: LDA 0,-2(2) load id adress
309: PUSH 0,0(6) push array adress to mp
310: POP 1,0(6) move the adress of ID
311: POP 0,0(6) copy bytes
312: ST 0,0(1) copy bytes
* while stmt:
313: LABEL 18,0,0 generate label
314: LD 0,-2(2) load id value
315: PUSH 0,0(6) store exp
316: LD 0,-5(5) load id value
317: PUSH 0,0(6) store exp
318: POP 1,0(6) pop right
319: POP 0,0(6) pop left
320: SUB 0,0,1 op ==, convertd_type
321: JNE 0,2(7) br if true
322: LDC 0,0(0) false case
323: LDA 7,1(7) unconditional jmp
324: LDC 0,1(0) true case
325: PUSH 0,0(6)
* push function parameters
326: LD 0,3(2) load id value
327: PUSH 0,0(6) store exp
328: POP 0,0(6) copy bytes
329: PUSH 0,0(3) PUSH bytes
* push function parameters
330: LD 0,-2(2) load id value
331: PUSH 0,0(6) store exp
332: POP 1,0,6 load adress of lhs struct
333: LDC 0,2,0 load offset of member
334: ADD 0,0,1 compute the real adress if pointK
335: PUSH 0,0(6)
336: POP 0,0(6) load adress from mp
337: LD 1,0(0) copy bytes
338: PUSH 1,0(6) push a.x value into tmp
339: POP 0,0(6) copy bytes
340: PUSH 0,0(3) PUSH bytes
341: LD 0,1(2) load env
342: PUSH 0,0(3) store env
* call function:
* match
343: LD 0,2(2) load id value
344: PUSH 0,0(6) store exp
345: POP 1,0,6 load adress of lhs struct
346: LDC 0,5,0 load offset of member
347: ADD 0,0,1 compute the real adress if pointK
348: PUSH 0,0(6)
349: POP 0,0(6) load adress from mp
350: LD 1,0(0) copy bytes
351: PUSH 1,0(6) push a.x value into tmp
352: LDC 0,354(0) store the return adress
353: POP 7,0(6) ujp to the function body
354: LDA 3,2(3) pop parameters
355: LDA 3,1(3) pop env
356: LDC 0,0(0) load integer const
357: PUSH 0,0(6) store exp
358: POP 1,0(6) pop right
359: POP 0,0(6) pop left
360: SUB 0,0,1 op ==, convertd_type
361: JNE 0,2(7) br if true
362: LDC 0,0(0) false case
363: LDA 7,1(7) unconditional jmp
364: LDC 0,1(0) true case
365: PUSH 0,0(6)
366: POP 1,0(6) pop right
367: POP 0,0(6) pop left
368: JEQ 0,3(7) br if false
369: JEQ 1,2(7) br if false
370: LDC 0,1(0) true case
371: LDA 7,1(7) unconditional jmp
372: LDC 0,0(0) false case
373: PUSH 0,0(6)
374: POP 0,0(6) pop from the mp
375: JNE 0,1,7 true case:, skip the break, execute the block code
376: GO 19,0,0 go to label
377: LD 0,-2(2) load id value
378: PUSH 0,0(6) store exp
379: POP 1,0,6 load adress of lhs struct
380: LDC 0,1,0 load offset of member
381: ADD 0,0,1 compute the real adress if pointK
382: PUSH 0,0(6)
383: POP 0,0(6) load adress from mp
384: LD 1,0(0) copy bytes
385: PUSH 1,0(6) push a.x value into tmp
386: LDA 0,-2(2) load id adress
387: PUSH 0,0(6) push array adress to mp
388: POP 1,0(6) move the adress of ID
389: POP 0,0(6) copy bytes
390: ST 0,0(1) copy bytes
391: GO 18,0,0 go to label
392: LABEL 19,0,0 generate label
393: LD 0,-2(2) load id value
394: PUSH 0,0(6) store exp
395: LD 0,-5(5) load id value
396: PUSH 0,0(6) store exp
397: POP 1,0(6) pop right
398: POP 0,0(6) pop left
399: SUB 0,0,1 op ==, convertd_type
400: JEQ 0,2(7) br if true
401: LDC 0,0(0) false case
402: LDA 7,1(7) unconditional jmp
403: LDC 0,1(0) true case
404: PUSH 0,0(6)
405: POP 0,0(6) pop from the mp
406: JNE 0,1,7 true case:, execute if part
407: GO 20,0,0 go to label
408: MOV 3,2,0 restore the caller sp
409: LD 2,0(2) resotre the caller fp
410: RETURN 0,-1,3 return to the caller
411: GO 21,0,0 go to label
412: LABEL 20,0,0 generate label
* if: jump to else
413: LABEL 21,0,0 generate label
414: LDA 3,-1(3) stack expand
415: LD 0,-2(2) load id value
416: PUSH 0,0(6) store exp
417: POP 1,0,6 load adress of lhs struct
418: LDC 0,0,0 load offset of member
419: ADD 0,0,1 compute the real adress if pointK
420: PUSH 0,0(6)
421: POP 0,0(6) load adress from mp
422: LD 1,0(0) copy bytes
423: PUSH 1,0(6) push a.x value into tmp
424: LDA 0,-3(2) load id adress
425: PUSH 0,0(6) push array adress to mp
426: POP 1,0(6) move the adress of ID
427: POP 0,0(6) copy bytes
428: ST 0,0(1) copy bytes
429: LDA 3,-1(3) stack expand
430: LD 0,-2(2) load id value
431: PUSH 0,0(6) store exp
432: POP 1,0,6 load adress of lhs struct
433: LDC 0,1,0 load offset of member
434: ADD 0,0,1 compute the real adress if pointK
435: PUSH 0,0(6)
436: POP 0,0(6) load adress from mp
437: LD 1,0(0) copy bytes
438: PUSH 1,0(6) push a.x value into tmp
439: LDA 0,-4(2) load id adress
440: PUSH 0,0(6) push array adress to mp
441: POP 1,0(6) move the adress of ID
442: POP 0,0(6) copy bytes
443: ST 0,0(1) copy bytes
444: LD 0,-4(2) load id value
445: PUSH 0,0(6) store exp
446: LD 0,-3(2) load id value
447: PUSH 0,0(6) store exp
448: POP 1,0,6 load adress of lhs struct
449: LDC 0,1,0 load offset of member
450: ADD 0,0,1 compute the real adress if pointK
451: PUSH 0,0(6)
452: POP 1,0(6) move the adress of referenced
453: POP 0,0(6) copy bytes
454: ST 0,0(1) copy bytes
455: LD 0,-4(2) load id value
456: PUSH 0,0(6) store exp
457: LD 0,-5(5) load id value
458: PUSH 0,0(6) store exp
459: POP 1,0(6) pop right
460: POP 0,0(6) pop left
461: SUB 0,0,1 op ==, convertd_type
462: JNE 0,2(7) br if true
463: LDC 0,0(0) false case
464: LDA 7,1(7) unconditional jmp
465: LDC 0,1(0) true case
466: PUSH 0,0(6)
467: POP 0,0(6) pop from the mp
468: JNE 0,1,7 true case:, execute if part
469: GO 22,0,0 go to label
470: LD 0,-3(2) load id value
471: PUSH 0,0(6) store exp
472: LD 0,-4(2) load id value
473: PUSH 0,0(6) store exp
474: POP 1,0,6 load adress of lhs struct
475: LDC 0,0,0 load offset of member
476: ADD 0,0,1 compute the real adress if pointK
477: PUSH 0,0(6)
478: POP 1,0(6) move the adress of referenced
479: POP 0,0(6) copy bytes
480: ST 0,0(1) copy bytes
481: GO 23,0,0 go to label
482: LABEL 22,0,0 generate label
* if: jump to else
483: LABEL 23,0,0 generate label
484: LD 0,-2(2) load id value
485: PUSH 0,0(6) store exp
486: LD 0,2(2) load id value
487: PUSH 0,0(6) store exp
488: POP 1,0,6 load adress of lhs struct
489: LDC 0,1,0 load offset of member
490: ADD 0,0,1 compute the real adress if pointK
491: PUSH 0,0(6)
492: POP 0,0(6) load adress from mp
493: LD 1,0(0) copy bytes
494: PUSH 1,0(6) push a.x value into tmp
495: POP 1,0(6) pop right
496: POP 0,0(6) pop left
497: SUB 0,0,1 op ==, convertd_type
498: JEQ 0,2(7) br if true
499: LDC 0,0(0) false case
500: LDA 7,1(7) unconditional jmp
501: LDC 0,1(0) true case
502: PUSH 0,0(6)
503: POP 0,0(6) pop from the mp
504: JNE 0,1,7 true case:, execute if part
505: GO 24,0,0 go to label
506: LD 0,-3(2) load id value
507: PUSH 0,0(6) store exp
508: LD 0,2(2) load id value
509: PUSH 0,0(6) store exp
510: POP 1,0,6 load adress of lhs struct
511: LDC 0,1,0 load offset of member
512: ADD 0,0,1 compute the real adress if pointK
513: PUSH 0,0(6)
514: POP 1,0(6) move the adress of referenced
515: POP 0,0(6) copy bytes
516: ST 0,0(1) copy bytes
517: GO 25,0,0 go to label
518: LABEL 24,0,0 generate label
* if: jump to else
519: LABEL 25,0,0 generate label
* push function parameters
520: LD 0,-2(2) load id value
521: PUSH 0,0(6) store exp
522: POP 0,0(6) copy bytes
523: PUSH 0,0(3) PUSH bytes
524: LD 0,1(2) load env
525: LD 0,1(0) load env1
526: PUSH 0,0(3) store env
* call function:
* free
527: LD 0,-7(5) load id value
528: PUSH 0,0(6) store exp
529: LDC 0,531(0) store the return adress
530: POP 7,0(6) ujp to the function body
531: LDA 3,1(3) pop parameters
532: LDA 3,1(3) pop env
533: MOV 3,2,0 restore the caller sp
534: LD 2,0(2) resotre the caller fp
535: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
536: LABEL 15,0,0 generate label
* function entry:
* append
537: LDA 3,-1(3) stack expand for function variable
538: GO 26,0,0 go to label
539: MOV 1,2,0 store the caller fp temporarily
540: MOV 2,3,0 exchang the stack(context)
541: PUSH 1,0(3) push the caller fp
542: PUSH 0,0(3) push the return adress
543: LD 0,3(2) load id value
544: PUSH 0,0(6) store exp
545: LD 0,-5(5) load id value
546: PUSH 0,0(6) store exp
547: POP 1,0(6) pop right
548: POP 0,0(6) pop left
549: SUB 0,0,1 op ==, convertd_type
550: JEQ 0,2(7) br if true
551: LDC 0,0(0) false case
552: LDA 7,1(7) unconditional jmp
553: LDC 0,1(0) true case
554: PUSH 0,0(6)
555: POP 0,0(6) pop from the mp
556: JNE 0,1,7 true case:, execute if part
557: GO 27,0,0 go to label
558: MOV 3,2,0 restore the caller sp
559: LD 2,0(2) resotre the caller fp
560: RETURN 0,-1,3 return to the caller
561: GO 28,0,0 go to label
562: LABEL 27,0,0 generate label
* if: jump to else
563: LABEL 28,0,0 generate label
564: LD 0,2(2) load id value
565: PUSH 0,0(6) store exp
566: POP 1,0,6 load adress of lhs struct
567: LDC 0,2,0 load offset of member
568: ADD 0,0,1 compute the real adress if pointK
569: PUSH 0,0(6)
570: POP 0,0(6) load adress from mp
571: LD 1,0(0) copy bytes
572: PUSH 1,0(6) push a.x value into tmp
573: POP 0,0(6) pop right
574: LD 0,2(2) load id value
575: PUSH 0,0(6) store exp
576: POP 1,0,6 load adress of lhs struct
577: LDC 0,2,0 load offset of member
578: ADD 0,0,1 compute the real adress if pointK
579: PUSH 0,0(6)
580: POP 0,0(6) load adress from mp
581: LD 1,0(0) copy bytes
582: PUSH 1,0(6) push a.x value into tmp
583: LDC 0,1(0) load integer const
584: PUSH 0,0(6) store exp
585: POP 1,0(6) pop right
586: POP 0,0(6) pop left
587: ADD 0,0,1 op +
588: PUSH 0,0(6) op: load left
589: LD 0,2(2) load id value
590: PUSH 0,0(6) store exp
591: POP 1,0,6 load adress of lhs struct
592: LDC 0,2,0 load offset of member
593: ADD 0,0,1 compute the real adress if pointK
594: PUSH 0,0(6)
595: POP 1,0(6) move the adress of referenced
596: POP 0,0(6) copy bytes
597: ST 0,0(1) copy bytes
598: LD 0,3(2) load id value
599: PUSH 0,0(6) store exp
600: LD 0,2(2) load id value
601: PUSH 0,0(6) store exp
602: POP 1,0,6 load adress of lhs struct
603: LDC 0,1,0 load offset of member
604: ADD 0,0,1 compute the real adress if pointK
605: PUSH 0,0(6)
606: POP 0,0(6) load adress from mp
607: LD 1,0(0) copy bytes
608: PUSH 1,0(6) push a.x value into tmp
609: POP 1,0,6 load adress of lhs struct
610: LDC 0,1,0 load offset of member
611: ADD 0,0,1 compute the real adress if pointK
612: PUSH 0,0(6)
613: POP 1,0(6) move the adress of referenced
614: POP 0,0(6) copy bytes
615: ST 0,0(1) copy bytes
616: LD 0,2(2) load id value
617: PUSH 0,0(6) store exp
618: POP 1,0,6 load adress of lhs struct
619: LDC 0,1,0 load offset of member
620: ADD 0,0,1 compute the real adress if pointK
621: PUSH 0,0(6)
622: POP 0,0(6) load adress from mp
623: LD 1,0(0) copy bytes
624: PUSH 1,0(6) push a.x value into tmp
625: LD 0,3(2) load id value
626: PUSH 0,0(6) store exp
627: POP 1,0,6 load adress of lhs struct
628: LDC 0,0,0 load offset of member
629: ADD 0,0,1 compute the real adress if pointK
630: PUSH 0,0(6)
631: POP 1,0(6) move the adress of referenced
632: POP 0,0(6) copy bytes
633: ST 0,0(1) copy bytes
634: LD 0,-5(5) load id value
635: PUSH 0,0(6) store exp
636: LD 0,3(2) load id value
637: PUSH 0,0(6) store exp
638: POP 1,0,6 load adress of lhs struct
639: LDC 0,1,0 load offset of member
640: ADD 0,0,1 compute the real adress if pointK
641: PUSH 0,0(6)
642: POP 1,0(6) move the adress of referenced
643: POP 0,0(6) copy bytes
644: ST 0,0(1) copy bytes
645: LD 0,3(2) load id value
646: PUSH 0,0(6) store exp
647: LD 0,2(2) load id value
648: PUSH 0,0(6) store exp
649: POP 1,0,6 load adress of lhs struct
650: LDC 0,1,0 load offset of member
651: ADD 0,0,1 compute the real adress if pointK
652: PUSH 0,0(6)
653: POP 1,0(6) move the adress of referenced
654: POP 0,0(6) copy bytes
655: ST 0,0(1) copy bytes
656: MOV 3,2,0 restore the caller sp
657: LD 2,0(2) resotre the caller fp
658: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
659: LABEL 26,0,0 generate label
* function entry:
* insertSortedList
660: LDA 3,-1(3) stack expand for function variable
661: GO 29,0,0 go to label
662: MOV 1,2,0 store the caller fp temporarily
663: MOV 2,3,0 exchang the stack(context)
664: PUSH 1,0(3) push the caller fp
665: PUSH 0,0(3) push the return adress
666: LD 0,3(2) load id value
667: PUSH 0,0(6) store exp
668: LD 0,-5(5) load id value
669: PUSH 0,0(6) store exp
670: POP 1,0(6) pop right
671: POP 0,0(6) pop left
672: SUB 0,0,1 op ==, convertd_type
673: JEQ 0,2(7) br if true
674: LDC 0,0(0) false case
675: LDA 7,1(7) unconditional jmp
676: LDC 0,1(0) true case
677: PUSH 0,0(6)
678: POP 0,0(6) pop from the mp
679: JNE 0,1,7 true case:, execute if part
680: GO 30,0,0 go to label
681: MOV 3,2,0 restore the caller sp
682: LD 2,0(2) resotre the caller fp
683: RETURN 0,-1,3 return to the caller
684: GO 31,0,0 go to label
685: LABEL 30,0,0 generate label
* if: jump to else
686: LABEL 31,0,0 generate label
687: LDA 3,-1(3) stack expand
688: LDC 0,10(0) load integer const
689: PUSH 0,0(6) store exp
690: LDA 0,-2(2) load id adress
691: PUSH 0,0(6) push array adress to mp
692: POP 1,0(6) move the adress of ID
693: POP 0,0(6) copy bytes
694: ST 0,0(1) copy bytes
695: LD 0,2(2) load id value
696: PUSH 0,0(6) store exp
697: POP 1,0,6 load adress of lhs struct
698: LDC 0,2,0 load offset of member
699: ADD 0,0,1 compute the real adress if pointK
700: PUSH 0,0(6)
701: POP 0,0(6) load adress from mp
702: LD 1,0(0) copy bytes
703: PUSH 1,0(6) push a.x value into tmp
704: LDC 0,1(0) load integer const
705: PUSH 0,0(6) store exp
706: POP 1,0(6) pop right
707: POP 0,0(6) pop left
708: ADD 0,0,1 op +
709: PUSH 0,0(6) op: load left
710: LD 0,2(2) load id value
711: PUSH 0,0(6) store exp
712: POP 1,0,6 load adress of lhs struct
713: LDC 0,2,0 load offset of member
714: ADD 0,0,1 compute the real adress if pointK
715: PUSH 0,0(6)
716: POP 1,0(6) move the adress of referenced
717: POP 0,0(6) copy bytes
718: ST 0,0(1) copy bytes
719: LDA 3,-1(3) stack expand
720: LD 0,2(2) load id value
721: PUSH 0,0(6) store exp
722: POP 1,0,6 load adress of lhs struct
723: LDC 0,0,0 load offset of member
724: ADD 0,0,1 compute the real adress if pointK
725: PUSH 0,0(6)
726: POP 0,0(6) load adress from mp
727: LD 1,0(0) copy bytes
728: PUSH 1,0(6) push a.x value into tmp
729: LDA 0,-3(2) load id adress
730: PUSH 0,0(6) push array adress to mp
731: POP 1,0(6) move the adress of ID
732: POP 0,0(6) copy bytes
733: ST 0,0(1) copy bytes
* while stmt:
734: LABEL 32,0,0 generate label
735: LD 0,-3(2) load id value
736: PUSH 0,0(6) store exp
737: POP 1,0,6 load adress of lhs struct
738: LDC 0,1,0 load offset of member
739: ADD 0,0,1 compute the real adress if pointK
740: PUSH 0,0(6)
741: POP 0,0(6) load adress from mp
742: LD 1,0(0) copy bytes
743: PUSH 1,0(6) push a.x value into tmp
744: LD 0,-5(5) load id value
745: PUSH 0,0(6) store exp
746: POP 1,0(6) pop right
747: POP 0,0(6) pop left
748: SUB 0,0,1 op ==, convertd_type
749: JNE 0,2(7) br if true
750: LDC 0,0(0) false case
751: LDA 7,1(7) unconditional jmp
752: LDC 0,1(0) true case
753: PUSH 0,0(6)
754: POP 0,0(6) pop from the mp
755: JNE 0,1,7 true case:, skip the break, execute the block code
756: GO 33,0,0 go to label
* push function parameters
757: LD 0,3(2) load id value
758: PUSH 0,0(6) store exp
759: POP 1,0,6 load adress of lhs struct
760: LDC 0,2,0 load offset of member
761: ADD 0,0,1 compute the real adress if pointK
762: PUSH 0,0(6)
763: POP 0,0(6) load adress from mp
764: LD 1,0(0) copy bytes
765: PUSH 1,0(6) push a.x value into tmp
766: POP 0,0(6) copy bytes
767: PUSH 0,0(3) PUSH bytes
* push function parameters
768: LD 0,-3(2) load id value
769: PUSH 0,0(6) store exp
770: POP 1,0,6 load adress of lhs struct
771: LDC 0,1,0 load offset of member
772: ADD 0,0,1 compute the real adress if pointK
773: PUSH 0,0(6)
774: POP 0,0(6) load adress from mp
775: LD 1,0(0) copy bytes
776: PUSH 1,0(6) push a.x value into tmp
777: POP 1,0,6 load adress of lhs struct
778: LDC 0,2,0 load offset of member
779: ADD 0,0,1 compute the real adress if pointK
780: PUSH 0,0(6)
781: POP 0,0(6) load adress from mp
782: LD 1,0(0) copy bytes
783: PUSH 1,0(6) push a.x value into tmp
784: POP 0,0(6) copy bytes
785: PUSH 0,0(3) PUSH bytes
786: LD 0,1(2) load env
787: PUSH 0,0(3) store env
* call function:
* match
788: LD 0,2(2) load id value
789: PUSH 0,0(6) store exp
790: POP 1,0,6 load adress of lhs struct
791: LDC 0,5,0 load offset of member
792: ADD 0,0,1 compute the real adress if pointK
793: PUSH 0,0(6)
794: POP 0,0(6) load adress from mp
795: LD 1,0(0) copy bytes
796: PUSH 1,0(6) push a.x value into tmp
797: LDC 0,799(0) store the return adress
798: POP 7,0(6) ujp to the function body
799: LDA 3,2(3) pop parameters
800: LDA 3,1(3) pop env
801: LDC 0,0(0) load integer const
802: PUSH 0,0(6) store exp
803: POP 1,0(6) pop right
804: POP 0,0(6) pop left
805: SUB 0,0,1 op <
806: JGE 0,2(7) br if true
807: LDC 0,0(0) false case
808: LDA 7,1(7) unconditional jmp
809: LDC 0,1(0) true case
810: PUSH 0,0(6)
811: POP 0,0(6) pop from the mp
812: JNE 0,1,7 true case:, execute if part
813: GO 34,0,0 go to label
814: GO 33,0,0 go to label
815: GO 35,0,0 go to label
816: LABEL 34,0,0 generate label
* if: jump to else
817: LABEL 35,0,0 generate label
818: LD 0,-3(2) load id value
819: PUSH 0,0(6) store exp
820: POP 1,0,6 load adress of lhs struct
821: LDC 0,1,0 load offset of member
822: ADD 0,0,1 compute the real adress if pointK
823: PUSH 0,0(6)
824: POP 0,0(6) load adress from mp
825: LD 1,0(0) copy bytes
826: PUSH 1,0(6) push a.x value into tmp
827: LDA 0,-3(2) load id adress
828: PUSH 0,0(6) push array adress to mp
829: POP 1,0(6) move the adress of ID
830: POP 0,0(6) copy bytes
831: ST 0,0(1) copy bytes
832: GO 32,0,0 go to label
833: LABEL 33,0,0 generate label
834: LDA 3,-1(3) stack expand
835: LD 0,-3(2) load id value
836: PUSH 0,0(6) store exp
837: POP 1,0,6 load adress of lhs struct
838: LDC 0,1,0 load offset of member
839: ADD 0,0,1 compute the real adress if pointK
840: PUSH 0,0(6)
841: POP 0,0(6) load adress from mp
842: LD 1,0(0) copy bytes
843: PUSH 1,0(6) push a.x value into tmp
844: LDA 0,-4(2) load id adress
845: PUSH 0,0(6) push array adress to mp
846: POP 1,0(6) move the adress of ID
847: POP 0,0(6) copy bytes
848: ST 0,0(1) copy bytes
849: LD 0,3(2) load id value
850: PUSH 0,0(6) store exp
851: LD 0,-3(2) load id value
852: PUSH 0,0(6) store exp
853: POP 1,0,6 load adress of lhs struct
854: LDC 0,1,0 load offset of member
855: ADD 0,0,1 compute the real adress if pointK
856: PUSH 0,0(6)
857: POP 1,0(6) move the adress of referenced
858: POP 0,0(6) copy bytes
859: ST 0,0(1) copy bytes
860: LD 0,-4(2) load id value
861: PUSH 0,0(6) store exp
862: LD 0,3(2) load id value
863: PUSH 0,0(6) store exp
864: POP 1,0,6 load adress of lhs struct
865: LDC 0,1,0 load offset of member
866: ADD 0,0,1 compute the real adress if pointK
867: PUSH 0,0(6)
868: POP 1,0(6) move the adress of referenced
869: POP 0,0(6) copy bytes
870: ST 0,0(1) copy bytes
871: LD 0,-3(2) load id value
872: PUSH 0,0(6) store exp
873: LD 0,3(2) load id value
874: PUSH 0,0(6) store exp
875: POP 1,0,6 load adress of lhs struct
876: LDC 0,0,0 load offset of member
877: ADD 0,0,1 compute the real adress if pointK
878: PUSH 0,0(6)
879: POP 1,0(6) move the adress of referenced
880: POP 0,0(6) copy bytes
881: ST 0,0(1) copy bytes
882: LD 0,-4(2) load id value
883: PUSH 0,0(6) store exp
884: LD 0,-5(5) load id value
885: PUSH 0,0(6) store exp
886: POP 1,0(6) pop right
887: POP 0,0(6) pop left
888: SUB 0,0,1 op ==, convertd_type
889: JNE 0,2(7) br if true
890: LDC 0,0(0) false case
891: LDA 7,1(7) unconditional jmp
892: LDC 0,1(0) true case
893: PUSH 0,0(6)
894: POP 0,0(6) pop from the mp
895: JNE 0,1,7 true case:, execute if part
896: GO 36,0,0 go to label
897: LD 0,3(2) load id value
898: PUSH 0,0(6) store exp
899: LD 0,-4(2) load id value
900: PUSH 0,0(6) store exp
901: POP 1,0,6 load adress of lhs struct
902: LDC 0,0,0 load offset of member
903: ADD 0,0,1 compute the real adress if pointK
904: PUSH 0,0(6)
905: POP 1,0(6) move the adress of referenced
906: POP 0,0(6) copy bytes
907: ST 0,0(1) copy bytes
908: GO 37,0,0 go to label
909: LABEL 36,0,0 generate label
* if: jump to else
910: LD 0,3(2) load id value
911: PUSH 0,0(6) store exp
912: LD 0,2(2) load id value
913: PUSH 0,0(6) store exp
914: POP 1,0,6 load adress of lhs struct
915: LDC 0,1,0 load offset of member
916: ADD 0,0,1 compute the real adress if pointK
917: PUSH 0,0(6)
918: POP 1,0(6) move the adress of referenced
919: POP 0,0(6) copy bytes
920: ST 0,0(1) copy bytes
921: LABEL 37,0,0 generate label
922: MOV 3,2,0 restore the caller sp
923: LD 2,0(2) resotre the caller fp
924: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
925: LABEL 29,0,0 generate label
* function entry:
* popRight
926: LDA 3,-1(3) stack expand for function variable
927: GO 38,0,0 go to label
928: MOV 1,2,0 store the caller fp temporarily
929: MOV 2,3,0 exchang the stack(context)
930: PUSH 1,0(3) push the caller fp
931: PUSH 0,0(3) push the return adress
932: LD 0,2(2) load id value
933: PUSH 0,0(6) store exp
934: LD 0,-5(5) load id value
935: PUSH 0,0(6) store exp
936: POP 1,0(6) pop right
937: POP 0,0(6) pop left
938: SUB 0,0,1 op ==, convertd_type
939: JEQ 0,2(7) br if true
940: LDC 0,0(0) false case
941: LDA 7,1(7) unconditional jmp
942: LDC 0,1(0) true case
943: PUSH 0,0(6)
944: LD 0,2(2) load id value
945: PUSH 0,0(6) store exp
946: POP 1,0,6 load adress of lhs struct
947: LDC 0,2,0 load offset of member
948: ADD 0,0,1 compute the real adress if pointK
949: PUSH 0,0(6)
950: POP 0,0(6) load adress from mp
951: LD 1,0(0) copy bytes
952: PUSH 1,0(6) push a.x value into tmp
953: LDC 0,0(0) load integer const
954: PUSH 0,0(6) store exp
955: POP 1,0(6) pop right
956: POP 0,0(6) pop left
957: SUB 0,0,1 op <
958: JLE 0,2(7) br if true
959: LDC 0,0(0) false case
960: LDA 7,1(7) unconditional jmp
961: LDC 0,1(0) true case
962: PUSH 0,0(6)
963: POP 1,0(6) pop right
964: POP 0,0(6) pop left
965: JNE 0,3(7) br if true
966: JNE 1,2(7) br if true
967: LDC 0,0(0) false case
968: LDA 7,1(7) unconditional jmp
969: LDC 0,1(0) true case
970: PUSH 0,0(6)
971: POP 0,0(6) pop from the mp
972: JNE 0,1,7 true case:, execute if part
973: GO 39,0,0 go to label
974: MOV 3,2,0 restore the caller sp
975: LD 2,0(2) resotre the caller fp
976: RETURN 0,-1,3 return to the caller
977: GO 40,0,0 go to label
978: LABEL 39,0,0 generate label
* if: jump to else
979: LABEL 40,0,0 generate label
980: LD 0,2(2) load id value
981: PUSH 0,0(6) store exp
982: POP 1,0,6 load adress of lhs struct
983: LDC 0,2,0 load offset of member
984: ADD 0,0,1 compute the real adress if pointK
985: PUSH 0,0(6)
986: POP 0,0(6) load adress from mp
987: LD 1,0(0) copy bytes
988: PUSH 1,0(6) push a.x value into tmp
989: POP 0,0(6) pop right
990: LD 0,2(2) load id value
991: PUSH 0,0(6) store exp
992: POP 1,0,6 load adress of lhs struct
993: LDC 0,2,0 load offset of member
994: ADD 0,0,1 compute the real adress if pointK
995: PUSH 0,0(6)
996: POP 0,0(6) load adress from mp
997: LD 1,0(0) copy bytes
998: PUSH 1,0(6) push a.x value into tmp
999: LDC 0,1(0) load integer const
1000: PUSH 0,0(6) store exp
1001: POP 1,0(6) pop right
1002: POP 0,0(6) pop left
1003: SUB 0,0,1 op -
1004: PUSH 0,0(6) op: load left
1005: LD 0,2(2) load id value
1006: PUSH 0,0(6) store exp
1007: POP 1,0,6 load adress of lhs struct
1008: LDC 0,2,0 load offset of member
1009: ADD 0,0,1 compute the real adress if pointK
1010: PUSH 0,0(6)
1011: POP 1,0(6) move the adress of referenced
1012: POP 0,0(6) copy bytes
1013: ST 0,0(1) copy bytes