-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash_example.tm
More file actions
1903 lines (1903 loc) · 68.3 KB
/
Copy pathhash_example.tm
File metadata and controls
1903 lines (1903 loc) · 68.3 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: hash_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,-62(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,-63(5) set function adress
19: GO 63,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 63,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,-64(5) set function adress
35: GO 64,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 64,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,-65(5) set function adress
51: GO 65,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 66,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 67,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 66,0,0 go to label
3682: LABEL 67,0,0 generate label
3683: MOV 3,2,0 restore the caller sp
3684: LD 2,0(2) resotre the caller fp
3685: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
3686: LABEL 65,0,0 generate label
* call main function
* File: hash_example.tm
* Standard prelude:
3687: LDC 6,65535(0) load mp adress
3688: ST 0,0(0) clear location 0
3689: LDC 5,4095(0) load gp adress from location 1
3690: ST 0,1(0) clear location 1
3691: LDC 4,2000(0) load gp adress from location 1
3692: LDC 2,60000(0) load first fp from location 2
3693: LDC 3,60000(0) load first sp from location 2
3694: ST 0,2(0) clear location 2
* End of standard prelude.
3695: LDA 3,-1(3) stack expand
3696: LDA 3,-1(3) stack expand
3697: LDA 3,-1(3) stack expand
3698: LDA 3,-1(3) stack expand
3699: LDA 3,-1(3) stack expand
3700: LDA 3,-1(3) stack expand
* function entry:
* hash_func
3701: LDA 3,-1(3) stack expand for function variable
3702: GO 68,0,0 go to label
3703: MOV 1,2,0 store the caller fp temporarily
3704: MOV 2,3,0 exchang the stack(context)
3705: PUSH 1,0(3) push the caller fp
3706: PUSH 0,0(3) push the return adress
3707: MOV 3,2,0 restore the caller sp
3708: LD 2,0(2) resotre the caller fp
3709: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
3710: LABEL 68,0,0 generate label
* function entry:
* get_idx
3711: LDA 3,-1(3) stack expand for function variable
3712: GO 69,0,0 go to label
3713: MOV 1,2,0 store the caller fp temporarily
3714: MOV 2,3,0 exchang the stack(context)
3715: PUSH 1,0(3) push the caller fp
3716: PUSH 0,0(3) push the return adress
* push function parameters
3717: LD 0,3(2) load id value
3718: PUSH 0,0(6) store exp
3719: POP 0,0(6) copy bytes
3720: PUSH 0,0(3) PUSH bytes
3721: LD 0,1(2) load env
3722: PUSH 0,0(3) store env
* call function:
* hash_func
3723: LD 0,2(2) load id value
3724: PUSH 0,0(6) store exp
3725: POP 1,0,6 load adress of lhs struct
3726: LDC 0,3,0 load offset of member
3727: ADD 0,0,1 compute the real adress if pointK
3728: PUSH 0,0(6)
3729: POP 0,0(6) load adress from mp
3730: LD 1,0(0) copy bytes
3731: PUSH 1,0(6) push a.x value into tmp
3732: LDC 0,3734(0) store the return adress
3733: POP 7,0(6) ujp to the function body
3734: LDA 3,1(3) pop parameters
3735: LDA 3,1(3) pop env
3736: LD 0,2(2) load id value
3737: PUSH 0,0(6) store exp
3738: POP 1,0,6 load adress of lhs struct
3739: LDC 0,1,0 load offset of member
3740: ADD 0,0,1 compute the real adress if pointK
3741: PUSH 0,0(6)
3742: POP 0,0(6) load adress from mp
3743: LD 1,0(0) copy bytes
3744: PUSH 1,0(6) push a.x value into tmp
3745: POP 1,0(6) pop right
3746: POP 0,0(6) pop left
3747: MOD 0,0,1 op %
3748: PUSH 0,0(6) op: load left
3749: MOV 3,2,0 restore the caller sp
3750: LD 2,0(2) resotre the caller fp
3751: RETURN 0,-1,3 return to the caller
3752: MOV 3,2,0 restore the caller sp
3753: LD 2,0(2) resotre the caller fp
3754: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
3755: LABEL 69,0,0 generate label
* function entry:
* slot_free
3756: LDA 3,-1(3) stack expand for function variable
3757: GO 70,0,0 go to label
3758: MOV 1,2,0 store the caller fp temporarily
3759: MOV 2,3,0 exchang the stack(context)
3760: PUSH 1,0(3) push the caller fp
3761: PUSH 0,0(3) push the return adress
3762: MOV 3,2,0 restore the caller sp
3763: LD 2,0(2) resotre the caller fp
3764: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
3765: LABEL 70,0,0 generate label
* function entry:
* equal
3766: LDA 3,-1(3) stack expand for function variable
3767: GO 71,0,0 go to label
3768: MOV 1,2,0 store the caller fp temporarily
3769: MOV 2,3,0 exchang the stack(context)
3770: PUSH 1,0(3) push the caller fp
3771: PUSH 0,0(3) push the return adress
3772: MOV 3,2,0 restore the caller sp
3773: LD 2,0(2) resotre the caller fp
3774: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
3775: LABEL 71,0,0 generate label
* function entry:
* put
3776: LDA 3,-1(3) stack expand for function variable
3777: GO 72,0,0 go to label
3778: MOV 1,2,0 store the caller fp temporarily
3779: MOV 2,3,0 exchang the stack(context)
3780: PUSH 1,0(3) push the caller fp
3781: PUSH 0,0(3) push the return adress
3782: LDA 3,-1(3) stack expand
* push function parameters
3783: LD 0,3(2) load id value
3784: PUSH 0,0(6) store exp
3785: POP 0,0(6) copy bytes
3786: PUSH 0,0(3) PUSH bytes
3787: LD 0,2(2) load id value
3788: PUSH 0,0(6) store exp
3789: POP 0,0(6)
3790: PUSH 0,0(3)
3791: LD 0,1(2) load env
3792: PUSH 0,0(3) store env
* call function:
* get_idx
3793: LD 0,2(2) load id value
3794: PUSH 0,0(6) store exp
3795: POP 1,0,6 load adress of lhs struct
3796: LDC 0,4,0 load offset of member
3797: ADD 0,0,1 compute the real adress if pointK
3798: PUSH 0,0(6)
3799: POP 0,0(6) load adress from mp
3800: LD 1,0(0) copy bytes
3801: PUSH 1,0(6) push a.x value into tmp
3802: LDC 0,3804(0) store the return adress
3803: POP 7,0(6) ujp to the function body
3804: LDA 3,1(3) pop parameters
3805: LDA 3,1(3) pop env
3806: LDA 3,1(3) pop parameters
3807: LDA 0,-2(2) load id adress
3808: PUSH 0,0(6) push array adress to mp
3809: POP 1,0(6) move the adress of ID
3810: POP 0,0(6) copy bytes
3811: ST 0,0(1) copy bytes
3812: LDA 3,-1(3) stack expand
3813: LD 0,2(2) load id value
3814: PUSH 0,0(6) store exp
3815: POP 1,0,6 load adress of lhs struct
3816: LDC 0,0,0 load offset of member
3817: ADD 0,0,1 compute the real adress if pointK
3818: PUSH 0,0(6)
3819: POP 0,0(6) load adress from mp
3820: LD 1,0(0) copy bytes
3821: PUSH 1,0(6) push a.x value into tmp
3822: LD 0,-2(2) load id value
3823: PUSH 0,0(6) store exp
3824: POP 0,0(6) load index value to ac
3825: LDC 1,3,0 load pointkind size
3826: MUL 0,1,0 compute the offset
3827: POP 1,0(6) load lhs adress to ac1
3828: ADD 0,1,0 compute the real index adress
3829: PUSH 0,0(6) op: load left
3830: LDA 0,-3(2) load id adress
3831: PUSH 0,0(6) push array adress to mp
3832: POP 1,0(6) move the adress of ID
3833: POP 0,0(6) copy bytes
3834: ST 0,0(1) copy bytes
3835: LD 0,-3(2) load id value
3836: PUSH 0,0(6) store exp
3837: POP 1,0,6 load adress of lhs struct
3838: LDC 0,1,0 load offset of member
3839: ADD 0,0,1 compute the real adress if pointK
3840: PUSH 0,0(6)
3841: POP 0,0(6) load adress from mp
3842: LD 1,0(0) copy bytes
3843: PUSH 1,0(6) push a.x value into tmp
3844: LD 0,-62(5) load id value
3845: PUSH 0,0(6) store exp
3846: POP 1,0(6) pop right
3847: POP 0,0(6) pop left
3848: SUB 0,0,1 op ==, convertd_type
3849: JEQ 0,2(7) br if true
3850: LDC 0,0(0) false case
3851: LDA 7,1(7) unconditional jmp
3852: LDC 0,1(0) true case
3853: PUSH 0,0(6)
3854: POP 0,0(6) pop from the mp
3855: JNE 0,1,7 true case:, execute if part
3856: GO 73,0,0 go to label
3857: LD 0,3(2) load id value
3858: PUSH 0,0(6) store exp
3859: LD 0,-3(2) load id value
3860: PUSH 0,0(6) store exp
3861: POP 1,0,6 load adress of lhs struct
3862: LDC 0,1,0 load offset of member
3863: ADD 0,0,1 compute the real adress if pointK
3864: PUSH 0,0(6)
3865: POP 1,0(6) move the adress of referenced
3866: POP 0,0(6) copy bytes
3867: ST 0,0(1) copy bytes
3868: LD 0,4(2) load id value
3869: PUSH 0,0(6) store exp
3870: LD 0,-3(2) load id value
3871: PUSH 0,0(6) store exp
3872: POP 1,0,6 load adress of lhs struct
3873: LDC 0,2,0 load offset of member
3874: ADD 0,0,1 compute the real adress if pointK
3875: PUSH 0,0(6)
3876: POP 1,0(6) move the adress of referenced
3877: POP 0,0(6) copy bytes
3878: ST 0,0(1) copy bytes
3879: LD 0,-62(5) load id value
3880: PUSH 0,0(6) store exp
3881: LD 0,-3(2) load id value
3882: PUSH 0,0(6) store exp
3883: POP 1,0,6 load adress of lhs struct
3884: LDC 0,0,0 load offset of member
3885: ADD 0,0,1 compute the real adress if pointK
3886: PUSH 0,0(6)
3887: POP 1,0(6) move the adress of referenced
3888: POP 0,0(6) copy bytes
3889: ST 0,0(1) copy bytes
3890: MOV 3,2,0 restore the caller sp
3891: LD 2,0(2) resotre the caller fp
3892: RETURN 0,-1,3 return to the caller
3893: GO 74,0,0 go to label
3894: LABEL 73,0,0 generate label
* if: jump to else
3895: LABEL 74,0,0 generate label
3896: LDA 3,-1(3) stack expand
* push function parameters
3897: LDC 0,3,0 load size of exp
3898: PUSH 0,0(6)
3899: POP 0,0(6) copy bytes
3900: PUSH 0,0(3) PUSH bytes
3901: LD 0,1(2) load env
3902: LD 0,1(0) load env1
3903: PUSH 0,0(3) store env
* call function:
* malloc
3904: LD 0,-63(5) load id value
3905: PUSH 0,0(6) store exp
3906: LDC 0,3908(0) store the return adress
3907: POP 7,0(6) ujp to the function body
3908: LDA 3,1(3) pop parameters
3909: LDA 3,1(3) pop env
3910: LDA 0,-4(2) load id adress
3911: PUSH 0,0(6) push array adress to mp
3912: POP 1,0(6) move the adress of ID
3913: POP 0,0(6) copy bytes
3914: ST 0,0(1) copy bytes
3915: LD 0,3(2) load id value
3916: PUSH 0,0(6) store exp
3917: LD 0,-4(2) load id value
3918: PUSH 0,0(6) store exp
3919: POP 1,0,6 load adress of lhs struct
3920: LDC 0,1,0 load offset of member
3921: ADD 0,0,1 compute the real adress if pointK
3922: PUSH 0,0(6)
3923: POP 1,0(6) move the adress of referenced
3924: POP 0,0(6) copy bytes
3925: ST 0,0(1) copy bytes
3926: LD 0,4(2) load id value
3927: PUSH 0,0(6) store exp
3928: LD 0,-4(2) load id value
3929: PUSH 0,0(6) store exp
3930: POP 1,0,6 load adress of lhs struct
3931: LDC 0,2,0 load offset of member
3932: ADD 0,0,1 compute the real adress if pointK
3933: PUSH 0,0(6)
3934: POP 1,0(6) move the adress of referenced
3935: POP 0,0(6) copy bytes
3936: ST 0,0(1) copy bytes
3937: LD 0,-3(2) load id value
3938: PUSH 0,0(6) store exp
3939: POP 1,0,6 load adress of lhs struct
3940: LDC 0,0,0 load offset of member
3941: ADD 0,0,1 compute the real adress if pointK
3942: PUSH 0,0(6)
3943: POP 0,0(6) load adress from mp
3944: LD 1,0(0) copy bytes
3945: PUSH 1,0(6) push a.x value into tmp
3946: LD 0,-4(2) load id value
3947: PUSH 0,0(6) store exp
3948: POP 1,0,6 load adress of lhs struct
3949: LDC 0,0,0 load offset of member
3950: ADD 0,0,1 compute the real adress if pointK
3951: PUSH 0,0(6)
3952: POP 1,0(6) move the adress of referenced
3953: POP 0,0(6) copy bytes
3954: ST 0,0(1) copy bytes
3955: LD 0,-4(2) load id value
3956: PUSH 0,0(6) store exp
3957: LD 0,-3(2) load id value
3958: PUSH 0,0(6) store exp
3959: POP 1,0,6 load adress of lhs struct
3960: LDC 0,0,0 load offset of member
3961: ADD 0,0,1 compute the real adress if pointK
3962: PUSH 0,0(6)
3963: POP 1,0(6) move the adress of referenced
3964: POP 0,0(6) copy bytes
3965: ST 0,0(1) copy bytes
3966: MOV 3,2,0 restore the caller sp
3967: LD 2,0(2) resotre the caller fp
3968: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
3969: LABEL 72,0,0 generate label
* function entry:
* get
3970: LDA 3,-1(3) stack expand for function variable
3971: GO 75,0,0 go to label
3972: MOV 1,2,0 store the caller fp temporarily
3973: MOV 2,3,0 exchang the stack(context)
3974: PUSH 1,0(3) push the caller fp
3975: PUSH 0,0(3) push the return adress
3976: LDA 3,-1(3) stack expand
* push function parameters
3977: LD 0,3(2) load id value
3978: PUSH 0,0(6) store exp
3979: POP 0,0(6) copy bytes
3980: PUSH 0,0(3) PUSH bytes
3981: LD 0,2(2) load id value
3982: PUSH 0,0(6) store exp
3983: POP 0,0(6)
3984: PUSH 0,0(3)
3985: LD 0,1(2) load env
3986: PUSH 0,0(3) store env
* call function:
* get_idx
3987: LD 0,2(2) load id value
3988: PUSH 0,0(6) store exp
3989: POP 1,0,6 load adress of lhs struct
3990: LDC 0,4,0 load offset of member
3991: ADD 0,0,1 compute the real adress if pointK
3992: PUSH 0,0(6)
3993: POP 0,0(6) load adress from mp
3994: LD 1,0(0) copy bytes
3995: PUSH 1,0(6) push a.x value into tmp
3996: LDC 0,3998(0) store the return adress
3997: POP 7,0(6) ujp to the function body
3998: LDA 3,1(3) pop parameters
3999: LDA 3,1(3) pop env
4000: LDA 3,1(3) pop parameters
4001: LDA 0,-2(2) load id adress
4002: PUSH 0,0(6) push array adress to mp
4003: POP 1,0(6) move the adress of ID
4004: POP 0,0(6) copy bytes
4005: ST 0,0(1) copy bytes
4006: LDA 3,-1(3) stack expand
4007: LD 0,2(2) load id value
4008: PUSH 0,0(6) store exp
4009: POP 1,0,6 load adress of lhs struct
4010: LDC 0,0,0 load offset of member
4011: ADD 0,0,1 compute the real adress if pointK
4012: PUSH 0,0(6)
4013: POP 0,0(6) load adress from mp
4014: LD 1,0(0) copy bytes
4015: PUSH 1,0(6) push a.x value into tmp
4016: LD 0,-2(2) load id value
4017: PUSH 0,0(6) store exp
4018: POP 0,0(6) load index value to ac
4019: LDC 1,3,0 load pointkind size
4020: MUL 0,1,0 compute the offset
4021: POP 1,0(6) load lhs adress to ac1
4022: ADD 0,1,0 compute the real index adress
4023: PUSH 0,0(6) op: load left
4024: LDA 0,-3(2) load id adress
4025: PUSH 0,0(6) push array adress to mp
4026: POP 1,0(6) move the adress of ID
4027: POP 0,0(6) copy bytes
4028: ST 0,0(1) copy bytes
* while stmt:
4029: LABEL 76,0,0 generate label
4030: LD 0,-3(2) load id value
4031: PUSH 0,0(6) store exp
4032: LD 0,-62(5) load id value
4033: PUSH 0,0(6) store exp
4034: POP 1,0(6) pop right
4035: POP 0,0(6) pop left
4036: SUB 0,0,1 op ==, convertd_type
4037: JNE 0,2(7) br if true
4038: LDC 0,0(0) false case
4039: LDA 7,1(7) unconditional jmp
4040: LDC 0,1(0) true case
4041: PUSH 0,0(6)
4042: LD 0,-3(2) load id value
4043: PUSH 0,0(6) store exp
4044: POP 1,0,6 load adress of lhs struct
4045: LDC 0,1,0 load offset of member
4046: ADD 0,0,1 compute the real adress if pointK
4047: PUSH 0,0(6)
4048: POP 0,0(6) load adress from mp
4049: LD 1,0(0) copy bytes
4050: PUSH 1,0(6) push a.x value into tmp
4051: LD 0,-62(5) load id value
4052: PUSH 0,0(6) store exp
4053: POP 1,0(6) pop right
4054: POP 0,0(6) pop left
4055: SUB 0,0,1 op ==, convertd_type
4056: JNE 0,2(7) br if true
4057: LDC 0,0(0) false case
4058: LDA 7,1(7) unconditional jmp
4059: LDC 0,1(0) true case
4060: PUSH 0,0(6)
4061: POP 1,0(6) pop right
4062: POP 0,0(6) pop left
4063: JEQ 0,3(7) br if false
4064: JEQ 1,2(7) br if false
4065: LDC 0,1(0) true case
4066: LDA 7,1(7) unconditional jmp
4067: LDC 0,0(0) false case
4068: PUSH 0,0(6)
* push function parameters
4069: LD 0,-3(2) load id value
4070: PUSH 0,0(6) store exp
4071: POP 1,0,6 load adress of lhs struct
4072: LDC 0,1,0 load offset of member
4073: ADD 0,0,1 compute the real adress if pointK
4074: PUSH 0,0(6)
4075: POP 0,0(6) load adress from mp
4076: LD 1,0(0) copy bytes
4077: PUSH 1,0(6) push a.x value into tmp
4078: POP 0,0(6) copy bytes
4079: PUSH 0,0(3) PUSH bytes
* push function parameters
4080: LD 0,3(2) load id value
4081: PUSH 0,0(6) store exp
4082: POP 0,0(6) copy bytes
4083: PUSH 0,0(3) PUSH bytes
4084: LD 0,1(2) load env
4085: PUSH 0,0(3) store env
* call function:
* equal
4086: LD 0,2(2) load id value
4087: PUSH 0,0(6) store exp
4088: POP 1,0,6 load adress of lhs struct
4089: LDC 0,6,0 load offset of member
4090: ADD 0,0,1 compute the real adress if pointK
4091: PUSH 0,0(6)
4092: POP 0,0(6) load adress from mp
4093: LD 1,0(0) copy bytes
4094: PUSH 1,0(6) push a.x value into tmp
4095: LDC 0,4097(0) store the return adress
4096: POP 7,0(6) ujp to the function body
4097: LDA 3,2(3) pop parameters
4098: LDA 3,1(3) pop env
4099: LDC 0,1(0) load integer const
4100: PUSH 0,0(6) store exp
4101: POP 1,0(6) pop right
4102: POP 0,0(6) pop left
4103: SUB 0,0,1 op ==, convertd_type
4104: JNE 0,2(7) br if true
4105: LDC 0,0(0) false case
4106: LDA 7,1(7) unconditional jmp
4107: LDC 0,1(0) true case
4108: PUSH 0,0(6)
4109: POP 1,0(6) pop right
4110: POP 0,0(6) pop left
4111: JEQ 0,3(7) br if false
4112: JEQ 1,2(7) br if false
4113: LDC 0,1(0) true case
4114: LDA 7,1(7) unconditional jmp
4115: LDC 0,0(0) false case
4116: PUSH 0,0(6)
4117: POP 0,0(6) pop from the mp
4118: JNE 0,1,7 true case:, skip the break, execute the block code
4119: GO 77,0,0 go to label
4120: LD 0,-3(2) load id value
4121: PUSH 0,0(6) store exp
4122: POP 1,0,6 load adress of lhs struct
4123: LDC 0,0,0 load offset of member
4124: ADD 0,0,1 compute the real adress if pointK
4125: PUSH 0,0(6)
4126: POP 0,0(6) load adress from mp
4127: LD 1,0(0) copy bytes
4128: PUSH 1,0(6) push a.x value into tmp
4129: LDA 0,-3(2) load id adress
4130: PUSH 0,0(6) push array adress to mp
4131: POP 1,0(6) move the adress of ID
4132: POP 0,0(6) copy bytes
4133: ST 0,0(1) copy bytes
4134: GO 76,0,0 go to label
4135: LABEL 77,0,0 generate label
4136: LD 0,-3(2) load id value
4137: PUSH 0,0(6) store exp
4138: LD 0,-62(5) load id value
4139: PUSH 0,0(6) store exp
4140: POP 1,0(6) pop right
4141: POP 0,0(6) pop left
4142: SUB 0,0,1 op ==, convertd_type
4143: JEQ 0,2(7) br if true
4144: LDC 0,0(0) false case
4145: LDA 7,1(7) unconditional jmp
4146: LDC 0,1(0) true case
4147: PUSH 0,0(6)
4148: LD 0,-3(2) load id value
4149: PUSH 0,0(6) store exp
4150: POP 1,0,6 load adress of lhs struct
4151: LDC 0,1,0 load offset of member
4152: ADD 0,0,1 compute the real adress if pointK
4153: PUSH 0,0(6)
4154: POP 0,0(6) load adress from mp
4155: LD 1,0(0) copy bytes
4156: PUSH 1,0(6) push a.x value into tmp
4157: LD 0,-62(5) load id value
4158: PUSH 0,0(6) store exp
4159: POP 1,0(6) pop right
4160: POP 0,0(6) pop left
4161: SUB 0,0,1 op ==, convertd_type
4162: JEQ 0,2(7) br if true
4163: LDC 0,0(0) false case
4164: LDA 7,1(7) unconditional jmp
4165: LDC 0,1(0) true case
4166: PUSH 0,0(6)
4167: POP 1,0(6) pop right
4168: POP 0,0(6) pop left
4169: JNE 0,3(7) br if true
4170: JNE 1,2(7) br if true
4171: LDC 0,0(0) false case
4172: LDA 7,1(7) unconditional jmp
4173: LDC 0,1(0) true case
4174: PUSH 0,0(6)
4175: POP 0,0(6) pop from the mp
4176: JNE 0,1,7 true case:, execute if part
4177: GO 78,0,0 go to label
4178: LD 0,-62(5) load id value
4179: PUSH 0,0(6) store exp
4180: MOV 3,2,0 restore the caller sp
4181: LD 2,0(2) resotre the caller fp
4182: RETURN 0,-1,3 return to the caller
4183: GO 79,0,0 go to label
4184: LABEL 78,0,0 generate label
* if: jump to else
4185: LABEL 79,0,0 generate label
4186: LD 0,-3(2) load id value
4187: PUSH 0,0(6) store exp
4188: POP 1,0,6 load adress of lhs struct
4189: LDC 0,2,0 load offset of member
4190: ADD 0,0,1 compute the real adress if pointK
4191: PUSH 0,0(6)
4192: POP 0,0(6) load adress from mp
4193: LD 1,0(0) copy bytes
4194: PUSH 1,0(6) push a.x value into tmp
4195: MOV 3,2,0 restore the caller sp
4196: LD 2,0(2) resotre the caller fp
4197: RETURN 0,-1,3 return to the caller
4198: MOV 3,2,0 restore the caller sp
4199: LD 2,0(2) resotre the caller fp
4200: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end:
4201: LABEL 75,0,0 generate label
* function entry:
* delete
4202: LDA 3,-1(3) stack expand for function variable
4203: GO 80,0,0 go to label
4204: MOV 1,2,0 store the caller fp temporarily
4205: MOV 2,3,0 exchang the stack(context)
4206: PUSH 1,0(3) push the caller fp
4207: PUSH 0,0(3) push the return adress
4208: LDA 3,-1(3) stack expand
* push function parameters
4209: LD 0,3(2) load id value
4210: PUSH 0,0(6) store exp
4211: POP 0,0(6) copy bytes
4212: PUSH 0,0(3) PUSH bytes
4213: LD 0,2(2) load id value
4214: PUSH 0,0(6) store exp
4215: POP 0,0(6)
4216: PUSH 0,0(3)
4217: LD 0,1(2) load env
4218: PUSH 0,0(3) store env
* call function:
* get_idx
4219: LD 0,2(2) load id value
4220: PUSH 0,0(6) store exp
4221: POP 1,0,6 load adress of lhs struct
4222: LDC 0,4,0 load offset of member
4223: ADD 0,0,1 compute the real adress if pointK
4224: PUSH 0,0(6)
4225: POP 0,0(6) load adress from mp
4226: LD 1,0(0) copy bytes
4227: PUSH 1,0(6) push a.x value into tmp
4228: LDC 0,4230(0) store the return adress
4229: POP 7,0(6) ujp to the function body
4230: LDA 3,1(3) pop parameters
4231: LDA 3,1(3) pop env
4232: LDA 3,1(3) pop parameters
4233: LDA 0,-2(2) load id adress
4234: PUSH 0,0(6) push array adress to mp
4235: POP 1,0(6) move the adress of ID
4236: POP 0,0(6) copy bytes
4237: ST 0,0(1) copy bytes
4238: LDA 3,-1(3) stack expand
4239: LD 0,2(2) load id value
4240: PUSH 0,0(6) store exp
4241: POP 1,0,6 load adress of lhs struct
4242: LDC 0,0,0 load offset of member
4243: ADD 0,0,1 compute the real adress if pointK
4244: PUSH 0,0(6)
4245: POP 0,0(6) load adress from mp
4246: LD 1,0(0) copy bytes
4247: PUSH 1,0(6) push a.x value into tmp
4248: LD 0,-2(2) load id value
4249: PUSH 0,0(6) store exp
4250: POP 0,0(6) load index value to ac
4251: LDC 1,3,0 load pointkind size
4252: MUL 0,1,0 compute the offset
4253: POP 1,0(6) load lhs adress to ac1
4254: ADD 0,1,0 compute the real index adress
4255: PUSH 0,0(6) op: load left
4256: LDA 0,-3(2) load id adress
4257: PUSH 0,0(6) push array adress to mp
4258: POP 1,0(6) move the adress of ID
4259: POP 0,0(6) copy bytes
4260: ST 0,0(1) copy bytes
4261: LDA 3,-1(3) stack expand
4262: LD 0,-62(5) load id value
4263: PUSH 0,0(6) store exp
4264: LDA 0,-4(2) load id adress
4265: PUSH 0,0(6) push array adress to mp
4266: POP 1,0(6) move the adress of ID
4267: POP 0,0(6) copy bytes
4268: ST 0,0(1) copy bytes
* while stmt:
4269: LABEL 81,0,0 generate label
4270: LD 0,-3(2) load id value
4271: PUSH 0,0(6) store exp
4272: LD 0,-62(5) load id value
4273: PUSH 0,0(6) store exp
4274: POP 1,0(6) pop right
4275: POP 0,0(6) pop left
4276: SUB 0,0,1 op ==, convertd_type
4277: JNE 0,2(7) br if true
4278: LDC 0,0(0) false case
4279: LDA 7,1(7) unconditional jmp
4280: LDC 0,1(0) true case
4281: PUSH 0,0(6)
4282: LD 0,-3(2) load id value
4283: PUSH 0,0(6) store exp
4284: POP 1,0,6 load adress of lhs struct
4285: LDC 0,1,0 load offset of member
4286: ADD 0,0,1 compute the real adress if pointK
4287: PUSH 0,0(6)
4288: POP 0,0(6) load adress from mp
4289: LD 1,0(0) copy bytes
4290: PUSH 1,0(6) push a.x value into tmp
4291: LD 0,-62(5) load id value
4292: PUSH 0,0(6) store exp
4293: POP 1,0(6) pop right
4294: POP 0,0(6) pop left
4295: SUB 0,0,1 op ==, convertd_type
4296: JNE 0,2(7) br if true
4297: LDC 0,0(0) false case
4298: LDA 7,1(7) unconditional jmp
4299: LDC 0,1(0) true case
4300: PUSH 0,0(6)
4301: POP 1,0(6) pop right
4302: POP 0,0(6) pop left
4303: JEQ 0,3(7) br if false
4304: JEQ 1,2(7) br if false
4305: LDC 0,1(0) true case
4306: LDA 7,1(7) unconditional jmp
4307: LDC 0,0(0) false case
4308: PUSH 0,0(6)
* push function parameters
4309: LD 0,-3(2) load id value
4310: PUSH 0,0(6) store exp
4311: POP 1,0,6 load adress of lhs struct
4312: LDC 0,1,0 load offset of member
4313: ADD 0,0,1 compute the real adress if pointK
4314: PUSH 0,0(6)
4315: POP 0,0(6) load adress from mp
4316: LD 1,0(0) copy bytes
4317: PUSH 1,0(6) push a.x value into tmp
4318: POP 0,0(6) copy bytes
4319: PUSH 0,0(3) PUSH bytes
* push function parameters
4320: LD 0,3(2) load id value
4321: PUSH 0,0(6) store exp
4322: POP 0,0(6) copy bytes
4323: PUSH 0,0(3) PUSH bytes
4324: LD 0,1(2) load env
4325: PUSH 0,0(3) store env
* call function:
* equal
4326: LD 0,2(2) load id value
4327: PUSH 0,0(6) store exp
4328: POP 1,0,6 load adress of lhs struct
4329: LDC 0,6,0 load offset of member
4330: ADD 0,0,1 compute the real adress if pointK
4331: PUSH 0,0(6)
4332: POP 0,0(6) load adress from mp
4333: LD 1,0(0) copy bytes
4334: PUSH 1,0(6) push a.x value into tmp
4335: LDC 0,4337(0) store the return adress
4336: POP 7,0(6) ujp to the function body
4337: LDA 3,2(3) pop parameters
4338: LDA 3,1(3) pop env
4339: LDC 0,1(0) load integer const
4340: PUSH 0,0(6) store exp
4341: POP 1,0(6) pop right
4342: POP 0,0(6) pop left
4343: SUB 0,0,1 op ==, convertd_type
4344: JNE 0,2(7) br if true
4345: LDC 0,0(0) false case
4346: LDA 7,1(7) unconditional jmp
4347: LDC 0,1(0) true case
4348: PUSH 0,0(6)
4349: POP 1,0(6) pop right
4350: POP 0,0(6) pop left
4351: JEQ 0,3(7) br if false
4352: JEQ 1,2(7) br if false
4353: LDC 0,1(0) true case
4354: LDA 7,1(7) unconditional jmp
4355: LDC 0,0(0) false case
4356: PUSH 0,0(6)
4357: POP 0,0(6) pop from the mp
4358: JNE 0,1,7 true case:, skip the break, execute the block code
4359: GO 82,0,0 go to label
4360: LD 0,-3(2) load id value
4361: PUSH 0,0(6) store exp
4362: LDA 0,-4(2) load id adress
4363: PUSH 0,0(6) push array adress to mp
4364: POP 1,0(6) move the adress of ID
4365: POP 0,0(6) copy bytes
4366: ST 0,0(1) copy bytes
4367: LD 0,-3(2) load id value
4368: PUSH 0,0(6) store exp
4369: POP 1,0,6 load adress of lhs struct
4370: LDC 0,0,0 load offset of member
4371: ADD 0,0,1 compute the real adress if pointK
4372: PUSH 0,0(6)
4373: POP 0,0(6) load adress from mp
4374: LD 1,0(0) copy bytes
4375: PUSH 1,0(6) push a.x value into tmp
4376: LDA 0,-3(2) load id adress
4377: PUSH 0,0(6) push array adress to mp
4378: POP 1,0(6) move the adress of ID
4379: POP 0,0(6) copy bytes
4380: ST 0,0(1) copy bytes
4381: GO 81,0,0 go to label
4382: LABEL 82,0,0 generate label
4383: LD 0,-3(2) load id value
4384: PUSH 0,0(6) store exp
4385: LD 0,-62(5) load id value
4386: PUSH 0,0(6) store exp
4387: POP 1,0(6) pop right
4388: POP 0,0(6) pop left
4389: SUB 0,0,1 op ==, convertd_type
4390: JEQ 0,2(7) br if true
4391: LDC 0,0(0) false case
4392: LDA 7,1(7) unconditional jmp
4393: LDC 0,1(0) true case
4394: PUSH 0,0(6)
4395: LD 0,-3(2) load id value
4396: PUSH 0,0(6) store exp
4397: POP 1,0,6 load adress of lhs struct
4398: LDC 0,1,0 load offset of member
4399: ADD 0,0,1 compute the real adress if pointK
4400: PUSH 0,0(6)
4401: POP 0,0(6) load adress from mp
4402: LD 1,0(0) copy bytes
4403: PUSH 1,0(6) push a.x value into tmp
4404: LD 0,-62(5) load id value
4405: PUSH 0,0(6) store exp
4406: POP 1,0(6) pop right
4407: POP 0,0(6) pop left
4408: SUB 0,0,1 op ==, convertd_type
4409: JEQ 0,2(7) br if true
4410: LDC 0,0(0) false case
4411: LDA 7,1(7) unconditional jmp
4412: LDC 0,1(0) true case
4413: PUSH 0,0(6)
4414: POP 1,0(6) pop right
4415: POP 0,0(6) pop left
4416: JNE 0,3(7) br if true
4417: JNE 1,2(7) br if true
4418: LDC 0,0(0) false case
4419: LDA 7,1(7) unconditional jmp
4420: LDC 0,1(0) true case
4421: PUSH 0,0(6)
4422: POP 0,0(6) pop from the mp
4423: JNE 0,1,7 true case:, execute if part
4424: GO 83,0,0 go to label
4425: MOV 3,2,0 restore the caller sp
4426: LD 2,0(2) resotre the caller fp
4427: RETURN 0,-1,3 return to the caller
4428: GO 84,0,0 go to label
4429: LABEL 83,0,0 generate label
* if: jump to else
* push function parameters
4430: LD 0,-3(2) load id value
4431: PUSH 0,0(6) store exp
4432: POP 0,0(6) copy bytes
4433: PUSH 0,0(3) PUSH bytes
4434: LD 0,1(2) load env
4435: PUSH 0,0(3) store env
* call function:
* slot_free
4436: LD 0,2(2) load id value
4437: PUSH 0,0(6) store exp
4438: POP 1,0,6 load adress of lhs struct
4439: LDC 0,5,0 load offset of member
4440: ADD 0,0,1 compute the real adress if pointK
4441: PUSH 0,0(6)
4442: POP 0,0(6) load adress from mp
4443: LD 1,0(0) copy bytes
4444: PUSH 1,0(6) push a.x value into tmp
4445: LDC 0,4447(0) store the return adress
4446: POP 7,0(6) ujp to the function body
4447: LDA 3,1(3) pop parameters
4448: LDA 3,1(3) pop env
4449: LD 0,-62(5) load id value
4450: PUSH 0,0(6) store exp
4451: LD 0,-3(2) load id value
4452: PUSH 0,0(6) store exp
4453: POP 1,0,6 load adress of lhs struct
4454: LDC 0,1,0 load offset of member
4455: ADD 0,0,1 compute the real adress if pointK
4456: PUSH 0,0(6)
4457: POP 1,0(6) move the adress of referenced
4458: POP 0,0(6) copy bytes
4459: ST 0,0(1) copy bytes
4460: LD 0,-62(5) load id value
4461: PUSH 0,0(6) store exp
4462: LD 0,-3(2) load id value
4463: PUSH 0,0(6) store exp
4464: POP 1,0,6 load adress of lhs struct
4465: LDC 0,2,0 load offset of member
4466: ADD 0,0,1 compute the real adress if pointK
4467: PUSH 0,0(6)
4468: POP 1,0(6) move the adress of referenced
4469: POP 0,0(6) copy bytes
4470: ST 0,0(1) copy bytes
4471: LD 0,-4(2) load id value
4472: PUSH 0,0(6) store exp
4473: LD 0,-62(5) load id value
4474: PUSH 0,0(6) store exp
4475: POP 1,0(6) pop right
4476: POP 0,0(6) pop left
4477: SUB 0,0,1 op ==, convertd_type
4478: JNE 0,2(7) br if true
4479: LDC 0,0(0) false case
4480: LDA 7,1(7) unconditional jmp
4481: LDC 0,1(0) true case
4482: PUSH 0,0(6)
4483: POP 0,0(6) pop from the mp
4484: JNE 0,1,7 true case:, execute if part
4485: GO 85,0,0 go to label
4486: LD 0,-3(2) load id value
4487: PUSH 0,0(6) store exp
4488: POP 1,0,6 load adress of lhs struct
4489: LDC 0,0,0 load offset of member
4490: ADD 0,0,1 compute the real adress if pointK
4491: PUSH 0,0(6)
4492: POP 0,0(6) load adress from mp
4493: LD 1,0(0) copy bytes
4494: PUSH 1,0(6) push a.x value into tmp
4495: LD 0,-4(2) load id value
4496: PUSH 0,0(6) store exp
4497: POP 1,0,6 load adress of lhs struct
4498: LDC 0,0,0 load offset of member
4499: ADD 0,0,1 compute the real adress if pointK
4500: PUSH 0,0(6)
4501: POP 1,0(6) move the adress of referenced
4502: POP 0,0(6) copy bytes
4503: ST 0,0(1) copy bytes
4504: GO 86,0,0 go to label
4505: LABEL 85,0,0 generate label
* if: jump to else
4506: LABEL 86,0,0 generate label
4507: LABEL 84,0,0 generate label
4508: MOV 3,2,0 restore the caller sp
4509: LD 2,0(2) resotre the caller fp
4510: RETURN 0,-1,3 return to adress : reg[fp]+1
* function end: