Skip to content
Snippets Groups Projects
Verified Commit 772b0697 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

PUSH instruction problem fixed: now push satisfies x86 spec

parent 6bb094b5
No related branches found
No related tags found
No related merge requests found
Pipeline #237 passed with warnings with stages
in 4 minutes and 8 seconds
......@@ -39,13 +39,13 @@ public class CodeGenImpl extends CodeGenBase {
}
}
public void emitPush(RiscVBackend.Register reg, String comment) {
backend.emitSW(reg, SP, 0, comment);
backend.emitADDI(SP, SP, -1 * backend.getWordSize(), comment);
backend.emitSW(reg, SP, 0, comment);
}
public void emitPop(RiscVBackend.Register reg, String comment) {
backend.emitADDI(SP, SP, backend.getWordSize(), comment);
if(reg != null)
backend.emitLW(reg, SP, 0, comment);
backend.emitADDI(SP, SP, backend.getWordSize(), comment);
}
public void emitCall(Label calledLabel, String comment) {
// Arguments should be already pushed to stack.
......@@ -56,7 +56,7 @@ public class CodeGenImpl extends CodeGenBase {
// jal will set RA register properly.
// FIXME: Testing fucking silly $print
backend.emitADDI(SP, SP, 3 * backend.getWordSize(), "FUCKING SILLY BUILTIN CODE");
backend.emitADDI(SP, SP, 2 * backend.getWordSize(), "FUCKING SILLY BUILTIN CODE");
backend.emitJAL(calledLabel, "Call it!");
backend.emitADDI(SP, FP, -2 * backend.getWordSize(), "Revert all local variables on this dying frame.");
......@@ -79,7 +79,7 @@ public class CodeGenImpl extends CodeGenBase {
emitPush(tmpReg, null);
backend.emitLI(tmpReg, 1, "OBJECT HEAD - TYPE = INT");
emitPush(tmpReg, null);
backend.emitADDI(tmpReg, SP, backend.getWordSize(), "Return INT address.");
backend.emitMV(tmpReg, SP, "Return INT address.");
}
public void emitPushBoolVal(RiscVBackend.Register tmpReg, Boolean val, String comment) {
emitNoop(comment);
......@@ -91,7 +91,7 @@ public class CodeGenImpl extends CodeGenBase {
emitPush(tmpReg, null);
backend.emitLI(tmpReg, 2, "OBJECT HEAD - TYPE = BOOL");
emitPush(tmpReg, null);
backend.emitADDI(tmpReg, SP, backend.getWordSize(), "Return BOOL address.");
backend.emitMV(tmpReg, SP, "Return BOOL address.");
}
public void emitPushStrVal(RiscVBackend.Register tmpReg, String val, String comment) {
emitNoop(comment);
......@@ -121,7 +121,7 @@ public class CodeGenImpl extends CodeGenBase {
emitPush(tmpReg, null);
backend.emitLI(tmpReg, 3, "OBJECT HEAD - TYPE = STR");
emitPush(tmpReg, null);
backend.emitADDI(tmpReg, SP, backend.getWordSize(), "Return STR OBJ address.");
backend.emitMV(tmpReg, SP, "Return STR OBJ address.");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment