diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-05-21 19:41:06 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-05-21 19:41:06 +0200 |
commit | c30d5a9904d204c99b727676532bfaaf74bc429e (patch) | |
tree | 29efd5d290ab9286a164c12b271e37761b7243c3 | |
parent | 87549afc50dea3f91a142a1f97d673ffcb960d4b (diff) | |
download | compilertests-c30d5a9904d204c99b727676532bfaaf74bc429e.tar.gz compilertests-c30d5a9904d204c99b727676532bfaaf74bc429e.tar.bz2 |
also initializing data segment for db
adapted all tests
-rw-r--r-- | ecomp-c/ec.c | 5 | ||||
-rw-r--r-- | ecomp-c/tests/boolean_variable.e | 2 | ||||
-rw-r--r-- | ecomp-c/tests/boolean_variable.easm | 4 | ||||
-rw-r--r-- | ecomp-c/tests/boolean_variable.erun | 61 | ||||
-rw-r--r-- | ecomp-c/tests/variable_initialization.e | 1 | ||||
-rw-r--r-- | ecomp-c/tests/variable_initialization.easm | 2 | ||||
-rw-r--r-- | ecomp-c/tests/variable_initialization.erun | 44 |
7 files changed, 48 insertions, 71 deletions
diff --git a/ecomp-c/ec.c b/ecomp-c/ec.c index d98999d..f76dbd6 100644 --- a/ecomp-c/ec.c +++ b/ecomp-c/ec.c @@ -1378,7 +1378,6 @@ static void register_internal_types( Scope *scope ) type_symbol->size = 4; type_symbol = insert_symbol( current_scope, "boolean", SYMBOL_CLASS_TYPE ); - /* TODO: for now, till we have alignment and stuff sorted out */ type_symbol->size = 4; const_symbol = insert_symbol( current_scope, "false", SYMBOL_CLASS_CONSTANT ); @@ -1430,7 +1429,9 @@ static void epilogue( void ) Emit( "\n" ); break; case 1: - Emit( "%s: db $00\n", symbol->name ); + Emit( "%s: db $", symbol->name ); + Emit_Hexbyte( symbol->value ); + Emit( "\n" ); break; default: Abort( "Unhandled size of type '%s' in variable '%s'", diff --git a/ecomp-c/tests/boolean_variable.e b/ecomp-c/tests/boolean_variable.e index 084350b..8903205 100644 --- a/ecomp-c/tests/boolean_variable.e +++ b/ecomp-c/tests/boolean_variable.e @@ -11,5 +11,5 @@ var begin a := 1; b := 2; - flag := a = b; // flag must be false + flag := a <> b; // flag must be false end diff --git a/ecomp-c/tests/boolean_variable.easm b/ecomp-c/tests/boolean_variable.easm index d41269d..7b64339 100644 --- a/ecomp-c/tests/boolean_variable.easm +++ b/ecomp-c/tests/boolean_variable.easm @@ -14,7 +14,7 @@ mov eax, 2 push eax pop eax mov [b], eax -; LET flag <- a b = +; LET flag <- a b <> mov eax, [a] push eax mov eax, [b] @@ -22,7 +22,7 @@ push eax pop ebx pop eax cmp eax, ebx -je __global_0 +jne __global_0 mov eax, 0 jmp __global_1 __global_0: mov eax, 1 diff --git a/ecomp-c/tests/boolean_variable.erun b/ecomp-c/tests/boolean_variable.erun index 88b2ebf..14d0cd6 100644 --- a/ecomp-c/tests/boolean_variable.erun +++ b/ecomp-c/tests/boolean_variable.erun @@ -14,7 +14,7 @@ Read 74 bytes of code.. 1000024: 5B pop ebx 1000025: 58 pop eax 1000026: 39D8 cmp eax, ebx -1000028: 7407 je 0x1000031 +1000028: 7507 jne 0x1000031 100002A: B800000000 mov eax, 0 100002F: EB05 jmp 0x1000036 1000031: B801000000 mov eax, 1 @@ -475,8 +475,8 @@ data: 01000076: 00000000 0100007A: 00000000 -- iteration 16 -1000028: 7407 je 0x1000031 -EIP: 0100002A +1000028: 7507 jne 0x1000031 +EIP: 01000031 ESP: 01800000 EBP: 00000000 EAX: 00000001 @@ -504,40 +504,11 @@ data: 01000076: 00000000 0100007A: 00000000 -- iteration 17 -100002A: B800000000 mov eax, 0 -EIP: 0100002F -ESP: 01800000 -EBP: 00000000 -EAX: 00000000 -EBX: 00000002 -ECX: 00000000 -EDX: 00000000 -ESI: 00000000 -EDI: 00000000 -stack: -data: -0100003E: 00000000 -01000042: 00000002 -01000046: 00000001 -0100004A: 00000000 -0100004E: 00000000 -01000052: 00000000 -01000056: 00000000 -0100005A: 00000000 -0100005E: 00000000 -01000062: 00000000 -01000066: 00000000 -0100006A: 00000000 -0100006E: 00000000 -01000072: 00000000 -01000076: 00000000 -0100007A: 00000000 --- iteration 18 -100002F: EB05 jmp 0x1000036 +1000031: B801000000 mov eax, 1 EIP: 01000036 ESP: 01800000 EBP: 00000000 -EAX: 00000000 +EAX: 00000001 EBX: 00000002 ECX: 00000000 EDX: 00000000 @@ -561,19 +532,19 @@ data: 01000072: 00000000 01000076: 00000000 0100007A: 00000000 --- iteration 19 +-- iteration 18 1000036: 50 push eax EIP: 01000037 ESP: 017FFFFC EBP: 00000000 -EAX: 00000000 +EAX: 00000001 EBX: 00000002 ECX: 00000000 EDX: 00000000 ESI: 00000000 EDI: 00000000 stack: -017FFFFC: 00000000 +017FFFFC: 00000001 data: 0100003E: 00000000 01000042: 00000002 @@ -591,12 +562,12 @@ data: 01000072: 00000000 01000076: 00000000 0100007A: 00000000 --- iteration 20 +-- iteration 19 1000037: 58 pop eax EIP: 01000038 ESP: 01800000 EBP: 00000000 -EAX: 00000000 +EAX: 00000001 EBX: 00000002 ECX: 00000000 EDX: 00000000 @@ -620,12 +591,12 @@ data: 01000072: 00000000 01000076: 00000000 0100007A: 00000000 --- iteration 21 +-- iteration 20 1000038: A33E000001 mov dword ptr [0x100003e], eax EIP: 0100003D ESP: 01800000 EBP: 00000000 -EAX: 00000000 +EAX: 00000001 EBX: 00000002 ECX: 00000000 EDX: 00000000 @@ -633,7 +604,7 @@ ESI: 00000000 EDI: 00000000 stack: data: -0100003E: 00000000 +0100003E: 00000001 01000042: 00000002 01000046: 00000001 0100004A: 00000000 @@ -649,12 +620,12 @@ data: 01000072: 00000000 01000076: 00000000 0100007A: 00000000 --- iteration 22 +-- iteration 21 100003D: F4 hlt EIP: 0100003E ESP: 01800000 EBP: 00000000 -EAX: 00000000 +EAX: 00000001 EBX: 00000002 ECX: 00000000 EDX: 00000000 @@ -662,7 +633,7 @@ ESI: 00000000 EDI: 00000000 stack: data: -0100003E: 00000000 +0100003E: 00000001 01000042: 00000002 01000046: 00000001 0100004A: 00000000 diff --git a/ecomp-c/tests/variable_initialization.e b/ecomp-c/tests/variable_initialization.e index 8e1b12e..04910a1 100644 --- a/ecomp-c/tests/variable_initialization.e +++ b/ecomp-c/tests/variable_initialization.e @@ -11,6 +11,7 @@ var a : integer; // not initialized, defacto initialized in data segment to zero b : integer := N; // initialized on declaration, initialized in data segment c : integer; // initialized at runtime to 2, in data segment initialized as zero + d : boolean := true; // a flag begin c := 2; // initialized at runtime, in data segment initialized as zero diff --git a/ecomp-c/tests/variable_initialization.easm b/ecomp-c/tests/variable_initialization.easm index facf5d4..1a6a3ad 100644 --- a/ecomp-c/tests/variable_initialization.easm +++ b/ecomp-c/tests/variable_initialization.easm @@ -5,12 +5,14 @@ org $1000000 ; DECL a -> integer, 0 ; DECL b -> integer, 1 ; DECL c -> integer, 0 +; DECL d -> boolean, 1 ; LET c <- 2 mov eax, 2 push eax pop eax mov [c], eax hlt +d: dd $00000001 c: dd $00000000 b: dd $00000001 a: dd $00000000 diff --git a/ecomp-c/tests/variable_initialization.erun b/ecomp-c/tests/variable_initialization.erun index 4c00a35..397dbaf 100644 --- a/ecomp-c/tests/variable_initialization.erun +++ b/ecomp-c/tests/variable_initialization.erun @@ -1,15 +1,17 @@ -Read 25 bytes of code.. +Read 29 bytes of code.. 1000000: B802000000 mov eax, 2 1000005: 50 push eax 1000006: 58 pop eax -1000007: A30D000001 mov dword ptr [0x100000d], eax +1000007: A311000001 mov dword ptr [0x1000011], eax 100000C: F4 hlt -100000D: 0000 data +100000D: 0100 data 100000F: 0000 data -1000011: 0100 data +1000011: 0000 data 1000013: 0000 data -1000015: 0000 data +1000015: 0100 data 1000017: 0000 data +1000019: 0000 data +100001B: 0000 data core start 1000000 data start 100000d stack start 1800000 @@ -27,9 +29,9 @@ ESI: 00000000 EDI: 00000000 stack: data: -0100000D: 00000000 -01000011: 00000001 -01000015: 00000000 +0100000D: 00000001 +01000011: 00000000 +01000015: 00000001 01000019: 00000000 0100001D: 00000000 01000021: 00000000 @@ -57,9 +59,9 @@ EDI: 00000000 stack: 017FFFFC: 00000002 data: -0100000D: 00000000 -01000011: 00000001 -01000015: 00000000 +0100000D: 00000001 +01000011: 00000000 +01000015: 00000001 01000019: 00000000 0100001D: 00000000 01000021: 00000000 @@ -86,9 +88,9 @@ ESI: 00000000 EDI: 00000000 stack: data: -0100000D: 00000000 -01000011: 00000001 -01000015: 00000000 +0100000D: 00000001 +01000011: 00000000 +01000015: 00000001 01000019: 00000000 0100001D: 00000000 01000021: 00000000 @@ -103,7 +105,7 @@ data: 01000045: 00000000 01000049: 00000000 -- iteration 4 -1000007: A30D000001 mov dword ptr [0x100000d], eax +1000007: A311000001 mov dword ptr [0x1000011], eax EIP: 0100000C ESP: 01800000 EBP: 00000000 @@ -115,9 +117,9 @@ ESI: 00000000 EDI: 00000000 stack: data: -0100000D: 00000002 -01000011: 00000001 -01000015: 00000000 +0100000D: 00000001 +01000011: 00000002 +01000015: 00000001 01000019: 00000000 0100001D: 00000000 01000021: 00000000 @@ -144,9 +146,9 @@ ESI: 00000000 EDI: 00000000 stack: data: -0100000D: 00000002 -01000011: 00000001 -01000015: 00000000 +0100000D: 00000001 +01000011: 00000002 +01000015: 00000001 01000019: 00000000 0100001D: 00000000 01000021: 00000000 |