From 245daeb6f9982671e309d155abbcdb629fd991d8 Mon Sep 17 00:00:00 2001 From: Curle Date: Mon, 23 Nov 2020 19:23:41 +0000 Subject: [PATCH] Clean up generated assembly - the switch takes care of the primitive size so we need only pass a length of 1 for variables. --- src/Assembler.c | 6 +++--- src/Statements.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Assembler.c b/src/Assembler.c index c94a504..c1b391c 100644 --- a/src/Assembler.c +++ b/src/Assembler.c @@ -512,9 +512,9 @@ void AsNewSymb(int ID) { for(int i = 0; i < Symbols[ID].Length; i++) { switch(TypeSize) { - case 1: fprintf(OutputFile, "\t.byte\t0\n", Symbols[ID].Name); break; - case 4: fprintf(OutputFile, "\t.long\t0\n", Symbols[ID].Name); break; - case 8: fprintf(OutputFile, "\t.quad\t0\n", Symbols[ID].Name); break; + case 1: fprintf(OutputFile, "\t.byte\t0\r\n", Symbols[ID].Name); break; + case 4: fprintf(OutputFile, "\t.long\t0\r\n", Symbols[ID].Name); break; + case 8: fprintf(OutputFile, "\t.quad\t0\r\n", Symbols[ID].Name); break; default: DieDecimal("Unknown type in AsNewSymbol", TypeSize); break; } } diff --git a/src/Statements.c b/src/Statements.c index c229d88..54fd8c7 100644 --- a/src/Statements.c +++ b/src/Statements.c @@ -42,7 +42,7 @@ void BeginVariableDeclaration(int Type) { while(1) { //printf("Identifier: %s\n", CurrentIdentifier); printf("Adding symbol %s of type %s.\n", CurrentIdentifier, TypeNames[Type]); - ID = AddSymbol(CurrentIdentifier, Type, ST_VAR, TypeSizes[Type]); + ID = AddSymbol(CurrentIdentifier, Type, ST_VAR, 1); AsNewSymb(ID); if(CurrentToken.type == LI_SEMIC) {