Fix bug in loading values into variables

This commit is contained in:
Curle 2020-09-13 00:04:38 +01:00
parent 7fe6a34613
commit c2b396b853
Signed by: TheCurle
GPG Key ID: 2F2E62F0DA69A5AE

View File

@ -348,11 +348,11 @@ int AsLdVar(int ID) {
switch(Symbols[ID].Type) {
case RET_CHAR:
// movzbq zeroes, then moves a byte into the quad register
fprintf(OutputFile, "\tmovzbq\t%s(\%%rip), %s\n", Symbols[ID].Name, Registers[Reg]);
fprintf(OutputFile, "\tmovb\t%s(\%%rip), %s\n", Symbols[ID].Name, ByteRegisters[Reg]);
break;
case RET_INT:
fprintf(OutputFile, "\tmovzbl\t%s(\%%rip), %s\n", Symbols[ID].Name, Registers[Reg]);
fprintf(OutputFile, "\tmovl\t%s(\%%rip), %s\n", Symbols[ID].Name, DoubleRegisters[Reg]);
break;
case RET_LONG:
@ -367,29 +367,27 @@ int AsLdVar(int ID) {
}
int AsStrVar(int Register, int ID) {
int Reg = RetrieveRegister();
printf("\tStoring contents of %s into %s\n", Registers[Register], Symbols[ID].Name);
switch(Symbols[ID].Type) {
case RET_CHAR:
// movzbq zeroes, then moves a byte into the quad register
fprintf(OutputFile, "\tmovb\t%s, %s(\%%rip)\n", ByteRegisters[Reg], Symbols[ID].Name);
fprintf(OutputFile, "\tmovb\t%s, %s(\%%rip)\n", ByteRegisters[Register], Symbols[ID].Name);
break;
case RET_INT:
fprintf(OutputFile, "\tmovl\t%s, %s(\%%rip)\n", DoubleRegisters[Reg], Symbols[ID].Name);
fprintf(OutputFile, "\tmovl\t%s, %s(\%%rip)\n", DoubleRegisters[Register], Symbols[ID].Name);
break;
case RET_LONG:
fprintf(OutputFile, "\tmovq\t%s, %s(%%rip)\n", Registers[Reg], Symbols[ID].Name);
fprintf(OutputFile, "\tmovq\t%s, %s(%%rip)\n", Registers[Register], Symbols[ID].Name);
break;
default:
DieMessage("Bad type for saving", Types[Symbols[ID].Type]);
}
return Reg;
return Register;
}
void AsNewSymb(int ID) {