fixed sp_off initial value
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user