summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-06-28 08:54:27 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2020-06-28 08:54:27 +0200
commit6832eb323e51af3a05e9f4ee62e7c9cc358cb863 (patch)
treea4b3253f104405a39ff6027de80bf496bae4f4a7
parent94c2ac9790daff1f10252b474c1fc2fc17bd3cac (diff)
downloadcompilertests-6832eb323e51af3a05e9f4ee62e7c9cc358cb863.tar.gz
compilertests-6832eb323e51af3a05e9f4ee62e7c9cc358cb863.tar.bz2
added a test for forward declarations of procedures
-rwxr-xr-xecomp-c/test.sh1
-rw-r--r--ecomp-c/tests/procedure_forward_declaration.e24
-rw-r--r--ecomp-c/tests/procedure_forward_declaration.easm21
-rw-r--r--ecomp-c/tests/procedure_forward_declaration.easm_err0
-rw-r--r--ecomp-c/tests/procedure_forward_declaration.ecomp_err0
-rw-r--r--ecomp-c/tests/procedure_forward_declaration.erun171
6 files changed, 217 insertions, 0 deletions
diff --git a/ecomp-c/test.sh b/ecomp-c/test.sh
index cc2632f..a284678 100755
--- a/ecomp-c/test.sh
+++ b/ecomp-c/test.sh
@@ -23,6 +23,7 @@ type_check_assignment
type_check_comparision
while_statement
procedure_call
+procedure_forward_declaration
example_divisors
example_divisors_array_result
example_reverse_array
diff --git a/ecomp-c/tests/procedure_forward_declaration.e b/ecomp-c/tests/procedure_forward_declaration.e
new file mode 100644
index 0000000..7129184
--- /dev/null
+++ b/ecomp-c/tests/procedure_forward_declaration.e
@@ -0,0 +1,24 @@
+/*
+ * forware declaration of procedure
+ */
+
+module procedure_forward_declaration;
+
+var
+ i : integer := 0;
+
+procedure proc2;
+
+procedure proc1;
+begin
+ proc2;
+end
+
+procedure proc2;
+begin
+ i := 1;
+end
+
+begin
+ proc1;
+end
diff --git a/ecomp-c/tests/procedure_forward_declaration.easm b/ecomp-c/tests/procedure_forward_declaration.easm
new file mode 100644
index 0000000..2b587e2
--- /dev/null
+++ b/ecomp-c/tests/procedure_forward_declaration.easm
@@ -0,0 +1,21 @@
+format binary
+use32
+org $1000000
+jmp __global_0
+; DECL i -> integer, 0
+; PROC proc1
+__global_proc1:
+call __global_proc2
+ret
+; PROC proc2
+__global_proc2:
+; LET i <- 1
+mov eax, 1
+push eax
+pop eax
+mov [i], eax
+ret
+__global_0:
+call __global_proc1
+hlt
+i: dd $00000000
diff --git a/ecomp-c/tests/procedure_forward_declaration.easm_err b/ecomp-c/tests/procedure_forward_declaration.easm_err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ecomp-c/tests/procedure_forward_declaration.easm_err
diff --git a/ecomp-c/tests/procedure_forward_declaration.ecomp_err b/ecomp-c/tests/procedure_forward_declaration.ecomp_err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ecomp-c/tests/procedure_forward_declaration.ecomp_err
diff --git a/ecomp-c/tests/procedure_forward_declaration.erun b/ecomp-c/tests/procedure_forward_declaration.erun
new file mode 100644
index 0000000..a3a6f58
--- /dev/null
+++ b/ecomp-c/tests/procedure_forward_declaration.erun
@@ -0,0 +1,171 @@
+Read 31 bytes of code and static data..
+1000000: EB13 jmp 0x1000015
+1000002: E801000000 call 0x1000008
+1000007: C3 ret
+1000008: B801000000 mov eax, 1
+100000D: 50 push eax
+100000E: 58 pop eax
+100000F: A31B000001 mov dword ptr [0x100001b], eax
+1000014: C3 ret
+1000015: E8E8FFFFFF call 0x1000002
+100001A: F4 hlt
+data:
+0100001B: 00000000
+core start 1000000
+data start 100001b
+data size 4
+stack start 1800000
+Single step execution:
+-- iteration 1
+1000000: EB13 jmp 0x1000015
+EIP: 01000015
+ESP: 01800000
+EBP: 00000000
+EAX: 00000000
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+data:
+0100001B: 00000000
+-- iteration 2
+1000015: E8E8FFFFFF call 0x1000002
+EIP: 01000002
+ESP: 017FFFFC
+EBP: 00000000
+EAX: 00000000
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+017FFFFC: 0100001A
+data:
+0100001B: 00000000
+-- iteration 3
+1000002: E801000000 call 0x1000008
+EIP: 01000008
+ESP: 017FFFF8
+EBP: 00000000
+EAX: 00000000
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+017FFFF8: 01000007
+017FFFFC: 0100001A
+data:
+0100001B: 00000000
+-- iteration 4
+1000008: B801000000 mov eax, 1
+EIP: 0100000D
+ESP: 017FFFF8
+EBP: 00000000
+EAX: 00000001
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+017FFFF8: 01000007
+017FFFFC: 0100001A
+data:
+0100001B: 00000000
+-- iteration 5
+100000D: 50 push eax
+EIP: 0100000E
+ESP: 017FFFF4
+EBP: 00000000
+EAX: 00000001
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+017FFFF4: 00000001
+017FFFF8: 01000007
+017FFFFC: 0100001A
+data:
+0100001B: 00000000
+-- iteration 6
+100000E: 58 pop eax
+EIP: 0100000F
+ESP: 017FFFF8
+EBP: 00000000
+EAX: 00000001
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+017FFFF8: 01000007
+017FFFFC: 0100001A
+data:
+0100001B: 00000000
+-- iteration 7
+100000F: A31B000001 mov dword ptr [0x100001b], eax
+EIP: 01000014
+ESP: 017FFFF8
+EBP: 00000000
+EAX: 00000001
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+017FFFF8: 01000007
+017FFFFC: 0100001A
+data:
+0100001B: 01000000
+-- iteration 8
+1000014: C3 ret
+EIP: 01000007
+ESP: 017FFFFC
+EBP: 00000000
+EAX: 00000001
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+017FFFFC: 0100001A
+data:
+0100001B: 01000000
+-- iteration 9
+1000007: C3 ret
+EIP: 0100001A
+ESP: 01800000
+EBP: 00000000
+EAX: 00000001
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+data:
+0100001B: 01000000
+-- iteration 10
+100001A: F4 hlt
+EIP: 0100001B
+ESP: 01800000
+EBP: 00000000
+EAX: 00000001
+EBX: 00000000
+ECX: 00000000
+EDX: 00000000
+ESI: 00000000
+EDI: 00000000
+stack:
+data:
+0100001B: 01000000