fixed sp_off initial value

master
bill 4 years ago
parent 3530c83c5f
commit 273ee2a092

@ -252,7 +252,7 @@ public class CodeGenImpl extends CodeGenBase
size_label = "@..main.size";
} else {
sym = funcInfo.getSymbolTable();
sp_off = max_sp = funcInfo0.getLocals().size() + 2;
sp_off = max_sp = funcInfo0.getLocals().size() + 2 + 1;
size_label = "@"+funcInfo0.getFuncName()+".size";
}
epilogue = generateLocalLabel();
@ -643,10 +643,12 @@ public class CodeGenImpl extends CodeGenBase
if(node.left.getInferredType().equals(Type.INT_TYPE) && node.right.getInferredType().equals(Type.INT_TYPE))
{
node.right.dispatch(this);
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
Register r = node.right.dispatch(this);
backend.emitSW(r, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
incSp(1);
node.left.dispatch(this);
Register l = node.left.dispatch(this);
if(l != A0)
backend.emitMV(A0, l, "mv l to A0");
sp_off--;
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);

Loading…
Cancel
Save