-
Notifications
You must be signed in to change notification settings - Fork 19
/
hex5c.he
1622 lines (1444 loc) · 25.3 KB
/
hex5c.he
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
#
# HEX5 for Linux-i386-ELF
#
# Copyright (C) 2001, Edmund GRIMLEY EVANS <[email protected]>
#
###
### ELF headers
###
# Elf32_Ehdr
'7f '45 '4c '46 '01 '01 '01 # e_ident
'00 '00 '00 '00 '00 '00 '00 '00 '00
'02 '00 # e_type
'03 '00 # e_machine
'01 '00 '00 '00 # e_version
'54 '80 '04 '08 # e_entry = 0x08048000 + _start
'34 '00 '00 '00 # e_phoff = len(ehdr)
'00 '00 '00 '00 # e_shoff
'00 '00 '00 '00 # e_flags
'34 '00 # e_ehsize = len(ehdr)
'20 '00 # e_phentsize = len(phdr)
'01 '00 # e_phnum
'00 '00 # e_shentsize
'00 '00 # e_shnum
'00 '00 # e_shstrndx
# Elf32_Phdr
'01 '00 '00 '00 # p_type
'00 '00 '00 '00 # p_offset
'00 '80 '04 '08 # p_vaddr = 0x08048000
'00 '80 '04 '08 # p_paddr = 0x08048000
'00 '40 '00 '00 #FIXME # p_filesz = len(ehdr) + len(phdr) + len(prog)
'00 '40 '00 '00 #FIXME # p_memsz = len(ehdr) + len(phdr) + len(prog)
'07 '00 '00 '00 # p_flags
'00 '10 '00 '00 # p_align
######################################################################
# Enter here:
def _start
{
0 main exit
}
######################################################################
###
### Support for functions: arguments, variables, return values
###
_def xreturn0
'5b # pop %ebx
'5b # pop %ebx
'c9 # leave
'58 # pop %eax
'8d '24 '9c # lea (%esp,%ebx,4),%esp
'50 # push %eax
'c3 # ret
_def xreturn1
'5b # pop %ebx
'5b # pop %ebx
'59 # pop %ecx
'c9 # leave
'58 # pop %eax
'8d '24 '9c # lea (%esp,%ebx,4),%esp
'51 # push %ecx
'50 # push %eax
'c3 # ret
###
### Stack manipulation
###
_def drop
'5b # pop %ebx
'58 # pop %eax
'ff 'e3 # jmp *%ebx
_def swap
'5b # pop %ebx
'58 # pop %eax
'59 # pop %ecx
'50 # push %eax
'51 # push %ecx
'ff 'e3 # jmp *%ebx
_def dup
'5b # pop %ebx
'58 # pop %eax
'50 # push %eax
'50 # push %eax
'ff 'e3 # jmp *%ebx
_def twodup
'5b # pop %ebx
'58 # pop %eax
'59 # pop %ecx
'51 # push %ecx
'50 # push %eax
'51 # push %ecx
'50 # push %eax
'ff 'e3 # jmp *%ebx
_def rot
'58 # pop %eax
'5b # pop %ebx
'59 # pop %ecx
'5a # pop %edx
'51 # push %ecx
'53 # push %ebx
'52 # push %edx
'50 # push %eax
'c3
_def pick
'8b '44 '24 '04 # mov 4(%esp),%eax
'01 'c0 # add %eax,%eax
'01 'c0 # add %eax,%eax
'8d '5c '24 '08 # lea 8(%esp),%ebx
'01 'd8 # add %ebx,%eax
'8b '00 # mov (%eax),%eax
'89 '44 '24 '04 # mov %eax,4(%esp)
'c3 # ret
###
### Arithmetic
###
_def -
'5b # pop %ebx
'58 # pop %eax
'29 '04 '24 # sub %eax,(%esp)
'ff 'e3 # jmp *%ebx
_def +
'5b # pop %ebx
'58 # pop %eax
'01 '04 '24 # add %eax,(%esp)
'ff 'e3 # jmp *%ebx
_def bitand
'5b # pop %ebx
'58 # pop %eax
'21 '04 '24 # and %eax,(%esp)
'ff 'e3 # jmp *%ebx
_def *
'5b # pop %ebx
'58 # pop %eax
'0f 'af '04 '24 # imul (%esp),%eax
'89 '04 '24 # mov %eax,(%esp)
'ff 'e3 # jmp *%ebx
_def <<
'5b # pop %ebx
'59 # pop %ecx
'58 # pop %eax
'd3 'e0 # shl %cl,%eax
'50 # push %eax
'ff 'e3 # jmp *%ebx
_def >>
'5b # pop %ebx
'59 # pop %ecx
'58 # pop %eax
'd3 'f8 # sar %cl,%eax
'50 # push %eax
'ff 'e3 # jmp *%ebx
# Comparisons
_def <
'5b # pop %ebx
'58 # pop %eax
'59 # pop %ecx
'39 'c1 # cmp %eax,%ecx
'0f '9c 'c0 # setl %al
'25 'ff '00 '00 '00 # and $0xff,%eax
'50 # push %eax
'ff 'e3 # jmp *%ebx
_def <=
'5b # pop %ebx
'58 # pop %eax
'59 # pop %ecx
'39 'c1 # cmp %eax,%ecx
'0f '9e 'c0 # setle %al
'25 'ff '00 '00 '00 # and $0xff,%eax
'50 # push %eax
'ff 'e3 # jmp *%ebx
_def ==
'5b # pop %ebx
'58 # pop %eax
'59 # pop %ecx
'39 'c1 # cmp %eax,%ecx
'0f '94 'c0 # sete %al
'25 'ff '00 '00 '00 # and $0xff,%eax
'50 # push %eax
'ff 'e3 # jmp *%ebx
_def !=
'5b # pop %ebx
'58 # pop %eax
'59 # pop %ecx
'39 'c1 # cmp %eax,%ecx
'0f '95 'c0 # setne %al
'25 'ff '00 '00 '00 # and $0xff,%eax
'50 # push %eax
'ff 'e3 # jmp *%ebx
###
### Memory access
###
_def @
'5b # pop %ebx
'58 # pop %eax
'8b '00 # mov (%eax),%eax
'50 # push %eax
'53 # push %ebx
'c3 # ret
_def =
'5b # pop %ebx
'58 # pop %eax
'59 # pop %ecx
'89 '08 # mov %ecx,(%eax)
'53 # push %ebx
'c3 # ret
_def c[]
'5b # pop %ebx
'5a # pop %edx
'58 # pop %eax
'0f 'be '04 '10 # movsbl (%eax,%edx,1),%eax
'50 # push %eax
'53 # push %ebx
'c3 # ret
_def c[]=
'5b # pop %ebx
'5a # pop %edx
'58 # pop %eax
'59 # pop %ecx
'88 '0c '10 # mov %cl,(%eax,%edx,1)
'53 # push %ebx
'c3 # ret
_def c[]&
'5b # pop %ebx
'5a # pop %edx
'58 # pop %eax
'8d '04 '10 # lea (%eax,%edx,1),%eax
'50 # push %eax
'53 # push %ebx
'c3 # ret
###
### Flow of control
###
_def jump
'58 # pop %eax
'5b # pop %ebx
'01 'c3 # add %eax,%ebx
'83 'eb '05 # sub $5,%ebx
'53 # push %ebx
'c3 # ret
_def branch
'58 # pop %eax
'5b # pop %ebx
'59 # pop %ecx
'85 'c9 # test %ecx,%ecx
'75 '02 # jne +2
'50 # push %eax
'c3 # ret
'01 'c3 # add %eax,%ebx
'83 'eb '05 # sub $5,%ebx
'53 # push %ebx
'c3 # ret
_def call
'58 # pop %eax
'5b # pop %ebx
'50 # push %eax
'53 # push %ebx
'c3 # ret
######################################################################
###
### System calls
###
_def exit
'5b # pop %ebx
'5b # pop %ebx
'31 'c0 # xor %eax,%eax
'40 # inc %eax
'cd '80 # int $0x80
_def _brk
'58 # pop %eax
'5b # pop %ebx
'50 # push %eax
'b8 '2d '00 '00 '00 # mov $0x45,%eax
'cd '80 # int $0x80
'5b # pop %ebx
'50 # push %eax
'53 # push %ebx
'c3 # ret
_def getchar
'6a '00 # push $0x0
'31 'db # xor %ebx,%ebx
'89 'e1 # mov %esp,%ecx
'31 'd2 # xor %edx,%edx
'42 # inc %edx
'b8 '03 '00 '00 '00 # mov $0x3,%eax
'cd '80 # int $0x80
'5b # pop %ebx
'85 'c0 # test %eax,%eax
'75 '01 # jne +1
'4b # dec %ebx
'58 # pop %eax
'53 # push %ebx
'50 # push %eax
'c3 # ret
_def putchar
'31 'db # xor %ebx,%ebx
'43 # inc %ebx
'8d '4c '24 '04 # lea 0x4(%esp,1),%ecx
'89 'da # mov %ebx,%edx
'b8 '04 '00 '00 '00 # mov $0x4,%eax
'cd '80 # int $0x80
'5b # pop %ebx
'58 # pop %eax
'53 # push %ebx
'c3 # ret
def increment sbrk
{
var pos
0 _brk pos=
pos increment + dup _brk == if
pos 1 xreturn1
fi
0 1 - 1 xreturn1
}
######################################################################
###
### Debugging
###
# A stackless implementation of exit(42), for debugging:
# '31 'c0 '40 'b3 '2a 'cd '80
def w outw
{
w
dup putchar 8 >>
dup putchar 8 >>
dup putchar 8 >>
putchar
1 xreturn0
}
def outs
{
3735928559 # 0xdeadbeef
outw outw outw outw
outw outw outw outw
outw outw outw outw
0 exit
}
######################################################################
###
### A bogus implementation of malloc, realloc, free
###
def wsize
{
4 0 xreturn1
}
def size malloc
{
size wsize + sbrk
dup size swap =
wsize + 1 xreturn1
}
def ptr size realloc
{
var old_size
var new_ptr
ptr 0 == if
# just call malloc
size malloc 2 xreturn1
fi
ptr wsize - @ old_size=
size old_size <= if
# keep the same bit of memory
ptr 2 xreturn1
fi
size malloc new_ptr=
# copy old data to new memory
{
old_size 0 == if break fi
old_size 1 - old_size=
ptr old_size c[] new_ptr old_size c[]=
continue
}
new_ptr 2 xreturn1
}
def free
{
# do nothing
1 xreturn0
}
######################################################################
###
### The program itself
###
def x not
{
x if
0 1 xreturn1
else
1 1 xreturn1
fi
}
def a b cmp
{
a b < if
0 1 - 2 xreturn1
fi
a b == if
0 2 xreturn1
fi
1 2 xreturn1
}
def p q strcmp
{
var i
var r
0 i=
{
p i c[] q i c[] cmp r=
r if break fi
p i c[] not if break fi
i 1 + i=
continue
}
r 2 xreturn1
}
def s strlen
{
var n
0 n=
{
s n c[] not if break fi
n 1 + n=
continue
}
n 1 xreturn1
}
def s strdup
{
var n
var s1
0 n=
s strlen 1 + malloc s1=
{
s n c[] not if break fi
s n c[] s1 n c[]=
n 1 + n=
continue
}
s1 1 xreturn1
}
def s prints
{
s
0
{
twodup c[] dup not if 1 xreturn0 fi
putchar
1 +
continue
}
}
###
### Binary image
###
_def _var_address
'58 # pop %eax
'83 'c0 '02 # add $0x2,%eax
'c9 # leave
'5b # pop %ebx
'50 # push %eax
'53 # push %ebx
'c3 # ret
var binary
var binary_size
var pc
def out_of_memory
{
123 exit
}
def addr data emit
{
addr binary_size < not if
addr 1 + 1 << binary_size=
binary binary_size realloc binary=
binary not if
out_of_memory
fi
fi
data binary addr c[]=
2 xreturn0
}
def dump
{
var i
0 i=
{
i pc == if break fi
binary i c[] putchar
i 1 + i=
continue
}
0 xreturn0
}
def pos n store_int
{
n binary pos c[]& =
2 xreturn0
}
def pos fetch_int
{
binary pos c[]& @
1 xreturn1
}
###
### Lexical analysis
###
def token_eof
{ _var_address }
'00
def token_def
{ _var_address }
'64 '65 '66 '00
def token__def
{ _var_address }
'5f '64 '65 '66 '00
def token_ob
{ _var_address }
'7b '00
def token_cb
{ _var_address }
'7d '00
def token_var
{ _var_address }
'76 '61 '72 '00
def token_if
{ _var_address }
'69 '66 '00
def token_else
{ _var_address }
'65 '6c '73 '65 '00
def token_fi
{ _var_address }
'66 '69 '00
def token_break
{ _var_address }
'62 '72 '65 '61 '6b '00
def token_continue
{ _var_address }
'63 '6f '6e '74 '69 '6e '75 '65 '00
def token_until
{ _var_address }
'75 '6e '74 '69 '6c '00
def token_while
{ _var_address }
'77 '68 '69 '6c '65 '00
def token_string
{ _var_address }
'73 '74 '72 '69 '6e '67 '00
def token_return0
{ _var_address }
'72 '65 '74 '75 '72 '6e '30 '00
def token_return1
{ _var_address }
'72 '65 '74 '75 '72 '6e '31 '00
def s is_symbol
{
s token_eof strcmp not if 0 1 xreturn1 fi
s token_def strcmp not if 0 1 xreturn1 fi
s token_ob strcmp not if 0 1 xreturn1 fi
s token_cb strcmp not if 0 1 xreturn1 fi
s token_var strcmp not if 0 1 xreturn1 fi
s token_if strcmp not if 0 1 xreturn1 fi
s token_else strcmp not if 0 1 xreturn1 fi
s token_fi strcmp not if 0 1 xreturn1 fi
s token_break strcmp not if 0 1 xreturn1 fi
s token_continue strcmp not if 0 1 xreturn1 fi
s token_until strcmp not if 0 1 xreturn1 fi
s token_while strcmp not if 0 1 xreturn1 fi
s token_return0 strcmp not if 0 1 xreturn1 fi
s token_return1 strcmp not if 0 1 xreturn1 fi
1 1 xreturn1
}
def next_token
{ _var_address }
# A silly fixed-length buffer
'00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00
'00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00
'00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00
'00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00 '00
# comment = /#[^\n]*\n?/
# space = /\s/
# string_literal = /"([^"]|\\.)*"/
# token = /\S+/
def get_next_token
{
var c
var p
getchar c=
c 0 1 - == if
0 next_token 0 c[]=
0 xreturn0
fi
c 32 <= if
continue
fi
c 35 == if
{
getchar c=
c 10 == if break fi
c 0 1 - == if
0 next_token 0 c[]=
0 xreturn0
fi
continue
}
continue
fi
c 34 == if
next_token p=
{
c p 0 c[]=
p 1 + p=
getchar c=
c 34 == if
c p 0 c[]=
p 1 + p=
break
fi
c 92 == if
getchar c=
fi
c 0 1 - == if
96 exit # unterminated string
fi
continue
}
else
next_token p=
{
c p 0 c[]=
p 1 + p=
getchar c=
c 32 <= not if continue fi
}
fi
0 p 0 c[]=
0 xreturn0
}
def eof
{
next_token 0 c[] 0 == 0 xreturn1
}
def s token
{
next_token s strcmp if 0 1 xreturn1 fi
get_next_token
1 1 xreturn1
}
def syntax_error
{
19 exit
}
def x require
{
x not if syntax_error fi
1 xreturn0
}
###
### Symbol tables
###
var globals
var locals
var local_args_num
def symbol.sizeof
{
wsize 4 * 0 xreturn1
}
def sym symbol.name&
{
sym 1 xreturn1
}
def sym symbol.type&
{
sym wsize + 1 xreturn1
}
def sym symbol.value&
{
sym wsize 2 * + 1 xreturn1
}
def sym symbol.next&
{
sym wsize 3 * + 1 xreturn1
}
def sym symbol.type
{
sym symbol.type& @ 1 xreturn1
}
def type sym symbol.type=
{
type sym symbol.type& = 2 xreturn0
}
def sym symbol.value
{
sym symbol.value& @ 1 xreturn1
}
def value sym symbol.value=
{
value sym symbol.value& = 2 xreturn0
}
def table s symbol_found
{
var t
table t=
{
t @ not if
0 2 xreturn1
fi
t @ symbol.name& @ s strcmp not if
t @ 2 xreturn1
fi
t @ symbol.next& t=
continue
}
}
def table s symbol_find
{
var t
table t=
{
t @ not if
symbol.sizeof malloc
dup t =
dup symbol.name& s strdup swap =
dup symbol.type& 0 swap =
dup symbol.value& 0 swap =
dup symbol.next& 0 swap =
2 xreturn1
fi
t @ symbol.name& @ s strcmp not if
t @ 2 xreturn1
fi
t @ symbol.next& t=
continue
}
}
def table symbol_table_clear
{
# FIXME: leaks
0 table =
}
###
### Code generation
###
def a n generate_int
{
# little-endian
a n 255 bitand emit
a 1 + n 8 >> 255 bitand emit
a 2 + n 16 >> 255 bitand emit
a 3 + n 24 >> 255 bitand emit
2 xreturn0
}
def a n generate_call
{
a 232 emit # 0xe8 = call N
a 1 + n a - 5 - generate_int
a 5 + 2 xreturn1
}
def a n generate_jump
{
a 233 emit # 0xe9 = jmp N
a 1 + n a - 5 - generate_int
a 5 + 2 xreturn1
}
def a n generate_branch_false
{
a 88 emit # 0x58 = pop %eax
a 1 + 133 emit
a 2 + 192 emit # 0x85 0xc0 = test %eax,%eax
a 3 + 15 emit
a 4 + 132 emit # 0x0f 0x84 = je N
a 5 + n a - 9 - generate_int
a 9 + 2 xreturn1
}
def a n generate_branch_true # unused
{
a 88 emit # 0x58 = pop %eax
a 1 + 133 emit
a 2 + 192 emit # 0x85 0xc0 = test %eax,%eax
a 3 + 15 emit
a 4 + 133 emit # 0x0f 0x85 = jne N
a 5 + n a - 9 - generate_int
a 9 + 2 xreturn1
}
def a n generate_constant
{
a 104 emit # 0x68 = push N
a 1 + n generate_int
a 5 + 2 xreturn1
}
def a generate_proc_start
{
a 85 emit # 0x55 = push %ebp
a 1 + 137 emit
a 2 + 229 emit # 0x89 0xe5 = mov %esp,%ebp
a 3 + 1 xreturn1
}
def a generate_proc_end
{
a 201 emit # 0xc9 = leave
a 1 + 195 emit # 0xc3 = ret
a 2 + 1 xreturn1
}
def a n generate_arg_load
{
a 139 emit
a 1 + 133 emit # 0x8b 0x85 = mov N(%ebp),%eax
a 2 + 2 local_args_num + n - 4 * generate_int
a 6 + 80 emit # 0x50 = push %eax
a 7 + 2 xreturn1
}
def a n generate_stack_frame
{
n not if
a 2 xreturn1
fi
a 129 emit
a 1 + 236 emit # 0x81 0xec = sub $N,%esp
a 2 + n 4 * generate_int
a 6 + 2 xreturn1
}
def a n generate_var_load
{
a 139 emit
a 1 + 133 emit # 0x8b 0x85 = mov N(%ebp),%eax
a 2 + 0 n - 4 * generate_int
a 6 + 80 emit # 0x50 = push %eax
a 7 + 2 xreturn1
}
def a n generate_var_store
{
a 88 emit # 0x58 = pop %eax
a 1 + 137 emit
a 2 + 133 emit # 0x89 0x85 = mov %eax,N(%ebp)
a 3 + 0 n - 4 * generate_int
a 7 + 2 xreturn1
}
def a n generate_var_addr
{
a 141 emit
a 1 + 133 emit # 0x8d 0x85 = lea N(%ebp),%eax
a 2 + 0 n - 4 * generate_int
a 6 + 80 emit # 0x50 = push %eax
a 7 + 2 xreturn1
}
def a generate_global
{
a 0 generate_int
a 4 + 1 xreturn1
}
def a n generate_global_load
{
a 232 emit # 0xe8 = call N
a 1 + 0 generate_int
a 5 + 88 emit # 0x58 = pop %eax
a 6 + 139 emit
a 7 + 128 emit # 0x8b 0x80 = mov N(%eax),%eax
a 8 + n a - 5 - generate_int
a 12 + 80 emit # 0x50 = push %eax
a 13 + 2 xreturn1
}
def a n generate_global_store
{
a 232 emit # 0xe8 = call N
a 1 + 0 generate_int
a 5 + 88 emit # 0x58 = pop %eax
a 6 + 91 emit # 0x5b = pop %ebx
a 7 + 137 emit
a 8 + 152 emit # 0x89 0x98 = mov %ebx,N(%eax)
a 9 + n a - 5 - generate_int
a 13 + 2 xreturn1
}
def a n generate_global_addr
{
a 232 emit # 0xe8 = call N
a 1 + 0 generate_int
a 5 + 88 emit # 0x58 = pop %eax
a 6 + 141 emit
a 7 + 128 emit # 0x8d 0x80 = lea N(%eax),%eax
a 8 + n a - 5 - generate_int
a 12 + 80 emit # 0x50 = push %eax
a 13 + 2 xreturn1
}
def a generate_skip_jump_if_false