Skip to content

Commit

Permalink
Change the style of labels and goto statements inside a function
Browse files Browse the repository at this point in the history
  • Loading branch information
VipinindKumar committed Aug 29, 2017
1 parent f6e67a1 commit 943f164
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions CodeWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,12 @@ public void writeFunction(String funcName, String nLocals) {
out.newLine();

// while(n > 0)
out.write("(LOOP" + i + ")");
out.newLine();
writeLabel(funcName + "$LOOP");
out.write("@n");
out.newLine();
out.write("D = M");
out.newLine();
out.write("@END_LOOP" + i);
out.write("@" + funcName + "$END_LOOP");
out.newLine();
out.write("D;JLE");
out.newLine();
Expand All @@ -689,14 +688,10 @@ public void writeFunction(String funcName, String nLocals) {
out.newLine();

// goto LOOP
out.write("@LOOP" + i);
out.newLine();
out.write("0;JMP");
out.newLine();
writeGoto(funcName + "$LOOP");

// (END_LOOPi)
out.write("(END_LOOP" + i + ")");
out.newLine();
writeLabel(funcName + "$END_LOOP");

i++;
}
Expand Down

0 comments on commit 943f164

Please sign in to comment.