summaryrefslogtreecommitdiff
path: root/ecomp-c/tests/procedure_call_value_parameters.easm
blob: 787f95244f5791a65f3ffb4817a31445c9f7451d (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
56
57
58
59
60
61
62
63
64
65
66
67
format binary
use32
org $1000000
jmp __global_0
; DECL i -> integer, 1
; param y, offset: -8, size: 4
; param x, offset: -12, size: 4
; PROC proc
__global_proc:
push ebp
push esp
pop ebp
; DECL l -> integer, 0
; local l, offset: 4, size: 4
mov eax, 4
sub esp, eax
push ebp
pop ebx
mov eax, 4
sub ebx, eax
mov eax, 0
mov [ebx], eax
; LET l <- x y - 
push ebp
pop ebx
mov eax, -12
sub ebx, eax
mov eax, [ebx]
push eax
push ebp
pop ebx
mov eax, -8
sub ebx, eax
mov eax, [ebx]
push eax
pop ebx
pop eax
sub eax, ebx
push eax
push ebp
pop ebx
mov eax, 4
sub ebx, eax
pop eax
mov [ebx], eax
; LET i <- l 
push ebp
pop ebx
mov eax, 4
sub ebx, eax
mov eax, [ebx]
push eax
pop eax
mov [i], eax
mov eax, 4
add esp, eax
pop ebp
ret 8
__global_0:
; CALL __global_proc( 43 1 )
mov eax, 43
push eax
mov eax, 1
push eax
call __global_proc
hlt
i: dd $00000001