summaryrefslogtreecommitdiff
path: root/ecomp-c/tests/procedure_local_variables.easm
blob: 88312af1e12b3af41e5d9fa16c7d06b8bdd02d68 (plain)
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
format binary
use32
org $1000000
jmp __global_0
; DECL i -> integer, 1
; PROC proc
__global_proc:
push ebp
push esp
pop ebp
; CONST C -> integer, 42
; DECL j -> integer, 0
; DECL k -> integer, 42
; local k, offset: 4, size: 4
; local j, offset: 8, size: 4
mov eax, 8
sub esp, eax
push ebp
pop ebx
mov eax, 4
sub ebx, eax
mov eax, 42
mov [ebx], eax
push ebp
pop ebx
mov eax, 8
sub ebx, eax
mov eax, 0
mov [ebx], eax
; LET j <- i 
mov eax, [i]
push eax
push ebp
pop ebx
mov eax, 8
sub ebx, eax
pop eax
mov [ebx], eax
; LET i <- k 
push ebp
pop ebx
mov eax, 4
sub ebx, eax
mov eax, [ebx]
push eax
pop eax
mov [i], eax
mov eax, 8
add esp, eax
pop ebp
ret
__global_0:
call __global_proc
hlt
i: dd $00000001