diff --git a/CodeWriter.java b/CodeWriter.java index 0f2aeed..c3821e5 100644 --- a/CodeWriter.java +++ b/CodeWriter.java @@ -528,7 +528,10 @@ public void writeCall(String funcName, String nArgs) { // goto funcName - writeGoto(funcName); + out.write("@" + funcName.toUpperCase()); + out.newLine(); + out.write("0;JMP"); + out.newLine(); // (returnAddress) @@ -676,7 +679,7 @@ public void writeFunction(String funcName, String nLocals) { out.newLine(); // while(n > 0) - writeLabel(funcName + "$LOOP"); + writeLabel("LOOP"); out.write("@n"); out.newLine(); out.write("D = M"); @@ -696,10 +699,10 @@ public void writeFunction(String funcName, String nLocals) { out.newLine(); // goto LOOP - writeGoto(funcName + "$LOOP"); + writeGoto("LOOP"); // (END_LOOPi) - writeLabel(funcName + "$END_LOOP"); + writeLabel("END_LOOP"); i++; }