diff options
author | Yuchen Pei <me@ypei.me> | 2018-01-08 12:35:44 +0100 |
---|---|---|
committer | Yuchen Pei <me@ypei.me> | 2018-01-08 12:35:44 +0100 |
commit | 7e4cd1bac23f7cc02d0f14bcc6ef00357377fc2a (patch) | |
tree | 4d843698e8763dcbe0bdefb22712432cd5273605 /projects | |
parent | 29a1931f2ee4e72ddd240096bf6fe9a04668f131 (diff) |
checkpoint finished first draft of Board.jack
Diffstat (limited to 'projects')
-rw-r--r-- | projects/09/HelloWorld/HelloWorld.asm | 923 | ||||
-rw-r--r-- | projects/09/HelloWorld/Main.vm | 33 | ||||
-rw-r--r-- | projects/09/K/Board.jack | 237 | ||||
-rw-r--r-- | projects/09/K/K.txt | 25 | ||||
-rw-r--r-- | projects/09/Square/Main.vm | 11 | ||||
-rw-r--r-- | projects/09/Square/Square.asm | 6346 | ||||
-rw-r--r-- | projects/09/Square/Square.vm | 304 | ||||
-rw-r--r-- | projects/09/Square/SquareGame.vm | 179 |
8 files changed, 8058 insertions, 0 deletions
diff --git a/projects/09/HelloWorld/HelloWorld.asm b/projects/09/HelloWorld/HelloWorld.asm new file mode 100644 index 0000000..550a010 --- /dev/null +++ b/projects/09/HelloWorld/HelloWorld.asm @@ -0,0 +1,923 @@ +@256 +D=A +@SP +M=D +@RET0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@0 +D=D-A +@ARG +M=D +@Sys.init +0;JMP +(RET0) +(Main.main) +@12 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@String.new +0;JMP +(RET2) +@72 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET4 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET4) +@101 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET6 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET6) +@108 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET8 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET8) +@108 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET10 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET10) +@111 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET12 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET12) +@32 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET14 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET14) +@119 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET16 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET16) +@111 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET18 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET18) +@114 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET20 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET20) +@108 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET22 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET22) +@100 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET24 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET24) +@33 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET26 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@2 +D=D-A +@ARG +M=D +@String.appendChar +0;JMP +(RET26) +@RET27 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Output.printString +0;JMP +(RET27) +@SP +AM=M-1 +D=M +@5 +M=D +@RET29 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@0 +D=D-A +@ARG +M=D +@Output.println +0;JMP +(RET29) +@SP +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP diff --git a/projects/09/HelloWorld/Main.vm b/projects/09/HelloWorld/Main.vm new file mode 100644 index 0000000..32eb03f --- /dev/null +++ b/projects/09/HelloWorld/Main.vm @@ -0,0 +1,33 @@ +function Main.main 0 +push constant 12 +call String.new 1 +push constant 72 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 33 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 0 +return diff --git a/projects/09/K/Board.jack b/projects/09/K/Board.jack new file mode 100644 index 0000000..9e3678e --- /dev/null +++ b/projects/09/K/Board.jack @@ -0,0 +1,237 @@ +class Board { + field Array grid; + field int nTurn; + + constructor Board new() { + let grid = Array.new(4); + var int i, j; + let i = 0; + while (i < 4) { + let j = 0; + let grid[i] = Array.new(4); + while (j < 4) { + let grid[i][j] = 32; + } + let i = i + 1; + } + let grid[0][0] = 65; + let nTurn = 0; + return this; + } + + method void arrange(Array xs, boolean isHorizontal) { + if (isHorizontal) { + let grid = copy(xs) + } else { + let grid = transpose(xs) + } + } + + + method Array copy(Array xs) { + var Array ys; + let ys = Array.new(4); + var int i; + let i = 0; + while (i < 4) { + let ys[i] = xs[i]; + let i = i + 1; + } + return ys; + } + + method Array deepcopy(Array xs) { + var Array ys; + let ys = Array.new(4); + var int i; + let i = 0; + while (i < 4) { + let ys[i] = copy(xs[i]); + let i = i + 1; + } + return ys; + } + + mothod Array transpose(Array xs){ + var Array ys; + var int i, j; + let i = 0; + let ys = Array.new(4); + while (i < 4) { + let ys[i] = Array.new(4) + let j = 0; + while (j < 4) { + let ys[i][j] = xs[j][i]; + let j = j + 1; + } + let i = i + 1; + } + return ys; + } + + method Array getStrip(boolean isHorizontal){ + var Array xs; + if (isHorizontal) { + let xs = deepcopy(grid); + } else { + let xs = transpose(grid); + } + return xs; + } + + method Array align(Array xs, boolean left){ + var int i, j; + let i = 0; + let j = 0; + if (left = true) { + while (i < 4) { + if (xs[i] > 96) { + let xs[j] = xs[i]; + let j = j + 1; + } + let i = i + 1; + } + while (j < 4) { + let xs[j] = 32; + let j = j + 1; + } + } else { + while (i < 4) { + if (xs[3 - i] > 96) { + let xs[3 - j] = xs[3 - i]; + let j = j + 1; + } + let i = i + 1; + } + while (j < 4) { + let xs[3 - j] = 32; + let j = j + 1; + } + } + return xs; + } + + method Array reduce(Array xs, boolean left){ + if ((xs[0] = xs[1]) & (xs[2] = xs[3])) { + if (left = true) { + let xs[0] = xs[0] + 1; + let xs[1] = xs[2] + 1; + let xs[2] = 32; + let xs[3] = 32; + } else { + let xs[3] = xs[3] + 1; + let xs[2] = xs[1] + 1; + let xs[1] = 32; + let xs[0] = 32; + } + return xs; + } + if (xs[0] = xs[1]) { + if (left = true) { + let xs[0] = xs[0] + 1; + let xs[1] = xs[2]; + let xs[2] = xs[3]; + let xs[3] = 32; + } else { + let xs[1] = xs[1] + 1; + let xs[0] = 32; + } + return xs; + } + if (xs[2] = xs[3]) { + if (left = true) { + let xs[2] = xs[2] + 1; + let xs[3] = 32; + } else { + let xs[3] = xs[3] + 1; + let xs[2] = xs[1]; + let xs[1] = xs[0]; + let xs[0] = 32; + } + return xs; + } + if (xs[1] = xs[2]) { + if (left = true) { + let xs[1] = xs[1] + 1; + let xs[2] = xs[3]; + let xs[3] = 32; + } else { + let xs[2] = xs[2] + 1; + let xs[1] = xs[0] + let xs[0] = 32; + } + return xs; + } + return xs; + } + + method void addTile(){ + var int x, y; + var char z; + let x = nTurn; + let y = 23 * x * x + 79; + let x = y - (y / 16 * 16); + let r = x / 4; + let c = x - (r * 4); + let z = 97; + while (grid[r][c] > 96) { + let y = 23 * x * x + 79; + let x = y - (y / 16 * 16); + let r = x / 4; + let c = x - (r * 4); + let z = 195 - z; + } + let grid[r][c] = z; + return; + } + + method void transform(char dir){ + var boolean isHorizontal, left; + if ((dir = 0) or (dir = 1)) { + let left = true; + } else { + let left = false; + } + if ((dir = 0) or (dir = 2)) { + let isHorizontal = true; + } else { + let isHorizontal = false; + } + var Array xs; + let xs = getStrip(isHorizontal); + var int i; + let i = 0; + while (i < 4) { + xs[i] = reduce(align(xs[i], left), left); + } + do arrange(xs, isHorizontal); + return; + } + + method void next(char dir){ + do addTile(); + let nTurn = nTurn + 1; + do transform(dir); + return; + } + + method void draw(){ + var int r, c, i, j; + let r = 9; + let c = 30; + let i = 0; + while (i < 4) { + let j = 0; + do Output.moveCursor(r + i, c); + while (j < 4) { + do Output.printChar(grid[i][j]); + let j = j + 1; + } + let i = i + 1; + } + } + + method void dispose() { + do Memory.deAlloc(this); + } +} diff --git a/projects/09/K/K.txt b/projects/09/K/K.txt new file mode 100644 index 0000000..dc75c82 --- /dev/null +++ b/projects/09/K/K.txt @@ -0,0 +1,25 @@ +from a to k + +- a title frame showing game name and instructions. space to continue. +- a main frame showing the game running +- a endofgame frame showing game results: win or lose + +- a Board class with cell being a 4 by 4 two-d array. +- arrange strings according to an orientation: arrange(4 strings, dir)=cells + - dir: 0: align to left, 1: align to right, 2: align to top, 3:align to bottom + - e.g.: arrange({"abc", "bc", "dc", "efeh", 0}) gives the following board: + abc_ + bc__ + dc__ + efeh + - arrange({"abc", "bc", "dc", "efeh", 0}, 3) gives the following + ___e + a__f + bbde + ccch +- a new tile of 'a' or 'b' appears each turn somewhere, using some quasirandomisation e.g. (23 * n^2 + 79) mod 16. + - addtile(char, x, y) +- the board transformation: board.trans(dir) = arrange(dir) . (fmap reduce) . getstring(dir). calls getstrings, then reduce on each row / column +- board.getstrings(dir)= the strings according to direction dir. Inverse of arrange. +- reduce(string)=string: reduce("baac")=="bbc"; reduce("aabb")=="bc"; and reduce("cbb")== "cc" instead of "d". +- when one of the hjkl keys is pressed get the direction dir. diff --git a/projects/09/Square/Main.vm b/projects/09/Square/Main.vm new file mode 100644 index 0000000..a3b355b --- /dev/null +++ b/projects/09/Square/Main.vm @@ -0,0 +1,11 @@ +function Main.main 1 +call SquareGame.new 0 +pop local 0 +push local 0 +call SquareGame.run 1 +pop temp 0 +push local 0 +call SquareGame.dispose 1 +pop temp 0 +push constant 0 +return diff --git a/projects/09/Square/Square.asm b/projects/09/Square/Square.asm new file mode 100644 index 0000000..8ad70dd --- /dev/null +++ b/projects/09/Square/Square.asm @@ -0,0 +1,6346 @@ +@256 +D=A +@SP +M=D +@RET0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@0 +D=D-A +@ARG +M=D +@Sys.init +0;JMP +(RET0) +(Main.main) +@SP +A=M +M=0 +@SP +M=M+1 +@RET1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@0 +D=D-A +@ARG +M=D +@SquareGame.new +0;JMP +(RET1) +@LCL +D=M +@0 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET4 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@SquareGame.run +0;JMP +(RET4) +@SP +AM=M-1 +D=M +@5 +M=D +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET7 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@SquareGame.dispose +0;JMP +(RET7) +@SP +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(SquareGame.new) +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Memory.alloc +0;JMP +(RET2) +@SP +AM=M-1 +D=M +@3 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@30 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET7 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@3 +D=D-A +@ARG +M=D +@Square.new +0;JMP +(RET7) +@THIS +D=M +@0 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(SquareGame.dispose) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.dispose +0;JMP +(RET17) +@SP +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET20 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Memory.deAlloc +0;JMP +(RET20) +@SP +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(SquareGame.moveSquare) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame29 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame29 +0;JMP +(IFSquareGame29) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame29) +@SP +AM=M-1 +D=M +@SquareGame.moveSquare$IF_TRUE0 +D;JNE +@SquareGame.moveSquare$IF_FALSE0 +0;JMP +(SquareGame.moveSquare$IF_TRUE0) +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET34 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.moveUp +0;JMP +(RET34) +@SP +AM=M-1 +D=M +@5 +M=D +(SquareGame.moveSquare$IF_FALSE0) +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame39 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame39 +0;JMP +(IFSquareGame39) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame39) +@SP +AM=M-1 +D=M +@SquareGame.moveSquare$IF_TRUE1 +D;JNE +@SquareGame.moveSquare$IF_FALSE1 +0;JMP +(SquareGame.moveSquare$IF_TRUE1) +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET44 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.moveDown +0;JMP +(RET44) +@SP +AM=M-1 +D=M +@5 +M=D +(SquareGame.moveSquare$IF_FALSE1) +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@3 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame49 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame49 +0;JMP +(IFSquareGame49) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame49) +@SP +AM=M-1 +D=M +@SquareGame.moveSquare$IF_TRUE2 +D;JNE +@SquareGame.moveSquare$IF_FALSE2 +0;JMP +(SquareGame.moveSquare$IF_TRUE2) +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET54 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.moveLeft +0;JMP +(RET54) +@SP +AM=M-1 +D=M +@5 +M=D +(SquareGame.moveSquare$IF_FALSE2) +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@4 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame59 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame59 +0;JMP +(IFSquareGame59) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame59) +@SP +AM=M-1 +D=M +@SquareGame.moveSquare$IF_TRUE3 +D;JNE +@SquareGame.moveSquare$IF_FALSE3 +0;JMP +(SquareGame.moveSquare$IF_TRUE3) +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET64 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.moveRight +0;JMP +(RET64) +@SP +AM=M-1 +D=M +@5 +M=D +(SquareGame.moveSquare$IF_FALSE3) +@5 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET68 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Sys.wait +0;JMP +(RET68) +@SP +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(SquareGame.run) +@SP +A=M +M=0 +@SP +M=M+1 +@SP +A=M +M=0 +@SP +M=M+1 +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(SquareGame.run$WHILE_EXP0) +@LCL +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SquareGame.run$WHILE_END0 +D;JNE +(SquareGame.run$WHILE_EXP1) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame85 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame85 +0;JMP +(IFSquareGame85) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame85) +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SquareGame.run$WHILE_END1 +D;JNE +@RET88 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@0 +D=D-A +@ARG +M=D +@Keyboard.keyPressed +0;JMP +(RET88) +@LCL +D=M +@0 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET91 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@SquareGame.moveSquare +0;JMP +(RET91) +@SP +AM=M-1 +D=M +@5 +M=D +@SquareGame.run$WHILE_EXP1 +0;JMP +(SquareGame.run$WHILE_END1) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@81 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame97 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame97 +0;JMP +(IFSquareGame97) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame97) +@SP +AM=M-1 +D=M +@SquareGame.run$IF_TRUE0 +D;JNE +@SquareGame.run$IF_FALSE0 +0;JMP +(SquareGame.run$IF_TRUE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@LCL +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(SquareGame.run$IF_FALSE0) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@90 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame107 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame107 +0;JMP +(IFSquareGame107) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame107) +@SP +AM=M-1 +D=M +@SquareGame.run$IF_TRUE1 +D;JNE +@SquareGame.run$IF_FALSE1 +0;JMP +(SquareGame.run$IF_TRUE1) +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET112 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.decSize +0;JMP +(RET112) +@SP +AM=M-1 +D=M +@5 +M=D +(SquareGame.run$IF_FALSE1) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@88 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame117 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame117 +0;JMP +(IFSquareGame117) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame117) +@SP +AM=M-1 +D=M +@SquareGame.run$IF_TRUE2 +D;JNE +@SquareGame.run$IF_FALSE2 +0;JMP +(SquareGame.run$IF_TRUE2) +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET122 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.incSize +0;JMP +(RET122) +@SP +AM=M-1 +D=M +@5 +M=D +(SquareGame.run$IF_FALSE2) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@131 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame127 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame127 +0;JMP +(IFSquareGame127) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame127) +@SP +AM=M-1 +D=M +@SquareGame.run$IF_TRUE3 +D;JNE +@SquareGame.run$IF_FALSE3 +0;JMP +(SquareGame.run$IF_TRUE3) +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(SquareGame.run$IF_FALSE3) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@133 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame136 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame136 +0;JMP +(IFSquareGame136) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame136) +@SP +AM=M-1 +D=M +@SquareGame.run$IF_TRUE4 +D;JNE +@SquareGame.run$IF_FALSE4 +0;JMP +(SquareGame.run$IF_TRUE4) +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(SquareGame.run$IF_FALSE4) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@130 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame145 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame145 +0;JMP +(IFSquareGame145) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame145) +@SP +AM=M-1 +D=M +@SquareGame.run$IF_TRUE5 +D;JNE +@SquareGame.run$IF_FALSE5 +0;JMP +(SquareGame.run$IF_TRUE5) +@3 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(SquareGame.run$IF_FALSE5) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@132 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame154 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame154 +0;JMP +(IFSquareGame154) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame154) +@SP +AM=M-1 +D=M +@SquareGame.run$IF_TRUE6 +D;JNE +@SquareGame.run$IF_FALSE6 +0;JMP +(SquareGame.run$IF_TRUE6) +@4 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(SquareGame.run$IF_FALSE6) +(SquareGame.run$WHILE_EXP2) +@LCL +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquareGame164 +D;JEQ +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquareGame164 +0;JMP +(IFSquareGame164) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquareGame164) +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SquareGame.run$WHILE_END2 +D;JNE +@RET168 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@0 +D=D-A +@ARG +M=D +@Keyboard.keyPressed +0;JMP +(RET168) +@LCL +D=M +@0 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET171 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@SquareGame.moveSquare +0;JMP +(RET171) +@SP +AM=M-1 +D=M +@5 +M=D +@SquareGame.run$WHILE_EXP2 +0;JMP +(SquareGame.run$WHILE_END2) +@SquareGame.run$WHILE_EXP0 +0;JMP +(SquareGame.run$WHILE_END0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.new) +@3 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Memory.alloc +0;JMP +(RET2) +@SP +AM=M-1 +D=M +@3 +M=D +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET11 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.draw +0;JMP +(RET11) +@SP +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.dispose) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET19 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Memory.deAlloc +0;JMP +(RET19) +@SP +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.draw) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@RET28 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET28) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET38 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET38) +@SP +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.erase) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET46 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET46) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET56 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET56) +@SP +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.incSize) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@254 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquare67 +D;JLT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquare67 +0;JMP +(IFSquare67) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquare67) +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@510 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquare72 +D;JLT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquare72 +0;JMP +(IFSquare72) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquare72) +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M&D +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@Square.incSize$IF_TRUE0 +D;JNE +@Square.incSize$IF_FALSE0 +0;JMP +(Square.incSize$IF_TRUE0) +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET78 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.erase +0;JMP +(RET78) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET85 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.draw +0;JMP +(RET85) +@SP +AM=M-1 +D=M +@5 +M=D +(Square.incSize$IF_FALSE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.decSize) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquare95 +D;JGT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquare95 +0;JMP +(IFSquare95) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquare95) +@SP +AM=M-1 +D=M +@Square.decSize$IF_TRUE0 +D;JNE +@Square.decSize$IF_FALSE0 +0;JMP +(Square.decSize$IF_TRUE0) +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET100 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.erase +0;JMP +(RET100) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@RET107 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Square.draw +0;JMP +(RET107) +@SP +AM=M-1 +D=M +@5 +M=D +(Square.decSize$IF_FALSE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.moveUp) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquare117 +D;JGT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquare117 +0;JMP +(IFSquare117) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquare117) +@SP +AM=M-1 +D=M +@Square.moveUp$IF_TRUE0 +D;JNE +@Square.moveUp$IF_FALSE0 +0;JMP +(Square.moveUp$IF_TRUE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET122 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET122) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET136 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET136) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@RET144 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET144) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET154 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET154) +@SP +AM=M-1 +D=M +@5 +M=D +(Square.moveUp$IF_FALSE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.moveDown) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@254 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquare166 +D;JLT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquare166 +0;JMP +(IFSquare166) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquare166) +@SP +AM=M-1 +D=M +@Square.moveDown$IF_TRUE0 +D;JNE +@Square.moveDown$IF_FALSE0 +0;JMP +(Square.moveDown$IF_TRUE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET171 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET171) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET181 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET181) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@RET189 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET189) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET203 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET203) +@SP +AM=M-1 +D=M +@5 +M=D +(Square.moveDown$IF_FALSE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.moveLeft) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquare213 +D;JGT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquare213 +0;JMP +(IFSquare213) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquare213) +@SP +AM=M-1 +D=M +@Square.moveLeft$IF_TRUE0 +D;JNE +@Square.moveLeft$IF_FALSE0 +0;JMP +(Square.moveLeft$IF_TRUE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET218 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET218) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET232 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET232) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@RET240 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET240) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET250 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET250) +@SP +AM=M-1 +D=M +@5 +M=D +(Square.moveLeft$IF_FALSE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP +(Square.moveRight) +@ARG +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@3 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@510 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@IFSquare262 +D;JLT +@SP +A=M +M=0 +@SP +M=M+1 +@ENDIFSquare262 +0;JMP +(IFSquare262) +@SP +A=M +M=-1 +@SP +M=M+1 +(ENDIFSquare262) +@SP +AM=M-1 +D=M +@Square.moveRight$IF_TRUE0 +D;JNE +@Square.moveRight$IF_FALSE0 +0;JMP +(Square.moveRight$IF_TRUE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@RET267 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET267) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET277 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET277) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +A=M +M=!D +@SP +M=M+1 +@RET285 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@1 +D=D-A +@ARG +M=D +@Screen.setColor +0;JMP +(RET285) +@SP +AM=M-1 +D=M +@5 +M=D +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M-D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@0 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@1 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@2 +D=A+D +A=D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +AM=M-1 +D=M +@SP +AM=M-1 +D=M+D +@SP +A=M +M=D +@SP +M=M+1 +@RET299 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@SP +A=M +M=D +@SP +M=M+1 +@ARG +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THIS +D=M +@SP +A=M +M=D +@SP +M=M+1 +@THAT +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +D=M +@LCL +M=D +@5 +D=D-A +@4 +D=D-A +@ARG +M=D +@Screen.drawRectangle +0;JMP +(RET299) +@SP +AM=M-1 +D=M +@5 +M=D +(Square.moveRight$IF_FALSE0) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@LCL +D=M +@R13 +M=D +@5 +A=D-A +D=M +@R14 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +AM=M-1 +D=M +@THAT +M=D +@R13 +AM=M-1 +D=M +@THIS +M=D +@R13 +AM=M-1 +D=M +@ARG +M=D +@R13 +AM=M-1 +D=M +@LCL +M=D +@R14 +A=M +0;JMP diff --git a/projects/09/Square/Square.vm b/projects/09/Square/Square.vm new file mode 100644 index 0000000..e3932bc --- /dev/null +++ b/projects/09/Square/Square.vm @@ -0,0 +1,304 @@ +function Square.new 0 +push constant 3 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +pop this 0 +push argument 1 +pop this 1 +push argument 2 +pop this 2 +push pointer 0 +call Square.draw 1 +pop temp 0 +push pointer 0 +return +function Square.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function Square.draw 0 +push argument 0 +pop pointer 0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push this 2 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Square.erase 0 +push argument 0 +pop pointer 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push this 2 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Square.incSize 0 +push argument 0 +pop pointer 0 +push this 1 +push this 2 +add +push constant 254 +lt +push this 0 +push this 2 +add +push constant 510 +lt +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push pointer 0 +call Square.erase 1 +pop temp 0 +push this 2 +push constant 2 +add +pop this 2 +push pointer 0 +call Square.draw 1 +pop temp 0 +label IF_FALSE0 +push constant 0 +return +function Square.decSize 0 +push argument 0 +pop pointer 0 +push this 2 +push constant 2 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push pointer 0 +call Square.erase 1 +pop temp 0 +push this 2 +push constant 2 +sub +pop this 2 +push pointer 0 +call Square.draw 1 +pop temp 0 +label IF_FALSE0 +push constant 0 +return +function Square.moveUp 0 +push argument 0 +pop pointer 0 +push this 1 +push constant 1 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +add +push constant 1 +sub +push this 0 +push this 2 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +push this 1 +push constant 2 +sub +pop this 1 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push this 2 +add +push this 1 +push constant 1 +add +call Screen.drawRectangle 4 +pop temp 0 +label IF_FALSE0 +push constant 0 +return +function Square.moveDown 0 +push argument 0 +pop pointer 0 +push this 1 +push this 2 +add +push constant 254 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push this 2 +add +push this 1 +push constant 1 +add +call Screen.drawRectangle 4 +pop temp 0 +push this 1 +push constant 2 +add +pop this 1 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +add +push constant 1 +sub +push this 0 +push this 2 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +label IF_FALSE0 +push constant 0 +return +function Square.moveLeft 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 1 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 2 +add +push constant 1 +sub +push this 1 +push this 0 +push this 2 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +push this 0 +push constant 2 +sub +pop this 0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push constant 1 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +label IF_FALSE0 +push constant 0 +return +function Square.moveRight 0 +push argument 0 +pop pointer 0 +push this 0 +push this 2 +add +push constant 510 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push constant 1 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +push this 0 +push constant 2 +add +pop this 0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 2 +add +push constant 1 +sub +push this 1 +push this 0 +push this 2 +add +push this 1 +push this 2 +add +call Screen.drawRectangle 4 +pop temp 0 +label IF_FALSE0 +push constant 0 +return diff --git a/projects/09/Square/SquareGame.vm b/projects/09/Square/SquareGame.vm new file mode 100644 index 0000000..8444dbc --- /dev/null +++ b/projects/09/Square/SquareGame.vm @@ -0,0 +1,179 @@ +function SquareGame.new 0 +push constant 2 +call Memory.alloc 1 +pop pointer 0 +push constant 0 +push constant 0 +push constant 30 +call Square.new 3 +pop this 0 +push constant 0 +pop this 1 +push pointer 0 +return +function SquareGame.dispose 0 +push argument 0 +pop pointer 0 +push this 0 +call Square.dispose 1 +pop temp 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function SquareGame.moveSquare 0 +push argument 0 +pop pointer 0 +push this 1 +push constant 1 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 0 +call Square.moveUp 1 +pop temp 0 +label IF_FALSE0 +push this 1 +push constant 2 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push this 0 +call Square.moveDown 1 +pop temp 0 +label IF_FALSE1 +push this 1 +push constant 3 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push this 0 +call Square.moveLeft 1 +pop temp 0 +label IF_FALSE2 +push this 1 +push constant 4 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push this 0 +call Square.moveRight 1 +pop temp 0 +label IF_FALSE3 +push constant 5 +call Sys.wait 1 +pop temp 0 +push constant 0 +return +function SquareGame.run 2 +push argument 0 +pop pointer 0 +push constant 0 +pop local 1 +label WHILE_EXP0 +push local 1 +not +not +if-goto WHILE_END0 +label WHILE_EXP1 +push local 0 +push constant 0 +eq +not +if-goto WHILE_END1 +call Keyboard.keyPressed 0 +pop local 0 +push pointer 0 +call SquareGame.moveSquare 1 +pop temp 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 0 +push constant 81 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +not +pop local 1 +label IF_FALSE0 +push local 0 +push constant 90 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push this 0 +call Square.decSize 1 +pop temp 0 +label IF_FALSE1 +push local 0 +push constant 88 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push this 0 +call Square.incSize 1 +pop temp 0 +label IF_FALSE2 +push local 0 +push constant 131 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 1 +pop this 1 +label IF_FALSE3 +push local 0 +push constant 133 +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 2 +pop this 1 +label IF_FALSE4 +push local 0 +push constant 130 +eq +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push constant 3 +pop this 1 +label IF_FALSE5 +push local 0 +push constant 132 +eq +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push constant 4 +pop this 1 +label IF_FALSE6 +label WHILE_EXP2 +push local 0 +push constant 0 +eq +not +not +if-goto WHILE_END2 +call Keyboard.keyPressed 0 +pop local 0 +push pointer 0 +call SquareGame.moveSquare 1 +pop temp 0 +goto WHILE_EXP2 +label WHILE_END2 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return |