-
Notifications
You must be signed in to change notification settings - Fork 0
/
opcodes.s
92 lines (75 loc) · 1.15 KB
/
opcodes.s
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
; this file is to manually kept in sync
; with x86-32_backend.c
; defined word
call 42 ; e8 xx xx xx xx
; runtime word
; add ebx, 4
; mov [ebx], eax
mov ecx, [edi+(42+1)*4]
call [esi+36]
; mov eax, [ebx]
; sub ebx, 4
; push literal
; add ebx, 4
; mov [ebx], eax
mov eax, 42
; exit word
leave
ret
; defined word location
push ebp
mov ebp, esp
; push data address
; add ebx, 4
; mov [ebx], eax
mov eax, [esi+16]
add eax, 42
; declare variable
add edx, 3 ; align data-space pointer
and edx, ~3
mov [edi+(-42)*4], edx
add edx, 4
; use variable or constant
; add ebx, 4
; mov [ebx], eax
mov eax, [edi+(-42)*4]
; halt
ret
; branch location
; (empty)
; branch if zero
sub ebx, 4
test eax, eax
mov eax, [ebx+4]
jz 42 ; '74 42' or '0f 84 42 00 00 00'
; branch
jmp 42 ; 'eb 2a' or 'e9 2a 00 00 00'
; do
push dword [ebx]
push eax
sub ebx, 4
; mov eax, [ebx]
; sub ebx, 4
; loop
pop ecx
inc ecx
cmp ecx, [esp]
push ecx
jl 42
add esp, 8
; push offset address
; add ebx, 4
; mov [ebx], eax
call .L0
.L0:
pop eax
add eax, 42
; push callback
; add ebx, 4
; mov [ebx], eax
mov eax, [esi+40]
mov eax, [eax+42]
; declare constant
mov [edi+(-42)*4], eax
; mov eax, [ebx]
; sub ebx, 4