summaryrefslogtreecommitdiff
path: root/ecomp-c/tests/procedure_local_variables.easm
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-c/tests/procedure_local_variables.easm')
-rw-r--r--ecomp-c/tests/procedure_local_variables.easm55
1 files changed, 55 insertions, 0 deletions
diff --git a/ecomp-c/tests/procedure_local_variables.easm b/ecomp-c/tests/procedure_local_variables.easm
new file mode 100644
index 0000000..88312af
--- /dev/null
+++ b/ecomp-c/tests/procedure_local_variables.easm
@@ -0,0 +1,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