commit 7894b48931aa6e4bfa0e7db53361ff5b1ac25a8c Author: QkoSad Date: Wed Jul 16 13:00:37 2025 +0300 . diff --git a/README.md b/README.md new file mode 100755 index 0000000..ec9e3f0 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Contents for the courses nand2tetris part one and part two. +Important things: +1. Project 06 cotaints an assemler which takes Assembly and translates it into machine code +2. Project 08 contains a VMtranslator which takes VM code and translates it into Assemly +3. Project 11 contains an language translator which takes JACK code and translates it into VM code +4. Project 09 contains a game written in the language developed before, a.k.a JACK + +Projects 06, 08, 11 have been writen in Python 3.9 diff --git a/projects/00/file.txt b/projects/00/file.txt new file mode 100755 index 0000000..ff654e3 --- /dev/null +++ b/projects/00/file.txt @@ -0,0 +1,6 @@ +The only purpose of this file is to practice submitting files +in the Nand to Tetris course websites in Coursera. + +There is no need to modify the contents of this file. +All you have to do is submit it as is, following the +Project 0 guidelines in the website. \ No newline at end of file diff --git a/projects/01/And.cmp b/projects/01/And.cmp new file mode 100755 index 0000000..75e709a --- /dev/null +++ b/projects/01/And.cmp @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 0 | +| 1 | 0 | 0 | +| 1 | 1 | 1 | diff --git a/projects/01/And.hdl b/projects/01/And.hdl new file mode 100755 index 0000000..4816b67 --- /dev/null +++ b/projects/01/And.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/And.hdl + +/** + * And gate: + * out = 1 if (a == 1 and b == 1) + * 0 otherwise + */ + +CHIP And { + IN a, b; + OUT out; + + PARTS: + Nand(a=a,b=b,out=out1); + Not(in=out1,out=out); +} diff --git a/projects/01/And.out b/projects/01/And.out new file mode 100755 index 0000000..75e709a --- /dev/null +++ b/projects/01/And.out @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 0 | +| 1 | 0 | 0 | +| 1 | 1 | 1 | diff --git a/projects/01/And.tst b/projects/01/And.tst new file mode 100755 index 0000000..7ace19d --- /dev/null +++ b/projects/01/And.tst @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/And.tst + +load And.hdl, +output-file And.out, +compare-to And.cmp, +output-list a%B3.1.3 b%B3.1.3 out%B3.1.3; + +set a 0, +set b 0, +eval, +output; + +set a 0, +set b 1, +eval, +output; + +set a 1, +set b 0, +eval, +output; + +set a 1, +set b 1, +eval, +output; diff --git a/projects/01/And16.cmp b/projects/01/And16.cmp new file mode 100755 index 0000000..32c8648 --- /dev/null +++ b/projects/01/And16.cmp @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0000000000000000 | +| 1111111111111111 | 1111111111111111 | 1111111111111111 | +| 1010101010101010 | 0101010101010101 | 0000000000000000 | +| 0011110011000011 | 0000111111110000 | 0000110011000000 | +| 0001001000110100 | 1001100001110110 | 0001000000110100 | diff --git a/projects/01/And16.hdl b/projects/01/And16.hdl new file mode 100755 index 0000000..1fbcabe --- /dev/null +++ b/projects/01/And16.hdl @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/And16.hdl + +/** + * 16-bit bitwise And: + * for i = 0..15: out[i] = (a[i] and b[i]) + */ + +CHIP And16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + + And(a=a[0],b=b[0],out=out[0]); + And(a=a[1],b=b[1],out=out[1]); + And(a=a[2],b=b[2],out=out[2]); + And(a=a[3],b=b[3],out=out[3]); + And(a=a[4],b=b[4],out=out[4]); + And(a=a[5],b=b[5],out=out[5]); + And(a=a[6],b=b[6],out=out[6]); + And(a=a[7],b=b[7],out=out[7]); + And(a=a[8],b=b[8],out=out[8]); + And(a=a[9],b=b[9],out=out[9]); + And(a=a[10],b=b[10],out=out[10]); + And(a=a[11],b=b[11],out=out[11]); + And(a=a[12],b=b[12],out=out[12]); + And(a=a[13],b=b[13],out=out[13]); + And(a=a[14],b=b[14],out=out[14]); + And(a=a[15],b=b[15],out=out[15]); + + +} \ No newline at end of file diff --git a/projects/01/And16.out b/projects/01/And16.out new file mode 100755 index 0000000..32c8648 --- /dev/null +++ b/projects/01/And16.out @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0000000000000000 | +| 1111111111111111 | 1111111111111111 | 1111111111111111 | +| 1010101010101010 | 0101010101010101 | 0000000000000000 | +| 0011110011000011 | 0000111111110000 | 0000110011000000 | +| 0001001000110100 | 1001100001110110 | 0001000000110100 | diff --git a/projects/01/And16.tst b/projects/01/And16.tst new file mode 100755 index 0000000..c8921e7 --- /dev/null +++ b/projects/01/And16.tst @@ -0,0 +1,39 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/And16.tst + +load And16.hdl, +output-file And16.out, +compare-to And16.cmp, +output-list a%B1.16.1 b%B1.16.1 out%B1.16.1; + +set a %B0000000000000000, +set b %B0000000000000000, +eval, +output; + +set a %B0000000000000000, +set b %B1111111111111111, +eval, +output; + +set a %B1111111111111111, +set b %B1111111111111111, +eval, +output; + +set a %B1010101010101010, +set b %B0101010101010101, +eval, +output; + +set a %B0011110011000011, +set b %B0000111111110000, +eval, +output; + +set a %B0001001000110100, +set b %B1001100001110110, +eval, +output; \ No newline at end of file diff --git a/projects/01/DMux.cmp b/projects/01/DMux.cmp new file mode 100755 index 0000000..6982094 --- /dev/null +++ b/projects/01/DMux.cmp @@ -0,0 +1,5 @@ +| in | sel | a | b | +| 0 | 0 | 0 | 0 | +| 0 | 1 | 0 | 0 | +| 1 | 0 | 1 | 0 | +| 1 | 1 | 0 | 1 | diff --git a/projects/01/DMux.hdl b/projects/01/DMux.hdl new file mode 100755 index 0000000..ede6878 --- /dev/null +++ b/projects/01/DMux.hdl @@ -0,0 +1,21 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux.hdl + +/** + * Demultiplexor: + * {a, b} = {in, 0} if sel == 0 + * {0, in} if sel == 1 + */ + +CHIP DMux { + IN in, sel; + OUT a, b; + + PARTS: + Not(in=sel,out=notsel); + And(a=in,b=notsel,out=a); + And(a=in,b=sel,out=b); + +} diff --git a/projects/01/DMux.out b/projects/01/DMux.out new file mode 100755 index 0000000..6982094 --- /dev/null +++ b/projects/01/DMux.out @@ -0,0 +1,5 @@ +| in | sel | a | b | +| 0 | 0 | 0 | 0 | +| 0 | 1 | 0 | 0 | +| 1 | 0 | 1 | 0 | +| 1 | 1 | 0 | 1 | diff --git a/projects/01/DMux.tst b/projects/01/DMux.tst new file mode 100755 index 0000000..4adbc43 --- /dev/null +++ b/projects/01/DMux.tst @@ -0,0 +1,27 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux.tst + +load DMux.hdl, +output-file DMux.out, +compare-to DMux.cmp, +output-list in%B3.1.3 sel%B3.1.3 a%B3.1.3 b%B3.1.3; + +set in 0, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set in 1, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; diff --git a/projects/01/DMux4Way.cmp b/projects/01/DMux4Way.cmp new file mode 100755 index 0000000..eac35c4 --- /dev/null +++ b/projects/01/DMux4Way.cmp @@ -0,0 +1,9 @@ +| in | sel | a | b | c | d | +| 0 | 00 | 0 | 0 | 0 | 0 | +| 0 | 01 | 0 | 0 | 0 | 0 | +| 0 | 10 | 0 | 0 | 0 | 0 | +| 0 | 11 | 0 | 0 | 0 | 0 | +| 1 | 00 | 1 | 0 | 0 | 0 | +| 1 | 01 | 0 | 1 | 0 | 0 | +| 1 | 10 | 0 | 0 | 1 | 0 | +| 1 | 11 | 0 | 0 | 0 | 1 | diff --git a/projects/01/DMux4Way.hdl b/projects/01/DMux4Way.hdl new file mode 100755 index 0000000..7346e03 --- /dev/null +++ b/projects/01/DMux4Way.hdl @@ -0,0 +1,32 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux4Way.hdl + +/** + * 4-way demultiplexor: + * {a, b, c, d} = {in, 0, 0, 0} if sel == 00 + * {0, in, 0, 0} if sel == 01 + * {0, 0, in, 0} if sel == 10 + * {0, 0, 0, in} if sel == 11 + */ + +CHIP DMux4Way { + IN in, sel[2]; + OUT a, b, c, d; + + PARTS: + Not(in=sel[1],out=notsel1); + Not(in=sel[0],out=notsel0); + + And(a=notsel1,b=notsel0,out=out1); + And(a=notsel1,b=sel[0],out=out2); + And(a=sel[1],b=notsel0,out=out3); + And(a=sel[1],b=sel[0],out=out4); + + And(a=in,b=out1,out=a); + And(a=in,b=out2,out=b); + And(a=in,b=out3,out=c); + And(a=in,b=out4,out=d); + +} \ No newline at end of file diff --git a/projects/01/DMux4Way.out b/projects/01/DMux4Way.out new file mode 100755 index 0000000..eac35c4 --- /dev/null +++ b/projects/01/DMux4Way.out @@ -0,0 +1,9 @@ +| in | sel | a | b | c | d | +| 0 | 00 | 0 | 0 | 0 | 0 | +| 0 | 01 | 0 | 0 | 0 | 0 | +| 0 | 10 | 0 | 0 | 0 | 0 | +| 0 | 11 | 0 | 0 | 0 | 0 | +| 1 | 00 | 1 | 0 | 0 | 0 | +| 1 | 01 | 0 | 1 | 0 | 0 | +| 1 | 10 | 0 | 0 | 1 | 0 | +| 1 | 11 | 0 | 0 | 0 | 1 | diff --git a/projects/01/DMux4Way.tst b/projects/01/DMux4Way.tst new file mode 100755 index 0000000..6fbbb56 --- /dev/null +++ b/projects/01/DMux4Way.tst @@ -0,0 +1,43 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux4Way.tst + +load DMux4Way.hdl, +output-file DMux4Way.out, +compare-to DMux4Way.cmp, +output-list in%B2.1.2 sel%B2.2.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2; + +set in 0, +set sel %B00, +eval, +output; + +set sel %B01, +eval, +output; + +set sel %B10, +eval, +output; + +set sel %B11, +eval, +output; + +set in 1, +set sel %B00, +eval, +output; + +set sel %B01, +eval, +output; + +set sel %B10, +eval, +output; + +set sel %B11, +eval, +output; diff --git a/projects/01/DMux8Way.cmp b/projects/01/DMux8Way.cmp new file mode 100755 index 0000000..375d44a --- /dev/null +++ b/projects/01/DMux8Way.cmp @@ -0,0 +1,17 @@ +| in | sel | a | b | c | d | e | f | g | h | +| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | +| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | +| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | +| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | +| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | +| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | diff --git a/projects/01/DMux8Way.hdl b/projects/01/DMux8Way.hdl new file mode 100755 index 0000000..04d82ca --- /dev/null +++ b/projects/01/DMux8Way.hdl @@ -0,0 +1,47 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux8Way.hdl + +/** + * 8-way demultiplexor: + * {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000 + * {0, in, 0, 0, 0, 0, 0, 0} if sel == 001 + * etc. + * {0, 0, 0, 0, 0, 0, 0, in} if sel == 111 + */ + +CHIP DMux8Way { + IN in, sel[3]; + OUT a, b, c, d, e, f, g, h; + + PARTS: + Not(in=sel[0],out=notsel0); + Not(in=sel[1],out=notsel1); + Not(in=sel[2],out=notsel2); + + And(a=notsel2,b=notsel1,out=out1); + And(a=out1,b=notsel0,out=outA); + And(a=out1,b=sel[0],out=outB); + + And(a=notsel2,b=sel[1],out=out2); + And(a=out2,b=notsel0,out=outC); + And(a=out2,b=sel[0],out=outD); + + And(a=sel[2],b=notsel1,out=out3); + And(a=out3,b=notsel0,out=outE); + And(a=out3,b=sel[0],out=outF); + + And(a=sel[2],b=sel[1],out=out4); + And(a=out4,b=notsel0,out=outG); + And(a=out4,b=sel[0],out=outH); + + And(a=in,b=outA,out=a); + And(a=in,b=outB,out=b); + And(a=in,b=outC,out=c); + And(a=in,b=outD,out=d); + And(a=in,b=outE,out=e); + And(a=in,b=outF,out=f); + And(a=in,b=outG,out=g); + And(a=in,b=outH,out=h); +} \ No newline at end of file diff --git a/projects/01/DMux8Way.out b/projects/01/DMux8Way.out new file mode 100755 index 0000000..375d44a --- /dev/null +++ b/projects/01/DMux8Way.out @@ -0,0 +1,17 @@ +| in | sel | a | b | c | d | e | f | g | h | +| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | +| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | +| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | +| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | +| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | +| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | diff --git a/projects/01/DMux8Way.tst b/projects/01/DMux8Way.tst new file mode 100755 index 0000000..56d827e --- /dev/null +++ b/projects/01/DMux8Way.tst @@ -0,0 +1,75 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux8Way.tst + +load DMux8Way.hdl, +output-file DMux8Way.out, +compare-to DMux8Way.cmp, +output-list in%B2.1.2 sel%B2.3.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2 e%B2.1.2 f%B2.1.2 g%B2.1.2 h%B2.1.2; + +set in 0, +set sel %B000, +eval, +output; + +set sel %B001, +eval, +output; + +set sel %B010, +eval, +output; + +set sel %B011, +eval, +output; + +set sel %B100, +eval, +output; + +set sel %B101, +eval, +output; + +set sel %B110, +eval, +output; + +set sel %B111, +eval, +output; + +set in 1, +set sel %B000, +eval, +output; + +set sel %B001, +eval, +output; + +set sel %B010, +eval, +output; + +set sel %B011, +eval, +output; + +set sel %B100, +eval, +output; + +set sel %B101, +eval, +output; + +set sel %B110, +eval, +output; + +set sel %B111, +eval, +output; diff --git a/projects/01/Mux.cmp b/projects/01/Mux.cmp new file mode 100755 index 0000000..7a5cc5b --- /dev/null +++ b/projects/01/Mux.cmp @@ -0,0 +1,9 @@ +| a | b | sel | out | +| 0 | 0 | 0 | 0 | +| 0 | 0 | 1 | 0 | +| 0 | 1 | 0 | 0 | +| 0 | 1 | 1 | 1 | +| 1 | 0 | 0 | 1 | +| 1 | 0 | 1 | 0 | +| 1 | 1 | 0 | 1 | +| 1 | 1 | 1 | 1 | diff --git a/projects/01/Mux.hdl b/projects/01/Mux.hdl new file mode 100755 index 0000000..1afeb7b --- /dev/null +++ b/projects/01/Mux.hdl @@ -0,0 +1,17 @@ + +/** + * Multiplexor: + * out = a if sel == 0 + * b otherwise + */ + +CHIP Mux { + IN a, b, sel; + OUT out; + + PARTS: + Not(in=sel,out=notsel); + And(a=a,b=notsel,out=out1); + And(a=b,b=sel,out=out2); + Or(a=out1,b=out2,out=out); +} \ No newline at end of file diff --git a/projects/01/Mux.out b/projects/01/Mux.out new file mode 100755 index 0000000..7a5cc5b --- /dev/null +++ b/projects/01/Mux.out @@ -0,0 +1,9 @@ +| a | b | sel | out | +| 0 | 0 | 0 | 0 | +| 0 | 0 | 1 | 0 | +| 0 | 1 | 0 | 0 | +| 0 | 1 | 1 | 1 | +| 1 | 0 | 0 | 1 | +| 1 | 0 | 1 | 0 | +| 1 | 1 | 0 | 1 | +| 1 | 1 | 1 | 1 | diff --git a/projects/01/Mux.tst b/projects/01/Mux.tst new file mode 100755 index 0000000..9b7afd9 --- /dev/null +++ b/projects/01/Mux.tst @@ -0,0 +1,49 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux.tst + +load Mux.hdl, +output-file Mux.out, +compare-to Mux.cmp, +output-list a%B3.1.3 b%B3.1.3 sel%B3.1.3 out%B3.1.3; + +set a 0, +set b 0, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set a 0, +set b 1, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set a 1, +set b 0, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set a 1, +set b 1, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; diff --git a/projects/01/Mux16.cmp b/projects/01/Mux16.cmp new file mode 100755 index 0000000..661ee67 --- /dev/null +++ b/projects/01/Mux16.cmp @@ -0,0 +1,9 @@ +| a | b | sel | out | +| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 | +| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 | +| 0000000000000000 | 0001001000110100 | 1 | 0001001000110100 | +| 1001100001110110 | 0000000000000000 | 0 | 1001100001110110 | +| 1001100001110110 | 0000000000000000 | 1 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | 0 | 1010101010101010 | +| 1010101010101010 | 0101010101010101 | 1 | 0101010101010101 | diff --git a/projects/01/Mux16.hdl b/projects/01/Mux16.hdl new file mode 100755 index 0000000..21b0184 --- /dev/null +++ b/projects/01/Mux16.hdl @@ -0,0 +1,34 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Mux16.hdl + +/** + * 16-bit multiplexor: + * for i = 1..15 out[i] = a[i] if sel == 1 + * b[i] if sel == 1 + */ + +CHIP Mux16 { + IN a[16], b[16], sel; + OUT out[16]; + + PARTS: + Mux(a=a[0],b=b[0],sel=sel,out=out[0]); + Mux(a=a[1],b=b[1],sel=sel,out=out[1]); + Mux(a=a[2],b=b[2],sel=sel,out=out[2]); + Mux(a=a[3],b=b[3],sel=sel,out=out[3]); + Mux(a=a[4],b=b[4],sel=sel,out=out[4]); + Mux(a=a[5],b=b[5],sel=sel,out=out[5]); + Mux(a=a[6],b=b[6],sel=sel,out=out[6]); + Mux(a=a[7],b=b[7],sel=sel,out=out[7]); + Mux(a=a[8],b=b[8],sel=sel,out=out[8]); + Mux(a=a[9],b=b[9],sel=sel,out=out[9]); + Mux(a=a[10],b=b[10],sel=sel,out=out[10]); + Mux(a=a[11],b=b[11],sel=sel,out=out[11]); + Mux(a=a[12],b=b[12],sel=sel,out=out[12]); + Mux(a=a[13],b=b[13],sel=sel,out=out[13]); + Mux(a=a[14],b=b[14],sel=sel,out=out[14]); + Mux(a=a[15],b=b[15],sel=sel,out=out[15]); + +} \ No newline at end of file diff --git a/projects/01/Mux16.out b/projects/01/Mux16.out new file mode 100755 index 0000000..661ee67 --- /dev/null +++ b/projects/01/Mux16.out @@ -0,0 +1,9 @@ +| a | b | sel | out | +| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 | +| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 | +| 0000000000000000 | 0001001000110100 | 1 | 0001001000110100 | +| 1001100001110110 | 0000000000000000 | 0 | 1001100001110110 | +| 1001100001110110 | 0000000000000000 | 1 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | 0 | 1010101010101010 | +| 1010101010101010 | 0101010101010101 | 1 | 0101010101010101 | diff --git a/projects/01/Mux16.tst b/projects/01/Mux16.tst new file mode 100755 index 0000000..cf34155 --- /dev/null +++ b/projects/01/Mux16.tst @@ -0,0 +1,49 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux16.tst + +load Mux16.hdl, +output-file Mux16.out, +compare-to Mux16.cmp, +output-list a%B1.16.1 b%B1.16.1 sel%D2.1.2 out%B1.16.1; + +set a 0, +set b 0, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set a %B0000000000000000, +set b %B0001001000110100, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set a %B1001100001110110, +set b %B0000000000000000, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set a %B1010101010101010, +set b %B0101010101010101, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; \ No newline at end of file diff --git a/projects/01/Mux4Way.hdl b/projects/01/Mux4Way.hdl new file mode 100755 index 0000000..fca2c16 --- /dev/null +++ b/projects/01/Mux4Way.hdl @@ -0,0 +1,21 @@ +CHIP Mux4Way { + IN a, b, c, d, sel0, sel1; + OUT out; + + PARTS: + Not(in=sel0,out=notsel0); + Not(in=sel1,out=notsel1); + + And(a=notsel0,b=notsel1,out=outA); + And(a=sel0,b=notsel1,out=outB); + And(a=notsel0,b=sel1,out=outC); + And(a=sel0,b=sel1,out=outD); + + And(a=outA,b=a,out=outA1); + And(a=outB,b=b,out=outB1); + And(a=outC,b=c,out=outC1); + And(a=outD,b=d,out=outD1); + Or(a=outA1,b=outB1,out=out1); + Or(a=outC1,b=outD1,out=out2); + Or(a=out1,b=out2,out=out); +} \ No newline at end of file diff --git a/projects/01/Mux4Way16.cmp b/projects/01/Mux4Way16.cmp new file mode 100755 index 0000000..8704e79 --- /dev/null +++ b/projects/01/Mux4Way16.cmp @@ -0,0 +1,9 @@ +| a | b | c | d | sel | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 00 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 01 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 10 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 11 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 00 | 0001001000110100 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 1001100001110110 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 1010101010101010 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0101010101010101 | diff --git a/projects/01/Mux4Way16.hdl b/projects/01/Mux4Way16.hdl new file mode 100755 index 0000000..64fbffc --- /dev/null +++ b/projects/01/Mux4Way16.hdl @@ -0,0 +1,38 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux4Way16.hdl + +/** + * 4-way 16-bit multiplexor: + * out = a if sel == 00 + * b if sel == 01 + * c if sel == 10 + * d if sel == 11 + */ + +CHIP Mux4Way16 { + IN a[16], b[16], c[16], d[16], sel[2]; + OUT out[16]; + + PARTS: + + Mux4Way(a=a[0],b=b[0],c=c[0],d=d[0],sel0=sel[0],sel1=sel[1],out=out[0]); + Mux4Way(a=a[1],b=b[1],c=c[1],d=d[1],sel0=sel[0],sel1=sel[1],out=out[1]); + Mux4Way(a=a[2],b=b[2],c=c[2],d=d[2],sel0=sel[0],sel1=sel[1],out=out[2]); + Mux4Way(a=a[3],b=b[3],c=c[3],d=d[3],sel0=sel[0],sel1=sel[1],out=out[3]); + Mux4Way(a=a[4],b=b[4],c=c[4],d=d[4],sel0=sel[0],sel1=sel[1],out=out[4]); + Mux4Way(a=a[5],b=b[5],c=c[5],d=d[5],sel0=sel[0],sel1=sel[1],out=out[5]); + Mux4Way(a=a[6],b=b[6],c=c[6],d=d[6],sel0=sel[0],sel1=sel[1],out=out[6]); + Mux4Way(a=a[7],b=b[7],c=c[7],d=d[7],sel0=sel[0],sel1=sel[1],out=out[7]); + Mux4Way(a=a[8],b=b[8],c=c[8],d=d[8],sel0=sel[0],sel1=sel[1],out=out[8]); + Mux4Way(a=a[9],b=b[9],c=c[9],d=d[9],sel0=sel[0],sel1=sel[1],out=out[9]); + + Mux4Way(a=a[10],b=b[10],c=c[10],d=d[10],sel0=sel[0],sel1=sel[1],out=out[10]); + Mux4Way(a=a[11],b=b[11],c=c[11],d=d[11],sel0=sel[0],sel1=sel[1],out=out[11]); + Mux4Way(a=a[12],b=b[12],c=c[12],d=d[12],sel0=sel[0],sel1=sel[1],out=out[12]); + Mux4Way(a=a[13],b=b[13],c=c[13],d=d[13],sel0=sel[0],sel1=sel[1],out=out[13]); + Mux4Way(a=a[14],b=b[14],c=c[14],d=d[14],sel0=sel[0],sel1=sel[1],out=out[14]); + Mux4Way(a=a[15],b=b[15],c=c[15],d=d[15],sel0=sel[0],sel1=sel[1],out=out[15]); + +} \ No newline at end of file diff --git a/projects/01/Mux4Way16.out b/projects/01/Mux4Way16.out new file mode 100755 index 0000000..8704e79 --- /dev/null +++ b/projects/01/Mux4Way16.out @@ -0,0 +1,9 @@ +| a | b | c | d | sel | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 00 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 01 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 10 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 11 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 00 | 0001001000110100 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 1001100001110110 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 1010101010101010 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0101010101010101 | diff --git a/projects/01/Mux4Way16.tst b/projects/01/Mux4Way16.tst new file mode 100755 index 0000000..3f4efa3 --- /dev/null +++ b/projects/01/Mux4Way16.tst @@ -0,0 +1,49 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux4Way16.tst + +load Mux4Way16.hdl, +output-file Mux4Way16.out, +compare-to Mux4Way16.cmp, +output-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 sel%B2.2.2 out%B1.16.1; + +set a 0, +set b 0, +set c 0, +set d 0, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set sel 2, +eval, +output; + +set sel 3, +eval, +output; + +set a %B0001001000110100, +set b %B1001100001110110, +set c %B1010101010101010, +set d %B0101010101010101, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set sel 2, +eval, +output; + +set sel 3, +eval, +output; diff --git a/projects/01/Mux8Way.hdl b/projects/01/Mux8Way.hdl new file mode 100755 index 0000000..00816be --- /dev/null +++ b/projects/01/Mux8Way.hdl @@ -0,0 +1,41 @@ +CHIP Mux8Way { + IN a, b, c, d, e, f, g, h, sel0, sel1, sel2; + OUT out; + + PARTS: + Not(in=sel0,out=notsel0); + Not(in=sel1,out=notsel1); + Not(in=sel2,out=notsel2); + + + And(a=notsel0,b=notsel1,out=outA); + And(a=notsel0,b=sel2,out=outC); + And(a=sel0,b=notsel1,out=outE); + And(a=sel0,b=sel1,out=outG); + + And(a=outA,b=notsel2,out=outA1); + And(a=outC,b=notsel2,out=outC1); + And(a=outE,b=notsel2,out=outE1); + And(a=outG,b=notsel2,out=outG1); + And(a=outA,b=sel2,out=outB1); + And(a=outG,b=sel2,out=outH1); + And(a=outC,b=sel2,out=outD1); + And(a=outE,b=sel2,out=outF1); + + And(a=outA1,b=a,out=outA2); + And(a=outB1,b=b,out=outB2); + And(a=outC1,b=c,out=outC2); + And(a=outD1,b=d,out=outD2); + And(a=outE1,b=e,out=outE2); + And(a=outF1,b=f,out=outF2); + And(a=outG1,b=g,out=outG2); + And(a=outH1,b=h,out=outH2); + + Or(a=outA2,b=outB2,out=out1); + Or(a=outC2,b=outD2,out=out2); + Or(a=outE2,b=outF2,out=out4); + Or(a=outG2,b=outH2,out=out5); + Or(a=out4,b=out5,out=out6); + Or(a=out1,b=out2,out=out3); + Or(a=out3,b=out6,out=out); +} diff --git a/projects/01/Mux8Way16.cmp b/projects/01/Mux8Way16.cmp new file mode 100755 index 0000000..1484e0a --- /dev/null +++ b/projects/01/Mux8Way16.cmp @@ -0,0 +1,17 @@ +| a | b | c | d | e | f | g | h | sel | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 000 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 001 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 010 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 011 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 100 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 101 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 110 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 111 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 000 | 0001001000110100 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 001 | 0010001101000101 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 010 | 0011010001010110 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 011 | 0100010101100111 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 100 | 0101011001111000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 101 | 0110011110001001 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 110 | 0111100010011010 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 111 | 1000100110101011 | diff --git a/projects/01/Mux8Way16.hdl b/projects/01/Mux8Way16.hdl new file mode 100755 index 0000000..960aa7d --- /dev/null +++ b/projects/01/Mux8Way16.hdl @@ -0,0 +1,38 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux8Way16.hdl + +/** + * 8-way 16-bit multiplexor: + * out = a if sel == 000 + * b if sel == 001 + * etc. + * h if sel == 111 + */ + +CHIP Mux8Way16 { + IN a[16], b[16], c[16], d[16], + e[16], f[16], g[16], h[16], + sel[3]; + OUT out[16]; + + PARTS: + Mux8Way(a=a[0],b=b[0],c=c[0],d=d[0],e=e[0],f=f[0],g=g[0],h=h[0],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[0]); + Mux8Way(a=a[1],b=b[1],c=c[1],d=d[1],e=e[1],f=f[1],g=g[1],h=h[1],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[1]); + Mux8Way(a=a[2],b=b[2],c=c[2],d=d[2],e=e[2],f=f[2],g=g[2],h=h[2],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[2]); + Mux8Way(a=a[3],b=b[3],c=c[3],d=d[3],e=e[3],f=f[3],g=g[3],h=h[3],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[3]); + Mux8Way(a=a[4],b=b[4],c=c[4],d=d[4],e=e[4],f=f[4],g=g[4],h=h[4],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[4]); + Mux8Way(a=a[5],b=b[5],c=c[5],d=d[5],e=e[5],f=f[5],g=g[5],h=h[5],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[5]); + Mux8Way(a=a[6],b=b[6],c=c[6],d=d[6],e=e[6],f=f[6],g=g[6],h=h[6],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[6]); + Mux8Way(a=a[7],b=b[7],c=c[7],d=d[7],e=e[7],f=f[7],g=g[7],h=h[7],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[7]); + Mux8Way(a=a[8],b=b[8],c=c[8],d=d[8],e=e[8],f=f[8],g=g[8],h=h[8],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[8]); + Mux8Way(a=a[9],b=b[9],c=c[9],d=d[9],e=e[9],f=f[9],g=g[9],h=h[9],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[9]); + + Mux8Way(a=a[11],b=b[11],c=c[11],d=d[11],e=e[11],f=f[11],g=g[11],h=h[11],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[11]); + Mux8Way(a=a[12],b=b[12],c=c[12],d=d[12],e=e[12],f=f[12],g=g[12],h=h[12],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[12]); + Mux8Way(a=a[14],b=b[14],c=c[14],d=d[14],e=e[14],f=f[14],g=g[14],h=h[14],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[14]); + Mux8Way(a=a[13],b=b[13],c=c[13],d=d[13],e=e[13],f=f[13],g=g[13],h=h[13],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[13]); + Mux8Way(a=a[15],b=b[15],c=c[15],d=d[15],e=e[15],f=f[15],g=g[15],h=h[15],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[15]); + Mux8Way(a=a[10],b=b[10],c=c[10],d=d[10],e=e[10],f=f[10],g=g[10],h=h[10],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[10]); +} \ No newline at end of file diff --git a/projects/01/Mux8Way16.tst b/projects/01/Mux8Way16.tst new file mode 100755 index 0000000..59bb41c --- /dev/null +++ b/projects/01/Mux8Way16.tst @@ -0,0 +1,89 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux8Way16.tst + +load Mux8Way16.hdl, +output-file Mux8Way16.out, +compare-to Mux8Way16.cmp, +output-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 e%B1.16.1 f%B1.16.1 g%B1.16.1 h%B1.16.1 sel%B2.3.2 out%B1.16.1; + +set a 0, +set b 0, +set c 0, +set d 0, +set e 0, +set f 0, +set g 0, +set h 0, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set sel 2, +eval, +output; + +set sel 3, +eval, +output; + +set sel 4, +eval, +output; + +set sel 5, +eval, +output; + +set sel 6, +eval, +output; + +set sel 7, +eval, +output; + +set a %B0001001000110100, +set b %B0010001101000101, +set c %B0011010001010110, +set d %B0100010101100111, +set e %B0101011001111000, +set f %B0110011110001001, +set g %B0111100010011010, +set h %B1000100110101011, +set sel 0, +eval, +output; + +set sel 1, +eval, +output; + +set sel 2, +eval, +output; + +set sel 3, +eval, +output; + +set sel 4, +eval, +output; + +set sel 5, +eval, +output; + +set sel 6, +eval, +output; + +set sel 7, +eval, +output; diff --git a/projects/01/Not.cmp b/projects/01/Not.cmp new file mode 100755 index 0000000..e8c1191 --- /dev/null +++ b/projects/01/Not.cmp @@ -0,0 +1,3 @@ +| in | out | +| 0 | 1 | +| 1 | 0 | diff --git a/projects/01/Not.hdl b/projects/01/Not.hdl new file mode 100755 index 0000000..5b75a10 --- /dev/null +++ b/projects/01/Not.hdl @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Not.hdl + +/** + * Not gate: + * out = not in + */ + +CHIP Not { + IN in; + OUT out; + + PARTS: + Nand(a=in,b=in,out=out); +} \ No newline at end of file diff --git a/projects/01/Not.out b/projects/01/Not.out new file mode 100755 index 0000000..e8c1191 --- /dev/null +++ b/projects/01/Not.out @@ -0,0 +1,3 @@ +| in | out | +| 0 | 1 | +| 1 | 0 | diff --git a/projects/01/Not.tst b/projects/01/Not.tst new file mode 100755 index 0000000..1e3bbe7 --- /dev/null +++ b/projects/01/Not.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Not.tst + +load Not.hdl, +output-file Not.out, +compare-to Not.cmp, +output-list in%B3.1.3 out%B3.1.3; + +set in 0, +eval, +output; + +set in 1, +eval, +output; diff --git a/projects/01/Not16.cmp b/projects/01/Not16.cmp new file mode 100755 index 0000000..68a5512 --- /dev/null +++ b/projects/01/Not16.cmp @@ -0,0 +1,6 @@ +| in | out | +| 0000000000000000 | 1111111111111111 | +| 1111111111111111 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | +| 0011110011000011 | 1100001100111100 | +| 0001001000110100 | 1110110111001011 | diff --git a/projects/01/Not16.hdl b/projects/01/Not16.hdl new file mode 100755 index 0000000..88fb6b6 --- /dev/null +++ b/projects/01/Not16.hdl @@ -0,0 +1,33 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Not16.hdl + +/** + * 16-bit Not: + * for i=0..15: out[i] = not in[i] + */ + +CHIP Not16 { + IN in[16]; + OUT out[16]; + + PARTS: + Not(in=in[0],out=out[0]); + Not(in=in[1],out=out[1]); + Not(in=in[2],out=out[2]); + Not(in=in[3],out=out[3]); + Not(in=in[4],out=out[4]); + Not(in=in[5],out=out[5]); + Not(in=in[6],out=out[6]); + Not(in=in[7],out=out[7]); + Not(in=in[8],out=out[8]); + Not(in=in[9],out=out[9]); + Not(in=in[10],out=out[10]); + Not(in=in[11],out=out[11]); + Not(in=in[12],out=out[12]); + Not(in=in[13],out=out[13]); + Not(in=in[14],out=out[14]); + Not(in=in[15],out=out[15]); + +} \ No newline at end of file diff --git a/projects/01/Not16.out b/projects/01/Not16.out new file mode 100755 index 0000000..68a5512 --- /dev/null +++ b/projects/01/Not16.out @@ -0,0 +1,6 @@ +| in | out | +| 0000000000000000 | 1111111111111111 | +| 1111111111111111 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | +| 0011110011000011 | 1100001100111100 | +| 0001001000110100 | 1110110111001011 | diff --git a/projects/01/Not16.tst b/projects/01/Not16.tst new file mode 100755 index 0000000..e7e2c3b --- /dev/null +++ b/projects/01/Not16.tst @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Not16.tst + +load Not16.hdl, +output-file Not16.out, +compare-to Not16.cmp, +output-list in%B1.16.1 out%B1.16.1; + +set in %B0000000000000000, +eval, +output; + +set in %B1111111111111111, +eval, +output; + +set in %B1010101010101010, +eval, +output; + +set in %B0011110011000011, +eval, +output; + +set in %B0001001000110100, +eval, +output; \ No newline at end of file diff --git a/projects/01/Or.cmp b/projects/01/Or.cmp new file mode 100755 index 0000000..dab924c --- /dev/null +++ b/projects/01/Or.cmp @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 1 | +| 1 | 0 | 1 | +| 1 | 1 | 1 | diff --git a/projects/01/Or.hdl b/projects/01/Or.hdl new file mode 100755 index 0000000..283c7d5 --- /dev/null +++ b/projects/01/Or.hdl @@ -0,0 +1,9 @@ +CHIP Or { + IN a, b; + OUT out; + + PARTS: + Not(in=a,out=nota); + Not(in=b,out=notb); + Nand(a=nota,b=notb,out=out); +} diff --git a/projects/01/Or.out b/projects/01/Or.out new file mode 100755 index 0000000..e69de29 diff --git a/projects/01/Or.tst b/projects/01/Or.tst new file mode 100755 index 0000000..948b6b3 --- /dev/null +++ b/projects/01/Or.tst @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or.tst + +load Or.hdl, +output-file Or.out, +compare-to Or.cmp, +output-list a%B3.1.3 b%B3.1.3 out%B3.1.3; + +set a 0, +set b 0, +eval, +output; + +set a 0, +set b 1, +eval, +output; + +set a 1, +set b 0, +eval, +output; + +set a 1, +set b 1, +eval, +output; diff --git a/projects/01/Or16.cmp b/projects/01/Or16.cmp new file mode 100755 index 0000000..e2c3a30 --- /dev/null +++ b/projects/01/Or16.cmp @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1111111111111111 | +| 1111111111111111 | 1111111111111111 | 1111111111111111 | +| 1010101010101010 | 0101010101010101 | 1111111111111111 | +| 0011110011000011 | 0000111111110000 | 0011111111110011 | +| 0001001000110100 | 1001100001110110 | 1001101001110110 | diff --git a/projects/01/Or16.hdl b/projects/01/Or16.hdl new file mode 100755 index 0000000..7708c5b --- /dev/null +++ b/projects/01/Or16.hdl @@ -0,0 +1,33 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Or16.hdl + +/** + * 16-bit bitwise Or: + * for i = 1..15 out[i] = (a[i] or b[i]) + */ + +CHIP Or16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + Or(a=a[0],b=b[0],out=out[0]); + Or(a=a[1],b=b[1],out=out[1]); + Or(a=a[2],b=b[2],out=out[2]); + Or(a=a[3],b=b[3],out=out[3]); + Or(a=a[4],b=b[4],out=out[4]); + Or(a=a[5],b=b[5],out=out[5]); + Or(a=a[6],b=b[6],out=out[6]); + Or(a=a[7],b=b[7],out=out[7]); + Or(a=a[8],b=b[8],out=out[8]); + Or(a=a[9],b=b[9],out=out[9]); + Or(a=a[10],b=b[10],out=out[10]); + Or(a=a[11],b=b[11],out=out[11]); + Or(a=a[12],b=b[12],out=out[12]); + Or(a=a[13],b=b[13],out=out[13]); + Or(a=a[14],b=b[14],out=out[14]); + Or(a=a[15],b=b[15],out=out[15]); + +} \ No newline at end of file diff --git a/projects/01/Or16.out b/projects/01/Or16.out new file mode 100755 index 0000000..e2c3a30 --- /dev/null +++ b/projects/01/Or16.out @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1111111111111111 | +| 1111111111111111 | 1111111111111111 | 1111111111111111 | +| 1010101010101010 | 0101010101010101 | 1111111111111111 | +| 0011110011000011 | 0000111111110000 | 0011111111110011 | +| 0001001000110100 | 1001100001110110 | 1001101001110110 | diff --git a/projects/01/Or16.tst b/projects/01/Or16.tst new file mode 100755 index 0000000..ea7b944 --- /dev/null +++ b/projects/01/Or16.tst @@ -0,0 +1,39 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or16.tst + +load Or16.hdl, +output-file Or16.out, +compare-to Or16.cmp, +output-list a%B1.16.1 b%B1.16.1 out%B1.16.1; + +set a %B0000000000000000, +set b %B0000000000000000, +eval, +output; + +set a %B0000000000000000, +set b %B1111111111111111, +eval, +output; + +set a %B1111111111111111, +set b %B1111111111111111, +eval, +output; + +set a %B1010101010101010, +set b %B0101010101010101, +eval, +output; + +set a %B0011110011000011, +set b %B0000111111110000, +eval, +output; + +set a %B0001001000110100, +set b %B1001100001110110, +eval, +output; \ No newline at end of file diff --git a/projects/01/Or8Way.cmp b/projects/01/Or8Way.cmp new file mode 100755 index 0000000..3f9fd54 --- /dev/null +++ b/projects/01/Or8Way.cmp @@ -0,0 +1,6 @@ +| in | out | +| 00000000 | 0 | +| 11111111 | 1 | +| 00010000 | 1 | +| 00000001 | 1 | +| 00100110 | 1 | diff --git a/projects/01/Or8Way.hdl b/projects/01/Or8Way.hdl new file mode 100755 index 0000000..667b506 --- /dev/null +++ b/projects/01/Or8Way.hdl @@ -0,0 +1,25 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or8Way.hdl + +/** + * 8-way Or: + * out = (in[0] or in[1] or ... or in[7]) + */ + +CHIP Or8Way { + IN in[8]; + OUT out; + + PARTS: + Or(a=in[0],b=in[1],out=out1); + Or(a=out1,b=in[2],out=out2); + Or(a=out2,b=in[3],out=out3); + Or(a=out3,b=in[4],out=out4); + Or(a=out4,b=in[5],out=out5); + Or(a=out5,b=in[6],out=out6); + Or(a=out6,b=in[7],out=out); + + +} \ No newline at end of file diff --git a/projects/01/Or8Way.out b/projects/01/Or8Way.out new file mode 100755 index 0000000..3f9fd54 --- /dev/null +++ b/projects/01/Or8Way.out @@ -0,0 +1,6 @@ +| in | out | +| 00000000 | 0 | +| 11111111 | 1 | +| 00010000 | 1 | +| 00000001 | 1 | +| 00100110 | 1 | diff --git a/projects/01/Or8Way.tst b/projects/01/Or8Way.tst new file mode 100755 index 0000000..e6fbba7 --- /dev/null +++ b/projects/01/Or8Way.tst @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or8Way.tst + +load Or8Way.hdl, +output-file Or8Way.out, +compare-to Or8Way.cmp, +output-list in%B2.8.2 out%B2.1.2; + +set in %B00000000, +eval, +output; + +set in %B11111111, +eval, +output; + +set in %B00010000, +eval, +output; + +set in %B00000001, +eval, +output; + +set in %B00100110, +eval, +output; \ No newline at end of file diff --git a/projects/01/Xor.cmp b/projects/01/Xor.cmp new file mode 100755 index 0000000..a1e07b2 --- /dev/null +++ b/projects/01/Xor.cmp @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 1 | +| 1 | 0 | 1 | +| 1 | 1 | 0 | diff --git a/projects/01/Xor.hdl b/projects/01/Xor.hdl new file mode 100755 index 0000000..af58d40 --- /dev/null +++ b/projects/01/Xor.hdl @@ -0,0 +1,11 @@ +CHIP Xor { + IN a, b; + OUT out; + + PARTS: + Not(in=a,out=nota); + Not(in=b,out=notb); + And(a=a,b=notb,out=aAndnotb); + And(a=nota,b=b,out=notaAndb); + Or(a=aAndnotb,b=notaAndb,out=out); +} \ No newline at end of file diff --git a/projects/01/Xor.out b/projects/01/Xor.out new file mode 100755 index 0000000..a1e07b2 --- /dev/null +++ b/projects/01/Xor.out @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 1 | +| 1 | 0 | 1 | +| 1 | 1 | 0 | diff --git a/projects/01/Xor.tst b/projects/01/Xor.tst new file mode 100755 index 0000000..cd93be4 --- /dev/null +++ b/projects/01/Xor.tst @@ -0,0 +1,14 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Xor.tst + +load Xor.hdl, +output-file Xor.out, +compare-to Xor.cmp, +output-list a%B3.1.3 b%B3.1.3 out%B3.1.3; + +set a 0,set b 0,eval,output; +set a 0,set b 1,eval,output; +set a 1,set b 0,eval,output; +set a 1,set b 1,eval,output; diff --git a/projects/02/ALU-nostat.cmp b/projects/02/ALU-nostat.cmp new file mode 100755 index 0000000..976ab78 --- /dev/null +++ b/projects/02/ALU-nostat.cmp @@ -0,0 +1,37 @@ +| x | y |zx |nx |zy |ny | f |no | out | +| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 | +| 0101101110100000 | 0001111011010010 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 0 | 0101101110100000 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 0 | 0001111011010010 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 1 | 1010010001011111 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 1 | 1110000100101101 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 1 | 1010010001100000 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 1 | 1110000100101110 | +| 0101101110100000 | 0001111011010010 | 0 | 1 | 1 | 1 | 1 | 1 | 0101101110100001 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 1 | 1 | 1 | 0001111011010011 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 0 | 0101101110011111 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 0 | 0001111011010001 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 1 | 0 | 0111101001110010 | +| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 0 | 1 | 1 | 0011110011001110 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 1 | 1 | 1 | 1100001100110010 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 0 | 0 | 0001101010000000 | +| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 1 | 0 | 1 | 0101111111110010 | diff --git a/projects/02/ALU-nostat.out b/projects/02/ALU-nostat.out new file mode 100755 index 0000000..976ab78 --- /dev/null +++ b/projects/02/ALU-nostat.out @@ -0,0 +1,37 @@ +| x | y |zx |nx |zy |ny | f |no | out | +| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 | +| 0101101110100000 | 0001111011010010 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 0 | 0101101110100000 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 0 | 0001111011010010 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 0 | 1 | 1010010001011111 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 0 | 1 | 1110000100101101 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 1 | 1010010001100000 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 1 | 1110000100101110 | +| 0101101110100000 | 0001111011010010 | 0 | 1 | 1 | 1 | 1 | 1 | 0101101110100001 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 1 | 1 | 1 | 0001111011010011 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 1 | 1 | 1 | 0 | 0101101110011111 | +| 0101101110100000 | 0001111011010010 | 1 | 1 | 0 | 0 | 1 | 0 | 0001111011010001 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 1 | 0 | 0111101001110010 | +| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 0 | 1 | 1 | 0011110011001110 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 1 | 1 | 1 | 1100001100110010 | +| 0101101110100000 | 0001111011010010 | 0 | 0 | 0 | 0 | 0 | 0 | 0001101010000000 | +| 0101101110100000 | 0001111011010010 | 0 | 1 | 0 | 1 | 0 | 1 | 0101111111110010 | diff --git a/projects/02/ALU-nostat.tst b/projects/02/ALU-nostat.tst new file mode 100755 index 0000000..fa3e448 --- /dev/null +++ b/projects/02/ALU-nostat.tst @@ -0,0 +1,353 @@ +// This file is part of the materials accompanying the book +// "The Elements of Computing Systems" by Nisan and Schocken, +// MIT Press. Book site: www.idc.ac.il/tecs +// File name: projects/02/ALU-nostat.tst + +// ALU-nostat.tst provides a partial test of the ALU chip. +// It IS NOT a replacement for ALU.tst. + +// ALU-nostat.tst tests only the computation part of the ALU. +// The 'zr' and 'ng' status outputs are ignored. + +// This test lets you concentrate on getting the ALU computation right without the +// additional task of handling the status outputs. + +// Once your ALU passes ALU-nostat.tst you need to test it with ALU.tst. +// This way, any comparison failures during ALU.tst will be caused by errors in +// the handling of the 'zr' and 'ng' status outputs. + +load ALU.hdl, +output-file ALU-nostat.out, +compare-to ALU-nostat.cmp, +output-list x%B1.16.1 y%B1.16.1 zx%B1.1.1 nx%B1.1.1 zy%B1.1.1 + ny%B1.1.1 f%B1.1.1 no%B1.1.1 out%B1.16.1; + +set x %B0000000000000000, +set y %B1111111111111111, + +set zx 1, +set nx 0, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 1, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 0, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 0, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 0, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +set zx 0, +set nx 1, +set zy 0, +set ny 1, +set f 0, +set no 1, +eval, +output; + +set x %B101101110100000, +set y %B001111011010010, + +set zx 1, +set nx 0, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 1, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 0, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 0, +eval, +output; + +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +set zx 0, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +set zx 0, +set nx 1, +set zy 0, +set ny 1, +set f 0, +set no 1, +eval, +output; diff --git a/projects/02/ALU.cmp b/projects/02/ALU.cmp new file mode 100755 index 0000000..2ec3a55 --- /dev/null +++ b/projects/02/ALU.cmp @@ -0,0 +1,37 @@ +| x | y |zx |nx |zy |ny | f |no | out |zr |ng | +| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000010001 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 0 | 0000000000000011 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111101110 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 1 | 1111111111111100 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 1 | 1111111111101111 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 1 | 1111111111111101 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000010010 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000100 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 0 | 0000000000010000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 0 | 0000000000000010 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 1 | 0 | 0000000000010100 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000001110 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111110010 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000001 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 1 | 0 | 1 | 0000000000010011 | 0 | 0 | diff --git a/projects/02/ALU.hdl b/projects/02/ALU.hdl new file mode 100755 index 0000000..856ebf4 --- /dev/null +++ b/projects/02/ALU.hdl @@ -0,0 +1,66 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/ALU.hdl + +/** + * The ALU (Arithmetic Logic Unit). + * Computes one of the following functions: + * x+y, x-y, y-x, 0, 1, -1, x, y, -x, -y, !x, !y, + * x+1, y+1, x-1, y-1, x&y, x|y on two 16-bit inputs, + * according to 6 input bits denoted zx,nx,zy,ny,f,no. + * In addition, the ALU computes two 1-bit outputs: + * if the ALU output == 0, zr is set to 1; otherwise zr is set to 0; + * if the ALU output < 0, ng is set to 1; otherwise ng is set to 0. + */ + +// Implementation: the ALU logic manipulates the x and y inputs +// and operates on the resulting values, as follows: +// if (zx == 1) set x = 0 // 16-bit constant +// if (nx == 1) set x = !x // bitwise not +// if (zy == 1) set y = 0 // 16-bit constant +// if (ny == 1) set y = !y // bitwise not +// if (f == 1) set out = x + y // integer 2's complement addition +// if (f == 0) set out = x & y // bitwise and +// if (no == 1) set out = !out // bitwise not +// if (out == 0) set zr = 1 +// if (out < 0) set ng = 1 + +CHIP ALU { + IN + x[16], y[16], // 16-bit inputs + zx, // zero the x input? + nx, // negate the x input? + zy, // zero the y input? + ny, // negate the y input? + f, // compute out = x + y (if 1) or x & y (if 0) + no; // negate the out output? + + OUT + out[16], // 16-bit output + zr, // 1 if (out == 0), 0 otherwise + ng; // 1 if (out < 0), 0 otherwise + + PARTS: + Mux16(a=x,b[0..15]=false,sel=zx,out=outZx);//zx + + Mux16(a=y,b[0..15]=false,sel=zy,out=outZy);//zy + + + Not16(in=outZx,out=outNx1);//nx1 + Not16(in=outZy,out=outNy1);//ny1 + Mux16(a=outZx,b=outNx1,sel=nx,out=outNx);//nx + + Mux16(a=outZy,b=outNy1,sel=ny,out=outNy);//ny + + + Add16(a=outNx,b=outNy,out=outF1);//f1 + + And16(a=outNy,b=outNx,out=outF0);//f0 + + Mux16(a=outF0,b=outF1,sel=f,out=outF);//f + + Not16(in=outF,out=outNo1);//no + + Mux16(a=outF, b=outNo1, sel=no, out=out, out[15]=ng, out[0..7]=zr1, out[8..15]=zr2); + + + Or8Way(in=zr1,out=out2); + Or8Way(in=zr2,out=out3); + Not(in=out2,out=out4); + Not(in=out3,out=out5); + And(a=out4,b=out5,out=zr); + +} \ No newline at end of file diff --git a/projects/02/ALU.out b/projects/02/ALU.out new file mode 100755 index 0000000..2ec3a55 --- /dev/null +++ b/projects/02/ALU.out @@ -0,0 +1,37 @@ +| x | y |zx |nx |zy |ny | f |no | out |zr |ng | +| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 1111111111111110 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111111111 | 0 | 1 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 1111111111111111 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 0 | 1 | 0 | 1111111111111111 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000010001 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 0 | 0000000000000011 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 1 | 1111111111101110 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 1 | 1111111111111100 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 1 | 1111111111101111 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 1 | 1111111111111101 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000010010 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000100 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 0 | 0000000000010000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 0 | 0000000000000010 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 1 | 0 | 0000000000010100 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000001110 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 1 | 1 | 1 | 1111111111110010 | 0 | 1 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000001 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 1 | 0 | 1 | 0000000000010011 | 0 | 0 | diff --git a/projects/02/ALU.tst b/projects/02/ALU.tst new file mode 100755 index 0000000..9e665b0 --- /dev/null +++ b/projects/02/ALU.tst @@ -0,0 +1,377 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/ALU.tst + +load ALU.hdl, +output-file ALU.out, +compare-to ALU.cmp, +output-list x%B1.16.1 y%B1.16.1 zx%B1.1.1 nx%B1.1.1 zy%B1.1.1 + ny%B1.1.1 f%B1.1.1 no%B1.1.1 out%B1.16.1 zr%B1.1.1 + ng%B1.1.1; + +set x %B0000000000000000, // x = 0 +set y %B1111111111111111; // y = -1 + +// Compute 0 +set zx 1, +set nx 0, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute 1 +set zx 1, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute -1 +set zx 1, +set nx 1, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute x +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 0, +eval, +output; + +// Compute y +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +// Compute !x +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 1, +eval, +output; + +// Compute !y +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 1, +eval, +output; + +// Compute -x +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute -y +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +// Compute x + 1 +set zx 0, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute y + 1 +set zx 1, +set nx 1, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute x - 1 +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 0, +eval, +output; + +// Compute y - 1 +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute x + y +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute x - y +set zx 0, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +// Compute y - x +set zx 0, +set nx 0, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute x & y +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +// Compute x | y +set zx 0, +set nx 1, +set zy 0, +set ny 1, +set f 0, +set no 1, +eval, +output; + +set x %B000000000010001, // x = 17 +set y %B000000000000011; // y = 3 + +// Compute 0 +set zx 1, +set nx 0, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute 1 +set zx 1, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute -1 +set zx 1, +set nx 1, +set zy 1, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute x +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 0, +eval, +output; + +// Compute y +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +// Compute !x +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 0, +set no 1, +eval, +output; + +// Compute !y +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 0, +set no 1, +eval, +output; + +// Compute -x +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute -y +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +// Compute x + 1 +set zx 0, +set nx 1, +set zy 1, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute y + 1 +set zx 1, +set nx 1, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute x - 1 +set zx 0, +set nx 0, +set zy 1, +set ny 1, +set f 1, +set no 0, +eval, +output; + +// Compute y - 1 +set zx 1, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute x + y +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 1, +set no 0, +eval, +output; + +// Compute x - y +set zx 0, +set nx 1, +set zy 0, +set ny 0, +set f 1, +set no 1, +eval, +output; + +// Compute y - x +set zx 0, +set nx 0, +set zy 0, +set ny 1, +set f 1, +set no 1, +eval, +output; + +// Compute x & y +set zx 0, +set nx 0, +set zy 0, +set ny 0, +set f 0, +set no 0, +eval, +output; + +// Compute x | y +set zx 0, +set nx 1, +set zy 0, +set ny 1, +set f 0, +set no 1, +eval, +output; diff --git a/projects/02/Add16.cmp b/projects/02/Add16.cmp new file mode 100755 index 0000000..76d069c --- /dev/null +++ b/projects/02/Add16.cmp @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1111111111111111 | +| 1111111111111111 | 1111111111111111 | 1111111111111110 | +| 1010101010101010 | 0101010101010101 | 1111111111111111 | +| 0011110011000011 | 0000111111110000 | 0100110010110011 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | diff --git a/projects/02/Add16.hdl b/projects/02/Add16.hdl new file mode 100755 index 0000000..a33305e --- /dev/null +++ b/projects/02/Add16.hdl @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/Adder16.hdl + +/** + * Adds two 16-bit values. + * The most significant carry bit is ignored. + */ + +CHIP Add16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + HalfAdder(a=a[0], b=b[0], sum=out[0], carry=carry1); + FullAdder(a=a[1], b=b[1], c=carry1, sum=out[1], carry=carry2); + FullAdder(a=a[2], b=b[2], c=carry2, sum=out[2], carry=carry3); + FullAdder(a=a[3], b=b[3], c=carry3, sum=out[3], carry=carry4); + FullAdder(a=a[4], b=b[4], c=carry4, sum=out[4], carry=carry5); + FullAdder(a=a[5], b=b[5], c=carry5, sum=out[5], carry=carry6); + FullAdder(a=a[6], b=b[6], c=carry6, sum=out[6], carry=carry7); + FullAdder(a=a[7], b=b[7], c=carry7, sum=out[7], carry=carry8); + FullAdder(a=a[8], b=b[8], c=carry8, sum=out[8], carry=carry9); + FullAdder(a=a[9], b=b[9], c=carry9, sum=out[9], carry=carry10); + + FullAdder(a=a[10],b=b[10],c=carry10,sum=out[10],carry=carry11); + FullAdder(a=a[11],b=b[11],c=carry11,sum=out[11],carry=carry12); + FullAdder(a=a[12],b=b[12],c=carry12,sum=out[12],carry=carry13); + FullAdder(a=a[13],b=b[13],c=carry13,sum=out[13],carry=carry14); + FullAdder(a=a[14],b=b[14],c=carry14,sum=out[14],carry=carry15); + FullAdder(a=a[15],b=b[15],c=carry15,sum=out[15],carry=carry16); + + +} \ No newline at end of file diff --git a/projects/02/Add16.out b/projects/02/Add16.out new file mode 100755 index 0000000..76d069c --- /dev/null +++ b/projects/02/Add16.out @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 1111111111111111 | +| 1111111111111111 | 1111111111111111 | 1111111111111110 | +| 1010101010101010 | 0101010101010101 | 1111111111111111 | +| 0011110011000011 | 0000111111110000 | 0100110010110011 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | diff --git a/projects/02/Add16.tst b/projects/02/Add16.tst new file mode 100755 index 0000000..85e1be1 --- /dev/null +++ b/projects/02/Add16.tst @@ -0,0 +1,39 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/Add16.tst + +load Add16.hdl, +output-file Add16.out, +compare-to Add16.cmp, +output-list a%B1.16.1 b%B1.16.1 out%B1.16.1; + +set a %B0000000000000000, +set b %B0000000000000000, +eval, +output; + +set a %B0000000000000000, +set b %B1111111111111111, +eval, +output; + +set a %B1111111111111111, +set b %B1111111111111111, +eval, +output; + +set a %B1010101010101010, +set b %B0101010101010101, +eval, +output; + +set a %B0011110011000011, +set b %B0000111111110000, +eval, +output; + +set a %B0001001000110100, +set b %B1001100001110110, +eval, +output; diff --git a/projects/02/FullAdder.cmp b/projects/02/FullAdder.cmp new file mode 100755 index 0000000..84551aa --- /dev/null +++ b/projects/02/FullAdder.cmp @@ -0,0 +1,9 @@ +| a | b | c | sum | carry | +| 0 | 0 | 0 | 0 | 0 | +| 0 | 0 | 1 | 1 | 0 | +| 0 | 1 | 0 | 1 | 0 | +| 0 | 1 | 1 | 0 | 1 | +| 1 | 0 | 0 | 1 | 0 | +| 1 | 0 | 1 | 0 | 1 | +| 1 | 1 | 0 | 0 | 1 | +| 1 | 1 | 1 | 1 | 1 | diff --git a/projects/02/FullAdder.hdl b/projects/02/FullAdder.hdl new file mode 100755 index 0000000..e87e8a7 --- /dev/null +++ b/projects/02/FullAdder.hdl @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/FullAdder.hdl + +/** + * Computes the sum of three bits. + */ + +CHIP FullAdder { + IN a, b, c; // 1-bit inputs + OUT sum, // Right bit of a + b + c + carry; // Left bit of a + b + c + + PARTS: + HalfAdder(a=b,b=c,sum=sum1,carry=carry1); + HalfAdder(a=a,b=sum1,sum=sum,carry=carry2); + Or(a=carry1,b=carry2,out=carry); + +} \ No newline at end of file diff --git a/projects/02/FullAdder.out b/projects/02/FullAdder.out new file mode 100755 index 0000000..84551aa --- /dev/null +++ b/projects/02/FullAdder.out @@ -0,0 +1,9 @@ +| a | b | c | sum | carry | +| 0 | 0 | 0 | 0 | 0 | +| 0 | 0 | 1 | 1 | 0 | +| 0 | 1 | 0 | 1 | 0 | +| 0 | 1 | 1 | 0 | 1 | +| 1 | 0 | 0 | 1 | 0 | +| 1 | 0 | 1 | 0 | 1 | +| 1 | 1 | 0 | 0 | 1 | +| 1 | 1 | 1 | 1 | 1 | diff --git a/projects/02/FullAdder.tst b/projects/02/FullAdder.tst new file mode 100755 index 0000000..5125cee --- /dev/null +++ b/projects/02/FullAdder.tst @@ -0,0 +1,47 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/FullAdder.tst + +load FullAdder.hdl, +output-file FullAdder.out, +compare-to FullAdder.cmp, +output-list a%B3.1.3 b%B3.1.3 c%B3.1.3 sum%B3.1.3 carry%B3.1.3; + +set a 0, +set b 0, +set c 0, +eval, +output; + +set c 1, +eval, +output; + +set b 1, +set c 0, +eval, +output; + +set c 1, +eval, +output; + +set a 1, +set b 0, +set c 0, +eval, +output; + +set c 1, +eval, +output; + +set b 1, +set c 0, +eval, +output; + +set c 1, +eval, +output; diff --git a/projects/02/HalfAdder.cmp b/projects/02/HalfAdder.cmp new file mode 100755 index 0000000..911c770 --- /dev/null +++ b/projects/02/HalfAdder.cmp @@ -0,0 +1,5 @@ +| a | b | sum | carry | +| 0 | 0 | 0 | 0 | +| 0 | 1 | 1 | 0 | +| 1 | 0 | 1 | 0 | +| 1 | 1 | 0 | 1 | diff --git a/projects/02/HalfAdder.hdl b/projects/02/HalfAdder.hdl new file mode 100755 index 0000000..27ada40 --- /dev/null +++ b/projects/02/HalfAdder.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/HalfAdder.hdl + +/** + * Computes the sum of two bits. + */ + +CHIP HalfAdder { + IN a, b; // 1-bit inputs + OUT sum, // Right bit of a + b + carry; // Left bit of a + b + + PARTS: + Xor(a=a,b=b,out=sum); + And(a=a,b=b,out=carry); +} diff --git a/projects/02/HalfAdder.out b/projects/02/HalfAdder.out new file mode 100755 index 0000000..911c770 --- /dev/null +++ b/projects/02/HalfAdder.out @@ -0,0 +1,5 @@ +| a | b | sum | carry | +| 0 | 0 | 0 | 0 | +| 0 | 1 | 1 | 0 | +| 1 | 0 | 1 | 0 | +| 1 | 1 | 0 | 1 | diff --git a/projects/02/HalfAdder.tst b/projects/02/HalfAdder.tst new file mode 100755 index 0000000..069b8ea --- /dev/null +++ b/projects/02/HalfAdder.tst @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/HalfAdder.tst + +load HalfAdder.hdl, +output-file HalfAdder.out, +compare-to HalfAdder.cmp, +output-list a%B3.1.3 b%B3.1.3 sum%B3.1.3 carry%B3.1.3; + +set a 0, +set b 0, +eval, +output; + +set a 0, +set b 1, +eval, +output; + +set a 1, +set b 0, +eval, +output; + +set a 1, +set b 1, +eval, +output; diff --git a/projects/02/Inc16.cmp b/projects/02/Inc16.cmp new file mode 100755 index 0000000..451f563 --- /dev/null +++ b/projects/02/Inc16.cmp @@ -0,0 +1,5 @@ +| in | out | +| 0000000000000000 | 0000000000000001 | +| 1111111111111111 | 0000000000000000 | +| 0000000000000101 | 0000000000000110 | +| 1111111111111011 | 1111111111111100 | diff --git a/projects/02/Inc16.hdl b/projects/02/Inc16.hdl new file mode 100755 index 0000000..23c872e --- /dev/null +++ b/projects/02/Inc16.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/Inc16.hdl + +/** + * 16-bit incrementer: + * out = in + 1 (arithmetic addition) + */ + +CHIP Inc16 { + IN in[16]; + OUT out[16]; + + PARTS: + Add16(a=in, b[1..15]=false, b[0]=true , out=out); + +} \ No newline at end of file diff --git a/projects/02/Inc16.out b/projects/02/Inc16.out new file mode 100755 index 0000000..451f563 --- /dev/null +++ b/projects/02/Inc16.out @@ -0,0 +1,5 @@ +| in | out | +| 0000000000000000 | 0000000000000001 | +| 1111111111111111 | 0000000000000000 | +| 0000000000000101 | 0000000000000110 | +| 1111111111111011 | 1111111111111100 | diff --git a/projects/02/Inc16.tst b/projects/02/Inc16.tst new file mode 100755 index 0000000..8537d86 --- /dev/null +++ b/projects/02/Inc16.tst @@ -0,0 +1,25 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/Inc16.tst + +load Inc16.hdl, +output-file Inc16.out, +compare-to Inc16.cmp, +output-list in%B1.16.1 out%B1.16.1; + +set in %B0000000000000000, // in = 0 +eval, +output; + +set in %B1111111111111111, // in = -1 +eval, +output; + +set in %B0000000000000101, // in = 5 +eval, +output; + +set in %B1111111111111011, // in = -5 +eval, +output; diff --git a/projects/03/a/Bit.cmp b/projects/03/a/Bit.cmp new file mode 100755 index 0000000..e900ec7 --- /dev/null +++ b/projects/03/a/Bit.cmp @@ -0,0 +1,215 @@ +| time | in |load | out | +| 0+ | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | +| 2 | 0 | 1 | 0 | +| 2+ | 1 | 0 | 0 | +| 3 | 1 | 0 | 0 | +| 3+ | 1 | 1 | 0 | +| 4 | 1 | 1 | 1 | +| 4+ | 0 | 0 | 1 | +| 5 | 0 | 0 | 1 | +| 5+ | 1 | 0 | 1 | +| 6 | 1 | 0 | 1 | +| 6+ | 0 | 1 | 1 | +| 7 | 0 | 1 | 0 | +| 7+ | 1 | 1 | 0 | +| 8 | 1 | 1 | 1 | +| 8+ | 0 | 0 | 1 | +| 9 | 0 | 0 | 1 | +| 9+ | 0 | 0 | 1 | +| 10 | 0 | 0 | 1 | +| 10+ | 0 | 0 | 1 | +| 11 | 0 | 0 | 1 | +| 11+ | 0 | 0 | 1 | +| 12 | 0 | 0 | 1 | +| 12+ | 0 | 0 | 1 | +| 13 | 0 | 0 | 1 | +| 13+ | 0 | 0 | 1 | +| 14 | 0 | 0 | 1 | +| 14+ | 0 | 0 | 1 | +| 15 | 0 | 0 | 1 | +| 15+ | 0 | 0 | 1 | +| 16 | 0 | 0 | 1 | +| 16+ | 0 | 0 | 1 | +| 17 | 0 | 0 | 1 | +| 17+ | 0 | 0 | 1 | +| 18 | 0 | 0 | 1 | +| 18+ | 0 | 0 | 1 | +| 19 | 0 | 0 | 1 | +| 19+ | 0 | 0 | 1 | +| 20 | 0 | 0 | 1 | +| 20+ | 0 | 0 | 1 | +| 21 | 0 | 0 | 1 | +| 21+ | 0 | 0 | 1 | +| 22 | 0 | 0 | 1 | +| 22+ | 0 | 0 | 1 | +| 23 | 0 | 0 | 1 | +| 23+ | 0 | 0 | 1 | +| 24 | 0 | 0 | 1 | +| 24+ | 0 | 0 | 1 | +| 25 | 0 | 0 | 1 | +| 25+ | 0 | 0 | 1 | +| 26 | 0 | 0 | 1 | +| 26+ | 0 | 0 | 1 | +| 27 | 0 | 0 | 1 | +| 27+ | 0 | 0 | 1 | +| 28 | 0 | 0 | 1 | +| 28+ | 0 | 0 | 1 | +| 29 | 0 | 0 | 1 | +| 29+ | 0 | 0 | 1 | +| 30 | 0 | 0 | 1 | +| 30+ | 0 | 0 | 1 | +| 31 | 0 | 0 | 1 | +| 31+ | 0 | 0 | 1 | +| 32 | 0 | 0 | 1 | +| 32+ | 0 | 0 | 1 | +| 33 | 0 | 0 | 1 | +| 33+ | 0 | 0 | 1 | +| 34 | 0 | 0 | 1 | +| 34+ | 0 | 0 | 1 | +| 35 | 0 | 0 | 1 | +| 35+ | 0 | 0 | 1 | +| 36 | 0 | 0 | 1 | +| 36+ | 0 | 0 | 1 | +| 37 | 0 | 0 | 1 | +| 37+ | 0 | 0 | 1 | +| 38 | 0 | 0 | 1 | +| 38+ | 0 | 0 | 1 | +| 39 | 0 | 0 | 1 | +| 39+ | 0 | 0 | 1 | +| 40 | 0 | 0 | 1 | +| 40+ | 0 | 0 | 1 | +| 41 | 0 | 0 | 1 | +| 41+ | 0 | 0 | 1 | +| 42 | 0 | 0 | 1 | +| 42+ | 0 | 0 | 1 | +| 43 | 0 | 0 | 1 | +| 43+ | 0 | 0 | 1 | +| 44 | 0 | 0 | 1 | +| 44+ | 0 | 0 | 1 | +| 45 | 0 | 0 | 1 | +| 45+ | 0 | 0 | 1 | +| 46 | 0 | 0 | 1 | +| 46+ | 0 | 0 | 1 | +| 47 | 0 | 0 | 1 | +| 47+ | 0 | 0 | 1 | +| 48 | 0 | 0 | 1 | +| 48+ | 0 | 0 | 1 | +| 49 | 0 | 0 | 1 | +| 49+ | 0 | 0 | 1 | +| 50 | 0 | 0 | 1 | +| 50+ | 0 | 0 | 1 | +| 51 | 0 | 0 | 1 | +| 51+ | 0 | 0 | 1 | +| 52 | 0 | 0 | 1 | +| 52+ | 0 | 0 | 1 | +| 53 | 0 | 0 | 1 | +| 53+ | 0 | 0 | 1 | +| 54 | 0 | 0 | 1 | +| 54+ | 0 | 0 | 1 | +| 55 | 0 | 0 | 1 | +| 55+ | 0 | 0 | 1 | +| 56 | 0 | 0 | 1 | +| 56+ | 0 | 0 | 1 | +| 57 | 0 | 0 | 1 | +| 57+ | 0 | 1 | 1 | +| 58 | 0 | 1 | 0 | +| 58+ | 1 | 0 | 0 | +| 59 | 1 | 0 | 0 | +| 59+ | 1 | 0 | 0 | +| 60 | 1 | 0 | 0 | +| 60+ | 1 | 0 | 0 | +| 61 | 1 | 0 | 0 | +| 61+ | 1 | 0 | 0 | +| 62 | 1 | 0 | 0 | +| 62+ | 1 | 0 | 0 | +| 63 | 1 | 0 | 0 | +| 63+ | 1 | 0 | 0 | +| 64 | 1 | 0 | 0 | +| 64+ | 1 | 0 | 0 | +| 65 | 1 | 0 | 0 | +| 65+ | 1 | 0 | 0 | +| 66 | 1 | 0 | 0 | +| 66+ | 1 | 0 | 0 | +| 67 | 1 | 0 | 0 | +| 67+ | 1 | 0 | 0 | +| 68 | 1 | 0 | 0 | +| 68+ | 1 | 0 | 0 | +| 69 | 1 | 0 | 0 | +| 69+ | 1 | 0 | 0 | +| 70 | 1 | 0 | 0 | +| 70+ | 1 | 0 | 0 | +| 71 | 1 | 0 | 0 | +| 71+ | 1 | 0 | 0 | +| 72 | 1 | 0 | 0 | +| 72+ | 1 | 0 | 0 | +| 73 | 1 | 0 | 0 | +| 73+ | 1 | 0 | 0 | +| 74 | 1 | 0 | 0 | +| 74+ | 1 | 0 | 0 | +| 75 | 1 | 0 | 0 | +| 75+ | 1 | 0 | 0 | +| 76 | 1 | 0 | 0 | +| 76+ | 1 | 0 | 0 | +| 77 | 1 | 0 | 0 | +| 77+ | 1 | 0 | 0 | +| 78 | 1 | 0 | 0 | +| 78+ | 1 | 0 | 0 | +| 79 | 1 | 0 | 0 | +| 79+ | 1 | 0 | 0 | +| 80 | 1 | 0 | 0 | +| 80+ | 1 | 0 | 0 | +| 81 | 1 | 0 | 0 | +| 81+ | 1 | 0 | 0 | +| 82 | 1 | 0 | 0 | +| 82+ | 1 | 0 | 0 | +| 83 | 1 | 0 | 0 | +| 83+ | 1 | 0 | 0 | +| 84 | 1 | 0 | 0 | +| 84+ | 1 | 0 | 0 | +| 85 | 1 | 0 | 0 | +| 85+ | 1 | 0 | 0 | +| 86 | 1 | 0 | 0 | +| 86+ | 1 | 0 | 0 | +| 87 | 1 | 0 | 0 | +| 87+ | 1 | 0 | 0 | +| 88 | 1 | 0 | 0 | +| 88+ | 1 | 0 | 0 | +| 89 | 1 | 0 | 0 | +| 89+ | 1 | 0 | 0 | +| 90 | 1 | 0 | 0 | +| 90+ | 1 | 0 | 0 | +| 91 | 1 | 0 | 0 | +| 91+ | 1 | 0 | 0 | +| 92 | 1 | 0 | 0 | +| 92+ | 1 | 0 | 0 | +| 93 | 1 | 0 | 0 | +| 93+ | 1 | 0 | 0 | +| 94 | 1 | 0 | 0 | +| 94+ | 1 | 0 | 0 | +| 95 | 1 | 0 | 0 | +| 95+ | 1 | 0 | 0 | +| 96 | 1 | 0 | 0 | +| 96+ | 1 | 0 | 0 | +| 97 | 1 | 0 | 0 | +| 97+ | 1 | 0 | 0 | +| 98 | 1 | 0 | 0 | +| 98+ | 1 | 0 | 0 | +| 99 | 1 | 0 | 0 | +| 99+ | 1 | 0 | 0 | +| 100 | 1 | 0 | 0 | +| 100+ | 1 | 0 | 0 | +| 101 | 1 | 0 | 0 | +| 101+ | 1 | 0 | 0 | +| 102 | 1 | 0 | 0 | +| 102+ | 1 | 0 | 0 | +| 103 | 1 | 0 | 0 | +| 103+ | 1 | 0 | 0 | +| 104 | 1 | 0 | 0 | +| 104+ | 1 | 0 | 0 | +| 105 | 1 | 0 | 0 | +| 105+ | 1 | 0 | 0 | +| 106 | 1 | 0 | 0 | +| 106+ | 1 | 0 | 0 | +| 107 | 1 | 0 | 0 | diff --git a/projects/03/a/Bit.hdl b/projects/03/a/Bit.hdl new file mode 100755 index 0000000..a85e716 --- /dev/null +++ b/projects/03/a/Bit.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/Bit.hdl + +/** + * 1-bit register: + * If load[t] == 1 then out[t+1] = in[t] + * else out does not change (out[t+1] = out[t]) + */ + +CHIP Bit { + IN in, load; + OUT out; + + PARTS: + Mux(a=out2,b=in,sel=load,out=out1); + DFF(in=out1,out=out2,out=out); +} diff --git a/projects/03/a/Bit.out b/projects/03/a/Bit.out new file mode 100755 index 0000000..e900ec7 --- /dev/null +++ b/projects/03/a/Bit.out @@ -0,0 +1,215 @@ +| time | in |load | out | +| 0+ | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | +| 2 | 0 | 1 | 0 | +| 2+ | 1 | 0 | 0 | +| 3 | 1 | 0 | 0 | +| 3+ | 1 | 1 | 0 | +| 4 | 1 | 1 | 1 | +| 4+ | 0 | 0 | 1 | +| 5 | 0 | 0 | 1 | +| 5+ | 1 | 0 | 1 | +| 6 | 1 | 0 | 1 | +| 6+ | 0 | 1 | 1 | +| 7 | 0 | 1 | 0 | +| 7+ | 1 | 1 | 0 | +| 8 | 1 | 1 | 1 | +| 8+ | 0 | 0 | 1 | +| 9 | 0 | 0 | 1 | +| 9+ | 0 | 0 | 1 | +| 10 | 0 | 0 | 1 | +| 10+ | 0 | 0 | 1 | +| 11 | 0 | 0 | 1 | +| 11+ | 0 | 0 | 1 | +| 12 | 0 | 0 | 1 | +| 12+ | 0 | 0 | 1 | +| 13 | 0 | 0 | 1 | +| 13+ | 0 | 0 | 1 | +| 14 | 0 | 0 | 1 | +| 14+ | 0 | 0 | 1 | +| 15 | 0 | 0 | 1 | +| 15+ | 0 | 0 | 1 | +| 16 | 0 | 0 | 1 | +| 16+ | 0 | 0 | 1 | +| 17 | 0 | 0 | 1 | +| 17+ | 0 | 0 | 1 | +| 18 | 0 | 0 | 1 | +| 18+ | 0 | 0 | 1 | +| 19 | 0 | 0 | 1 | +| 19+ | 0 | 0 | 1 | +| 20 | 0 | 0 | 1 | +| 20+ | 0 | 0 | 1 | +| 21 | 0 | 0 | 1 | +| 21+ | 0 | 0 | 1 | +| 22 | 0 | 0 | 1 | +| 22+ | 0 | 0 | 1 | +| 23 | 0 | 0 | 1 | +| 23+ | 0 | 0 | 1 | +| 24 | 0 | 0 | 1 | +| 24+ | 0 | 0 | 1 | +| 25 | 0 | 0 | 1 | +| 25+ | 0 | 0 | 1 | +| 26 | 0 | 0 | 1 | +| 26+ | 0 | 0 | 1 | +| 27 | 0 | 0 | 1 | +| 27+ | 0 | 0 | 1 | +| 28 | 0 | 0 | 1 | +| 28+ | 0 | 0 | 1 | +| 29 | 0 | 0 | 1 | +| 29+ | 0 | 0 | 1 | +| 30 | 0 | 0 | 1 | +| 30+ | 0 | 0 | 1 | +| 31 | 0 | 0 | 1 | +| 31+ | 0 | 0 | 1 | +| 32 | 0 | 0 | 1 | +| 32+ | 0 | 0 | 1 | +| 33 | 0 | 0 | 1 | +| 33+ | 0 | 0 | 1 | +| 34 | 0 | 0 | 1 | +| 34+ | 0 | 0 | 1 | +| 35 | 0 | 0 | 1 | +| 35+ | 0 | 0 | 1 | +| 36 | 0 | 0 | 1 | +| 36+ | 0 | 0 | 1 | +| 37 | 0 | 0 | 1 | +| 37+ | 0 | 0 | 1 | +| 38 | 0 | 0 | 1 | +| 38+ | 0 | 0 | 1 | +| 39 | 0 | 0 | 1 | +| 39+ | 0 | 0 | 1 | +| 40 | 0 | 0 | 1 | +| 40+ | 0 | 0 | 1 | +| 41 | 0 | 0 | 1 | +| 41+ | 0 | 0 | 1 | +| 42 | 0 | 0 | 1 | +| 42+ | 0 | 0 | 1 | +| 43 | 0 | 0 | 1 | +| 43+ | 0 | 0 | 1 | +| 44 | 0 | 0 | 1 | +| 44+ | 0 | 0 | 1 | +| 45 | 0 | 0 | 1 | +| 45+ | 0 | 0 | 1 | +| 46 | 0 | 0 | 1 | +| 46+ | 0 | 0 | 1 | +| 47 | 0 | 0 | 1 | +| 47+ | 0 | 0 | 1 | +| 48 | 0 | 0 | 1 | +| 48+ | 0 | 0 | 1 | +| 49 | 0 | 0 | 1 | +| 49+ | 0 | 0 | 1 | +| 50 | 0 | 0 | 1 | +| 50+ | 0 | 0 | 1 | +| 51 | 0 | 0 | 1 | +| 51+ | 0 | 0 | 1 | +| 52 | 0 | 0 | 1 | +| 52+ | 0 | 0 | 1 | +| 53 | 0 | 0 | 1 | +| 53+ | 0 | 0 | 1 | +| 54 | 0 | 0 | 1 | +| 54+ | 0 | 0 | 1 | +| 55 | 0 | 0 | 1 | +| 55+ | 0 | 0 | 1 | +| 56 | 0 | 0 | 1 | +| 56+ | 0 | 0 | 1 | +| 57 | 0 | 0 | 1 | +| 57+ | 0 | 1 | 1 | +| 58 | 0 | 1 | 0 | +| 58+ | 1 | 0 | 0 | +| 59 | 1 | 0 | 0 | +| 59+ | 1 | 0 | 0 | +| 60 | 1 | 0 | 0 | +| 60+ | 1 | 0 | 0 | +| 61 | 1 | 0 | 0 | +| 61+ | 1 | 0 | 0 | +| 62 | 1 | 0 | 0 | +| 62+ | 1 | 0 | 0 | +| 63 | 1 | 0 | 0 | +| 63+ | 1 | 0 | 0 | +| 64 | 1 | 0 | 0 | +| 64+ | 1 | 0 | 0 | +| 65 | 1 | 0 | 0 | +| 65+ | 1 | 0 | 0 | +| 66 | 1 | 0 | 0 | +| 66+ | 1 | 0 | 0 | +| 67 | 1 | 0 | 0 | +| 67+ | 1 | 0 | 0 | +| 68 | 1 | 0 | 0 | +| 68+ | 1 | 0 | 0 | +| 69 | 1 | 0 | 0 | +| 69+ | 1 | 0 | 0 | +| 70 | 1 | 0 | 0 | +| 70+ | 1 | 0 | 0 | +| 71 | 1 | 0 | 0 | +| 71+ | 1 | 0 | 0 | +| 72 | 1 | 0 | 0 | +| 72+ | 1 | 0 | 0 | +| 73 | 1 | 0 | 0 | +| 73+ | 1 | 0 | 0 | +| 74 | 1 | 0 | 0 | +| 74+ | 1 | 0 | 0 | +| 75 | 1 | 0 | 0 | +| 75+ | 1 | 0 | 0 | +| 76 | 1 | 0 | 0 | +| 76+ | 1 | 0 | 0 | +| 77 | 1 | 0 | 0 | +| 77+ | 1 | 0 | 0 | +| 78 | 1 | 0 | 0 | +| 78+ | 1 | 0 | 0 | +| 79 | 1 | 0 | 0 | +| 79+ | 1 | 0 | 0 | +| 80 | 1 | 0 | 0 | +| 80+ | 1 | 0 | 0 | +| 81 | 1 | 0 | 0 | +| 81+ | 1 | 0 | 0 | +| 82 | 1 | 0 | 0 | +| 82+ | 1 | 0 | 0 | +| 83 | 1 | 0 | 0 | +| 83+ | 1 | 0 | 0 | +| 84 | 1 | 0 | 0 | +| 84+ | 1 | 0 | 0 | +| 85 | 1 | 0 | 0 | +| 85+ | 1 | 0 | 0 | +| 86 | 1 | 0 | 0 | +| 86+ | 1 | 0 | 0 | +| 87 | 1 | 0 | 0 | +| 87+ | 1 | 0 | 0 | +| 88 | 1 | 0 | 0 | +| 88+ | 1 | 0 | 0 | +| 89 | 1 | 0 | 0 | +| 89+ | 1 | 0 | 0 | +| 90 | 1 | 0 | 0 | +| 90+ | 1 | 0 | 0 | +| 91 | 1 | 0 | 0 | +| 91+ | 1 | 0 | 0 | +| 92 | 1 | 0 | 0 | +| 92+ | 1 | 0 | 0 | +| 93 | 1 | 0 | 0 | +| 93+ | 1 | 0 | 0 | +| 94 | 1 | 0 | 0 | +| 94+ | 1 | 0 | 0 | +| 95 | 1 | 0 | 0 | +| 95+ | 1 | 0 | 0 | +| 96 | 1 | 0 | 0 | +| 96+ | 1 | 0 | 0 | +| 97 | 1 | 0 | 0 | +| 97+ | 1 | 0 | 0 | +| 98 | 1 | 0 | 0 | +| 98+ | 1 | 0 | 0 | +| 99 | 1 | 0 | 0 | +| 99+ | 1 | 0 | 0 | +| 100 | 1 | 0 | 0 | +| 100+ | 1 | 0 | 0 | +| 101 | 1 | 0 | 0 | +| 101+ | 1 | 0 | 0 | +| 102 | 1 | 0 | 0 | +| 102+ | 1 | 0 | 0 | +| 103 | 1 | 0 | 0 | +| 103+ | 1 | 0 | 0 | +| 104 | 1 | 0 | 0 | +| 104+ | 1 | 0 | 0 | +| 105 | 1 | 0 | 0 | +| 105+ | 1 | 0 | 0 | +| 106 | 1 | 0 | 0 | +| 106+ | 1 | 0 | 0 | +| 107 | 1 | 0 | 0 | diff --git a/projects/03/a/Bit.tst b/projects/03/a/Bit.tst new file mode 100755 index 0000000..c6bf523 --- /dev/null +++ b/projects/03/a/Bit.tst @@ -0,0 +1,865 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/Bit.tst + +load Bit.hdl, +output-file Bit.out, +compare-to Bit.cmp, +output-list time%S1.4.1 in%B2.1.2 load%B2.1.2 out%B2.1.2; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 1, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 1, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 1, +tick, +output; + +tock, +output; + +set in 1, +set load 1, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 1, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; + +set in 1, +set load 0, +tick, +output; + +tock, +output; diff --git a/projects/03/a/DMux8Way16.hdl b/projects/03/a/DMux8Way16.hdl new file mode 100755 index 0000000..1029f09 --- /dev/null +++ b/projects/03/a/DMux8Way16.hdl @@ -0,0 +1,22 @@ +CHIP DMux8Way16 { + IN in[16], sel[3]; + OUT a[16], b[16], c[16], d[16], e[16], f[16], g[16], h[16]; + + PARTS: + DMux8Way(a=a[0],b=b[0],c=c[0],d=d[0],e=e[0],f=f[0],g=g[0],h=h[0],sel=sel,in=in[0]); + DMux8Way(a=a[1],b=b[1],c=c[1],d=d[1],e=e[1],f=f[1],g=g[1],h=h[1],sel=sel,in=in[1]); + DMux8Way(a=a[2],b=b[2],c=c[2],d=d[2],e=e[2],f=f[2],g=g[2],h=h[2],sel=sel,in=in[2]); + DMux8Way(a=a[3],b=b[3],c=c[3],d=d[3],e=e[3],f=f[3],g=g[3],h=h[3],sel=sel,in=in[3]); + DMux8Way(a=a[4],b=b[4],c=c[4],d=d[4],e=e[4],f=f[4],g=g[4],h=h[4],sel=sel,in=in[4]); + DMux8Way(a=a[5],b=b[5],c=c[5],d=d[5],e=e[5],f=f[5],g=g[5],h=h[5],sel=sel,in=in[5]); + DMux8Way(a=a[6],b=b[6],c=c[6],d=d[6],e=e[6],f=f[6],g=g[6],h=h[6],sel=sel,in=in[6]); + DMux8Way(a=a[7],b=b[7],c=c[7],d=d[7],e=e[7],f=f[7],g=g[7],h=h[7],sel=sel,in=in[7]); + DMux8Way(a=a[8],b=b[8],c=c[8],d=d[8],e=e[8],f=f[8],g=g[8],h=h[8],sel=sel,in=in[8]); + DMux8Way(a=a[9],b=b[9],c=c[9],d=d[9],e=e[9],f=f[9],g=g[9],h=h[9],sel=sel,in=in[9]); + DMux8Way(a=a[10],b=b[10],c=c[10],d=d[10],e=e[10],f=f[10],g=g[10],h=h[10],sel=sel,in=in[10]); + DMux8Way(a=a[11],b=b[11],c=c[11],d=d[11],e=e[11],f=f[11],g=g[11],h=h[11],sel=sel,in=in[11]); + DMux8Way(a=a[12],b=b[12],c=c[12],d=d[12],e=e[12],f=f[12],g=g[12],h=h[12],sel=sel,in=in[12]); + DMux8Way(a=a[13],b=b[13],c=c[13],d=d[13],e=e[13],f=f[13],g=g[13],h=h[13],sel=sel,in=in[13]); + DMux8Way(a=a[14],b=b[14],c=c[14],d=d[14],e=e[14],f=f[14],g=g[14],h=h[14],sel=sel,in=in[14]); + DMux8Way(a=a[15],b=b[15],c=c[15],d=d[15],e=e[15],f=f[15],g=g[15],h=h[15],sel=sel,in=in[15]); +} \ No newline at end of file diff --git a/projects/03/a/PC.cmp b/projects/03/a/PC.cmp new file mode 100755 index 0000000..6a050d9 --- /dev/null +++ b/projects/03/a/PC.cmp @@ -0,0 +1,31 @@ +| time | in |reset|load | inc | out | +| 0+ | 0 | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 0 | 0 | 1 | 0 | +| 2 | 0 | 0 | 0 | 1 | 1 | +| 2+ | -32123 | 0 | 0 | 1 | 1 | +| 3 | -32123 | 0 | 0 | 1 | 2 | +| 3+ | -32123 | 0 | 1 | 1 | 2 | +| 4 | -32123 | 0 | 1 | 1 | -32123 | +| 4+ | -32123 | 0 | 0 | 1 | -32123 | +| 5 | -32123 | 0 | 0 | 1 | -32122 | +| 5+ | -32123 | 0 | 0 | 1 | -32122 | +| 6 | -32123 | 0 | 0 | 1 | -32121 | +| 6+ | 12345 | 0 | 1 | 0 | -32121 | +| 7 | 12345 | 0 | 1 | 0 | 12345 | +| 7+ | 12345 | 1 | 1 | 0 | 12345 | +| 8 | 12345 | 1 | 1 | 0 | 0 | +| 8+ | 12345 | 0 | 1 | 1 | 0 | +| 9 | 12345 | 0 | 1 | 1 | 12345 | +| 9+ | 12345 | 1 | 1 | 1 | 12345 | +| 10 | 12345 | 1 | 1 | 1 | 0 | +| 10+ | 12345 | 0 | 0 | 1 | 0 | +| 11 | 12345 | 0 | 0 | 1 | 1 | +| 11+ | 12345 | 1 | 0 | 1 | 1 | +| 12 | 12345 | 1 | 0 | 1 | 0 | +| 12+ | 0 | 0 | 1 | 1 | 0 | +| 13 | 0 | 0 | 1 | 1 | 0 | +| 13+ | 0 | 0 | 0 | 1 | 0 | +| 14 | 0 | 0 | 0 | 1 | 1 | +| 14+ | 22222 | 1 | 0 | 0 | 1 | +| 15 | 22222 | 1 | 0 | 0 | 0 | diff --git a/projects/03/a/PC.hdl b/projects/03/a/PC.hdl new file mode 100755 index 0000000..448e6c2 --- /dev/null +++ b/projects/03/a/PC.hdl @@ -0,0 +1,44 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/PC.hdl + +/** + * A 16-bit counter with load and reset control bits. + * if (reset[t] == 1) out[t+1] = 0 + * else if (load[t] == 1) out[t+1] = in[t] + * else if (inc[t] == 1) out[t+1] = out[t] + 1 (integer addition) + * else out[t+1] = out[t] + */ + +CHIP PC { + IN in[16],load,inc,reset; + OUT out[16]; + + PARTS: + DMux8Way(in=true,sel[0]=reset,sel[1]=load,sel[2]=inc,a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + + DFF(in=inc,out=inct); + And(a=inc,b=inct,out=out1); + Mux16(a=in,b=out4,sel=out1,out=out2); + Inc16(in=out2,out=out3); + Register(in=out3,load=load,out=out4,out=out); + + Not(in=a,out=notа); + Register(in=in,load=notа,out=outA); + + And16(a[0..15]=false,b[0..15]=false,out=outB); + + Register(in=in,load=c,out=outC); + + And16(a[0..15]=false,b[0..15]=false,out=outD); + + + And16(a[0..15]=false,b[0..15]=false,out=outF); + + Register(in=in,load=g,out=outG); + + And16(a[0..15]=false,b[0..15]=false,out=outH); + And16(a[0..15]=false,b[0..15]=false,out=outE); + Mux8Way16(a=outA,b=outB,c=outC,d=outD,e=outE,f=outF,g=outG,h=outH,sel[0]=reset,sel[1]=load,sel[2]=inc,out=out67); + } \ No newline at end of file diff --git a/projects/03/a/PC.out b/projects/03/a/PC.out new file mode 100755 index 0000000..e69de29 diff --git a/projects/03/a/PC.tst b/projects/03/a/PC.tst new file mode 100755 index 0000000..7f4f3cd --- /dev/null +++ b/projects/03/a/PC.tst @@ -0,0 +1,125 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/PC.tst + +load PC.hdl, +output-file PC.out, +compare-to PC.cmp, +output-list time%S1.4.1 in%D1.6.1 reset%B2.1.2 load%B2.1.2 inc%B2.1.2 out%D1.6.1; + +set in 0, +set reset 0, +set load 0, +set inc 0, +tick, +output; + +tock, +output; + +set inc 1, +tick, +output; + +tock, +output; + +set in -32123, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set load 0, +tick, +output; + +tock, +output; + +tick, +output; + +tock, +output; + +set in 12345, +set load 1, +set inc 0, +tick, +output; + +tock, +output; + +set reset 1, +tick, +output; + +tock, +output; + +set reset 0, +set inc 1, +tick, +output; + +tock, +output; + +set reset 1, +tick, +output; + +tock, +output; + +set reset 0, +set load 0, +tick, +output; + +tock, +output; + +set reset 1, +tick, +output; + +tock, +output; + +set in 0, +set reset 0, +set load 1, +tick, +output; + +tock, +output; + +set load 0, +set inc 1, +tick, +output; + +tock, +output; + +set in 22222, +set reset 1, +set inc 0, +tick, +output; + +tock, +output; diff --git a/projects/03/a/RAM64.cmp b/projects/03/a/RAM64.cmp new file mode 100755 index 0000000..fdb7745 --- /dev/null +++ b/projects/03/a/RAM64.cmp @@ -0,0 +1,320 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 1313 | 0 | 0 | 0 | +| 3 | 1313 | 0 | 0 | 0 | +| 3+ | 1313 | 1 | 13 | 0 | +| 4 | 1313 | 1 | 13 | 1313 | +| 4+ | 1313 | 0 | 0 | 0 | +| 5 | 1313 | 0 | 0 | 0 | +| 5+ | 4747 | 0 | 47 | 0 | +| 6 | 4747 | 0 | 47 | 0 | +| 6+ | 4747 | 1 | 47 | 0 | +| 7 | 4747 | 1 | 47 | 4747 | +| 7+ | 4747 | 0 | 47 | 4747 | +| 8 | 4747 | 0 | 47 | 4747 | +| 8 | 4747 | 0 | 13 | 1313 | +| 8+ | 6363 | 0 | 13 | 1313 | +| 9 | 6363 | 0 | 13 | 1313 | +| 9+ | 6363 | 1 | 63 | 0 | +| 10 | 6363 | 1 | 63 | 6363 | +| 10+ | 6363 | 0 | 63 | 6363 | +| 11 | 6363 | 0 | 63 | 6363 | +| 11 | 6363 | 0 | 47 | 4747 | +| 11 | 6363 | 0 | 63 | 6363 | +| 11+ | 6363 | 0 | 40 | 0 | +| 12 | 6363 | 0 | 40 | 0 | +| 12 | 6363 | 0 | 41 | 0 | +| 12 | 6363 | 0 | 42 | 0 | +| 12 | 6363 | 0 | 43 | 0 | +| 12 | 6363 | 0 | 44 | 0 | +| 12 | 6363 | 0 | 45 | 0 | +| 12 | 6363 | 0 | 46 | 0 | +| 12 | 6363 | 0 | 47 | 4747 | +| 12+ | 21845 | 1 | 40 | 0 | +| 13 | 21845 | 1 | 40 | 21845 | +| 13+ | 21845 | 1 | 41 | 0 | +| 14 | 21845 | 1 | 41 | 21845 | +| 14+ | 21845 | 1 | 42 | 0 | +| 15 | 21845 | 1 | 42 | 21845 | +| 15+ | 21845 | 1 | 43 | 0 | +| 16 | 21845 | 1 | 43 | 21845 | +| 16+ | 21845 | 1 | 44 | 0 | +| 17 | 21845 | 1 | 44 | 21845 | +| 17+ | 21845 | 1 | 45 | 0 | +| 18 | 21845 | 1 | 45 | 21845 | +| 18+ | 21845 | 1 | 46 | 0 | +| 19 | 21845 | 1 | 46 | 21845 | +| 19+ | 21845 | 1 | 47 | 4747 | +| 20 | 21845 | 1 | 47 | 21845 | +| 20+ | 21845 | 0 | 40 | 21845 | +| 21 | 21845 | 0 | 40 | 21845 | +| 21 | 21845 | 0 | 41 | 21845 | +| 21 | 21845 | 0 | 42 | 21845 | +| 21 | 21845 | 0 | 43 | 21845 | +| 21 | 21845 | 0 | 44 | 21845 | +| 21 | 21845 | 0 | 45 | 21845 | +| 21 | 21845 | 0 | 46 | 21845 | +| 21 | 21845 | 0 | 47 | 21845 | +| 21+ | -21846 | 1 | 40 | 21845 | +| 22 | -21846 | 1 | 40 | -21846 | +| 22+ | -21846 | 0 | 40 | -21846 | +| 23 | -21846 | 0 | 40 | -21846 | +| 23 | -21846 | 0 | 41 | 21845 | +| 23 | -21846 | 0 | 42 | 21845 | +| 23 | -21846 | 0 | 43 | 21845 | +| 23 | -21846 | 0 | 44 | 21845 | +| 23 | -21846 | 0 | 45 | 21845 | +| 23 | -21846 | 0 | 46 | 21845 | +| 23 | -21846 | 0 | 47 | 21845 | +| 23+ | 21845 | 1 | 40 | -21846 | +| 24 | 21845 | 1 | 40 | 21845 | +| 24+ | -21846 | 1 | 41 | 21845 | +| 25 | -21846 | 1 | 41 | -21846 | +| 25+ | -21846 | 0 | 40 | 21845 | +| 26 | -21846 | 0 | 40 | 21845 | +| 26 | -21846 | 0 | 41 | -21846 | +| 26 | -21846 | 0 | 42 | 21845 | +| 26 | -21846 | 0 | 43 | 21845 | +| 26 | -21846 | 0 | 44 | 21845 | +| 26 | -21846 | 0 | 45 | 21845 | +| 26 | -21846 | 0 | 46 | 21845 | +| 26 | -21846 | 0 | 47 | 21845 | +| 26+ | 21845 | 1 | 41 | -21846 | +| 27 | 21845 | 1 | 41 | 21845 | +| 27+ | -21846 | 1 | 42 | 21845 | +| 28 | -21846 | 1 | 42 | -21846 | +| 28+ | -21846 | 0 | 40 | 21845 | +| 29 | -21846 | 0 | 40 | 21845 | +| 29 | -21846 | 0 | 41 | 21845 | +| 29 | -21846 | 0 | 42 | -21846 | +| 29 | -21846 | 0 | 43 | 21845 | +| 29 | -21846 | 0 | 44 | 21845 | +| 29 | -21846 | 0 | 45 | 21845 | +| 29 | -21846 | 0 | 46 | 21845 | +| 29 | -21846 | 0 | 47 | 21845 | +| 29+ | 21845 | 1 | 42 | -21846 | +| 30 | 21845 | 1 | 42 | 21845 | +| 30+ | -21846 | 1 | 43 | 21845 | +| 31 | -21846 | 1 | 43 | -21846 | +| 31+ | -21846 | 0 | 40 | 21845 | +| 32 | -21846 | 0 | 40 | 21845 | +| 32 | -21846 | 0 | 41 | 21845 | +| 32 | -21846 | 0 | 42 | 21845 | +| 32 | -21846 | 0 | 43 | -21846 | +| 32 | -21846 | 0 | 44 | 21845 | +| 32 | -21846 | 0 | 45 | 21845 | +| 32 | -21846 | 0 | 46 | 21845 | +| 32 | -21846 | 0 | 47 | 21845 | +| 32+ | 21845 | 1 | 43 | -21846 | +| 33 | 21845 | 1 | 43 | 21845 | +| 33+ | -21846 | 1 | 44 | 21845 | +| 34 | -21846 | 1 | 44 | -21846 | +| 34+ | -21846 | 0 | 40 | 21845 | +| 35 | -21846 | 0 | 40 | 21845 | +| 35 | -21846 | 0 | 41 | 21845 | +| 35 | -21846 | 0 | 42 | 21845 | +| 35 | -21846 | 0 | 43 | 21845 | +| 35 | -21846 | 0 | 44 | -21846 | +| 35 | -21846 | 0 | 45 | 21845 | +| 35 | -21846 | 0 | 46 | 21845 | +| 35 | -21846 | 0 | 47 | 21845 | +| 35+ | 21845 | 1 | 44 | -21846 | +| 36 | 21845 | 1 | 44 | 21845 | +| 36+ | -21846 | 1 | 45 | 21845 | +| 37 | -21846 | 1 | 45 | -21846 | +| 37+ | -21846 | 0 | 40 | 21845 | +| 38 | -21846 | 0 | 40 | 21845 | +| 38 | -21846 | 0 | 41 | 21845 | +| 38 | -21846 | 0 | 42 | 21845 | +| 38 | -21846 | 0 | 43 | 21845 | +| 38 | -21846 | 0 | 44 | 21845 | +| 38 | -21846 | 0 | 45 | -21846 | +| 38 | -21846 | 0 | 46 | 21845 | +| 38 | -21846 | 0 | 47 | 21845 | +| 38+ | 21845 | 1 | 45 | -21846 | +| 39 | 21845 | 1 | 45 | 21845 | +| 39+ | -21846 | 1 | 46 | 21845 | +| 40 | -21846 | 1 | 46 | -21846 | +| 40+ | -21846 | 0 | 40 | 21845 | +| 41 | -21846 | 0 | 40 | 21845 | +| 41 | -21846 | 0 | 41 | 21845 | +| 41 | -21846 | 0 | 42 | 21845 | +| 41 | -21846 | 0 | 43 | 21845 | +| 41 | -21846 | 0 | 44 | 21845 | +| 41 | -21846 | 0 | 45 | 21845 | +| 41 | -21846 | 0 | 46 | -21846 | +| 41 | -21846 | 0 | 47 | 21845 | +| 41+ | 21845 | 1 | 46 | -21846 | +| 42 | 21845 | 1 | 46 | 21845 | +| 42+ | -21846 | 1 | 47 | 21845 | +| 43 | -21846 | 1 | 47 | -21846 | +| 43+ | -21846 | 0 | 40 | 21845 | +| 44 | -21846 | 0 | 40 | 21845 | +| 44 | -21846 | 0 | 41 | 21845 | +| 44 | -21846 | 0 | 42 | 21845 | +| 44 | -21846 | 0 | 43 | 21845 | +| 44 | -21846 | 0 | 44 | 21845 | +| 44 | -21846 | 0 | 45 | 21845 | +| 44 | -21846 | 0 | 46 | 21845 | +| 44 | -21846 | 0 | 47 | -21846 | +| 44+ | 21845 | 1 | 47 | -21846 | +| 45 | 21845 | 1 | 47 | 21845 | +| 45+ | 21845 | 0 | 40 | 21845 | +| 46 | 21845 | 0 | 40 | 21845 | +| 46 | 21845 | 0 | 41 | 21845 | +| 46 | 21845 | 0 | 42 | 21845 | +| 46 | 21845 | 0 | 43 | 21845 | +| 46 | 21845 | 0 | 44 | 21845 | +| 46 | 21845 | 0 | 45 | 21845 | +| 46 | 21845 | 0 | 46 | 21845 | +| 46 | 21845 | 0 | 47 | 21845 | +| 46+ | 21845 | 0 | 5 | 0 | +| 47 | 21845 | 0 | 5 | 0 | +| 47 | 21845 | 0 | 13 | 1313 | +| 47 | 21845 | 0 | 21 | 0 | +| 47 | 21845 | 0 | 29 | 0 | +| 47 | 21845 | 0 | 37 | 0 | +| 47 | 21845 | 0 | 45 | 21845 | +| 47 | 21845 | 0 | 53 | 0 | +| 47 | 21845 | 0 | 61 | 0 | +| 47+ | 21845 | 1 | 5 | 0 | +| 48 | 21845 | 1 | 5 | 21845 | +| 48+ | 21845 | 1 | 13 | 1313 | +| 49 | 21845 | 1 | 13 | 21845 | +| 49+ | 21845 | 1 | 21 | 0 | +| 50 | 21845 | 1 | 21 | 21845 | +| 50+ | 21845 | 1 | 29 | 0 | +| 51 | 21845 | 1 | 29 | 21845 | +| 51+ | 21845 | 1 | 37 | 0 | +| 52 | 21845 | 1 | 37 | 21845 | +| 52+ | 21845 | 1 | 45 | 21845 | +| 53 | 21845 | 1 | 45 | 21845 | +| 53+ | 21845 | 1 | 53 | 0 | +| 54 | 21845 | 1 | 53 | 21845 | +| 54+ | 21845 | 1 | 61 | 0 | +| 55 | 21845 | 1 | 61 | 21845 | +| 55+ | 21845 | 0 | 5 | 21845 | +| 56 | 21845 | 0 | 5 | 21845 | +| 56 | 21845 | 0 | 13 | 21845 | +| 56 | 21845 | 0 | 21 | 21845 | +| 56 | 21845 | 0 | 29 | 21845 | +| 56 | 21845 | 0 | 37 | 21845 | +| 56 | 21845 | 0 | 45 | 21845 | +| 56 | 21845 | 0 | 53 | 21845 | +| 56 | 21845 | 0 | 61 | 21845 | +| 56+ | -21846 | 1 | 5 | 21845 | +| 57 | -21846 | 1 | 5 | -21846 | +| 57+ | -21846 | 0 | 5 | -21846 | +| 58 | -21846 | 0 | 5 | -21846 | +| 58 | -21846 | 0 | 13 | 21845 | +| 58 | -21846 | 0 | 21 | 21845 | +| 58 | -21846 | 0 | 29 | 21845 | +| 58 | -21846 | 0 | 37 | 21845 | +| 58 | -21846 | 0 | 45 | 21845 | +| 58 | -21846 | 0 | 53 | 21845 | +| 58 | -21846 | 0 | 61 | 21845 | +| 58+ | 21845 | 1 | 5 | -21846 | +| 59 | 21845 | 1 | 5 | 21845 | +| 59+ | -21846 | 1 | 13 | 21845 | +| 60 | -21846 | 1 | 13 | -21846 | +| 60+ | -21846 | 0 | 5 | 21845 | +| 61 | -21846 | 0 | 5 | 21845 | +| 61 | -21846 | 0 | 13 | -21846 | +| 61 | -21846 | 0 | 21 | 21845 | +| 61 | -21846 | 0 | 29 | 21845 | +| 61 | -21846 | 0 | 37 | 21845 | +| 61 | -21846 | 0 | 45 | 21845 | +| 61 | -21846 | 0 | 53 | 21845 | +| 61 | -21846 | 0 | 61 | 21845 | +| 61+ | 21845 | 1 | 13 | -21846 | +| 62 | 21845 | 1 | 13 | 21845 | +| 62+ | -21846 | 1 | 21 | 21845 | +| 63 | -21846 | 1 | 21 | -21846 | +| 63+ | -21846 | 0 | 5 | 21845 | +| 64 | -21846 | 0 | 5 | 21845 | +| 64 | -21846 | 0 | 13 | 21845 | +| 64 | -21846 | 0 | 21 | -21846 | +| 64 | -21846 | 0 | 29 | 21845 | +| 64 | -21846 | 0 | 37 | 21845 | +| 64 | -21846 | 0 | 45 | 21845 | +| 64 | -21846 | 0 | 53 | 21845 | +| 64 | -21846 | 0 | 61 | 21845 | +| 64+ | 21845 | 1 | 21 | -21846 | +| 65 | 21845 | 1 | 21 | 21845 | +| 65+ | -21846 | 1 | 29 | 21845 | +| 66 | -21846 | 1 | 29 | -21846 | +| 66+ | -21846 | 0 | 5 | 21845 | +| 67 | -21846 | 0 | 5 | 21845 | +| 67 | -21846 | 0 | 13 | 21845 | +| 67 | -21846 | 0 | 21 | 21845 | +| 67 | -21846 | 0 | 29 | -21846 | +| 67 | -21846 | 0 | 37 | 21845 | +| 67 | -21846 | 0 | 45 | 21845 | +| 67 | -21846 | 0 | 53 | 21845 | +| 67 | -21846 | 0 | 61 | 21845 | +| 67+ | 21845 | 1 | 29 | -21846 | +| 68 | 21845 | 1 | 29 | 21845 | +| 68+ | -21846 | 1 | 37 | 21845 | +| 69 | -21846 | 1 | 37 | -21846 | +| 69+ | -21846 | 0 | 5 | 21845 | +| 70 | -21846 | 0 | 5 | 21845 | +| 70 | -21846 | 0 | 13 | 21845 | +| 70 | -21846 | 0 | 21 | 21845 | +| 70 | -21846 | 0 | 29 | 21845 | +| 70 | -21846 | 0 | 37 | -21846 | +| 70 | -21846 | 0 | 45 | 21845 | +| 70 | -21846 | 0 | 53 | 21845 | +| 70 | -21846 | 0 | 61 | 21845 | +| 70+ | 21845 | 1 | 37 | -21846 | +| 71 | 21845 | 1 | 37 | 21845 | +| 71+ | -21846 | 1 | 45 | 21845 | +| 72 | -21846 | 1 | 45 | -21846 | +| 72+ | -21846 | 0 | 5 | 21845 | +| 73 | -21846 | 0 | 5 | 21845 | +| 73 | -21846 | 0 | 13 | 21845 | +| 73 | -21846 | 0 | 21 | 21845 | +| 73 | -21846 | 0 | 29 | 21845 | +| 73 | -21846 | 0 | 37 | 21845 | +| 73 | -21846 | 0 | 45 | -21846 | +| 73 | -21846 | 0 | 53 | 21845 | +| 73 | -21846 | 0 | 61 | 21845 | +| 73+ | 21845 | 1 | 45 | -21846 | +| 74 | 21845 | 1 | 45 | 21845 | +| 74+ | -21846 | 1 | 53 | 21845 | +| 75 | -21846 | 1 | 53 | -21846 | +| 75+ | -21846 | 0 | 5 | 21845 | +| 76 | -21846 | 0 | 5 | 21845 | +| 76 | -21846 | 0 | 13 | 21845 | +| 76 | -21846 | 0 | 21 | 21845 | +| 76 | -21846 | 0 | 29 | 21845 | +| 76 | -21846 | 0 | 37 | 21845 | +| 76 | -21846 | 0 | 45 | 21845 | +| 76 | -21846 | 0 | 53 | -21846 | +| 76 | -21846 | 0 | 61 | 21845 | +| 76+ | 21845 | 1 | 53 | -21846 | +| 77 | 21845 | 1 | 53 | 21845 | +| 77+ | -21846 | 1 | 61 | 21845 | +| 78 | -21846 | 1 | 61 | -21846 | +| 78+ | -21846 | 0 | 5 | 21845 | +| 79 | -21846 | 0 | 5 | 21845 | +| 79 | -21846 | 0 | 13 | 21845 | +| 79 | -21846 | 0 | 21 | 21845 | +| 79 | -21846 | 0 | 29 | 21845 | +| 79 | -21846 | 0 | 37 | 21845 | +| 79 | -21846 | 0 | 45 | 21845 | +| 79 | -21846 | 0 | 53 | 21845 | +| 79 | -21846 | 0 | 61 | -21846 | +| 79+ | 21845 | 1 | 61 | -21846 | +| 80 | 21845 | 1 | 61 | 21845 | +| 80+ | 21845 | 0 | 5 | 21845 | +| 81 | 21845 | 0 | 5 | 21845 | +| 81 | 21845 | 0 | 13 | 21845 | +| 81 | 21845 | 0 | 21 | 21845 | +| 81 | 21845 | 0 | 29 | 21845 | +| 81 | 21845 | 0 | 37 | 21845 | +| 81 | 21845 | 0 | 45 | 21845 | +| 81 | 21845 | 0 | 53 | 21845 | +| 81 | 21845 | 0 | 61 | 21845 | diff --git a/projects/03/a/RAM64.hdl b/projects/03/a/RAM64.hdl new file mode 100755 index 0000000..44d11bf --- /dev/null +++ b/projects/03/a/RAM64.hdl @@ -0,0 +1,28 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/RAM64.hdl + +/** + * Memory of 64 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM64 { + IN in[16], load, address[6]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address[0..2],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + RAM8(in=in,load=a,address=address[3..5],out=outa); + RAM8(in=in,load=b,address=address[3..5],out=outb); + RAM8(in=in,load=c,address=address[3..5],out=outc); + RAM8(in=in,load=d,address=address[3..5],out=outd); + RAM8(in=in,load=e,address=address[3..5],out=oute); + RAM8(in=in,load=f,address=address[3..5],out=outf); + RAM8(in=in,load=g,address=address[3..5],out=outg); + RAM8(in=in,load=h,address=address[3..5],out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address[0..2],out=out); +} \ No newline at end of file diff --git a/projects/03/a/RAM64.out b/projects/03/a/RAM64.out new file mode 100755 index 0000000..fdb7745 --- /dev/null +++ b/projects/03/a/RAM64.out @@ -0,0 +1,320 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 1313 | 0 | 0 | 0 | +| 3 | 1313 | 0 | 0 | 0 | +| 3+ | 1313 | 1 | 13 | 0 | +| 4 | 1313 | 1 | 13 | 1313 | +| 4+ | 1313 | 0 | 0 | 0 | +| 5 | 1313 | 0 | 0 | 0 | +| 5+ | 4747 | 0 | 47 | 0 | +| 6 | 4747 | 0 | 47 | 0 | +| 6+ | 4747 | 1 | 47 | 0 | +| 7 | 4747 | 1 | 47 | 4747 | +| 7+ | 4747 | 0 | 47 | 4747 | +| 8 | 4747 | 0 | 47 | 4747 | +| 8 | 4747 | 0 | 13 | 1313 | +| 8+ | 6363 | 0 | 13 | 1313 | +| 9 | 6363 | 0 | 13 | 1313 | +| 9+ | 6363 | 1 | 63 | 0 | +| 10 | 6363 | 1 | 63 | 6363 | +| 10+ | 6363 | 0 | 63 | 6363 | +| 11 | 6363 | 0 | 63 | 6363 | +| 11 | 6363 | 0 | 47 | 4747 | +| 11 | 6363 | 0 | 63 | 6363 | +| 11+ | 6363 | 0 | 40 | 0 | +| 12 | 6363 | 0 | 40 | 0 | +| 12 | 6363 | 0 | 41 | 0 | +| 12 | 6363 | 0 | 42 | 0 | +| 12 | 6363 | 0 | 43 | 0 | +| 12 | 6363 | 0 | 44 | 0 | +| 12 | 6363 | 0 | 45 | 0 | +| 12 | 6363 | 0 | 46 | 0 | +| 12 | 6363 | 0 | 47 | 4747 | +| 12+ | 21845 | 1 | 40 | 0 | +| 13 | 21845 | 1 | 40 | 21845 | +| 13+ | 21845 | 1 | 41 | 0 | +| 14 | 21845 | 1 | 41 | 21845 | +| 14+ | 21845 | 1 | 42 | 0 | +| 15 | 21845 | 1 | 42 | 21845 | +| 15+ | 21845 | 1 | 43 | 0 | +| 16 | 21845 | 1 | 43 | 21845 | +| 16+ | 21845 | 1 | 44 | 0 | +| 17 | 21845 | 1 | 44 | 21845 | +| 17+ | 21845 | 1 | 45 | 0 | +| 18 | 21845 | 1 | 45 | 21845 | +| 18+ | 21845 | 1 | 46 | 0 | +| 19 | 21845 | 1 | 46 | 21845 | +| 19+ | 21845 | 1 | 47 | 4747 | +| 20 | 21845 | 1 | 47 | 21845 | +| 20+ | 21845 | 0 | 40 | 21845 | +| 21 | 21845 | 0 | 40 | 21845 | +| 21 | 21845 | 0 | 41 | 21845 | +| 21 | 21845 | 0 | 42 | 21845 | +| 21 | 21845 | 0 | 43 | 21845 | +| 21 | 21845 | 0 | 44 | 21845 | +| 21 | 21845 | 0 | 45 | 21845 | +| 21 | 21845 | 0 | 46 | 21845 | +| 21 | 21845 | 0 | 47 | 21845 | +| 21+ | -21846 | 1 | 40 | 21845 | +| 22 | -21846 | 1 | 40 | -21846 | +| 22+ | -21846 | 0 | 40 | -21846 | +| 23 | -21846 | 0 | 40 | -21846 | +| 23 | -21846 | 0 | 41 | 21845 | +| 23 | -21846 | 0 | 42 | 21845 | +| 23 | -21846 | 0 | 43 | 21845 | +| 23 | -21846 | 0 | 44 | 21845 | +| 23 | -21846 | 0 | 45 | 21845 | +| 23 | -21846 | 0 | 46 | 21845 | +| 23 | -21846 | 0 | 47 | 21845 | +| 23+ | 21845 | 1 | 40 | -21846 | +| 24 | 21845 | 1 | 40 | 21845 | +| 24+ | -21846 | 1 | 41 | 21845 | +| 25 | -21846 | 1 | 41 | -21846 | +| 25+ | -21846 | 0 | 40 | 21845 | +| 26 | -21846 | 0 | 40 | 21845 | +| 26 | -21846 | 0 | 41 | -21846 | +| 26 | -21846 | 0 | 42 | 21845 | +| 26 | -21846 | 0 | 43 | 21845 | +| 26 | -21846 | 0 | 44 | 21845 | +| 26 | -21846 | 0 | 45 | 21845 | +| 26 | -21846 | 0 | 46 | 21845 | +| 26 | -21846 | 0 | 47 | 21845 | +| 26+ | 21845 | 1 | 41 | -21846 | +| 27 | 21845 | 1 | 41 | 21845 | +| 27+ | -21846 | 1 | 42 | 21845 | +| 28 | -21846 | 1 | 42 | -21846 | +| 28+ | -21846 | 0 | 40 | 21845 | +| 29 | -21846 | 0 | 40 | 21845 | +| 29 | -21846 | 0 | 41 | 21845 | +| 29 | -21846 | 0 | 42 | -21846 | +| 29 | -21846 | 0 | 43 | 21845 | +| 29 | -21846 | 0 | 44 | 21845 | +| 29 | -21846 | 0 | 45 | 21845 | +| 29 | -21846 | 0 | 46 | 21845 | +| 29 | -21846 | 0 | 47 | 21845 | +| 29+ | 21845 | 1 | 42 | -21846 | +| 30 | 21845 | 1 | 42 | 21845 | +| 30+ | -21846 | 1 | 43 | 21845 | +| 31 | -21846 | 1 | 43 | -21846 | +| 31+ | -21846 | 0 | 40 | 21845 | +| 32 | -21846 | 0 | 40 | 21845 | +| 32 | -21846 | 0 | 41 | 21845 | +| 32 | -21846 | 0 | 42 | 21845 | +| 32 | -21846 | 0 | 43 | -21846 | +| 32 | -21846 | 0 | 44 | 21845 | +| 32 | -21846 | 0 | 45 | 21845 | +| 32 | -21846 | 0 | 46 | 21845 | +| 32 | -21846 | 0 | 47 | 21845 | +| 32+ | 21845 | 1 | 43 | -21846 | +| 33 | 21845 | 1 | 43 | 21845 | +| 33+ | -21846 | 1 | 44 | 21845 | +| 34 | -21846 | 1 | 44 | -21846 | +| 34+ | -21846 | 0 | 40 | 21845 | +| 35 | -21846 | 0 | 40 | 21845 | +| 35 | -21846 | 0 | 41 | 21845 | +| 35 | -21846 | 0 | 42 | 21845 | +| 35 | -21846 | 0 | 43 | 21845 | +| 35 | -21846 | 0 | 44 | -21846 | +| 35 | -21846 | 0 | 45 | 21845 | +| 35 | -21846 | 0 | 46 | 21845 | +| 35 | -21846 | 0 | 47 | 21845 | +| 35+ | 21845 | 1 | 44 | -21846 | +| 36 | 21845 | 1 | 44 | 21845 | +| 36+ | -21846 | 1 | 45 | 21845 | +| 37 | -21846 | 1 | 45 | -21846 | +| 37+ | -21846 | 0 | 40 | 21845 | +| 38 | -21846 | 0 | 40 | 21845 | +| 38 | -21846 | 0 | 41 | 21845 | +| 38 | -21846 | 0 | 42 | 21845 | +| 38 | -21846 | 0 | 43 | 21845 | +| 38 | -21846 | 0 | 44 | 21845 | +| 38 | -21846 | 0 | 45 | -21846 | +| 38 | -21846 | 0 | 46 | 21845 | +| 38 | -21846 | 0 | 47 | 21845 | +| 38+ | 21845 | 1 | 45 | -21846 | +| 39 | 21845 | 1 | 45 | 21845 | +| 39+ | -21846 | 1 | 46 | 21845 | +| 40 | -21846 | 1 | 46 | -21846 | +| 40+ | -21846 | 0 | 40 | 21845 | +| 41 | -21846 | 0 | 40 | 21845 | +| 41 | -21846 | 0 | 41 | 21845 | +| 41 | -21846 | 0 | 42 | 21845 | +| 41 | -21846 | 0 | 43 | 21845 | +| 41 | -21846 | 0 | 44 | 21845 | +| 41 | -21846 | 0 | 45 | 21845 | +| 41 | -21846 | 0 | 46 | -21846 | +| 41 | -21846 | 0 | 47 | 21845 | +| 41+ | 21845 | 1 | 46 | -21846 | +| 42 | 21845 | 1 | 46 | 21845 | +| 42+ | -21846 | 1 | 47 | 21845 | +| 43 | -21846 | 1 | 47 | -21846 | +| 43+ | -21846 | 0 | 40 | 21845 | +| 44 | -21846 | 0 | 40 | 21845 | +| 44 | -21846 | 0 | 41 | 21845 | +| 44 | -21846 | 0 | 42 | 21845 | +| 44 | -21846 | 0 | 43 | 21845 | +| 44 | -21846 | 0 | 44 | 21845 | +| 44 | -21846 | 0 | 45 | 21845 | +| 44 | -21846 | 0 | 46 | 21845 | +| 44 | -21846 | 0 | 47 | -21846 | +| 44+ | 21845 | 1 | 47 | -21846 | +| 45 | 21845 | 1 | 47 | 21845 | +| 45+ | 21845 | 0 | 40 | 21845 | +| 46 | 21845 | 0 | 40 | 21845 | +| 46 | 21845 | 0 | 41 | 21845 | +| 46 | 21845 | 0 | 42 | 21845 | +| 46 | 21845 | 0 | 43 | 21845 | +| 46 | 21845 | 0 | 44 | 21845 | +| 46 | 21845 | 0 | 45 | 21845 | +| 46 | 21845 | 0 | 46 | 21845 | +| 46 | 21845 | 0 | 47 | 21845 | +| 46+ | 21845 | 0 | 5 | 0 | +| 47 | 21845 | 0 | 5 | 0 | +| 47 | 21845 | 0 | 13 | 1313 | +| 47 | 21845 | 0 | 21 | 0 | +| 47 | 21845 | 0 | 29 | 0 | +| 47 | 21845 | 0 | 37 | 0 | +| 47 | 21845 | 0 | 45 | 21845 | +| 47 | 21845 | 0 | 53 | 0 | +| 47 | 21845 | 0 | 61 | 0 | +| 47+ | 21845 | 1 | 5 | 0 | +| 48 | 21845 | 1 | 5 | 21845 | +| 48+ | 21845 | 1 | 13 | 1313 | +| 49 | 21845 | 1 | 13 | 21845 | +| 49+ | 21845 | 1 | 21 | 0 | +| 50 | 21845 | 1 | 21 | 21845 | +| 50+ | 21845 | 1 | 29 | 0 | +| 51 | 21845 | 1 | 29 | 21845 | +| 51+ | 21845 | 1 | 37 | 0 | +| 52 | 21845 | 1 | 37 | 21845 | +| 52+ | 21845 | 1 | 45 | 21845 | +| 53 | 21845 | 1 | 45 | 21845 | +| 53+ | 21845 | 1 | 53 | 0 | +| 54 | 21845 | 1 | 53 | 21845 | +| 54+ | 21845 | 1 | 61 | 0 | +| 55 | 21845 | 1 | 61 | 21845 | +| 55+ | 21845 | 0 | 5 | 21845 | +| 56 | 21845 | 0 | 5 | 21845 | +| 56 | 21845 | 0 | 13 | 21845 | +| 56 | 21845 | 0 | 21 | 21845 | +| 56 | 21845 | 0 | 29 | 21845 | +| 56 | 21845 | 0 | 37 | 21845 | +| 56 | 21845 | 0 | 45 | 21845 | +| 56 | 21845 | 0 | 53 | 21845 | +| 56 | 21845 | 0 | 61 | 21845 | +| 56+ | -21846 | 1 | 5 | 21845 | +| 57 | -21846 | 1 | 5 | -21846 | +| 57+ | -21846 | 0 | 5 | -21846 | +| 58 | -21846 | 0 | 5 | -21846 | +| 58 | -21846 | 0 | 13 | 21845 | +| 58 | -21846 | 0 | 21 | 21845 | +| 58 | -21846 | 0 | 29 | 21845 | +| 58 | -21846 | 0 | 37 | 21845 | +| 58 | -21846 | 0 | 45 | 21845 | +| 58 | -21846 | 0 | 53 | 21845 | +| 58 | -21846 | 0 | 61 | 21845 | +| 58+ | 21845 | 1 | 5 | -21846 | +| 59 | 21845 | 1 | 5 | 21845 | +| 59+ | -21846 | 1 | 13 | 21845 | +| 60 | -21846 | 1 | 13 | -21846 | +| 60+ | -21846 | 0 | 5 | 21845 | +| 61 | -21846 | 0 | 5 | 21845 | +| 61 | -21846 | 0 | 13 | -21846 | +| 61 | -21846 | 0 | 21 | 21845 | +| 61 | -21846 | 0 | 29 | 21845 | +| 61 | -21846 | 0 | 37 | 21845 | +| 61 | -21846 | 0 | 45 | 21845 | +| 61 | -21846 | 0 | 53 | 21845 | +| 61 | -21846 | 0 | 61 | 21845 | +| 61+ | 21845 | 1 | 13 | -21846 | +| 62 | 21845 | 1 | 13 | 21845 | +| 62+ | -21846 | 1 | 21 | 21845 | +| 63 | -21846 | 1 | 21 | -21846 | +| 63+ | -21846 | 0 | 5 | 21845 | +| 64 | -21846 | 0 | 5 | 21845 | +| 64 | -21846 | 0 | 13 | 21845 | +| 64 | -21846 | 0 | 21 | -21846 | +| 64 | -21846 | 0 | 29 | 21845 | +| 64 | -21846 | 0 | 37 | 21845 | +| 64 | -21846 | 0 | 45 | 21845 | +| 64 | -21846 | 0 | 53 | 21845 | +| 64 | -21846 | 0 | 61 | 21845 | +| 64+ | 21845 | 1 | 21 | -21846 | +| 65 | 21845 | 1 | 21 | 21845 | +| 65+ | -21846 | 1 | 29 | 21845 | +| 66 | -21846 | 1 | 29 | -21846 | +| 66+ | -21846 | 0 | 5 | 21845 | +| 67 | -21846 | 0 | 5 | 21845 | +| 67 | -21846 | 0 | 13 | 21845 | +| 67 | -21846 | 0 | 21 | 21845 | +| 67 | -21846 | 0 | 29 | -21846 | +| 67 | -21846 | 0 | 37 | 21845 | +| 67 | -21846 | 0 | 45 | 21845 | +| 67 | -21846 | 0 | 53 | 21845 | +| 67 | -21846 | 0 | 61 | 21845 | +| 67+ | 21845 | 1 | 29 | -21846 | +| 68 | 21845 | 1 | 29 | 21845 | +| 68+ | -21846 | 1 | 37 | 21845 | +| 69 | -21846 | 1 | 37 | -21846 | +| 69+ | -21846 | 0 | 5 | 21845 | +| 70 | -21846 | 0 | 5 | 21845 | +| 70 | -21846 | 0 | 13 | 21845 | +| 70 | -21846 | 0 | 21 | 21845 | +| 70 | -21846 | 0 | 29 | 21845 | +| 70 | -21846 | 0 | 37 | -21846 | +| 70 | -21846 | 0 | 45 | 21845 | +| 70 | -21846 | 0 | 53 | 21845 | +| 70 | -21846 | 0 | 61 | 21845 | +| 70+ | 21845 | 1 | 37 | -21846 | +| 71 | 21845 | 1 | 37 | 21845 | +| 71+ | -21846 | 1 | 45 | 21845 | +| 72 | -21846 | 1 | 45 | -21846 | +| 72+ | -21846 | 0 | 5 | 21845 | +| 73 | -21846 | 0 | 5 | 21845 | +| 73 | -21846 | 0 | 13 | 21845 | +| 73 | -21846 | 0 | 21 | 21845 | +| 73 | -21846 | 0 | 29 | 21845 | +| 73 | -21846 | 0 | 37 | 21845 | +| 73 | -21846 | 0 | 45 | -21846 | +| 73 | -21846 | 0 | 53 | 21845 | +| 73 | -21846 | 0 | 61 | 21845 | +| 73+ | 21845 | 1 | 45 | -21846 | +| 74 | 21845 | 1 | 45 | 21845 | +| 74+ | -21846 | 1 | 53 | 21845 | +| 75 | -21846 | 1 | 53 | -21846 | +| 75+ | -21846 | 0 | 5 | 21845 | +| 76 | -21846 | 0 | 5 | 21845 | +| 76 | -21846 | 0 | 13 | 21845 | +| 76 | -21846 | 0 | 21 | 21845 | +| 76 | -21846 | 0 | 29 | 21845 | +| 76 | -21846 | 0 | 37 | 21845 | +| 76 | -21846 | 0 | 45 | 21845 | +| 76 | -21846 | 0 | 53 | -21846 | +| 76 | -21846 | 0 | 61 | 21845 | +| 76+ | 21845 | 1 | 53 | -21846 | +| 77 | 21845 | 1 | 53 | 21845 | +| 77+ | -21846 | 1 | 61 | 21845 | +| 78 | -21846 | 1 | 61 | -21846 | +| 78+ | -21846 | 0 | 5 | 21845 | +| 79 | -21846 | 0 | 5 | 21845 | +| 79 | -21846 | 0 | 13 | 21845 | +| 79 | -21846 | 0 | 21 | 21845 | +| 79 | -21846 | 0 | 29 | 21845 | +| 79 | -21846 | 0 | 37 | 21845 | +| 79 | -21846 | 0 | 45 | 21845 | +| 79 | -21846 | 0 | 53 | 21845 | +| 79 | -21846 | 0 | 61 | -21846 | +| 79+ | 21845 | 1 | 61 | -21846 | +| 80 | 21845 | 1 | 61 | 21845 | +| 80+ | 21845 | 0 | 5 | 21845 | +| 81 | 21845 | 0 | 5 | 21845 | +| 81 | 21845 | 0 | 13 | 21845 | +| 81 | 21845 | 0 | 21 | 21845 | +| 81 | 21845 | 0 | 29 | 21845 | +| 81 | 21845 | 0 | 37 | 21845 | +| 81 | 21845 | 0 | 45 | 21845 | +| 81 | 21845 | 0 | 53 | 21845 | +| 81 | 21845 | 0 | 61 | 21845 | diff --git a/projects/03/a/RAM64.tst b/projects/03/a/RAM64.tst new file mode 100755 index 0000000..e1a1409 --- /dev/null +++ b/projects/03/a/RAM64.tst @@ -0,0 +1,1026 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/RAM64.tst + +load RAM64.hdl, +output-file RAM64.out, +compare-to RAM64.cmp, +output-list time%S1.4.1 in%D1.6.1 load%B2.1.2 address%D2.3.2 out%D1.6.1; + +set in 0, +set load 0, +set address 0, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set in 1313, +set load 0, +tick, +output; +tock, +output; + +set load 1, +set address 13, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; + +set in 4747, +set address 47, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 13, +eval, +output; + +set in 6363, +tick, +output; +tock, +output; + +set load 1, +set address 63, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 47, +eval, +output; + +set address 63, +eval, +output; + + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +tick, +output, +tock, +output; +set address %B101010, +tick, +output, +tock, +output; +set address %B101011, +tick, +output, +tock, +output; +set address %B101100, +tick, +output, +tock, +output; +set address %B101101, +tick, +output, +tock, +output; +set address %B101110, +tick, +output, +tock, +output; +set address %B101111, +tick, +output, +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101000, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101000, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101001, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101001, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101011, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101011, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101100, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101100, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101110, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101110, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101111, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + +set load 1, +set address %B101111, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B101000, +tick, +output; +tock, +output; +set address %B101001, +eval, +output; +set address %B101010, +eval, +output; +set address %B101011, +eval, +output; +set address %B101100, +eval, +output; +set address %B101101, +eval, +output; +set address %B101110, +eval, +output; +set address %B101111, +eval, +output; + + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +tick, +output, +tock, +output; +set address %B010101, +tick, +output, +tock, +output; +set address %B011101, +tick, +output, +tock, +output; +set address %B100101, +tick, +output, +tock, +output; +set address %B101101, +tick, +output, +tock, +output; +set address %B110101, +tick, +output, +tock, +output; +set address %B111101, +tick, +output, +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B000101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B000101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B001101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B001101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B011101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B011101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B100101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B100101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B101101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B110101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B110101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B111101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; + +set load 1, +set address %B111101, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B000101, +tick, +output; +tock, +output; +set address %B001101, +eval, +output; +set address %B010101, +eval, +output; +set address %B011101, +eval, +output; +set address %B100101, +eval, +output; +set address %B101101, +eval, +output; +set address %B110101, +eval, +output; +set address %B111101, +eval, +output; diff --git a/projects/03/a/RAM8.cmp b/projects/03/a/RAM8.cmp new file mode 100755 index 0000000..536c6ef --- /dev/null +++ b/projects/03/a/RAM8.cmp @@ -0,0 +1,173 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 11111 | 0 | 0 | 0 | +| 3 | 11111 | 0 | 0 | 0 | +| 3+ | 11111 | 1 | 1 | 0 | +| 4 | 11111 | 1 | 1 | 11111 | +| 4+ | 11111 | 0 | 0 | 0 | +| 5 | 11111 | 0 | 0 | 0 | +| 5+ | 3333 | 0 | 3 | 0 | +| 6 | 3333 | 0 | 3 | 0 | +| 6+ | 3333 | 1 | 3 | 0 | +| 7 | 3333 | 1 | 3 | 3333 | +| 7+ | 3333 | 0 | 3 | 3333 | +| 8 | 3333 | 0 | 3 | 3333 | +| 8 | 3333 | 0 | 1 | 11111 | +| 8+ | 7777 | 0 | 1 | 11111 | +| 9 | 7777 | 0 | 1 | 11111 | +| 9+ | 7777 | 1 | 7 | 0 | +| 10 | 7777 | 1 | 7 | 7777 | +| 10+ | 7777 | 0 | 7 | 7777 | +| 11 | 7777 | 0 | 7 | 7777 | +| 11 | 7777 | 0 | 3 | 3333 | +| 11 | 7777 | 0 | 7 | 7777 | +| 11+ | 7777 | 0 | 0 | 0 | +| 12 | 7777 | 0 | 0 | 0 | +| 12 | 7777 | 0 | 1 | 11111 | +| 12 | 7777 | 0 | 2 | 0 | +| 12 | 7777 | 0 | 3 | 3333 | +| 12 | 7777 | 0 | 4 | 0 | +| 12 | 7777 | 0 | 5 | 0 | +| 12 | 7777 | 0 | 6 | 0 | +| 12 | 7777 | 0 | 7 | 7777 | +| 12+ | 21845 | 1 | 0 | 0 | +| 13 | 21845 | 1 | 0 | 21845 | +| 13+ | 21845 | 1 | 1 | 11111 | +| 14 | 21845 | 1 | 1 | 21845 | +| 14+ | 21845 | 1 | 2 | 0 | +| 15 | 21845 | 1 | 2 | 21845 | +| 15+ | 21845 | 1 | 3 | 3333 | +| 16 | 21845 | 1 | 3 | 21845 | +| 16+ | 21845 | 1 | 4 | 0 | +| 17 | 21845 | 1 | 4 | 21845 | +| 17+ | 21845 | 1 | 5 | 0 | +| 18 | 21845 | 1 | 5 | 21845 | +| 18+ | 21845 | 1 | 6 | 0 | +| 19 | 21845 | 1 | 6 | 21845 | +| 19+ | 21845 | 1 | 7 | 7777 | +| 20 | 21845 | 1 | 7 | 21845 | +| 20+ | 21845 | 0 | 0 | 21845 | +| 21 | 21845 | 0 | 0 | 21845 | +| 21 | 21845 | 0 | 1 | 21845 | +| 21 | 21845 | 0 | 2 | 21845 | +| 21 | 21845 | 0 | 3 | 21845 | +| 21 | 21845 | 0 | 4 | 21845 | +| 21 | 21845 | 0 | 5 | 21845 | +| 21 | 21845 | 0 | 6 | 21845 | +| 21 | 21845 | 0 | 7 | 21845 | +| 21+ | -21846 | 1 | 0 | 21845 | +| 22 | -21846 | 1 | 0 | -21846 | +| 22+ | -21846 | 0 | 0 | -21846 | +| 23 | -21846 | 0 | 0 | -21846 | +| 23 | -21846 | 0 | 1 | 21845 | +| 23 | -21846 | 0 | 2 | 21845 | +| 23 | -21846 | 0 | 3 | 21845 | +| 23 | -21846 | 0 | 4 | 21845 | +| 23 | -21846 | 0 | 5 | 21845 | +| 23 | -21846 | 0 | 6 | 21845 | +| 23 | -21846 | 0 | 7 | 21845 | +| 23+ | 21845 | 1 | 0 | -21846 | +| 24 | 21845 | 1 | 0 | 21845 | +| 24+ | -21846 | 1 | 1 | 21845 | +| 25 | -21846 | 1 | 1 | -21846 | +| 25+ | -21846 | 0 | 0 | 21845 | +| 26 | -21846 | 0 | 0 | 21845 | +| 26 | -21846 | 0 | 1 | -21846 | +| 26 | -21846 | 0 | 2 | 21845 | +| 26 | -21846 | 0 | 3 | 21845 | +| 26 | -21846 | 0 | 4 | 21845 | +| 26 | -21846 | 0 | 5 | 21845 | +| 26 | -21846 | 0 | 6 | 21845 | +| 26 | -21846 | 0 | 7 | 21845 | +| 26+ | 21845 | 1 | 1 | -21846 | +| 27 | 21845 | 1 | 1 | 21845 | +| 27+ | -21846 | 1 | 2 | 21845 | +| 28 | -21846 | 1 | 2 | -21846 | +| 28+ | -21846 | 0 | 0 | 21845 | +| 29 | -21846 | 0 | 0 | 21845 | +| 29 | -21846 | 0 | 1 | 21845 | +| 29 | -21846 | 0 | 2 | -21846 | +| 29 | -21846 | 0 | 3 | 21845 | +| 29 | -21846 | 0 | 4 | 21845 | +| 29 | -21846 | 0 | 5 | 21845 | +| 29 | -21846 | 0 | 6 | 21845 | +| 29 | -21846 | 0 | 7 | 21845 | +| 29+ | 21845 | 1 | 2 | -21846 | +| 30 | 21845 | 1 | 2 | 21845 | +| 30+ | -21846 | 1 | 3 | 21845 | +| 31 | -21846 | 1 | 3 | -21846 | +| 31+ | -21846 | 0 | 0 | 21845 | +| 32 | -21846 | 0 | 0 | 21845 | +| 32 | -21846 | 0 | 1 | 21845 | +| 32 | -21846 | 0 | 2 | 21845 | +| 32 | -21846 | 0 | 3 | -21846 | +| 32 | -21846 | 0 | 4 | 21845 | +| 32 | -21846 | 0 | 5 | 21845 | +| 32 | -21846 | 0 | 6 | 21845 | +| 32 | -21846 | 0 | 7 | 21845 | +| 32+ | 21845 | 1 | 3 | -21846 | +| 33 | 21845 | 1 | 3 | 21845 | +| 33+ | -21846 | 1 | 4 | 21845 | +| 34 | -21846 | 1 | 4 | -21846 | +| 34+ | -21846 | 0 | 0 | 21845 | +| 35 | -21846 | 0 | 0 | 21845 | +| 35 | -21846 | 0 | 1 | 21845 | +| 35 | -21846 | 0 | 2 | 21845 | +| 35 | -21846 | 0 | 3 | 21845 | +| 35 | -21846 | 0 | 4 | -21846 | +| 35 | -21846 | 0 | 5 | 21845 | +| 35 | -21846 | 0 | 6 | 21845 | +| 35 | -21846 | 0 | 7 | 21845 | +| 35+ | 21845 | 1 | 4 | -21846 | +| 36 | 21845 | 1 | 4 | 21845 | +| 36+ | -21846 | 1 | 5 | 21845 | +| 37 | -21846 | 1 | 5 | -21846 | +| 37+ | -21846 | 0 | 0 | 21845 | +| 38 | -21846 | 0 | 0 | 21845 | +| 38 | -21846 | 0 | 1 | 21845 | +| 38 | -21846 | 0 | 2 | 21845 | +| 38 | -21846 | 0 | 3 | 21845 | +| 38 | -21846 | 0 | 4 | 21845 | +| 38 | -21846 | 0 | 5 | -21846 | +| 38 | -21846 | 0 | 6 | 21845 | +| 38 | -21846 | 0 | 7 | 21845 | +| 38+ | 21845 | 1 | 5 | -21846 | +| 39 | 21845 | 1 | 5 | 21845 | +| 39+ | -21846 | 1 | 6 | 21845 | +| 40 | -21846 | 1 | 6 | -21846 | +| 40+ | -21846 | 0 | 0 | 21845 | +| 41 | -21846 | 0 | 0 | 21845 | +| 41 | -21846 | 0 | 1 | 21845 | +| 41 | -21846 | 0 | 2 | 21845 | +| 41 | -21846 | 0 | 3 | 21845 | +| 41 | -21846 | 0 | 4 | 21845 | +| 41 | -21846 | 0 | 5 | 21845 | +| 41 | -21846 | 0 | 6 | -21846 | +| 41 | -21846 | 0 | 7 | 21845 | +| 41+ | 21845 | 1 | 6 | -21846 | +| 42 | 21845 | 1 | 6 | 21845 | +| 42+ | -21846 | 1 | 7 | 21845 | +| 43 | -21846 | 1 | 7 | -21846 | +| 43+ | -21846 | 0 | 0 | 21845 | +| 44 | -21846 | 0 | 0 | 21845 | +| 44 | -21846 | 0 | 1 | 21845 | +| 44 | -21846 | 0 | 2 | 21845 | +| 44 | -21846 | 0 | 3 | 21845 | +| 44 | -21846 | 0 | 4 | 21845 | +| 44 | -21846 | 0 | 5 | 21845 | +| 44 | -21846 | 0 | 6 | 21845 | +| 44 | -21846 | 0 | 7 | -21846 | +| 44+ | 21845 | 1 | 7 | -21846 | +| 45 | 21845 | 1 | 7 | 21845 | +| 45+ | 21845 | 0 | 0 | 21845 | +| 46 | 21845 | 0 | 0 | 21845 | +| 46 | 21845 | 0 | 1 | 21845 | +| 46 | 21845 | 0 | 2 | 21845 | +| 46 | 21845 | 0 | 3 | 21845 | +| 46 | 21845 | 0 | 4 | 21845 | +| 46 | 21845 | 0 | 5 | 21845 | +| 46 | 21845 | 0 | 6 | 21845 | +| 46 | 21845 | 0 | 7 | 21845 | diff --git a/projects/03/a/RAM8.hdl b/projects/03/a/RAM8.hdl new file mode 100755 index 0000000..9562736 --- /dev/null +++ b/projects/03/a/RAM8.hdl @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/RAM8.hdl + +/** + * Memory of 8 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM8 { + IN in[16], load, address[3]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address,a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + + Register(in=in,load=a,out=outa); + Register(in=in,load=b,out=outb); + Register(in=in,load=c,out=outc); + Register(in=in,load=d,out=outd); + Register(in=in,load=e,out=oute); + Register(in=in,load=f,out=outf); + Register(in=in,load=g,out=outg); + Register(in=in,load=h,out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address,out=out); +} \ No newline at end of file diff --git a/projects/03/a/RAM8.out b/projects/03/a/RAM8.out new file mode 100755 index 0000000..536c6ef --- /dev/null +++ b/projects/03/a/RAM8.out @@ -0,0 +1,173 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 11111 | 0 | 0 | 0 | +| 3 | 11111 | 0 | 0 | 0 | +| 3+ | 11111 | 1 | 1 | 0 | +| 4 | 11111 | 1 | 1 | 11111 | +| 4+ | 11111 | 0 | 0 | 0 | +| 5 | 11111 | 0 | 0 | 0 | +| 5+ | 3333 | 0 | 3 | 0 | +| 6 | 3333 | 0 | 3 | 0 | +| 6+ | 3333 | 1 | 3 | 0 | +| 7 | 3333 | 1 | 3 | 3333 | +| 7+ | 3333 | 0 | 3 | 3333 | +| 8 | 3333 | 0 | 3 | 3333 | +| 8 | 3333 | 0 | 1 | 11111 | +| 8+ | 7777 | 0 | 1 | 11111 | +| 9 | 7777 | 0 | 1 | 11111 | +| 9+ | 7777 | 1 | 7 | 0 | +| 10 | 7777 | 1 | 7 | 7777 | +| 10+ | 7777 | 0 | 7 | 7777 | +| 11 | 7777 | 0 | 7 | 7777 | +| 11 | 7777 | 0 | 3 | 3333 | +| 11 | 7777 | 0 | 7 | 7777 | +| 11+ | 7777 | 0 | 0 | 0 | +| 12 | 7777 | 0 | 0 | 0 | +| 12 | 7777 | 0 | 1 | 11111 | +| 12 | 7777 | 0 | 2 | 0 | +| 12 | 7777 | 0 | 3 | 3333 | +| 12 | 7777 | 0 | 4 | 0 | +| 12 | 7777 | 0 | 5 | 0 | +| 12 | 7777 | 0 | 6 | 0 | +| 12 | 7777 | 0 | 7 | 7777 | +| 12+ | 21845 | 1 | 0 | 0 | +| 13 | 21845 | 1 | 0 | 21845 | +| 13+ | 21845 | 1 | 1 | 11111 | +| 14 | 21845 | 1 | 1 | 21845 | +| 14+ | 21845 | 1 | 2 | 0 | +| 15 | 21845 | 1 | 2 | 21845 | +| 15+ | 21845 | 1 | 3 | 3333 | +| 16 | 21845 | 1 | 3 | 21845 | +| 16+ | 21845 | 1 | 4 | 0 | +| 17 | 21845 | 1 | 4 | 21845 | +| 17+ | 21845 | 1 | 5 | 0 | +| 18 | 21845 | 1 | 5 | 21845 | +| 18+ | 21845 | 1 | 6 | 0 | +| 19 | 21845 | 1 | 6 | 21845 | +| 19+ | 21845 | 1 | 7 | 7777 | +| 20 | 21845 | 1 | 7 | 21845 | +| 20+ | 21845 | 0 | 0 | 21845 | +| 21 | 21845 | 0 | 0 | 21845 | +| 21 | 21845 | 0 | 1 | 21845 | +| 21 | 21845 | 0 | 2 | 21845 | +| 21 | 21845 | 0 | 3 | 21845 | +| 21 | 21845 | 0 | 4 | 21845 | +| 21 | 21845 | 0 | 5 | 21845 | +| 21 | 21845 | 0 | 6 | 21845 | +| 21 | 21845 | 0 | 7 | 21845 | +| 21+ | -21846 | 1 | 0 | 21845 | +| 22 | -21846 | 1 | 0 | -21846 | +| 22+ | -21846 | 0 | 0 | -21846 | +| 23 | -21846 | 0 | 0 | -21846 | +| 23 | -21846 | 0 | 1 | 21845 | +| 23 | -21846 | 0 | 2 | 21845 | +| 23 | -21846 | 0 | 3 | 21845 | +| 23 | -21846 | 0 | 4 | 21845 | +| 23 | -21846 | 0 | 5 | 21845 | +| 23 | -21846 | 0 | 6 | 21845 | +| 23 | -21846 | 0 | 7 | 21845 | +| 23+ | 21845 | 1 | 0 | -21846 | +| 24 | 21845 | 1 | 0 | 21845 | +| 24+ | -21846 | 1 | 1 | 21845 | +| 25 | -21846 | 1 | 1 | -21846 | +| 25+ | -21846 | 0 | 0 | 21845 | +| 26 | -21846 | 0 | 0 | 21845 | +| 26 | -21846 | 0 | 1 | -21846 | +| 26 | -21846 | 0 | 2 | 21845 | +| 26 | -21846 | 0 | 3 | 21845 | +| 26 | -21846 | 0 | 4 | 21845 | +| 26 | -21846 | 0 | 5 | 21845 | +| 26 | -21846 | 0 | 6 | 21845 | +| 26 | -21846 | 0 | 7 | 21845 | +| 26+ | 21845 | 1 | 1 | -21846 | +| 27 | 21845 | 1 | 1 | 21845 | +| 27+ | -21846 | 1 | 2 | 21845 | +| 28 | -21846 | 1 | 2 | -21846 | +| 28+ | -21846 | 0 | 0 | 21845 | +| 29 | -21846 | 0 | 0 | 21845 | +| 29 | -21846 | 0 | 1 | 21845 | +| 29 | -21846 | 0 | 2 | -21846 | +| 29 | -21846 | 0 | 3 | 21845 | +| 29 | -21846 | 0 | 4 | 21845 | +| 29 | -21846 | 0 | 5 | 21845 | +| 29 | -21846 | 0 | 6 | 21845 | +| 29 | -21846 | 0 | 7 | 21845 | +| 29+ | 21845 | 1 | 2 | -21846 | +| 30 | 21845 | 1 | 2 | 21845 | +| 30+ | -21846 | 1 | 3 | 21845 | +| 31 | -21846 | 1 | 3 | -21846 | +| 31+ | -21846 | 0 | 0 | 21845 | +| 32 | -21846 | 0 | 0 | 21845 | +| 32 | -21846 | 0 | 1 | 21845 | +| 32 | -21846 | 0 | 2 | 21845 | +| 32 | -21846 | 0 | 3 | -21846 | +| 32 | -21846 | 0 | 4 | 21845 | +| 32 | -21846 | 0 | 5 | 21845 | +| 32 | -21846 | 0 | 6 | 21845 | +| 32 | -21846 | 0 | 7 | 21845 | +| 32+ | 21845 | 1 | 3 | -21846 | +| 33 | 21845 | 1 | 3 | 21845 | +| 33+ | -21846 | 1 | 4 | 21845 | +| 34 | -21846 | 1 | 4 | -21846 | +| 34+ | -21846 | 0 | 0 | 21845 | +| 35 | -21846 | 0 | 0 | 21845 | +| 35 | -21846 | 0 | 1 | 21845 | +| 35 | -21846 | 0 | 2 | 21845 | +| 35 | -21846 | 0 | 3 | 21845 | +| 35 | -21846 | 0 | 4 | -21846 | +| 35 | -21846 | 0 | 5 | 21845 | +| 35 | -21846 | 0 | 6 | 21845 | +| 35 | -21846 | 0 | 7 | 21845 | +| 35+ | 21845 | 1 | 4 | -21846 | +| 36 | 21845 | 1 | 4 | 21845 | +| 36+ | -21846 | 1 | 5 | 21845 | +| 37 | -21846 | 1 | 5 | -21846 | +| 37+ | -21846 | 0 | 0 | 21845 | +| 38 | -21846 | 0 | 0 | 21845 | +| 38 | -21846 | 0 | 1 | 21845 | +| 38 | -21846 | 0 | 2 | 21845 | +| 38 | -21846 | 0 | 3 | 21845 | +| 38 | -21846 | 0 | 4 | 21845 | +| 38 | -21846 | 0 | 5 | -21846 | +| 38 | -21846 | 0 | 6 | 21845 | +| 38 | -21846 | 0 | 7 | 21845 | +| 38+ | 21845 | 1 | 5 | -21846 | +| 39 | 21845 | 1 | 5 | 21845 | +| 39+ | -21846 | 1 | 6 | 21845 | +| 40 | -21846 | 1 | 6 | -21846 | +| 40+ | -21846 | 0 | 0 | 21845 | +| 41 | -21846 | 0 | 0 | 21845 | +| 41 | -21846 | 0 | 1 | 21845 | +| 41 | -21846 | 0 | 2 | 21845 | +| 41 | -21846 | 0 | 3 | 21845 | +| 41 | -21846 | 0 | 4 | 21845 | +| 41 | -21846 | 0 | 5 | 21845 | +| 41 | -21846 | 0 | 6 | -21846 | +| 41 | -21846 | 0 | 7 | 21845 | +| 41+ | 21845 | 1 | 6 | -21846 | +| 42 | 21845 | 1 | 6 | 21845 | +| 42+ | -21846 | 1 | 7 | 21845 | +| 43 | -21846 | 1 | 7 | -21846 | +| 43+ | -21846 | 0 | 0 | 21845 | +| 44 | -21846 | 0 | 0 | 21845 | +| 44 | -21846 | 0 | 1 | 21845 | +| 44 | -21846 | 0 | 2 | 21845 | +| 44 | -21846 | 0 | 3 | 21845 | +| 44 | -21846 | 0 | 4 | 21845 | +| 44 | -21846 | 0 | 5 | 21845 | +| 44 | -21846 | 0 | 6 | 21845 | +| 44 | -21846 | 0 | 7 | -21846 | +| 44+ | 21845 | 1 | 7 | -21846 | +| 45 | 21845 | 1 | 7 | 21845 | +| 45+ | 21845 | 0 | 0 | 21845 | +| 46 | 21845 | 0 | 0 | 21845 | +| 46 | 21845 | 0 | 1 | 21845 | +| 46 | 21845 | 0 | 2 | 21845 | +| 46 | 21845 | 0 | 3 | 21845 | +| 46 | 21845 | 0 | 4 | 21845 | +| 46 | 21845 | 0 | 5 | 21845 | +| 46 | 21845 | 0 | 6 | 21845 | +| 46 | 21845 | 0 | 7 | 21845 | diff --git a/projects/03/a/RAM8.tst b/projects/03/a/RAM8.tst new file mode 100755 index 0000000..9b6069c --- /dev/null +++ b/projects/03/a/RAM8.tst @@ -0,0 +1,560 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/RAM8.tst + +load RAM8.hdl, +output-file RAM8.out, +compare-to RAM8.cmp, +output-list time%S1.4.1 in%D1.6.1 load%B2.1.2 address%D3.1.3 out%D1.6.1; + +set in 0, +set load 0, +set address 0, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set in 11111, +set load 0, +tick, +output; +tock, +output; + +set load 1, +set address 1, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; + +set in 3333, +set address 3, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 1, +eval, +output; + +set in 7777, +tick, +output; +tock, +output; + +set load 1, +set address 7, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 3, +eval, +output; + +set address 7, +eval, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address 0, +tick, +output; +tock, +output; +set address 1, +tick, +output, +tock, +output; +set address 2, +tick, +output, +tock, +output; +set address 3, +tick, +output, +tock, +output; +set address 4, +tick, +output, +tock, +output; +set address 5, +tick, +output, +tock, +output; +set address 6, +tick, +output, +tock, +output; +set address 7, +tick, +output, +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 0, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 0, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address 1, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 1, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address 2, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 2, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address 3, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 3, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address 4, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 4, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address 5, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 5, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address 6, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 6, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address 7, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + +set load 1, +set address 7, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; +set address 1, +eval, +output; +set address 2, +eval, +output; +set address 3, +eval, +output; +set address 4, +eval, +output; +set address 5, +eval, +output; +set address 6, +eval, +output; +set address 7, +eval, +output; + diff --git a/projects/03/a/Register.cmp b/projects/03/a/Register.cmp new file mode 100755 index 0000000..a899f27 --- /dev/null +++ b/projects/03/a/Register.cmp @@ -0,0 +1,149 @@ +| time | in |load | out | +| 0+ | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | +| 2 | 0 | 1 | 0 | +| 2+ | -32123 | 0 | 0 | +| 3 | -32123 | 0 | 0 | +| 3+ | 11111 | 0 | 0 | +| 4 | 11111 | 0 | 0 | +| 4+ | -32123 | 1 | 0 | +| 5 | -32123 | 1 | -32123 | +| 5+ | -32123 | 1 | -32123 | +| 6 | -32123 | 1 | -32123 | +| 6+ | -32123 | 0 | -32123 | +| 7 | -32123 | 0 | -32123 | +| 7+ | 12345 | 1 | -32123 | +| 8 | 12345 | 1 | 12345 | +| 8+ | 0 | 0 | 12345 | +| 9 | 0 | 0 | 12345 | +| 9+ | 0 | 1 | 12345 | +| 10 | 0 | 1 | 0 | +| 10+ | 1 | 0 | 0 | +| 11 | 1 | 0 | 0 | +| 11+ | 1 | 1 | 0 | +| 12 | 1 | 1 | 1 | +| 12+ | 2 | 0 | 1 | +| 13 | 2 | 0 | 1 | +| 13+ | 2 | 1 | 1 | +| 14 | 2 | 1 | 2 | +| 14+ | 4 | 0 | 2 | +| 15 | 4 | 0 | 2 | +| 15+ | 4 | 1 | 2 | +| 16 | 4 | 1 | 4 | +| 16+ | 8 | 0 | 4 | +| 17 | 8 | 0 | 4 | +| 17+ | 8 | 1 | 4 | +| 18 | 8 | 1 | 8 | +| 18+ | 16 | 0 | 8 | +| 19 | 16 | 0 | 8 | +| 19+ | 16 | 1 | 8 | +| 20 | 16 | 1 | 16 | +| 20+ | 32 | 0 | 16 | +| 21 | 32 | 0 | 16 | +| 21+ | 32 | 1 | 16 | +| 22 | 32 | 1 | 32 | +| 22+ | 64 | 0 | 32 | +| 23 | 64 | 0 | 32 | +| 23+ | 64 | 1 | 32 | +| 24 | 64 | 1 | 64 | +| 24+ | 128 | 0 | 64 | +| 25 | 128 | 0 | 64 | +| 25+ | 128 | 1 | 64 | +| 26 | 128 | 1 | 128 | +| 26+ | 256 | 0 | 128 | +| 27 | 256 | 0 | 128 | +| 27+ | 256 | 1 | 128 | +| 28 | 256 | 1 | 256 | +| 28+ | 512 | 0 | 256 | +| 29 | 512 | 0 | 256 | +| 29+ | 512 | 1 | 256 | +| 30 | 512 | 1 | 512 | +| 30+ | 1024 | 0 | 512 | +| 31 | 1024 | 0 | 512 | +| 31+ | 1024 | 1 | 512 | +| 32 | 1024 | 1 | 1024 | +| 32+ | 2048 | 0 | 1024 | +| 33 | 2048 | 0 | 1024 | +| 33+ | 2048 | 1 | 1024 | +| 34 | 2048 | 1 | 2048 | +| 34+ | 4096 | 0 | 2048 | +| 35 | 4096 | 0 | 2048 | +| 35+ | 4096 | 1 | 2048 | +| 36 | 4096 | 1 | 4096 | +| 36+ | 8192 | 0 | 4096 | +| 37 | 8192 | 0 | 4096 | +| 37+ | 8192 | 1 | 4096 | +| 38 | 8192 | 1 | 8192 | +| 38+ | 16384 | 0 | 8192 | +| 39 | 16384 | 0 | 8192 | +| 39+ | 16384 | 1 | 8192 | +| 40 | 16384 | 1 | 16384 | +| 40+ | -32768 | 0 | 16384 | +| 41 | -32768 | 0 | 16384 | +| 41+ | -32768 | 1 | 16384 | +| 42 | -32768 | 1 | -32768 | +| 42+ | -2 | 0 | -32768 | +| 43 | -2 | 0 | -32768 | +| 43+ | -2 | 1 | -32768 | +| 44 | -2 | 1 | -2 | +| 44+ | -3 | 0 | -2 | +| 45 | -3 | 0 | -2 | +| 45+ | -3 | 1 | -2 | +| 46 | -3 | 1 | -3 | +| 46+ | -5 | 0 | -3 | +| 47 | -5 | 0 | -3 | +| 47+ | -5 | 1 | -3 | +| 48 | -5 | 1 | -5 | +| 48+ | -9 | 0 | -5 | +| 49 | -9 | 0 | -5 | +| 49+ | -9 | 1 | -5 | +| 50 | -9 | 1 | -9 | +| 50+ | -17 | 0 | -9 | +| 51 | -17 | 0 | -9 | +| 51+ | -17 | 1 | -9 | +| 52 | -17 | 1 | -17 | +| 52+ | -33 | 0 | -17 | +| 53 | -33 | 0 | -17 | +| 53+ | -33 | 1 | -17 | +| 54 | -33 | 1 | -33 | +| 54+ | -65 | 0 | -33 | +| 55 | -65 | 0 | -33 | +| 55+ | -65 | 1 | -33 | +| 56 | -65 | 1 | -65 | +| 56+ | -129 | 0 | -65 | +| 57 | -129 | 0 | -65 | +| 57+ | -129 | 1 | -65 | +| 58 | -129 | 1 | -129 | +| 58+ | -257 | 0 | -129 | +| 59 | -257 | 0 | -129 | +| 59+ | -257 | 1 | -129 | +| 60 | -257 | 1 | -257 | +| 60+ | -513 | 0 | -257 | +| 61 | -513 | 0 | -257 | +| 61+ | -513 | 1 | -257 | +| 62 | -513 | 1 | -513 | +| 62+ | -1025 | 0 | -513 | +| 63 | -1025 | 0 | -513 | +| 63+ | -1025 | 1 | -513 | +| 64 | -1025 | 1 | -1025 | +| 64+ | -2049 | 0 | -1025 | +| 65 | -2049 | 0 | -1025 | +| 65+ | -2049 | 1 | -1025 | +| 66 | -2049 | 1 | -2049 | +| 66+ | -4097 | 0 | -2049 | +| 67 | -4097 | 0 | -2049 | +| 67+ | -4097 | 1 | -2049 | +| 68 | -4097 | 1 | -4097 | +| 68+ | -8193 | 0 | -4097 | +| 69 | -8193 | 0 | -4097 | +| 69+ | -8193 | 1 | -4097 | +| 70 | -8193 | 1 | -8193 | +| 70+ | -16385 | 0 | -8193 | +| 71 | -16385 | 0 | -8193 | +| 71+ | -16385 | 1 | -8193 | +| 72 | -16385 | 1 | -16385 | +| 72+ | 32767 | 0 | -16385 | +| 73 | 32767 | 0 | -16385 | +| 73+ | 32767 | 1 | -16385 | +| 74 | 32767 | 1 | 32767 | diff --git a/projects/03/a/Register.hdl b/projects/03/a/Register.hdl new file mode 100755 index 0000000..257c7a0 --- /dev/null +++ b/projects/03/a/Register.hdl @@ -0,0 +1,34 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/Register.hdl + +/** + * 16-bit register: + * If load[t] == 1 then out[t+1] = in[t] + * else out does not change + */ + +CHIP Register { + IN in[16], load; + OUT out[16]; + + PARTS: + Bit(in=in[0],load=load,out=out[0]); + Bit(in=in[1],load=load,out=out[1]); + Bit(in=in[2],load=load,out=out[2]); + Bit(in=in[3],load=load,out=out[3]); + Bit(in=in[4],load=load,out=out[4]); + Bit(in=in[5],load=load,out=out[5]); + Bit(in=in[6],load=load,out=out[6]); + Bit(in=in[7],load=load,out=out[7]); + Bit(in=in[8],load=load,out=out[8]); + Bit(in=in[9],load=load,out=out[9]); + Bit(in=in[10],load=load,out=out[10]); + Bit(in=in[11],load=load,out=out[11]); + Bit(in=in[12],load=load,out=out[12]); + Bit(in=in[13],load=load,out=out[13]); + Bit(in=in[14],load=load,out=out[14]); + Bit(in=in[15],load=load,out=out[15]); + +} diff --git a/projects/03/a/Register.out b/projects/03/a/Register.out new file mode 100755 index 0000000..a899f27 --- /dev/null +++ b/projects/03/a/Register.out @@ -0,0 +1,149 @@ +| time | in |load | out | +| 0+ | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | +| 2 | 0 | 1 | 0 | +| 2+ | -32123 | 0 | 0 | +| 3 | -32123 | 0 | 0 | +| 3+ | 11111 | 0 | 0 | +| 4 | 11111 | 0 | 0 | +| 4+ | -32123 | 1 | 0 | +| 5 | -32123 | 1 | -32123 | +| 5+ | -32123 | 1 | -32123 | +| 6 | -32123 | 1 | -32123 | +| 6+ | -32123 | 0 | -32123 | +| 7 | -32123 | 0 | -32123 | +| 7+ | 12345 | 1 | -32123 | +| 8 | 12345 | 1 | 12345 | +| 8+ | 0 | 0 | 12345 | +| 9 | 0 | 0 | 12345 | +| 9+ | 0 | 1 | 12345 | +| 10 | 0 | 1 | 0 | +| 10+ | 1 | 0 | 0 | +| 11 | 1 | 0 | 0 | +| 11+ | 1 | 1 | 0 | +| 12 | 1 | 1 | 1 | +| 12+ | 2 | 0 | 1 | +| 13 | 2 | 0 | 1 | +| 13+ | 2 | 1 | 1 | +| 14 | 2 | 1 | 2 | +| 14+ | 4 | 0 | 2 | +| 15 | 4 | 0 | 2 | +| 15+ | 4 | 1 | 2 | +| 16 | 4 | 1 | 4 | +| 16+ | 8 | 0 | 4 | +| 17 | 8 | 0 | 4 | +| 17+ | 8 | 1 | 4 | +| 18 | 8 | 1 | 8 | +| 18+ | 16 | 0 | 8 | +| 19 | 16 | 0 | 8 | +| 19+ | 16 | 1 | 8 | +| 20 | 16 | 1 | 16 | +| 20+ | 32 | 0 | 16 | +| 21 | 32 | 0 | 16 | +| 21+ | 32 | 1 | 16 | +| 22 | 32 | 1 | 32 | +| 22+ | 64 | 0 | 32 | +| 23 | 64 | 0 | 32 | +| 23+ | 64 | 1 | 32 | +| 24 | 64 | 1 | 64 | +| 24+ | 128 | 0 | 64 | +| 25 | 128 | 0 | 64 | +| 25+ | 128 | 1 | 64 | +| 26 | 128 | 1 | 128 | +| 26+ | 256 | 0 | 128 | +| 27 | 256 | 0 | 128 | +| 27+ | 256 | 1 | 128 | +| 28 | 256 | 1 | 256 | +| 28+ | 512 | 0 | 256 | +| 29 | 512 | 0 | 256 | +| 29+ | 512 | 1 | 256 | +| 30 | 512 | 1 | 512 | +| 30+ | 1024 | 0 | 512 | +| 31 | 1024 | 0 | 512 | +| 31+ | 1024 | 1 | 512 | +| 32 | 1024 | 1 | 1024 | +| 32+ | 2048 | 0 | 1024 | +| 33 | 2048 | 0 | 1024 | +| 33+ | 2048 | 1 | 1024 | +| 34 | 2048 | 1 | 2048 | +| 34+ | 4096 | 0 | 2048 | +| 35 | 4096 | 0 | 2048 | +| 35+ | 4096 | 1 | 2048 | +| 36 | 4096 | 1 | 4096 | +| 36+ | 8192 | 0 | 4096 | +| 37 | 8192 | 0 | 4096 | +| 37+ | 8192 | 1 | 4096 | +| 38 | 8192 | 1 | 8192 | +| 38+ | 16384 | 0 | 8192 | +| 39 | 16384 | 0 | 8192 | +| 39+ | 16384 | 1 | 8192 | +| 40 | 16384 | 1 | 16384 | +| 40+ | -32768 | 0 | 16384 | +| 41 | -32768 | 0 | 16384 | +| 41+ | -32768 | 1 | 16384 | +| 42 | -32768 | 1 | -32768 | +| 42+ | -2 | 0 | -32768 | +| 43 | -2 | 0 | -32768 | +| 43+ | -2 | 1 | -32768 | +| 44 | -2 | 1 | -2 | +| 44+ | -3 | 0 | -2 | +| 45 | -3 | 0 | -2 | +| 45+ | -3 | 1 | -2 | +| 46 | -3 | 1 | -3 | +| 46+ | -5 | 0 | -3 | +| 47 | -5 | 0 | -3 | +| 47+ | -5 | 1 | -3 | +| 48 | -5 | 1 | -5 | +| 48+ | -9 | 0 | -5 | +| 49 | -9 | 0 | -5 | +| 49+ | -9 | 1 | -5 | +| 50 | -9 | 1 | -9 | +| 50+ | -17 | 0 | -9 | +| 51 | -17 | 0 | -9 | +| 51+ | -17 | 1 | -9 | +| 52 | -17 | 1 | -17 | +| 52+ | -33 | 0 | -17 | +| 53 | -33 | 0 | -17 | +| 53+ | -33 | 1 | -17 | +| 54 | -33 | 1 | -33 | +| 54+ | -65 | 0 | -33 | +| 55 | -65 | 0 | -33 | +| 55+ | -65 | 1 | -33 | +| 56 | -65 | 1 | -65 | +| 56+ | -129 | 0 | -65 | +| 57 | -129 | 0 | -65 | +| 57+ | -129 | 1 | -65 | +| 58 | -129 | 1 | -129 | +| 58+ | -257 | 0 | -129 | +| 59 | -257 | 0 | -129 | +| 59+ | -257 | 1 | -129 | +| 60 | -257 | 1 | -257 | +| 60+ | -513 | 0 | -257 | +| 61 | -513 | 0 | -257 | +| 61+ | -513 | 1 | -257 | +| 62 | -513 | 1 | -513 | +| 62+ | -1025 | 0 | -513 | +| 63 | -1025 | 0 | -513 | +| 63+ | -1025 | 1 | -513 | +| 64 | -1025 | 1 | -1025 | +| 64+ | -2049 | 0 | -1025 | +| 65 | -2049 | 0 | -1025 | +| 65+ | -2049 | 1 | -1025 | +| 66 | -2049 | 1 | -2049 | +| 66+ | -4097 | 0 | -2049 | +| 67 | -4097 | 0 | -2049 | +| 67+ | -4097 | 1 | -2049 | +| 68 | -4097 | 1 | -4097 | +| 68+ | -8193 | 0 | -4097 | +| 69 | -8193 | 0 | -4097 | +| 69+ | -8193 | 1 | -4097 | +| 70 | -8193 | 1 | -8193 | +| 70+ | -16385 | 0 | -8193 | +| 71 | -16385 | 0 | -8193 | +| 71+ | -16385 | 1 | -8193 | +| 72 | -16385 | 1 | -16385 | +| 72+ | 32767 | 0 | -16385 | +| 73 | 32767 | 0 | -16385 | +| 73+ | 32767 | 1 | -16385 | +| 74 | 32767 | 1 | 32767 | diff --git a/projects/03/a/Register.tst b/projects/03/a/Register.tst new file mode 100755 index 0000000..aeec166 --- /dev/null +++ b/projects/03/a/Register.tst @@ -0,0 +1,569 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/Register.tst + +load Register.hdl, +output-file Register.out, +compare-to Register.cmp, +output-list time%S1.4.1 in%D1.6.1 load%B2.1.2 out%D1.6.1; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 1, +tick, +output; + +tock, +output; + +set in -32123, +set load 0, +tick, +output; + +tock, +output; + +set in 11111, +set load 0, +tick, +output; + +tock, +output; + +set in -32123, +set load 1, +tick, +output; + +tock, +output; + +set in -32123, +set load 1, +tick, +output; + +tock, +output; + +set in -32123, +set load 0, +tick, +output; + +tock, +output; + +set in 12345, +set load 1, +tick, +output; + +tock, +output; + +set in 0, +set load 0, +tick, +output; + +tock, +output; + +set in 0, +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000000000001, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000000000010, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000000000100, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000000001000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000000010000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000000100000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000001000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000010000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000000100000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000001000000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000010000000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0000100000000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0001000000000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0010000000000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0100000000000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1000000000000000, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111111111110, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111111111101, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111111111011, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111111110111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111111101111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111111011111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111110111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111101111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111111011111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111110111111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111101111111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1111011111111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1110111111111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1101111111111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B1011111111111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; + +set in %B0111111111111111, +set load 0, +tick, +output; + +tock, +output; + +set load 1, +tick, +output; + +tock, +output; diff --git a/projects/03/b/RAM16K.cmp b/projects/03/b/RAM16K.cmp new file mode 100755 index 0000000..a1ad9db --- /dev/null +++ b/projects/03/b/RAM16K.cmp @@ -0,0 +1,320 @@ +| time | in |load | address | out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 4321 | 0 | 0 | 0 | +| 3 | 4321 | 0 | 0 | 0 | +| 3+ | 4321 | 1 | 4321 | 0 | +| 4 | 4321 | 1 | 4321 | 4321 | +| 4+ | 4321 | 0 | 0 | 0 | +| 5 | 4321 | 0 | 0 | 0 | +| 5+ | 12345 | 0 | 12345 | 0 | +| 6 | 12345 | 0 | 12345 | 0 | +| 6+ | 12345 | 1 | 12345 | 0 | +| 7 | 12345 | 1 | 12345 | 12345 | +| 7+ | 12345 | 0 | 12345 | 12345 | +| 8 | 12345 | 0 | 12345 | 12345 | +| 8 | 12345 | 0 | 4321 | 4321 | +| 8+ | 16383 | 0 | 4321 | 4321 | +| 9 | 16383 | 0 | 4321 | 4321 | +| 9+ | 16383 | 1 | 16383 | 0 | +| 10 | 16383 | 1 | 16383 | 16383 | +| 10+ | 16383 | 0 | 16383 | 16383 | +| 11 | 16383 | 0 | 16383 | 16383 | +| 11 | 16383 | 0 | 12345 | 12345 | +| 11 | 16383 | 0 | 16383 | 16383 | +| 11+ | 16383 | 0 | 10920 | 0 | +| 12 | 16383 | 0 | 10920 | 0 | +| 12 | 16383 | 0 | 10921 | 0 | +| 12 | 16383 | 0 | 10922 | 0 | +| 12 | 16383 | 0 | 10923 | 0 | +| 12 | 16383 | 0 | 10924 | 0 | +| 12 | 16383 | 0 | 10925 | 0 | +| 12 | 16383 | 0 | 10926 | 0 | +| 12 | 16383 | 0 | 10927 | 0 | +| 12+ | 21845 | 1 | 10920 | 0 | +| 13 | 21845 | 1 | 10920 | 21845 | +| 13+ | 21845 | 1 | 10921 | 0 | +| 14 | 21845 | 1 | 10921 | 21845 | +| 14+ | 21845 | 1 | 10922 | 0 | +| 15 | 21845 | 1 | 10922 | 21845 | +| 15+ | 21845 | 1 | 10923 | 0 | +| 16 | 21845 | 1 | 10923 | 21845 | +| 16+ | 21845 | 1 | 10924 | 0 | +| 17 | 21845 | 1 | 10924 | 21845 | +| 17+ | 21845 | 1 | 10925 | 0 | +| 18 | 21845 | 1 | 10925 | 21845 | +| 18+ | 21845 | 1 | 10926 | 0 | +| 19 | 21845 | 1 | 10926 | 21845 | +| 19+ | 21845 | 1 | 10927 | 0 | +| 20 | 21845 | 1 | 10927 | 21845 | +| 20+ | 21845 | 0 | 10920 | 21845 | +| 21 | 21845 | 0 | 10920 | 21845 | +| 21 | 21845 | 0 | 10921 | 21845 | +| 21 | 21845 | 0 | 10922 | 21845 | +| 21 | 21845 | 0 | 10923 | 21845 | +| 21 | 21845 | 0 | 10924 | 21845 | +| 21 | 21845 | 0 | 10925 | 21845 | +| 21 | 21845 | 0 | 10926 | 21845 | +| 21 | 21845 | 0 | 10927 | 21845 | +| 21+ | -21846 | 1 | 10920 | 21845 | +| 22 | -21846 | 1 | 10920 | -21846 | +| 22+ | -21846 | 0 | 10920 | -21846 | +| 23 | -21846 | 0 | 10920 | -21846 | +| 23 | -21846 | 0 | 10921 | 21845 | +| 23 | -21846 | 0 | 10922 | 21845 | +| 23 | -21846 | 0 | 10923 | 21845 | +| 23 | -21846 | 0 | 10924 | 21845 | +| 23 | -21846 | 0 | 10925 | 21845 | +| 23 | -21846 | 0 | 10926 | 21845 | +| 23 | -21846 | 0 | 10927 | 21845 | +| 23+ | 21845 | 1 | 10920 | -21846 | +| 24 | 21845 | 1 | 10920 | 21845 | +| 24+ | -21846 | 1 | 10921 | 21845 | +| 25 | -21846 | 1 | 10921 | -21846 | +| 25+ | -21846 | 0 | 10920 | 21845 | +| 26 | -21846 | 0 | 10920 | 21845 | +| 26 | -21846 | 0 | 10921 | -21846 | +| 26 | -21846 | 0 | 10922 | 21845 | +| 26 | -21846 | 0 | 10923 | 21845 | +| 26 | -21846 | 0 | 10924 | 21845 | +| 26 | -21846 | 0 | 10925 | 21845 | +| 26 | -21846 | 0 | 10926 | 21845 | +| 26 | -21846 | 0 | 10927 | 21845 | +| 26+ | 21845 | 1 | 10921 | -21846 | +| 27 | 21845 | 1 | 10921 | 21845 | +| 27+ | -21846 | 1 | 10922 | 21845 | +| 28 | -21846 | 1 | 10922 | -21846 | +| 28+ | -21846 | 0 | 10920 | 21845 | +| 29 | -21846 | 0 | 10920 | 21845 | +| 29 | -21846 | 0 | 10921 | 21845 | +| 29 | -21846 | 0 | 10922 | -21846 | +| 29 | -21846 | 0 | 10923 | 21845 | +| 29 | -21846 | 0 | 10924 | 21845 | +| 29 | -21846 | 0 | 10925 | 21845 | +| 29 | -21846 | 0 | 10926 | 21845 | +| 29 | -21846 | 0 | 10927 | 21845 | +| 29+ | 21845 | 1 | 10922 | -21846 | +| 30 | 21845 | 1 | 10922 | 21845 | +| 30+ | -21846 | 1 | 10923 | 21845 | +| 31 | -21846 | 1 | 10923 | -21846 | +| 31+ | -21846 | 0 | 10920 | 21845 | +| 32 | -21846 | 0 | 10920 | 21845 | +| 32 | -21846 | 0 | 10921 | 21845 | +| 32 | -21846 | 0 | 10922 | 21845 | +| 32 | -21846 | 0 | 10923 | -21846 | +| 32 | -21846 | 0 | 10924 | 21845 | +| 32 | -21846 | 0 | 10925 | 21845 | +| 32 | -21846 | 0 | 10926 | 21845 | +| 32 | -21846 | 0 | 10927 | 21845 | +| 32+ | 21845 | 1 | 10923 | -21846 | +| 33 | 21845 | 1 | 10923 | 21845 | +| 33+ | -21846 | 1 | 10924 | 21845 | +| 34 | -21846 | 1 | 10924 | -21846 | +| 34+ | -21846 | 0 | 10920 | 21845 | +| 35 | -21846 | 0 | 10920 | 21845 | +| 35 | -21846 | 0 | 10921 | 21845 | +| 35 | -21846 | 0 | 10922 | 21845 | +| 35 | -21846 | 0 | 10923 | 21845 | +| 35 | -21846 | 0 | 10924 | -21846 | +| 35 | -21846 | 0 | 10925 | 21845 | +| 35 | -21846 | 0 | 10926 | 21845 | +| 35 | -21846 | 0 | 10927 | 21845 | +| 35+ | 21845 | 1 | 10924 | -21846 | +| 36 | 21845 | 1 | 10924 | 21845 | +| 36+ | -21846 | 1 | 10925 | 21845 | +| 37 | -21846 | 1 | 10925 | -21846 | +| 37+ | -21846 | 0 | 10920 | 21845 | +| 38 | -21846 | 0 | 10920 | 21845 | +| 38 | -21846 | 0 | 10921 | 21845 | +| 38 | -21846 | 0 | 10922 | 21845 | +| 38 | -21846 | 0 | 10923 | 21845 | +| 38 | -21846 | 0 | 10924 | 21845 | +| 38 | -21846 | 0 | 10925 | -21846 | +| 38 | -21846 | 0 | 10926 | 21845 | +| 38 | -21846 | 0 | 10927 | 21845 | +| 38+ | 21845 | 1 | 10925 | -21846 | +| 39 | 21845 | 1 | 10925 | 21845 | +| 39+ | -21846 | 1 | 10926 | 21845 | +| 40 | -21846 | 1 | 10926 | -21846 | +| 40+ | -21846 | 0 | 10920 | 21845 | +| 41 | -21846 | 0 | 10920 | 21845 | +| 41 | -21846 | 0 | 10921 | 21845 | +| 41 | -21846 | 0 | 10922 | 21845 | +| 41 | -21846 | 0 | 10923 | 21845 | +| 41 | -21846 | 0 | 10924 | 21845 | +| 41 | -21846 | 0 | 10925 | 21845 | +| 41 | -21846 | 0 | 10926 | -21846 | +| 41 | -21846 | 0 | 10927 | 21845 | +| 41+ | 21845 | 1 | 10926 | -21846 | +| 42 | 21845 | 1 | 10926 | 21845 | +| 42+ | -21846 | 1 | 10927 | 21845 | +| 43 | -21846 | 1 | 10927 | -21846 | +| 43+ | -21846 | 0 | 10920 | 21845 | +| 44 | -21846 | 0 | 10920 | 21845 | +| 44 | -21846 | 0 | 10921 | 21845 | +| 44 | -21846 | 0 | 10922 | 21845 | +| 44 | -21846 | 0 | 10923 | 21845 | +| 44 | -21846 | 0 | 10924 | 21845 | +| 44 | -21846 | 0 | 10925 | 21845 | +| 44 | -21846 | 0 | 10926 | 21845 | +| 44 | -21846 | 0 | 10927 | -21846 | +| 44+ | 21845 | 1 | 10927 | -21846 | +| 45 | 21845 | 1 | 10927 | 21845 | +| 45+ | 21845 | 0 | 10920 | 21845 | +| 46 | 21845 | 0 | 10920 | 21845 | +| 46 | 21845 | 0 | 10921 | 21845 | +| 46 | 21845 | 0 | 10922 | 21845 | +| 46 | 21845 | 0 | 10923 | 21845 | +| 46 | 21845 | 0 | 10924 | 21845 | +| 46 | 21845 | 0 | 10925 | 21845 | +| 46 | 21845 | 0 | 10926 | 21845 | +| 46 | 21845 | 0 | 10927 | 21845 | +| 46+ | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 3413 | 0 | +| 47 | 21845 | 0 | 5461 | 0 | +| 47 | 21845 | 0 | 7509 | 0 | +| 47 | 21845 | 0 | 9557 | 0 | +| 47 | 21845 | 0 | 11605 | 0 | +| 47 | 21845 | 0 | 13653 | 0 | +| 47 | 21845 | 0 | 15701 | 0 | +| 47+ | 21845 | 1 | 1365 | 0 | +| 48 | 21845 | 1 | 1365 | 21845 | +| 48+ | 21845 | 1 | 3413 | 0 | +| 49 | 21845 | 1 | 3413 | 21845 | +| 49+ | 21845 | 1 | 5461 | 0 | +| 50 | 21845 | 1 | 5461 | 21845 | +| 50+ | 21845 | 1 | 7509 | 0 | +| 51 | 21845 | 1 | 7509 | 21845 | +| 51+ | 21845 | 1 | 9557 | 0 | +| 52 | 21845 | 1 | 9557 | 21845 | +| 52+ | 21845 | 1 | 11605 | 0 | +| 53 | 21845 | 1 | 11605 | 21845 | +| 53+ | 21845 | 1 | 13653 | 0 | +| 54 | 21845 | 1 | 13653 | 21845 | +| 54+ | 21845 | 1 | 15701 | 0 | +| 55 | 21845 | 1 | 15701 | 21845 | +| 55+ | 21845 | 0 | 1365 | 21845 | +| 56 | 21845 | 0 | 1365 | 21845 | +| 56 | 21845 | 0 | 3413 | 21845 | +| 56 | 21845 | 0 | 5461 | 21845 | +| 56 | 21845 | 0 | 7509 | 21845 | +| 56 | 21845 | 0 | 9557 | 21845 | +| 56 | 21845 | 0 | 11605 | 21845 | +| 56 | 21845 | 0 | 13653 | 21845 | +| 56 | 21845 | 0 | 15701 | 21845 | +| 56+ | -21846 | 1 | 1365 | 21845 | +| 57 | -21846 | 1 | 1365 | -21846 | +| 57+ | -21846 | 0 | 1365 | -21846 | +| 58 | -21846 | 0 | 1365 | -21846 | +| 58 | -21846 | 0 | 3413 | 21845 | +| 58 | -21846 | 0 | 5461 | 21845 | +| 58 | -21846 | 0 | 7509 | 21845 | +| 58 | -21846 | 0 | 9557 | 21845 | +| 58 | -21846 | 0 | 11605 | 21845 | +| 58 | -21846 | 0 | 13653 | 21845 | +| 58 | -21846 | 0 | 15701 | 21845 | +| 58+ | 21845 | 1 | 1365 | -21846 | +| 59 | 21845 | 1 | 1365 | 21845 | +| 59+ | -21846 | 1 | 3413 | 21845 | +| 60 | -21846 | 1 | 3413 | -21846 | +| 60+ | -21846 | 0 | 1365 | 21845 | +| 61 | -21846 | 0 | 1365 | 21845 | +| 61 | -21846 | 0 | 3413 | -21846 | +| 61 | -21846 | 0 | 5461 | 21845 | +| 61 | -21846 | 0 | 7509 | 21845 | +| 61 | -21846 | 0 | 9557 | 21845 | +| 61 | -21846 | 0 | 11605 | 21845 | +| 61 | -21846 | 0 | 13653 | 21845 | +| 61 | -21846 | 0 | 15701 | 21845 | +| 61+ | 21845 | 1 | 3413 | -21846 | +| 62 | 21845 | 1 | 3413 | 21845 | +| 62+ | -21846 | 1 | 5461 | 21845 | +| 63 | -21846 | 1 | 5461 | -21846 | +| 63+ | -21846 | 0 | 1365 | 21845 | +| 64 | -21846 | 0 | 1365 | 21845 | +| 64 | -21846 | 0 | 3413 | 21845 | +| 64 | -21846 | 0 | 5461 | -21846 | +| 64 | -21846 | 0 | 7509 | 21845 | +| 64 | -21846 | 0 | 9557 | 21845 | +| 64 | -21846 | 0 | 11605 | 21845 | +| 64 | -21846 | 0 | 13653 | 21845 | +| 64 | -21846 | 0 | 15701 | 21845 | +| 64+ | 21845 | 1 | 5461 | -21846 | +| 65 | 21845 | 1 | 5461 | 21845 | +| 65+ | -21846 | 1 | 7509 | 21845 | +| 66 | -21846 | 1 | 7509 | -21846 | +| 66+ | -21846 | 0 | 1365 | 21845 | +| 67 | -21846 | 0 | 1365 | 21845 | +| 67 | -21846 | 0 | 3413 | 21845 | +| 67 | -21846 | 0 | 5461 | 21845 | +| 67 | -21846 | 0 | 7509 | -21846 | +| 67 | -21846 | 0 | 9557 | 21845 | +| 67 | -21846 | 0 | 11605 | 21845 | +| 67 | -21846 | 0 | 13653 | 21845 | +| 67 | -21846 | 0 | 15701 | 21845 | +| 67+ | 21845 | 1 | 7509 | -21846 | +| 68 | 21845 | 1 | 7509 | 21845 | +| 68+ | -21846 | 1 | 9557 | 21845 | +| 69 | -21846 | 1 | 9557 | -21846 | +| 69+ | -21846 | 0 | 1365 | 21845 | +| 70 | -21846 | 0 | 1365 | 21845 | +| 70 | -21846 | 0 | 3413 | 21845 | +| 70 | -21846 | 0 | 5461 | 21845 | +| 70 | -21846 | 0 | 7509 | 21845 | +| 70 | -21846 | 0 | 9557 | -21846 | +| 70 | -21846 | 0 | 11605 | 21845 | +| 70 | -21846 | 0 | 13653 | 21845 | +| 70 | -21846 | 0 | 15701 | 21845 | +| 70+ | 21845 | 1 | 9557 | -21846 | +| 71 | 21845 | 1 | 9557 | 21845 | +| 71+ | -21846 | 1 | 11605 | 21845 | +| 72 | -21846 | 1 | 11605 | -21846 | +| 72+ | -21846 | 0 | 1365 | 21845 | +| 73 | -21846 | 0 | 1365 | 21845 | +| 73 | -21846 | 0 | 3413 | 21845 | +| 73 | -21846 | 0 | 5461 | 21845 | +| 73 | -21846 | 0 | 7509 | 21845 | +| 73 | -21846 | 0 | 9557 | 21845 | +| 73 | -21846 | 0 | 11605 | -21846 | +| 73 | -21846 | 0 | 13653 | 21845 | +| 73 | -21846 | 0 | 15701 | 21845 | +| 73+ | 21845 | 1 | 11605 | -21846 | +| 74 | 21845 | 1 | 11605 | 21845 | +| 74+ | -21846 | 1 | 13653 | 21845 | +| 75 | -21846 | 1 | 13653 | -21846 | +| 75+ | -21846 | 0 | 1365 | 21845 | +| 76 | -21846 | 0 | 1365 | 21845 | +| 76 | -21846 | 0 | 3413 | 21845 | +| 76 | -21846 | 0 | 5461 | 21845 | +| 76 | -21846 | 0 | 7509 | 21845 | +| 76 | -21846 | 0 | 9557 | 21845 | +| 76 | -21846 | 0 | 11605 | 21845 | +| 76 | -21846 | 0 | 13653 | -21846 | +| 76 | -21846 | 0 | 15701 | 21845 | +| 76+ | 21845 | 1 | 13653 | -21846 | +| 77 | 21845 | 1 | 13653 | 21845 | +| 77+ | -21846 | 1 | 15701 | 21845 | +| 78 | -21846 | 1 | 15701 | -21846 | +| 78+ | -21846 | 0 | 1365 | 21845 | +| 79 | -21846 | 0 | 1365 | 21845 | +| 79 | -21846 | 0 | 3413 | 21845 | +| 79 | -21846 | 0 | 5461 | 21845 | +| 79 | -21846 | 0 | 7509 | 21845 | +| 79 | -21846 | 0 | 9557 | 21845 | +| 79 | -21846 | 0 | 11605 | 21845 | +| 79 | -21846 | 0 | 13653 | 21845 | +| 79 | -21846 | 0 | 15701 | -21846 | +| 79+ | 21845 | 1 | 15701 | -21846 | +| 80 | 21845 | 1 | 15701 | 21845 | +| 80+ | 21845 | 0 | 1365 | 21845 | +| 81 | 21845 | 0 | 1365 | 21845 | +| 81 | 21845 | 0 | 3413 | 21845 | +| 81 | 21845 | 0 | 5461 | 21845 | +| 81 | 21845 | 0 | 7509 | 21845 | +| 81 | 21845 | 0 | 9557 | 21845 | +| 81 | 21845 | 0 | 11605 | 21845 | +| 81 | 21845 | 0 | 13653 | 21845 | +| 81 | 21845 | 0 | 15701 | 21845 | diff --git a/projects/03/b/RAM16K.hdl b/projects/03/b/RAM16K.hdl new file mode 100755 index 0000000..31127b0 --- /dev/null +++ b/projects/03/b/RAM16K.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/b/RAM16K.hdl + +/** + * Memory of 16K registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM16K { + IN in[16], load, address[14]; + OUT out[16]; + + PARTS: + DMux4Way(in=load,sel=address[0..1],a=a,b=b,c=c,d=d); + RAM4K(in=in,load=a,address=address[2..13],out=outa); + RAM4K(in=in,load=b,address=address[2..13],out=outb); + RAM4K(in=in,load=c,address=address[2..13],out=outc); + RAM4K(in=in,load=d,address=address[2..13],out=outd); + Mux4Way16(a=outa,b=outb,c=outc,d=outd,sel=address[0..1],out=out); +} \ No newline at end of file diff --git a/projects/03/b/RAM16K.out b/projects/03/b/RAM16K.out new file mode 100755 index 0000000..a1ad9db --- /dev/null +++ b/projects/03/b/RAM16K.out @@ -0,0 +1,320 @@ +| time | in |load | address | out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 4321 | 0 | 0 | 0 | +| 3 | 4321 | 0 | 0 | 0 | +| 3+ | 4321 | 1 | 4321 | 0 | +| 4 | 4321 | 1 | 4321 | 4321 | +| 4+ | 4321 | 0 | 0 | 0 | +| 5 | 4321 | 0 | 0 | 0 | +| 5+ | 12345 | 0 | 12345 | 0 | +| 6 | 12345 | 0 | 12345 | 0 | +| 6+ | 12345 | 1 | 12345 | 0 | +| 7 | 12345 | 1 | 12345 | 12345 | +| 7+ | 12345 | 0 | 12345 | 12345 | +| 8 | 12345 | 0 | 12345 | 12345 | +| 8 | 12345 | 0 | 4321 | 4321 | +| 8+ | 16383 | 0 | 4321 | 4321 | +| 9 | 16383 | 0 | 4321 | 4321 | +| 9+ | 16383 | 1 | 16383 | 0 | +| 10 | 16383 | 1 | 16383 | 16383 | +| 10+ | 16383 | 0 | 16383 | 16383 | +| 11 | 16383 | 0 | 16383 | 16383 | +| 11 | 16383 | 0 | 12345 | 12345 | +| 11 | 16383 | 0 | 16383 | 16383 | +| 11+ | 16383 | 0 | 10920 | 0 | +| 12 | 16383 | 0 | 10920 | 0 | +| 12 | 16383 | 0 | 10921 | 0 | +| 12 | 16383 | 0 | 10922 | 0 | +| 12 | 16383 | 0 | 10923 | 0 | +| 12 | 16383 | 0 | 10924 | 0 | +| 12 | 16383 | 0 | 10925 | 0 | +| 12 | 16383 | 0 | 10926 | 0 | +| 12 | 16383 | 0 | 10927 | 0 | +| 12+ | 21845 | 1 | 10920 | 0 | +| 13 | 21845 | 1 | 10920 | 21845 | +| 13+ | 21845 | 1 | 10921 | 0 | +| 14 | 21845 | 1 | 10921 | 21845 | +| 14+ | 21845 | 1 | 10922 | 0 | +| 15 | 21845 | 1 | 10922 | 21845 | +| 15+ | 21845 | 1 | 10923 | 0 | +| 16 | 21845 | 1 | 10923 | 21845 | +| 16+ | 21845 | 1 | 10924 | 0 | +| 17 | 21845 | 1 | 10924 | 21845 | +| 17+ | 21845 | 1 | 10925 | 0 | +| 18 | 21845 | 1 | 10925 | 21845 | +| 18+ | 21845 | 1 | 10926 | 0 | +| 19 | 21845 | 1 | 10926 | 21845 | +| 19+ | 21845 | 1 | 10927 | 0 | +| 20 | 21845 | 1 | 10927 | 21845 | +| 20+ | 21845 | 0 | 10920 | 21845 | +| 21 | 21845 | 0 | 10920 | 21845 | +| 21 | 21845 | 0 | 10921 | 21845 | +| 21 | 21845 | 0 | 10922 | 21845 | +| 21 | 21845 | 0 | 10923 | 21845 | +| 21 | 21845 | 0 | 10924 | 21845 | +| 21 | 21845 | 0 | 10925 | 21845 | +| 21 | 21845 | 0 | 10926 | 21845 | +| 21 | 21845 | 0 | 10927 | 21845 | +| 21+ | -21846 | 1 | 10920 | 21845 | +| 22 | -21846 | 1 | 10920 | -21846 | +| 22+ | -21846 | 0 | 10920 | -21846 | +| 23 | -21846 | 0 | 10920 | -21846 | +| 23 | -21846 | 0 | 10921 | 21845 | +| 23 | -21846 | 0 | 10922 | 21845 | +| 23 | -21846 | 0 | 10923 | 21845 | +| 23 | -21846 | 0 | 10924 | 21845 | +| 23 | -21846 | 0 | 10925 | 21845 | +| 23 | -21846 | 0 | 10926 | 21845 | +| 23 | -21846 | 0 | 10927 | 21845 | +| 23+ | 21845 | 1 | 10920 | -21846 | +| 24 | 21845 | 1 | 10920 | 21845 | +| 24+ | -21846 | 1 | 10921 | 21845 | +| 25 | -21846 | 1 | 10921 | -21846 | +| 25+ | -21846 | 0 | 10920 | 21845 | +| 26 | -21846 | 0 | 10920 | 21845 | +| 26 | -21846 | 0 | 10921 | -21846 | +| 26 | -21846 | 0 | 10922 | 21845 | +| 26 | -21846 | 0 | 10923 | 21845 | +| 26 | -21846 | 0 | 10924 | 21845 | +| 26 | -21846 | 0 | 10925 | 21845 | +| 26 | -21846 | 0 | 10926 | 21845 | +| 26 | -21846 | 0 | 10927 | 21845 | +| 26+ | 21845 | 1 | 10921 | -21846 | +| 27 | 21845 | 1 | 10921 | 21845 | +| 27+ | -21846 | 1 | 10922 | 21845 | +| 28 | -21846 | 1 | 10922 | -21846 | +| 28+ | -21846 | 0 | 10920 | 21845 | +| 29 | -21846 | 0 | 10920 | 21845 | +| 29 | -21846 | 0 | 10921 | 21845 | +| 29 | -21846 | 0 | 10922 | -21846 | +| 29 | -21846 | 0 | 10923 | 21845 | +| 29 | -21846 | 0 | 10924 | 21845 | +| 29 | -21846 | 0 | 10925 | 21845 | +| 29 | -21846 | 0 | 10926 | 21845 | +| 29 | -21846 | 0 | 10927 | 21845 | +| 29+ | 21845 | 1 | 10922 | -21846 | +| 30 | 21845 | 1 | 10922 | 21845 | +| 30+ | -21846 | 1 | 10923 | 21845 | +| 31 | -21846 | 1 | 10923 | -21846 | +| 31+ | -21846 | 0 | 10920 | 21845 | +| 32 | -21846 | 0 | 10920 | 21845 | +| 32 | -21846 | 0 | 10921 | 21845 | +| 32 | -21846 | 0 | 10922 | 21845 | +| 32 | -21846 | 0 | 10923 | -21846 | +| 32 | -21846 | 0 | 10924 | 21845 | +| 32 | -21846 | 0 | 10925 | 21845 | +| 32 | -21846 | 0 | 10926 | 21845 | +| 32 | -21846 | 0 | 10927 | 21845 | +| 32+ | 21845 | 1 | 10923 | -21846 | +| 33 | 21845 | 1 | 10923 | 21845 | +| 33+ | -21846 | 1 | 10924 | 21845 | +| 34 | -21846 | 1 | 10924 | -21846 | +| 34+ | -21846 | 0 | 10920 | 21845 | +| 35 | -21846 | 0 | 10920 | 21845 | +| 35 | -21846 | 0 | 10921 | 21845 | +| 35 | -21846 | 0 | 10922 | 21845 | +| 35 | -21846 | 0 | 10923 | 21845 | +| 35 | -21846 | 0 | 10924 | -21846 | +| 35 | -21846 | 0 | 10925 | 21845 | +| 35 | -21846 | 0 | 10926 | 21845 | +| 35 | -21846 | 0 | 10927 | 21845 | +| 35+ | 21845 | 1 | 10924 | -21846 | +| 36 | 21845 | 1 | 10924 | 21845 | +| 36+ | -21846 | 1 | 10925 | 21845 | +| 37 | -21846 | 1 | 10925 | -21846 | +| 37+ | -21846 | 0 | 10920 | 21845 | +| 38 | -21846 | 0 | 10920 | 21845 | +| 38 | -21846 | 0 | 10921 | 21845 | +| 38 | -21846 | 0 | 10922 | 21845 | +| 38 | -21846 | 0 | 10923 | 21845 | +| 38 | -21846 | 0 | 10924 | 21845 | +| 38 | -21846 | 0 | 10925 | -21846 | +| 38 | -21846 | 0 | 10926 | 21845 | +| 38 | -21846 | 0 | 10927 | 21845 | +| 38+ | 21845 | 1 | 10925 | -21846 | +| 39 | 21845 | 1 | 10925 | 21845 | +| 39+ | -21846 | 1 | 10926 | 21845 | +| 40 | -21846 | 1 | 10926 | -21846 | +| 40+ | -21846 | 0 | 10920 | 21845 | +| 41 | -21846 | 0 | 10920 | 21845 | +| 41 | -21846 | 0 | 10921 | 21845 | +| 41 | -21846 | 0 | 10922 | 21845 | +| 41 | -21846 | 0 | 10923 | 21845 | +| 41 | -21846 | 0 | 10924 | 21845 | +| 41 | -21846 | 0 | 10925 | 21845 | +| 41 | -21846 | 0 | 10926 | -21846 | +| 41 | -21846 | 0 | 10927 | 21845 | +| 41+ | 21845 | 1 | 10926 | -21846 | +| 42 | 21845 | 1 | 10926 | 21845 | +| 42+ | -21846 | 1 | 10927 | 21845 | +| 43 | -21846 | 1 | 10927 | -21846 | +| 43+ | -21846 | 0 | 10920 | 21845 | +| 44 | -21846 | 0 | 10920 | 21845 | +| 44 | -21846 | 0 | 10921 | 21845 | +| 44 | -21846 | 0 | 10922 | 21845 | +| 44 | -21846 | 0 | 10923 | 21845 | +| 44 | -21846 | 0 | 10924 | 21845 | +| 44 | -21846 | 0 | 10925 | 21845 | +| 44 | -21846 | 0 | 10926 | 21845 | +| 44 | -21846 | 0 | 10927 | -21846 | +| 44+ | 21845 | 1 | 10927 | -21846 | +| 45 | 21845 | 1 | 10927 | 21845 | +| 45+ | 21845 | 0 | 10920 | 21845 | +| 46 | 21845 | 0 | 10920 | 21845 | +| 46 | 21845 | 0 | 10921 | 21845 | +| 46 | 21845 | 0 | 10922 | 21845 | +| 46 | 21845 | 0 | 10923 | 21845 | +| 46 | 21845 | 0 | 10924 | 21845 | +| 46 | 21845 | 0 | 10925 | 21845 | +| 46 | 21845 | 0 | 10926 | 21845 | +| 46 | 21845 | 0 | 10927 | 21845 | +| 46+ | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 3413 | 0 | +| 47 | 21845 | 0 | 5461 | 0 | +| 47 | 21845 | 0 | 7509 | 0 | +| 47 | 21845 | 0 | 9557 | 0 | +| 47 | 21845 | 0 | 11605 | 0 | +| 47 | 21845 | 0 | 13653 | 0 | +| 47 | 21845 | 0 | 15701 | 0 | +| 47+ | 21845 | 1 | 1365 | 0 | +| 48 | 21845 | 1 | 1365 | 21845 | +| 48+ | 21845 | 1 | 3413 | 0 | +| 49 | 21845 | 1 | 3413 | 21845 | +| 49+ | 21845 | 1 | 5461 | 0 | +| 50 | 21845 | 1 | 5461 | 21845 | +| 50+ | 21845 | 1 | 7509 | 0 | +| 51 | 21845 | 1 | 7509 | 21845 | +| 51+ | 21845 | 1 | 9557 | 0 | +| 52 | 21845 | 1 | 9557 | 21845 | +| 52+ | 21845 | 1 | 11605 | 0 | +| 53 | 21845 | 1 | 11605 | 21845 | +| 53+ | 21845 | 1 | 13653 | 0 | +| 54 | 21845 | 1 | 13653 | 21845 | +| 54+ | 21845 | 1 | 15701 | 0 | +| 55 | 21845 | 1 | 15701 | 21845 | +| 55+ | 21845 | 0 | 1365 | 21845 | +| 56 | 21845 | 0 | 1365 | 21845 | +| 56 | 21845 | 0 | 3413 | 21845 | +| 56 | 21845 | 0 | 5461 | 21845 | +| 56 | 21845 | 0 | 7509 | 21845 | +| 56 | 21845 | 0 | 9557 | 21845 | +| 56 | 21845 | 0 | 11605 | 21845 | +| 56 | 21845 | 0 | 13653 | 21845 | +| 56 | 21845 | 0 | 15701 | 21845 | +| 56+ | -21846 | 1 | 1365 | 21845 | +| 57 | -21846 | 1 | 1365 | -21846 | +| 57+ | -21846 | 0 | 1365 | -21846 | +| 58 | -21846 | 0 | 1365 | -21846 | +| 58 | -21846 | 0 | 3413 | 21845 | +| 58 | -21846 | 0 | 5461 | 21845 | +| 58 | -21846 | 0 | 7509 | 21845 | +| 58 | -21846 | 0 | 9557 | 21845 | +| 58 | -21846 | 0 | 11605 | 21845 | +| 58 | -21846 | 0 | 13653 | 21845 | +| 58 | -21846 | 0 | 15701 | 21845 | +| 58+ | 21845 | 1 | 1365 | -21846 | +| 59 | 21845 | 1 | 1365 | 21845 | +| 59+ | -21846 | 1 | 3413 | 21845 | +| 60 | -21846 | 1 | 3413 | -21846 | +| 60+ | -21846 | 0 | 1365 | 21845 | +| 61 | -21846 | 0 | 1365 | 21845 | +| 61 | -21846 | 0 | 3413 | -21846 | +| 61 | -21846 | 0 | 5461 | 21845 | +| 61 | -21846 | 0 | 7509 | 21845 | +| 61 | -21846 | 0 | 9557 | 21845 | +| 61 | -21846 | 0 | 11605 | 21845 | +| 61 | -21846 | 0 | 13653 | 21845 | +| 61 | -21846 | 0 | 15701 | 21845 | +| 61+ | 21845 | 1 | 3413 | -21846 | +| 62 | 21845 | 1 | 3413 | 21845 | +| 62+ | -21846 | 1 | 5461 | 21845 | +| 63 | -21846 | 1 | 5461 | -21846 | +| 63+ | -21846 | 0 | 1365 | 21845 | +| 64 | -21846 | 0 | 1365 | 21845 | +| 64 | -21846 | 0 | 3413 | 21845 | +| 64 | -21846 | 0 | 5461 | -21846 | +| 64 | -21846 | 0 | 7509 | 21845 | +| 64 | -21846 | 0 | 9557 | 21845 | +| 64 | -21846 | 0 | 11605 | 21845 | +| 64 | -21846 | 0 | 13653 | 21845 | +| 64 | -21846 | 0 | 15701 | 21845 | +| 64+ | 21845 | 1 | 5461 | -21846 | +| 65 | 21845 | 1 | 5461 | 21845 | +| 65+ | -21846 | 1 | 7509 | 21845 | +| 66 | -21846 | 1 | 7509 | -21846 | +| 66+ | -21846 | 0 | 1365 | 21845 | +| 67 | -21846 | 0 | 1365 | 21845 | +| 67 | -21846 | 0 | 3413 | 21845 | +| 67 | -21846 | 0 | 5461 | 21845 | +| 67 | -21846 | 0 | 7509 | -21846 | +| 67 | -21846 | 0 | 9557 | 21845 | +| 67 | -21846 | 0 | 11605 | 21845 | +| 67 | -21846 | 0 | 13653 | 21845 | +| 67 | -21846 | 0 | 15701 | 21845 | +| 67+ | 21845 | 1 | 7509 | -21846 | +| 68 | 21845 | 1 | 7509 | 21845 | +| 68+ | -21846 | 1 | 9557 | 21845 | +| 69 | -21846 | 1 | 9557 | -21846 | +| 69+ | -21846 | 0 | 1365 | 21845 | +| 70 | -21846 | 0 | 1365 | 21845 | +| 70 | -21846 | 0 | 3413 | 21845 | +| 70 | -21846 | 0 | 5461 | 21845 | +| 70 | -21846 | 0 | 7509 | 21845 | +| 70 | -21846 | 0 | 9557 | -21846 | +| 70 | -21846 | 0 | 11605 | 21845 | +| 70 | -21846 | 0 | 13653 | 21845 | +| 70 | -21846 | 0 | 15701 | 21845 | +| 70+ | 21845 | 1 | 9557 | -21846 | +| 71 | 21845 | 1 | 9557 | 21845 | +| 71+ | -21846 | 1 | 11605 | 21845 | +| 72 | -21846 | 1 | 11605 | -21846 | +| 72+ | -21846 | 0 | 1365 | 21845 | +| 73 | -21846 | 0 | 1365 | 21845 | +| 73 | -21846 | 0 | 3413 | 21845 | +| 73 | -21846 | 0 | 5461 | 21845 | +| 73 | -21846 | 0 | 7509 | 21845 | +| 73 | -21846 | 0 | 9557 | 21845 | +| 73 | -21846 | 0 | 11605 | -21846 | +| 73 | -21846 | 0 | 13653 | 21845 | +| 73 | -21846 | 0 | 15701 | 21845 | +| 73+ | 21845 | 1 | 11605 | -21846 | +| 74 | 21845 | 1 | 11605 | 21845 | +| 74+ | -21846 | 1 | 13653 | 21845 | +| 75 | -21846 | 1 | 13653 | -21846 | +| 75+ | -21846 | 0 | 1365 | 21845 | +| 76 | -21846 | 0 | 1365 | 21845 | +| 76 | -21846 | 0 | 3413 | 21845 | +| 76 | -21846 | 0 | 5461 | 21845 | +| 76 | -21846 | 0 | 7509 | 21845 | +| 76 | -21846 | 0 | 9557 | 21845 | +| 76 | -21846 | 0 | 11605 | 21845 | +| 76 | -21846 | 0 | 13653 | -21846 | +| 76 | -21846 | 0 | 15701 | 21845 | +| 76+ | 21845 | 1 | 13653 | -21846 | +| 77 | 21845 | 1 | 13653 | 21845 | +| 77+ | -21846 | 1 | 15701 | 21845 | +| 78 | -21846 | 1 | 15701 | -21846 | +| 78+ | -21846 | 0 | 1365 | 21845 | +| 79 | -21846 | 0 | 1365 | 21845 | +| 79 | -21846 | 0 | 3413 | 21845 | +| 79 | -21846 | 0 | 5461 | 21845 | +| 79 | -21846 | 0 | 7509 | 21845 | +| 79 | -21846 | 0 | 9557 | 21845 | +| 79 | -21846 | 0 | 11605 | 21845 | +| 79 | -21846 | 0 | 13653 | 21845 | +| 79 | -21846 | 0 | 15701 | -21846 | +| 79+ | 21845 | 1 | 15701 | -21846 | +| 80 | 21845 | 1 | 15701 | 21845 | +| 80+ | 21845 | 0 | 1365 | 21845 | +| 81 | 21845 | 0 | 1365 | 21845 | +| 81 | 21845 | 0 | 3413 | 21845 | +| 81 | 21845 | 0 | 5461 | 21845 | +| 81 | 21845 | 0 | 7509 | 21845 | +| 81 | 21845 | 0 | 9557 | 21845 | +| 81 | 21845 | 0 | 11605 | 21845 | +| 81 | 21845 | 0 | 13653 | 21845 | +| 81 | 21845 | 0 | 15701 | 21845 | diff --git a/projects/03/b/RAM16K.tst b/projects/03/b/RAM16K.tst new file mode 100755 index 0000000..e556ad4 --- /dev/null +++ b/projects/03/b/RAM16K.tst @@ -0,0 +1,1026 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/b/RAM16K.tst + +load RAM16K.hdl, +output-file RAM16K.out, +compare-to RAM16K.cmp, +output-list time%S1.4.1 in%D1.6.1 load%B2.1.2 address%D2.5.2 out%D1.6.1; + +set in 0, +set load 0, +set address 0, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set in 4321, +set load 0, +tick, +output; +tock, +output; + +set load 1, +set address 4321, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; + +set in 12345, +set address 12345, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 4321, +eval, +output; + +set in 16383, +tick, +output; +tock, +output; + +set load 1, +set address 16383, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 12345, +eval, +output; + +set address 16383, +eval, +output; + + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +tick, +output, +tock, +output; +set address %B10101010101010, +tick, +output, +tock, +output; +set address %B10101010101011, +tick, +output, +tock, +output; +set address %B10101010101100, +tick, +output, +tock, +output; +set address %B10101010101101, +tick, +output, +tock, +output; +set address %B10101010101110, +tick, +output, +tock, +output; +set address %B10101010101111, +tick, +output, +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101000, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101000, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10101010101001, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101001, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10101010101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10101010101011, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101011, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10101010101100, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101100, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10101010101101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10101010101110, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101110, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10101010101111, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + +set load 1, +set address %B10101010101111, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B10101010101000, +tick, +output; +tock, +output; +set address %B10101010101001, +eval, +output; +set address %B10101010101010, +eval, +output; +set address %B10101010101011, +eval, +output; +set address %B10101010101100, +eval, +output; +set address %B10101010101101, +eval, +output; +set address %B10101010101110, +eval, +output; +set address %B10101010101111, +eval, +output; + + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +tick, +output, +tock, +output; +set address %B01010101010101, +tick, +output, +tock, +output; +set address %B01110101010101, +tick, +output, +tock, +output; +set address %B10010101010101, +tick, +output, +tock, +output; +set address %B10110101010101, +tick, +output, +tock, +output; +set address %B11010101010101, +tick, +output, +tock, +output; +set address %B11110101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B00010101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B00010101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B00110101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B00110101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B01010101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B01010101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B01110101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B01110101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10010101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B10010101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B10110101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B10110101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B11010101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B11010101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B11110101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; + +set load 1, +set address %B11110101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B00010101010101, +tick, +output; +tock, +output; +set address %B00110101010101, +eval, +output; +set address %B01010101010101, +eval, +output; +set address %B01110101010101, +eval, +output; +set address %B10010101010101, +eval, +output; +set address %B10110101010101, +eval, +output; +set address %B11010101010101, +eval, +output; +set address %B11110101010101, +eval, +output; diff --git a/projects/03/b/RAM4K.cmp b/projects/03/b/RAM4K.cmp new file mode 100755 index 0000000..a614796 --- /dev/null +++ b/projects/03/b/RAM4K.cmp @@ -0,0 +1,320 @@ +| time | in |load |address | out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 1111 | 0 | 0 | 0 | +| 3 | 1111 | 0 | 0 | 0 | +| 3+ | 1111 | 1 | 1111 | 0 | +| 4 | 1111 | 1 | 1111 | 1111 | +| 4+ | 1111 | 0 | 0 | 0 | +| 5 | 1111 | 0 | 0 | 0 | +| 5+ | 3513 | 0 | 3513 | 0 | +| 6 | 3513 | 0 | 3513 | 0 | +| 6+ | 3513 | 1 | 3513 | 0 | +| 7 | 3513 | 1 | 3513 | 3513 | +| 7+ | 3513 | 0 | 3513 | 3513 | +| 8 | 3513 | 0 | 3513 | 3513 | +| 8 | 3513 | 0 | 1111 | 1111 | +| 8+ | 4095 | 0 | 1111 | 1111 | +| 9 | 4095 | 0 | 1111 | 1111 | +| 9+ | 4095 | 1 | 4095 | 0 | +| 10 | 4095 | 1 | 4095 | 4095 | +| 10+ | 4095 | 0 | 4095 | 4095 | +| 11 | 4095 | 0 | 4095 | 4095 | +| 11 | 4095 | 0 | 3513 | 3513 | +| 11 | 4095 | 0 | 4095 | 4095 | +| 11+ | 4095 | 0 | 2728 | 0 | +| 12 | 4095 | 0 | 2728 | 0 | +| 12 | 4095 | 0 | 2729 | 0 | +| 12 | 4095 | 0 | 2730 | 0 | +| 12 | 4095 | 0 | 2731 | 0 | +| 12 | 4095 | 0 | 2732 | 0 | +| 12 | 4095 | 0 | 2733 | 0 | +| 12 | 4095 | 0 | 2734 | 0 | +| 12 | 4095 | 0 | 2735 | 0 | +| 12+ | 21845 | 1 | 2728 | 0 | +| 13 | 21845 | 1 | 2728 | 21845 | +| 13+ | 21845 | 1 | 2729 | 0 | +| 14 | 21845 | 1 | 2729 | 21845 | +| 14+ | 21845 | 1 | 2730 | 0 | +| 15 | 21845 | 1 | 2730 | 21845 | +| 15+ | 21845 | 1 | 2731 | 0 | +| 16 | 21845 | 1 | 2731 | 21845 | +| 16+ | 21845 | 1 | 2732 | 0 | +| 17 | 21845 | 1 | 2732 | 21845 | +| 17+ | 21845 | 1 | 2733 | 0 | +| 18 | 21845 | 1 | 2733 | 21845 | +| 18+ | 21845 | 1 | 2734 | 0 | +| 19 | 21845 | 1 | 2734 | 21845 | +| 19+ | 21845 | 1 | 2735 | 0 | +| 20 | 21845 | 1 | 2735 | 21845 | +| 20+ | 21845 | 0 | 2728 | 21845 | +| 21 | 21845 | 0 | 2728 | 21845 | +| 21 | 21845 | 0 | 2729 | 21845 | +| 21 | 21845 | 0 | 2730 | 21845 | +| 21 | 21845 | 0 | 2731 | 21845 | +| 21 | 21845 | 0 | 2732 | 21845 | +| 21 | 21845 | 0 | 2733 | 21845 | +| 21 | 21845 | 0 | 2734 | 21845 | +| 21 | 21845 | 0 | 2735 | 21845 | +| 21+ | -21846 | 1 | 2728 | 21845 | +| 22 | -21846 | 1 | 2728 | -21846 | +| 22+ | -21846 | 0 | 2728 | -21846 | +| 23 | -21846 | 0 | 2728 | -21846 | +| 23 | -21846 | 0 | 2729 | 21845 | +| 23 | -21846 | 0 | 2730 | 21845 | +| 23 | -21846 | 0 | 2731 | 21845 | +| 23 | -21846 | 0 | 2732 | 21845 | +| 23 | -21846 | 0 | 2733 | 21845 | +| 23 | -21846 | 0 | 2734 | 21845 | +| 23 | -21846 | 0 | 2735 | 21845 | +| 23+ | 21845 | 1 | 2728 | -21846 | +| 24 | 21845 | 1 | 2728 | 21845 | +| 24+ | -21846 | 1 | 2729 | 21845 | +| 25 | -21846 | 1 | 2729 | -21846 | +| 25+ | -21846 | 0 | 2728 | 21845 | +| 26 | -21846 | 0 | 2728 | 21845 | +| 26 | -21846 | 0 | 2729 | -21846 | +| 26 | -21846 | 0 | 2730 | 21845 | +| 26 | -21846 | 0 | 2731 | 21845 | +| 26 | -21846 | 0 | 2732 | 21845 | +| 26 | -21846 | 0 | 2733 | 21845 | +| 26 | -21846 | 0 | 2734 | 21845 | +| 26 | -21846 | 0 | 2735 | 21845 | +| 26+ | 21845 | 1 | 2729 | -21846 | +| 27 | 21845 | 1 | 2729 | 21845 | +| 27+ | -21846 | 1 | 2730 | 21845 | +| 28 | -21846 | 1 | 2730 | -21846 | +| 28+ | -21846 | 0 | 2728 | 21845 | +| 29 | -21846 | 0 | 2728 | 21845 | +| 29 | -21846 | 0 | 2729 | 21845 | +| 29 | -21846 | 0 | 2730 | -21846 | +| 29 | -21846 | 0 | 2731 | 21845 | +| 29 | -21846 | 0 | 2732 | 21845 | +| 29 | -21846 | 0 | 2733 | 21845 | +| 29 | -21846 | 0 | 2734 | 21845 | +| 29 | -21846 | 0 | 2735 | 21845 | +| 29+ | 21845 | 1 | 2730 | -21846 | +| 30 | 21845 | 1 | 2730 | 21845 | +| 30+ | -21846 | 1 | 2731 | 21845 | +| 31 | -21846 | 1 | 2731 | -21846 | +| 31+ | -21846 | 0 | 2728 | 21845 | +| 32 | -21846 | 0 | 2728 | 21845 | +| 32 | -21846 | 0 | 2729 | 21845 | +| 32 | -21846 | 0 | 2730 | 21845 | +| 32 | -21846 | 0 | 2731 | -21846 | +| 32 | -21846 | 0 | 2732 | 21845 | +| 32 | -21846 | 0 | 2733 | 21845 | +| 32 | -21846 | 0 | 2734 | 21845 | +| 32 | -21846 | 0 | 2735 | 21845 | +| 32+ | 21845 | 1 | 2731 | -21846 | +| 33 | 21845 | 1 | 2731 | 21845 | +| 33+ | -21846 | 1 | 2732 | 21845 | +| 34 | -21846 | 1 | 2732 | -21846 | +| 34+ | -21846 | 0 | 2728 | 21845 | +| 35 | -21846 | 0 | 2728 | 21845 | +| 35 | -21846 | 0 | 2729 | 21845 | +| 35 | -21846 | 0 | 2730 | 21845 | +| 35 | -21846 | 0 | 2731 | 21845 | +| 35 | -21846 | 0 | 2732 | -21846 | +| 35 | -21846 | 0 | 2733 | 21845 | +| 35 | -21846 | 0 | 2734 | 21845 | +| 35 | -21846 | 0 | 2735 | 21845 | +| 35+ | 21845 | 1 | 2732 | -21846 | +| 36 | 21845 | 1 | 2732 | 21845 | +| 36+ | -21846 | 1 | 2733 | 21845 | +| 37 | -21846 | 1 | 2733 | -21846 | +| 37+ | -21846 | 0 | 2728 | 21845 | +| 38 | -21846 | 0 | 2728 | 21845 | +| 38 | -21846 | 0 | 2729 | 21845 | +| 38 | -21846 | 0 | 2730 | 21845 | +| 38 | -21846 | 0 | 2731 | 21845 | +| 38 | -21846 | 0 | 2732 | 21845 | +| 38 | -21846 | 0 | 2733 | -21846 | +| 38 | -21846 | 0 | 2734 | 21845 | +| 38 | -21846 | 0 | 2735 | 21845 | +| 38+ | 21845 | 1 | 2733 | -21846 | +| 39 | 21845 | 1 | 2733 | 21845 | +| 39+ | -21846 | 1 | 2734 | 21845 | +| 40 | -21846 | 1 | 2734 | -21846 | +| 40+ | -21846 | 0 | 2728 | 21845 | +| 41 | -21846 | 0 | 2728 | 21845 | +| 41 | -21846 | 0 | 2729 | 21845 | +| 41 | -21846 | 0 | 2730 | 21845 | +| 41 | -21846 | 0 | 2731 | 21845 | +| 41 | -21846 | 0 | 2732 | 21845 | +| 41 | -21846 | 0 | 2733 | 21845 | +| 41 | -21846 | 0 | 2734 | -21846 | +| 41 | -21846 | 0 | 2735 | 21845 | +| 41+ | 21845 | 1 | 2734 | -21846 | +| 42 | 21845 | 1 | 2734 | 21845 | +| 42+ | -21846 | 1 | 2735 | 21845 | +| 43 | -21846 | 1 | 2735 | -21846 | +| 43+ | -21846 | 0 | 2728 | 21845 | +| 44 | -21846 | 0 | 2728 | 21845 | +| 44 | -21846 | 0 | 2729 | 21845 | +| 44 | -21846 | 0 | 2730 | 21845 | +| 44 | -21846 | 0 | 2731 | 21845 | +| 44 | -21846 | 0 | 2732 | 21845 | +| 44 | -21846 | 0 | 2733 | 21845 | +| 44 | -21846 | 0 | 2734 | 21845 | +| 44 | -21846 | 0 | 2735 | -21846 | +| 44+ | 21845 | 1 | 2735 | -21846 | +| 45 | 21845 | 1 | 2735 | 21845 | +| 45+ | 21845 | 0 | 2728 | 21845 | +| 46 | 21845 | 0 | 2728 | 21845 | +| 46 | 21845 | 0 | 2729 | 21845 | +| 46 | 21845 | 0 | 2730 | 21845 | +| 46 | 21845 | 0 | 2731 | 21845 | +| 46 | 21845 | 0 | 2732 | 21845 | +| 46 | 21845 | 0 | 2733 | 21845 | +| 46 | 21845 | 0 | 2734 | 21845 | +| 46 | 21845 | 0 | 2735 | 21845 | +| 46+ | 21845 | 0 | 341 | 0 | +| 47 | 21845 | 0 | 341 | 0 | +| 47 | 21845 | 0 | 853 | 0 | +| 47 | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 1877 | 0 | +| 47 | 21845 | 0 | 2389 | 0 | +| 47 | 21845 | 0 | 2901 | 0 | +| 47 | 21845 | 0 | 3413 | 0 | +| 47 | 21845 | 0 | 3925 | 0 | +| 47+ | 21845 | 1 | 341 | 0 | +| 48 | 21845 | 1 | 341 | 21845 | +| 48+ | 21845 | 1 | 853 | 0 | +| 49 | 21845 | 1 | 853 | 21845 | +| 49+ | 21845 | 1 | 1365 | 0 | +| 50 | 21845 | 1 | 1365 | 21845 | +| 50+ | 21845 | 1 | 1877 | 0 | +| 51 | 21845 | 1 | 1877 | 21845 | +| 51+ | 21845 | 1 | 2389 | 0 | +| 52 | 21845 | 1 | 2389 | 21845 | +| 52+ | 21845 | 1 | 2901 | 0 | +| 53 | 21845 | 1 | 2901 | 21845 | +| 53+ | 21845 | 1 | 3413 | 0 | +| 54 | 21845 | 1 | 3413 | 21845 | +| 54+ | 21845 | 1 | 3925 | 0 | +| 55 | 21845 | 1 | 3925 | 21845 | +| 55+ | 21845 | 0 | 341 | 21845 | +| 56 | 21845 | 0 | 341 | 21845 | +| 56 | 21845 | 0 | 853 | 21845 | +| 56 | 21845 | 0 | 1365 | 21845 | +| 56 | 21845 | 0 | 1877 | 21845 | +| 56 | 21845 | 0 | 2389 | 21845 | +| 56 | 21845 | 0 | 2901 | 21845 | +| 56 | 21845 | 0 | 3413 | 21845 | +| 56 | 21845 | 0 | 3925 | 21845 | +| 56+ | -21846 | 1 | 341 | 21845 | +| 57 | -21846 | 1 | 341 | -21846 | +| 57+ | -21846 | 0 | 341 | -21846 | +| 58 | -21846 | 0 | 341 | -21846 | +| 58 | -21846 | 0 | 853 | 21845 | +| 58 | -21846 | 0 | 1365 | 21845 | +| 58 | -21846 | 0 | 1877 | 21845 | +| 58 | -21846 | 0 | 2389 | 21845 | +| 58 | -21846 | 0 | 2901 | 21845 | +| 58 | -21846 | 0 | 3413 | 21845 | +| 58 | -21846 | 0 | 3925 | 21845 | +| 58+ | 21845 | 1 | 341 | -21846 | +| 59 | 21845 | 1 | 341 | 21845 | +| 59+ | -21846 | 1 | 853 | 21845 | +| 60 | -21846 | 1 | 853 | -21846 | +| 60+ | -21846 | 0 | 341 | 21845 | +| 61 | -21846 | 0 | 341 | 21845 | +| 61 | -21846 | 0 | 853 | -21846 | +| 61 | -21846 | 0 | 1365 | 21845 | +| 61 | -21846 | 0 | 1877 | 21845 | +| 61 | -21846 | 0 | 2389 | 21845 | +| 61 | -21846 | 0 | 2901 | 21845 | +| 61 | -21846 | 0 | 3413 | 21845 | +| 61 | -21846 | 0 | 3925 | 21845 | +| 61+ | 21845 | 1 | 853 | -21846 | +| 62 | 21845 | 1 | 853 | 21845 | +| 62+ | -21846 | 1 | 1365 | 21845 | +| 63 | -21846 | 1 | 1365 | -21846 | +| 63+ | -21846 | 0 | 341 | 21845 | +| 64 | -21846 | 0 | 341 | 21845 | +| 64 | -21846 | 0 | 853 | 21845 | +| 64 | -21846 | 0 | 1365 | -21846 | +| 64 | -21846 | 0 | 1877 | 21845 | +| 64 | -21846 | 0 | 2389 | 21845 | +| 64 | -21846 | 0 | 2901 | 21845 | +| 64 | -21846 | 0 | 3413 | 21845 | +| 64 | -21846 | 0 | 3925 | 21845 | +| 64+ | 21845 | 1 | 1365 | -21846 | +| 65 | 21845 | 1 | 1365 | 21845 | +| 65+ | -21846 | 1 | 1877 | 21845 | +| 66 | -21846 | 1 | 1877 | -21846 | +| 66+ | -21846 | 0 | 341 | 21845 | +| 67 | -21846 | 0 | 341 | 21845 | +| 67 | -21846 | 0 | 853 | 21845 | +| 67 | -21846 | 0 | 1365 | 21845 | +| 67 | -21846 | 0 | 1877 | -21846 | +| 67 | -21846 | 0 | 2389 | 21845 | +| 67 | -21846 | 0 | 2901 | 21845 | +| 67 | -21846 | 0 | 3413 | 21845 | +| 67 | -21846 | 0 | 3925 | 21845 | +| 67+ | 21845 | 1 | 1877 | -21846 | +| 68 | 21845 | 1 | 1877 | 21845 | +| 68+ | -21846 | 1 | 2389 | 21845 | +| 69 | -21846 | 1 | 2389 | -21846 | +| 69+ | -21846 | 0 | 341 | 21845 | +| 70 | -21846 | 0 | 341 | 21845 | +| 70 | -21846 | 0 | 853 | 21845 | +| 70 | -21846 | 0 | 1365 | 21845 | +| 70 | -21846 | 0 | 1877 | 21845 | +| 70 | -21846 | 0 | 2389 | -21846 | +| 70 | -21846 | 0 | 2901 | 21845 | +| 70 | -21846 | 0 | 3413 | 21845 | +| 70 | -21846 | 0 | 3925 | 21845 | +| 70+ | 21845 | 1 | 2389 | -21846 | +| 71 | 21845 | 1 | 2389 | 21845 | +| 71+ | -21846 | 1 | 2901 | 21845 | +| 72 | -21846 | 1 | 2901 | -21846 | +| 72+ | -21846 | 0 | 341 | 21845 | +| 73 | -21846 | 0 | 341 | 21845 | +| 73 | -21846 | 0 | 853 | 21845 | +| 73 | -21846 | 0 | 1365 | 21845 | +| 73 | -21846 | 0 | 1877 | 21845 | +| 73 | -21846 | 0 | 2389 | 21845 | +| 73 | -21846 | 0 | 2901 | -21846 | +| 73 | -21846 | 0 | 3413 | 21845 | +| 73 | -21846 | 0 | 3925 | 21845 | +| 73+ | 21845 | 1 | 2901 | -21846 | +| 74 | 21845 | 1 | 2901 | 21845 | +| 74+ | -21846 | 1 | 3413 | 21845 | +| 75 | -21846 | 1 | 3413 | -21846 | +| 75+ | -21846 | 0 | 341 | 21845 | +| 76 | -21846 | 0 | 341 | 21845 | +| 76 | -21846 | 0 | 853 | 21845 | +| 76 | -21846 | 0 | 1365 | 21845 | +| 76 | -21846 | 0 | 1877 | 21845 | +| 76 | -21846 | 0 | 2389 | 21845 | +| 76 | -21846 | 0 | 2901 | 21845 | +| 76 | -21846 | 0 | 3413 | -21846 | +| 76 | -21846 | 0 | 3925 | 21845 | +| 76+ | 21845 | 1 | 3413 | -21846 | +| 77 | 21845 | 1 | 3413 | 21845 | +| 77+ | -21846 | 1 | 3925 | 21845 | +| 78 | -21846 | 1 | 3925 | -21846 | +| 78+ | -21846 | 0 | 341 | 21845 | +| 79 | -21846 | 0 | 341 | 21845 | +| 79 | -21846 | 0 | 853 | 21845 | +| 79 | -21846 | 0 | 1365 | 21845 | +| 79 | -21846 | 0 | 1877 | 21845 | +| 79 | -21846 | 0 | 2389 | 21845 | +| 79 | -21846 | 0 | 2901 | 21845 | +| 79 | -21846 | 0 | 3413 | 21845 | +| 79 | -21846 | 0 | 3925 | -21846 | +| 79+ | 21845 | 1 | 3925 | -21846 | +| 80 | 21845 | 1 | 3925 | 21845 | +| 80+ | 21845 | 0 | 341 | 21845 | +| 81 | 21845 | 0 | 341 | 21845 | +| 81 | 21845 | 0 | 853 | 21845 | +| 81 | 21845 | 0 | 1365 | 21845 | +| 81 | 21845 | 0 | 1877 | 21845 | +| 81 | 21845 | 0 | 2389 | 21845 | +| 81 | 21845 | 0 | 2901 | 21845 | +| 81 | 21845 | 0 | 3413 | 21845 | +| 81 | 21845 | 0 | 3925 | 21845 | diff --git a/projects/03/b/RAM4K.hdl b/projects/03/b/RAM4K.hdl new file mode 100755 index 0000000..1f969ef --- /dev/null +++ b/projects/03/b/RAM4K.hdl @@ -0,0 +1,28 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/b/RAM4K.hdl + +/** + * Memory of 4K registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM4K { + IN in[16], load, address[12]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address[0..2],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + RAM512(in=in,load=a,address=address[3..11],out=outa); + RAM512(in=in,load=b,address=address[3..11],out=outb); + RAM512(in=in,load=c,address=address[3..11],out=outc); + RAM512(in=in,load=d,address=address[3..11],out=outd); + RAM512(in=in,load=e,address=address[3..11],out=oute); + RAM512(in=in,load=f,address=address[3..11],out=outf); + RAM512(in=in,load=g,address=address[3..11],out=outg); + RAM512(in=in,load=h,address=address[3..11],out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address[0..2],out=out); +} \ No newline at end of file diff --git a/projects/03/b/RAM4K.out b/projects/03/b/RAM4K.out new file mode 100755 index 0000000..a614796 --- /dev/null +++ b/projects/03/b/RAM4K.out @@ -0,0 +1,320 @@ +| time | in |load |address | out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 1111 | 0 | 0 | 0 | +| 3 | 1111 | 0 | 0 | 0 | +| 3+ | 1111 | 1 | 1111 | 0 | +| 4 | 1111 | 1 | 1111 | 1111 | +| 4+ | 1111 | 0 | 0 | 0 | +| 5 | 1111 | 0 | 0 | 0 | +| 5+ | 3513 | 0 | 3513 | 0 | +| 6 | 3513 | 0 | 3513 | 0 | +| 6+ | 3513 | 1 | 3513 | 0 | +| 7 | 3513 | 1 | 3513 | 3513 | +| 7+ | 3513 | 0 | 3513 | 3513 | +| 8 | 3513 | 0 | 3513 | 3513 | +| 8 | 3513 | 0 | 1111 | 1111 | +| 8+ | 4095 | 0 | 1111 | 1111 | +| 9 | 4095 | 0 | 1111 | 1111 | +| 9+ | 4095 | 1 | 4095 | 0 | +| 10 | 4095 | 1 | 4095 | 4095 | +| 10+ | 4095 | 0 | 4095 | 4095 | +| 11 | 4095 | 0 | 4095 | 4095 | +| 11 | 4095 | 0 | 3513 | 3513 | +| 11 | 4095 | 0 | 4095 | 4095 | +| 11+ | 4095 | 0 | 2728 | 0 | +| 12 | 4095 | 0 | 2728 | 0 | +| 12 | 4095 | 0 | 2729 | 0 | +| 12 | 4095 | 0 | 2730 | 0 | +| 12 | 4095 | 0 | 2731 | 0 | +| 12 | 4095 | 0 | 2732 | 0 | +| 12 | 4095 | 0 | 2733 | 0 | +| 12 | 4095 | 0 | 2734 | 0 | +| 12 | 4095 | 0 | 2735 | 0 | +| 12+ | 21845 | 1 | 2728 | 0 | +| 13 | 21845 | 1 | 2728 | 21845 | +| 13+ | 21845 | 1 | 2729 | 0 | +| 14 | 21845 | 1 | 2729 | 21845 | +| 14+ | 21845 | 1 | 2730 | 0 | +| 15 | 21845 | 1 | 2730 | 21845 | +| 15+ | 21845 | 1 | 2731 | 0 | +| 16 | 21845 | 1 | 2731 | 21845 | +| 16+ | 21845 | 1 | 2732 | 0 | +| 17 | 21845 | 1 | 2732 | 21845 | +| 17+ | 21845 | 1 | 2733 | 0 | +| 18 | 21845 | 1 | 2733 | 21845 | +| 18+ | 21845 | 1 | 2734 | 0 | +| 19 | 21845 | 1 | 2734 | 21845 | +| 19+ | 21845 | 1 | 2735 | 0 | +| 20 | 21845 | 1 | 2735 | 21845 | +| 20+ | 21845 | 0 | 2728 | 21845 | +| 21 | 21845 | 0 | 2728 | 21845 | +| 21 | 21845 | 0 | 2729 | 21845 | +| 21 | 21845 | 0 | 2730 | 21845 | +| 21 | 21845 | 0 | 2731 | 21845 | +| 21 | 21845 | 0 | 2732 | 21845 | +| 21 | 21845 | 0 | 2733 | 21845 | +| 21 | 21845 | 0 | 2734 | 21845 | +| 21 | 21845 | 0 | 2735 | 21845 | +| 21+ | -21846 | 1 | 2728 | 21845 | +| 22 | -21846 | 1 | 2728 | -21846 | +| 22+ | -21846 | 0 | 2728 | -21846 | +| 23 | -21846 | 0 | 2728 | -21846 | +| 23 | -21846 | 0 | 2729 | 21845 | +| 23 | -21846 | 0 | 2730 | 21845 | +| 23 | -21846 | 0 | 2731 | 21845 | +| 23 | -21846 | 0 | 2732 | 21845 | +| 23 | -21846 | 0 | 2733 | 21845 | +| 23 | -21846 | 0 | 2734 | 21845 | +| 23 | -21846 | 0 | 2735 | 21845 | +| 23+ | 21845 | 1 | 2728 | -21846 | +| 24 | 21845 | 1 | 2728 | 21845 | +| 24+ | -21846 | 1 | 2729 | 21845 | +| 25 | -21846 | 1 | 2729 | -21846 | +| 25+ | -21846 | 0 | 2728 | 21845 | +| 26 | -21846 | 0 | 2728 | 21845 | +| 26 | -21846 | 0 | 2729 | -21846 | +| 26 | -21846 | 0 | 2730 | 21845 | +| 26 | -21846 | 0 | 2731 | 21845 | +| 26 | -21846 | 0 | 2732 | 21845 | +| 26 | -21846 | 0 | 2733 | 21845 | +| 26 | -21846 | 0 | 2734 | 21845 | +| 26 | -21846 | 0 | 2735 | 21845 | +| 26+ | 21845 | 1 | 2729 | -21846 | +| 27 | 21845 | 1 | 2729 | 21845 | +| 27+ | -21846 | 1 | 2730 | 21845 | +| 28 | -21846 | 1 | 2730 | -21846 | +| 28+ | -21846 | 0 | 2728 | 21845 | +| 29 | -21846 | 0 | 2728 | 21845 | +| 29 | -21846 | 0 | 2729 | 21845 | +| 29 | -21846 | 0 | 2730 | -21846 | +| 29 | -21846 | 0 | 2731 | 21845 | +| 29 | -21846 | 0 | 2732 | 21845 | +| 29 | -21846 | 0 | 2733 | 21845 | +| 29 | -21846 | 0 | 2734 | 21845 | +| 29 | -21846 | 0 | 2735 | 21845 | +| 29+ | 21845 | 1 | 2730 | -21846 | +| 30 | 21845 | 1 | 2730 | 21845 | +| 30+ | -21846 | 1 | 2731 | 21845 | +| 31 | -21846 | 1 | 2731 | -21846 | +| 31+ | -21846 | 0 | 2728 | 21845 | +| 32 | -21846 | 0 | 2728 | 21845 | +| 32 | -21846 | 0 | 2729 | 21845 | +| 32 | -21846 | 0 | 2730 | 21845 | +| 32 | -21846 | 0 | 2731 | -21846 | +| 32 | -21846 | 0 | 2732 | 21845 | +| 32 | -21846 | 0 | 2733 | 21845 | +| 32 | -21846 | 0 | 2734 | 21845 | +| 32 | -21846 | 0 | 2735 | 21845 | +| 32+ | 21845 | 1 | 2731 | -21846 | +| 33 | 21845 | 1 | 2731 | 21845 | +| 33+ | -21846 | 1 | 2732 | 21845 | +| 34 | -21846 | 1 | 2732 | -21846 | +| 34+ | -21846 | 0 | 2728 | 21845 | +| 35 | -21846 | 0 | 2728 | 21845 | +| 35 | -21846 | 0 | 2729 | 21845 | +| 35 | -21846 | 0 | 2730 | 21845 | +| 35 | -21846 | 0 | 2731 | 21845 | +| 35 | -21846 | 0 | 2732 | -21846 | +| 35 | -21846 | 0 | 2733 | 21845 | +| 35 | -21846 | 0 | 2734 | 21845 | +| 35 | -21846 | 0 | 2735 | 21845 | +| 35+ | 21845 | 1 | 2732 | -21846 | +| 36 | 21845 | 1 | 2732 | 21845 | +| 36+ | -21846 | 1 | 2733 | 21845 | +| 37 | -21846 | 1 | 2733 | -21846 | +| 37+ | -21846 | 0 | 2728 | 21845 | +| 38 | -21846 | 0 | 2728 | 21845 | +| 38 | -21846 | 0 | 2729 | 21845 | +| 38 | -21846 | 0 | 2730 | 21845 | +| 38 | -21846 | 0 | 2731 | 21845 | +| 38 | -21846 | 0 | 2732 | 21845 | +| 38 | -21846 | 0 | 2733 | -21846 | +| 38 | -21846 | 0 | 2734 | 21845 | +| 38 | -21846 | 0 | 2735 | 21845 | +| 38+ | 21845 | 1 | 2733 | -21846 | +| 39 | 21845 | 1 | 2733 | 21845 | +| 39+ | -21846 | 1 | 2734 | 21845 | +| 40 | -21846 | 1 | 2734 | -21846 | +| 40+ | -21846 | 0 | 2728 | 21845 | +| 41 | -21846 | 0 | 2728 | 21845 | +| 41 | -21846 | 0 | 2729 | 21845 | +| 41 | -21846 | 0 | 2730 | 21845 | +| 41 | -21846 | 0 | 2731 | 21845 | +| 41 | -21846 | 0 | 2732 | 21845 | +| 41 | -21846 | 0 | 2733 | 21845 | +| 41 | -21846 | 0 | 2734 | -21846 | +| 41 | -21846 | 0 | 2735 | 21845 | +| 41+ | 21845 | 1 | 2734 | -21846 | +| 42 | 21845 | 1 | 2734 | 21845 | +| 42+ | -21846 | 1 | 2735 | 21845 | +| 43 | -21846 | 1 | 2735 | -21846 | +| 43+ | -21846 | 0 | 2728 | 21845 | +| 44 | -21846 | 0 | 2728 | 21845 | +| 44 | -21846 | 0 | 2729 | 21845 | +| 44 | -21846 | 0 | 2730 | 21845 | +| 44 | -21846 | 0 | 2731 | 21845 | +| 44 | -21846 | 0 | 2732 | 21845 | +| 44 | -21846 | 0 | 2733 | 21845 | +| 44 | -21846 | 0 | 2734 | 21845 | +| 44 | -21846 | 0 | 2735 | -21846 | +| 44+ | 21845 | 1 | 2735 | -21846 | +| 45 | 21845 | 1 | 2735 | 21845 | +| 45+ | 21845 | 0 | 2728 | 21845 | +| 46 | 21845 | 0 | 2728 | 21845 | +| 46 | 21845 | 0 | 2729 | 21845 | +| 46 | 21845 | 0 | 2730 | 21845 | +| 46 | 21845 | 0 | 2731 | 21845 | +| 46 | 21845 | 0 | 2732 | 21845 | +| 46 | 21845 | 0 | 2733 | 21845 | +| 46 | 21845 | 0 | 2734 | 21845 | +| 46 | 21845 | 0 | 2735 | 21845 | +| 46+ | 21845 | 0 | 341 | 0 | +| 47 | 21845 | 0 | 341 | 0 | +| 47 | 21845 | 0 | 853 | 0 | +| 47 | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 1877 | 0 | +| 47 | 21845 | 0 | 2389 | 0 | +| 47 | 21845 | 0 | 2901 | 0 | +| 47 | 21845 | 0 | 3413 | 0 | +| 47 | 21845 | 0 | 3925 | 0 | +| 47+ | 21845 | 1 | 341 | 0 | +| 48 | 21845 | 1 | 341 | 21845 | +| 48+ | 21845 | 1 | 853 | 0 | +| 49 | 21845 | 1 | 853 | 21845 | +| 49+ | 21845 | 1 | 1365 | 0 | +| 50 | 21845 | 1 | 1365 | 21845 | +| 50+ | 21845 | 1 | 1877 | 0 | +| 51 | 21845 | 1 | 1877 | 21845 | +| 51+ | 21845 | 1 | 2389 | 0 | +| 52 | 21845 | 1 | 2389 | 21845 | +| 52+ | 21845 | 1 | 2901 | 0 | +| 53 | 21845 | 1 | 2901 | 21845 | +| 53+ | 21845 | 1 | 3413 | 0 | +| 54 | 21845 | 1 | 3413 | 21845 | +| 54+ | 21845 | 1 | 3925 | 0 | +| 55 | 21845 | 1 | 3925 | 21845 | +| 55+ | 21845 | 0 | 341 | 21845 | +| 56 | 21845 | 0 | 341 | 21845 | +| 56 | 21845 | 0 | 853 | 21845 | +| 56 | 21845 | 0 | 1365 | 21845 | +| 56 | 21845 | 0 | 1877 | 21845 | +| 56 | 21845 | 0 | 2389 | 21845 | +| 56 | 21845 | 0 | 2901 | 21845 | +| 56 | 21845 | 0 | 3413 | 21845 | +| 56 | 21845 | 0 | 3925 | 21845 | +| 56+ | -21846 | 1 | 341 | 21845 | +| 57 | -21846 | 1 | 341 | -21846 | +| 57+ | -21846 | 0 | 341 | -21846 | +| 58 | -21846 | 0 | 341 | -21846 | +| 58 | -21846 | 0 | 853 | 21845 | +| 58 | -21846 | 0 | 1365 | 21845 | +| 58 | -21846 | 0 | 1877 | 21845 | +| 58 | -21846 | 0 | 2389 | 21845 | +| 58 | -21846 | 0 | 2901 | 21845 | +| 58 | -21846 | 0 | 3413 | 21845 | +| 58 | -21846 | 0 | 3925 | 21845 | +| 58+ | 21845 | 1 | 341 | -21846 | +| 59 | 21845 | 1 | 341 | 21845 | +| 59+ | -21846 | 1 | 853 | 21845 | +| 60 | -21846 | 1 | 853 | -21846 | +| 60+ | -21846 | 0 | 341 | 21845 | +| 61 | -21846 | 0 | 341 | 21845 | +| 61 | -21846 | 0 | 853 | -21846 | +| 61 | -21846 | 0 | 1365 | 21845 | +| 61 | -21846 | 0 | 1877 | 21845 | +| 61 | -21846 | 0 | 2389 | 21845 | +| 61 | -21846 | 0 | 2901 | 21845 | +| 61 | -21846 | 0 | 3413 | 21845 | +| 61 | -21846 | 0 | 3925 | 21845 | +| 61+ | 21845 | 1 | 853 | -21846 | +| 62 | 21845 | 1 | 853 | 21845 | +| 62+ | -21846 | 1 | 1365 | 21845 | +| 63 | -21846 | 1 | 1365 | -21846 | +| 63+ | -21846 | 0 | 341 | 21845 | +| 64 | -21846 | 0 | 341 | 21845 | +| 64 | -21846 | 0 | 853 | 21845 | +| 64 | -21846 | 0 | 1365 | -21846 | +| 64 | -21846 | 0 | 1877 | 21845 | +| 64 | -21846 | 0 | 2389 | 21845 | +| 64 | -21846 | 0 | 2901 | 21845 | +| 64 | -21846 | 0 | 3413 | 21845 | +| 64 | -21846 | 0 | 3925 | 21845 | +| 64+ | 21845 | 1 | 1365 | -21846 | +| 65 | 21845 | 1 | 1365 | 21845 | +| 65+ | -21846 | 1 | 1877 | 21845 | +| 66 | -21846 | 1 | 1877 | -21846 | +| 66+ | -21846 | 0 | 341 | 21845 | +| 67 | -21846 | 0 | 341 | 21845 | +| 67 | -21846 | 0 | 853 | 21845 | +| 67 | -21846 | 0 | 1365 | 21845 | +| 67 | -21846 | 0 | 1877 | -21846 | +| 67 | -21846 | 0 | 2389 | 21845 | +| 67 | -21846 | 0 | 2901 | 21845 | +| 67 | -21846 | 0 | 3413 | 21845 | +| 67 | -21846 | 0 | 3925 | 21845 | +| 67+ | 21845 | 1 | 1877 | -21846 | +| 68 | 21845 | 1 | 1877 | 21845 | +| 68+ | -21846 | 1 | 2389 | 21845 | +| 69 | -21846 | 1 | 2389 | -21846 | +| 69+ | -21846 | 0 | 341 | 21845 | +| 70 | -21846 | 0 | 341 | 21845 | +| 70 | -21846 | 0 | 853 | 21845 | +| 70 | -21846 | 0 | 1365 | 21845 | +| 70 | -21846 | 0 | 1877 | 21845 | +| 70 | -21846 | 0 | 2389 | -21846 | +| 70 | -21846 | 0 | 2901 | 21845 | +| 70 | -21846 | 0 | 3413 | 21845 | +| 70 | -21846 | 0 | 3925 | 21845 | +| 70+ | 21845 | 1 | 2389 | -21846 | +| 71 | 21845 | 1 | 2389 | 21845 | +| 71+ | -21846 | 1 | 2901 | 21845 | +| 72 | -21846 | 1 | 2901 | -21846 | +| 72+ | -21846 | 0 | 341 | 21845 | +| 73 | -21846 | 0 | 341 | 21845 | +| 73 | -21846 | 0 | 853 | 21845 | +| 73 | -21846 | 0 | 1365 | 21845 | +| 73 | -21846 | 0 | 1877 | 21845 | +| 73 | -21846 | 0 | 2389 | 21845 | +| 73 | -21846 | 0 | 2901 | -21846 | +| 73 | -21846 | 0 | 3413 | 21845 | +| 73 | -21846 | 0 | 3925 | 21845 | +| 73+ | 21845 | 1 | 2901 | -21846 | +| 74 | 21845 | 1 | 2901 | 21845 | +| 74+ | -21846 | 1 | 3413 | 21845 | +| 75 | -21846 | 1 | 3413 | -21846 | +| 75+ | -21846 | 0 | 341 | 21845 | +| 76 | -21846 | 0 | 341 | 21845 | +| 76 | -21846 | 0 | 853 | 21845 | +| 76 | -21846 | 0 | 1365 | 21845 | +| 76 | -21846 | 0 | 1877 | 21845 | +| 76 | -21846 | 0 | 2389 | 21845 | +| 76 | -21846 | 0 | 2901 | 21845 | +| 76 | -21846 | 0 | 3413 | -21846 | +| 76 | -21846 | 0 | 3925 | 21845 | +| 76+ | 21845 | 1 | 3413 | -21846 | +| 77 | 21845 | 1 | 3413 | 21845 | +| 77+ | -21846 | 1 | 3925 | 21845 | +| 78 | -21846 | 1 | 3925 | -21846 | +| 78+ | -21846 | 0 | 341 | 21845 | +| 79 | -21846 | 0 | 341 | 21845 | +| 79 | -21846 | 0 | 853 | 21845 | +| 79 | -21846 | 0 | 1365 | 21845 | +| 79 | -21846 | 0 | 1877 | 21845 | +| 79 | -21846 | 0 | 2389 | 21845 | +| 79 | -21846 | 0 | 2901 | 21845 | +| 79 | -21846 | 0 | 3413 | 21845 | +| 79 | -21846 | 0 | 3925 | -21846 | +| 79+ | 21845 | 1 | 3925 | -21846 | +| 80 | 21845 | 1 | 3925 | 21845 | +| 80+ | 21845 | 0 | 341 | 21845 | +| 81 | 21845 | 0 | 341 | 21845 | +| 81 | 21845 | 0 | 853 | 21845 | +| 81 | 21845 | 0 | 1365 | 21845 | +| 81 | 21845 | 0 | 1877 | 21845 | +| 81 | 21845 | 0 | 2389 | 21845 | +| 81 | 21845 | 0 | 2901 | 21845 | +| 81 | 21845 | 0 | 3413 | 21845 | +| 81 | 21845 | 0 | 3925 | 21845 | diff --git a/projects/03/b/RAM4K.tst b/projects/03/b/RAM4K.tst new file mode 100755 index 0000000..7a5aa12 --- /dev/null +++ b/projects/03/b/RAM4K.tst @@ -0,0 +1,1026 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/b/RAM4K.tst + +load RAM4K.hdl, +output-file RAM4K.out, +compare-to RAM4K.cmp, +output-list time%S1.4.1 in%D1.6.1 load%B2.1.2 address%D2.4.2 out%D1.6.1; + +set in 0, +set load 0, +set address 0, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set in 1111, +set load 0, +tick, +output; +tock, +output; + +set load 1, +set address 1111, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; + +set in 3513, +set address 3513, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 1111, +eval, +output; + +set in 4095, +tick, +output; +tock, +output; + +set load 1, +set address 4095, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 3513, +eval, +output; + +set address 4095, +eval, +output; + + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +tick, +output, +tock, +output; +set address %B101010101010, +tick, +output, +tock, +output; +set address %B101010101011, +tick, +output, +tock, +output; +set address %B101010101100, +tick, +output, +tock, +output; +set address %B101010101101, +tick, +output, +tock, +output; +set address %B101010101110, +tick, +output, +tock, +output; +set address %B101010101111, +tick, +output, +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101000, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101000, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010101001, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101001, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010101011, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101011, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010101100, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101100, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010101101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010101110, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101110, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101010101111, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + +set load 1, +set address %B101010101111, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B101010101000, +tick, +output; +tock, +output; +set address %B101010101001, +eval, +output; +set address %B101010101010, +eval, +output; +set address %B101010101011, +eval, +output; +set address %B101010101100, +eval, +output; +set address %B101010101101, +eval, +output; +set address %B101010101110, +eval, +output; +set address %B101010101111, +eval, +output; + + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +tick, +output, +tock, +output; +set address %B010101010101, +tick, +output, +tock, +output; +set address %B011101010101, +tick, +output, +tock, +output; +set address %B100101010101, +tick, +output, +tock, +output; +set address %B101101010101, +tick, +output, +tock, +output; +set address %B110101010101, +tick, +output, +tock, +output; +set address %B111101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B000101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B000101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B001101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B001101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B010101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B011101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B011101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B100101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B100101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B101101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B110101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B110101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B111101010101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; + +set load 1, +set address %B111101010101, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B000101010101, +tick, +output; +tock, +output; +set address %B001101010101, +eval, +output; +set address %B010101010101, +eval, +output; +set address %B011101010101, +eval, +output; +set address %B100101010101, +eval, +output; +set address %B101101010101, +eval, +output; +set address %B110101010101, +eval, +output; +set address %B111101010101, +eval, +output; diff --git a/projects/03/b/RAM512.cmp b/projects/03/b/RAM512.cmp new file mode 100755 index 0000000..6f756ca --- /dev/null +++ b/projects/03/b/RAM512.cmp @@ -0,0 +1,320 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 13099 | 0 | 0 | 0 | +| 3 | 13099 | 0 | 0 | 0 | +| 3+ | 13099 | 1 | 130 | 0 | +| 4 | 13099 | 1 | 130 | 13099 | +| 4+ | 13099 | 0 | 0 | 0 | +| 5 | 13099 | 0 | 0 | 0 | +| 5+ | 4729 | 0 | 472 | 0 | +| 6 | 4729 | 0 | 472 | 0 | +| 6+ | 4729 | 1 | 472 | 0 | +| 7 | 4729 | 1 | 472 | 4729 | +| 7+ | 4729 | 0 | 472 | 4729 | +| 8 | 4729 | 0 | 472 | 4729 | +| 8 | 4729 | 0 | 130 | 13099 | +| 8+ | 5119 | 0 | 130 | 13099 | +| 9 | 5119 | 0 | 130 | 13099 | +| 9+ | 5119 | 1 | 511 | 0 | +| 10 | 5119 | 1 | 511 | 5119 | +| 10+ | 5119 | 0 | 511 | 5119 | +| 11 | 5119 | 0 | 511 | 5119 | +| 11 | 5119 | 0 | 472 | 4729 | +| 11 | 5119 | 0 | 511 | 5119 | +| 11+ | 5119 | 0 | 168 | 0 | +| 12 | 5119 | 0 | 168 | 0 | +| 12 | 5119 | 0 | 169 | 0 | +| 12 | 5119 | 0 | 170 | 0 | +| 12 | 5119 | 0 | 171 | 0 | +| 12 | 5119 | 0 | 172 | 0 | +| 12 | 5119 | 0 | 173 | 0 | +| 12 | 5119 | 0 | 174 | 0 | +| 12 | 5119 | 0 | 175 | 0 | +| 12+ | 21845 | 1 | 168 | 0 | +| 13 | 21845 | 1 | 168 | 21845 | +| 13+ | 21845 | 1 | 169 | 0 | +| 14 | 21845 | 1 | 169 | 21845 | +| 14+ | 21845 | 1 | 170 | 0 | +| 15 | 21845 | 1 | 170 | 21845 | +| 15+ | 21845 | 1 | 171 | 0 | +| 16 | 21845 | 1 | 171 | 21845 | +| 16+ | 21845 | 1 | 172 | 0 | +| 17 | 21845 | 1 | 172 | 21845 | +| 17+ | 21845 | 1 | 173 | 0 | +| 18 | 21845 | 1 | 173 | 21845 | +| 18+ | 21845 | 1 | 174 | 0 | +| 19 | 21845 | 1 | 174 | 21845 | +| 19+ | 21845 | 1 | 175 | 0 | +| 20 | 21845 | 1 | 175 | 21845 | +| 20+ | 21845 | 0 | 168 | 21845 | +| 21 | 21845 | 0 | 168 | 21845 | +| 21 | 21845 | 0 | 169 | 21845 | +| 21 | 21845 | 0 | 170 | 21845 | +| 21 | 21845 | 0 | 171 | 21845 | +| 21 | 21845 | 0 | 172 | 21845 | +| 21 | 21845 | 0 | 173 | 21845 | +| 21 | 21845 | 0 | 174 | 21845 | +| 21 | 21845 | 0 | 175 | 21845 | +| 21+ | -21846 | 1 | 168 | 21845 | +| 22 | -21846 | 1 | 168 | -21846 | +| 22+ | -21846 | 0 | 168 | -21846 | +| 23 | -21846 | 0 | 168 | -21846 | +| 23 | -21846 | 0 | 169 | 21845 | +| 23 | -21846 | 0 | 170 | 21845 | +| 23 | -21846 | 0 | 171 | 21845 | +| 23 | -21846 | 0 | 172 | 21845 | +| 23 | -21846 | 0 | 173 | 21845 | +| 23 | -21846 | 0 | 174 | 21845 | +| 23 | -21846 | 0 | 175 | 21845 | +| 23+ | 21845 | 1 | 168 | -21846 | +| 24 | 21845 | 1 | 168 | 21845 | +| 24+ | -21846 | 1 | 169 | 21845 | +| 25 | -21846 | 1 | 169 | -21846 | +| 25+ | -21846 | 0 | 168 | 21845 | +| 26 | -21846 | 0 | 168 | 21845 | +| 26 | -21846 | 0 | 169 | -21846 | +| 26 | -21846 | 0 | 170 | 21845 | +| 26 | -21846 | 0 | 171 | 21845 | +| 26 | -21846 | 0 | 172 | 21845 | +| 26 | -21846 | 0 | 173 | 21845 | +| 26 | -21846 | 0 | 174 | 21845 | +| 26 | -21846 | 0 | 175 | 21845 | +| 26+ | 21845 | 1 | 169 | -21846 | +| 27 | 21845 | 1 | 169 | 21845 | +| 27+ | -21846 | 1 | 170 | 21845 | +| 28 | -21846 | 1 | 170 | -21846 | +| 28+ | -21846 | 0 | 168 | 21845 | +| 29 | -21846 | 0 | 168 | 21845 | +| 29 | -21846 | 0 | 169 | 21845 | +| 29 | -21846 | 0 | 170 | -21846 | +| 29 | -21846 | 0 | 171 | 21845 | +| 29 | -21846 | 0 | 172 | 21845 | +| 29 | -21846 | 0 | 173 | 21845 | +| 29 | -21846 | 0 | 174 | 21845 | +| 29 | -21846 | 0 | 175 | 21845 | +| 29+ | 21845 | 1 | 170 | -21846 | +| 30 | 21845 | 1 | 170 | 21845 | +| 30+ | -21846 | 1 | 171 | 21845 | +| 31 | -21846 | 1 | 171 | -21846 | +| 31+ | -21846 | 0 | 168 | 21845 | +| 32 | -21846 | 0 | 168 | 21845 | +| 32 | -21846 | 0 | 169 | 21845 | +| 32 | -21846 | 0 | 170 | 21845 | +| 32 | -21846 | 0 | 171 | -21846 | +| 32 | -21846 | 0 | 172 | 21845 | +| 32 | -21846 | 0 | 173 | 21845 | +| 32 | -21846 | 0 | 174 | 21845 | +| 32 | -21846 | 0 | 175 | 21845 | +| 32+ | 21845 | 1 | 171 | -21846 | +| 33 | 21845 | 1 | 171 | 21845 | +| 33+ | -21846 | 1 | 172 | 21845 | +| 34 | -21846 | 1 | 172 | -21846 | +| 34+ | -21846 | 0 | 168 | 21845 | +| 35 | -21846 | 0 | 168 | 21845 | +| 35 | -21846 | 0 | 169 | 21845 | +| 35 | -21846 | 0 | 170 | 21845 | +| 35 | -21846 | 0 | 171 | 21845 | +| 35 | -21846 | 0 | 172 | -21846 | +| 35 | -21846 | 0 | 173 | 21845 | +| 35 | -21846 | 0 | 174 | 21845 | +| 35 | -21846 | 0 | 175 | 21845 | +| 35+ | 21845 | 1 | 172 | -21846 | +| 36 | 21845 | 1 | 172 | 21845 | +| 36+ | -21846 | 1 | 173 | 21845 | +| 37 | -21846 | 1 | 173 | -21846 | +| 37+ | -21846 | 0 | 168 | 21845 | +| 38 | -21846 | 0 | 168 | 21845 | +| 38 | -21846 | 0 | 169 | 21845 | +| 38 | -21846 | 0 | 170 | 21845 | +| 38 | -21846 | 0 | 171 | 21845 | +| 38 | -21846 | 0 | 172 | 21845 | +| 38 | -21846 | 0 | 173 | -21846 | +| 38 | -21846 | 0 | 174 | 21845 | +| 38 | -21846 | 0 | 175 | 21845 | +| 38+ | 21845 | 1 | 173 | -21846 | +| 39 | 21845 | 1 | 173 | 21845 | +| 39+ | -21846 | 1 | 174 | 21845 | +| 40 | -21846 | 1 | 174 | -21846 | +| 40+ | -21846 | 0 | 168 | 21845 | +| 41 | -21846 | 0 | 168 | 21845 | +| 41 | -21846 | 0 | 169 | 21845 | +| 41 | -21846 | 0 | 170 | 21845 | +| 41 | -21846 | 0 | 171 | 21845 | +| 41 | -21846 | 0 | 172 | 21845 | +| 41 | -21846 | 0 | 173 | 21845 | +| 41 | -21846 | 0 | 174 | -21846 | +| 41 | -21846 | 0 | 175 | 21845 | +| 41+ | 21845 | 1 | 174 | -21846 | +| 42 | 21845 | 1 | 174 | 21845 | +| 42+ | -21846 | 1 | 175 | 21845 | +| 43 | -21846 | 1 | 175 | -21846 | +| 43+ | -21846 | 0 | 168 | 21845 | +| 44 | -21846 | 0 | 168 | 21845 | +| 44 | -21846 | 0 | 169 | 21845 | +| 44 | -21846 | 0 | 170 | 21845 | +| 44 | -21846 | 0 | 171 | 21845 | +| 44 | -21846 | 0 | 172 | 21845 | +| 44 | -21846 | 0 | 173 | 21845 | +| 44 | -21846 | 0 | 174 | 21845 | +| 44 | -21846 | 0 | 175 | -21846 | +| 44+ | 21845 | 1 | 175 | -21846 | +| 45 | 21845 | 1 | 175 | 21845 | +| 45+ | 21845 | 0 | 168 | 21845 | +| 46 | 21845 | 0 | 168 | 21845 | +| 46 | 21845 | 0 | 169 | 21845 | +| 46 | 21845 | 0 | 170 | 21845 | +| 46 | 21845 | 0 | 171 | 21845 | +| 46 | 21845 | 0 | 172 | 21845 | +| 46 | 21845 | 0 | 173 | 21845 | +| 46 | 21845 | 0 | 174 | 21845 | +| 46 | 21845 | 0 | 175 | 21845 | +| 46+ | 21845 | 0 | 42 | 0 | +| 47 | 21845 | 0 | 42 | 0 | +| 47 | 21845 | 0 | 106 | 0 | +| 47 | 21845 | 0 | 170 | 21845 | +| 47 | 21845 | 0 | 234 | 0 | +| 47 | 21845 | 0 | 298 | 0 | +| 47 | 21845 | 0 | 362 | 0 | +| 47 | 21845 | 0 | 426 | 0 | +| 47 | 21845 | 0 | 490 | 0 | +| 47+ | 21845 | 1 | 42 | 0 | +| 48 | 21845 | 1 | 42 | 21845 | +| 48+ | 21845 | 1 | 106 | 0 | +| 49 | 21845 | 1 | 106 | 21845 | +| 49+ | 21845 | 1 | 170 | 21845 | +| 50 | 21845 | 1 | 170 | 21845 | +| 50+ | 21845 | 1 | 234 | 0 | +| 51 | 21845 | 1 | 234 | 21845 | +| 51+ | 21845 | 1 | 298 | 0 | +| 52 | 21845 | 1 | 298 | 21845 | +| 52+ | 21845 | 1 | 362 | 0 | +| 53 | 21845 | 1 | 362 | 21845 | +| 53+ | 21845 | 1 | 426 | 0 | +| 54 | 21845 | 1 | 426 | 21845 | +| 54+ | 21845 | 1 | 490 | 0 | +| 55 | 21845 | 1 | 490 | 21845 | +| 55+ | 21845 | 0 | 42 | 21845 | +| 56 | 21845 | 0 | 42 | 21845 | +| 56 | 21845 | 0 | 106 | 21845 | +| 56 | 21845 | 0 | 170 | 21845 | +| 56 | 21845 | 0 | 234 | 21845 | +| 56 | 21845 | 0 | 298 | 21845 | +| 56 | 21845 | 0 | 362 | 21845 | +| 56 | 21845 | 0 | 426 | 21845 | +| 56 | 21845 | 0 | 490 | 21845 | +| 56+ | -21846 | 1 | 42 | 21845 | +| 57 | -21846 | 1 | 42 | -21846 | +| 57+ | -21846 | 0 | 42 | -21846 | +| 58 | -21846 | 0 | 42 | -21846 | +| 58 | -21846 | 0 | 106 | 21845 | +| 58 | -21846 | 0 | 170 | 21845 | +| 58 | -21846 | 0 | 234 | 21845 | +| 58 | -21846 | 0 | 298 | 21845 | +| 58 | -21846 | 0 | 362 | 21845 | +| 58 | -21846 | 0 | 426 | 21845 | +| 58 | -21846 | 0 | 490 | 21845 | +| 58+ | 21845 | 1 | 42 | -21846 | +| 59 | 21845 | 1 | 42 | 21845 | +| 59+ | -21846 | 1 | 106 | 21845 | +| 60 | -21846 | 1 | 106 | -21846 | +| 60+ | -21846 | 0 | 42 | 21845 | +| 61 | -21846 | 0 | 42 | 21845 | +| 61 | -21846 | 0 | 106 | -21846 | +| 61 | -21846 | 0 | 170 | 21845 | +| 61 | -21846 | 0 | 234 | 21845 | +| 61 | -21846 | 0 | 298 | 21845 | +| 61 | -21846 | 0 | 362 | 21845 | +| 61 | -21846 | 0 | 426 | 21845 | +| 61 | -21846 | 0 | 490 | 21845 | +| 61+ | 21845 | 1 | 106 | -21846 | +| 62 | 21845 | 1 | 106 | 21845 | +| 62+ | -21846 | 1 | 170 | 21845 | +| 63 | -21846 | 1 | 170 | -21846 | +| 63+ | -21846 | 0 | 42 | 21845 | +| 64 | -21846 | 0 | 42 | 21845 | +| 64 | -21846 | 0 | 106 | 21845 | +| 64 | -21846 | 0 | 170 | -21846 | +| 64 | -21846 | 0 | 234 | 21845 | +| 64 | -21846 | 0 | 298 | 21845 | +| 64 | -21846 | 0 | 362 | 21845 | +| 64 | -21846 | 0 | 426 | 21845 | +| 64 | -21846 | 0 | 490 | 21845 | +| 64+ | 21845 | 1 | 170 | -21846 | +| 65 | 21845 | 1 | 170 | 21845 | +| 65+ | -21846 | 1 | 234 | 21845 | +| 66 | -21846 | 1 | 234 | -21846 | +| 66+ | -21846 | 0 | 42 | 21845 | +| 67 | -21846 | 0 | 42 | 21845 | +| 67 | -21846 | 0 | 106 | 21845 | +| 67 | -21846 | 0 | 170 | 21845 | +| 67 | -21846 | 0 | 234 | -21846 | +| 67 | -21846 | 0 | 298 | 21845 | +| 67 | -21846 | 0 | 362 | 21845 | +| 67 | -21846 | 0 | 426 | 21845 | +| 67 | -21846 | 0 | 490 | 21845 | +| 67+ | 21845 | 1 | 234 | -21846 | +| 68 | 21845 | 1 | 234 | 21845 | +| 68+ | -21846 | 1 | 298 | 21845 | +| 69 | -21846 | 1 | 298 | -21846 | +| 69+ | -21846 | 0 | 42 | 21845 | +| 70 | -21846 | 0 | 42 | 21845 | +| 70 | -21846 | 0 | 106 | 21845 | +| 70 | -21846 | 0 | 170 | 21845 | +| 70 | -21846 | 0 | 234 | 21845 | +| 70 | -21846 | 0 | 298 | -21846 | +| 70 | -21846 | 0 | 362 | 21845 | +| 70 | -21846 | 0 | 426 | 21845 | +| 70 | -21846 | 0 | 490 | 21845 | +| 70+ | 21845 | 1 | 298 | -21846 | +| 71 | 21845 | 1 | 298 | 21845 | +| 71+ | -21846 | 1 | 362 | 21845 | +| 72 | -21846 | 1 | 362 | -21846 | +| 72+ | -21846 | 0 | 42 | 21845 | +| 73 | -21846 | 0 | 42 | 21845 | +| 73 | -21846 | 0 | 106 | 21845 | +| 73 | -21846 | 0 | 170 | 21845 | +| 73 | -21846 | 0 | 234 | 21845 | +| 73 | -21846 | 0 | 298 | 21845 | +| 73 | -21846 | 0 | 362 | -21846 | +| 73 | -21846 | 0 | 426 | 21845 | +| 73 | -21846 | 0 | 490 | 21845 | +| 73+ | 21845 | 1 | 362 | -21846 | +| 74 | 21845 | 1 | 362 | 21845 | +| 74+ | -21846 | 1 | 426 | 21845 | +| 75 | -21846 | 1 | 426 | -21846 | +| 75+ | -21846 | 0 | 42 | 21845 | +| 76 | -21846 | 0 | 42 | 21845 | +| 76 | -21846 | 0 | 106 | 21845 | +| 76 | -21846 | 0 | 170 | 21845 | +| 76 | -21846 | 0 | 234 | 21845 | +| 76 | -21846 | 0 | 298 | 21845 | +| 76 | -21846 | 0 | 362 | 21845 | +| 76 | -21846 | 0 | 426 | -21846 | +| 76 | -21846 | 0 | 490 | 21845 | +| 76+ | 21845 | 1 | 426 | -21846 | +| 77 | 21845 | 1 | 426 | 21845 | +| 77+ | -21846 | 1 | 490 | 21845 | +| 78 | -21846 | 1 | 490 | -21846 | +| 78+ | -21846 | 0 | 42 | 21845 | +| 79 | -21846 | 0 | 42 | 21845 | +| 79 | -21846 | 0 | 106 | 21845 | +| 79 | -21846 | 0 | 170 | 21845 | +| 79 | -21846 | 0 | 234 | 21845 | +| 79 | -21846 | 0 | 298 | 21845 | +| 79 | -21846 | 0 | 362 | 21845 | +| 79 | -21846 | 0 | 426 | 21845 | +| 79 | -21846 | 0 | 490 | -21846 | +| 79+ | 21845 | 1 | 490 | -21846 | +| 80 | 21845 | 1 | 490 | 21845 | +| 80+ | 21845 | 0 | 42 | 21845 | +| 81 | 21845 | 0 | 42 | 21845 | +| 81 | 21845 | 0 | 106 | 21845 | +| 81 | 21845 | 0 | 170 | 21845 | +| 81 | 21845 | 0 | 234 | 21845 | +| 81 | 21845 | 0 | 298 | 21845 | +| 81 | 21845 | 0 | 362 | 21845 | +| 81 | 21845 | 0 | 426 | 21845 | +| 81 | 21845 | 0 | 490 | 21845 | diff --git a/projects/03/b/RAM512.hdl b/projects/03/b/RAM512.hdl new file mode 100755 index 0000000..e62e717 --- /dev/null +++ b/projects/03/b/RAM512.hdl @@ -0,0 +1,28 @@ +// This file is part of the materials accompanying the book +// "The Elements of Computing Systems" by Nisan and Schocken, +// MIT Press. Book site: www.idc.ac.il/tecs +// File name: projects/03/b/RAM512.hdl + +/** + * Memory of 512 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM512 { + IN in[16], load, address[9]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address[0..2],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + RAM64(in=in,load=a,address=address[3..8],out=outa); + RAM64(in=in,load=b,address=address[3..8],out=outb); + RAM64(in=in,load=c,address=address[3..8],out=outc); + RAM64(in=in,load=d,address=address[3..8],out=outd); + RAM64(in=in,load=e,address=address[3..8],out=oute); + RAM64(in=in,load=f,address=address[3..8],out=outf); + RAM64(in=in,load=g,address=address[3..8],out=outg); + RAM64(in=in,load=h,address=address[3..8],out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address[0..2],out=out); +} \ No newline at end of file diff --git a/projects/03/b/RAM512.out b/projects/03/b/RAM512.out new file mode 100755 index 0000000..6f756ca --- /dev/null +++ b/projects/03/b/RAM512.out @@ -0,0 +1,320 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 13099 | 0 | 0 | 0 | +| 3 | 13099 | 0 | 0 | 0 | +| 3+ | 13099 | 1 | 130 | 0 | +| 4 | 13099 | 1 | 130 | 13099 | +| 4+ | 13099 | 0 | 0 | 0 | +| 5 | 13099 | 0 | 0 | 0 | +| 5+ | 4729 | 0 | 472 | 0 | +| 6 | 4729 | 0 | 472 | 0 | +| 6+ | 4729 | 1 | 472 | 0 | +| 7 | 4729 | 1 | 472 | 4729 | +| 7+ | 4729 | 0 | 472 | 4729 | +| 8 | 4729 | 0 | 472 | 4729 | +| 8 | 4729 | 0 | 130 | 13099 | +| 8+ | 5119 | 0 | 130 | 13099 | +| 9 | 5119 | 0 | 130 | 13099 | +| 9+ | 5119 | 1 | 511 | 0 | +| 10 | 5119 | 1 | 511 | 5119 | +| 10+ | 5119 | 0 | 511 | 5119 | +| 11 | 5119 | 0 | 511 | 5119 | +| 11 | 5119 | 0 | 472 | 4729 | +| 11 | 5119 | 0 | 511 | 5119 | +| 11+ | 5119 | 0 | 168 | 0 | +| 12 | 5119 | 0 | 168 | 0 | +| 12 | 5119 | 0 | 169 | 0 | +| 12 | 5119 | 0 | 170 | 0 | +| 12 | 5119 | 0 | 171 | 0 | +| 12 | 5119 | 0 | 172 | 0 | +| 12 | 5119 | 0 | 173 | 0 | +| 12 | 5119 | 0 | 174 | 0 | +| 12 | 5119 | 0 | 175 | 0 | +| 12+ | 21845 | 1 | 168 | 0 | +| 13 | 21845 | 1 | 168 | 21845 | +| 13+ | 21845 | 1 | 169 | 0 | +| 14 | 21845 | 1 | 169 | 21845 | +| 14+ | 21845 | 1 | 170 | 0 | +| 15 | 21845 | 1 | 170 | 21845 | +| 15+ | 21845 | 1 | 171 | 0 | +| 16 | 21845 | 1 | 171 | 21845 | +| 16+ | 21845 | 1 | 172 | 0 | +| 17 | 21845 | 1 | 172 | 21845 | +| 17+ | 21845 | 1 | 173 | 0 | +| 18 | 21845 | 1 | 173 | 21845 | +| 18+ | 21845 | 1 | 174 | 0 | +| 19 | 21845 | 1 | 174 | 21845 | +| 19+ | 21845 | 1 | 175 | 0 | +| 20 | 21845 | 1 | 175 | 21845 | +| 20+ | 21845 | 0 | 168 | 21845 | +| 21 | 21845 | 0 | 168 | 21845 | +| 21 | 21845 | 0 | 169 | 21845 | +| 21 | 21845 | 0 | 170 | 21845 | +| 21 | 21845 | 0 | 171 | 21845 | +| 21 | 21845 | 0 | 172 | 21845 | +| 21 | 21845 | 0 | 173 | 21845 | +| 21 | 21845 | 0 | 174 | 21845 | +| 21 | 21845 | 0 | 175 | 21845 | +| 21+ | -21846 | 1 | 168 | 21845 | +| 22 | -21846 | 1 | 168 | -21846 | +| 22+ | -21846 | 0 | 168 | -21846 | +| 23 | -21846 | 0 | 168 | -21846 | +| 23 | -21846 | 0 | 169 | 21845 | +| 23 | -21846 | 0 | 170 | 21845 | +| 23 | -21846 | 0 | 171 | 21845 | +| 23 | -21846 | 0 | 172 | 21845 | +| 23 | -21846 | 0 | 173 | 21845 | +| 23 | -21846 | 0 | 174 | 21845 | +| 23 | -21846 | 0 | 175 | 21845 | +| 23+ | 21845 | 1 | 168 | -21846 | +| 24 | 21845 | 1 | 168 | 21845 | +| 24+ | -21846 | 1 | 169 | 21845 | +| 25 | -21846 | 1 | 169 | -21846 | +| 25+ | -21846 | 0 | 168 | 21845 | +| 26 | -21846 | 0 | 168 | 21845 | +| 26 | -21846 | 0 | 169 | -21846 | +| 26 | -21846 | 0 | 170 | 21845 | +| 26 | -21846 | 0 | 171 | 21845 | +| 26 | -21846 | 0 | 172 | 21845 | +| 26 | -21846 | 0 | 173 | 21845 | +| 26 | -21846 | 0 | 174 | 21845 | +| 26 | -21846 | 0 | 175 | 21845 | +| 26+ | 21845 | 1 | 169 | -21846 | +| 27 | 21845 | 1 | 169 | 21845 | +| 27+ | -21846 | 1 | 170 | 21845 | +| 28 | -21846 | 1 | 170 | -21846 | +| 28+ | -21846 | 0 | 168 | 21845 | +| 29 | -21846 | 0 | 168 | 21845 | +| 29 | -21846 | 0 | 169 | 21845 | +| 29 | -21846 | 0 | 170 | -21846 | +| 29 | -21846 | 0 | 171 | 21845 | +| 29 | -21846 | 0 | 172 | 21845 | +| 29 | -21846 | 0 | 173 | 21845 | +| 29 | -21846 | 0 | 174 | 21845 | +| 29 | -21846 | 0 | 175 | 21845 | +| 29+ | 21845 | 1 | 170 | -21846 | +| 30 | 21845 | 1 | 170 | 21845 | +| 30+ | -21846 | 1 | 171 | 21845 | +| 31 | -21846 | 1 | 171 | -21846 | +| 31+ | -21846 | 0 | 168 | 21845 | +| 32 | -21846 | 0 | 168 | 21845 | +| 32 | -21846 | 0 | 169 | 21845 | +| 32 | -21846 | 0 | 170 | 21845 | +| 32 | -21846 | 0 | 171 | -21846 | +| 32 | -21846 | 0 | 172 | 21845 | +| 32 | -21846 | 0 | 173 | 21845 | +| 32 | -21846 | 0 | 174 | 21845 | +| 32 | -21846 | 0 | 175 | 21845 | +| 32+ | 21845 | 1 | 171 | -21846 | +| 33 | 21845 | 1 | 171 | 21845 | +| 33+ | -21846 | 1 | 172 | 21845 | +| 34 | -21846 | 1 | 172 | -21846 | +| 34+ | -21846 | 0 | 168 | 21845 | +| 35 | -21846 | 0 | 168 | 21845 | +| 35 | -21846 | 0 | 169 | 21845 | +| 35 | -21846 | 0 | 170 | 21845 | +| 35 | -21846 | 0 | 171 | 21845 | +| 35 | -21846 | 0 | 172 | -21846 | +| 35 | -21846 | 0 | 173 | 21845 | +| 35 | -21846 | 0 | 174 | 21845 | +| 35 | -21846 | 0 | 175 | 21845 | +| 35+ | 21845 | 1 | 172 | -21846 | +| 36 | 21845 | 1 | 172 | 21845 | +| 36+ | -21846 | 1 | 173 | 21845 | +| 37 | -21846 | 1 | 173 | -21846 | +| 37+ | -21846 | 0 | 168 | 21845 | +| 38 | -21846 | 0 | 168 | 21845 | +| 38 | -21846 | 0 | 169 | 21845 | +| 38 | -21846 | 0 | 170 | 21845 | +| 38 | -21846 | 0 | 171 | 21845 | +| 38 | -21846 | 0 | 172 | 21845 | +| 38 | -21846 | 0 | 173 | -21846 | +| 38 | -21846 | 0 | 174 | 21845 | +| 38 | -21846 | 0 | 175 | 21845 | +| 38+ | 21845 | 1 | 173 | -21846 | +| 39 | 21845 | 1 | 173 | 21845 | +| 39+ | -21846 | 1 | 174 | 21845 | +| 40 | -21846 | 1 | 174 | -21846 | +| 40+ | -21846 | 0 | 168 | 21845 | +| 41 | -21846 | 0 | 168 | 21845 | +| 41 | -21846 | 0 | 169 | 21845 | +| 41 | -21846 | 0 | 170 | 21845 | +| 41 | -21846 | 0 | 171 | 21845 | +| 41 | -21846 | 0 | 172 | 21845 | +| 41 | -21846 | 0 | 173 | 21845 | +| 41 | -21846 | 0 | 174 | -21846 | +| 41 | -21846 | 0 | 175 | 21845 | +| 41+ | 21845 | 1 | 174 | -21846 | +| 42 | 21845 | 1 | 174 | 21845 | +| 42+ | -21846 | 1 | 175 | 21845 | +| 43 | -21846 | 1 | 175 | -21846 | +| 43+ | -21846 | 0 | 168 | 21845 | +| 44 | -21846 | 0 | 168 | 21845 | +| 44 | -21846 | 0 | 169 | 21845 | +| 44 | -21846 | 0 | 170 | 21845 | +| 44 | -21846 | 0 | 171 | 21845 | +| 44 | -21846 | 0 | 172 | 21845 | +| 44 | -21846 | 0 | 173 | 21845 | +| 44 | -21846 | 0 | 174 | 21845 | +| 44 | -21846 | 0 | 175 | -21846 | +| 44+ | 21845 | 1 | 175 | -21846 | +| 45 | 21845 | 1 | 175 | 21845 | +| 45+ | 21845 | 0 | 168 | 21845 | +| 46 | 21845 | 0 | 168 | 21845 | +| 46 | 21845 | 0 | 169 | 21845 | +| 46 | 21845 | 0 | 170 | 21845 | +| 46 | 21845 | 0 | 171 | 21845 | +| 46 | 21845 | 0 | 172 | 21845 | +| 46 | 21845 | 0 | 173 | 21845 | +| 46 | 21845 | 0 | 174 | 21845 | +| 46 | 21845 | 0 | 175 | 21845 | +| 46+ | 21845 | 0 | 42 | 0 | +| 47 | 21845 | 0 | 42 | 0 | +| 47 | 21845 | 0 | 106 | 0 | +| 47 | 21845 | 0 | 170 | 21845 | +| 47 | 21845 | 0 | 234 | 0 | +| 47 | 21845 | 0 | 298 | 0 | +| 47 | 21845 | 0 | 362 | 0 | +| 47 | 21845 | 0 | 426 | 0 | +| 47 | 21845 | 0 | 490 | 0 | +| 47+ | 21845 | 1 | 42 | 0 | +| 48 | 21845 | 1 | 42 | 21845 | +| 48+ | 21845 | 1 | 106 | 0 | +| 49 | 21845 | 1 | 106 | 21845 | +| 49+ | 21845 | 1 | 170 | 21845 | +| 50 | 21845 | 1 | 170 | 21845 | +| 50+ | 21845 | 1 | 234 | 0 | +| 51 | 21845 | 1 | 234 | 21845 | +| 51+ | 21845 | 1 | 298 | 0 | +| 52 | 21845 | 1 | 298 | 21845 | +| 52+ | 21845 | 1 | 362 | 0 | +| 53 | 21845 | 1 | 362 | 21845 | +| 53+ | 21845 | 1 | 426 | 0 | +| 54 | 21845 | 1 | 426 | 21845 | +| 54+ | 21845 | 1 | 490 | 0 | +| 55 | 21845 | 1 | 490 | 21845 | +| 55+ | 21845 | 0 | 42 | 21845 | +| 56 | 21845 | 0 | 42 | 21845 | +| 56 | 21845 | 0 | 106 | 21845 | +| 56 | 21845 | 0 | 170 | 21845 | +| 56 | 21845 | 0 | 234 | 21845 | +| 56 | 21845 | 0 | 298 | 21845 | +| 56 | 21845 | 0 | 362 | 21845 | +| 56 | 21845 | 0 | 426 | 21845 | +| 56 | 21845 | 0 | 490 | 21845 | +| 56+ | -21846 | 1 | 42 | 21845 | +| 57 | -21846 | 1 | 42 | -21846 | +| 57+ | -21846 | 0 | 42 | -21846 | +| 58 | -21846 | 0 | 42 | -21846 | +| 58 | -21846 | 0 | 106 | 21845 | +| 58 | -21846 | 0 | 170 | 21845 | +| 58 | -21846 | 0 | 234 | 21845 | +| 58 | -21846 | 0 | 298 | 21845 | +| 58 | -21846 | 0 | 362 | 21845 | +| 58 | -21846 | 0 | 426 | 21845 | +| 58 | -21846 | 0 | 490 | 21845 | +| 58+ | 21845 | 1 | 42 | -21846 | +| 59 | 21845 | 1 | 42 | 21845 | +| 59+ | -21846 | 1 | 106 | 21845 | +| 60 | -21846 | 1 | 106 | -21846 | +| 60+ | -21846 | 0 | 42 | 21845 | +| 61 | -21846 | 0 | 42 | 21845 | +| 61 | -21846 | 0 | 106 | -21846 | +| 61 | -21846 | 0 | 170 | 21845 | +| 61 | -21846 | 0 | 234 | 21845 | +| 61 | -21846 | 0 | 298 | 21845 | +| 61 | -21846 | 0 | 362 | 21845 | +| 61 | -21846 | 0 | 426 | 21845 | +| 61 | -21846 | 0 | 490 | 21845 | +| 61+ | 21845 | 1 | 106 | -21846 | +| 62 | 21845 | 1 | 106 | 21845 | +| 62+ | -21846 | 1 | 170 | 21845 | +| 63 | -21846 | 1 | 170 | -21846 | +| 63+ | -21846 | 0 | 42 | 21845 | +| 64 | -21846 | 0 | 42 | 21845 | +| 64 | -21846 | 0 | 106 | 21845 | +| 64 | -21846 | 0 | 170 | -21846 | +| 64 | -21846 | 0 | 234 | 21845 | +| 64 | -21846 | 0 | 298 | 21845 | +| 64 | -21846 | 0 | 362 | 21845 | +| 64 | -21846 | 0 | 426 | 21845 | +| 64 | -21846 | 0 | 490 | 21845 | +| 64+ | 21845 | 1 | 170 | -21846 | +| 65 | 21845 | 1 | 170 | 21845 | +| 65+ | -21846 | 1 | 234 | 21845 | +| 66 | -21846 | 1 | 234 | -21846 | +| 66+ | -21846 | 0 | 42 | 21845 | +| 67 | -21846 | 0 | 42 | 21845 | +| 67 | -21846 | 0 | 106 | 21845 | +| 67 | -21846 | 0 | 170 | 21845 | +| 67 | -21846 | 0 | 234 | -21846 | +| 67 | -21846 | 0 | 298 | 21845 | +| 67 | -21846 | 0 | 362 | 21845 | +| 67 | -21846 | 0 | 426 | 21845 | +| 67 | -21846 | 0 | 490 | 21845 | +| 67+ | 21845 | 1 | 234 | -21846 | +| 68 | 21845 | 1 | 234 | 21845 | +| 68+ | -21846 | 1 | 298 | 21845 | +| 69 | -21846 | 1 | 298 | -21846 | +| 69+ | -21846 | 0 | 42 | 21845 | +| 70 | -21846 | 0 | 42 | 21845 | +| 70 | -21846 | 0 | 106 | 21845 | +| 70 | -21846 | 0 | 170 | 21845 | +| 70 | -21846 | 0 | 234 | 21845 | +| 70 | -21846 | 0 | 298 | -21846 | +| 70 | -21846 | 0 | 362 | 21845 | +| 70 | -21846 | 0 | 426 | 21845 | +| 70 | -21846 | 0 | 490 | 21845 | +| 70+ | 21845 | 1 | 298 | -21846 | +| 71 | 21845 | 1 | 298 | 21845 | +| 71+ | -21846 | 1 | 362 | 21845 | +| 72 | -21846 | 1 | 362 | -21846 | +| 72+ | -21846 | 0 | 42 | 21845 | +| 73 | -21846 | 0 | 42 | 21845 | +| 73 | -21846 | 0 | 106 | 21845 | +| 73 | -21846 | 0 | 170 | 21845 | +| 73 | -21846 | 0 | 234 | 21845 | +| 73 | -21846 | 0 | 298 | 21845 | +| 73 | -21846 | 0 | 362 | -21846 | +| 73 | -21846 | 0 | 426 | 21845 | +| 73 | -21846 | 0 | 490 | 21845 | +| 73+ | 21845 | 1 | 362 | -21846 | +| 74 | 21845 | 1 | 362 | 21845 | +| 74+ | -21846 | 1 | 426 | 21845 | +| 75 | -21846 | 1 | 426 | -21846 | +| 75+ | -21846 | 0 | 42 | 21845 | +| 76 | -21846 | 0 | 42 | 21845 | +| 76 | -21846 | 0 | 106 | 21845 | +| 76 | -21846 | 0 | 170 | 21845 | +| 76 | -21846 | 0 | 234 | 21845 | +| 76 | -21846 | 0 | 298 | 21845 | +| 76 | -21846 | 0 | 362 | 21845 | +| 76 | -21846 | 0 | 426 | -21846 | +| 76 | -21846 | 0 | 490 | 21845 | +| 76+ | 21845 | 1 | 426 | -21846 | +| 77 | 21845 | 1 | 426 | 21845 | +| 77+ | -21846 | 1 | 490 | 21845 | +| 78 | -21846 | 1 | 490 | -21846 | +| 78+ | -21846 | 0 | 42 | 21845 | +| 79 | -21846 | 0 | 42 | 21845 | +| 79 | -21846 | 0 | 106 | 21845 | +| 79 | -21846 | 0 | 170 | 21845 | +| 79 | -21846 | 0 | 234 | 21845 | +| 79 | -21846 | 0 | 298 | 21845 | +| 79 | -21846 | 0 | 362 | 21845 | +| 79 | -21846 | 0 | 426 | 21845 | +| 79 | -21846 | 0 | 490 | -21846 | +| 79+ | 21845 | 1 | 490 | -21846 | +| 80 | 21845 | 1 | 490 | 21845 | +| 80+ | 21845 | 0 | 42 | 21845 | +| 81 | 21845 | 0 | 42 | 21845 | +| 81 | 21845 | 0 | 106 | 21845 | +| 81 | 21845 | 0 | 170 | 21845 | +| 81 | 21845 | 0 | 234 | 21845 | +| 81 | 21845 | 0 | 298 | 21845 | +| 81 | 21845 | 0 | 362 | 21845 | +| 81 | 21845 | 0 | 426 | 21845 | +| 81 | 21845 | 0 | 490 | 21845 | diff --git a/projects/03/b/RAM512.tst b/projects/03/b/RAM512.tst new file mode 100755 index 0000000..4ec6fc2 --- /dev/null +++ b/projects/03/b/RAM512.tst @@ -0,0 +1,1027 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/b/RAM512.tst + +load RAM512.hdl, +output-file RAM512.out, +compare-to RAM512.cmp, +output-list time%S1.4.1 in%D1.6.1 load%B2.1.2 address%D2.3.2 out%D1.6.1; + +set in 0, +set load 0, +set address 0, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set in 13099, +set load 0, +tick, +output; +tock, +output; + +set load 1, +set address 130, +tick, +output; +tock, +output; + +set load 0, +set address 0, +tick, +output; +tock, +output; + +set in 4729, +set address 472, +tick, +output; +tock, +output; + +set load 1, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 130, +eval, +output; + +set in 5119, +tick, +output; +tock, +output; + +set load 1, +set address 511, +tick, +output; +tock, +output; + +set load 0, +tick, +output; +tock, +output; + +set address 472, +eval, +output; + +set address 511, +eval, +output; + + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +tick, +output, +tock, +output; +set address %B010101010, +tick, +output, +tock, +output; +set address %B010101011, +tick, +output, +tock, +output; +set address %B010101100, +tick, +output, +tock, +output; +set address %B010101101, +tick, +output, +tock, +output; +set address %B010101110, +tick, +output, +tock, +output; +set address %B010101111, +tick, +output, +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101000, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101000, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101001, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101001, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101011, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101011, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101100, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101100, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101101, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101101, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101110, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101110, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101111, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + +set load 1, +set address %B010101111, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B010101000, +tick, +output; +tock, +output; +set address %B010101001, +eval, +output; +set address %B010101010, +eval, +output; +set address %B010101011, +eval, +output; +set address %B010101100, +eval, +output; +set address %B010101101, +eval, +output; +set address %B010101110, +eval, +output; +set address %B010101111, +eval, +output; + + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set in %B0101010101010101, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +tick, +output, +tock, +output; +set address %B010101010, +tick, +output, +tock, +output; +set address %B011101010, +tick, +output, +tock, +output; +set address %B100101010, +tick, +output, +tock, +output; +set address %B101101010, +tick, +output, +tock, +output; +set address %B110101010, +tick, +output, +tock, +output; +set address %B111101010, +tick, +output, +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B000101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B000101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B001101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B001101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B010101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B010101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B011101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B011101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B100101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B100101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B101101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B101101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B110101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B110101010, +set in %B0101010101010101, +tick, +output, +tock, +output; +set address %B111101010, +set in %B1010101010101010, +tick, +output; +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + +set load 1, +set address %B111101010, +set in %B0101010101010101, +tick, +output, +tock, +output; + +set load 0, +set address %B000101010, +tick, +output; +tock, +output; +set address %B001101010, +eval, +output; +set address %B010101010, +eval, +output; +set address %B011101010, +eval, +output; +set address %B100101010, +eval, +output; +set address %B101101010, +eval, +output; +set address %B110101010, +eval, +output; +set address %B111101010, +eval, +output; + diff --git a/projects/04/Fill.asm b/projects/04/Fill.asm new file mode 100755 index 0000000..c96edc6 --- /dev/null +++ b/projects/04/Fill.asm @@ -0,0 +1,97 @@ +@END //check if button is pressed +0;JMP + +(BLACK) +//start= 16384 the start of the screen memory +@SCREEN +D=A +@start +M=D + +//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen +@8192 +D=A +@n +M=D + +//i=0 this is the index for each group of pixels +@i +M=0 + +(LOOP1) +//if i==n goto end +@i +D=M +@n +D=D-M +@END +D;JEQ + +//start+1=-1 set each group of pixels to -1 which is = 111111111111 +@start +D=M +@i +A=D+M +M=-1 + +// increment i by 1 +@i +M=M+1 + +// go back to the start of the loop +@LOOP1 +0;JMP + +(WHITE) +//start= 16384 the start of the screen memory +@SCREEN +D=A +@start +M=D + +//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen +@8192 +D=A +@n +M=D + +//i=0 this is the index for each group of pixels +@i +M=0 + +(LOOP2) +//if i==n goto end +@i +D=M +@n +D=D-M +@END +D;JEQ + +//start+1=-1 set each group of pixels to 0 which is = 00000000 +@start +D=M +@i +A=D+M +M=0 + +// increment i by 1 +@i +M=M+1 + +// go back to the start of the loop +@LOOP2 +0;JMP + +//check if button is pressed +(END) +@KBD +D=M +@WHITE +D;JEQ +@KBD +D=M +@BLACK +D;JNE +@END +0;JMP \ No newline at end of file diff --git a/projects/04/Mult.asm b/projects/04/Mult.asm new file mode 100755 index 0000000..59bb1ac --- /dev/null +++ b/projects/04/Mult.asm @@ -0,0 +1,24 @@ +@R2 +M=0 +@sum +M=0 +(LOOP) +@1 +D=M +@END +D;JEQ // if R1==0 goto end +@R0 +D=M // D=R0 +@sum +M=M+D // sum=sum+R0 +@R1 +M=M-1 //R1=R1-1 +@sum +D=M +@R2 +M=D +@LOOP +0;JMP +(END) +@END +0;JMP \ No newline at end of file diff --git a/projects/04/fill/Fill.asm b/projects/04/fill/Fill.asm new file mode 100755 index 0000000..c96edc6 --- /dev/null +++ b/projects/04/fill/Fill.asm @@ -0,0 +1,97 @@ +@END //check if button is pressed +0;JMP + +(BLACK) +//start= 16384 the start of the screen memory +@SCREEN +D=A +@start +M=D + +//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen +@8192 +D=A +@n +M=D + +//i=0 this is the index for each group of pixels +@i +M=0 + +(LOOP1) +//if i==n goto end +@i +D=M +@n +D=D-M +@END +D;JEQ + +//start+1=-1 set each group of pixels to -1 which is = 111111111111 +@start +D=M +@i +A=D+M +M=-1 + +// increment i by 1 +@i +M=M+1 + +// go back to the start of the loop +@LOOP1 +0;JMP + +(WHITE) +//start= 16384 the start of the screen memory +@SCREEN +D=A +@start +M=D + +//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen +@8192 +D=A +@n +M=D + +//i=0 this is the index for each group of pixels +@i +M=0 + +(LOOP2) +//if i==n goto end +@i +D=M +@n +D=D-M +@END +D;JEQ + +//start+1=-1 set each group of pixels to 0 which is = 00000000 +@start +D=M +@i +A=D+M +M=0 + +// increment i by 1 +@i +M=M+1 + +// go back to the start of the loop +@LOOP2 +0;JMP + +//check if button is pressed +(END) +@KBD +D=M +@WHITE +D;JEQ +@KBD +D=M +@BLACK +D;JNE +@END +0;JMP \ No newline at end of file diff --git a/projects/04/fill/Fill.tst b/projects/04/fill/Fill.tst new file mode 100755 index 0000000..e8bb385 --- /dev/null +++ b/projects/04/fill/Fill.tst @@ -0,0 +1,11 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/04/fill/Fill.tst + +load Fill.asm; +echo "Make sure that 'No Animation' is selected. Then, select the keyboard, press any key for some time, and inspect the screen."; + +repeat { + ticktock; +} diff --git a/projects/04/fill/FillAutomatic.cmp b/projects/04/fill/FillAutomatic.cmp new file mode 100755 index 0000000..a71db27 --- /dev/null +++ b/projects/04/fill/FillAutomatic.cmp @@ -0,0 +1,4 @@ +|RAM[16384]|RAM[17648]|RAM[18349]|RAM[19444]|RAM[20771]|RAM[21031]|RAM[22596]|RAM[23754]|RAM[24575]| +| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | +| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | diff --git a/projects/04/fill/FillAutomatic.tst b/projects/04/fill/FillAutomatic.tst new file mode 100755 index 0000000..fbc29a0 --- /dev/null +++ b/projects/04/fill/FillAutomatic.tst @@ -0,0 +1,37 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/04/fill/FillAutomatic + +// This script can be used to test the Fill program automatically, +// rather than interactively. Specifically, the script sets the keyboard +// memory map (RAM[24576]) to 0, 1, and then again to 0. This simulates the +// acts of leaving the keyboard untouched, pressing some key, and then releasing +// the key. After each on of these simulated events, the script outputs the values +// of some selected registers from the screen memory map (RAM[16384]-RAM[24576]). +// This is done in order to test that these registers are set to 000...0 or 111....1, +// as mandated by how the Fill program should react to the keyboard events. + +load Fill.asm, +output-file FillAutomatic.out, +compare-to FillAutomatic.cmp, +output-list RAM[16384]%D2.6.2 RAM[17648]%D2.6.2 RAM[18349]%D2.6.2 RAM[19444]%D2.6.2 RAM[20771]%D2.6.2 RAM[21031]%D2.6.2 RAM[22596]%D2.6.2 RAM[23754]%D2.6.2 RAM[24575]%D2.6.2; + +set RAM[24576] 0, // the keyboard is untouched +repeat 1000000 { + ticktock; +} +output; // test that the screen is white + +set RAM[24576] 1, // a keyboard key is pressed +repeat 1000000 { + ticktock; +} +output; // test that the screen is black + +set RAM[24576] 0, // they keyboard in untouched +repeat 1000000 { + ticktock; +} +output; // test that the screen is white + diff --git a/projects/04/mult/Mult.asm b/projects/04/mult/Mult.asm new file mode 100755 index 0000000..59bb1ac --- /dev/null +++ b/projects/04/mult/Mult.asm @@ -0,0 +1,24 @@ +@R2 +M=0 +@sum +M=0 +(LOOP) +@1 +D=M +@END +D;JEQ // if R1==0 goto end +@R0 +D=M // D=R0 +@sum +M=M+D // sum=sum+R0 +@R1 +M=M-1 //R1=R1-1 +@sum +D=M +@R2 +M=D +@LOOP +0;JMP +(END) +@END +0;JMP \ No newline at end of file diff --git a/projects/04/mult/Mult.cmp b/projects/04/mult/Mult.cmp new file mode 100755 index 0000000..296b5fb --- /dev/null +++ b/projects/04/mult/Mult.cmp @@ -0,0 +1,7 @@ +| RAM[0] | RAM[1] | RAM[2] | +| 0 | 0 | 0 | +| 1 | 0 | 0 | +| 0 | 2 | 0 | +| 3 | 1 | 3 | +| 2 | 4 | 8 | +| 6 | 7 | 42 | \ No newline at end of file diff --git a/projects/04/mult/Mult.out b/projects/04/mult/Mult.out new file mode 100755 index 0000000..e69de29 diff --git a/projects/04/mult/Mult.tst b/projects/04/mult/Mult.tst new file mode 100755 index 0000000..9bf4fa8 --- /dev/null +++ b/projects/04/mult/Mult.tst @@ -0,0 +1,74 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/04/mult/Mult.tst + +load Mult.asm, +output-file Mult.out, +compare-to Mult.cmp, +output-list RAM[0]%D2.6.2 RAM[1]%D2.6.2 RAM[2]%D2.6.2; + +set RAM[0] 0, // Set test arguments +set RAM[1] 0, +set RAM[2] -1; // Test that program initialized product to 0 +repeat 20 { + ticktock; +} +set RAM[0] 0, // Restore arguments in case program used them as loop counter +set RAM[1] 0, +output; + +set PC 0, +set RAM[0] 1, // Set test arguments +set RAM[1] 0, +set RAM[2] -1; // Ensure that program initialized product to 0 +repeat 50 { + ticktock; +} +set RAM[0] 1, // Restore arguments in case program used them as loop counter +set RAM[1] 0, +output; + +set PC 0, +set RAM[0] 0, // Set test arguments +set RAM[1] 2, +set RAM[2] -1; // Ensure that program initialized product to 0 +repeat 80 { + ticktock; +} +set RAM[0] 0, // Restore arguments in case program used them as loop counter +set RAM[1] 2, +output; + +set PC 0, +set RAM[0] 3, // Set test arguments +set RAM[1] 1, +set RAM[2] -1; // Ensure that program initialized product to 0 +repeat 120 { + ticktock; +} +set RAM[0] 3, // Restore arguments in case program used them as loop counter +set RAM[1] 1, +output; + +set PC 0, +set RAM[0] 2, // Set test arguments +set RAM[1] 4, +set RAM[2] -1; // Ensure that program initialized product to 0 +repeat 150 { + ticktock; +} +set RAM[0] 2, // Restore arguments in case program used them as loop counter +set RAM[1] 4, +output; + +set PC 0, +set RAM[0] 6, // Set test arguments +set RAM[1] 7, +set RAM[2] -1; // Ensure that program initialized product to 0 +repeat 210 { + ticktock; +} +set RAM[0] 6, // Restore arguments in case program used them as loop counter +set RAM[1] 7, +output; diff --git a/projects/05/Add.hack b/projects/05/Add.hack new file mode 100755 index 0000000..fe5969d --- /dev/null +++ b/projects/05/Add.hack @@ -0,0 +1,6 @@ +0000000000000010 +1110110000010000 +0000000000000011 +1110000010010000 +0000000000000000 +1110001100001000 diff --git a/projects/05/CPU-external.cmp b/projects/05/CPU-external.cmp new file mode 100755 index 0000000..58f43bd --- /dev/null +++ b/projects/05/CPU-external.cmp @@ -0,0 +1,93 @@ +|time| inM | instruction |reset| outM |writeM |addre| pc | +|0+ | 0|0011000000111001| 0 |*******| 0 | 0| 0| +|1 | 0|0011000000111001| 0 |*******| 0 |12345| 1| +|1+ | 0|1110110000010000| 0 |*******| 0 |12345| 1| +|2 | 0|1110110000010000| 0 |*******| 0 |12345| 2| +|2+ | 0|0101101110100000| 0 |*******| 0 |12345| 2| +|3 | 0|0101101110100000| 0 |*******| 0 |23456| 3| +|3+ | 0|1110000111010000| 0 |*******| 0 |23456| 3| +|4 | 0|1110000111010000| 0 |*******| 0 |23456| 4| +|4+ | 0|0000001111101000| 0 |*******| 0 |23456| 4| +|5 | 0|0000001111101000| 0 |*******| 0 | 1000| 5| +|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5| +|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6| +|6+ | 0|0000001111101001| 0 |*******| 0 | 1000| 6| +|7 | 0|0000001111101001| 0 |*******| 0 | 1001| 7| +|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7| +|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8| +|8+ | 0|0000001111101000| 0 |*******| 0 | 1001| 8| +|9 | 0|0000001111101000| 0 |*******| 0 | 1000| 9| +|9+ | 11111|1111010011010000| 0 |*******| 0 | 1000| 9| +|10 | 11111|1111010011010000| 0 |*******| 0 | 1000| 10| +|10+ | 11111|0000000000001110| 0 |*******| 0 | 1000| 10| +|11 | 11111|0000000000001110| 0 |*******| 0 | 14| 11| +|11+ | 11111|1110001100000100| 0 |*******| 0 | 14| 11| +|12 | 11111|1110001100000100| 0 |*******| 0 | 14| 14| +|12+ | 11111|0000001111100111| 0 |*******| 0 | 14| 14| +|13 | 11111|0000001111100111| 0 |*******| 0 | 999| 15| +|13+ | 11111|1110110111100000| 0 |*******| 0 | 999| 15| +|14 | 11111|1110110111100000| 0 |*******| 0 | 1000| 16| +|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16| +|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17| +|15+ | 11111|0000000000010101| 0 |*******| 0 | 1000| 17| +|16 | 11111|0000000000010101| 0 |*******| 0 | 21| 18| +|16+ | 11111|1110011111000010| 0 |*******| 0 | 21| 18| +|17 | 11111|1110011111000010| 0 |*******| 0 | 21| 21| +|17+ | 11111|0000000000000010| 0 |*******| 0 | 21| 21| +|18 | 11111|0000000000000010| 0 |*******| 0 | 2| 22| +|18+ | 11111|1110000010010000| 0 |*******| 0 | 2| 22| +|19 | 11111|1110000010010000| 0 |*******| 0 | 2| 23| +|19+ | 11111|0000001111101000| 0 |*******| 0 | 2| 23| +|20 | 11111|0000001111101000| 0 |*******| 0 | 1000| 24| +|20+ | 11111|1110111010010000| 0 |*******| 0 | 1000| 24| +|21 | 11111|1110111010010000| 0 |*******| 0 | 1000| 25| +|21+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 25| +|22 | 11111|1110001100000001| 0 |*******| 0 | 1000| 26| +|22+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 26| +|23 | 11111|1110001100000010| 0 |*******| 0 | 1000| 27| +|23+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 27| +|24 | 11111|1110001100000011| 0 |*******| 0 | 1000| 28| +|24+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 28| +|25 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| +|25+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| +|26 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| +|26+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| +|27 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| +|27+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| +|28 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| +|28+ | 11111|1110101010010000| 0 |*******| 0 | 1000| 1000| +|29 | 11111|1110101010010000| 0 |*******| 0 | 1000| 1001| +|29+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 1001| +|30 | 11111|1110001100000001| 0 |*******| 0 | 1000| 1002| +|30+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 1002| +|31 | 11111|1110001100000010| 0 |*******| 0 | 1000| 1000| +|31+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| +|32 | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| +|32+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| +|33 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1001| +|33+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1001| +|34 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1002| +|34+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1002| +|35 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| +|35+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| +|36 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| +|36+ | 11111|1110111111010000| 0 |*******| 0 | 1000| 1000| +|37 | 11111|1110111111010000| 0 |*******| 0 | 1000| 1001| +|37+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 1001| +|38 | 11111|1110001100000001| 0 |*******| 0 | 1000| 1000| +|38+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 1000| +|39 | 11111|1110001100000010| 0 |*******| 0 | 1000| 1001| +|39+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 1001| +|40 | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| +|40+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| +|41 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1001| +|41+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1001| +|42 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| +|42+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| +|43 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1001| +|43+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1001| +|44 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| +|44+ | 11111|1110001100000111| 1 |*******| 0 | 1000| 1000| +|45 | 11111|1110001100000111| 1 |*******| 0 | 1000| 0| +|45+ | 11111|0111111111111111| 0 |*******| 0 | 1000| 0| +|46 | 11111|0111111111111111| 0 |*******| 0 |32767| 1| diff --git a/projects/05/CPU-external.out b/projects/05/CPU-external.out new file mode 100755 index 0000000..89c74c3 --- /dev/null +++ b/projects/05/CPU-external.out @@ -0,0 +1,93 @@ +|time| inM | instruction |reset| outM |writeM |addre| pc | +|0+ | 0|0011000000111001| 0 | 0| 0 | 0| 0| +|1 | 0|0011000000111001| 0 | 0| 0 |12345| 1| +|1+ | 0|1110110000010000| 0 | 12345| 0 |12345| 1| +|2 | 0|1110110000010000| 0 | 12345| 0 |12345| 2| +|2+ | 0|0101101110100000| 0 | -1| 0 |12345| 2| +|3 | 0|0101101110100000| 0 | -1| 0 |23456| 3| +|3+ | 0|1110000111010000| 0 | 11111| 0 |23456| 3| +|4 | 0|1110000111010000| 0 | 12345| 0 |23456| 4| +|4+ | 0|0000001111101000| 0 | -11111| 0 |23456| 4| +|5 | 0|0000001111101000| 0 | -11111| 0 | 1000| 5| +|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5| +|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6| +|6+ | 0|0000001111101001| 0 | -11111| 0 | 1000| 6| +|7 | 0|0000001111101001| 0 | -11111| 0 | 1001| 7| +|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7| +|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8| +|8+ | 0|0000001111101000| 0 | -11110| 0 | 1001| 8| +|9 | 0|0000001111101000| 0 | -11110| 0 | 1000| 9| +|9+ | 11111|1111010011010000| 0 | -1| 0 | 1000| 9| +|10 | 11111|1111010011010000| 0 | -11112| 0 | 1000| 10| +|10+ | 11111|0000000000001110| 0 | 1000| 0 | 1000| 10| +|11 | 11111|0000000000001110| 0 | 14| 0 | 14| 11| +|11+ | 11111|1110001100000100| 0 | -1| 0 | 14| 11| +|12 | 11111|1110001100000100| 0 | -1| 0 | 14| 14| +|12+ | 11111|0000001111100111| 0 | 1| 0 | 14| 14| +|13 | 11111|0000001111100111| 0 | 1| 0 | 999| 15| +|13+ | 11111|1110110111100000| 0 | 1000| 0 | 999| 15| +|14 | 11111|1110110111100000| 0 | 1001| 0 | 1000| 16| +|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16| +|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17| +|15+ | 11111|0000000000010101| 0 | 1000| 0 | 1000| 17| +|16 | 11111|0000000000010101| 0 | 21| 0 | 21| 18| +|16+ | 11111|1110011111000010| 0 | 0| 0 | 21| 18| +|17 | 11111|1110011111000010| 0 | 0| 0 | 21| 21| +|17+ | 11111|0000000000000010| 0 | 21| 0 | 21| 21| +|18 | 11111|0000000000000010| 0 | 2| 0 | 2| 22| +|18+ | 11111|1110000010010000| 0 | 1| 0 | 2| 22| +|19 | 11111|1110000010010000| 0 | 3| 0 | 2| 23| +|19+ | 11111|0000001111101000| 0 | -1| 0 | 2| 23| +|20 | 11111|0000001111101000| 0 | -1| 0 | 1000| 24| +|20+ | 11111|1110111010010000| 0 | -1| 0 | 1000| 24| +|21 | 11111|1110111010010000| 0 | -1| 0 | 1000| 25| +|21+ | 11111|1110001100000001| 0 | -1| 0 | 1000| 25| +|22 | 11111|1110001100000001| 0 | -1| 0 | 1000| 26| +|22+ | 11111|1110001100000010| 0 | -1| 0 | 1000| 26| +|23 | 11111|1110001100000010| 0 | -1| 0 | 1000| 27| +|23+ | 11111|1110001100000011| 0 | -1| 0 | 1000| 27| +|24 | 11111|1110001100000011| 0 | -1| 0 | 1000| 28| +|24+ | 11111|1110001100000100| 0 | -1| 0 | 1000| 28| +|25 | 11111|1110001100000100| 0 | -1| 0 | 1000| 1000| +|25+ | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| +|26 | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| +|26+ | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| +|27 | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| +|27+ | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| +|28 | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| +|28+ | 11111|1110101010010000| 0 | 0| 0 | 1000| 1000| +|29 | 11111|1110101010010000| 0 | 0| 0 | 1000| 1001| +|29+ | 11111|1110001100000001| 0 | 0| 0 | 1000| 1001| +|30 | 11111|1110001100000001| 0 | 0| 0 | 1000| 1002| +|30+ | 11111|1110001100000010| 0 | 0| 0 | 1000| 1002| +|31 | 11111|1110001100000010| 0 | 0| 0 | 1000| 1000| +|31+ | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| +|32 | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| +|32+ | 11111|1110001100000100| 0 | 0| 0 | 1000| 1000| +|33 | 11111|1110001100000100| 0 | 0| 0 | 1000| 1001| +|33+ | 11111|1110001100000101| 0 | 0| 0 | 1000| 1001| +|34 | 11111|1110001100000101| 0 | 0| 0 | 1000| 1002| +|34+ | 11111|1110001100000110| 0 | 0| 0 | 1000| 1002| +|35 | 11111|1110001100000110| 0 | 0| 0 | 1000| 1000| +|35+ | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| +|36 | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| +|36+ | 11111|1110111111010000| 0 | 1| 0 | 1000| 1000| +|37 | 11111|1110111111010000| 0 | 1| 0 | 1000| 1001| +|37+ | 11111|1110001100000001| 0 | 1| 0 | 1000| 1001| +|38 | 11111|1110001100000001| 0 | 1| 0 | 1000| 1000| +|38+ | 11111|1110001100000010| 0 | 1| 0 | 1000| 1000| +|39 | 11111|1110001100000010| 0 | 1| 0 | 1000| 1001| +|39+ | 11111|1110001100000011| 0 | 1| 0 | 1000| 1001| +|40 | 11111|1110001100000011| 0 | 1| 0 | 1000| 1000| +|40+ | 11111|1110001100000100| 0 | 1| 0 | 1000| 1000| +|41 | 11111|1110001100000100| 0 | 1| 0 | 1000| 1001| +|41+ | 11111|1110001100000101| 0 | 1| 0 | 1000| 1001| +|42 | 11111|1110001100000101| 0 | 1| 0 | 1000| 1000| +|42+ | 11111|1110001100000110| 0 | 1| 0 | 1000| 1000| +|43 | 11111|1110001100000110| 0 | 1| 0 | 1000| 1001| +|43+ | 11111|1110001100000111| 0 | 1| 0 | 1000| 1001| +|44 | 11111|1110001100000111| 0 | 1| 0 | 1000| 1000| +|44+ | 11111|1110001100000111| 1 | 1| 0 | 1000| 1000| +|45 | 11111|1110001100000111| 1 | 1| 0 | 1000| 0| +|45+ | 11111|0111111111111111| 0 | 1| 0 | 1000| 0| +|46 | 11111|0111111111111111| 0 | 1| 0 |32767| 1| diff --git a/projects/05/CPU-external.tst b/projects/05/CPU-external.tst new file mode 100755 index 0000000..5aa0295 --- /dev/null +++ b/projects/05/CPU-external.tst @@ -0,0 +1,150 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/CPU-external.tst + +load CPU.hdl, +output-file CPU-external.out, +compare-to CPU-external.cmp, +output-list time%S0.4.0 inM%D0.6.0 instruction%B0.16.0 reset%B2.1.2 outM%D1.6.0 writeM%B3.1.3 addressM%D0.5.0 pc%D0.5.0; + + +set instruction %B0011000000111001, // @12345 +tick, output, tock, output; + +set instruction %B1110110000010000, // D=A +tick, output, tock, output; + +set instruction %B0101101110100000, // @23456 +tick, output, tock, output; + +set instruction %B1110000111010000, // D=A-D +tick, output, tock, output; + +set instruction %B0000001111101000, // @1000 +tick, output, tock, output; + +set instruction %B1110001100001000, // M=D +tick, output, tock, output; + +set instruction %B0000001111101001, // @1001 +tick, output, tock, output; + +set instruction %B1110001110011000, // MD=D-1 +tick, output, tock, output; + +set instruction %B0000001111101000, // @1000 +tick, output, tock, output; + +set instruction %B1111010011010000, // D=D-M +set inM 11111, +tick, output, tock, output; + +set instruction %B0000000000001110, // @14 +tick, output, tock, output; + +set instruction %B1110001100000100, // D;jlt +tick, output, tock, output; + +set instruction %B0000001111100111, // @999 +tick, output, tock, output; + +set instruction %B1110110111100000, // A=A+1 +tick, output, tock, output; + +set instruction %B1110001100001000, // M=D +tick, output, tock, output; + +set instruction %B0000000000010101, // @21 +tick, output, tock, output; + +set instruction %B1110011111000010, // D+1;jeq +tick, output, tock, output; + +set instruction %B0000000000000010, // @2 +tick, output, tock, output; + +set instruction %B1110000010010000, // D=D+A +tick, output, tock, output; + +set instruction %B0000001111101000, // @1000 +tick, output, tock, output; + +set instruction %B1110111010010000, // D=-1 +tick, output, tock, output; + +set instruction %B1110001100000001, // D;JGT +tick, output, tock, output; + +set instruction %B1110001100000010, // D;JEQ +tick, output, tock, output; + +set instruction %B1110001100000011, // D;JGE +tick, output, tock, output; + +set instruction %B1110001100000100, // D;JLT +tick, output, tock, output; + +set instruction %B1110001100000101, // D;JNE +tick, output, tock, output; + +set instruction %B1110001100000110, // D;JLE +tick, output, tock, output; + +set instruction %B1110001100000111, // D;JMP +tick, output, tock, output; + +set instruction %B1110101010010000, // D=0 +tick, output, tock, output; + +set instruction %B1110001100000001, // D;JGT +tick, output, tock, output; + +set instruction %B1110001100000010, // D;JEQ +tick, output, tock, output; + +set instruction %B1110001100000011, // D;JGE +tick, output, tock, output; + +set instruction %B1110001100000100, // D;JLT +tick, output, tock, output; + +set instruction %B1110001100000101, // D;JNE +tick, output, tock, output; + +set instruction %B1110001100000110, // D;JLE +tick, output, tock, output; + +set instruction %B1110001100000111, // D;JMP +tick, output, tock, output; + +set instruction %B1110111111010000, // D=1 +tick, output, tock, output; + +set instruction %B1110001100000001, // D;JGT +tick, output, tock, output; + +set instruction %B1110001100000010, // D;JEQ +tick, output, tock, output; + +set instruction %B1110001100000011, // D;JGE +tick, output, tock, output; + +set instruction %B1110001100000100, // D;JLT +tick, output, tock, output; + +set instruction %B1110001100000101, // D;JNE +tick, output, tock, output; + +set instruction %B1110001100000110, // D;JLE +tick, output, tock, output; + +set instruction %B1110001100000111, // D;JMP +tick, output, tock, output; + +set reset 1; +tick, output, tock, output; + +set instruction %B0111111111111111, // @32767 +set reset 0; +tick, output, tock, output; diff --git a/projects/05/CPU.cmp b/projects/05/CPU.cmp new file mode 100755 index 0000000..345674c --- /dev/null +++ b/projects/05/CPU.cmp @@ -0,0 +1,93 @@ +|time| inM | instruction |reset| outM |writeM |addre| pc |DRegiste| +|0+ | 0|0011000000111001| 0 |*******| 0 | 0| 0| 0 | +|1 | 0|0011000000111001| 0 |*******| 0 |12345| 1| 0 | +|1+ | 0|1110110000010000| 0 |*******| 0 |12345| 1| 12345 | +|2 | 0|1110110000010000| 0 |*******| 0 |12345| 2| 12345 | +|2+ | 0|0101101110100000| 0 |*******| 0 |12345| 2| 12345 | +|3 | 0|0101101110100000| 0 |*******| 0 |23456| 3| 12345 | +|3+ | 0|1110000111010000| 0 |*******| 0 |23456| 3| 11111 | +|4 | 0|1110000111010000| 0 |*******| 0 |23456| 4| 11111 | +|4+ | 0|0000001111101000| 0 |*******| 0 |23456| 4| 11111 | +|5 | 0|0000001111101000| 0 |*******| 0 | 1000| 5| 11111 | +|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5| 11111 | +|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6| 11111 | +|6+ | 0|0000001111101001| 0 |*******| 0 | 1000| 6| 11111 | +|7 | 0|0000001111101001| 0 |*******| 0 | 1001| 7| 11111 | +|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7| 11110 | +|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8| 11110 | +|8+ | 0|0000001111101000| 0 |*******| 0 | 1001| 8| 11110 | +|9 | 0|0000001111101000| 0 |*******| 0 | 1000| 9| 11110 | +|9+ | 11111|1111010011010000| 0 |*******| 0 | 1000| 9| -1 | +|10 | 11111|1111010011010000| 0 |*******| 0 | 1000| 10| -1 | +|10+ | 11111|0000000000001110| 0 |*******| 0 | 1000| 10| -1 | +|11 | 11111|0000000000001110| 0 |*******| 0 | 14| 11| -1 | +|11+ | 11111|1110001100000100| 0 |*******| 0 | 14| 11| -1 | +|12 | 11111|1110001100000100| 0 |*******| 0 | 14| 14| -1 | +|12+ | 11111|0000001111100111| 0 |*******| 0 | 14| 14| -1 | +|13 | 11111|0000001111100111| 0 |*******| 0 | 999| 15| -1 | +|13+ | 11111|1110110111100000| 0 |*******| 0 | 999| 15| -1 | +|14 | 11111|1110110111100000| 0 |*******| 0 | 1000| 16| -1 | +|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16| -1 | +|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17| -1 | +|15+ | 11111|0000000000010101| 0 |*******| 0 | 1000| 17| -1 | +|16 | 11111|0000000000010101| 0 |*******| 0 | 21| 18| -1 | +|16+ | 11111|1110011111000010| 0 |*******| 0 | 21| 18| -1 | +|17 | 11111|1110011111000010| 0 |*******| 0 | 21| 21| -1 | +|17+ | 11111|0000000000000010| 0 |*******| 0 | 21| 21| -1 | +|18 | 11111|0000000000000010| 0 |*******| 0 | 2| 22| -1 | +|18+ | 11111|1110000010010000| 0 |*******| 0 | 2| 22| 1 | +|19 | 11111|1110000010010000| 0 |*******| 0 | 2| 23| 1 | +|19+ | 11111|0000001111101000| 0 |*******| 0 | 2| 23| 1 | +|20 | 11111|0000001111101000| 0 |*******| 0 | 1000| 24| 1 | +|20+ | 11111|1110111010010000| 0 |*******| 0 | 1000| 24| -1 | +|21 | 11111|1110111010010000| 0 |*******| 0 | 1000| 25| -1 | +|21+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 25| -1 | +|22 | 11111|1110001100000001| 0 |*******| 0 | 1000| 26| -1 | +|22+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 26| -1 | +|23 | 11111|1110001100000010| 0 |*******| 0 | 1000| 27| -1 | +|23+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 27| -1 | +|24 | 11111|1110001100000011| 0 |*******| 0 | 1000| 28| -1 | +|24+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 28| -1 | +|25 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| -1 | +|25+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| -1 | +|26 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| -1 | +|26+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| -1 | +|27 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| -1 | +|27+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| -1 | +|28 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| -1 | +|28+ | 11111|1110101010010000| 0 |*******| 0 | 1000| 1000| 0 | +|29 | 11111|1110101010010000| 0 |*******| 0 | 1000| 1001| 0 | +|29+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 1001| 0 | +|30 | 11111|1110001100000001| 0 |*******| 0 | 1000| 1002| 0 | +|30+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 1002| 0 | +|31 | 11111|1110001100000010| 0 |*******| 0 | 1000| 1000| 0 | +|31+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| 0 | +|32 | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| 0 | +|32+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| 0 | +|33 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1001| 0 | +|33+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1001| 0 | +|34 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1002| 0 | +|34+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1002| 0 | +|35 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| 0 | +|35+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| 0 | +|36 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| 0 | +|36+ | 11111|1110111111010000| 0 |*******| 0 | 1000| 1000| 1 | +|37 | 11111|1110111111010000| 0 |*******| 0 | 1000| 1001| 1 | +|37+ | 11111|1110001100000001| 0 |*******| 0 | 1000| 1001| 1 | +|38 | 11111|1110001100000001| 0 |*******| 0 | 1000| 1000| 1 | +|38+ | 11111|1110001100000010| 0 |*******| 0 | 1000| 1000| 1 | +|39 | 11111|1110001100000010| 0 |*******| 0 | 1000| 1001| 1 | +|39+ | 11111|1110001100000011| 0 |*******| 0 | 1000| 1001| 1 | +|40 | 11111|1110001100000011| 0 |*******| 0 | 1000| 1000| 1 | +|40+ | 11111|1110001100000100| 0 |*******| 0 | 1000| 1000| 1 | +|41 | 11111|1110001100000100| 0 |*******| 0 | 1000| 1001| 1 | +|41+ | 11111|1110001100000101| 0 |*******| 0 | 1000| 1001| 1 | +|42 | 11111|1110001100000101| 0 |*******| 0 | 1000| 1000| 1 | +|42+ | 11111|1110001100000110| 0 |*******| 0 | 1000| 1000| 1 | +|43 | 11111|1110001100000110| 0 |*******| 0 | 1000| 1001| 1 | +|43+ | 11111|1110001100000111| 0 |*******| 0 | 1000| 1001| 1 | +|44 | 11111|1110001100000111| 0 |*******| 0 | 1000| 1000| 1 | +|44+ | 11111|1110001100000111| 1 |*******| 0 | 1000| 1000| 1 | +|45 | 11111|1110001100000111| 1 |*******| 0 | 1000| 0| 1 | +|45+ | 11111|0111111111111111| 0 |*******| 0 | 1000| 0| 1 | +|46 | 11111|0111111111111111| 0 |*******| 0 |32767| 1| 1 | diff --git a/projects/05/CPU.hdl b/projects/05/CPU.hdl new file mode 100755 index 0000000..1b03712 --- /dev/null +++ b/projects/05/CPU.hdl @@ -0,0 +1,115 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/CPU.hdl + +/** + * The Hack CPU (Central Processing unit), consisting of an ALU, + * two registers named A and D, and a program counter named PC. + * The CPU is designed to fetch and execute instructions written in + * the Hack machine language. In particular, functions as follows: + * Executes the inputted instruction according to the Hack machine + * language specification. The D and A in the language specification + * refer to CPU-resident registers, while M refers to the external + * memory location addressed by A, i.e. to Memory[A]. The inM input + * holds the value of this location. If the current instruction needs + * to write a value to M, the value is placed in outM, the address + * of the target location is placed in the addressM output, and the + * writeM control bit is asserted. (When writeM==0, any value may + * appear in outM). The outM and writeM outputs are combinational: + * they are affected instantaneously by the execution of the current + * instruction. The addressM and pc outputs are clocked: although they + * are affected by the execution of the current instruction, they commit + * to their new values only in the next time step. If reset==1 then the + * CPU jumps to address 0 (i.e. pc is set to 0 in next time step) rather + * than to the address resulting from executing the current instruction. + */ + +CHIP CPU { + + IN inM[16], // M value input (M = contents of RAM[A]) + instruction[16], // Instruction for execution + reset; // Signals whether to re-start the current + // program (reset==1) or continue executing + // the current program (reset==0). + + OUT outM[16], // M value output + writeM, // Write to M? + addressM[15], // Address in data memory (of M) + pc[15]; // address of next instruction + + PARTS: + Mux16(a=instruction ,b=ALUout ,sel=instruction[15] ,out=outToAreg ); + ARegister(in=outToAreg ,load=loadAreg ,out=outAreg,out[0..14]=addressM ); + DRegister(in=ALUout ,load=loadDreg ,out=outDreg ); + Mux16(a=outAreg ,b=inM ,sel=instruction[12] ,out=outToALU ); + ALU(x=outDreg ,y=outToALU ,zx=instruction[11] ,nx=instruction[10] ,zy=instruction[9] ,ny=instruction[8] ,f=instruction[7] ,no=instruction[6] ,out=ALUout,out=outM ,zr=zr ,ng=ng ); + And(a=instruction[3],b=instruction[15],out=writeM); + + //when to load A reg + Not(in=instruction[5],out=notd5); + Nand(a=instruction[15],b=notd5,out=loadAreg); + Not(in=ng,out=notNg); + Not(in=zr,out=notZr); + + //when to load D reg + And(a=instruction[4],b=instruction[15],out=loadDreg); + + //checking if instruction is a or c before jump decision is made + And(a=instruction[2],b=instruction[15],out=J1); + And(a=instruction[1],b=instruction[15],out=J2); + And(a=instruction[0],b=instruction[15],out=J3); + + //NULL + Nand(a=J1,b=J2,out=NandJ1J2); + Nand(a=NandJ1J2,b=J3,out=NoJump); + //JGT + And(a=J3,b=J3,out=AndJ3J3); + Or(a=zr,b=ng,out=orZrNg); + Not(in=orZrNg,out=NorZrNg); + And(a=AndJ3J3,b=NorZrNg,out=JGT); + + //JEQ + And(a=J2,b=J2,out=AndJ2J2); + And(a=zr,b=zr,out=AndZrZr); + And(a=AndZrZr,b=AndJ2J2,out=JEQ); + + //JGE + And(a=J3,b=J2,out=AndJ3J2); + Or(a=zr,b=notNg,out=AndZrNotNg); + And(a=AndZrNotNg,b=AndJ3J2,out=JGE); + + //JLT + And(a=J1,b=J1,out=AndJ1J1); + And(a=ng,b=ng,out=AndNgNg); + And(a=AndJ1J1,b=AndNgNg,out=JLT); + + //JNE + And(a=J3,b=J1,out=AndJ3J1); + And(a=notZr,b=notZr,out=AndNotZrNotZr); + And(a=AndNotZrNotZr,b=AndJ3J1,out=JNE); + + //JLE + And(a=J2,b=J1,out=AndJ2J1); + And(a=AndJ2J1,b=orZrNg,out=JLE); + + //JMP + And(a=AndJ3J1,b=J2,out=JMP); + + Not(in=outToLoad,out=outToLoad1); // once needted to know when to increes but also needed to not it so it dosent load the reg when J1J2J3=000 + + //4wayMux one + Mux(a=JMP,b=JGT,sel=instruction[0] ,out=out1); + Mux(a=JEQ,b=JGE,sel=instruction[0] ,out=out2); + Mux(a=out1,b=out2, sel=instruction[1] ,out=out5); + + //4wayMux two + Mux(a=JLT,b=JNE,sel=instruction[0] ,out=out3); + Mux(a=JLE,b=JMP,sel=instruction[0] ,out=out4); + Mux(a=out3,b=out4,sel=instruction[1] ,out=out6); + + //2wayMux + Mux(a=out5,b=out6,sel= instruction[2],out=outToLoad); + + PC(in=outAreg ,load=outToLoad ,inc=outToLoad1 ,reset=reset ,out[0..14]=pc); +} \ No newline at end of file diff --git a/projects/05/CPU.out b/projects/05/CPU.out new file mode 100755 index 0000000..2d5391a --- /dev/null +++ b/projects/05/CPU.out @@ -0,0 +1,93 @@ +|time| inM | instruction |reset| outM |writeM |addre| pc |DRegiste| +|0+ | 0|0011000000111001| 0 | 0| 0 | 0| 0| 0 | +|1 | 0|0011000000111001| 0 | 0| 0 |12345| 1| 0 | +|1+ | 0|1110110000010000| 0 | 12345| 0 |12345| 1| 12345 | +|2 | 0|1110110000010000| 0 | 12345| 0 |12345| 2| 12345 | +|2+ | 0|0101101110100000| 0 | -1| 0 |12345| 2| 12345 | +|3 | 0|0101101110100000| 0 | -1| 0 |23456| 3| 12345 | +|3+ | 0|1110000111010000| 0 | 11111| 0 |23456| 3| 11111 | +|4 | 0|1110000111010000| 0 | 12345| 0 |23456| 4| 11111 | +|4+ | 0|0000001111101000| 0 | -11111| 0 |23456| 4| 11111 | +|5 | 0|0000001111101000| 0 | -11111| 0 | 1000| 5| 11111 | +|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5| 11111 | +|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6| 11111 | +|6+ | 0|0000001111101001| 0 | -11111| 0 | 1000| 6| 11111 | +|7 | 0|0000001111101001| 0 | -11111| 0 | 1001| 7| 11111 | +|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7| 11110 | +|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8| 11110 | +|8+ | 0|0000001111101000| 0 | -11110| 0 | 1001| 8| 11110 | +|9 | 0|0000001111101000| 0 | -11110| 0 | 1000| 9| 11110 | +|9+ | 11111|1111010011010000| 0 | -1| 0 | 1000| 9| -1 | +|10 | 11111|1111010011010000| 0 | -11112| 0 | 1000| 10| -1 | +|10+ | 11111|0000000000001110| 0 | 1000| 0 | 1000| 10| -1 | +|11 | 11111|0000000000001110| 0 | 14| 0 | 14| 11| -1 | +|11+ | 11111|1110001100000100| 0 | -1| 0 | 14| 11| -1 | +|12 | 11111|1110001100000100| 0 | -1| 0 | 14| 14| -1 | +|12+ | 11111|0000001111100111| 0 | 1| 0 | 14| 14| -1 | +|13 | 11111|0000001111100111| 0 | 1| 0 | 999| 15| -1 | +|13+ | 11111|1110110111100000| 0 | 1000| 0 | 999| 15| -1 | +|14 | 11111|1110110111100000| 0 | 1001| 0 | 1000| 16| -1 | +|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16| -1 | +|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17| -1 | +|15+ | 11111|0000000000010101| 0 | 1000| 0 | 1000| 17| -1 | +|16 | 11111|0000000000010101| 0 | 21| 0 | 21| 18| -1 | +|16+ | 11111|1110011111000010| 0 | 0| 0 | 21| 18| -1 | +|17 | 11111|1110011111000010| 0 | 0| 0 | 21| 21| -1 | +|17+ | 11111|0000000000000010| 0 | 21| 0 | 21| 21| -1 | +|18 | 11111|0000000000000010| 0 | 2| 0 | 2| 22| -1 | +|18+ | 11111|1110000010010000| 0 | 1| 0 | 2| 22| 1 | +|19 | 11111|1110000010010000| 0 | 3| 0 | 2| 23| 1 | +|19+ | 11111|0000001111101000| 0 | -1| 0 | 2| 23| 1 | +|20 | 11111|0000001111101000| 0 | -1| 0 | 1000| 24| 1 | +|20+ | 11111|1110111010010000| 0 | -1| 0 | 1000| 24| -1 | +|21 | 11111|1110111010010000| 0 | -1| 0 | 1000| 25| -1 | +|21+ | 11111|1110001100000001| 0 | -1| 0 | 1000| 25| -1 | +|22 | 11111|1110001100000001| 0 | -1| 0 | 1000| 26| -1 | +|22+ | 11111|1110001100000010| 0 | -1| 0 | 1000| 26| -1 | +|23 | 11111|1110001100000010| 0 | -1| 0 | 1000| 27| -1 | +|23+ | 11111|1110001100000011| 0 | -1| 0 | 1000| 27| -1 | +|24 | 11111|1110001100000011| 0 | -1| 0 | 1000| 28| -1 | +|24+ | 11111|1110001100000100| 0 | -1| 0 | 1000| 28| -1 | +|25 | 11111|1110001100000100| 0 | -1| 0 | 1000| 1000| -1 | +|25+ | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| -1 | +|26 | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| -1 | +|26+ | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| -1 | +|27 | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| -1 | +|27+ | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| -1 | +|28 | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| -1 | +|28+ | 11111|1110101010010000| 0 | 0| 0 | 1000| 1000| 0 | +|29 | 11111|1110101010010000| 0 | 0| 0 | 1000| 1001| 0 | +|29+ | 11111|1110001100000001| 0 | 0| 0 | 1000| 1001| 0 | +|30 | 11111|1110001100000001| 0 | 0| 0 | 1000| 1002| 0 | +|30+ | 11111|1110001100000010| 0 | 0| 0 | 1000| 1002| 0 | +|31 | 11111|1110001100000010| 0 | 0| 0 | 1000| 1000| 0 | +|31+ | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| 0 | +|32 | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| 0 | +|32+ | 11111|1110001100000100| 0 | 0| 0 | 1000| 1000| 0 | +|33 | 11111|1110001100000100| 0 | 0| 0 | 1000| 1001| 0 | +|33+ | 11111|1110001100000101| 0 | 0| 0 | 1000| 1001| 0 | +|34 | 11111|1110001100000101| 0 | 0| 0 | 1000| 1002| 0 | +|34+ | 11111|1110001100000110| 0 | 0| 0 | 1000| 1002| 0 | +|35 | 11111|1110001100000110| 0 | 0| 0 | 1000| 1000| 0 | +|35+ | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| 0 | +|36 | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| 0 | +|36+ | 11111|1110111111010000| 0 | 1| 0 | 1000| 1000| 1 | +|37 | 11111|1110111111010000| 0 | 1| 0 | 1000| 1001| 1 | +|37+ | 11111|1110001100000001| 0 | 1| 0 | 1000| 1001| 1 | +|38 | 11111|1110001100000001| 0 | 1| 0 | 1000| 1000| 1 | +|38+ | 11111|1110001100000010| 0 | 1| 0 | 1000| 1000| 1 | +|39 | 11111|1110001100000010| 0 | 1| 0 | 1000| 1001| 1 | +|39+ | 11111|1110001100000011| 0 | 1| 0 | 1000| 1001| 1 | +|40 | 11111|1110001100000011| 0 | 1| 0 | 1000| 1000| 1 | +|40+ | 11111|1110001100000100| 0 | 1| 0 | 1000| 1000| 1 | +|41 | 11111|1110001100000100| 0 | 1| 0 | 1000| 1001| 1 | +|41+ | 11111|1110001100000101| 0 | 1| 0 | 1000| 1001| 1 | +|42 | 11111|1110001100000101| 0 | 1| 0 | 1000| 1000| 1 | +|42+ | 11111|1110001100000110| 0 | 1| 0 | 1000| 1000| 1 | +|43 | 11111|1110001100000110| 0 | 1| 0 | 1000| 1001| 1 | +|43+ | 11111|1110001100000111| 0 | 1| 0 | 1000| 1001| 1 | +|44 | 11111|1110001100000111| 0 | 1| 0 | 1000| 1000| 1 | +|44+ | 11111|1110001100000111| 1 | 1| 0 | 1000| 1000| 1 | +|45 | 11111|1110001100000111| 1 | 1| 0 | 1000| 0| 1 | +|45+ | 11111|0111111111111111| 0 | 1| 0 | 1000| 0| 1 | +|46 | 11111|0111111111111111| 0 | 1| 0 |32767| 1| 1 | diff --git a/projects/05/CPU.tst b/projects/05/CPU.tst new file mode 100755 index 0000000..98eee1c --- /dev/null +++ b/projects/05/CPU.tst @@ -0,0 +1,150 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/CPU.tst + +load CPU.hdl, +output-file CPU.out, +compare-to CPU.cmp, +output-list time%S0.4.0 inM%D0.6.0 instruction%B0.16.0 reset%B2.1.2 outM%D1.6.0 writeM%B3.1.3 addressM%D0.5.0 pc%D0.5.0 DRegister[]%D1.6.1; + + +set instruction %B0011000000111001, // @12345 +tick, output, tock, output; + +set instruction %B1110110000010000, // D=A +tick, output, tock, output; + +set instruction %B0101101110100000, // @23456 +tick, output, tock, output; + +set instruction %B1110000111010000, // D=A-D +tick, output, tock, output; + +set instruction %B0000001111101000, // @1000 +tick, output, tock, output; + +set instruction %B1110001100001000, // M=D +tick, output, tock, output; + +set instruction %B0000001111101001, // @1001 +tick, output, tock, output; + +set instruction %B1110001110011000, // MD=D-1 +tick, output, tock, output; + +set instruction %B0000001111101000, // @1000 +tick, output, tock, output; + +set instruction %B1111010011010000, // D=D-M +set inM 11111, +tick, output, tock, output; + +set instruction %B0000000000001110, // @14 +tick, output, tock, output; + +set instruction %B1110001100000100, // D;jlt +tick, output, tock, output; + +set instruction %B0000001111100111, // @999 +tick, output, tock, output; + +set instruction %B1110110111100000, // A=A+1 +tick, output, tock, output; + +set instruction %B1110001100001000, // M=D +tick, output, tock, output; + +set instruction %B0000000000010101, // @21 +tick, output, tock, output; + +set instruction %B1110011111000010, // D+1;jeq +tick, output, tock, output; + +set instruction %B0000000000000010, // @2 +tick, output, tock, output; + +set instruction %B1110000010010000, // D=D+A +tick, output, tock, output; + +set instruction %B0000001111101000, // @1000 +tick, output, tock, output; + +set instruction %B1110111010010000, // D=-1 +tick, output, tock, output; + +set instruction %B1110001100000001, // D;JGT +tick, output, tock, output; + +set instruction %B1110001100000010, // D;JEQ +tick, output, tock, output; + +set instruction %B1110001100000011, // D;JGE +tick, output, tock, output; + +set instruction %B1110001100000100, // D;JLT +tick, output, tock, output; + +set instruction %B1110001100000101, // D;JNE +tick, output, tock, output; + +set instruction %B1110001100000110, // D;JLE +tick, output, tock, output; + +set instruction %B1110001100000111, // D;JMP +tick, output, tock, output; + +set instruction %B1110101010010000, // D=0 +tick, output, tock, output; + +set instruction %B1110001100000001, // D;JGT +tick, output, tock, output; + +set instruction %B1110001100000010, // D;JEQ +tick, output, tock, output; + +set instruction %B1110001100000011, // D;JGE +tick, output, tock, output; + +set instruction %B1110001100000100, // D;JLT +tick, output, tock, output; + +set instruction %B1110001100000101, // D;JNE +tick, output, tock, output; + +set instruction %B1110001100000110, // D;JLE +tick, output, tock, output; + +set instruction %B1110001100000111, // D;JMP +tick, output, tock, output; + +set instruction %B1110111111010000, // D=1 +tick, output, tock, output; + +set instruction %B1110001100000001, // D;JGT +tick, output, tock, output; + +set instruction %B1110001100000010, // D;JEQ +tick, output, tock, output; + +set instruction %B1110001100000011, // D;JGE +tick, output, tock, output; + +set instruction %B1110001100000100, // D;JLT +tick, output, tock, output; + +set instruction %B1110001100000101, // D;JNE +tick, output, tock, output; + +set instruction %B1110001100000110, // D;JLE +tick, output, tock, output; + +set instruction %B1110001100000111, // D;JMP +tick, output, tock, output; + +set reset 1; +tick, output, tock, output; + +set instruction %B0111111111111111, // @32767 +set reset 0; +tick, output, tock, output; diff --git a/projects/05/Computer.hdl b/projects/05/Computer.hdl new file mode 100755 index 0000000..ea198e4 --- /dev/null +++ b/projects/05/Computer.hdl @@ -0,0 +1,25 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/Computer.hdl + +/** + * The HACK computer, including CPU, ROM and RAM. + * When reset is 0, the program stored in the computer's ROM executes. + * When reset is 1, the execution of the program restarts. + * Thus, to start a program's execution, reset must be pushed "up" (1) + * and "down" (0). From this point onward the user is at the mercy of + * the software. In particular, depending on the program's code, the + * screen may show some output and the user may be able to interact + * with the computer via the keyboard. + */ + +CHIP Computer { + + IN reset; + + PARTS: + CPU(inM=inM ,instruction=inst ,reset=reset ,outM=outM ,writeM=writeM ,addressM=addressM ,pc=pc ); + Memory(in=outM ,load=writeM ,address= addressM,out=inM ); + ROM32K(address=pc ,out=inst ); +} diff --git a/projects/05/ComputerAdd-external.cmp b/projects/05/ComputerAdd-external.cmp new file mode 100755 index 0000000..a3a8eaf --- /dev/null +++ b/projects/05/ComputerAdd-external.cmp @@ -0,0 +1,15 @@ +| time |reset|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 2 | 0 | 0 | 0 | 0 | +| 3 | 0 | 0 | 0 | 0 | +| 4 | 0 | 0 | 0 | 0 | +| 5 | 0 | 0 | 0 | 0 | +| 6 | 0 | 5 | 0 | 0 | +| 7 | 1 | 0 | 0 | 0 | +| 8 | 0 | 0 | 0 | 0 | +| 9 | 0 | 0 | 0 | 0 | +| 10 | 0 | 0 | 0 | 0 | +| 11 | 0 | 0 | 0 | 0 | +| 12 | 0 | 0 | 0 | 0 | +| 13 | 0 | 5 | 0 | 0 | diff --git a/projects/05/ComputerAdd-external.out b/projects/05/ComputerAdd-external.out new file mode 100755 index 0000000..a3a8eaf --- /dev/null +++ b/projects/05/ComputerAdd-external.out @@ -0,0 +1,15 @@ +| time |reset|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 2 | 0 | 0 | 0 | 0 | +| 3 | 0 | 0 | 0 | 0 | +| 4 | 0 | 0 | 0 | 0 | +| 5 | 0 | 0 | 0 | 0 | +| 6 | 0 | 5 | 0 | 0 | +| 7 | 1 | 0 | 0 | 0 | +| 8 | 0 | 0 | 0 | 0 | +| 9 | 0 | 0 | 0 | 0 | +| 10 | 0 | 0 | 0 | 0 | +| 11 | 0 | 0 | 0 | 0 | +| 12 | 0 | 0 | 0 | 0 | +| 13 | 0 | 5 | 0 | 0 | diff --git a/projects/05/ComputerAdd-external.tst b/projects/05/ComputerAdd-external.tst new file mode 100755 index 0000000..09cc1a7 --- /dev/null +++ b/projects/05/ComputerAdd-external.tst @@ -0,0 +1,32 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/ComputerAdd-external.tst + +load Computer.hdl, +output-file ComputerAdd-external.out, +compare-to ComputerAdd-external.cmp, +output-list time%S1.4.1 reset%B2.1.2 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1; + +// Load a program written in the Hack machine language. +// The program adds the two constants 2 and 3 and writes the result in RAM[0]. +ROM32K load Add.hack, +output; + +// First run (at the beginning PC=0) +repeat 6 { + tick, tock, output; +} + +// Reset the PC +set reset 1, +set RAM16K[0] 0, +tick, tock, output; + + +// Second run, to check that the PC was reset correctly. +set reset 0, + +repeat 6 { + tick, tock, output; +} diff --git a/projects/05/ComputerAdd.cmp b/projects/05/ComputerAdd.cmp new file mode 100755 index 0000000..f295464 --- /dev/null +++ b/projects/05/ComputerAdd.cmp @@ -0,0 +1,15 @@ +| time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0| 0 | 0 | 0 | +| 1 | 0 | 2 | 0 | 1| 0 | 0 | 0 | +| 2 | 0 | 2 | 2 | 2| 0 | 0 | 0 | +| 3 | 0 | 3 | 2 | 3| 0 | 0 | 0 | +| 4 | 0 | 3 | 5 | 4| 0 | 0 | 0 | +| 5 | 0 | 0 | 5 | 5| 0 | 0 | 0 | +| 6 | 0 | 0 | 5 | 6| 5 | 0 | 0 | +| 7 | 1 | 0 | 5 | 0| 0 | 0 | 0 | +| 8 | 0 | 2 | 5 | 1| 0 | 0 | 0 | +| 9 | 0 | 2 | 2 | 2| 0 | 0 | 0 | +| 10 | 0 | 3 | 2 | 3| 0 | 0 | 0 | +| 11 | 0 | 3 | 5 | 4| 0 | 0 | 0 | +| 12 | 0 | 0 | 5 | 5| 0 | 0 | 0 | +| 13 | 0 | 0 | 5 | 6| 5 | 0 | 0 | diff --git a/projects/05/ComputerAdd.out b/projects/05/ComputerAdd.out new file mode 100755 index 0000000..f295464 --- /dev/null +++ b/projects/05/ComputerAdd.out @@ -0,0 +1,15 @@ +| time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0| 0 | 0 | 0 | +| 1 | 0 | 2 | 0 | 1| 0 | 0 | 0 | +| 2 | 0 | 2 | 2 | 2| 0 | 0 | 0 | +| 3 | 0 | 3 | 2 | 3| 0 | 0 | 0 | +| 4 | 0 | 3 | 5 | 4| 0 | 0 | 0 | +| 5 | 0 | 0 | 5 | 5| 0 | 0 | 0 | +| 6 | 0 | 0 | 5 | 6| 5 | 0 | 0 | +| 7 | 1 | 0 | 5 | 0| 0 | 0 | 0 | +| 8 | 0 | 2 | 5 | 1| 0 | 0 | 0 | +| 9 | 0 | 2 | 2 | 2| 0 | 0 | 0 | +| 10 | 0 | 3 | 2 | 3| 0 | 0 | 0 | +| 11 | 0 | 3 | 5 | 4| 0 | 0 | 0 | +| 12 | 0 | 0 | 5 | 5| 0 | 0 | 0 | +| 13 | 0 | 0 | 5 | 6| 5 | 0 | 0 | diff --git a/projects/05/ComputerAdd.tst b/projects/05/ComputerAdd.tst new file mode 100755 index 0000000..27f4411 --- /dev/null +++ b/projects/05/ComputerAdd.tst @@ -0,0 +1,32 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/ComputerAdd.tst + +load Computer.hdl, +output-file ComputerAdd.out, +compare-to ComputerAdd.cmp, +output-list time%S1.4.1 reset%B2.1.2 ARegister[0]%D1.7.1 DRegister[0]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1; + +// Load a program written in the Hack machine language. +// The program adds the two constants 2 and 3 and writes the result in RAM[0]. +ROM32K load Add.hack, +output; + +// First run (at the beginning PC=0) +repeat 6 { + tick, tock, output; +} + +// Reset the PC +set reset 1, +set RAM16K[0] 0, +tick, tock, output; + + +// Second run, to check that the PC was reset correctly. +set reset 0, + +repeat 6 { + tick, tock, output; +} diff --git a/projects/05/ComputerMax-external.cmp b/projects/05/ComputerMax-external.cmp new file mode 100755 index 0000000..f864733 --- /dev/null +++ b/projects/05/ComputerMax-external.cmp @@ -0,0 +1,28 @@ +| time |reset|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 3 | 5 | 0 | +| 1 | 0 | 3 | 5 | 0 | +| 2 | 0 | 3 | 5 | 0 | +| 3 | 0 | 3 | 5 | 0 | +| 4 | 0 | 3 | 5 | 0 | +| 5 | 0 | 3 | 5 | 0 | +| 6 | 0 | 3 | 5 | 0 | +| 7 | 0 | 3 | 5 | 0 | +| 8 | 0 | 3 | 5 | 0 | +| 9 | 0 | 3 | 5 | 0 | +| 10 | 0 | 3 | 5 | 0 | +| 11 | 0 | 3 | 5 | 0 | +| 12 | 0 | 3 | 5 | 5 | +| 13 | 0 | 3 | 5 | 5 | +| 14 | 0 | 3 | 5 | 5 | +| 15 | 1 | 3 | 5 | 5 | +| 15 | 0 | 23456 | 12345 | 5 | +| 16 | 0 | 23456 | 12345 | 5 | +| 17 | 0 | 23456 | 12345 | 5 | +| 18 | 0 | 23456 | 12345 | 5 | +| 19 | 0 | 23456 | 12345 | 5 | +| 20 | 0 | 23456 | 12345 | 5 | +| 21 | 0 | 23456 | 12345 | 5 | +| 22 | 0 | 23456 | 12345 | 5 | +| 23 | 0 | 23456 | 12345 | 5 | +| 24 | 0 | 23456 | 12345 | 5 | +| 25 | 0 | 23456 | 12345 | 23456 | diff --git a/projects/05/ComputerMax-external.out b/projects/05/ComputerMax-external.out new file mode 100755 index 0000000..f864733 --- /dev/null +++ b/projects/05/ComputerMax-external.out @@ -0,0 +1,28 @@ +| time |reset|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 3 | 5 | 0 | +| 1 | 0 | 3 | 5 | 0 | +| 2 | 0 | 3 | 5 | 0 | +| 3 | 0 | 3 | 5 | 0 | +| 4 | 0 | 3 | 5 | 0 | +| 5 | 0 | 3 | 5 | 0 | +| 6 | 0 | 3 | 5 | 0 | +| 7 | 0 | 3 | 5 | 0 | +| 8 | 0 | 3 | 5 | 0 | +| 9 | 0 | 3 | 5 | 0 | +| 10 | 0 | 3 | 5 | 0 | +| 11 | 0 | 3 | 5 | 0 | +| 12 | 0 | 3 | 5 | 5 | +| 13 | 0 | 3 | 5 | 5 | +| 14 | 0 | 3 | 5 | 5 | +| 15 | 1 | 3 | 5 | 5 | +| 15 | 0 | 23456 | 12345 | 5 | +| 16 | 0 | 23456 | 12345 | 5 | +| 17 | 0 | 23456 | 12345 | 5 | +| 18 | 0 | 23456 | 12345 | 5 | +| 19 | 0 | 23456 | 12345 | 5 | +| 20 | 0 | 23456 | 12345 | 5 | +| 21 | 0 | 23456 | 12345 | 5 | +| 22 | 0 | 23456 | 12345 | 5 | +| 23 | 0 | 23456 | 12345 | 5 | +| 24 | 0 | 23456 | 12345 | 5 | +| 25 | 0 | 23456 | 12345 | 23456 | diff --git a/projects/05/ComputerMax-external.tst b/projects/05/ComputerMax-external.tst new file mode 100755 index 0000000..52b6bef --- /dev/null +++ b/projects/05/ComputerMax-external.tst @@ -0,0 +1,38 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/ComputerMax-external.tst + +load Computer.hdl, +output-file ComputerMax-external.out, +compare-to ComputerMax-external.cmp, +output-list time%S1.4.1 reset%B2.1.2 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1; + +// Load a program written in the Hack machine language. +// The program computes the maximum of RAM[0] and RAM[1] +// and writes the result in RAM[2]. +ROM32K load Max.hack, + +// first run: compute max(3,5) +set RAM16K[0] 3, +set RAM16K[1] 5, +output; + +repeat 14 { + tick, tock, output; +} + +// reset the PC +set reset 1, +tick, tock, output; + +// second run: compute max(23456,12345) +set reset 0, +set RAM16K[0] 23456, +set RAM16K[1] 12345, +output; + +// The run on these inputs needs less cycles (different branching) +repeat 10 { + tick, tock, output; +} diff --git a/projects/05/ComputerMax.cmp b/projects/05/ComputerMax.cmp new file mode 100755 index 0000000..42276cd --- /dev/null +++ b/projects/05/ComputerMax.cmp @@ -0,0 +1,28 @@ +| time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0| 3 | 5 | 0 | +| 1 | 0 | 0 | 0 | 1| 3 | 5 | 0 | +| 2 | 0 | 0 | 3 | 2| 3 | 5 | 0 | +| 3 | 0 | 1 | 3 | 3| 3 | 5 | 0 | +| 4 | 0 | 1 | -2 | 4| 3 | 5 | 0 | +| 5 | 0 | 10 | -2 | 5| 3 | 5 | 0 | +| 6 | 0 | 10 | -2 | 6| 3 | 5 | 0 | +| 7 | 0 | 1 | -2 | 7| 3 | 5 | 0 | +| 8 | 0 | 1 | 5 | 8| 3 | 5 | 0 | +| 9 | 0 | 12 | 5 | 9| 3 | 5 | 0 | +| 10 | 0 | 12 | 5 | 12| 3 | 5 | 0 | +| 11 | 0 | 2 | 5 | 13| 3 | 5 | 0 | +| 12 | 0 | 2 | 5 | 14| 3 | 5 | 5 | +| 13 | 0 | 14 | 5 | 15| 3 | 5 | 5 | +| 14 | 0 | 14 | 5 | 14| 3 | 5 | 5 | +| 15 | 1 | 14 | 5 | 0| 3 | 5 | 5 | +| 15 | 0 | 14 | 5 | 0| 23456 | 12345 | 5 | +| 16 | 0 | 0 | 5 | 1| 23456 | 12345 | 5 | +| 17 | 0 | 0 | 23456 | 2| 23456 | 12345 | 5 | +| 18 | 0 | 1 | 23456 | 3| 23456 | 12345 | 5 | +| 19 | 0 | 1 | 11111 | 4| 23456 | 12345 | 5 | +| 20 | 0 | 10 | 11111 | 5| 23456 | 12345 | 5 | +| 21 | 0 | 10 | 11111 | 10| 23456 | 12345 | 5 | +| 22 | 0 | 0 | 11111 | 11| 23456 | 12345 | 5 | +| 23 | 0 | 0 | 23456 | 12| 23456 | 12345 | 5 | +| 24 | 0 | 2 | 23456 | 13| 23456 | 12345 | 5 | +| 25 | 0 | 2 | 23456 | 14| 23456 | 12345 | 23456 | diff --git a/projects/05/ComputerMax.out b/projects/05/ComputerMax.out new file mode 100755 index 0000000..42276cd --- /dev/null +++ b/projects/05/ComputerMax.out @@ -0,0 +1,28 @@ +| time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0| 3 | 5 | 0 | +| 1 | 0 | 0 | 0 | 1| 3 | 5 | 0 | +| 2 | 0 | 0 | 3 | 2| 3 | 5 | 0 | +| 3 | 0 | 1 | 3 | 3| 3 | 5 | 0 | +| 4 | 0 | 1 | -2 | 4| 3 | 5 | 0 | +| 5 | 0 | 10 | -2 | 5| 3 | 5 | 0 | +| 6 | 0 | 10 | -2 | 6| 3 | 5 | 0 | +| 7 | 0 | 1 | -2 | 7| 3 | 5 | 0 | +| 8 | 0 | 1 | 5 | 8| 3 | 5 | 0 | +| 9 | 0 | 12 | 5 | 9| 3 | 5 | 0 | +| 10 | 0 | 12 | 5 | 12| 3 | 5 | 0 | +| 11 | 0 | 2 | 5 | 13| 3 | 5 | 0 | +| 12 | 0 | 2 | 5 | 14| 3 | 5 | 5 | +| 13 | 0 | 14 | 5 | 15| 3 | 5 | 5 | +| 14 | 0 | 14 | 5 | 14| 3 | 5 | 5 | +| 15 | 1 | 14 | 5 | 0| 3 | 5 | 5 | +| 15 | 0 | 14 | 5 | 0| 23456 | 12345 | 5 | +| 16 | 0 | 0 | 5 | 1| 23456 | 12345 | 5 | +| 17 | 0 | 0 | 23456 | 2| 23456 | 12345 | 5 | +| 18 | 0 | 1 | 23456 | 3| 23456 | 12345 | 5 | +| 19 | 0 | 1 | 11111 | 4| 23456 | 12345 | 5 | +| 20 | 0 | 10 | 11111 | 5| 23456 | 12345 | 5 | +| 21 | 0 | 10 | 11111 | 10| 23456 | 12345 | 5 | +| 22 | 0 | 0 | 11111 | 11| 23456 | 12345 | 5 | +| 23 | 0 | 0 | 23456 | 12| 23456 | 12345 | 5 | +| 24 | 0 | 2 | 23456 | 13| 23456 | 12345 | 5 | +| 25 | 0 | 2 | 23456 | 14| 23456 | 12345 | 23456 | diff --git a/projects/05/ComputerMax.tst b/projects/05/ComputerMax.tst new file mode 100755 index 0000000..e090754 --- /dev/null +++ b/projects/05/ComputerMax.tst @@ -0,0 +1,39 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/ComputerMax.tst + +load Computer.hdl, +output-file ComputerMax.out, +compare-to ComputerMax.cmp, +output-list time%S1.4.1 reset%B2.1.2 ARegister[]%D1.7.1 DRegister[]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1; + +// Load a program written in the Hack machine language. +// The program computes the maximum of RAM[0] and RAM[1] +// and writes the result in RAM[2]. + +ROM32K load Max.hack, + +// first run: compute max(3,5) +set RAM16K[0] 3, +set RAM16K[1] 5, +output; + +repeat 14 { + tick, tock, output; +} + +// reset the PC +set reset 1, +tick, tock, output; + +// second run: compute max(23456,12345) +set reset 0, +set RAM16K[0] 23456, +set RAM16K[1] 12345, +output; + +// The run on these inputs needs less cycles (different branching) +repeat 10 { + tick, tock, output; +} diff --git a/projects/05/ComputerRect-external.cmp b/projects/05/ComputerRect-external.cmp new file mode 100755 index 0000000..f276922 --- /dev/null +++ b/projects/05/ComputerRect-external.cmp @@ -0,0 +1,65 @@ +| time | +| 0 | +| 1 | +| 2 | +| 3 | +| 4 | +| 5 | +| 6 | +| 7 | +| 8 | +| 9 | +| 10 | +| 11 | +| 12 | +| 13 | +| 14 | +| 15 | +| 16 | +| 17 | +| 18 | +| 19 | +| 20 | +| 21 | +| 22 | +| 23 | +| 24 | +| 25 | +| 26 | +| 27 | +| 28 | +| 29 | +| 30 | +| 31 | +| 32 | +| 33 | +| 34 | +| 35 | +| 36 | +| 37 | +| 38 | +| 39 | +| 40 | +| 41 | +| 42 | +| 43 | +| 44 | +| 45 | +| 46 | +| 47 | +| 48 | +| 49 | +| 50 | +| 51 | +| 52 | +| 53 | +| 54 | +| 55 | +| 56 | +| 57 | +| 58 | +| 59 | +| 60 | +| 61 | +| 62 | +| 63 | diff --git a/projects/05/ComputerRect-external.out b/projects/05/ComputerRect-external.out new file mode 100755 index 0000000..f276922 --- /dev/null +++ b/projects/05/ComputerRect-external.out @@ -0,0 +1,65 @@ +| time | +| 0 | +| 1 | +| 2 | +| 3 | +| 4 | +| 5 | +| 6 | +| 7 | +| 8 | +| 9 | +| 10 | +| 11 | +| 12 | +| 13 | +| 14 | +| 15 | +| 16 | +| 17 | +| 18 | +| 19 | +| 20 | +| 21 | +| 22 | +| 23 | +| 24 | +| 25 | +| 26 | +| 27 | +| 28 | +| 29 | +| 30 | +| 31 | +| 32 | +| 33 | +| 34 | +| 35 | +| 36 | +| 37 | +| 38 | +| 39 | +| 40 | +| 41 | +| 42 | +| 43 | +| 44 | +| 45 | +| 46 | +| 47 | +| 48 | +| 49 | +| 50 | +| 51 | +| 52 | +| 53 | +| 54 | +| 55 | +| 56 | +| 57 | +| 58 | +| 59 | +| 60 | +| 61 | +| 62 | +| 63 | diff --git a/projects/05/ComputerRect-external.tst b/projects/05/ComputerRect-external.tst new file mode 100755 index 0000000..f9102f7 --- /dev/null +++ b/projects/05/ComputerRect-external.tst @@ -0,0 +1,26 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/ComputerRect-external.tst + +load Computer.hdl, +output-file ComputerRect-external.out, +compare-to ComputerRect-external.cmp, +output-list time%S1.4.1; + +// Load a program written in the Hack machine language. +// The program draws a rectangle of width 16 pixels and +// length RAM[0] at the top left of the screen. +ROM32K load Rect.hack, + +echo "Before you run this script, select the 'Screen' option from the 'View' menu"; + +echo "A small rectangle should be drawn at the top left of the screen (the 'Screen' option of the 'View' menu should be selected.)"; + +// draw a rectangle 16 pixels wide and 4 pixels long +set RAM16K[0] 4, +output; + +repeat 63 { + tick, tock, output; +} diff --git a/projects/05/ComputerRect.cmp b/projects/05/ComputerRect.cmp new file mode 100755 index 0000000..a6b5cc9 --- /dev/null +++ b/projects/05/ComputerRect.cmp @@ -0,0 +1,65 @@ +| time |ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0| 4 | 0 | 0 | +| 1 | 0 | 0 | 1| 4 | 0 | 0 | +| 2 | 0 | 4 | 2| 4 | 0 | 0 | +| 3 | 23 | 4 | 3| 4 | 0 | 0 | +| 4 | 23 | 4 | 4| 4 | 0 | 0 | +| 5 | 16 | 4 | 5| 4 | 0 | 0 | +| 6 | 16 | 4 | 6| 4 | 0 | 0 | +| 7 | 16384 | 4 | 7| 4 | 0 | 0 | +| 8 | 16384 | 16384 | 8| 4 | 0 | 0 | +| 9 | 17 | 16384 | 9| 4 | 0 | 0 | +| 10 | 17 | 16384 | 10| 4 | 0 | 0 | +| 11 | 17 | 16384 | 11| 4 | 0 | 0 | +| 12 | 16384 | 16384 | 12| 4 | 0 | 0 | +| 13 | 16384 | 16384 | 13| 4 | 0 | 0 | +| 14 | 17 | 16384 | 14| 4 | 0 | 0 | +| 15 | 17 | 16384 | 15| 4 | 0 | 0 | +| 16 | 32 | 16384 | 16| 4 | 0 | 0 | +| 17 | 32 | 16416 | 17| 4 | 0 | 0 | +| 18 | 17 | 16416 | 18| 4 | 0 | 0 | +| 19 | 17 | 16416 | 19| 4 | 0 | 0 | +| 20 | 16 | 16416 | 20| 4 | 0 | 0 | +| 21 | 16 | 3 | 21| 4 | 0 | 0 | +| 22 | 10 | 3 | 22| 4 | 0 | 0 | +| 23 | 10 | 3 | 10| 4 | 0 | 0 | +| 24 | 17 | 3 | 11| 4 | 0 | 0 | +| 25 | 16416 | 3 | 12| 4 | 0 | 0 | +| 26 | 16416 | 3 | 13| 4 | 0 | 0 | +| 27 | 17 | 3 | 14| 4 | 0 | 0 | +| 28 | 17 | 16416 | 15| 4 | 0 | 0 | +| 29 | 32 | 16416 | 16| 4 | 0 | 0 | +| 30 | 32 | 16448 | 17| 4 | 0 | 0 | +| 31 | 17 | 16448 | 18| 4 | 0 | 0 | +| 32 | 17 | 16448 | 19| 4 | 0 | 0 | +| 33 | 16 | 16448 | 20| 4 | 0 | 0 | +| 34 | 16 | 2 | 21| 4 | 0 | 0 | +| 35 | 10 | 2 | 22| 4 | 0 | 0 | +| 36 | 10 | 2 | 10| 4 | 0 | 0 | +| 37 | 17 | 2 | 11| 4 | 0 | 0 | +| 38 | 16448 | 2 | 12| 4 | 0 | 0 | +| 39 | 16448 | 2 | 13| 4 | 0 | 0 | +| 40 | 17 | 2 | 14| 4 | 0 | 0 | +| 41 | 17 | 16448 | 15| 4 | 0 | 0 | +| 42 | 32 | 16448 | 16| 4 | 0 | 0 | +| 43 | 32 | 16480 | 17| 4 | 0 | 0 | +| 44 | 17 | 16480 | 18| 4 | 0 | 0 | +| 45 | 17 | 16480 | 19| 4 | 0 | 0 | +| 46 | 16 | 16480 | 20| 4 | 0 | 0 | +| 47 | 16 | 1 | 21| 4 | 0 | 0 | +| 48 | 10 | 1 | 22| 4 | 0 | 0 | +| 49 | 10 | 1 | 10| 4 | 0 | 0 | +| 50 | 17 | 1 | 11| 4 | 0 | 0 | +| 51 | 16480 | 1 | 12| 4 | 0 | 0 | +| 52 | 16480 | 1 | 13| 4 | 0 | 0 | +| 53 | 17 | 1 | 14| 4 | 0 | 0 | +| 54 | 17 | 16480 | 15| 4 | 0 | 0 | +| 55 | 32 | 16480 | 16| 4 | 0 | 0 | +| 56 | 32 | 16512 | 17| 4 | 0 | 0 | +| 57 | 17 | 16512 | 18| 4 | 0 | 0 | +| 58 | 17 | 16512 | 19| 4 | 0 | 0 | +| 59 | 16 | 16512 | 20| 4 | 0 | 0 | +| 60 | 16 | 0 | 21| 4 | 0 | 0 | +| 61 | 10 | 0 | 22| 4 | 0 | 0 | +| 62 | 10 | 0 | 23| 4 | 0 | 0 | +| 63 | 23 | 0 | 24| 4 | 0 | 0 | diff --git a/projects/05/ComputerRect.out b/projects/05/ComputerRect.out new file mode 100755 index 0000000..a6b5cc9 --- /dev/null +++ b/projects/05/ComputerRect.out @@ -0,0 +1,65 @@ +| time |ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0| 4 | 0 | 0 | +| 1 | 0 | 0 | 1| 4 | 0 | 0 | +| 2 | 0 | 4 | 2| 4 | 0 | 0 | +| 3 | 23 | 4 | 3| 4 | 0 | 0 | +| 4 | 23 | 4 | 4| 4 | 0 | 0 | +| 5 | 16 | 4 | 5| 4 | 0 | 0 | +| 6 | 16 | 4 | 6| 4 | 0 | 0 | +| 7 | 16384 | 4 | 7| 4 | 0 | 0 | +| 8 | 16384 | 16384 | 8| 4 | 0 | 0 | +| 9 | 17 | 16384 | 9| 4 | 0 | 0 | +| 10 | 17 | 16384 | 10| 4 | 0 | 0 | +| 11 | 17 | 16384 | 11| 4 | 0 | 0 | +| 12 | 16384 | 16384 | 12| 4 | 0 | 0 | +| 13 | 16384 | 16384 | 13| 4 | 0 | 0 | +| 14 | 17 | 16384 | 14| 4 | 0 | 0 | +| 15 | 17 | 16384 | 15| 4 | 0 | 0 | +| 16 | 32 | 16384 | 16| 4 | 0 | 0 | +| 17 | 32 | 16416 | 17| 4 | 0 | 0 | +| 18 | 17 | 16416 | 18| 4 | 0 | 0 | +| 19 | 17 | 16416 | 19| 4 | 0 | 0 | +| 20 | 16 | 16416 | 20| 4 | 0 | 0 | +| 21 | 16 | 3 | 21| 4 | 0 | 0 | +| 22 | 10 | 3 | 22| 4 | 0 | 0 | +| 23 | 10 | 3 | 10| 4 | 0 | 0 | +| 24 | 17 | 3 | 11| 4 | 0 | 0 | +| 25 | 16416 | 3 | 12| 4 | 0 | 0 | +| 26 | 16416 | 3 | 13| 4 | 0 | 0 | +| 27 | 17 | 3 | 14| 4 | 0 | 0 | +| 28 | 17 | 16416 | 15| 4 | 0 | 0 | +| 29 | 32 | 16416 | 16| 4 | 0 | 0 | +| 30 | 32 | 16448 | 17| 4 | 0 | 0 | +| 31 | 17 | 16448 | 18| 4 | 0 | 0 | +| 32 | 17 | 16448 | 19| 4 | 0 | 0 | +| 33 | 16 | 16448 | 20| 4 | 0 | 0 | +| 34 | 16 | 2 | 21| 4 | 0 | 0 | +| 35 | 10 | 2 | 22| 4 | 0 | 0 | +| 36 | 10 | 2 | 10| 4 | 0 | 0 | +| 37 | 17 | 2 | 11| 4 | 0 | 0 | +| 38 | 16448 | 2 | 12| 4 | 0 | 0 | +| 39 | 16448 | 2 | 13| 4 | 0 | 0 | +| 40 | 17 | 2 | 14| 4 | 0 | 0 | +| 41 | 17 | 16448 | 15| 4 | 0 | 0 | +| 42 | 32 | 16448 | 16| 4 | 0 | 0 | +| 43 | 32 | 16480 | 17| 4 | 0 | 0 | +| 44 | 17 | 16480 | 18| 4 | 0 | 0 | +| 45 | 17 | 16480 | 19| 4 | 0 | 0 | +| 46 | 16 | 16480 | 20| 4 | 0 | 0 | +| 47 | 16 | 1 | 21| 4 | 0 | 0 | +| 48 | 10 | 1 | 22| 4 | 0 | 0 | +| 49 | 10 | 1 | 10| 4 | 0 | 0 | +| 50 | 17 | 1 | 11| 4 | 0 | 0 | +| 51 | 16480 | 1 | 12| 4 | 0 | 0 | +| 52 | 16480 | 1 | 13| 4 | 0 | 0 | +| 53 | 17 | 1 | 14| 4 | 0 | 0 | +| 54 | 17 | 16480 | 15| 4 | 0 | 0 | +| 55 | 32 | 16480 | 16| 4 | 0 | 0 | +| 56 | 32 | 16512 | 17| 4 | 0 | 0 | +| 57 | 17 | 16512 | 18| 4 | 0 | 0 | +| 58 | 17 | 16512 | 19| 4 | 0 | 0 | +| 59 | 16 | 16512 | 20| 4 | 0 | 0 | +| 60 | 16 | 0 | 21| 4 | 0 | 0 | +| 61 | 10 | 0 | 22| 4 | 0 | 0 | +| 62 | 10 | 0 | 23| 4 | 0 | 0 | +| 63 | 23 | 0 | 24| 4 | 0 | 0 | diff --git a/projects/05/ComputerRect.tst b/projects/05/ComputerRect.tst new file mode 100755 index 0000000..b1e2126 --- /dev/null +++ b/projects/05/ComputerRect.tst @@ -0,0 +1,26 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/ComputerRect.tst + +load Computer.hdl, +output-file ComputerRect.out, +compare-to ComputerRect.cmp, +output-list time%S1.4.1 ARegister[]%D1.7.1 DRegister[]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1; + +// Load a program written in the Hack machine language. +// The program draws a rectangle of width 16 pixels and +// length RAM[0] at the top left of the screen. +ROM32K load Rect.hack, + +echo "Before you run this script, select the 'Screen' option from the 'View' menu"; + +echo "A small rectangle should be drawn at the top left of the screen (the 'Screen' option of the 'View' menu should be selected.)"; + +// Draws a rectangle 16 pixels wide and 4 pixels long +set RAM16K[0] 4, +output; + +repeat 63 { + tick, tock, output; +} diff --git a/projects/05/Max.hack b/projects/05/Max.hack new file mode 100755 index 0000000..2e04a8d --- /dev/null +++ b/projects/05/Max.hack @@ -0,0 +1,16 @@ +0000000000000000 +1111110000010000 +0000000000000001 +1111010011010000 +0000000000001010 +1110001100000001 +0000000000000001 +1111110000010000 +0000000000001100 +1110101010000111 +0000000000000000 +1111110000010000 +0000000000000010 +1110001100001000 +0000000000001110 +1110101010000111 diff --git a/projects/05/Memory.cmp b/projects/05/Memory.cmp new file mode 100755 index 0000000..613d171 --- /dev/null +++ b/projects/05/Memory.cmp @@ -0,0 +1,54 @@ +| in |load | address | out | +| -1 | 1 | 000000000000000 | 0 | +| -1 | 1 | 000000000000000 | -1 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 010000000000000 | 0 | +| 9999 | 0 | 100000000000000 | 0 | +| 2222 | 1 | 010000000000000 | 0 | +| 2222 | 1 | 010000000000000 | 2222 | +| 9999 | 0 | 010000000000000 | 2222 | +| 9999 | 0 | 010000000000000 | 2222 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 100000000000000 | 0 | +| 9999 | 0 | 000000000000001 | 0 | +| 9999 | 0 | 000000000000010 | 0 | +| 9999 | 0 | 000000000000100 | 0 | +| 9999 | 0 | 000000000001000 | 0 | +| 9999 | 0 | 000000000010000 | 0 | +| 9999 | 0 | 000000000100000 | 0 | +| 9999 | 0 | 000000001000000 | 0 | +| 9999 | 0 | 000000010000000 | 0 | +| 9999 | 0 | 000000100000000 | 0 | +| 9999 | 0 | 000001000000000 | 0 | +| 9999 | 0 | 000010000000000 | 0 | +| 9999 | 0 | 000100000000000 | 0 | +| 9999 | 0 | 001000000000000 | 0 | +| 9999 | 0 | 010000000000000 | 2222 | +| 1234 | 1 | 001001000110100 | 0 | +| 1234 | 1 | 001001000110100 | 1234 | +| 1234 | 0 | 010001000110100 | 0 | +| 1234 | 0 | 110001000110100 | 0 | +| 2345 | 1 | 010001101000101 | 0 | +| 2345 | 1 | 010001101000101 | 2345 | +| 2345 | 0 | 000001101000101 | 0 | +| 2345 | 0 | 100001101000101 | 0 | +| 2345 | 0 | 110000000000000 | 75 | +| -1 | 1 | 100111111001111 | -1 | +| -1 | 1 | 101000001001111 | -1 | +| -1 | 1 | 000111111001111 | 0 | +| -1 | 1 | 010111111001111 | 0 | +| -1 | 0 | 100111111001110 | 0 | +| -1 | 0 | 100111111001101 | 0 | +| -1 | 0 | 100111111001011 | 0 | +| -1 | 0 | 100111111000111 | 0 | +| -1 | 0 | 100111111011111 | 0 | +| -1 | 0 | 100111111101111 | 0 | +| -1 | 0 | 100111110001111 | 0 | +| -1 | 0 | 100111101001111 | 0 | +| -1 | 0 | 100111011001111 | 0 | +| -1 | 0 | 100110111001111 | 0 | +| -1 | 0 | 100101111001111 | 0 | +| -1 | 0 | 100011111001111 | 0 | +| -1 | 0 | 101111111001111 | 0 | +| -1 | 0 | 110000000000000 | 89 | diff --git a/projects/05/Memory.hdl b/projects/05/Memory.hdl new file mode 100755 index 0000000..6aff3c3 --- /dev/null +++ b/projects/05/Memory.hdl @@ -0,0 +1,36 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/Memory.hdl + +/** + * The complete address space of the Hack computer's memory, + * including RAM and memory-mapped I/O. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = Memory[address(t)](t) + * Write: if load(t-1) then Memory[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load==1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output from the next time step onward. + * Address space rules: + * Only the upper 16K+8K+1 words of the Memory chip are used. + * Access to address>0x6000 is invalid. Access to any address in + * the range 0x4000-0x5FFF results in accessing the screen memory + * map. Access to address 0x6000 results in accessing the keyboard + * memory map. The behavior in these addresses is described in the + * Screen and Keyboard chip specifications given in the book. + */ + +CHIP Memory { + IN in[16], load, address[15]; + OUT out[16]; + + PARTS: + DMux4Way(in=load,sel[0]=address[13],sel[1]=address[14] ,a=ram16k ,b=ram16k2,c=ramScreen); + Or(a=ram16k ,b=ram16k2 ,out=ram16end); + RAM16K(in=in ,load=ram16end ,address=address[0..13] ,out=out1); + Screen(in=in ,load=ramScreen ,address=address[0..12] ,out=out2); + Keyboard(out=outKey); + Mux4Way16(a=out1 ,b=out1 ,c=out2 ,d=outKey ,sel[0]=address[13],sel[1]=address[14] ,out=out); +} \ No newline at end of file diff --git a/projects/05/Memory.out b/projects/05/Memory.out new file mode 100755 index 0000000..613d171 --- /dev/null +++ b/projects/05/Memory.out @@ -0,0 +1,54 @@ +| in |load | address | out | +| -1 | 1 | 000000000000000 | 0 | +| -1 | 1 | 000000000000000 | -1 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 010000000000000 | 0 | +| 9999 | 0 | 100000000000000 | 0 | +| 2222 | 1 | 010000000000000 | 0 | +| 2222 | 1 | 010000000000000 | 2222 | +| 9999 | 0 | 010000000000000 | 2222 | +| 9999 | 0 | 010000000000000 | 2222 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 100000000000000 | 0 | +| 9999 | 0 | 000000000000001 | 0 | +| 9999 | 0 | 000000000000010 | 0 | +| 9999 | 0 | 000000000000100 | 0 | +| 9999 | 0 | 000000000001000 | 0 | +| 9999 | 0 | 000000000010000 | 0 | +| 9999 | 0 | 000000000100000 | 0 | +| 9999 | 0 | 000000001000000 | 0 | +| 9999 | 0 | 000000010000000 | 0 | +| 9999 | 0 | 000000100000000 | 0 | +| 9999 | 0 | 000001000000000 | 0 | +| 9999 | 0 | 000010000000000 | 0 | +| 9999 | 0 | 000100000000000 | 0 | +| 9999 | 0 | 001000000000000 | 0 | +| 9999 | 0 | 010000000000000 | 2222 | +| 1234 | 1 | 001001000110100 | 0 | +| 1234 | 1 | 001001000110100 | 1234 | +| 1234 | 0 | 010001000110100 | 0 | +| 1234 | 0 | 110001000110100 | 0 | +| 2345 | 1 | 010001101000101 | 0 | +| 2345 | 1 | 010001101000101 | 2345 | +| 2345 | 0 | 000001101000101 | 0 | +| 2345 | 0 | 100001101000101 | 0 | +| 2345 | 0 | 110000000000000 | 75 | +| -1 | 1 | 100111111001111 | -1 | +| -1 | 1 | 101000001001111 | -1 | +| -1 | 1 | 000111111001111 | 0 | +| -1 | 1 | 010111111001111 | 0 | +| -1 | 0 | 100111111001110 | 0 | +| -1 | 0 | 100111111001101 | 0 | +| -1 | 0 | 100111111001011 | 0 | +| -1 | 0 | 100111111000111 | 0 | +| -1 | 0 | 100111111011111 | 0 | +| -1 | 0 | 100111111101111 | 0 | +| -1 | 0 | 100111110001111 | 0 | +| -1 | 0 | 100111101001111 | 0 | +| -1 | 0 | 100111011001111 | 0 | +| -1 | 0 | 100110111001111 | 0 | +| -1 | 0 | 100101111001111 | 0 | +| -1 | 0 | 100011111001111 | 0 | +| -1 | 0 | 101111111001111 | 0 | +| -1 | 0 | 110000000000000 | 89 | diff --git a/projects/05/Memory.tst b/projects/05/Memory.tst new file mode 100755 index 0000000..f712a48 --- /dev/null +++ b/projects/05/Memory.tst @@ -0,0 +1,163 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/Memory.tst + +load Memory.hdl, +output-file Memory.out, +compare-to Memory.cmp, +output-list in%D1.6.1 load%B2.1.2 address%B1.15.1 out%D1.6.1; + +echo "Before you run this script, select the 'Screen' option from the 'View' menu"; + +set in -1, // Set RAM[0] = -1 +set load 1, +set address 0, +tick, +output; +tock, +output; + +set in 9999, // RAM[0] holds value +set load 0, +tick, +output; +tock, +output; + +set address %X2000, // Did not also write to upper RAM or Screen +eval, +output; +set address %X4000, +eval, +output; + +set in 2222, // Set RAM[2000] = 2222 +set load 1, +set address %X2000, +tick, +output; +tock, +output; + +set in 9999, // RAM[2000] holds value +set load 0, +tick, +output; +tock, +output; + +set address 0, // Did not also write to lower RAM or Screen +eval, +output; +set address %X4000, +eval, +output; + +set load 0, // Low order address bits connected +set address %X0001, eval, output; +set address %X0002, eval, output; +set address %X0004, eval, output; +set address %X0008, eval, output; +set address %X0010, eval, output; +set address %X0020, eval, output; +set address %X0040, eval, output; +set address %X0080, eval, output; +set address %X0100, eval, output; +set address %X0200, eval, output; +set address %X0400, eval, output; +set address %X0800, eval, output; +set address %X1000, eval, output; +set address %X2000, eval, output; + +set address %X1234, // RAM[1234] = 1234 +set in 1234, +set load 1, +tick, +output; +tock, +output; + +set load 0, +set address %X2234, // Did not also write to upper RAM or Screen +eval, output; +set address %X6234, +eval, output; + +set address %X2345, // RAM[2345] = 2345 +set in 2345, +set load 1, +tick, +output; +tock, +output; + +set load 0, +set address %X0345, // Did not also write to lower RAM or Screen +eval, output; +set address %X4345, +eval, output; + +// Keyboard test + +set address 24576, +echo "Click the Keyboard icon and hold down the 'K' key (uppercase) until you see the next message (it should appear shortly after that) ...", +// It's important to keep holding the key down since if the system is busy, +// the memory will zero itself before being outputted. + +while out <> 75 { + eval, +} + +clear-echo, +output; + +// Screen test + +set load 1, +set in -1, +set address %X4FCF, +tick, +tock, +output, + +set address %X504F, +tick, +tock, +output; + +set address %X0FCF, // Did not also write to lower or upper RAM +eval, +output; +set address %X2FCF, +eval, +output; + +set load 0, // Low order address bits connected +set address %X4FCE, eval, output; +set address %X4FCD, eval, output; +set address %X4FCB, eval, output; +set address %X4FC7, eval, output; +set address %X4FDF, eval, output; +set address %X4FEF, eval, output; +set address %X4F8F, eval, output; +set address %X4F4F, eval, output; +set address %X4ECF, eval, output; +set address %X4DCF, eval, output; +set address %X4BCF, eval, output; +set address %X47CF, eval, output; +set address %X5FCF, eval, output; + + +set load 0, +set address 24576, +echo "Make sure you see ONLY two horizontal lines in the middle of the screen. Hold down 'Y' (uppercase) until you see the next message ...", +// It's important to keep holding the key down since if the system is busy, +// the memory will zero itself before being outputted. + +while out <> 89 { + eval, +} + +clear-echo, +output; diff --git a/projects/05/Rect.hack b/projects/05/Rect.hack new file mode 100755 index 0000000..ee017ab --- /dev/null +++ b/projects/05/Rect.hack @@ -0,0 +1,25 @@ +0000000000000000 +1111110000010000 +0000000000010111 +1110001100000110 +0000000000010000 +1110001100001000 +0100000000000000 +1110110000010000 +0000000000010001 +1110001100001000 +0000000000010001 +1111110000100000 +1110111010001000 +0000000000010001 +1111110000010000 +0000000000100000 +1110000010010000 +0000000000010001 +1110001100001000 +0000000000010000 +1111110010011000 +0000000000001010 +1110001100000001 +0000000000010111 +1110101010000111 diff --git a/projects/06/add/Add.asm b/projects/06/add/Add.asm new file mode 100755 index 0000000..fbd1688 --- /dev/null +++ b/projects/06/add/Add.asm @@ -0,0 +1,13 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/06/add/Add.asm + +// Computes R0 = 2 + 3 (R0 refers to RAM[0]) + +@2 +D = A +@3 +D=D+A +@0 +M=D diff --git a/projects/06/assembler_final_not_refined.py b/projects/06/assembler_final_not_refined.py new file mode 100755 index 0000000..22765fd --- /dev/null +++ b/projects/06/assembler_final_not_refined.py @@ -0,0 +1,230 @@ +def a_instruct(string): # covert the A instruction to bits + string = string.strip('@\n') + x = "{0:b}".format(int(string)) # convert the number to binary, problem if the number is too big + while len(x) < 16: # need to be 16 bits and 1 for \n + x = "0" + x + return x # return th 16 bit value + + +def c_instruct(string): # priema edna liniq koeto e edna instrukciq i q prevryshta v bit kod + string = string + "\n" + flag1, flag2, p = 0, 0, 0 + dest_s = '' + comp_s = '' + jump_s = '' + for c in range(len(string)): + if string[c] == '=': # ako ima ravno znachi predi nego ima destination + i = 0 + flag1 = 1 # diga flag za destination + while i < c: + p = c + dest_s += string[i] + i += 1 + dest_s = destDic.get(dest_s) # convert t to Destination + if string[c] == ';': # ako ima ; znachi predi nego ima computation + flag2 = 1 # diga flag za Jump + if flag1 == 0: # ako flaga za destination ne e dignat zapochvame ot nachaloto na liniqta + p = 0 + else: # ako e zapochvame ot kydeto e ravnoto koeto se pazi vyv var i + p = i + while p < c: + comp_s += string[p] + p += 1 + comp_s = compDic.get(comp_s) # convert t1 to Computation + + if string[c] == '\n': + if flag2 == 1: # ako ima flag za jump to vzimame stoinosta na jumpa + j = p + 1 + while j < c: + jump_s += string[j] + j += 1 + jump_s = jumpDic.get(jump_s) + else: # ako nqma togava vzima stoinosta na computationa + j = i + 1 + while j < c: + comp_s += string[j] + j += 1 + comp_s = compDic.get(comp_s) + final_result = '111' + comp_s # dobavqme 111 koeto e standart za C instrukt i computation bez koeto nqma instrukciq + if dest_s != '': # ako e imalo dest go dobavqme + final_result = final_result + dest_s + else: # inache dobavqme 3 nuli + final_result = final_result + '000' + if jump_s != '': # ako e imalo jump go dobavqme + final_result = final_result + jump_s + else: # inache dobavqme 3 nuli + final_result = final_result + '000' + return final_result + + +def check_a_or_c(temp_string): + line = '' + temp_string1 = '' + for j in temp_string: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + for index in range(len(line)): # proverqva vseki simvol ot liniqta + if line[index] == "@": # ako liniqta zapochva s @ znachi e a instrukciq + temp_string1 += a_instruct(line) + '\n' + line = '' + break + else: # ako ne zapochva s @ znachi e C instrukciq + temp_string1 += c_instruct(line) + '\n' + line = '' + break + return temp_string1 + + +def clear_file(temp_string_cf): # clears the empty lines, comments and spaces and writes them in a string + for line in asmfile: + f = 0 + if line == '\n': # removes empty lines + continue + for index in range(len(line)): + if line[index] == "/" and line[index + 1] == '/': # checks if it is comment + if f == 1: # maybe a problem if the last element of a line is / since it will stay + temp_string_cf += '\n' + break + if line[index] != ' ': # removes all of the whitespaces except newlines + temp_string_cf += line[index] + f = 1 + return temp_string_cf + + +def label(temp_string): # removes the labels and adds them to the dictionary writes all in a string + line = '' + temp_string_l = '' + global rowasm + for j in temp_string: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + f = 0 + for index in range(len(line)): # loops through the lines char by char + if line[index] == "(": + # checks if it is a label, will be a problem if there is only "(" and no closing bracket alse need to check label syntax + if bool(labelDic.get(line.strip('()'))) == False: # check if label is already in the Dictionary + labelDic[line.strip("()")] = str(rowasm) # adds the label to the dictionary + rowasm -= 1 # need to pay attention to the counting cause im not sure + f = 1 + break # brake so i don't write this line in the string since it needs to be removed + if f != 1: + temp_string_l += line + temp_string_l += '\n' + rowasm += 1 + line = '' + return temp_string_l + + +def variable(temp_string): # replaces the variables with the correct address + global variableCount + line = '' + temp_string_v = '' + for j in temp_string: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + for index in range(len(line)): + if line[index] == '@' and numbers.find(line[index + 1]) < 0: # checks if the line holds a variable + if bool(labelDic.get(line.strip('@'))): # check if variable is already in the Dictionary + line = '@' + labelDic[line.strip('@')] # replaces the variable with address i hope + else: + labelDic[line.strip('@')] = str(variableCount) # if isn't it adds it + line = '@' + str(variableCount) # replaces the variable with address i hope + variableCount += 1 # increases the variable counter so i don't write them all in address 16 + break + temp_string_v += line + '\n' # appends the line to the string + line = '' + return temp_string_v + + +destDic = {'None': '000', + 'M': '001', + 'D': '010', + 'MD': '011', + 'A': '100', + 'AM': '101', + 'AD': '110', + 'AMD': '111', } # contains all destinations and their bit equivalent +jumpDic = {'None': '000', + 'JGT': '001', + 'JQE': '010', + 'JGE': '011', + 'JLT': '100', + 'JNE': '101', + 'JLE': '110', + 'JMP': '111', } # contains all jumps and their bit equivalent +compDic = {'0': '0101010', + '1': '0111111', + '-1': '0111010', + 'D': '0001100', + 'A': '0110000', + '!D': '0001101', + '!A': '0110001', + '-D': '0001111', + '-A': '0110011', + 'D+1': '0011111', + 'A+1': '0110111', + 'D-1': '0001110', + 'A-1': '0110010', + 'D+A': '0000010', + 'D-A': '0010011', + 'A-D': '0000111', + 'D&A': '0000000', + 'D|A': '0010101', + 'M': '1110000', + '!M': '1110001', + '-M': '1110011', + 'M+1': '1110111', + 'M-1': '1110010', + 'D+M': '1000010', + 'D-M': '1010011', + 'M-D': '1000111', + 'D&M': '1000000', + 'D|M': '1010101', + } # contains all computations and their bit equivalent +tempString = '' # create empty string +rowasm = 0 +numbers = '0123456789' # used to check if given instruction calls to variable +variableCount = 16 # keeps count of the variable address + +labelDic = {'SP': '0', + 'LCL': '1', + 'ARG': '2', + 'THIS': '3', + 'THAT': '4', + 'SCREEN': '16384', + 'KBD': '24576', + 'R0': '0', + 'R1': '1', + 'R2': '2', + 'R3': '3', + 'R4': '4', + 'R5': '5', + 'R6': '6', + 'R7': '7', + 'R8': '8', + 'R9': '9', + 'R10': '10', + 'R11': '11', + 'R12': '12', + 'R13': '13', + 'R14': '14', + 'R15': '15', + } # dictionary containing Labels and Variables in format: AddressNumber : LabelName/ VariableName +with open("C:/Users/AGrudev/Desktop/n2t/nand2tetris/projects/06/pong/Pong.asm", "r+") as asmfile: + tempString = clear_file(tempString) +print(tempString + '----------') + +tempString = label(tempString) +print(tempString + '----------') + +tempString = variable(tempString) +print(tempString + '----------') + +tempString = check_a_or_c(tempString) +print(tempString + '----------') + +with open("C:/Users/AGrudev/Desktop/n2t/nand2tetris/projects/06/pong/Pong.hack", "w+") as destfile: + destfile.write(tempString) diff --git a/projects/06/max/Max.asm b/projects/06/max/Max.asm new file mode 100755 index 0000000..b62c138 --- /dev/null +++ b/projects/06/max/Max.asm @@ -0,0 +1,26 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/06/max/Max.asm + +// Computes R2 = max(R0, R1) (R0,R1,R2 refer to RAM[0],RAM[1],RAM[2]) + + @R0 + D=M // D = first number + @R1 + D=D-M // D = first number - second number + @OUTPUT_FIRST + D;JGT // if D>0 (first is greater) goto output_first + @R1 + D=M // D = second number + @OUTPUT_D + 0;JMP // goto output_d +(OUTPUT_FIRST) + @R0 + D=M // D = first number +(OUTPUT_D) + @R2 + M=D // M[2] = D (greatest number) +(INFINITE_LOOP) + @INFINITE_LOOP + 0;JMP // infinite loop diff --git a/projects/06/max/Max.hack b/projects/06/max/Max.hack new file mode 100755 index 0000000..2e04a8d --- /dev/null +++ b/projects/06/max/Max.hack @@ -0,0 +1,16 @@ +0000000000000000 +1111110000010000 +0000000000000001 +1111010011010000 +0000000000001010 +1110001100000001 +0000000000000001 +1111110000010000 +0000000000001100 +1110101010000111 +0000000000000000 +1111110000010000 +0000000000000010 +1110001100001000 +0000000000001110 +1110101010000111 diff --git a/projects/06/max/MaxL.asm b/projects/06/max/MaxL.asm new file mode 100755 index 0000000..fc3ccbf --- /dev/null +++ b/projects/06/max/MaxL.asm @@ -0,0 +1,23 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/06/max/MaxL.asm + +// Symbol-less version of the Max.asm program. + +@0 +D=M +@1 +D=D-M +@10 +D;JGT +@1 +D=M +@12 +0;JMP +@0 +D=M +@2 +M=D +@14 +0;JMP diff --git a/projects/06/pong/Pong.asm b/projects/06/pong/Pong.asm new file mode 100755 index 0000000..79691f0 --- /dev/null +++ b/projects/06/pong/Pong.asm @@ -0,0 +1,28375 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/06/pong/Pong.asm + +// The Pong game program was originally written in the high-level Jack language. +// The Jack code was then translated by the Jack compiler into VM code. +// The VM code was then translated by the VM translator into the Hack +// assembly code shown here. + +@256 +D=A +@SP +M=D +@133 +0;JMP +@R15 +M=D +@SP +AM=M-1 +D=M +A=A-1 +D=M-D +M=0 +@END_EQ +D;JNE +@SP +A=M-1 +M=-1 +(END_EQ) +@R15 +A=M +0;JMP +@R15 +M=D +@SP +AM=M-1 +D=M +A=A-1 +D=M-D +M=0 +@END_GT +D;JLE +@SP +A=M-1 +M=-1 +(END_GT) +@R15 +A=M +0;JMP +@R15 +M=D +@SP +AM=M-1 +D=M +A=A-1 +D=M-D +M=0 +@END_LT +D;JGE +@SP +A=M-1 +M=-1 +(END_LT) +@R15 +A=M +0;JMP +@5 +D=A +@LCL +A=M-D +D=M +@R13 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +D=A +@SP +M=D+1 +@LCL +D=M +@R14 +AM=D-1 +D=M +@THAT +M=D +@R14 +AM=M-1 +D=M +@THIS +M=D +@R14 +AM=M-1 +D=M +@ARG +M=D +@R14 +AM=M-1 +D=M +@LCL +M=D +@R13 +A=M +0;JMP +@SP +A=M +M=D +@LCL +D=M +@SP +AM=M+1 +M=D +@ARG +D=M +@SP +AM=M+1 +M=D +@THIS +D=M +@SP +AM=M+1 +M=D +@THAT +D=M +@SP +AM=M+1 +M=D +@4 +D=A +@R13 +D=D+M +@SP +D=M-D +@ARG +M=D +@SP +MD=M+1 +@LCL +M=D +@R14 +A=M +0;JMP +@0 +D=A +@R13 +M=D +@sys.init +D=A +@R14 +M=D +@RET_ADDRESS_CALL0 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL0) +(ball.new) +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.alloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL1 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL1) +@SP +AM=M-1 +D=M +@THIS +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@10 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@THIS +D=M +@11 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@12 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@THIS +D=M +@13 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@THIS +D=M +@14 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.show +D=A +@R14 +M=D +@RET_ADDRESS_CALL2 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL2) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(ball.dispose) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.dealloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL3 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL3) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ball.show) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL4 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL4) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.draw +D=A +@R14 +M=D +@RET_ADDRESS_CALL5 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL5) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ball.hide) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@SP +M=M+1 +A=M-1 +M=0 +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL6 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL6) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.draw +D=A +@R14 +M=D +@RET_ADDRESS_CALL7 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL7) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ball.draw) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@R13 +M=D +@screen.drawrectangle +D=A +@R14 +M=D +@RET_ADDRESS_CALL8 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL8) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ball.getleft) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(ball.getright) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@54 +0;JMP +(ball.setdestination) +@3 +D=A +(LOOP_ball.setdestination) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_ball.setdestination +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL9 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL9) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL10 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL10) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT0 +D=A +@38 +0;JMP +(RET_ADDRESS_LT0) +@THIS +D=M +@7 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ball.setdestination$if_true0 +D;JNE +@ball.setdestination$if_false0 +0;JMP +(ball.setdestination$if_true0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT1 +D=A +@38 +0;JMP +(RET_ADDRESS_LT1) +@THIS +D=M +@8 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT2 +D=A +@38 +0;JMP +(RET_ADDRESS_LT2) +@THIS +D=M +@9 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ball.setdestination$if_end0 +0;JMP +(ball.setdestination$if_false0) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT3 +D=A +@38 +0;JMP +(RET_ADDRESS_LT3) +@THIS +D=M +@8 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT4 +D=A +@38 +0;JMP +(RET_ADDRESS_LT4) +@THIS +D=M +@9 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(ball.setdestination$if_end0) +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL11 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL11) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL12 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL12) +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL13 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL13) +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ball.move) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.hide +D=A +@R14 +M=D +@RET_ADDRESS_CALL14 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL14) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT5 +D=A +@38 +0;JMP +(RET_ADDRESS_LT5) +@SP +AM=M-1 +D=M +@ball.move$if_true0 +D;JNE +@ball.move$if_false0 +0;JMP +(ball.move$if_true0) +@THIS +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ball.move$if_end0 +0;JMP +(ball.move$if_false0) +@THIS +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@THIS +D=M +@9 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ball.move$if_true1 +D;JNE +@ball.move$if_false1 +0;JMP +(ball.move$if_true1) +@THIS +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ball.move$if_true2 +D;JNE +@ball.move$if_false2 +0;JMP +(ball.move$if_true2) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@ball.move$if_end2 +0;JMP +(ball.move$if_false2) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +(ball.move$if_end2) +@ball.move$if_end1 +0;JMP +(ball.move$if_false1) +@THIS +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ball.move$if_true3 +D;JNE +@ball.move$if_false3 +0;JMP +(ball.move$if_true3) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@ball.move$if_end3 +0;JMP +(ball.move$if_false3) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +(ball.move$if_end3) +(ball.move$if_end1) +(ball.move$if_end0) +@THIS +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ball.move$if_true4 +D;JNE +@ball.move$if_false4 +0;JMP +(ball.move$if_true4) +@THIS +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ball.move$if_true5 +D;JNE +@ball.move$if_false5 +0;JMP +(ball.move$if_true5) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +@ball.move$if_end5 +0;JMP +(ball.move$if_false5) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +(ball.move$if_end5) +@ball.move$if_end4 +0;JMP +(ball.move$if_false4) +@THIS +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ball.move$if_true6 +D;JNE +@ball.move$if_false6 +0;JMP +(ball.move$if_true6) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +@ball.move$if_end6 +0;JMP +(ball.move$if_false6) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +(ball.move$if_end6) +(ball.move$if_end4) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@10 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT0 +D=A +@22 +0;JMP +(RET_ADDRESS_GT0) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ball.move$if_true7 +D;JNE +@ball.move$if_false7 +0;JMP +(ball.move$if_true7) +@SP +M=M+1 +A=M-1 +M=1 +@THIS +D=M +@14 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +D=M +@10 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +(ball.move$if_false7) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@11 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT6 +D=A +@38 +0;JMP +(RET_ADDRESS_LT6) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ball.move$if_true8 +D;JNE +@ball.move$if_false8 +0;JMP +(ball.move$if_true8) +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@14 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +D=M +@11 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +(ball.move$if_false8) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@12 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT1 +D=A +@22 +0;JMP +(RET_ADDRESS_GT1) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ball.move$if_true9 +D;JNE +@ball.move$if_false9 +0;JMP +(ball.move$if_true9) +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@14 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +D=M +@12 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +(ball.move$if_false9) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@13 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT7 +D=A +@38 +0;JMP +(RET_ADDRESS_LT7) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ball.move$if_true10 +D;JNE +@ball.move$if_false10 +0;JMP +(ball.move$if_true10) +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@14 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@THIS +D=M +@13 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +(ball.move$if_false10) +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.show +D=A +@R14 +M=D +@RET_ADDRESS_CALL15 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL15) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@14 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(ball.bounce) +@5 +D=A +(LOOP_ball.bounce) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_ball.bounce +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL16 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL16) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL17 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL17) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ0 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ0) +@SP +AM=M-1 +D=M +@ball.bounce$if_true0 +D;JNE +@ball.bounce$if_false0 +0;JMP +(ball.bounce$if_true0) +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ball.bounce$if_end0 +0;JMP +(ball.bounce$if_false0) +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT8 +D=A +@38 +0;JMP +(RET_ADDRESS_LT8) +@SP +A=M-1 +M=!M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@RET_ADDRESS_EQ1 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ1) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT9 +D=A +@38 +0;JMP +(RET_ADDRESS_LT9) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@RET_ADDRESS_EQ2 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ2) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +@ball.bounce$if_true1 +D;JNE +@ball.bounce$if_false1 +0;JMP +(ball.bounce$if_true1) +@20 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ball.bounce$if_end1 +0;JMP +(ball.bounce$if_false1) +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +(ball.bounce$if_end1) +(ball.bounce$if_end0) +@THIS +D=M +@14 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@RET_ADDRESS_EQ3 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ3) +@SP +AM=M-1 +D=M +@ball.bounce$if_true2 +D;JNE +@ball.bounce$if_false2 +0;JMP +(ball.bounce$if_true2) +@506 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@50 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL18 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL18) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL19 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL19) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL20 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL20) +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@ball.bounce$if_end2 +0;JMP +(ball.bounce$if_false2) +@THIS +D=M +@14 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ4 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ4) +@SP +AM=M-1 +D=M +@ball.bounce$if_true3 +D;JNE +@ball.bounce$if_false3 +0;JMP +(ball.bounce$if_true3) +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@50 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL21 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL21) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL22 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL22) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL23 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL23) +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@ball.bounce$if_end3 +0;JMP +(ball.bounce$if_false3) +@THIS +D=M +@14 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ5 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ5) +@SP +AM=M-1 +D=M +@ball.bounce$if_true4 +D;JNE +@ball.bounce$if_false4 +0;JMP +(ball.bounce$if_true4) +@250 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@25 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL24 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL24) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL25 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL25) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL26 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL26) +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@ball.bounce$if_end4 +0;JMP +(ball.bounce$if_false4) +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@25 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL27 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL27) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL28 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL28) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL29 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL29) +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(ball.bounce$if_end4) +(ball.bounce$if_end3) +(ball.bounce$if_end2) +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@R13 +M=D +@ball.setdestination +D=A +@R14 +M=D +@RET_ADDRESS_CALL30 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL30) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(bat.new) +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.alloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL31 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL31) +@SP +AM=M-1 +D=M +@THIS +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.show +D=A +@R14 +M=D +@RET_ADDRESS_CALL32 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL32) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(bat.dispose) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.dealloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL33 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL33) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(bat.show) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL34 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL34) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.draw +D=A +@R14 +M=D +@RET_ADDRESS_CALL35 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL35) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(bat.hide) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@SP +M=M+1 +A=M-1 +M=0 +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL36 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL36) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.draw +D=A +@R14 +M=D +@RET_ADDRESS_CALL37 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL37) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(bat.draw) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@R13 +M=D +@screen.drawrectangle +D=A +@R14 +M=D +@RET_ADDRESS_CALL38 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL38) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(bat.setdirection) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(bat.getleft) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(bat.getright) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@54 +0;JMP +(bat.setwidth) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.hide +D=A +@R14 +M=D +@RET_ADDRESS_CALL39 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL39) +@SP +AM=M-1 +D=M +@R5 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.show +D=A +@R14 +M=D +@RET_ADDRESS_CALL40 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL40) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(bat.move) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@RET_ADDRESS_EQ6 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ6) +@SP +AM=M-1 +D=M +@bat.move$if_true0 +D;JNE +@bat.move$if_false0 +0;JMP +(bat.move$if_true0) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT10 +D=A +@38 +0;JMP +(RET_ADDRESS_LT10) +@SP +AM=M-1 +D=M +@bat.move$if_true1 +D;JNE +@bat.move$if_false1 +0;JMP +(bat.move$if_true1) +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +(bat.move$if_false1) +@SP +M=M+1 +A=M-1 +M=0 +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL41 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL41) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@R13 +M=D +@screen.drawrectangle +D=A +@R14 +M=D +@RET_ADDRESS_CALL42 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL42) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL43 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL43) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@R13 +M=D +@screen.drawrectangle +D=A +@R14 +M=D +@RET_ADDRESS_CALL44 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL44) +@SP +AM=M-1 +D=M +@R5 +M=D +@bat.move$if_end0 +0;JMP +(bat.move$if_false0) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT2 +D=A +@22 +0;JMP +(RET_ADDRESS_GT2) +@SP +AM=M-1 +D=M +@bat.move$if_true2 +D;JNE +@bat.move$if_false2 +0;JMP +(bat.move$if_true2) +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +(bat.move$if_false2) +@SP +M=M+1 +A=M-1 +M=0 +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL45 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL45) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@R13 +M=D +@screen.drawrectangle +D=A +@R14 +M=D +@RET_ADDRESS_CALL46 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL46) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@1 +D=A +@R13 +M=D +@screen.setcolor +D=A +@R14 +M=D +@RET_ADDRESS_CALL47 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL47) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@R13 +M=D +@screen.drawrectangle +D=A +@R14 +M=D +@RET_ADDRESS_CALL48 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL48) +@SP +AM=M-1 +D=M +@R5 +M=D +(bat.move$if_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(main.main) +@SP +AM=M+1 +A=A-1 +M=0 +@0 +D=A +@R13 +M=D +@ponggame.newinstance +D=A +@R14 +M=D +@RET_ADDRESS_CALL49 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL49) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@ponggame.getinstance +D=A +@R14 +M=D +@RET_ADDRESS_CALL50 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL50) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ponggame.run +D=A +@R14 +M=D +@RET_ADDRESS_CALL51 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL51) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ponggame.dispose +D=A +@R14 +M=D +@RET_ADDRESS_CALL52 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL52) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ponggame.new) +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.alloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL53 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL53) +@SP +AM=M-1 +D=M +@THIS +M=D +@0 +D=A +@R13 +M=D +@screen.clearscreen +D=A +@R14 +M=D +@RET_ADDRESS_CALL54 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL54) +@SP +AM=M-1 +D=M +@R5 +M=D +@50 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@230 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@229 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@R13 +M=D +@bat.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL55 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL55) +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@253 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@222 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@229 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@R13 +M=D +@ball.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL56 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL56) +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@400 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@3 +D=A +@R13 +M=D +@ball.setdestination +D=A +@R14 +M=D +@RET_ADDRESS_CALL57 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL57) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@238 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@240 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@R13 +M=D +@screen.drawrectangle +D=A +@R14 +M=D +@RET_ADDRESS_CALL58 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL58) +@SP +AM=M-1 +D=M +@R5 +M=D +@22 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@2 +D=A +@R13 +M=D +@output.movecursor +D=A +@R14 +M=D +@RET_ADDRESS_CALL59 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL59) +@SP +AM=M-1 +D=M +@R5 +M=D +@8 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL60 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL60) +@83 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL61 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL61) +@99 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL62 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL62) +@111 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL63 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL63) +@114 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL64 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL64) +@101 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL65 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL65) +@58 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL66 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL66) +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL67 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL67) +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL68 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL68) +@1 +D=A +@R13 +M=D +@output.printstring +D=A +@R14 +M=D +@RET_ADDRESS_CALL69 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL69) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(ponggame.dispose) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.dispose +D=A +@R14 +M=D +@RET_ADDRESS_CALL70 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL70) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.dispose +D=A +@R14 +M=D +@RET_ADDRESS_CALL71 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL71) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.dealloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL72 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL72) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ponggame.newinstance) +@0 +D=A +@R13 +M=D +@ponggame.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL73 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL73) +@SP +AM=M-1 +D=M +@ponggame.0 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ponggame.getinstance) +@ponggame.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(ponggame.run) +@SP +AM=M+1 +A=A-1 +M=0 +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +(ponggame.run$while_exp0) +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ponggame.run$while_end0 +D;JNE +(ponggame.run$while_exp1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ7 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ7) +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ponggame.run$while_end1 +D;JNE +@0 +D=A +@R13 +M=D +@keyboard.keypressed +D=A +@R14 +M=D +@RET_ADDRESS_CALL74 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL74) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.move +D=A +@R14 +M=D +@RET_ADDRESS_CALL75 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL75) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ponggame.moveball +D=A +@R14 +M=D +@RET_ADDRESS_CALL76 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL76) +@SP +AM=M-1 +D=M +@R5 +M=D +@ponggame.run$while_exp1 +0;JMP +(ponggame.run$while_end1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@130 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ8 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ8) +@SP +AM=M-1 +D=M +@ponggame.run$if_true0 +D;JNE +@ponggame.run$if_false0 +0;JMP +(ponggame.run$if_true0) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@2 +D=A +@R13 +M=D +@bat.setdirection +D=A +@R14 +M=D +@RET_ADDRESS_CALL77 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL77) +@SP +AM=M-1 +D=M +@R5 +M=D +@ponggame.run$if_end0 +0;JMP +(ponggame.run$if_false0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@132 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ9 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ9) +@SP +AM=M-1 +D=M +@ponggame.run$if_true1 +D;JNE +@ponggame.run$if_false1 +0;JMP +(ponggame.run$if_true1) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@bat.setdirection +D=A +@R14 +M=D +@RET_ADDRESS_CALL78 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL78) +@SP +AM=M-1 +D=M +@R5 +M=D +@ponggame.run$if_end1 +0;JMP +(ponggame.run$if_false1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@140 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ10 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ10) +@SP +AM=M-1 +D=M +@ponggame.run$if_true2 +D;JNE +@ponggame.run$if_false2 +0;JMP +(ponggame.run$if_true2) +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +M=D +(ponggame.run$if_false2) +(ponggame.run$if_end1) +(ponggame.run$if_end0) +(ponggame.run$while_exp2) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ11 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ11) +@SP +A=M-1 +M=!M +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ponggame.run$while_end2 +D;JNE +@0 +D=A +@R13 +M=D +@keyboard.keypressed +D=A +@R14 +M=D +@RET_ADDRESS_CALL79 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL79) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.move +D=A +@R14 +M=D +@RET_ADDRESS_CALL80 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL80) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ponggame.moveball +D=A +@R14 +M=D +@RET_ADDRESS_CALL81 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL81) +@SP +AM=M-1 +D=M +@R5 +M=D +@ponggame.run$while_exp2 +0;JMP +(ponggame.run$while_end2) +@ponggame.run$while_exp0 +0;JMP +(ponggame.run$while_end0) +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ponggame.run$if_true3 +D;JNE +@ponggame.run$if_false3 +0;JMP +(ponggame.run$if_true3) +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@output.movecursor +D=A +@R14 +M=D +@RET_ADDRESS_CALL82 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL82) +@SP +AM=M-1 +D=M +@R5 +M=D +@9 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL83 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL83) +@71 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL84 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL84) +@97 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL85 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL85) +@109 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL86 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL86) +@101 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL87 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL87) +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL88 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL88) +@79 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL89 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL89) +@118 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL90 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL90) +@101 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL91 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL91) +@114 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL92 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL92) +@1 +D=A +@R13 +M=D +@output.printstring +D=A +@R14 +M=D +@RET_ADDRESS_CALL93 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL93) +@SP +AM=M-1 +D=M +@R5 +M=D +(ponggame.run$if_false3) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(ponggame.moveball) +@5 +D=A +(LOOP_ponggame.moveball) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_ponggame.moveball +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.move +D=A +@R14 +M=D +@RET_ADDRESS_CALL94 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL94) +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT3 +D=A +@22 +0;JMP +(RET_ADDRESS_GT3) +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ12 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ12) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +@ponggame.moveball$if_true0 +D;JNE +@ponggame.moveball$if_false0 +0;JMP +(ponggame.moveball$if_true0) +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.getleft +D=A +@R14 +M=D +@RET_ADDRESS_CALL95 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL95) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@bat.getright +D=A +@R14 +M=D +@RET_ADDRESS_CALL96 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL96) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.getleft +D=A +@R14 +M=D +@RET_ADDRESS_CALL97 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL97) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@ball.getright +D=A +@R14 +M=D +@RET_ADDRESS_CALL98 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL98) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ13 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ13) +@SP +AM=M-1 +D=M +@ponggame.moveball$if_true1 +D;JNE +@ponggame.moveball$if_false1 +0;JMP +(ponggame.moveball$if_true1) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT4 +D=A +@22 +0;JMP +(RET_ADDRESS_GT4) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT11 +D=A +@38 +0;JMP +(RET_ADDRESS_LT11) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +M=D +@THIS +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@ponggame.moveball$if_true2 +D;JNE +@ponggame.moveball$if_false2 +0;JMP +(ponggame.moveball$if_true2) +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@RET_ADDRESS_LT12 +D=A +@38 +0;JMP +(RET_ADDRESS_LT12) +@SP +AM=M-1 +D=M +@ponggame.moveball$if_true3 +D;JNE +@ponggame.moveball$if_false3 +0;JMP +(ponggame.moveball$if_true3) +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@ponggame.moveball$if_end3 +0;JMP +(ponggame.moveball$if_false3) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@RET_ADDRESS_GT5 +D=A +@22 +0;JMP +(RET_ADDRESS_GT5) +@SP +AM=M-1 +D=M +@ponggame.moveball$if_true4 +D;JNE +@ponggame.moveball$if_false4 +0;JMP +(ponggame.moveball$if_true4) +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(ponggame.moveball$if_false4) +(ponggame.moveball$if_end3) +@THIS +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@bat.setwidth +D=A +@R14 +M=D +@RET_ADDRESS_CALL99 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL99) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@22 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@output.movecursor +D=A +@R14 +M=D +@RET_ADDRESS_CALL100 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL100) +@SP +AM=M-1 +D=M +@R5 +M=D +@THIS +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.printint +D=A +@R14 +M=D +@RET_ADDRESS_CALL101 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL101) +@SP +AM=M-1 +D=M +@R5 +M=D +(ponggame.moveball$if_false2) +(ponggame.moveball$if_false1) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@ball.bounce +D=A +@R14 +M=D +@RET_ADDRESS_CALL102 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL102) +@SP +AM=M-1 +D=M +@R5 +M=D +(ponggame.moveball$if_false0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(array.new) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT6 +D=A +@22 +0;JMP +(RET_ADDRESS_GT6) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@array.new$if_true0 +D;JNE +@array.new$if_false0 +0;JMP +(array.new$if_true0) +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL103 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL103) +@SP +AM=M-1 +D=M +@R5 +M=D +(array.new$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.alloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL104 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL104) +@54 +0;JMP +(array.dispose) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.dealloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL105 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL105) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(keyboard.init) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(keyboard.keypressed) +@24576 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.peek +D=A +@R14 +M=D +@RET_ADDRESS_CALL106 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL106) +@54 +0;JMP +(keyboard.readchar) +@SP +A=M +M=0 +AD=A+1 +M=0 +@SP +M=D+1 +@SP +M=M+1 +A=M-1 +M=0 +@1 +D=A +@R13 +M=D +@output.printchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL107 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL107) +@SP +AM=M-1 +D=M +@R5 +M=D +(keyboard.readchar$while_exp0) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ14 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ14) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT7 +D=A +@22 +0;JMP +(RET_ADDRESS_GT7) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@keyboard.readchar$while_end0 +D;JNE +@0 +D=A +@R13 +M=D +@keyboard.keypressed +D=A +@R14 +M=D +@RET_ADDRESS_CALL108 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL108) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT8 +D=A +@22 +0;JMP +(RET_ADDRESS_GT8) +@SP +AM=M-1 +D=M +@keyboard.readchar$if_true0 +D;JNE +@keyboard.readchar$if_false0 +0;JMP +(keyboard.readchar$if_true0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +(keyboard.readchar$if_false0) +@keyboard.readchar$while_exp0 +0;JMP +(keyboard.readchar$while_end0) +@0 +D=A +@R13 +M=D +@string.backspace +D=A +@R14 +M=D +@RET_ADDRESS_CALL109 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL109) +@1 +D=A +@R13 +M=D +@output.printchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL110 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL110) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.printchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL111 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL111) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(keyboard.readline) +@5 +D=A +(LOOP_keyboard.readline) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_keyboard.readline +D;JGT +@80 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL112 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL112) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.printstring +D=A +@R14 +M=D +@RET_ADDRESS_CALL113 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL113) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@string.newline +D=A +@R14 +M=D +@RET_ADDRESS_CALL114 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL114) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@0 +D=A +@R13 +M=D +@string.backspace +D=A +@R14 +M=D +@RET_ADDRESS_CALL115 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL115) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +(keyboard.readline$while_exp0) +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@keyboard.readline$while_end0 +D;JNE +@0 +D=A +@R13 +M=D +@keyboard.readchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL116 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL116) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ15 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ15) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@keyboard.readline$if_true0 +D;JNE +@keyboard.readline$if_false0 +0;JMP +(keyboard.readline$if_true0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ16 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ16) +@SP +AM=M-1 +D=M +@keyboard.readline$if_true1 +D;JNE +@keyboard.readline$if_false1 +0;JMP +(keyboard.readline$if_true1) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.eraselastchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL117 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL117) +@SP +AM=M-1 +D=M +@R5 +M=D +@keyboard.readline$if_end1 +0;JMP +(keyboard.readline$if_false1) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL118 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL118) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +(keyboard.readline$if_end1) +(keyboard.readline$if_false0) +@keyboard.readline$while_exp0 +0;JMP +(keyboard.readline$while_end0) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(keyboard.readint) +@SP +A=M +M=0 +AD=A+1 +M=0 +@SP +M=D+1 +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@keyboard.readline +D=A +@R14 +M=D +@RET_ADDRESS_CALL119 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL119) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.intvalue +D=A +@R14 +M=D +@RET_ADDRESS_CALL120 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL120) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.dispose +D=A +@R14 +M=D +@RET_ADDRESS_CALL121 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL121) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(math.init) +@SP +AM=M+1 +A=A-1 +M=0 +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL122 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL122) +@SP +AM=M-1 +D=M +@math.1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL123 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL123) +@SP +AM=M-1 +D=M +@math.0 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +(math.init$while_exp0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT13 +D=A +@38 +0;JMP +(RET_ADDRESS_LT13) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.init$while_end0 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@math.init$while_exp0 +0;JMP +(math.init$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(math.abs) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT14 +D=A +@38 +0;JMP +(RET_ADDRESS_LT14) +@SP +AM=M-1 +D=M +@math.abs$if_true0 +D;JNE +@math.abs$if_false0 +0;JMP +(math.abs$if_true0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +(math.abs$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(math.multiply) +@5 +D=A +(LOOP_math.multiply) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_math.multiply +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT15 +D=A +@38 +0;JMP +(RET_ADDRESS_LT15) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT9 +D=A +@22 +0;JMP +(RET_ADDRESS_GT9) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT10 +D=A +@22 +0;JMP +(RET_ADDRESS_GT10) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT16 +D=A +@38 +0;JMP +(RET_ADDRESS_LT16) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL124 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL124) +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL125 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL125) +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT17 +D=A +@38 +0;JMP +(RET_ADDRESS_LT17) +@SP +AM=M-1 +D=M +@math.multiply$if_true0 +D;JNE +@math.multiply$if_false0 +0;JMP +(math.multiply$if_true0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +(math.multiply$if_false0) +(math.multiply$while_exp0) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT18 +D=A +@38 +0;JMP +(RET_ADDRESS_LT18) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.multiply$while_end0 +D;JNE +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT11 +D=A +@22 +0;JMP +(RET_ADDRESS_GT11) +@SP +AM=M-1 +D=M +@math.multiply$if_true1 +D;JNE +@math.multiply$if_false1 +0;JMP +(math.multiply$if_true1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +(math.multiply$if_false1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@math.multiply$while_exp0 +0;JMP +(math.multiply$while_end0) +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@math.multiply$if_true2 +D;JNE +@math.multiply$if_false2 +0;JMP +(math.multiply$if_true2) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(math.multiply$if_false2) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(math.divide) +@4 +D=A +(LOOP_math.divide) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_math.divide +D;JGT +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ17 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ17) +@SP +AM=M-1 +D=M +@math.divide$if_true0 +D;JNE +@math.divide$if_false0 +0;JMP +(math.divide$if_true0) +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL126 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL126) +@SP +AM=M-1 +D=M +@R5 +M=D +(math.divide$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT19 +D=A +@38 +0;JMP +(RET_ADDRESS_LT19) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT12 +D=A +@22 +0;JMP +(RET_ADDRESS_GT12) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT13 +D=A +@22 +0;JMP +(RET_ADDRESS_GT13) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT20 +D=A +@38 +0;JMP +(RET_ADDRESS_LT20) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL127 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL127) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL128 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL128) +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +(math.divide$while_exp0) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.divide$while_end0 +D;JNE +@32767 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT21 +D=A +@38 +0;JMP +(RET_ADDRESS_LT21) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.divide$if_true1 +D;JNE +@math.divide$if_false1 +0;JMP +(math.divide$if_true1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT14 +D=A +@22 +0;JMP +(RET_ADDRESS_GT14) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.divide$if_true2 +D;JNE +@math.divide$if_false2 +0;JMP +(math.divide$if_true2) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(math.divide$if_false2) +(math.divide$if_false1) +@math.divide$while_exp0 +0;JMP +(math.divide$while_end0) +(math.divide$while_exp1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@RET_ADDRESS_GT15 +D=A +@22 +0;JMP +(RET_ADDRESS_GT15) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.divide$while_end1 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT16 +D=A +@22 +0;JMP +(RET_ADDRESS_GT16) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.divide$if_true3 +D;JNE +@math.divide$if_false3 +0;JMP +(math.divide$if_true3) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +(math.divide$if_false3) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@math.divide$while_exp1 +0;JMP +(math.divide$while_end1) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@math.divide$if_true4 +D;JNE +@math.divide$if_false4 +0;JMP +(math.divide$if_true4) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +(math.divide$if_false4) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(math.sqrt) +@4 +D=A +(LOOP_math.sqrt) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_math.sqrt +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT22 +D=A +@38 +0;JMP +(RET_ADDRESS_LT22) +@SP +AM=M-1 +D=M +@math.sqrt$if_true0 +D;JNE +@math.sqrt$if_false0 +0;JMP +(math.sqrt$if_true0) +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL129 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL129) +@SP +AM=M-1 +D=M +@R5 +M=D +(math.sqrt$if_false0) +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(math.sqrt$while_exp0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@RET_ADDRESS_GT17 +D=A +@22 +0;JMP +(RET_ADDRESS_GT17) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@math.sqrt$while_end0 +D;JNE +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@math.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL130 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL130) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT18 +D=A +@22 +0;JMP +(RET_ADDRESS_GT18) +@SP +A=M-1 +M=!M +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT23 +D=A +@38 +0;JMP +(RET_ADDRESS_LT23) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +@math.sqrt$if_true1 +D;JNE +@math.sqrt$if_false1 +0;JMP +(math.sqrt$if_true1) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +(math.sqrt$if_false1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@math.sqrt$while_exp0 +0;JMP +(math.sqrt$while_end0) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(math.max) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT19 +D=A +@22 +0;JMP +(RET_ADDRESS_GT19) +@SP +AM=M-1 +D=M +@math.max$if_true0 +D;JNE +@math.max$if_false0 +0;JMP +(math.max$if_true0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +(math.max$if_false0) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(math.min) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT24 +D=A +@38 +0;JMP +(RET_ADDRESS_LT24) +@SP +AM=M-1 +D=M +@math.min$if_true0 +D;JNE +@math.min$if_false0 +0;JMP +(math.min$if_true0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +(math.min$if_false0) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(memory.init) +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@memory.0 +M=D +@2048 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@memory.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@14334 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@2049 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@memory.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@2050 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(memory.peek) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@memory.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(memory.poke) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@memory.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(memory.alloc) +@SP +AM=M+1 +A=A-1 +M=0 +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@RET_ADDRESS_LT25 +D=A +@38 +0;JMP +(RET_ADDRESS_LT25) +@SP +AM=M-1 +D=M +@memory.alloc$if_true0 +D;JNE +@memory.alloc$if_false0 +0;JMP +(memory.alloc$if_true0) +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL131 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL131) +@SP +AM=M-1 +D=M +@R5 +M=D +(memory.alloc$if_false0) +@2048 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(memory.alloc$while_exp0) +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT26 +D=A +@38 +0;JMP +(RET_ADDRESS_LT26) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@memory.alloc$while_end0 +D;JNE +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@memory.alloc$while_exp0 +0;JMP +(memory.alloc$while_end0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@16379 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT20 +D=A +@22 +0;JMP +(RET_ADDRESS_GT20) +@SP +AM=M-1 +D=M +@memory.alloc$if_true1 +D;JNE +@memory.alloc$if_false1 +0;JMP +(memory.alloc$if_true1) +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL132 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL132) +@SP +AM=M-1 +D=M +@R5 +M=D +(memory.alloc$if_false1) +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@RET_ADDRESS_GT21 +D=A +@22 +0;JMP +(RET_ADDRESS_GT21) +@SP +AM=M-1 +D=M +@memory.alloc$if_true2 +D;JNE +@memory.alloc$if_false2 +0;JMP +(memory.alloc$if_true2) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@RET_ADDRESS_EQ18 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ18) +@SP +AM=M-1 +D=M +@memory.alloc$if_true3 +D;JNE +@memory.alloc$if_false3 +0;JMP +(memory.alloc$if_true3) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@memory.alloc$if_end3 +0;JMP +(memory.alloc$if_false3) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +(memory.alloc$if_end3) +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +(memory.alloc$if_false2) +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@54 +0;JMP +(memory.dealloc) +@SP +A=M +M=0 +AD=A+1 +M=0 +@SP +M=D+1 +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ19 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ19) +@SP +AM=M-1 +D=M +@memory.dealloc$if_true0 +D;JNE +@memory.dealloc$if_false0 +0;JMP +(memory.dealloc$if_true0) +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@memory.dealloc$if_end0 +0;JMP +(memory.dealloc$if_false0) +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@RET_ADDRESS_EQ20 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ20) +@SP +AM=M-1 +D=M +@memory.dealloc$if_true1 +D;JNE +@memory.dealloc$if_false1 +0;JMP +(memory.dealloc$if_true1) +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@memory.dealloc$if_end1 +0;JMP +(memory.dealloc$if_false1) +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +(memory.dealloc$if_end1) +(memory.dealloc$if_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.init) +@16384 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.4 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.2 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@output.0 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL133 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL133) +@SP +AM=M-1 +D=M +@output.3 +M=D +@0 +D=A +@R13 +M=D +@output.initmap +D=A +@R14 +M=D +@RET_ADDRESS_CALL134 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL134) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@output.createshiftedmap +D=A +@R14 +M=D +@RET_ADDRESS_CALL135 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL135) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.initmap) +@127 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL136 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL136) +@SP +AM=M-1 +D=M +@output.5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL137 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL137) +@SP +AM=M-1 +D=M +@R5 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL138 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL138) +@SP +AM=M-1 +D=M +@R5 +M=D +@33 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL139 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL139) +@SP +AM=M-1 +D=M +@R5 +M=D +@34 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@20 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL140 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL140) +@SP +AM=M-1 +D=M +@R5 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL141 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL141) +@SP +AM=M-1 +D=M +@R5 +M=D +@36 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL142 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL142) +@SP +AM=M-1 +D=M +@R5 +M=D +@37 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@49 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL143 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL143) +@SP +AM=M-1 +D=M +@R5 +M=D +@38 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL144 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL144) +@SP +AM=M-1 +D=M +@R5 +M=D +@39 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL145 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL145) +@SP +AM=M-1 +D=M +@R5 +M=D +@40 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL146 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL146) +@SP +AM=M-1 +D=M +@R5 +M=D +@41 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL147 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL147) +@SP +AM=M-1 +D=M +@R5 +M=D +@42 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL148 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL148) +@SP +AM=M-1 +D=M +@R5 +M=D +@43 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL149 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL149) +@SP +AM=M-1 +D=M +@R5 +M=D +@44 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL150 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL150) +@SP +AM=M-1 +D=M +@R5 +M=D +@45 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL151 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL151) +@SP +AM=M-1 +D=M +@R5 +M=D +@46 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL152 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL152) +@SP +AM=M-1 +D=M +@R5 +M=D +@47 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL153 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL153) +@SP +AM=M-1 +D=M +@R5 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL154 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL154) +@SP +AM=M-1 +D=M +@R5 +M=D +@49 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@14 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL155 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL155) +@SP +AM=M-1 +D=M +@R5 +M=D +@50 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL156 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL156) +@SP +AM=M-1 +D=M +@R5 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL157 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL157) +@SP +AM=M-1 +D=M +@R5 +M=D +@52 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@26 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@25 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@60 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL158 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL158) +@SP +AM=M-1 +D=M +@R5 +M=D +@53 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL159 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL159) +@SP +AM=M-1 +D=M +@R5 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL160 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL160) +@SP +AM=M-1 +D=M +@R5 +M=D +@55 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@49 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL161 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL161) +@SP +AM=M-1 +D=M +@R5 +M=D +@56 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL162 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL162) +@SP +AM=M-1 +D=M +@R5 +M=D +@57 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@62 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@14 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL163 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL163) +@SP +AM=M-1 +D=M +@R5 +M=D +@58 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL164 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL164) +@SP +AM=M-1 +D=M +@R5 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL165 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL165) +@SP +AM=M-1 +D=M +@R5 +M=D +@60 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL166 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL166) +@SP +AM=M-1 +D=M +@R5 +M=D +@61 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL167 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL167) +@SP +AM=M-1 +D=M +@R5 +M=D +@62 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL168 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL168) +@SP +AM=M-1 +D=M +@R5 +M=D +@64 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL169 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL169) +@SP +AM=M-1 +D=M +@R5 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL170 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL170) +@SP +AM=M-1 +D=M +@R5 +M=D +@65 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL171 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL171) +@SP +AM=M-1 +D=M +@R5 +M=D +@66 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL172 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL172) +@SP +AM=M-1 +D=M +@R5 +M=D +@67 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL173 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL173) +@SP +AM=M-1 +D=M +@R5 +M=D +@68 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL174 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL174) +@SP +AM=M-1 +D=M +@R5 +M=D +@69 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL175 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL175) +@SP +AM=M-1 +D=M +@R5 +M=D +@70 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL176 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL176) +@SP +AM=M-1 +D=M +@R5 +M=D +@71 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@44 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL177 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL177) +@SP +AM=M-1 +D=M +@R5 +M=D +@72 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL178 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL178) +@SP +AM=M-1 +D=M +@R5 +M=D +@73 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL179 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL179) +@SP +AM=M-1 +D=M +@R5 +M=D +@74 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@60 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@14 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL180 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL180) +@SP +AM=M-1 +D=M +@R5 +M=D +@75 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL181 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL181) +@SP +AM=M-1 +D=M +@R5 +M=D +@76 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL182 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL182) +@SP +AM=M-1 +D=M +@R5 +M=D +@77 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@33 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL183 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL183) +@SP +AM=M-1 +D=M +@R5 +M=D +@78 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@55 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@55 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL184 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL184) +@SP +AM=M-1 +D=M +@R5 +M=D +@79 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL185 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL185) +@SP +AM=M-1 +D=M +@R5 +M=D +@80 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL186 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL186) +@SP +AM=M-1 +D=M +@R5 +M=D +@81 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@59 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL187 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL187) +@SP +AM=M-1 +D=M +@R5 +M=D +@82 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL188 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL188) +@SP +AM=M-1 +D=M +@R5 +M=D +@83 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL189 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL189) +@SP +AM=M-1 +D=M +@R5 +M=D +@84 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@45 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL190 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL190) +@SP +AM=M-1 +D=M +@R5 +M=D +@85 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL191 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL191) +@SP +AM=M-1 +D=M +@R5 +M=D +@86 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL192 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL192) +@SP +AM=M-1 +D=M +@R5 +M=D +@87 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL193 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL193) +@SP +AM=M-1 +D=M +@R5 +M=D +@88 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL194 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL194) +@SP +AM=M-1 +D=M +@R5 +M=D +@89 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL195 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL195) +@SP +AM=M-1 +D=M +@R5 +M=D +@90 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@49 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@35 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL196 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL196) +@SP +AM=M-1 +D=M +@R5 +M=D +@91 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL197 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL197) +@SP +AM=M-1 +D=M +@R5 +M=D +@92 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=1 +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL198 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL198) +@SP +AM=M-1 +D=M +@R5 +M=D +@93 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL199 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL199) +@SP +AM=M-1 +D=M +@R5 +M=D +@94 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@8 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL200 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL200) +@SP +AM=M-1 +D=M +@R5 +M=D +@95 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL201 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL201) +@SP +AM=M-1 +D=M +@R5 +M=D +@96 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL202 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL202) +@SP +AM=M-1 +D=M +@R5 +M=D +@97 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@14 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL203 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL203) +@SP +AM=M-1 +D=M +@R5 +M=D +@98 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL204 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL204) +@SP +AM=M-1 +D=M +@R5 +M=D +@99 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL205 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL205) +@SP +AM=M-1 +D=M +@R5 +M=D +@100 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@60 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL206 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL206) +@SP +AM=M-1 +D=M +@R5 +M=D +@101 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL207 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL207) +@SP +AM=M-1 +D=M +@R5 +M=D +@102 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@38 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL208 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL208) +@SP +AM=M-1 +D=M +@R5 +M=D +@103 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@62 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL209 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL209) +@SP +AM=M-1 +D=M +@R5 +M=D +@104 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@55 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL210 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL210) +@SP +AM=M-1 +D=M +@R5 +M=D +@105 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@14 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL211 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL211) +@SP +AM=M-1 +D=M +@R5 +M=D +@106 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@56 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL212 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL212) +@SP +AM=M-1 +D=M +@R5 +M=D +@107 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL213 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL213) +@SP +AM=M-1 +D=M +@R5 +M=D +@108 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@14 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL214 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL214) +@SP +AM=M-1 +D=M +@R5 +M=D +@109 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@29 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@43 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@43 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@43 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@43 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL215 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL215) +@SP +AM=M-1 +D=M +@R5 +M=D +@110 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@29 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL216 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL216) +@SP +AM=M-1 +D=M +@R5 +M=D +@111 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL217 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL217) +@SP +AM=M-1 +D=M +@R5 +M=D +@112 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL218 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL218) +@SP +AM=M-1 +D=M +@R5 +M=D +@113 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@62 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL219 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL219) +@SP +AM=M-1 +D=M +@R5 +M=D +@114 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@29 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@55 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL220 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL220) +@SP +AM=M-1 +D=M +@R5 +M=D +@115 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL221 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL221) +@SP +AM=M-1 +D=M +@R5 +M=D +@116 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@28 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL222 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL222) +@SP +AM=M-1 +D=M +@R5 +M=D +@117 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL223 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL223) +@SP +AM=M-1 +D=M +@R5 +M=D +@118 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL224 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL224) +@SP +AM=M-1 +D=M +@R5 +M=D +@119 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL225 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL225) +@SP +AM=M-1 +D=M +@R5 +M=D +@120 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@30 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL226 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL226) +@SP +AM=M-1 +D=M +@R5 +M=D +@121 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@62 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@24 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL227 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL227) +@SP +AM=M-1 +D=M +@R5 +M=D +@122 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@27 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@51 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL228 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL228) +@SP +AM=M-1 +D=M +@R5 +M=D +@123 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@56 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@56 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL229 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL229) +@SP +AM=M-1 +D=M +@R5 +M=D +@124 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL230 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL230) +@SP +AM=M-1 +D=M +@R5 +M=D +@125 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@56 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL231 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL231) +@SP +AM=M-1 +D=M +@R5 +M=D +@126 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@38 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@45 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@25 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@SP +M=M+1 +A=M-1 +M=0 +@12 +D=A +@R13 +M=D +@output.create +D=A +@R14 +M=D +@RET_ADDRESS_CALL232 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL232) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.create) +@SP +AM=M+1 +A=A-1 +M=0 +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL233 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL233) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=1 +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@4 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@8 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@9 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@9 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@10 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +D=M +@11 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.createshiftedmap) +@4 +D=A +(LOOP_output.createshiftedmap) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_output.createshiftedmap +D;JGT +@127 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL234 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL234) +@SP +AM=M-1 +D=M +@output.6 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +(output.createshiftedmap$while_exp0) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@127 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT27 +D=A +@38 +0;JMP +(RET_ADDRESS_LT27) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.createshiftedmap$while_end0 +D;JNE +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL235 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL235) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.6 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +(output.createshiftedmap$while_exp1) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT28 +D=A +@38 +0;JMP +(RET_ADDRESS_LT28) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.createshiftedmap$while_end1 +D;JNE +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@256 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL236 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL236) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@output.createshiftedmap$while_exp1 +0;JMP +(output.createshiftedmap$while_end1) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ21 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ21) +@SP +AM=M-1 +D=M +@output.createshiftedmap$if_true0 +D;JNE +@output.createshiftedmap$if_false0 +0;JMP +(output.createshiftedmap$if_true0) +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@output.createshiftedmap$if_end0 +0;JMP +(output.createshiftedmap$if_false0) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +(output.createshiftedmap$if_end0) +@output.createshiftedmap$while_exp0 +0;JMP +(output.createshiftedmap$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.getmap) +@SP +AM=M+1 +A=A-1 +M=0 +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT29 +D=A +@38 +0;JMP +(RET_ADDRESS_LT29) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@126 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT22 +D=A +@22 +0;JMP +(RET_ADDRESS_GT22) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@output.getmap$if_true0 +D;JNE +@output.getmap$if_false0 +0;JMP +(output.getmap$if_true0) +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +(output.getmap$if_false0) +@output.2 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.getmap$if_true1 +D;JNE +@output.getmap$if_false1 +0;JMP +(output.getmap$if_true1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@output.getmap$if_end1 +0;JMP +(output.getmap$if_false1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.6 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(output.getmap$if_end1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(output.drawchar) +@4 +D=A +(LOOP_output.drawchar) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_output.drawchar +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.getmap +D=A +@R14 +M=D +@RET_ADDRESS_CALL237 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL237) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@output.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(output.drawchar$while_exp0) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@11 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT30 +D=A +@38 +0;JMP +(RET_ADDRESS_LT30) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.drawchar$while_end0 +D;JNE +@output.2 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.drawchar$if_true0 +D;JNE +@output.drawchar$if_false0 +0;JMP +(output.drawchar$if_true0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.4 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@256 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@output.drawchar$if_end0 +0;JMP +(output.drawchar$if_false0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.4 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@255 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +(output.drawchar$if_end0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.4 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@output.drawchar$while_exp0 +0;JMP +(output.drawchar$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.movecursor) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT31 +D=A +@38 +0;JMP +(RET_ADDRESS_LT31) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@22 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT23 +D=A +@22 +0;JMP +(RET_ADDRESS_GT23) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT32 +D=A +@38 +0;JMP +(RET_ADDRESS_LT32) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@63 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT24 +D=A +@22 +0;JMP +(RET_ADDRESS_GT24) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@output.movecursor$if_true0 +D;JNE +@output.movecursor$if_false0 +0;JMP +(output.movecursor$if_true0) +@20 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL238 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL238) +@SP +AM=M-1 +D=M +@R5 +M=D +(output.movecursor$if_false0) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL239 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL239) +@SP +AM=M-1 +D=M +@output.0 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@352 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL240 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL240) +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@output.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@output.1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@output.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL241 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL241) +@RET_ADDRESS_EQ22 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ22) +@SP +AM=M-1 +D=M +@output.2 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.drawchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL242 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL242) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.printchar) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@0 +D=A +@R13 +M=D +@string.newline +D=A +@R14 +M=D +@RET_ADDRESS_CALL243 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL243) +@RET_ADDRESS_EQ23 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ23) +@SP +AM=M-1 +D=M +@output.printchar$if_true0 +D;JNE +@output.printchar$if_false0 +0;JMP +(output.printchar$if_true0) +@0 +D=A +@R13 +M=D +@output.println +D=A +@R14 +M=D +@RET_ADDRESS_CALL244 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL244) +@SP +AM=M-1 +D=M +@R5 +M=D +@output.printchar$if_end0 +0;JMP +(output.printchar$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@0 +D=A +@R13 +M=D +@string.backspace +D=A +@R14 +M=D +@RET_ADDRESS_CALL245 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL245) +@RET_ADDRESS_EQ24 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ24) +@SP +AM=M-1 +D=M +@output.printchar$if_true1 +D;JNE +@output.printchar$if_false1 +0;JMP +(output.printchar$if_true1) +@0 +D=A +@R13 +M=D +@output.backspace +D=A +@R14 +M=D +@RET_ADDRESS_CALL246 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL246) +@SP +AM=M-1 +D=M +@R5 +M=D +@output.printchar$if_end1 +0;JMP +(output.printchar$if_false1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.drawchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL247 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL247) +@SP +AM=M-1 +D=M +@R5 +M=D +@output.2 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.printchar$if_true2 +D;JNE +@output.printchar$if_false2 +0;JMP +(output.printchar$if_true2) +@output.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@output.0 +M=D +@output.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@output.1 +M=D +(output.printchar$if_false2) +@output.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ25 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ25) +@SP +AM=M-1 +D=M +@output.printchar$if_true3 +D;JNE +@output.printchar$if_false3 +0;JMP +(output.printchar$if_true3) +@0 +D=A +@R13 +M=D +@output.println +D=A +@R14 +M=D +@RET_ADDRESS_CALL248 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL248) +@SP +AM=M-1 +D=M +@R5 +M=D +@output.printchar$if_end3 +0;JMP +(output.printchar$if_false3) +@output.2 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.2 +M=D +(output.printchar$if_end3) +(output.printchar$if_end1) +(output.printchar$if_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.printstring) +@SP +A=M +M=0 +AD=A+1 +M=0 +@SP +M=D+1 +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.length +D=A +@R14 +M=D +@RET_ADDRESS_CALL249 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL249) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +(output.printstring$while_exp0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT33 +D=A +@38 +0;JMP +(RET_ADDRESS_LT33) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.printstring$while_end0 +D;JNE +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.charat +D=A +@R14 +M=D +@RET_ADDRESS_CALL250 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL250) +@1 +D=A +@R13 +M=D +@output.printchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL251 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL251) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@output.printstring$while_exp0 +0;JMP +(output.printstring$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.printint) +@output.3 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.setint +D=A +@R14 +M=D +@RET_ADDRESS_CALL252 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL252) +@SP +AM=M-1 +D=M +@R5 +M=D +@output.3 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.printstring +D=A +@R14 +M=D +@RET_ADDRESS_CALL253 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL253) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.println) +@output.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@352 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@output.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@output.1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@output.0 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.2 +M=D +@output.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@8128 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ26 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ26) +@SP +AM=M-1 +D=M +@output.println$if_true0 +D;JNE +@output.println$if_false0 +0;JMP +(output.println$if_true0) +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.1 +M=D +(output.println$if_false0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(output.backspace) +@output.2 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.backspace$if_true0 +D;JNE +@output.backspace$if_false0 +0;JMP +(output.backspace$if_true0) +@output.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT25 +D=A +@22 +0;JMP +(RET_ADDRESS_GT25) +@SP +AM=M-1 +D=M +@output.backspace$if_true1 +D;JNE +@output.backspace$if_false1 +0;JMP +(output.backspace$if_true1) +@output.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@output.0 +M=D +@output.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@output.1 +M=D +@output.backspace$if_end1 +0;JMP +(output.backspace$if_false1) +@31 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.0 +M=D +@output.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ27 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ27) +@SP +AM=M-1 +D=M +@output.backspace$if_true2 +D;JNE +@output.backspace$if_false2 +0;JMP +(output.backspace$if_true2) +@8128 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@output.1 +M=D +(output.backspace$if_false2) +@output.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@321 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@output.1 +M=D +(output.backspace$if_end1) +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@output.2 +M=D +@output.backspace$if_end0 +0;JMP +(output.backspace$if_false0) +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@output.2 +M=D +(output.backspace$if_end0) +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.drawchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL254 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL254) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.init) +@SP +AM=M+1 +A=A-1 +M=0 +@16384 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@screen.1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.2 +M=D +@17 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL255 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL255) +@SP +AM=M-1 +D=M +@screen.0 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +(screen.init$while_exp0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT34 +D=A +@38 +0;JMP +(RET_ADDRESS_LT34) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.init$while_end0 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@screen.init$while_exp0 +0;JMP +(screen.init$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.clearscreen) +@SP +AM=M+1 +A=A-1 +M=0 +(screen.clearscreen$while_exp0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@8192 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT35 +D=A +@38 +0;JMP +(RET_ADDRESS_LT35) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.clearscreen$while_end0 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@screen.clearscreen$while_exp0 +0;JMP +(screen.clearscreen$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.updatelocation) +@screen.2 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@screen.updatelocation$if_true0 +D;JNE +@screen.updatelocation$if_false0 +0;JMP +(screen.updatelocation$if_true0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@screen.updatelocation$if_end0 +0;JMP +(screen.updatelocation$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +(screen.updatelocation$if_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.setcolor) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@screen.2 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.drawpixel) +@3 +D=A +(LOOP_screen.drawpixel) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_screen.drawpixel +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT36 +D=A +@38 +0;JMP +(RET_ADDRESS_LT36) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT26 +D=A +@22 +0;JMP +(RET_ADDRESS_GT26) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT37 +D=A +@38 +0;JMP +(RET_ADDRESS_LT37) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@255 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT27 +D=A +@22 +0;JMP +(RET_ADDRESS_GT27) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@screen.drawpixel$if_true0 +D;JNE +@screen.drawpixel$if_false0 +0;JMP +(screen.drawpixel$if_true0) +@7 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL256 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL256) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawpixel$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL257 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL257) +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL258 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL258) +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL259 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL259) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL260 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL260) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.drawconditional) +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@screen.drawconditional$if_true0 +D;JNE +@screen.drawconditional$if_false0 +0;JMP +(screen.drawconditional$if_true0) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@screen.drawpixel +D=A +@R14 +M=D +@RET_ADDRESS_CALL261 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL261) +@SP +AM=M-1 +D=M +@R5 +M=D +@screen.drawconditional$if_end0 +0;JMP +(screen.drawconditional$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@screen.drawpixel +D=A +@R14 +M=D +@RET_ADDRESS_CALL262 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL262) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawconditional$if_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.drawline) +@11 +D=A +(LOOP_screen.drawline) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_screen.drawline +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT38 +D=A +@38 +0;JMP +(RET_ADDRESS_LT38) +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT28 +D=A +@22 +0;JMP +(RET_ADDRESS_GT28) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT39 +D=A +@38 +0;JMP +(RET_ADDRESS_LT39) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@255 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT29 +D=A +@22 +0;JMP +(RET_ADDRESS_GT29) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@screen.drawline$if_true0 +D;JNE +@screen.drawline$if_false0 +0;JMP +(screen.drawline$if_true0) +@8 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL263 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL263) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawline$if_false0) +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL264 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL264) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=A +@R13 +M=D +@math.abs +D=A +@R14 +M=D +@RET_ADDRESS_CALL265 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL265) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT40 +D=A +@38 +0;JMP +(RET_ADDRESS_LT40) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT41 +D=A +@38 +0;JMP +(RET_ADDRESS_LT41) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +M=!M +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT42 +D=A +@38 +0;JMP +(RET_ADDRESS_LT42) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@screen.drawline$if_true1 +D;JNE +@screen.drawline$if_false1 +0;JMP +(screen.drawline$if_true1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M+1 +A=A+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M+1 +A=A+1 +A=A+1 +M=D +(screen.drawline$if_false1) +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@screen.drawline$if_true2 +D;JNE +@screen.drawline$if_false2 +0;JMP +(screen.drawline$if_true2) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@8 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT30 +D=A +@22 +0;JMP +(RET_ADDRESS_GT30) +@LCL +D=M +@7 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@screen.drawline$if_end2 +0;JMP +(screen.drawline$if_false2) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@8 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT31 +D=A +@22 +0;JMP +(RET_ADDRESS_GT31) +@LCL +D=M +@7 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +(screen.drawline$if_end2) +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL266 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL266) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL267 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL267) +@LCL +D=M +@9 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL268 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL268) +@LCL +D=M +@10 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@R13 +M=D +@screen.drawconditional +D=A +@R14 +M=D +@RET_ADDRESS_CALL269 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL269) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawline$while_exp0) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT43 +D=A +@38 +0;JMP +(RET_ADDRESS_LT43) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.drawline$while_end0 +D;JNE +@LCL +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT44 +D=A +@38 +0;JMP +(RET_ADDRESS_LT44) +@SP +AM=M-1 +D=M +@screen.drawline$if_true3 +D;JNE +@screen.drawline$if_false3 +0;JMP +(screen.drawline$if_true3) +@LCL +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@9 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@screen.drawline$if_end3 +0;JMP +(screen.drawline$if_false3) +@LCL +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@10 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@screen.drawline$if_true4 +D;JNE +@screen.drawline$if_false4 +0;JMP +(screen.drawline$if_true4) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@screen.drawline$if_end4 +0;JMP +(screen.drawline$if_false4) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(screen.drawline$if_end4) +(screen.drawline$if_end3) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@3 +D=A +@R13 +M=D +@screen.drawconditional +D=A +@R14 +M=D +@RET_ADDRESS_CALL270 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL270) +@SP +AM=M-1 +D=M +@R5 +M=D +@screen.drawline$while_exp0 +0;JMP +(screen.drawline$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.drawrectangle) +@9 +D=A +(LOOP_screen.drawrectangle) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_screen.drawrectangle +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT32 +D=A +@22 +0;JMP +(RET_ADDRESS_GT32) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT33 +D=A +@22 +0;JMP +(RET_ADDRESS_GT33) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT45 +D=A +@38 +0;JMP +(RET_ADDRESS_LT45) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT34 +D=A +@22 +0;JMP +(RET_ADDRESS_GT34) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT46 +D=A +@38 +0;JMP +(RET_ADDRESS_LT46) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@255 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT35 +D=A +@22 +0;JMP +(RET_ADDRESS_GT35) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@screen.drawrectangle$if_true0 +D;JNE +@screen.drawrectangle$if_false0 +0;JMP +(screen.drawrectangle$if_true0) +@9 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL271 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL271) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawrectangle$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL272 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL272) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL273 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL273) +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@LCL +D=M +@7 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL274 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL274) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL275 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL275) +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@LCL +D=M +@8 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@LCL +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL276 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL276) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +(screen.drawrectangle$while_exp0) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT36 +D=A +@22 +0;JMP +(RET_ADDRESS_GT36) +@SP +A=M-1 +M=!M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.drawrectangle$while_end0 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ28 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ28) +@SP +AM=M-1 +D=M +@screen.drawrectangle$if_true1 +D;JNE +@screen.drawrectangle$if_false1 +0;JMP +(screen.drawrectangle$if_true1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL277 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL277) +@SP +AM=M-1 +D=M +@R5 +M=D +@screen.drawrectangle$if_end1 +0;JMP +(screen.drawrectangle$if_false1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL278 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL278) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(screen.drawrectangle$while_exp1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT47 +D=A +@38 +0;JMP +(RET_ADDRESS_LT47) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.drawrectangle$while_end1 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL279 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL279) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@screen.drawrectangle$while_exp1 +0;JMP +(screen.drawrectangle$while_end1) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL280 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL280) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawrectangle$if_end1) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@screen.drawrectangle$while_exp0 +0;JMP +(screen.drawrectangle$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.drawhorizontal) +@11 +D=A +(LOOP_screen.drawhorizontal) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_screen.drawhorizontal +D;JGT +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.min +D=A +@R14 +M=D +@RET_ADDRESS_CALL281 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL281) +@LCL +D=M +@7 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.max +D=A +@R14 +M=D +@RET_ADDRESS_CALL282 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL282) +@LCL +D=M +@8 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@RET_ADDRESS_GT37 +D=A +@22 +0;JMP +(RET_ADDRESS_GT37) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@256 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT48 +D=A +@38 +0;JMP +(RET_ADDRESS_LT48) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@LCL +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@512 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT49 +D=A +@38 +0;JMP +(RET_ADDRESS_LT49) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@LCL +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@RET_ADDRESS_GT38 +D=A +@22 +0;JMP +(RET_ADDRESS_GT38) +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +AM=M-1 +D=M +@screen.drawhorizontal$if_true0 +D;JNE +@screen.drawhorizontal$if_false0 +0;JMP +(screen.drawhorizontal$if_true0) +@LCL +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@2 +D=A +@R13 +M=D +@math.max +D=A +@R14 +M=D +@RET_ADDRESS_CALL283 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL283) +@LCL +D=M +@7 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@LCL +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.min +D=A +@R14 +M=D +@RET_ADDRESS_CALL284 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL284) +@LCL +D=M +@8 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@LCL +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL285 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL285) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +D=M +@7 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL286 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL286) +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@LCL +D=M +@9 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@LCL +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL287 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL287) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@LCL +D=M +@8 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL288 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL288) +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@LCL +D=M +@10 +D=D+A +@R13 +M=D +@SP +AM=M-1 +D=M +@R13 +A=M +M=D +@LCL +D=M +@9 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@10 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@screen.0 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@32 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL289 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL289) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@6 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ29 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ29) +@SP +AM=M-1 +D=M +@screen.drawhorizontal$if_true1 +D;JNE +@screen.drawhorizontal$if_false1 +0;JMP +(screen.drawhorizontal$if_true1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL290 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL290) +@SP +AM=M-1 +D=M +@R5 +M=D +@screen.drawhorizontal$if_end1 +0;JMP +(screen.drawhorizontal$if_false1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@5 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL291 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL291) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(screen.drawhorizontal$while_exp0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT50 +D=A +@38 +0;JMP +(RET_ADDRESS_LT50) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.drawhorizontal$while_end0 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +A=M-1 +D=!M +M=D+1 +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL292 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL292) +@SP +AM=M-1 +D=M +@R5 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@screen.drawhorizontal$while_exp0 +0;JMP +(screen.drawhorizontal$while_end0) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@screen.updatelocation +D=A +@R14 +M=D +@RET_ADDRESS_CALL293 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL293) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawhorizontal$if_end1) +(screen.drawhorizontal$if_false0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.drawsymetric) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +D=A +@R13 +M=D +@screen.drawhorizontal +D=A +@R14 +M=D +@RET_ADDRESS_CALL294 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL294) +@SP +AM=M-1 +D=M +@R5 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +D=A +@R13 +M=D +@screen.drawhorizontal +D=A +@R14 +M=D +@RET_ADDRESS_CALL295 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL295) +@SP +AM=M-1 +D=M +@R5 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@R13 +M=D +@screen.drawhorizontal +D=A +@R14 +M=D +@RET_ADDRESS_CALL296 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL296) +@SP +AM=M-1 +D=M +@R5 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@R13 +M=D +@screen.drawhorizontal +D=A +@R14 +M=D +@RET_ADDRESS_CALL297 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL297) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(screen.drawcircle) +@3 +D=A +(LOOP_screen.drawcircle) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_screen.drawcircle +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT51 +D=A +@38 +0;JMP +(RET_ADDRESS_LT51) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT39 +D=A +@22 +0;JMP +(RET_ADDRESS_GT39) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT52 +D=A +@38 +0;JMP +(RET_ADDRESS_LT52) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@255 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT40 +D=A +@22 +0;JMP +(RET_ADDRESS_GT40) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@screen.drawcircle$if_true0 +D;JNE +@screen.drawcircle$if_false0 +0;JMP +(screen.drawcircle$if_true0) +@12 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL298 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL298) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawcircle$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT53 +D=A +@38 +0;JMP +(RET_ADDRESS_LT53) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@511 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT41 +D=A +@22 +0;JMP +(RET_ADDRESS_GT41) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT54 +D=A +@38 +0;JMP +(RET_ADDRESS_LT54) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@255 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT42 +D=A +@22 +0;JMP +(RET_ADDRESS_GT42) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@screen.drawcircle$if_true1 +D;JNE +@screen.drawcircle$if_false1 +0;JMP +(screen.drawcircle$if_true1) +@13 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL299 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL299) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawcircle$if_false1) +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@R13 +M=D +@screen.drawsymetric +D=A +@R14 +M=D +@RET_ADDRESS_CALL300 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL300) +@SP +AM=M-1 +D=M +@R5 +M=D +(screen.drawcircle$while_exp0) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT43 +D=A +@22 +0;JMP +(RET_ADDRESS_GT43) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@screen.drawcircle$while_end0 +D;JNE +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT55 +D=A +@38 +0;JMP +(RET_ADDRESS_LT55) +@SP +AM=M-1 +D=M +@screen.drawcircle$if_true2 +D;JNE +@screen.drawcircle$if_false2 +0;JMP +(screen.drawcircle$if_true2) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL301 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL301) +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@screen.drawcircle$if_end2 +0;JMP +(screen.drawcircle$if_false2) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL302 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL302) +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@5 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +(screen.drawcircle$if_end2) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@4 +D=A +@R13 +M=D +@screen.drawsymetric +D=A +@R14 +M=D +@RET_ADDRESS_CALL303 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL303) +@SP +AM=M-1 +D=M +@R5 +M=D +@screen.drawcircle$while_exp0 +0;JMP +(screen.drawcircle$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(string.new) +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.alloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL304 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL304) +@SP +AM=M-1 +D=M +@THIS +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT56 +D=A +@38 +0;JMP +(RET_ADDRESS_LT56) +@SP +AM=M-1 +D=M +@string.new$if_true0 +D;JNE +@string.new$if_false0 +0;JMP +(string.new$if_true0) +@14 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL305 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL305) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.new$if_false0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT44 +D=A +@22 +0;JMP +(RET_ADDRESS_GT44) +@SP +AM=M-1 +D=M +@string.new$if_true1 +D;JNE +@string.new$if_false1 +0;JMP +(string.new$if_true1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL306 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL306) +@SP +AM=M-1 +D=M +@THIS +A=M+1 +M=D +(string.new$if_false1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(string.dispose) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT45 +D=A +@22 +0;JMP +(RET_ADDRESS_GT45) +@SP +AM=M-1 +D=M +@string.dispose$if_true0 +D;JNE +@string.dispose$if_false0 +0;JMP +(string.dispose$if_true0) +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.dispose +D=A +@R14 +M=D +@RET_ADDRESS_CALL307 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL307) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.dispose$if_false0) +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@memory.dealloc +D=A +@R14 +M=D +@RET_ADDRESS_CALL308 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL308) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(string.length) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(string.charat) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT57 +D=A +@38 +0;JMP +(RET_ADDRESS_LT57) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT46 +D=A +@22 +0;JMP +(RET_ADDRESS_GT46) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ30 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ30) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@string.charat$if_true0 +D;JNE +@string.charat$if_false0 +0;JMP +(string.charat$if_true0) +@15 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL309 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL309) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.charat$if_false0) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(string.setcharat) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT58 +D=A +@38 +0;JMP +(RET_ADDRESS_LT58) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT47 +D=A +@22 +0;JMP +(RET_ADDRESS_GT47) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ31 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ31) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +AM=M-1 +D=M +@string.setcharat$if_true0 +D;JNE +@string.setcharat$if_false0 +0;JMP +(string.setcharat$if_true0) +@16 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL310 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL310) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.setcharat$if_false0) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(string.appendchar) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ32 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ32) +@SP +AM=M-1 +D=M +@string.appendchar$if_true0 +D;JNE +@string.appendchar$if_false0 +0;JMP +(string.appendchar$if_true0) +@17 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL311 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL311) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.appendchar$if_false0) +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@THIS +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(string.eraselastchar) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ33 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ33) +@SP +AM=M-1 +D=M +@string.eraselastchar$if_true0 +D;JNE +@string.eraselastchar$if_false0 +0;JMP +(string.eraselastchar$if_true0) +@18 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL312 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL312) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.eraselastchar$if_false0) +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(string.intvalue) +@5 +D=A +(LOOP_string.intvalue) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_string.intvalue +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ34 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ34) +@SP +AM=M-1 +D=M +@string.intvalue$if_true0 +D;JNE +@string.intvalue$if_false0 +0;JMP +(string.intvalue$if_true0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(string.intvalue$if_false0) +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@45 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_EQ35 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ35) +@SP +AM=M-1 +D=M +@string.intvalue$if_true1 +D;JNE +@string.intvalue$if_false1 +0;JMP +(string.intvalue$if_true1) +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(string.intvalue$if_false1) +(string.intvalue$while_exp0) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT59 +D=A +@38 +0;JMP +(RET_ADDRESS_LT59) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D&M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@string.intvalue$while_end0 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT60 +D=A +@38 +0;JMP +(RET_ADDRESS_LT60) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@9 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_GT48 +D=A +@22 +0;JMP +(RET_ADDRESS_GT48) +@SP +AM=M-1 +D=M +A=A-1 +M=D|M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@string.intvalue$if_true2 +D;JNE +@string.intvalue$if_false2 +0;JMP +(string.intvalue$if_true2) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL313 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL313) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(string.intvalue$if_false2) +@string.intvalue$while_exp0 +0;JMP +(string.intvalue$while_end0) +@LCL +D=M +@4 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@string.intvalue$if_true3 +D;JNE +@string.intvalue$if_false3 +0;JMP +(string.intvalue$if_true3) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +(string.intvalue$if_false3) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(string.setint) +@4 +D=A +(LOOP_string.setint) +D=D-1 +@SP +AM=M+1 +A=A-1 +M=0 +@LOOP_string.setint +D;JGT +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THIS +M=D +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ36 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ36) +@SP +AM=M-1 +D=M +@string.setint$if_true0 +D;JNE +@string.setint$if_false0 +0;JMP +(string.setint$if_true0) +@19 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL314 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL314) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.setint$if_false0) +@6 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL315 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL315) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT61 +D=A +@38 +0;JMP +(RET_ADDRESS_LT61) +@SP +AM=M-1 +D=M +@string.setint$if_true1 +D;JNE +@string.setint$if_false1 +0;JMP +(string.setint$if_true1) +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@LCL +A=M+1 +A=A+1 +A=A+1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +A=M-1 +D=!M +M=D+1 +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +(string.setint$if_false1) +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +(string.setint$while_exp0) +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT49 +D=A +@22 +0;JMP +(RET_ADDRESS_GT49) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@string.setint$while_end0 +D;JNE +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.divide +D=A +@R14 +M=D +@RET_ADDRESS_CALL316 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL316) +@SP +AM=M-1 +D=M +@LCL +A=M+1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@ARG +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@10 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@math.multiply +D=A +@R14 +M=D +@RET_ADDRESS_CALL317 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL317) +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@LCL +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@ARG +A=M+1 +M=D +@string.setint$while_exp0 +0;JMP +(string.setint$while_end0) +@LCL +D=M +@3 +A=D+A +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@string.setint$if_true2 +D;JNE +@string.setint$if_false2 +0;JMP +(string.setint$if_true2) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@45 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(string.setint$if_false2) +@THIS +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT62 +D=A +@38 +0;JMP +(RET_ADDRESS_LT62) +@SP +AM=M-1 +D=M +@string.setint$if_true3 +D;JNE +@string.setint$if_false3 +0;JMP +(string.setint$if_true3) +@19 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL318 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL318) +@SP +AM=M-1 +D=M +@R5 +M=D +(string.setint$if_false3) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_EQ37 +D=A +@6 +0;JMP +(RET_ADDRESS_EQ37) +@SP +AM=M-1 +D=M +@string.setint$if_true4 +D;JNE +@string.setint$if_false4 +0;JMP +(string.setint$if_true4) +@SP +M=M+1 +A=M-1 +M=0 +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@48 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@string.setint$if_end4 +0;JMP +(string.setint$if_false4) +@SP +M=M+1 +A=M-1 +M=0 +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +(string.setint$while_exp1) +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@RET_ADDRESS_LT63 +D=A +@38 +0;JMP +(RET_ADDRESS_LT63) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@string.setint$while_end1 +D;JNE +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THAT +M=D +@THAT +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +AM=M-1 +D=M +@THAT +M=D +@R5 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@THAT +A=M +M=D +@THIS +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +@SP +AM=M-1 +D=M +@THIS +A=M+1 +A=A+1 +M=D +@string.setint$while_exp1 +0;JMP +(string.setint$while_end1) +(string.setint$if_end4) +@LCL +A=M+1 +A=A+1 +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@array.dispose +D=A +@R14 +M=D +@RET_ADDRESS_CALL319 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL319) +@SP +AM=M-1 +D=M +@R5 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(string.newline) +@128 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(string.backspace) +@129 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(string.doublequote) +@34 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +(sys.init) +@0 +D=A +@R13 +M=D +@memory.init +D=A +@R14 +M=D +@RET_ADDRESS_CALL320 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL320) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@math.init +D=A +@R14 +M=D +@RET_ADDRESS_CALL321 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL321) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@screen.init +D=A +@R14 +M=D +@RET_ADDRESS_CALL322 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL322) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@output.init +D=A +@R14 +M=D +@RET_ADDRESS_CALL323 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL323) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@keyboard.init +D=A +@R14 +M=D +@RET_ADDRESS_CALL324 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL324) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@main.main +D=A +@R14 +M=D +@RET_ADDRESS_CALL325 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL325) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@sys.halt +D=A +@R14 +M=D +@RET_ADDRESS_CALL326 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL326) +@SP +AM=M-1 +D=M +@R5 +M=D +(sys.halt) +(sys.halt$while_exp0) +@SP +M=M+1 +A=M-1 +M=0 +@SP +A=M-1 +M=!M +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@sys.halt$while_end0 +D;JNE +@sys.halt$while_exp0 +0;JMP +(sys.halt$while_end0) +(sys.wait) +@SP +AM=M+1 +A=A-1 +M=0 +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_LT64 +D=A +@38 +0;JMP +(RET_ADDRESS_LT64) +@SP +AM=M-1 +D=M +@sys.wait$if_true0 +D;JNE +@sys.wait$if_false0 +0;JMP +(sys.wait$if_true0) +@SP +M=M+1 +A=M-1 +M=1 +@1 +D=A +@R13 +M=D +@sys.error +D=A +@R14 +M=D +@RET_ADDRESS_CALL327 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL327) +@SP +AM=M-1 +D=M +@R5 +M=D +(sys.wait$if_false0) +(sys.wait$while_exp0) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT50 +D=A +@22 +0;JMP +(RET_ADDRESS_GT50) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@sys.wait$while_end0 +D;JNE +@50 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +(sys.wait$while_exp1) +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=0 +@RET_ADDRESS_GT51 +D=A +@22 +0;JMP +(RET_ADDRESS_GT51) +@SP +A=M-1 +M=!M +@SP +AM=M-1 +D=M +@sys.wait$while_end1 +D;JNE +@LCL +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@LCL +A=M +M=D +@sys.wait$while_exp1 +0;JMP +(sys.wait$while_end1) +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@SP +M=M+1 +A=M-1 +M=1 +@SP +AM=M-1 +D=M +A=A-1 +M=M-D +@SP +AM=M-1 +D=M +@ARG +A=M +M=D +@sys.wait$while_exp0 +0;JMP +(sys.wait$while_end0) +@SP +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +(sys.error) +@3 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@string.new +D=A +@R14 +M=D +@RET_ADDRESS_CALL328 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL328) +@69 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL329 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL329) +@82 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL330 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL330) +@82 +D=A +@SP +AM=M+1 +A=A-1 +M=D +@2 +D=A +@R13 +M=D +@string.appendchar +D=A +@R14 +M=D +@RET_ADDRESS_CALL331 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL331) +@1 +D=A +@R13 +M=D +@output.printstring +D=A +@R14 +M=D +@RET_ADDRESS_CALL332 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL332) +@SP +AM=M-1 +D=M +@R5 +M=D +@ARG +A=M +D=M +@SP +AM=M+1 +A=A-1 +M=D +@1 +D=A +@R13 +M=D +@output.printint +D=A +@R14 +M=D +@RET_ADDRESS_CALL333 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL333) +@SP +AM=M-1 +D=M +@R5 +M=D +@0 +D=A +@R13 +M=D +@sys.halt +D=A +@R14 +M=D +@RET_ADDRESS_CALL334 +D=A +@95 +0;JMP +(RET_ADDRESS_CALL334) +@SP +AM=M-1 +D=M +@R5 +M=D diff --git a/projects/06/pong/Pong.hack b/projects/06/pong/Pong.hack new file mode 100755 index 0000000..3a83e2b --- /dev/null +++ b/projects/06/pong/Pong.hack @@ -0,0 +1,27483 @@ +0000000100000000 +1110110000010000 +0000000000000000 +1110001100001000 +0000000010000101 +1110101010000111 +0000000000001111 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111010000 +1110101010001000 +0000000000010011 +1110001100000101 +0000000000000000 +1111110010100000 +1110111010001000 +0000000000001111 +1111110000100000 +1110101010000111 +0000000000001111 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111010000 +1110101010001000 +0000000000100011 +1110001100000110 +0000000000000000 +1111110010100000 +1110111010001000 +0000000000001111 +1111110000100000 +1110101010000111 +0000000000001111 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111010000 +1110101010001000 +0000000000110011 +1110001100000011 +0000000000000000 +1111110010100000 +1110111010001000 +0000000000001111 +1111110000100000 +1110101010000111 +0000000000000101 +1110110000010000 +0000000000000001 +1111000111100000 +1111110000010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +1110110000010000 +0000000000000000 +1110011111001000 +0000000000000001 +1111110000010000 +0000000000001110 +1110001110101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000001110 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000001110 +1111110010101000 +1111110000010000 +0000000000000010 +1110001100001000 +0000000000001110 +1111110010101000 +1111110000010000 +0000000000000001 +1110001100001000 +0000000000001101 +1111110000100000 +1110101010000111 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000000 +1111110111101000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000000 +1111110111101000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110001100001000 +0000000000000100 +1111110000010000 +0000000000000000 +1111110111101000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000001101 +1111000010010000 +0000000000000000 +1111000111010000 +0000000000000010 +1110001100001000 +0000000000000000 +1111110111011000 +0000000000000001 +1110001100001000 +0000000000001110 +1111110000100000 +1110101010000111 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110100110110010 +1110110000010000 +0000000000001110 +1110001100001000 +0000000010010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010000111000011 +1110110000010000 +0000000000001110 +1110001100001000 +0000000010100011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001010 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000011 +1111110000010000 +0000000000001011 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001100 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000011 +1111110000010000 +0000000000001101 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000000110000011 +1110110000010000 +0000000000001110 +1110001100001000 +0000000101001101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010010010001101 +1110110000010000 +0000000000001110 +1110001100001000 +0000000101111000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000000110100010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000001000000010 +1110110000010000 +0000000000001110 +1110001100001000 +0000000110111001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000000111100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000001000000010 +1110110000010000 +0000000000001110 +1110001100001000 +0000000111110111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101011101010010 +1110110000010000 +0000000000001110 +1110001100001000 +0000001001001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000110110 +1110101010000111 +0000000000000011 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000001010001110 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0000001011101011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0000001100000110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000001100011110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000111 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000001100111010 +1110001100000101 +0000001110100010 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000001101110110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000001000 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000001110010100 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000001001 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000001111011111 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000001110110100 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000001000 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000001111010011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000001001 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000001111111000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000010000100110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000010001010101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000000111000100 +1110110000010000 +0000000000001110 +1110001100001000 +0000010010000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000010010011010 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000010010100001 +1110001100000101 +0000010011000011 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000010101111001 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001001 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000010011110011 +1110001100000101 +0000010100110111 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000010100000011 +1110001100000101 +0000010100011101 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000010100110101 +1110101010000111 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000010101111001 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000010101000111 +1110001100000101 +0000010101100001 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000010101111001 +1110101010000111 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000010110001001 +1110001100000101 +0000010111001101 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000010110011001 +1110001100000101 +0000010110110011 +1110101010000111 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000010111001011 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000011000001111 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000010111011101 +1110001100000101 +0000010111110111 +1110101010000111 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000011000001111 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001010 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000011000100011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000011000101101 +1110001100000101 +0000011001001100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001010 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000011001100000 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000011001101010 +1110001100000101 +0000011010001011 +1110101010000111 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000011010011111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000011010101001 +1110001100000101 +0000011011001010 +1110101010000111 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000011011011110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000011011101000 +1110001100000101 +0000011100001001 +1110101010000111 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000000110000011 +1110110000010000 +0000000000001110 +1110001100001000 +0000011100011011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000101 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000011100101101 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0000011101011010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0000011101111100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000011110010011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000011110011010 +1110001100000101 +0000011110101011 +1110101010000111 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000100000100110 +1110101010000111 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000011110111011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000011111001101 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000011111100010 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000011111111010 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000100000000110 +1110001100000101 +0000100000010111 +1110101010000111 +0000000000010100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000100000100110 +1110101010000111 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000100000110111 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000100000111110 +1110001100000101 +0000100010110011 +1110101010000111 +0000000111111010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000100001101001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0000100001111101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000100010100110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000101000111000 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000100011000110 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000100011001101 +1110001100000101 +0000100100111100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000100011110010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0000100100000110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000100100101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000101000111000 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000001110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000100101001111 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000100101010110 +1110001100000101 +0000100111001011 +1110101010000111 +0000000011111010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000100110000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0000100110010101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000100110111110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000101000111000 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000100111101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0000101000000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0000101000101101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0000001010001100 +1110110000010000 +0000000000001110 +1110001100001000 +0000101001011000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010000111000011 +1110110000010000 +0000000000001110 +1110001100001000 +0000101001110101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000101100001011 +1110110000010000 +0000000000001110 +1110001100001000 +0000101011010101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010010010001101 +1110110000010000 +0000000000001110 +1110001100001000 +0000101100000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000101100101010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000101110001010 +1110110000010000 +0000000000001110 +1110001100001000 +0000101101000001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000101101101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000101110001010 +1110110000010000 +0000000000001110 +1110001100001000 +0000101101111111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101011101010010 +1110110000010000 +0000000000001110 +1110001100001000 +0000101111011001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000101101001100 +1110110000010000 +0000000000001110 +1110001100001000 +0000110001011011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000101100001011 +1110110000010000 +0000000000001110 +1110001100001000 +0000110010000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000110010101000 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000110010101111 +1110001100000101 +0000110111000101 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000110011010110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000110011011101 +1110001100000101 +0000110011100111 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000110011110111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101011101010010 +1110110000010000 +0000000000001110 +1110001100001000 +0000110101100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000110101111000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101011101010010 +1110110000010000 +0000000000001110 +1110001100001000 +0000110110111110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000111011110111 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000110111111011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000111000000010 +1110001100000101 +0000111000011011 +1110101010000111 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000111000101011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101011101010010 +1110110000010000 +0000000000001110 +1110001100001000 +0000111001111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110011001 +1110110000010000 +0000000000001110 +1110001100001000 +0000111010010010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101011101010010 +1110110000010000 +0000000000001110 +1110001100001000 +0000111011110010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001000110011100 +1110110000010000 +0000000000001110 +1110001100001000 +0000111100001101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001000110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0000111100011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001000110111011 +1110110000010000 +0000000000001110 +1110001100001000 +0000111100110111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001000101000011 +1110110000010000 +0000000000001110 +1110001100001000 +0000111101001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010000111000011 +1110110000010000 +0000000000001110 +1110001100001000 +0000111101101100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0101000001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0000111101111101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000011100110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011100101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0000101001100011 +1110110000010000 +0000000000001110 +1110001100001000 +0000111110111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000011111101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000011100101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000001101 +1110001100001000 +0000000010010001 +1110110000010000 +0000000000001110 +1110001100001000 +0000111111101100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000110010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0000001010001100 +1110110000010000 +0000000000001110 +1110001100001000 +0001000000001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000011101110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101011101010010 +1110110000010000 +0000000000001110 +1110001100001000 +0001000000110110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000010110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0100101110010110 +1110110000010000 +0000000000001110 +1110001100001000 +0001000001010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000001000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110001000010001 +1110110000010000 +0000000000001110 +1110001100001000 +0001000001101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001010011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000001111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000010001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001101111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000010011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000010110000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001100101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000011000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000111010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000011010100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000011100110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001000011111000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110110001010 +1110110000010000 +0000000000001110 +1110001100001000 +0001000100000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000101011100010 +1110110000010000 +0000000000001110 +1110001100001000 +0001000101100010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000000101011010 +1110110000010000 +0000000000001110 +1110001100001000 +0001000101111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010010010001101 +1110110000010000 +0000000000001110 +1110001100001000 +0001000110010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0000111101011010 +1110110000010000 +0000000000001110 +1110001100001000 +0001000110101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000010000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001001101001111 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001000111101110 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001001001001010 +1110001100000101 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001011100100100 +1110110000010000 +0000000000001110 +1110001100001000 +0001001000010011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000110010001011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001000101100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001010001000111 +1110110000010000 +0000000000001110 +1110001100001000 +0001001001000011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0001000111011111 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000010000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001001001011011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001001001100010 +1110001100000101 +0001001010000000 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0000101111100100 +1110110000010000 +0000000000001110 +1110001100001000 +0001001001111001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0001001011011111 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000010000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001001010010001 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001001010011000 +1110001100000101 +0001001010111000 +1110101010000111 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0000101111100100 +1110110000010000 +0000000000001110 +1110001100001000 +0001001010110001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0001001011011111 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000010001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001001011001001 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001001011010000 +1110001100000101 +0001001011011111 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001001011101110 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001001101001101 +1110001100000101 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001011100100100 +1110110000010000 +0000000000001110 +1110001100001000 +0001001100010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000110010001011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001100101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001010001000111 +1110110000010000 +0000000000001110 +1110001100001000 +0001001101000110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0001001011011111 +1110101010000111 +0001000111001011 +1110101010000111 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001001101011111 +1110001100000101 +0001010001000001 +1110101010000111 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0100101110010110 +1110110000010000 +0000000000001110 +1110001100001000 +0001001101110111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000001001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110001000010001 +1110110000010000 +0000000000001110 +1110001100001000 +0001001110001110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001110100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001100001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001110110010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001101101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001111000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001100101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001111010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001111101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001001111111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001010000001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001100101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001010000011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001010000110000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110110001010 +1110110000010000 +0000000000001110 +1110001100001000 +0001010000111100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000101 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0001010001001001 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000010001100110 +1110110000010000 +0000000000001110 +1110001100001000 +0001010001101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001010010000110 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001010010011011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001010010101010 +1110001100000101 +0001011010101010 +1110101010000111 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000110000000110 +1110110000010000 +0000000000001110 +1110001100001000 +0001010011011001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000110000011011 +1110110000010000 +0000000000001110 +1110001100001000 +0001010011110010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000001001010111 +1110110000010000 +0000000000001110 +1110001100001000 +0001010100001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0000001001101100 +1110110000010000 +0000000000001110 +1110001100001000 +0001010100100111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001010101000010 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001010101001001 +1110001100000101 +0001011010001011 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001010101011101 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001010101110010 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001010110010010 +1110001100000101 +0001011010001011 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0001010110110001 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001010110111000 +1110001100000101 +0001010111001000 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0001010111111001 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0001010111101000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001010111101111 +1110001100000101 +0001010111111001 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0000110000111101 +1110110000010000 +0000000000001110 +1110001100001000 +0001011000110100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000010110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0100101110010110 +1110110000010000 +0000000000001110 +1110001100001000 +0001011001101100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100111000001101 +1110110000010000 +0000000000001110 +1110001100001000 +0001011010000110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0000011100101011 +1110110000010000 +0000000000001110 +1110001100001000 +0001011010100101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001011010111111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001011011001001 +1110001100000101 +0001011011100000 +1110101010000111 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0001011011011011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010000111000011 +1110110000010000 +0000000000001110 +1110001100001000 +0001011011110011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010010010001101 +1110110000010000 +0000000000001110 +1110001100001000 +0001011100010011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0110000000000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010000101101110 +1110110000010000 +0000000000001110 +1110001100001000 +0001011100110110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000110110 +1110101010000111 +0000000000000000 +1111110000100000 +1110101010001000 +1110110111110000 +1110101010001000 +0000000000000000 +1110011111001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110010011010 +1110110000010000 +0000000000001110 +1110001100001000 +0001011101001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001011101100011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001011101110010 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001011110110110 +1110001100000101 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001011100100100 +1110110000010000 +0000000000001110 +1110001100001000 +0001011110001011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001011110100000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001011110100111 +1110001100000101 +0001011110110100 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0001011101010100 +1110101010000111 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110100110100010 +1110110000010000 +0000000000001110 +1110001100001000 +0001011111000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110010011010 +1110110000010000 +0000000000001110 +1110001100001000 +0001011111001110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110010011010 +1110110000010000 +0000000000001110 +1110001100001000 +0001011111100110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000101 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0001011111110110 +1110001100000001 +0000000001010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110001000010001 +1110110000010000 +0000000000001110 +1110001100001000 +0001100000001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110110001010 +1110110000010000 +0000000000001110 +1110001100001000 +0001100000101010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110100110011010 +1110110000010000 +0000000000001110 +1110001100001000 +0001100000111011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110100110100010 +1110110000010000 +0000000000001110 +1110001100001000 +0001100001001101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001100100000100 +1110001100000101 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001011100111000 +1110110000010000 +0000000000001110 +1110001100001000 +0001100001110100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001100010001100 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001100010101000 +1110001100000101 +0001100100000010 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001100010111011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001100011000010 +1110001100000101 +0001100011011110 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110010011001001 +1110110000010000 +0000000000001110 +1110001100001000 +0001100011010111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0001100100000010 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0001100011111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0001100001010100 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110000100000 +1110101010001000 +1110110111110000 +1110101010001000 +0000000000000000 +1110011111001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011111110100 +1110110000010000 +0000000000001110 +1110001100001000 +0001100100101001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110010100100001 +1110110000010000 +0000000000001110 +1110001100001000 +0001100101000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110001010100100 +1110110000010000 +0000000000001110 +1110001100001000 +0001100101011011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0001100101111111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010001 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0001100110010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010010 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001100111010101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001101001110000 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0001100111000100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001101010000101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001101010001100 +1110001100000101 +0001101010011101 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000101 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0001101010101000 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001101010111110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001101011001101 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001101011100001 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001101011110000 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0001101100010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0001101100101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001101101000111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001101101001110 +1110001100000101 +0001101101110101 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001101110001000 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001110001001101 +1110001100000101 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001101111000100 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001101111001011 +1110001100000101 +0001110000011000 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0001101101110101 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001110001011101 +1110001100000101 +0001110001101110 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000100 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0001110001111001 +1110001100000001 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001110010001111 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001110010010110 +1110001100000101 +0001110010101101 +1110101010000111 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0001110010101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001110010111100 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001110011001011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001110011011111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001110011101110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0001110100100001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0001110101001010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001111010100001 +1110001100000101 +0111111111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001110110101111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001110111001010 +1110001100000101 +0001111010011111 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001111001101110 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001111010001001 +1110001100000101 +0001111010011111 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0001110101010000 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0001111010110100 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001111101100111 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001111011100101 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001111011101111 +1110001100000101 +0001111101001111 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0001111010100001 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0001111101110110 +1110001100000101 +0001111110000111 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000100 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0001111110010010 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0001111110101000 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0001111110101111 +1110001100000101 +0001111111000110 +1110101010000111 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0001111111000001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0001111111100101 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0010000010011100 +1110001100000101 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0010000000111001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0010000001010011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0010000001100110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +0010000001110101 +1110001100000101 +0010000010000100 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0001111111010010 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0010000010111001 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010000011000000 +1110001100000101 +0010000011001101 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0010000011101000 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010000011101111 +1110001100000101 +0010000011111100 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010011 +1110001100001000 +0000100000000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0011011111111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000100000000001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000100000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0010000111010110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010000111011101 +1110001100000101 +0010000111110100 +1110101010000111 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0010000111101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000100000000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0010001000100111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0010001001010011 +1110001100000101 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0010001000000000 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0011111111111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0010001001110000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010001001110111 +1110001100000101 +0010001010001110 +1110101010000111 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0010001010001001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0010001011000000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010001011000111 +1110001100000101 +0010010001001111 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0010001101100000 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010001101100111 +1110001100000101 +0010001110111011 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0010010000001011 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110000100000 +1110101010001000 +1110110111110000 +1110101010001000 +0000000000000000 +1110011111001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0010010011110010 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010010011111001 +1110001100000101 +0010010101010100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0010011001111000 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0010010111110101 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0010010111111100 +1110001100000101 +0010011000110110 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0010011001111000 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0100000000000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010100 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010101 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010111 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110001000010001 +1110110000010000 +0000000000001110 +1110001100001000 +0010011010111011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000011000 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0010011011101000 +1110110000010000 +0000000000001110 +1110001100001000 +0010011011001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0100100000011000 +1110110000010000 +0000000000001110 +1110001100001000 +0010011011011101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000001111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0010011011111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000011001 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010011101001101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010011110010000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010011111100011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010100000101100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010100001111111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010100011010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010100100100111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010100101111100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000100111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010100111000101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010101000011010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010101001101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010101010111100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010101100001001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010101101010010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010101110010111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010101111011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000101111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010110000101101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010110010000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010110011010111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010110100101100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010110110000001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010110111010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010111000101011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010111010000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000110111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010111011010101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010111100101010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010111101111111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0010111111001010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011000000010111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011000001101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011000010101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011000100000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011000101010101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011000110101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011000111111101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011001001010010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011001010100111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011001011111100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011001101010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011001110100110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011001111111011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011010001010000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011010010100101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011010011111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011010101001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011010110100100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011010111111001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011011001001110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011011010100011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011011011111000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011011101001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011011110100100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011011111111001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011100001001110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011100010100011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011100011111000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001010111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011100101001101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011100110100010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011100111110111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011101001001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011101010100001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011101011110000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011101101000101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011101110001110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011101111010011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011110000011100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011110001101011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011110011000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011110100001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011110101100100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011110110110011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011111000001000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001100111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011111001011011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011111010110000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011111100000011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000111000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011111101011000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0011111110101101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100000000000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100000001010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100000010100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001101111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100000011101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100000101000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100000110010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100000111100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100001000101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100001010000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100001011010011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100001100100010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001110111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100001101110001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001111000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100001111000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001111001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100010000010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001111010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100010001100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001111011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100010010110101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001111100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100010100001010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001111101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100010101011111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000001111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000001100 +1110110000010000 +0000000000001101 +1110001100001000 +0100010110110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100010110101000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0100010111001001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000001000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000001001 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000001001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000001010 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000010000 +0000000000001011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000100 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0100100000011010 +1110001100000001 +0000000001111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0100100000110011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000011010 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000001111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100100001010101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100100110101011 +1110001100000101 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0100100010010100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100100011101001 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100100101101011 +1110001100000101 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000100000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0100100100111001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0100100011010110 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0100100101111011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0100100110000010 +1110001100000101 +0100100110010001 +1110101010000111 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0100100110101001 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0100100001000011 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100100111000110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000001111110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100100111010111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100100111100011 +1110001100000101 +0100100111101101 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000010101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100100111111010 +1110001100000101 +0100101000100000 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011001 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0100101001000100 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011010 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000100 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0100101001001111 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100100110110001 +1110110000010000 +0000000000001110 +1110001100001000 +0100101001101001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000010110 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100101010001101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100101110010000 +1110001100000101 +0000000000010101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100101010100010 +1110001100000101 +0100101011011001 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010100 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000100000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0100101100001010 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010100 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010100 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0100101001111100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0100101110100101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100101110110110 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0100101111001010 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100101111100000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100101111101100 +1110001100000101 +0100110000000011 +1110101010000111 +0000000000010100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0100101111111110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0100110000011100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010111 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000101100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0100110001000000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000010111 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010111 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0100110001110100 +1110110000010000 +0000000001011111 +1110101010000111 +0100110001111000 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010101 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100101001001101 +1110110000010000 +0000000000001110 +1110001100001000 +0100110010001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110100110011010 +1110110000010000 +0000000000001110 +1110001100001000 +0100110010101101 +1110110000010000 +0000000001011111 +1110101010000111 +0100110010110001 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0100110010111000 +1110001100000101 +0100110011001011 +1110101010000111 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0100111001001000 +1110110000010000 +0000000000001110 +1110001100001000 +0100110011000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0100110110000100 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110100110100010 +1110110000010000 +0000000000001110 +1110001100001000 +0100110011011110 +1110110000010000 +0000000001011111 +1110101010000111 +0100110011100010 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0100110011101001 +1110001100000101 +0100110011111100 +1110101010000111 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0100111010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0100110011110101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0100110110000100 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100101001001101 +1110110000010000 +0000000000001110 +1110001100001000 +0100110100001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000010101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100110100100100 +1110001100000101 +0100110101001100 +1110101010000111 +0000000000010111 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010111 +1110001100001000 +0000000000010110 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0000000000010111 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100110101011100 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0100110101100011 +1110001100000101 +0100110101110110 +1110101010000111 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0100111001001000 +1110110000010000 +0000000000001110 +1110001100001000 +0100110101101111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0100110110000100 +1110101010000111 +0000000000010101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110000100000 +1110101010001000 +1110110111110000 +1110101010001000 +0000000000000000 +1110011111001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110001011111011 +1110110000010000 +0000000000001110 +1110001100001000 +0100110110100100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100110110111100 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100111000000111 +1110001100000101 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110001100010001 +1110110000010000 +0000000000001110 +1110001100001000 +0100110111011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110010011010 +1110110000010000 +0000000000001110 +1110001100001000 +0100110111101010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0100110110101010 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000011000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110011010110011 +1110110000010000 +0000000000001110 +1110001100001000 +0100111000100110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000011000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110110001010 +1110110000010000 +0000000000001110 +1110001100001000 +0100111000111101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000010110 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000101100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000010111 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010111 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010101 +1110001100001000 +0000000000010110 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0001111111000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100111010001110 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0100111010010101 +1110001100000101 +0100111010100000 +1110101010000111 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000010101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0100111010110011 +1110001100000101 +0100111101000000 +1110101010000111 +0000000000010111 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0100111011000001 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0100111011001000 +1110001100000101 +0100111011110010 +1110101010000111 +0000000000010111 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010111 +1110001100001000 +0000000000010110 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0100111100110101 +1110101010000111 +0000000000011111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010111 +1110001100001000 +0000000000010110 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100111100001101 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0100111100010100 +1110001100000101 +0100111100011111 +1110101010000111 +0001111111000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0000000000010110 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000101000001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010110 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010101 +1110001100001000 +0100111101001100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000010101 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100101001001101 +1110110000010000 +0000000000001110 +1110001100001000 +0100111101011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0100000000000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000011011 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000011100 +1110001100001000 +0000000000010001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0100111110010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000011101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0100111111010101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101000001110000 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0100111111000100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0010000000000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101000010001011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101000011010111 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0101000001111010 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000011100 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101000011101010 +1110001100000101 +0101000100111110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0101000110010011 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000011100 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000011 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0101000110101101 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101000111000011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101000111010100 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101000111101000 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101000111111110 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101001000001010 +1110001100000101 +0101001000100001 +1110101010000111 +0000000000000111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0101001000011100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0101001000111010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101001001100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101001010000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101001011001001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101001011100011 +1110001100000101 +0101001100000100 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110101011 +1110110000010000 +0000000000001110 +1110001100001000 +0101001011111101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0101001100100011 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000110101011 +1110110000010000 +0000000000001110 +1110001100001000 +0101001100011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000001011 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0101001100101011 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101001101000001 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101001101010011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101001101100111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101001101111111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101001110001011 +1110001100000101 +0101001110100010 +1110101010000111 +0000000000001000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0101001110011101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0101001111000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001101001110110 +1110110000010000 +0000000000001110 +1110001100001000 +0101001111101011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101010000000111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101010000101111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101010001010011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101010001100100 +1110001100000101 +0101010011000010 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101010011010010 +1110001100000101 +0101010101010100 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101010101000110 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0101010110100010 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101010110010110 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101010110111100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101010111101110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000001001 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101011000100010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000001010 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0101001011010100 +1110110000010000 +0000000000001110 +1110001100001000 +0101011001010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101011001101010 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101011101001100 +1110001100000101 +0000000000000001 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101011010000011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0101011010001010 +1110001100000101 +0101011010101101 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001001 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0101011100001100 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001010 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101011011011110 +1110001100000101 +0101011011110110 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0101011100001100 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0101001011010100 +1110110000010000 +0000000000001110 +1110001100001000 +0101011101000101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0101011001010110 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000001001 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0101011101010100 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101011101101110 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101011110000010 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101011110010110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101011110101101 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101011111000001 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101011111011001 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101011111100101 +1110001100000101 +0101011111111100 +1110101010000111 +0000000000001001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0101011111110111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0101100000010101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101100000111111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0101100001101010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101100010010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101100100110011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101100101111001 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101101011001101 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101100110101110 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0101100110110101 +1110001100000101 +0101100111100110 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101100111011111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0101101010010000 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101101000000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101101000101111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101101001101111 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101101001010010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0101101000011101 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101101010001011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0101100101100101 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000001011 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0101101011010101 +1110001100000001 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0010000011010110 +1110110000010000 +0000000000001110 +1110001100001000 +0101101011110111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0010000010100111 +1110110000010000 +0000000000001110 +1110001100001000 +0101101100011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0101101100111101 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000100000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101101101001110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000001000000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101101101100110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0101101110000000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101101110001100 +1110001100000101 +0101111001010001 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0010000010100111 +1110110000010000 +0000000000001110 +1110001100001000 +0101101110100101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0010000011010110 +1110110000010000 +0000000000001110 +1110001100001000 +0101101111001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0101101111110011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000111 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101110000011011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1111110000010000 +0000000000001001 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0101110001000111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001000 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101110001110001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1111110000010000 +0000000000001010 +1110000010010000 +0000000000001101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000001101 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001001 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000001010 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000011101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000100000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0101110100001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000110 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101110101101011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0101110101110010 +1110001100000101 +0101110110100011 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101110110011100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0101111001010001 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000101 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101110110111111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101110111101110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101111000101110 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101111000010001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0101110111011010 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0101000011011101 +1110110000010000 +0000000000001110 +1110001100001000 +0101111001001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0101101011010011 +1110110000010000 +0000000000001110 +1110001100001000 +0101111010100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0101101011010011 +1110110000010000 +0000000000001110 +1110001100001000 +0101111011101110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0101101011010011 +1110110000010000 +0000000000001110 +1110001100001000 +0101111100111101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1110110000010000 +0000000000001101 +1110001100001000 +0101101011010011 +1110110000010000 +0000000000001110 +1110001100001000 +0101111110001100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000011 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0101111110011001 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101111110101111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101111111000000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0101111111010100 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000011111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0101111111101010 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0101111111110110 +1110001100000101 +0110000000001101 +1110101010000111 +0000000000001100 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110000000001000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110000000101001 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000111111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110000001000111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110000001101000 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000011111111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110000010001011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110000010010111 +1110001100000101 +0110000010101110 +1110101010000111 +0000000000001101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110000010101001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101111001010111 +1110110000010000 +0000000000001110 +1110001100001000 +0110000011111100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110000100010011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110001000001011 +1110001100000101 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110000100101011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110000100110010 +1110001100000101 +0110000101101100 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0110000101010011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0110000111000110 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0110000110011001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000100 +1110110000010000 +0000000000001101 +1110001100001000 +0101111001010111 +1110110000010000 +0000000000001110 +1110001100001000 +0110001000000100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0110000100000001 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010000111000011 +1110110000010000 +0000000000001110 +1110001100001000 +0110001000100011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110001000110111 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110001000111110 +1110001100000101 +0110001001010101 +1110101010000111 +0000000000001110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110001001010000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110001001100100 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110001001101011 +1110001100000101 +0110001010000100 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0110001001111110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110001010111111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110001011000110 +1110001100000101 +0110001011011110 +1110101010000111 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011011110101 +1110110000010000 +0000000000001110 +1110001100001000 +0110001011011001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0010010010001101 +1110110000010000 +0000000000001110 +1110001100001000 +0110001011110000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110001100101100 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110001100111111 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110001101010111 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110001101100011 +1110001100000101 +0110001101111010 +1110101010000111 +0000000000001111 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110001101110101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110001110110110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110001111001001 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110001111100001 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110001111101101 +1110001100000101 +0110010000000100 +1110101010000111 +0000000000010000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110001111111111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110010001011010 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110010001100001 +1110001100000101 +0110010001111000 +1110101010000111 +0000000000010001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110010001110011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110010011100101 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110010011101100 +1110001100000101 +0110010100000011 +1110101010000111 +0000000000010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110010011111110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000101 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0110010100100011 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110010101000110 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110010101001101 +1110001100000101 +0110010101010011 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000101101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110010110001000 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110010110001111 +1110001100000101 +0110010110101001 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110010110111100 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000000001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110011010001001 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110011000010011 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110011000100101 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111010101001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110011001000101 +1110001100000101 +0110011010000111 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0110011001011110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0110010110101001 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000100 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110011010011001 +1110001100000101 +0110011010101010 +1110101010000111 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000100 +1110110000010000 +1110001110010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0110011010110101 +1110001100000001 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110011011010111 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110011011011110 +1110001100000101 +0110011011110101 +1110101010000111 +0000000000010011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110011011110000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000110 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011010110000 +1110110000010000 +0000000000001110 +1110001100001000 +0110011100000111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110011100011101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110011100100100 +1110001100000101 +0110011101000100 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110110111100000 +1110110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010100000 +1111110001010000 +1110011111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110011101100000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110100000000110 +1110001100000101 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001110001110111 +1110110000010000 +0000000000001110 +1110001100001000 +0110011110000001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110111100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000001010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0001101010100110 +1110110000010000 +0000000000001110 +1110001100001000 +0110011111000001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110111100000 +1110001100001000 +0110011101010001 +1110101010000111 +0000000000000001 +1111110000010000 +0000000000000011 +1110000010100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110100000010110 +1110001100000101 +0110100001011100 +1110101010000111 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000101101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000011 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110100001101110 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110100001110101 +1110001100000101 +0110100010001100 +1110101010000111 +0000000000010011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110100010000111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110100010011011 +1110110000010000 +0000000000000110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110100010100010 +1110001100000101 +0110100011011011 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000110000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0110100101111011 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0110100011111001 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110100101111011 +1110001100000101 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000100 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1110001100001000 +0000000000000101 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000100 +1111110000100000 +1110001100001000 +0000000000000011 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000011 +1111110111100000 +1110110111100000 +1110001100001000 +0110100011100110 +1110101010000111 +0000000000000001 +1111110111100000 +1110110111100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0001011011110101 +1110110000010000 +0000000000001110 +1110001100001000 +0110100110001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000010000000 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000010000001 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000100010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000110110 +1110101010000111 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0010000100000101 +1110110000010000 +0000000000001110 +1110001100001000 +0110100110111110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001100101101001 +1110110000010000 +0000000000001110 +1110001100001000 +0110100111001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0100111101101001 +1110110000010000 +0000000000001110 +1110001100001000 +0110100111100000 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0010011001111110 +1110110000010000 +0000000000001110 +1110001100001000 +0110100111110001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0001011100011110 +1110110000010000 +0000000000001110 +1110001100001000 +0110101000000010 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0000111011111101 +1110110000010000 +0000000000001110 +1110001100001000 +0110101000010011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110101000101001 +1110110000010000 +0000000000001110 +1110001100001000 +0110101000100100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110101000111010 +1110001100000101 +0110101000101001 +1110101010000111 +0000000000000000 +1111110111101000 +1110110010100000 +1110101010001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110101001001101 +1110110000010000 +0000000000100110 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0110101001010100 +1110001100000101 +0110101001101001 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110101011011001 +1110110000010000 +0000000000001110 +1110001100001000 +0110101001100100 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110101001111000 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110101011010011 +1110001100000101 +0000000000110010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0110101010011011 +1110110000010000 +0000000000010110 +1110101010000111 +0000000000000000 +1111110010100000 +1111110001001000 +0000000000000000 +1111110010101000 +1111110000010000 +0110101010111011 +1110001100000101 +0000000000000001 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0110101010001100 +1110101010000111 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000000 +1111110111001000 +1111110010100000 +1110111111001000 +0000000000000000 +1111110010101000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0110101001101001 +1110101010000111 +0000000000000000 +1111110111001000 +1111110010100000 +1110101010001000 +0000000000110110 +1110101010000111 +0000000000000011 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0110001000010001 +1110110000010000 +0000000000001110 +1110001100001000 +0110101011101011 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001000101 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0110101011111101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0110101100001111 +1110110000010000 +0000000001011111 +1110101010000111 +0000000001010010 +1110110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000010 +1110110000010000 +0000000000001101 +1110001100001000 +0110010000111011 +1110110000010000 +0000000000001110 +1110001100001000 +0110101100100001 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100110110001010 +1110110000010000 +0000000000001110 +1110001100001000 +0110101100101101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000010 +1111110000100000 +1111110000010000 +0000000000000000 +1111110111101000 +1110110010100000 +1110001100001000 +0000000000000001 +1110110000010000 +0000000000001101 +1110001100001000 +0100111000001101 +1110110000010000 +0000000000001110 +1110001100001000 +0110101101000101 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000001101 +1110001100001000 +0110101000101001 +1110110000010000 +0000000000001110 +1110001100001000 +0110101101010110 +1110110000010000 +0000000001011111 +1110101010000111 +0000000000000000 +1111110010101000 +1111110000010000 +0000000000000101 +1110001100001000 diff --git a/projects/06/pong/PongL.asm b/projects/06/pong/PongL.asm new file mode 100755 index 0000000..17c1044 --- /dev/null +++ b/projects/06/pong/PongL.asm @@ -0,0 +1,27490 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/06/pong/PongL.asm + +// Symbol-less version of the Pong.asm program. + +@256 +D=A +@0 +M=D +@133 +0;JMP +@15 +M=D +@0 +AM=M-1 +D=M +A=A-1 +D=M-D +M=0 +@19 +D;JNE +@0 +A=M-1 +M=-1 +@15 +A=M +0;JMP +@15 +M=D +@0 +AM=M-1 +D=M +A=A-1 +D=M-D +M=0 +@35 +D;JLE +@0 +A=M-1 +M=-1 +@15 +A=M +0;JMP +@15 +M=D +@0 +AM=M-1 +D=M +A=A-1 +D=M-D +M=0 +@51 +D;JGE +@0 +A=M-1 +M=-1 +@15 +A=M +0;JMP +@5 +D=A +@1 +A=M-D +D=M +@13 +M=D +@0 +AM=M-1 +D=M +@2 +A=M +M=D +D=A +@0 +M=D+1 +@1 +D=M +@14 +AM=D-1 +D=M +@4 +M=D +@14 +AM=M-1 +D=M +@3 +M=D +@14 +AM=M-1 +D=M +@2 +M=D +@14 +AM=M-1 +D=M +@1 +M=D +@13 +A=M +0;JMP +@0 +A=M +M=D +@1 +D=M +@0 +AM=M+1 +M=D +@2 +D=M +@0 +AM=M+1 +M=D +@3 +D=M +@0 +AM=M+1 +M=D +@4 +D=M +@0 +AM=M+1 +M=D +@4 +D=A +@13 +D=D+M +@0 +D=M-D +@2 +M=D +@0 +MD=M+1 +@1 +M=D +@14 +A=M +0;JMP +@0 +D=A +@13 +M=D +@27058 +D=A +@14 +M=D +@145 +D=A +@95 +0;JMP +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@8643 +D=A +@14 +M=D +@163 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@10 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +D=M +@11 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@12 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +D=M +@13 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@3 +D=M +@14 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@387 +D=A +@14 +M=D +@333 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@9357 +D=A +@14 +M=D +@376 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@418 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@514 +D=A +@14 +M=D +@441 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@480 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@514 +D=A +@14 +M=D +@503 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@13 +M=D +@22354 +D=A +@14 +M=D +@588 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@54 +0;JMP +@3 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@654 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@747 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@774 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@798 +D=A +@38 +0;JMP +@3 +D=M +@7 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@826 +D;JNE +@930 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@886 +D=A +@38 +0;JMP +@3 +D=M +@8 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@916 +D=A +@38 +0;JMP +@3 +D=M +@9 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@991 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@948 +D=A +@38 +0;JMP +@3 +D=M +@8 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@979 +D=A +@38 +0;JMP +@3 +D=M +@9 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@1016 +D=A +@95 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@1062 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@1109 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@452 +D=A +@14 +M=D +@1156 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1178 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@1185 +D;JNE +@1219 +0;JMP +@3 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1401 +0;JMP +@3 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@3 +D=M +@9 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1267 +D;JNE +@1335 +0;JMP +@3 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1283 +D;JNE +@1309 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@1333 +0;JMP +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@1401 +0;JMP +@3 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1351 +D;JNE +@1377 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@1401 +0;JMP +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@3 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1417 +D;JNE +@1485 +0;JMP +@3 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1433 +D;JNE +@1459 +0;JMP +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@1483 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@1551 +0;JMP +@3 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1501 +D;JNE +@1527 +0;JMP +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@1551 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@10 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1571 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1581 +D;JNE +@1612 +0;JMP +@0 +M=M+1 +A=M-1 +M=1 +@3 +D=M +@14 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +D=M +@10 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@11 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1632 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1642 +D;JNE +@1675 +0;JMP +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@14 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +D=M +@11 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@12 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1695 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1705 +D;JNE +@1738 +0;JMP +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@14 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +D=M +@12 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@13 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1758 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1768 +D;JNE +@1801 +0;JMP +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@14 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@3 +D=M +@13 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@387 +D=A +@14 +M=D +@1819 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@14 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@5 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@1837 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@1882 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@1916 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1939 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@1946 +D;JNE +@1963 +0;JMP +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2086 +0;JMP +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1979 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@1997 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@2018 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@2042 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +@2054 +D;JNE +@2071 +0;JMP +@20 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2086 +0;JMP +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@3 +D=M +@14 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@2103 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@2110 +D;JNE +@2227 +0;JMP +@506 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@50 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2153 +D=A +@95 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@2173 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2214 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@2616 +0;JMP +@3 +D=M +@14 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2246 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@2253 +D;JNE +@2364 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@50 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2290 +D=A +@95 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@2310 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2351 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@2616 +0;JMP +@3 +D=M +@14 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2383 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@2390 +D;JNE +@2507 +0;JMP +@250 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2432 +D=A +@95 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@2453 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2494 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@2616 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2543 +D=A +@95 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@2564 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@2605 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@13 +M=D +@652 +D=A +@14 +M=D +@2648 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@8643 +D=A +@14 +M=D +@2677 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@2827 +D=A +@14 +M=D +@2773 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@9357 +D=A +@14 +M=D +@2816 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@2858 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@2954 +D=A +@14 +M=D +@2881 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@2920 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@2954 +D=A +@14 +M=D +@2943 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@13 +M=D +@22354 +D=A +@14 +M=D +@3033 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@2892 +D=A +@14 +M=D +@3163 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@2827 +D=A +@14 +M=D +@3200 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@3240 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@3247 +D;JNE +@3525 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@3286 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@3293 +D;JNE +@3303 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@3319 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@13 +M=D +@22354 +D=A +@14 +M=D +@3424 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@3448 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@13 +M=D +@22354 +D=A +@14 +M=D +@3518 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3831 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3579 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@3586 +D;JNE +@3611 +0;JMP +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@3627 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@13 +M=D +@22354 +D=A +@14 +M=D +@3706 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@1 +D=A +@13 +M=D +@20889 +D=A +@14 +M=D +@3730 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@13 +M=D +@22354 +D=A +@14 +M=D +@3826 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@0 +D=A +@13 +M=D +@4508 +D=A +@14 +M=D +@3853 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@4531 +D=A +@14 +M=D +@3870 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@4539 +D=A +@14 +M=D +@3895 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@4419 +D=A +@14 +M=D +@3919 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@8643 +D=A +@14 +M=D +@3948 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +M=D +@0 +D=A +@13 +M=D +@20598 +D=A +@14 +M=D +@3965 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@50 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@230 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@229 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@13 +M=D +@2659 +D=A +@14 +M=D +@4026 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@253 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@222 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@229 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@13 +M=D +@145 +D=A +@14 +M=D +@4076 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@400 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@3 +D=A +@13 +M=D +@652 +D=A +@14 +M=D +@4111 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@238 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@240 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@13 +M=D +@22354 +D=A +@14 +M=D +@4150 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@22 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@2 +D=A +@13 +M=D +@19350 +D=A +@14 +M=D +@4177 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@8 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25105 +D=A +@14 +M=D +@4200 +D=A +@95 +0;JMP +@83 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4218 +D=A +@95 +0;JMP +@99 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4236 +D=A +@95 +0;JMP +@111 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4254 +D=A +@95 +0;JMP +@114 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4272 +D=A +@95 +0;JMP +@101 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4290 +D=A +@95 +0;JMP +@58 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4308 +D=A +@95 +0;JMP +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4326 +D=A +@95 +0;JMP +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@4344 +D=A +@95 +0;JMP +@1 +D=A +@13 +M=D +@19850 +D=A +@14 +M=D +@4356 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@2786 +D=A +@14 +M=D +@4450 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@346 +D=A +@14 +M=D +@4474 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@9357 +D=A +@14 +M=D +@4497 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +D=A +@13 +M=D +@3930 +D=A +@14 +M=D +@4520 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@16 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@16 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@4943 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@4590 +D=A +@6 +0;JMP +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@4682 +D;JNE +@0 +D=A +@13 +M=D +@5924 +D=A +@14 +M=D +@4627 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@3211 +D=A +@14 +M=D +@4652 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5191 +D=A +@14 +M=D +@4675 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@4575 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@130 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@4699 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@4706 +D;JNE +@4736 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@2 +D=A +@13 +M=D +@3044 +D=A +@14 +M=D +@4729 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@4831 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@132 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@4753 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@4760 +D;JNE +@4792 +0;JMP +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@3044 +D=A +@14 +M=D +@4785 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@4831 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@140 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@4809 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@4816 +D;JNE +@4831 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@4846 +D=A +@6 +0;JMP +@0 +A=M-1 +M=!M +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@4941 +D;JNE +@0 +D=A +@13 +M=D +@5924 +D=A +@14 +M=D +@4886 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@3211 +D=A +@14 +M=D +@4911 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5191 +D=A +@14 +M=D +@4934 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@4831 +0;JMP +@4555 +0;JMP +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4959 +D;JNE +@5185 +0;JMP +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@19350 +D=A +@14 +M=D +@4983 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@9 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25105 +D=A +@14 +M=D +@5006 +D=A +@95 +0;JMP +@71 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5024 +D=A +@95 +0;JMP +@97 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5042 +D=A +@95 +0;JMP +@109 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5060 +D=A +@95 +0;JMP +@101 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5078 +D=A +@95 +0;JMP +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5096 +D=A +@95 +0;JMP +@79 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5114 +D=A +@95 +0;JMP +@118 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5132 +D=A +@95 +0;JMP +@101 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5150 +D=A +@95 +0;JMP +@114 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@5168 +D=A +@95 +0;JMP +@1 +D=A +@13 +M=D +@19850 +D=A +@14 +M=D +@5180 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@5 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@5193 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@1126 +D=A +@14 +M=D +@5231 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@5254 +D=A +@22 +0;JMP +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@5275 +D=A +@6 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +@5290 +D;JNE +@5802 +0;JMP +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@3078 +D=A +@14 +M=D +@5337 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@3099 +D=A +@14 +M=D +@5362 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@599 +D=A +@14 +M=D +@5388 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@620 +D=A +@14 +M=D +@5415 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@5442 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@5449 +D;JNE +@5771 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@5469 +D=A +@22 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@5490 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +M=D +@3 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@5522 +D;JNE +@5771 +0;JMP +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@5553 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@5560 +D;JNE +@5576 +0;JMP +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@5625 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@5608 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@5615 +D;JNE +@5625 +0;JMP +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@3133 +D=A +@14 +M=D +@5684 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@22 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@19350 +D=A +@14 +M=D +@5740 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19981 +D=A +@14 +M=D +@5766 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@1835 +D=A +@14 +M=D +@5797 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@5823 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@5833 +D;JNE +@5856 +0;JMP +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@5851 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@8643 +D=A +@14 +M=D +@5875 +D=A +@95 +0;JMP +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@9357 +D=A +@14 +M=D +@5907 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@24576 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@8558 +D=A +@14 +M=D +@5942 +D=A +@95 +0;JMP +@54 +0;JMP +@0 +A=M +M=0 +AD=A+1 +M=0 +@0 +M=D+1 +@0 +M=M+1 +A=M-1 +M=0 +@1 +D=A +@13 +M=D +@19610 +D=A +@14 +M=D +@5967 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@5987 +D=A +@6 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@6002 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@6070 +D;JNE +@0 +D=A +@13 +M=D +@5924 +D=A +@14 +M=D +@6027 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@6048 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@6055 +D;JNE +@6068 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@5972 +0;JMP +@0 +D=A +@13 +M=D +@27042 +D=A +@14 +M=D +@6082 +D=A +@95 +0;JMP +@1 +D=A +@13 +M=D +@19610 +D=A +@14 +M=D +@6094 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19610 +D=A +@14 +M=D +@6118 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@5 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@6134 +D;JGT +@80 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25105 +D=A +@14 +M=D +@6159 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19850 +D=A +@14 +M=D +@6186 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@27034 +D=A +@14 +M=D +@6203 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@0 +D=A +@13 +M=D +@27042 +D=A +@14 +M=D +@6221 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@6404 +D;JNE +@0 +D=A +@13 +M=D +@5944 +D=A +@14 +M=D +@6260 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@6284 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@6312 +D;JNE +@6402 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@6331 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@6338 +D;JNE +@6366 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25801 +D=A +@14 +M=D +@6359 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@6402 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@6394 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@6228 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@0 +A=M +M=0 +AD=A+1 +M=0 +@0 +M=D+1 +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@6132 +D=A +@14 +M=D +@6441 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25889 +D=A +@14 +M=D +@6466 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25252 +D=A +@14 +M=D +@6491 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@6527 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@17 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@6550 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@18 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6613 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@6768 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@6596 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@6789 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@6796 +D;JNE +@6813 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@5 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@6824 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@6846 +D=A +@38 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@6861 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@6881 +D=A +@22 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@6896 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@6934 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@6959 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@6983 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@6990 +D;JNE +@7029 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@7048 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@7245 +D;JNE +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +M=M+1 +A=M-1 +M=0 +@7108 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@7115 +D;JNE +@7192 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@7029 +0;JMP +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@7261 +D;JNE +@7278 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@4 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@7289 +D;JGT +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@7311 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@7318 +D;JNE +@7341 +0;JMP +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@7336 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@7356 +D=A +@38 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@7371 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@7391 +D=A +@22 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@7406 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@7457 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@7498 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@7841 +D;JNE +@32767 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@7599 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@7626 +D;JNE +@7839 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@7790 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@7817 +D;JNE +@7839 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@7504 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@7860 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@8039 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@7909 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@7919 +D;JNE +@8015 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@17 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@7841 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@8054 +D;JNE +@8071 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@4 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@8082 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@8104 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@8111 +D;JNE +@8134 +0;JMP +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@8129 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@8165 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@8348 +D;JNE +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@8249 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@8275 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@8294 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +@8309 +D;JNE +@8324 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@8146 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@8377 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@8384 +D;JNE +@8397 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@8424 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@8431 +D;JNE +@8444 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@19 +M=D +@2048 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@19 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@14334 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@2049 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@19 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2050 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@19 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@19 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@8662 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@8669 +D;JNE +@8692 +0;JMP +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@8687 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2048 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@8743 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@8787 +D;JNE +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@8704 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@16379 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@8816 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@8823 +D;JNE +@8846 +0;JMP +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@8841 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@8896 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@8903 +D;JNE +@9295 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@9056 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@9063 +D;JNE +@9147 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@9227 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@54 +0;JMP +@0 +A=M +M=0 +AD=A+1 +M=0 +@0 +M=D+1 +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@9458 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@9465 +D;JNE +@9556 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@9848 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@9717 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@9724 +D;JNE +@9782 +0;JMP +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@9848 +0;JMP +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@16384 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@20 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@21 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@22 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@23 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25105 +D=A +@14 +M=D +@9915 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@24 +M=D +@0 +D=A +@13 +M=D +@9960 +D=A +@14 +M=D +@9932 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@18456 +D=A +@14 +M=D +@9949 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@127 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@9978 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@25 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10061 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10128 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@33 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10211 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@34 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@20 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10284 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10367 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@36 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10454 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@37 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@49 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10535 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@38 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10620 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@39 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10693 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@40 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10778 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@41 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10863 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@42 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@10940 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@43 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11017 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@44 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11090 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@45 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11159 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@46 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11230 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@47 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11309 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11394 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@49 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@14 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11479 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@50 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11564 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11649 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@52 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@26 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@25 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@60 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11734 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@53 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11819 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11904 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@55 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@49 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@11989 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@56 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12074 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@57 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@62 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@14 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12159 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@58 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12234 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12311 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@60 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12392 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@61 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12463 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@62 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12544 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@64 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12629 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12712 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@65 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12797 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@66 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12882 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@67 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@12967 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@68 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13052 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@69 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13137 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@70 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13222 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@71 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@44 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13307 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@72 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13392 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@73 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13477 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@74 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@60 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@14 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13562 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@75 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13647 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@76 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13732 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@77 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@33 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13817 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@78 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@55 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@55 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13902 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@79 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@13987 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@80 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14072 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@81 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@59 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14159 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@82 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14244 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@83 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14329 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@84 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@45 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14414 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@85 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14499 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@86 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14584 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@87 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14669 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@88 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14754 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@89 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14839 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@90 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@49 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@35 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@14924 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@91 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15009 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@92 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=1 +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15088 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@93 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15173 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@94 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@8 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15246 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@95 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15315 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@96 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15388 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@97 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@14 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15467 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@98 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15552 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@99 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15631 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@100 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@60 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15716 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@101 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15795 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@102 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@38 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15880 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@103 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@62 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@15963 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@104 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@55 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16048 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@105 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@14 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16131 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@106 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@56 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16216 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@107 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16301 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@108 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@14 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16386 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@109 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@29 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@43 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@43 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@43 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@43 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16465 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@110 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@29 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16544 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@111 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16623 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@112 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16704 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@113 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@62 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16785 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@114 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@29 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@55 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16864 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@115 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@16943 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@116 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@28 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17028 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@117 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17107 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@118 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17186 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@119 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17265 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@120 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@30 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17344 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@121 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@62 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17425 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@122 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@51 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17504 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@123 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@56 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@56 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17589 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@124 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17674 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@125 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@56 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17759 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@126 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@38 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@45 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@25 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@0 +M=M+1 +A=M-1 +M=0 +@12 +D=A +@13 +M=D +@17843 +D=A +@14 +M=D +@17832 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@17865 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=1 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@4 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@8 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@9 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@9 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@10 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +D=M +@11 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@4 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@18458 +D;JGT +@127 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@18483 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@26 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@127 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18517 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@18859 +D;JNE +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@18580 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@26 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18665 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@18795 +D;JNE +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@256 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@18745 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@18646 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@18811 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@18818 +D;JNE +@18833 +0;JMP +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@18857 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@18499 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18886 +D=A +@38 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@126 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@18903 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@18915 +D;JNE +@18925 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@21 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@18938 +D;JNE +@18976 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@19012 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@26 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@4 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@19023 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@18865 +D=A +@14 +M=D +@19049 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@22 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@11 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@19085 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@19344 +D;JNE +@21 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@19106 +D;JNE +@19161 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@20 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@256 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@19210 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@20 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@255 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@20 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@19068 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@19365 +D=A +@38 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@22 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@19382 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@19402 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@63 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@19424 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@19436 +D;JNE +@19459 +0;JMP +@20 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@19454 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@19484 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@23 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@352 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@19520 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@23 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@22 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@23 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@19572 +D=A +@95 +0;JMP +@19576 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@21 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19021 +D=A +@14 +M=D +@19599 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +D=A +@13 +M=D +@27034 +D=A +@14 +M=D +@19629 +D=A +@95 +0;JMP +@19633 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@19640 +D;JNE +@19659 +0;JMP +@0 +D=A +@13 +M=D +@20040 +D=A +@14 +M=D +@19652 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@19844 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +D=A +@13 +M=D +@27042 +D=A +@14 +M=D +@19678 +D=A +@95 +0;JMP +@19682 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@19689 +D;JNE +@19708 +0;JMP +@0 +D=A +@13 +M=D +@20134 +D=A +@14 +M=D +@19701 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@19844 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19021 +D=A +@14 +M=D +@19727 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@21 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@19748 +D;JNE +@19788 +0;JMP +@23 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@23 +M=D +@22 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@22 +M=D +@23 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@19804 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@19811 +D;JNE +@19830 +0;JMP +@0 +D=A +@13 +M=D +@20040 +D=A +@14 +M=D +@19823 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@19844 +0;JMP +@21 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@21 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +A=M +M=0 +AD=A+1 +M=0 +@0 +M=D+1 +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25339 +D=A +@14 +M=D +@19876 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@19900 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@19975 +D;JNE +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25361 +D=A +@14 +M=D +@19934 +D=A +@95 +0;JMP +@1 +D=A +@13 +M=D +@19610 +D=A +@14 +M=D +@19946 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@19882 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@24 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@26291 +D=A +@14 +M=D +@20006 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@24 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19850 +D=A +@14 +M=D +@20029 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@22 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@352 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@23 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@22 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@23 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@21 +M=D +@22 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@8128 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@20110 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@20117 +D;JNE +@20128 +0;JMP +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@22 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@21 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@20147 +D;JNE +@20288 +0;JMP +@23 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@20161 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@20168 +D;JNE +@20210 +0;JMP +@23 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@23 +M=D +@22 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@22 +M=D +@20277 +0;JMP +@31 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@23 +M=D +@22 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@20237 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@20244 +D;JNE +@20255 +0;JMP +@8128 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@22 +M=D +@22 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@321 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@22 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@21 +M=D +@20300 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@21 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19021 +D=A +@14 +M=D +@20318 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@16384 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@27 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@28 +M=D +@17 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@20374 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@29 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@20437 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@20592 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@20420 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@8192 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@20619 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@20695 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@20602 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@28 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@20714 +D;JNE +@20798 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@20883 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@27 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@28 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@3 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@20909 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@20931 +D=A +@38 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@20948 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@20968 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@255 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@20990 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@21002 +D;JNE +@21025 +0;JMP +@7 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@21020 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@21050 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@21088 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@21124 +D=A +@95 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@21193 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@21219 +D;JNE +@21252 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@20907 +D=A +@14 +M=D +@21245 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@21283 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@20907 +D=A +@14 +M=D +@21278 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@11 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@21291 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@21313 +D=A +@38 +0;JMP +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@21331 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@21351 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@255 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@21375 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@21387 +D;JNE +@21410 +0;JMP +@8 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@21405 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@21442 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=A +@13 +M=D +@6774 +D=A +@14 +M=D +@21483 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@21511 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@21551 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +M=!M +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@21587 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@21604 +D;JNE +@21698 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M+1 +A=A+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@21714 +D;JNE +@21844 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@8 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@21830 +D=A +@22 +0;JMP +@1 +D=M +@7 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@21922 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@8 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@21910 +D=A +@22 +0;JMP +@1 +D=M +@7 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@21948 +D=A +@95 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@21998 +D=A +@95 +0;JMP +@1 +D=M +@9 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@22050 +D=A +@95 +0;JMP +@1 +D=M +@10 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@13 +M=D +@21204 +D=A +@14 +M=D +@22097 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@22122 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@22348 +D;JNE +@1 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@22147 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@22154 +D;JNE +@22189 +0;JMP +@1 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@9 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@22284 +0;JMP +@1 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@10 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@22238 +D;JNE +@22262 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@22284 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +D=A +@13 +M=D +@21204 +D=A +@14 +M=D +@22341 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@22102 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@9 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@22356 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@22382 +D=A +@22 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@22402 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@22422 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@22445 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@22465 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@255 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@22489 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@22501 +D;JNE +@22524 +0;JMP +@9 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@22519 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@22549 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@22591 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=M +@7 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@22634 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@22678 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=M +@8 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@1 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@22835 +D=A +@95 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@22905 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@23245 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@22958 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@22965 +D;JNE +@23014 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@23007 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@23184 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@23042 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@23087 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@23151 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@23122 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@23069 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@23179 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@22885 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@11 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@23253 +D;JGT +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@8406 +D=A +@14 +M=D +@23287 +D=A +@95 +0;JMP +@1 +D=M +@7 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@8359 +D=A +@14 +M=D +@23326 +D=A +@95 +0;JMP +@1 +D=M +@8 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@23357 +D=A +@22 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@256 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@23374 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@1 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@512 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@23398 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@1 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@23424 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +AM=M-1 +D=M +@23436 +D;JNE +@24145 +0;JMP +@1 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@2 +D=A +@13 +M=D +@8359 +D=A +@14 +M=D +@23461 +D=A +@95 +0;JMP +@1 +D=M +@7 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@1 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@8406 +D=A +@14 +M=D +@23500 +D=A +@95 +0;JMP +@1 +D=M +@8 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@1 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@23539 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +D=M +@7 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@23579 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=M +@9 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@1 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@23623 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +D=M +@8 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@23665 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +D=M +@10 +D=D+A +@13 +M=D +@0 +AM=M-1 +D=M +@13 +A=M +M=D +@1 +D=M +@9 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@10 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@29 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@32 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@23820 +D=A +@95 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@6 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@23915 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@23922 +D;JNE +@23971 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@23964 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@24145 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@5 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@23999 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@24046 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@24110 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +A=M-1 +D=!M +M=D+1 +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@24081 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@24026 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@20701 +D=A +@14 +M=D +@24140 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +D=A +@13 +M=D +@23251 +D=A +@14 +M=D +@24224 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@3 +D=A +@13 +M=D +@23251 +D=A +@14 +M=D +@24302 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@13 +M=D +@23251 +D=A +@14 +M=D +@24381 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@13 +M=D +@23251 +D=A +@14 +M=D +@24460 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@3 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@24473 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@24495 +D=A +@38 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24512 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@24532 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@255 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24554 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@24566 +D;JNE +@24589 +0;JMP +@12 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@24584 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +M=M+1 +A=M-1 +M=0 +@24617 +D=A +@38 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@511 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24647 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +M=M+1 +A=M-1 +M=0 +@24680 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@255 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@24715 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@24727 +D;JNE +@24750 +0;JMP +@13 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@24745 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@13 +M=D +@24151 +D=A +@14 +M=D +@24828 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@24851 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@25099 +D;JNE +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@24875 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@24882 +D;JNE +@24940 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@24915 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@25030 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@24985 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@5 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@4 +D=A +@13 +M=D +@24151 +D=A +@14 +M=D +@25092 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@24833 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@8643 +D=A +@14 +M=D +@25123 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@25143 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@25150 +D;JNE +@25173 +0;JMP +@14 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@25168 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@25188 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@25195 +D;JNE +@25220 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@25214 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@3 +A=M+1 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@25279 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +@25286 +D;JNE +@25310 +0;JMP +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5877 +D=A +@14 +M=D +@25305 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@9357 +D=A +@14 +M=D +@25328 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@25388 +D=A +@38 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25407 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25431 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@25443 +D;JNE +@25466 +0;JMP +@15 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@25461 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@25526 +D=A +@38 +0;JMP +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25545 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25569 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +AM=M-1 +D=M +@25581 +D;JNE +@25604 +0;JMP +@16 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@25599 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@25690 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@25697 +D;JNE +@25720 +0;JMP +@17 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@25715 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@3 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@25829 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@25836 +D;JNE +@25859 +0;JMP +@18 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@25854 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@5 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@25891 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@25926 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@25933 +D;JNE +@25939 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@45 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@25992 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@25999 +D;JNE +@26025 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +A=A+1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@26044 +D=A +@38 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D&M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@26249 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@26131 +D=A +@38 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@9 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@26149 +D=A +@22 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=D|M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@26181 +D;JNE +@26247 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@26206 +D=A +@95 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@26025 +0;JMP +@1 +D=M +@4 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@26265 +D;JNE +@26282 +0;JMP +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@4 +D=A +D=D-1 +@0 +AM=M+1 +A=A-1 +M=0 +@26293 +D;JGT +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@3 +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@26327 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@26334 +D;JNE +@26357 +0;JMP +@19 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@26352 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@6 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5808 +D=A +@14 +M=D +@26375 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@26397 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@26404 +D;JNE +@26436 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@1 +A=M+1 +A=A+1 +A=A+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +A=M-1 +D=!M +M=D+1 +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@26464 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@26630 +D;JNE +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@7287 +D=A +@14 +M=D +@26497 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@1 +A=M+1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@10 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@6822 +D=A +@14 +M=D +@26561 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@2 +A=M+1 +M=D +@26449 +0;JMP +@1 +D=M +@3 +A=D+A +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@26646 +D;JNE +@26716 +0;JMP +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@45 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@3 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@26734 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@26741 +D;JNE +@26764 +0;JMP +@19 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@26759 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@26779 +D=A +@6 +0;JMP +@0 +AM=M-1 +D=M +@26786 +D;JNE +@26843 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@48 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@27003 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@26873 +D=A +@38 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@27003 +D;JNE +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@4 +M=D +@4 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@5 +M=D +@0 +AM=M-1 +D=M +@4 +M=D +@5 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@4 +A=M +M=D +@3 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=D+M +@0 +AM=M-1 +D=M +@3 +A=M+1 +A=A+1 +M=D +@26854 +0;JMP +@1 +A=M+1 +A=A+1 +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@5877 +D=A +@14 +M=D +@27023 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@128 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@129 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@34 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@54 +0;JMP +@0 +D=A +@13 +M=D +@8453 +D=A +@14 +M=D +@27070 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@6505 +D=A +@14 +M=D +@27087 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@20329 +D=A +@14 +M=D +@27104 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@9854 +D=A +@14 +M=D +@27121 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@5918 +D=A +@14 +M=D +@27138 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@3837 +D=A +@14 +M=D +@27155 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@27177 +D=A +@14 +M=D +@27172 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@0 +A=M-1 +M=!M +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@27194 +D;JNE +@27177 +0;JMP +@0 +AM=M+1 +A=A-1 +M=0 +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@27213 +D=A +@38 +0;JMP +@0 +AM=M-1 +D=M +@27220 +D;JNE +@27241 +0;JMP +@0 +M=M+1 +A=M-1 +M=1 +@1 +D=A +@13 +M=D +@27353 +D=A +@14 +M=D +@27236 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@27256 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@27347 +D;JNE +@50 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=0 +@27291 +D=A +@22 +0;JMP +@0 +A=M-1 +M=!M +@0 +AM=M-1 +D=M +@27323 +D;JNE +@1 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@1 +A=M +M=D +@27276 +0;JMP +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@0 +M=M+1 +A=M-1 +M=1 +@0 +AM=M-1 +D=M +A=A-1 +M=M-D +@0 +AM=M-1 +D=M +@2 +A=M +M=D +@27241 +0;JMP +@0 +M=M+1 +A=M-1 +M=0 +@54 +0;JMP +@3 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@25105 +D=A +@14 +M=D +@27371 +D=A +@95 +0;JMP +@69 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@27389 +D=A +@95 +0;JMP +@82 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@27407 +D=A +@95 +0;JMP +@82 +D=A +@0 +AM=M+1 +A=A-1 +M=D +@2 +D=A +@13 +M=D +@25659 +D=A +@14 +M=D +@27425 +D=A +@95 +0;JMP +@1 +D=A +@13 +M=D +@19850 +D=A +@14 +M=D +@27437 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@2 +A=M +D=M +@0 +AM=M+1 +A=A-1 +M=D +@1 +D=A +@13 +M=D +@19981 +D=A +@14 +M=D +@27461 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D +@0 +D=A +@13 +M=D +@27177 +D=A +@14 +M=D +@27478 +D=A +@95 +0;JMP +@0 +AM=M-1 +D=M +@5 +M=D diff --git a/projects/06/rect/Rect.asm b/projects/06/rect/Rect.asm new file mode 100755 index 0000000..6cbbaeb --- /dev/null +++ b/projects/06/rect/Rect.asm @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/06/rect/Rect.asm + +// Draws a rectangle at the top-left corner of the screen. +// The rectangle is 16 pixels wide and R0 pixels high. + + @0 + D=M + @INFINITE_LOOP + D;JLE + @counter + M=D + @SCREEN + D=A + @address + M=D +(LOOP) + @address + A=M + M=-1 + @address + D=M + @32 + D=D+A + @address + M=D + @counter + MD=M-1 + @LOOP + D;JGT +(INFINITE_LOOP) + @INFINITE_LOOP + 0;JMP diff --git a/projects/06/rect/Rect.hack b/projects/06/rect/Rect.hack new file mode 100755 index 0000000..ee017ab --- /dev/null +++ b/projects/06/rect/Rect.hack @@ -0,0 +1,25 @@ +0000000000000000 +1111110000010000 +0000000000010111 +1110001100000110 +0000000000010000 +1110001100001000 +0100000000000000 +1110110000010000 +0000000000010001 +1110001100001000 +0000000000010001 +1111110000100000 +1110111010001000 +0000000000010001 +1111110000010000 +0000000000100000 +1110000010010000 +0000000000010001 +1110001100001000 +0000000000010000 +1111110010011000 +0000000000001010 +1110001100000001 +0000000000010111 +1110101010000111 diff --git a/projects/06/rect/RectL.asm b/projects/06/rect/RectL.asm new file mode 100755 index 0000000..e97c09b --- /dev/null +++ b/projects/06/rect/RectL.asm @@ -0,0 +1,32 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/06/rect/RectL.asm + +// Symbol-less version of the Rect.asm program. + +@0 +D=M +@23 +D;JLE +@16 +M=D +@16384 +D=A +@17 +M=D +@17 +A=M +M=-1 +@17 +D=M +@32 +D=D+A +@17 +M=D +@16 +MD=M-1 +@10 +D;JGT +@23 +0;JMP diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.asm b/projects/07/MemoryAccess/BasicTest/BasicTest.asm new file mode 100755 index 0000000..b2ce277 --- /dev/null +++ b/projects/07/MemoryAccess/BasicTest/BasicTest.asm @@ -0,0 +1,232 @@ +@10 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@0 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@0 +D=A +@LCL +M=M-D +@21 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@22 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@ARG +M=M+D +@SP +M=M-1 +A=M +D=M +@ARG +A=M +M=D +@2 +D=A +@ARG +M=M-D +@1 +D=A +@ARG +M=M+D +@SP +M=M-1 +A=M +D=M +@ARG +A=M +M=D +@1 +D=A +@ARG +M=M-D +@36 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@6 +D=A +@THIS +M=M+D +@SP +M=M-1 +A=M +D=M +@THIS +A=M +M=D +@6 +D=A +@THIS +M=M-D +@42 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@45 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@5 +D=A +@THAT +M=M+D +@SP +M=M-1 +A=M +D=M +@THAT +A=M +M=D +@5 +D=A +@THAT +M=M-D +@2 +D=A +@THAT +M=M+D +@SP +M=M-1 +A=M +D=M +@THAT +A=M +M=D +@2 +D=A +@THAT +M=M-D +@510 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +@11 +M=D +@0 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@5 +D=A +@THAT +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +@1 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +@6 +D=A +@THIS +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@6 +D=A +@THIS +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +@11 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.cmp b/projects/07/MemoryAccess/BasicTest/BasicTest.cmp new file mode 100755 index 0000000..538454b --- /dev/null +++ b/projects/07/MemoryAccess/BasicTest/BasicTest.cmp @@ -0,0 +1,2 @@ +|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] | +| 472 | 10 | 21 | 22 | 36 | 42 | 45 | 510 | diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.out b/projects/07/MemoryAccess/BasicTest/BasicTest.out new file mode 100755 index 0000000..538454b --- /dev/null +++ b/projects/07/MemoryAccess/BasicTest/BasicTest.out @@ -0,0 +1,2 @@ +|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] | +| 472 | 10 | 21 | 22 | 36 | 42 | 45 | 510 | diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.tst b/projects/07/MemoryAccess/BasicTest/BasicTest.tst new file mode 100755 index 0000000..fa6d9a6 --- /dev/null +++ b/projects/07/MemoryAccess/BasicTest/BasicTest.tst @@ -0,0 +1,25 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/BasicTest/BasicTest.tst + +load BasicTest.asm, +output-file BasicTest.out, +compare-to BasicTest.cmp, +output-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 + RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1 + RAM[3015]%D1.6.1 RAM[11]%D1.6.1; + +set RAM[0] 256, // stack pointer +set RAM[1] 300, // base address of the local segment +set RAM[2] 400, // base address of the argument segment +set RAM[3] 3000, // base address of the this segment +set RAM[4] 3010, // base address of the that segment + +repeat 600 { // enough cycles to complete the execution + ticktock; +} + +// Outputs the stack base and some values +// from the tested memory segments +output; diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.vm b/projects/07/MemoryAccess/BasicTest/BasicTest.vm new file mode 100755 index 0000000..b2f9343 --- /dev/null +++ b/projects/07/MemoryAccess/BasicTest/BasicTest.vm @@ -0,0 +1,31 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/BasicTest/BasicTest.vm + +// Executes pop and push commands using the virtual memory segments. +push constant 10 +pop local 0 +push constant 21 +push constant 22 +pop argument 2 +pop argument 1 +push constant 36 +pop this 6 +push constant 42 +push constant 45 +pop that 5 +pop that 2 +push constant 510 +pop temp 6 +push local 0 +push that 5 +add +push argument 1 +sub +push this 6 +push this 6 +add +sub +push temp 6 +add diff --git a/projects/07/MemoryAccess/BasicTest/BasicTestVME.tst b/projects/07/MemoryAccess/BasicTest/BasicTestVME.tst new file mode 100755 index 0000000..24e9090 --- /dev/null +++ b/projects/07/MemoryAccess/BasicTest/BasicTestVME.tst @@ -0,0 +1,25 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/BasicTest/BasicTestVME.tst + +load BasicTest.vm, +output-file BasicTest.out, +compare-to BasicTest.cmp, +output-list RAM[256]%D1.6.1 RAM[300]%D1.6.1 RAM[401]%D1.6.1 + RAM[402]%D1.6.1 RAM[3006]%D1.6.1 RAM[3012]%D1.6.1 + RAM[3015]%D1.6.1 RAM[11]%D1.6.1; + +set sp 256, // stack pointer +set local 300, // base address of the local segment +set argument 400, // base address of the argument segment +set this 3000, // base address of the this segment +set that 3010, // base address of the that segment + +repeat 25 { // BasicTest.vm has 25 instructions + vmstep; +} + +// Outputs the stack base and some values +// from the tested memory segments +output; diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.asm b/projects/07/MemoryAccess/PointerTest/PointerTest.asm new file mode 100755 index 0000000..597ce79 --- /dev/null +++ b/projects/07/MemoryAccess/PointerTest/PointerTest.asm @@ -0,0 +1,122 @@ +@3030 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +@3 +M=D +@3040 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +@4 +M=D +@32 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@2 +D=A +@THIS +M=M+D +@SP +M=M-1 +A=M +D=M +@THIS +A=M +M=D +@2 +D=A +@THIS +M=M-D +@46 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@6 +D=A +@THAT +M=M+D +@SP +M=M-1 +A=M +D=M +@THAT +A=M +M=D +@6 +D=A +@THAT +M=M-D +@3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@4 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +@2 +D=A +@THIS +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +@6 +D=A +@THAT +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.cmp b/projects/07/MemoryAccess/PointerTest/PointerTest.cmp new file mode 100755 index 0000000..b59fa97 --- /dev/null +++ b/projects/07/MemoryAccess/PointerTest/PointerTest.cmp @@ -0,0 +1,2 @@ +|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046| +| 6084 | 3030 | 3040 | 32 | 46 | diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.tst b/projects/07/MemoryAccess/PointerTest/PointerTest.tst new file mode 100755 index 0000000..cd5515d --- /dev/null +++ b/projects/07/MemoryAccess/PointerTest/PointerTest.tst @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/PointerTest/PointerTest.tst + +load PointerTest.asm, +output-file PointerTest.out, +compare-to PointerTest.cmp, +output-list RAM[256]%D1.6.1 RAM[3]%D1.6.1 + RAM[4]%D1.6.1 RAM[3032]%D1.6.1 RAM[3046]%D1.6.1; + +set RAM[0] 256, // initializes the stack pointer + +repeat 450 { // enough cycles to complete the execution + ticktock; +} + +// outputs the stack base, this, that, and +// some values from the the this and that segments +output; diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.vm b/projects/07/MemoryAccess/PointerTest/PointerTest.vm new file mode 100755 index 0000000..5b0a109 --- /dev/null +++ b/projects/07/MemoryAccess/PointerTest/PointerTest.vm @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/PointerTest/PointerTest.vm + +// Executes pop and push commands using the +// pointer, this, and that segments. +push constant 3030 +pop pointer 0 +push constant 3040 +pop pointer 1 +push constant 32 +pop this 2 +push constant 46 +pop that 6 +push pointer 0 +push pointer 1 +add +push this 2 +sub +push that 6 +add diff --git a/projects/07/MemoryAccess/PointerTest/PointerTestVME.tst b/projects/07/MemoryAccess/PointerTest/PointerTestVME.tst new file mode 100755 index 0000000..1b395c2 --- /dev/null +++ b/projects/07/MemoryAccess/PointerTest/PointerTestVME.tst @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/PointerTest/PointerTestVME.tst + +load PointerTest.vm, +output-file PointerTest.out, +compare-to PointerTest.cmp, +output-list RAM[256]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1 + RAM[3032]%D1.6.1 RAM[3046]%D1.6.1; + +set RAM[0] 256, // initializes the stack pointer + +repeat 15 { // PointerTest.vm has 15 instructions + vmstep; +} + +// outputs the stack base, this, that, and +// some values from the the this and that segments +output; diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.asm b/projects/07/MemoryAccess/StaticTest/StaticTest.asm new file mode 100755 index 0000000..4c667e6 --- /dev/null +++ b/projects/07/MemoryAccess/StaticTest/StaticTest.asm @@ -0,0 +1,72 @@ +@111 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@333 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@888 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +@StaticTest.vm.8 +M=D +@SP +M=M-1 +A=M +D=M +@StaticTest.vm.3 +M=D +@SP +M=M-1 +A=M +D=M +@StaticTest.vm.1 +M=D +@StaticTest.vm.3 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@StaticTest.vm.1 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +@StaticTest.vm.8 +D=M +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.cmp b/projects/07/MemoryAccess/StaticTest/StaticTest.cmp new file mode 100755 index 0000000..29f4bf0 --- /dev/null +++ b/projects/07/MemoryAccess/StaticTest/StaticTest.cmp @@ -0,0 +1,2 @@ +|RAM[256]| +| 1110 | diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.tst b/projects/07/MemoryAccess/StaticTest/StaticTest.tst new file mode 100755 index 0000000..1f23d66 --- /dev/null +++ b/projects/07/MemoryAccess/StaticTest/StaticTest.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/StaticTest/StaticTest.tst + +load StaticTest.asm, +output-file StaticTest.out, +compare-to StaticTest.cmp, +output-list RAM[256]%D1.6.1; + +set RAM[0] 256, // initializes the stack pointer + +repeat 200 { // enough cycles to complete the execution + ticktock; +} + +output; // the stack base diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.vm b/projects/07/MemoryAccess/StaticTest/StaticTest.vm new file mode 100755 index 0000000..65b4f6f --- /dev/null +++ b/projects/07/MemoryAccess/StaticTest/StaticTest.vm @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/StaticTest/StaticTest.vm + +// Executes pop and push commands using the static segment. +push constant 111 +push constant 333 +push constant 888 +pop static 8 +pop static 3 +pop static 1 +push static 3 +push static 1 +sub +push static 8 +add diff --git a/projects/07/MemoryAccess/StaticTest/StaticTestVME.tst b/projects/07/MemoryAccess/StaticTest/StaticTestVME.tst new file mode 100755 index 0000000..52882a4 --- /dev/null +++ b/projects/07/MemoryAccess/StaticTest/StaticTestVME.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/MemoryAccess/StaticTest/StaticTestVME.tst + +load StaticTest.vm, +output-file StaticTest.out, +compare-to StaticTest.cmp, +output-list RAM[256]%D1.6.1; + +set sp 256, // initializes the stack pointer + +repeat 11 { // StaticTest.vm has 11 instructions + vmstep; +} + +output; // the stack base diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm new file mode 100755 index 0000000..09e0b11 --- /dev/null +++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm @@ -0,0 +1,20 @@ +@7 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@8 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp new file mode 100755 index 0000000..7a3585b --- /dev/null +++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.cmp @@ -0,0 +1,2 @@ +| RAM[0] | RAM[256] | +| 257 | 15 | diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst new file mode 100755 index 0000000..02dece3 --- /dev/null +++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/StackArithmetic/SimpleAdd/SimpleAdd.tst + +load SimpleAdd.asm, +output-file SimpleAdd.out, +compare-to SimpleAdd.cmp, +output-list RAM[0]%D2.6.2 RAM[256]%D2.6.2; + +set RAM[0] 256, // initializes the stack pointer + +repeat 60 { // enough cycles to complete the execution + ticktock; +} + +output; // the stack pointer and the stack base diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm new file mode 100755 index 0000000..cfd4ee9 --- /dev/null +++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm @@ -0,0 +1,9 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm + +// Pushes and adds two constants. +push constant 7 +push constant 8 +add diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst b/projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst new file mode 100755 index 0000000..5010f4f --- /dev/null +++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/StackArithmetic/SimpleAdd/SimpleAddVME.tst + +load SimpleAdd.vm, +output-file SimpleAdd.out, +compare-to SimpleAdd.cmp, +output-list RAM[0]%D2.6.2 RAM[256]%D2.6.2; + +set RAM[0] 256, // initializes the stack pointer + +repeat 3 { // SimpleAdd.vm has 3 instructions + vmstep; +} + +output; // the stack pointer and the stack base diff --git a/projects/07/StackArithmetic/StackTest/StackTest.asm b/projects/07/StackArithmetic/StackTest/StackTest.asm new file mode 100755 index 0000000..4449f2a --- /dev/null +++ b/projects/07/StackArithmetic/StackTest/StackTest.asm @@ -0,0 +1,373 @@ +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE0 +D;JEQ +@SP +A=M +A=A-1 +M=0 +@FALSE0 +0;JMP +(TRUE0) +@SP +A=M +A=A-1 +M=-1 +(FALSE0) +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@16 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE1 +D;JEQ +@SP +A=M +A=A-1 +M=0 +@FALSE1 +0;JMP +(TRUE1) +@SP +A=M +A=A-1 +M=-1 +(FALSE1) +@16 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@17 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE2 +D;JEQ +@SP +A=M +A=A-1 +M=0 +@FALSE2 +0;JMP +(TRUE2) +@SP +A=M +A=A-1 +M=-1 +(FALSE2) +@892 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE3 +D;JLT +@SP +A=M +A=A-1 +M=0 +@FALSE3 +0;JMP +(TRUE3) +@SP +A=M +A=A-1 +M=-1 +(FALSE3) +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@892 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE4 +D;JLT +@SP +A=M +A=A-1 +M=0 +@FALSE4 +0;JMP +(TRUE4) +@SP +A=M +A=A-1 +M=-1 +(FALSE4) +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@891 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE5 +D;JLT +@SP +A=M +A=A-1 +M=0 +@FALSE5 +0;JMP +(TRUE5) +@SP +A=M +A=A-1 +M=-1 +(FALSE5) +@32767 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE6 +D;JGT +@SP +A=M +A=A-1 +M=0 +@FALSE6 +0;JMP +(TRUE6) +@SP +A=M +A=A-1 +M=-1 +(FALSE6) +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@32767 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE7 +D;JGT +@SP +A=M +A=A-1 +M=0 +@FALSE7 +0;JMP +(TRUE7) +@SP +A=M +A=A-1 +M=-1 +(FALSE7) +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@32766 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE8 +D;JGT +@SP +A=M +A=A-1 +M=0 +@FALSE8 +0;JMP +(TRUE8) +@SP +A=M +A=A-1 +M=-1 +(FALSE8) +@57 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@31 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@53 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +@112 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +@SP +A=M +A=A-1 +M=-M +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M&D +@82 +D=A +@SP +A=M +M=D +@SP +M=M+1 +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M|D +@SP +A=M +A=A-1 +M=!M diff --git a/projects/07/StackArithmetic/StackTest/StackTest.cmp b/projects/07/StackArithmetic/StackTest/StackTest.cmp new file mode 100755 index 0000000..f90fa1b --- /dev/null +++ b/projects/07/StackArithmetic/StackTest/StackTest.cmp @@ -0,0 +1,4 @@ +| RAM[0] | RAM[256] | RAM[257] | RAM[258] | RAM[259] | RAM[260] | +| 266 | -1 | 0 | 0 | 0 | -1 | +| RAM[261] | RAM[262] | RAM[263] | RAM[264] | RAM[265] | +| 0 | -1 | 0 | 0 | -91 | diff --git a/projects/07/StackArithmetic/StackTest/StackTest.tst b/projects/07/StackArithmetic/StackTest/StackTest.tst new file mode 100755 index 0000000..f9c5396 --- /dev/null +++ b/projects/07/StackArithmetic/StackTest/StackTest.tst @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/StackArithmetic/StackTest/StackTest.tst + +load StackTest.asm, +output-file StackTest.out, +compare-to StackTest.cmp, +output-list RAM[0]%D2.6.2 + RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2; + +set RAM[0] 256, // initializes the stack pointer + +repeat 1000 { // enough cycles to complete the execution + ticktock; +} + +// outputs the stack pointer (RAM[0]) and +// the stack contents: RAM[256]-RAM[265] +output; +output-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2; +output; diff --git a/projects/07/StackArithmetic/StackTest/StackTest.vm b/projects/07/StackArithmetic/StackTest/StackTest.vm new file mode 100755 index 0000000..bfe78e0 --- /dev/null +++ b/projects/07/StackArithmetic/StackTest/StackTest.vm @@ -0,0 +1,45 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/StackArithmetic/StackTest/StackTest.vm + +// Executes a sequence of arithmetic and logical operations +// on the stack. +push constant 17 +push constant 17 +eq +push constant 17 +push constant 16 +eq +push constant 16 +push constant 17 +eq +push constant 892 +push constant 891 +lt +push constant 891 +push constant 892 +lt +push constant 891 +push constant 891 +lt +push constant 32767 +push constant 32766 +gt +push constant 32766 +push constant 32767 +gt +push constant 32766 +push constant 32766 +gt +push constant 57 +push constant 31 +push constant 53 +add +push constant 112 +sub +neg +and +push constant 82 +or +not diff --git a/projects/07/StackArithmetic/StackTest/StackTestVME.tst b/projects/07/StackArithmetic/StackTest/StackTestVME.tst new file mode 100755 index 0000000..b66bd05 --- /dev/null +++ b/projects/07/StackArithmetic/StackTest/StackTestVME.tst @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/07/StackArithmetic/StackTest/StackTestVME.tst + +load StackTest.vm, +output-file StackTest.out, +compare-to StackTest.cmp, +output-list RAM[0]%D2.6.2 + RAM[256]%D2.6.2 RAM[257]%D2.6.2 RAM[258]%D2.6.2 RAM[259]%D2.6.2 RAM[260]%D2.6.2; + +set RAM[0] 256, // initializes the stack pointer + +repeat 38 { // StackTest.vm consists of 38 instructions + vmstep; +} + +// outputs the stack pointer (RAM[0]) and +// the stack contents: RAM[256]-RAM[265] +output; +output-list RAM[261]%D2.6.2 RAM[262]%D2.6.2 RAM[263]%D2.6.2 RAM[264]%D2.6.2 RAM[265]%D2.6.2; +output; diff --git a/projects/07/VMTranslator.py b/projects/07/VMTranslator.py new file mode 100755 index 0000000..9afbca4 --- /dev/null +++ b/projects/07/VMTranslator.py @@ -0,0 +1,160 @@ +import os +import sys +from pathlib import Path + +trueCounter = 0 +falseCounter = 0 +staticCounter = 16 + + +def clear_file(temp_string_cf, asmfile): # clears the empty lines, comments and spaces and writes them in a string + for line in asmfile: + f = 0 + if line == '\n': # removes empty lines + continue + for index in range(len(line)): + if line[index] == "/" and line[index + 1] == '/': # checks if it is comment + if f == 1: # maybe a problem if the last element of a line is / since it will stay + temp_string_cf += '\n' + break + if line[index] != ' ': # removes all of the whitespaces except newlines + temp_string_cf += line[index] + f = 1 + return temp_string_cf + + +def push(line): + global tempString1 + if line[4:8] == 'this': + number = int(line[8:]) + line = '@' + str(number) + '\nD=A\n@THIS\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:8] == 'that': + number = int(line[8:]) + line = '@' + str(number) + '\nD=A\n@THAT\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:8] == 'temp': + number = int(line[8:]) + number += 5 + line = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:9] == 'local': + number = int(line[9:]) + line = '@' + str(number) + '\nD=A\n@LCL\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:10] == 'static': + number = int(line[10:]) + line = '@' + name1 + '.' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:11] == 'pointer': + number = int(line[11:]) + number += 3 + line = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:12] == 'argument': + number = int(line[12:]) + line = '@' + str(number) + '\nD=A\n@ARG\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:12] == 'constant': + number = line[12:] + line = '@' + str(number) + '\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + tempString1 += line + + +def pop(line): + global SP + global tempString1 + if line[3:7] == 'this': + number = int(line[7:]) + line = '@' + str(number) + '\nD=A\n@THIS\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THIS\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THIS\nM=M-D\n' + elif line[3:7] == 'that': + number = int(line[7:]) + line = '@' + str(number) + '\nD=A\n@THAT\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THAT\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THAT\nM=M-D\n' + elif line[3:7] == 'temp': + number = int(line[7:]) + number = number + 5 + line = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n' + elif line[3:8] == 'local': + number = int(line[8:]) + line = '@' + str(number) + '\nD=A\n@LCL\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@LCL\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@LCL\nM=M-D\n' + elif line[3:9] == 'static': + number = int(line[9:]) + line = '@SP\nM=M-1\nA=M\nD=M\n@' + name1 + '.' + str(number) + '\nM=D\n' + elif line[3:10] == 'pointer': + number = int(line[10:]) + number = number + 3 + line = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n' + elif line[3:11] == 'argument': + number = int(line[11:]) + line = '@' + str(number) + '\nD=A\n@ARG\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@ARG\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@ARG\nM=M-D\n' + tempString1 += line + + +def aritmetic(line): + global trueCounter + global falseCounter + global tempString1 + if line == 'add': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M+D\n" + elif line == 'sub': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M-D\n" + elif line == 'neg': + line = "@SP\nA=M\nA=A-1\nM=-M\n" + elif line == 'eq': + line = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JEQ\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n' + trueCounter += 1 + falseCounter += 1 + elif line == 'gt': + line = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JGT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n' + trueCounter += 1 + falseCounter += 1 + elif line == 'lt': + line = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JLT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n' + trueCounter += 1 + falseCounter += 1 + elif line == 'and': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M&D\n" + elif line == 'or': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M|D\n" + elif line == 'not': + line = "@SP\nA=M\nA=A-1\nM=!M\n" + tempString1 += line + + +name1 = None +line, tempString = '', '' +tempString1 = '' +aritmeticList3 = ['add', 'sub', 'neg', 'and', 'not'] +aritmeticList2 = ['or', 'gt', 'lt', 'eq'] +yourpath = os.getcwd() +for root, dirs, files in os.walk(yourpath, topdown=False): + nam1 = '' + for name in files: + if name[-3:] == '.vm': + name1 = name + tempString1 = '' + tempString = '' + with open(Path(root, name), "r+") as vmfile: + tempString = clear_file(tempString, vmfile) + for j in tempString: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + if line[:4] == 'push': + push(line) + line = '' + elif line[:3] == 'pop': + pop(line) + line = '' + elif line[:2] in aritmeticList2 or line[:3] in aritmeticList3: + aritmetic(line) + line = '' + if name1 == name: + with open(Path(root, f'{name1[:-3]}.asm'), 'w+') as newfile: + newfile.write(tempString1) diff --git a/projects/07/lang.txt b/projects/07/lang.txt new file mode 100755 index 0000000..0d636da --- /dev/null +++ b/projects/07/lang.txt @@ -0,0 +1 @@ +python3 debug \ No newline at end of file diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm new file mode 100755 index 0000000..55ae771 --- /dev/null +++ b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm @@ -0,0 +1,447 @@ +@256 +D=A +@SP +M=D +@MainLoopXYZRA +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 +@0 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Sys.init +0;JMP +(MainLoopXYZRARA) +//CALLFUNC +(Sys.init) +@4 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@Main.fibonacci2RA +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 +@1 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Main.fibonacci +0;JMP +(Main.fibonacci2RA) +//CALLFUNC +(Sys.init$WHILE) +//LABEL +@Sys.init$WHILE +0;JMP +//GOTO +(Main.fibonacci) +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +D=M-D +@TRUE0 +D;JLT +@SP +A=M +A=A-1 +M=0 +@FALSE0 +0;JMP +(TRUE0) +@SP +A=M +A=A-1 +M=-1 +(FALSE0) +//LT +@SP +M=M-1 +A=M +D=M +@Main.fibonacci$IF_TRUE +D;JNE +//IFGOTO +@Main.fibonacci$IF_FALSE +0;JMP +//GOTO +(Main.fibonacci$IF_TRUE) +//LABEL +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN +(Main.fibonacci$IF_FALSE) +//LABEL +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@Main.fibonacci0RA +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 +@1 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Main.fibonacci +0;JMP +(Main.fibonacci0RA) +//CALLFUNC +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@Main.fibonacci1RA +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 +@1 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Main.fibonacci +0;JMP +(Main.fibonacci1RA) +//CALLFUNC +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.cmp b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.cmp new file mode 100755 index 0000000..d667834 --- /dev/null +++ b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.cmp @@ -0,0 +1,2 @@ +| RAM[0] |RAM[261]| +| 262 | 3 | diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.out b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.out new file mode 100755 index 0000000..d667834 --- /dev/null +++ b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.out @@ -0,0 +1,2 @@ +| RAM[0] |RAM[261]| +| 262 | 3 | diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst new file mode 100755 index 0000000..1f907b1 --- /dev/null +++ b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/FibonacciElement/FibonacciElement.tst + +// FibonacciElement.asm results from translating both Main.vm and Sys.vm into +// a single assembly program, stored in the file FibonacciElement.asm. + +load FibonacciElement.asm, +output-file FibonacciElement.out, +compare-to FibonacciElement.cmp, +output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1; + +repeat 6000 { + ticktock; +} + +output; diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst b/projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst new file mode 100755 index 0000000..87c0920 --- /dev/null +++ b/projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/FibonacciElement/FibonacciElementVME.tst + +load, // Load all the VM files from the current directory +output-file FibonacciElement.out, +compare-to FibonacciElement.cmp, +output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1; + +set sp 261, + +repeat 110 { + vmstep; +} + +output; diff --git a/projects/08/FunctionCalls/FibonacciElement/Main.vm b/projects/08/FunctionCalls/FibonacciElement/Main.vm new file mode 100755 index 0000000..55e5ad2 --- /dev/null +++ b/projects/08/FunctionCalls/FibonacciElement/Main.vm @@ -0,0 +1,30 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/FibonacciElement/Main.vm + +// Computes the n'th element of the Fibonacci series, recursively. +// n is given in argument[0]. Called by the Sys.init function +// (part of the Sys.vm file), which also pushes the argument[0] +// parameter before this code starts running. + +function Main.fibonacci 0 +push argument 0 +push constant 2 +lt // checks if n<2 +if-goto IF_TRUE +goto IF_FALSE +label IF_TRUE // if n<2, return n +push argument 0 +return +label IF_FALSE // if n>=2, returns fib(n-2)+fib(n-1) +push argument 0 +push constant 2 +sub +call Main.fibonacci 1 // computes fib(n-2) +push argument 0 +push constant 1 +sub +call Main.fibonacci 1 // computes fib(n-1) +add // returns fib(n-1) + fib(n-2) +return diff --git a/projects/08/FunctionCalls/FibonacciElement/Sys.vm b/projects/08/FunctionCalls/FibonacciElement/Sys.vm new file mode 100755 index 0000000..f3965c9 --- /dev/null +++ b/projects/08/FunctionCalls/FibonacciElement/Sys.vm @@ -0,0 +1,15 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/FibonacciElement/Sys.vm + +// Pushes a constant, say n, onto the stack, and calls the Main.fibonacii +// function, which computes the n'th element of the Fibonacci series. +// Note that by convention, the Sys.init function is called "automatically" +// by the bootstrap code. + +function Sys.init 0 +push constant 4 +call Main.fibonacci 1 // computes the 4'th fibonacci element +label WHILE +goto WHILE // loops infinitely diff --git a/projects/08/FunctionCalls/NestedCall/NestedCall.asm b/projects/08/FunctionCalls/NestedCall/NestedCall.asm new file mode 100755 index 0000000..eae43b1 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCall.asm @@ -0,0 +1,598 @@ +@256 +D=A +@SP +M=D +@MainLoopXYZRA +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 +@0 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Sys.init +0;JMP +(MainLoopXYZRARA) +//CALLFUNC +(Sys.init) +@4000 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@3 +M=D +//pop POINTER +@5000 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@Sys.main3RA +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 +@0 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Sys.main +0;JMP +(Sys.main3RA) +//CALLFUNC +@SP +M=M-1 +A=M +D=M +@6 +M=D +//pop TMP +(Sys.init$LOOP) +//LABEL +@Sys.init$LOOP +0;JMP +//GOTO +(Sys.main) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@4001 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@3 +M=D +//pop POINTER +@5001 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@200 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@1 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@1 +D=A +@LCL +M=M-D +//pop LOCAL +@40 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@2 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@2 +D=A +@LCL +M=M-D +//pop LOCAL +@6 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@3 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@3 +D=A +@LCL +M=M-D +//pop LOCAL +@123 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@Sys.add124RA +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 +@1 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Sys.add12 +0;JMP +(Sys.add124RA) +//CALLFUNC +@SP +M=M-1 +A=M +D=M +@5 +M=D +//pop TMP +@0 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@1 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@2 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@3 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@4 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN +(Sys.add12) +@4002 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@3 +M=D +//pop POINTER +@5002 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@12 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN diff --git a/projects/08/FunctionCalls/NestedCall/NestedCall.cmp b/projects/08/FunctionCalls/NestedCall/NestedCall.cmp new file mode 100755 index 0000000..9200202 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCall.cmp @@ -0,0 +1,2 @@ +| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] | RAM[5] | RAM[6] | +| 261 | 261 | 256 | 4000 | 5000 | 135 | 246 | diff --git a/projects/08/FunctionCalls/NestedCall/NestedCall.html b/projects/08/FunctionCalls/NestedCall/NestedCall.html new file mode 100755 index 0000000..0d8534d --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCall.html @@ -0,0 +1,196 @@ + + + + + NestedCall.tst — Nand2Tetris Calling Convention Test + + + + +

Synopsis

+NestedCall.tst is an intermediate test (in terms of complexity) intended to be used between the SimpleFunction and +FibonacciElement tests. It may be useful when SimpleFunction passes but FibonacciElement fails or crashes. NestedCall also +tests several requirements of the Function Calling Protocol that are not verified by the other +supplied tests. NestedCall can be used with or without the VM bootstrap code. +

+NestedCallVME.tst runs the same test on the VM Emulator. +

+The NestedCall tests and supporting documentation were written by Mark Armbrust. + + +

Test Structure

+

Startup

+NestedCall is implemented entirely within the Sys.vm file. The first function in Sys.vm is +Sys.init(). This allows it to be used before the bootstrap code has been added to the VM Translator +since there will be no file processing order issues. +

+NestedCall loads NestedCall.asm, sets up the stack to simulate the bootstrap's call to Sys.init(), then +begins execution at the beginning of NestedCall.asm. If the bootstrap is not present, the program begins +running with Sys.init() since it is the first function in Sys.vm. +

+If NestedCall.asm includes the bootstrap, the bootstrap will (re)initialize the stack and call Sys.init(), +so the test should see the same environment either way it gets to Sys.init(). +

+The test setup also initializes the LCL, ARG, THIS and THAT pointers to -1, -2, -3 and -4. + +

Sys.init()

+ +THIS and THAT are set to known values so that context save and restore can be tested. +

+Sys.init() calls Sys.main() and stores the return value in temp 1. This tests call to and +return from a function with no arguments. + +

Sys.main()

+Sys.main() allocates 5 local variables. It sets local 1, local 2 and +local 3. local 0 and local 4 are intentionally not set. +

+THIS and THAT are changed so that context save and restore can be tested. +

+Sys.main() calls Sys.add12(123) and stores the return value in temp 0. This tests call to and +return from a function with arguments. +

+After Sys.add12() returns, Sys.main() sums local 0 through local 4 and returns the +result. This tests that the local segment was properly allocated on the stack and that the local +variables were not overwritten by the call to Sys.main(). It also tests that local 0 and +local 4 were properly initialized to 0. + +

Sys.add12()

+ +THIS and THAT are set to known values so that context save and restore can be tested. +

+Returns argument 0 plus 12. + + +

Test Coverage

+ +

+Functions with no arguments return to correct RIP (Return Instruction Point) with correct return value on stack.
+This can fail if the RIP is not correctly pushed on the stack by the calling code, or if the returning +code does not store the RIP in a temporary register before overwriting it with the return value. + +

+Functions with arguments return to correct RIP with correct return value on stack.
+This can fail if it is assumed that ARG points to the RIP. + +

+Functions with local variables allocate space on the stack for the local variables.
+This can fail if the function prologue is not written or if the SP is not updated after zeroing +the local variables. + +

+All local variables are initialized to 0.
+Common errors are to forget this completely, or for the zeroing loop to be off by one. + +

+THIS and THAT are correctly retained across function calls. Looking ahead, in Project 9 you will be asked to write a simple computer game in the high-level Jack language. You can run your game (following compilation) on the supplied VM Emulator. But, if you choose to translate the VM code that the compiler generates using your VM Translator, then code like +"push THIS, push THAT ... pop THIS, pop THAT" can cause some interesting failures! + + +

Debugging

+These comments assume that your VM translator has passed the SimpleFunction test. +

+If RAM[0] is incorrect, you have a stack skew. More data was pushed onto the stack by +call than was popped by return, or vice versa. See debugging with +breakpoints later in this section. +

+If one or more of RAM[1] through RAM[4] is incorrect, the LCL, +ARG, THIS and THAT pointers are not being correctly saved or restored. +Most likely problem is when they are being saved; the SimpleFunction test verified that +return restored them correctly. +

+If RAM[5] is incorrect there may be a problem with setting up the ARG pointer. +

+If RAM[4] is incorrect and RAM[5] is correct, there may be a problem with +allocation or initialization of local variables. + +

Debugging with breakpoints

+ +To find tough bugs you can use the "breakpoint" facility in the CPU Emulator (red flag button). +You can use breakpoints to have you program stop when it gets to a particular RAM address. For +example:
+ • load the NestedCall.tst file,
+ • set a PC breakpoint at the ROM address for (Sys.main),
+ • hit the run button.
+When the CPU Emulator stops at the breakpoint you can inspect the RAM to check the stack and pointers values. +(If the breakpoint isn't hit, you will need to to single-step debug through +your calling code to see why it didn't get there.) +

+Other useful places to set breakpoints are the entry points to the other functions and at the +first and final instructions generated for return commands. +

+NestedCallStack.html shows the expected stack values at various points +during the test. + +

Finding ROM address in your ASM code

+It is not easy to find the ROM locations where you want to set breakpoints, because there is no +one-to-one correspondence between the ASM file line numbers and the ROM addresses. This is made even more +difficult because the supplied CPU Emulator does not display the (LABELS) in its ROM panel. +

+There are two things that you can do to make this easier. +

+

Modify your assembler to generate a listing file.
+A listing file shows all the ASM source lines, including comments, as well as the ROM addresses and +the values of the labels and the instructions. For example, here is a snippet of a listing file generated by an assembler written by Mark Armbrust: +
+   20    16      @i      // i -= 1
+   21  FC88      M=M-1
+             
+   22  FC10      D=M     // if i > 0
+   23     6      @LOOP
+   24  E301      D;JGT   //      goto LOOP
+             
+   25        (STOP)
+   25    25      @STOP
+   26  EA87      0;JMP
+
+Data Symbols
+
+   16 D  i
+
+Code Symbols
+
+    6 C  LOOP
+   17 C  SKIP
+   25 C  STOP
+
+For the Nand2Tetris environment, it is most useful to list the ROM addresses and A-instruction +values in decimal. In the above snippet, the C-instruction values are +listed in hexadecimal. +

+The list file is generated during pass 2 of the Assembler, parallel to generating the .hack file. To +make it easier to handle blank and comment only lines, Mark has Parser.commandType() return +NO_COMMAND for source lines with no command. Mark also added Parser.sourceLine() that returns the +unmodified source line. +

+

Have your VM Translator write the VM source lines as comments in the ASM output.
+For example: +
+    // label LOOP
+(Sys.init$LOOP)
+    // goto LOOP
+@Sys.init$LOOP
+0;JMP
+    //
+    // // Sys.main()
+    // 
+    // // Sets locals 1, 2 and 3, leaving locals 0 and 4 unchanged to test
+    // // default local initialization to 0.  (RAM set to -1 by test setup.)
+    // // Calls Sys.add12(123) and stores return value (135) in temp 0.
+    // // Returns local 0 + local 1 + local 2 + local 3 + local 4 (456) to confirm
+    // // that locals were not mangled by function call.
+    // 
+    // function Sys.main 5
+(Sys.main)
+@5
+D=-A
+($3)
+@SP
+
+Note that comments in the VM source become double comments. Looking ahead, in Project 11 you will be asked to write a compiler for the Jack language. If your compiler will write the Jack source lines as comments in the +generated VM files, this convention will be quite useful. + + + \ No newline at end of file diff --git a/projects/08/FunctionCalls/NestedCall/NestedCall.out b/projects/08/FunctionCalls/NestedCall/NestedCall.out new file mode 100755 index 0000000..9200202 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCall.out @@ -0,0 +1,2 @@ +| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] | RAM[5] | RAM[6] | +| 261 | 261 | 256 | 4000 | 5000 | 135 | 246 | diff --git a/projects/08/FunctionCalls/NestedCall/NestedCall.tst b/projects/08/FunctionCalls/NestedCall/NestedCall.tst new file mode 100755 index 0000000..70e5523 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCall.tst @@ -0,0 +1,65 @@ +// Test file for NestedCall test. + +load NestedCall.asm, +output-file NestedCall.out, +compare-to NestedCall.cmp, +output-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[5]%D1.6.1 RAM[6]%D1.6.1; + +set RAM[0] 261, +set RAM[1] 261, +set RAM[2] 256, +set RAM[3] -3, +set RAM[4] -4, +set RAM[5] -1, // test results +set RAM[6] -1, +set RAM[256] 1234, // fake stack frame from call Sys.init +set RAM[257] -1, +set RAM[258] -2, +set RAM[259] -3, +set RAM[260] -4, + +set RAM[261] -1, // Initialize stack to check for local segment +set RAM[262] -1, // being cleared to zero. +set RAM[263] -1, +set RAM[264] -1, +set RAM[265] -1, +set RAM[266] -1, +set RAM[267] -1, +set RAM[268] -1, +set RAM[269] -1, +set RAM[270] -1, +set RAM[271] -1, +set RAM[272] -1, +set RAM[273] -1, +set RAM[274] -1, +set RAM[275] -1, +set RAM[276] -1, +set RAM[277] -1, +set RAM[278] -1, +set RAM[279] -1, +set RAM[280] -1, +set RAM[281] -1, +set RAM[282] -1, +set RAM[283] -1, +set RAM[284] -1, +set RAM[285] -1, +set RAM[286] -1, +set RAM[287] -1, +set RAM[288] -1, +set RAM[289] -1, +set RAM[290] -1, +set RAM[291] -1, +set RAM[292] -1, +set RAM[293] -1, +set RAM[294] -1, +set RAM[295] -1, +set RAM[296] -1, +set RAM[297] -1, +set RAM[298] -1, +set RAM[299] -1, + +repeat 4000 { + ticktock; +} + +output; diff --git a/projects/08/FunctionCalls/NestedCall/NestedCallStack.html b/projects/08/FunctionCalls/NestedCall/NestedCallStack.html new file mode 100755 index 0000000..70582b6 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCallStack.html @@ -0,0 +1,306 @@ + + + + + NestedCall.tst — Stack Frames + + + + + + + +
+ + + + + + + + + + + +
Bootstrap init
Pointers
0256SP
1-1LCL
2-2ARG
3-3THIS
4-4THAT
Stack
256???←SP

+ This is how my boot­strap code initial­izes the pointers before calling Sys.init(). +

+ Setting the LCL, ARG, THIS and THAT point­ers to known illegal values helps identify + when a pointer is used before it is initial­ized. +

+ (If you are running the NestedCall test with­out boot­strap code, you will not see this state.)

+
+ + + + + + + + + + + + + + + + +
Entry to Sys.init()
Pointers
0261SP
1261LCL
2256ARG
3-3THIS
4-4THAT
Stack
256*Return IP←ARG
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261???←LCL, SP

+ This is how NestedCall.tst initial­izes the pointers and stack. This is what RAM looks + like after my boot­strap calls Sys.init(). +

+ (If your VM trans­lation includes the boot­strap, the -1 through -4 values may be + different if your boot­strap initial­izes them.)

+
+ + + + + + + + + + + + + + + + + + + + +
Entry to Sys.main()
Pointers
0266SP
1266LCL
2261ARG
34000THIS
45000THAT
Stack
256*Return IP
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261*Return IP←ARG
262261Saved LCL
263256Saved ARGSys.main
2644000Saved THIS frame
2655000Saved THAT
266???←LCL, SP
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
After Sys.main() prologue
Pointers
0271SP
1266LCL
2261ARG
34000THIS
45000THAT
Stack
256*Return IP
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261*Return IP←ARG
262261Saved LCL
263256Saved ARGSys.main
2644000Saved THIS frame
2655000Saved THAT
2660local 0←LCL
2670local 1
2680local 2
2690local 3
2700local 4
271???←SP

+ The function prologue is the assembly language code generated for the + "function" VM command. +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Entry to Sys.add12(123)
Pointers
0277SP
1277LCL
2271ARG
34001THIS
45001THAT
Stack
256*Return IP
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261*Return IP
262261Saved LCL
263256Saved ARGSys.main
2644000Saved THIS frame
2655000Saved THAT
2660local 0
267200local 1
26840local 2
2696local 3
2700local 4
271123argument 0←ARG
272*Return IP
273266Saved LCLSys.add12
274261Saved ARG frame
2754001Saved THIS
2765001Saved THAT
277???←LCL, SP
+
+ +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Before Sys.add12() return
Pointers
0278SP
1277LCL
2271ARG
34002THIS
45002THAT
Stack
256*Return IP
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261*Return IP
262261Saved LCL
263256Saved ARGSys.main
2644000Saved THIS frame
2655000Saved THAT
2660local 0
267200local 1
26840local 2
2696local 3
2700local 4
271123argument 0←ARG
272*Return IP
273266Saved LCLSys.add12
274261Saved ARG frame
2754001Saved THIS
2765001Saved THAT
277135Return value←LCL
278???←SP
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
After Sys.add12() return
Pointers
0272SP
1266LCL
2261ARG
34001THIS
45001THAT
Stack
256*Return IP
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261*Return IP←ARG
262261Saved LCL
263256Saved ARGSys.main
2644000Saved THIS frame
2655000Saved THAT
2660local 0←LCL
267200local 1
26840local 2
2696local 3
2700local 4
271135Return value
272???←SP
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Before Sys.main() return
Pointers
0272SP
1266LCL
2261ARG
34001THIS
45001THAT
Stack
256*Return IP
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261*Return IP←ARG
262261Saved LCL
263256Saved ARGSys.main
2644000Saved THIS frame
2655000Saved THAT
2660local 0←LCL
267200local 1
26840local 2
2696local 3
2700local 4
271246Return value
272???←SP
+
+ + + + + + + + + + + + + + + + +
After Sys.main() return
Pointers
0262SP
1261LCL
2256ARG
34000THIS
45000THAT
Stack
256*Return IP←ARG
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261246Return value←LCL
262???←SP
+
+ + + + + + + + + + + + + + + +
In Sys.init() halt loop
Pointers
0261SP
1261LCL
2256ARG
34000THIS
45000THAT
Stack
256*Return IP←ARG
257-1Saved LCL
258-2Saved ARGSys.init
259-3Saved THIS frame
260-4Saved THAT
261???←LCL, SP
+
+ + + \ No newline at end of file diff --git a/projects/08/FunctionCalls/NestedCall/NestedCallVME.tst b/projects/08/FunctionCalls/NestedCall/NestedCallVME.tst new file mode 100755 index 0000000..2c689b8 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCallVME.tst @@ -0,0 +1,70 @@ +// Test file for NestedCall test. + +load Sys.vm, +output-file NestedCall.out, +compare-to NestedCall.cmp, +output-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[5]%D1.6.1 RAM[6]%D1.6.1; + +set RAM[0] 261, +set RAM[1] 261, +set RAM[2] 256, +set RAM[3] -3, +set RAM[4] -4, +set RAM[5] -1, // test results +set RAM[6] -1, +set RAM[256] 1234, // fake stack frame from call Sys.init +set RAM[257] -1, +set RAM[258] -2, +set RAM[259] -3, +set RAM[260] -4, + +set RAM[261] -1, // Initialize stack to check for local segment +set RAM[262] -1, // being cleared to zero. +set RAM[263] -1, +set RAM[264] -1, +set RAM[265] -1, +set RAM[266] -1, +set RAM[267] -1, +set RAM[268] -1, +set RAM[269] -1, +set RAM[270] -1, +set RAM[271] -1, +set RAM[272] -1, +set RAM[273] -1, +set RAM[274] -1, +set RAM[275] -1, +set RAM[276] -1, +set RAM[277] -1, +set RAM[278] -1, +set RAM[279] -1, +set RAM[280] -1, +set RAM[281] -1, +set RAM[282] -1, +set RAM[283] -1, +set RAM[284] -1, +set RAM[285] -1, +set RAM[286] -1, +set RAM[287] -1, +set RAM[288] -1, +set RAM[289] -1, +set RAM[290] -1, +set RAM[291] -1, +set RAM[292] -1, +set RAM[293] -1, +set RAM[294] -1, +set RAM[295] -1, +set RAM[296] -1, +set RAM[297] -1, +set RAM[298] -1, +set RAM[299] -1, + +set sp 261, +set local 261, +set argument 256, +set this 3000, +set that 4000; + +repeat 50 { + vmstep; +} +output; diff --git a/projects/08/FunctionCalls/NestedCall/NestedCall_NoBoot.asm b/projects/08/FunctionCalls/NestedCall/NestedCall_NoBoot.asm new file mode 100755 index 0000000..1bd1561 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/NestedCall_NoBoot.asm @@ -0,0 +1,543 @@ +(Sys.init) +@4000 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@3 +M=D +//pop POINTER +@5000 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@Sys.main3RA +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 +@0 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Sys.main +0;JMP +(Sys.main3RA) +//CALLFUNC +@SP +M=M-1 +A=M +D=M +@6 +M=D +//pop TMP +(Sys.init$LOOP) +//LABEL +@Sys.init$LOOP +0;JMP +//GOTO +(Sys.main) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@4001 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@3 +M=D +//pop POINTER +@5001 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@200 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@1 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@1 +D=A +@LCL +M=M-D +//pop LOCAL +@40 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@2 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@2 +D=A +@LCL +M=M-D +//pop LOCAL +@6 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@3 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@3 +D=A +@LCL +M=M-D +//pop LOCAL +@123 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@Sys.add124RA +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 +@1 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Sys.add12 +0;JMP +(Sys.add124RA) +//CALLFUNC +@SP +M=M-1 +A=M +D=M +@5 +M=D +//pop TMP +@0 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@1 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@2 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@3 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@4 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN +(Sys.add12) +@4002 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@3 +M=D +//pop POINTER +@5002 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@12 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN diff --git a/projects/08/FunctionCalls/NestedCall/Sys.vm b/projects/08/FunctionCalls/NestedCall/Sys.vm new file mode 100755 index 0000000..8b0b003 --- /dev/null +++ b/projects/08/FunctionCalls/NestedCall/Sys.vm @@ -0,0 +1,63 @@ +// Sys.vm for NestedCall test. + +// Sys.init() +// +// Calls Sys.main() and stores return value in temp 1. +// Does not return. (Enters infinite loop.) + +function Sys.init 0 +push constant 4000 // test THIS and THAT context save +pop pointer 0 +push constant 5000 +pop pointer 1 +call Sys.main 0 +pop temp 1 +label LOOP +goto LOOP + +// Sys.main() +// +// Sets locals 1, 2 and 3, leaving locals 0 and 4 unchanged to test +// default local initialization to 0. (RAM set to -1 by test setup.) +// Calls Sys.add12(123) and stores return value (135) in temp 0. +// Returns local 0 + local 1 + local 2 + local 3 + local 4 (456) to confirm +// that locals were not mangled by function call. + +function Sys.main 5 +push constant 4001 +pop pointer 0 +push constant 5001 +pop pointer 1 +push constant 200 +pop local 1 +push constant 40 +pop local 2 +push constant 6 +pop local 3 +push constant 123 +call Sys.add12 1 +pop temp 0 +push local 0 +push local 1 +push local 2 +push local 3 +push local 4 +add +add +add +add +return + +// Sys.add12(int n) +// +// Returns n+12. + +function Sys.add12 0 +push constant 4002 +pop pointer 0 +push constant 5002 +pop pointer 1 +push argument 0 +push constant 12 +add +return diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm new file mode 100755 index 0000000..c6c39b1 --- /dev/null +++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm @@ -0,0 +1,137 @@ +(SimpleFunction.test) +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//DEFINEFUNC +@0 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@1 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +A=M +A=A-1 +M=!M +//NOT +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@1 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.cmp b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.cmp new file mode 100755 index 0000000..c3ea911 --- /dev/null +++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.cmp @@ -0,0 +1,2 @@ +| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] |RAM[310]| +| 311 | 305 | 300 | 3010 | 4010 | 1196 | diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.out b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.out new file mode 100755 index 0000000..c3ea911 --- /dev/null +++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.out @@ -0,0 +1,2 @@ +| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] |RAM[310]| +| 311 | 305 | 300 | 3010 | 4010 | 1196 | diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.tst b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.tst new file mode 100755 index 0000000..c7b5905 --- /dev/null +++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.tst @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/SimpleFunction/SimpleFunction.tst + +load SimpleFunction.asm, +output-file SimpleFunction.out, +compare-to SimpleFunction.cmp, +output-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 + RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[310]%D1.6.1; + +set RAM[0] 317, +set RAM[1] 317, +set RAM[2] 310, +set RAM[3] 3000, +set RAM[4] 4000, +set RAM[310] 1234, +set RAM[311] 37, +set RAM[312] 1000, +set RAM[313] 305, +set RAM[314] 300, +set RAM[315] 3010, +set RAM[316] 4010, + +repeat 300 { + ticktock; +} + +output; diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.vm b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.vm new file mode 100755 index 0000000..d64a34f --- /dev/null +++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.vm @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/SimpleFunction/SimpleFunction.vm + +// Performs a simple calculation and returns the result. +function SimpleFunction.test 2 +push local 0 +push local 1 +add +not +push argument 0 +add +push argument 1 +sub +return diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunctionVME.tst b/projects/08/FunctionCalls/SimpleFunction/SimpleFunctionVME.tst new file mode 100755 index 0000000..c9267ee --- /dev/null +++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunctionVME.tst @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/SimpleFunction/SimpleFunctionVME.tst + +load SimpleFunction.vm, +output-file SimpleFunction.out, +compare-to SimpleFunction.cmp, +output-list RAM[0]%D1.6.1 RAM[1]%D1.6.1 RAM[2]%D1.6.1 + RAM[3]%D1.6.1 RAM[4]%D1.6.1 RAM[310]%D1.6.1; + +set sp 317, +set local 317, +set argument 310, +set this 3000, +set that 4000, +set argument[0] 1234, +set argument[1] 37, +set argument[2] 9, +set argument[3] 305, +set argument[4] 300, +set argument[5] 3010, +set argument[6] 4010, + +repeat 10 { + vmstep; +} + +output; diff --git a/projects/08/FunctionCalls/StaticsTest/Class1.vm b/projects/08/FunctionCalls/StaticsTest/Class1.vm new file mode 100755 index 0000000..c463537 --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/Class1.vm @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/StaticsTest/Class1.vm + +// Stores two supplied arguments in static[0] and static[1]. +function Class1.set 0 +push argument 0 +pop static 0 +push argument 1 +pop static 1 +push constant 0 +return + +// Returns static[0] - static[1]. +function Class1.get 0 +push static 0 +push static 1 +sub +return diff --git a/projects/08/FunctionCalls/StaticsTest/Class2.vm b/projects/08/FunctionCalls/StaticsTest/Class2.vm new file mode 100755 index 0000000..94f2946 --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/Class2.vm @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/StaticsTest/Class2.vm + +// Stores two supplied arguments in static[0] and static[1]. +function Class2.set 0 +push argument 0 +pop static 0 +push argument 1 +pop static 1 +push constant 0 +return + +// Returns static[0] - static[1]. +function Class2.get 0 +push static 0 +push static 1 +sub +return diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm b/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm new file mode 100755 index 0000000..bffee0e --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm @@ -0,0 +1,649 @@ +@256 +D=A +@SP +M=D +@MainLoopXYZRA +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 +@0 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Sys.init +0;JMP +(MainLoopXYZRARA) +//CALLFUNC +(Sys.init) +@6 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@8 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@Class1.set5RA +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 +@2 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Class1.set +0;JMP +(Class1.set5RA) +//CALLFUNC +@SP +M=M-1 +A=M +D=M +@5 +M=D +//pop TMP +@23 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@15 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@Class2.set6RA +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 +@2 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Class2.set +0;JMP +(Class2.set6RA) +//CALLFUNC +@SP +M=M-1 +A=M +D=M +@5 +M=D +//pop TMP +@Class1.get7RA +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 +@0 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Class1.get +0;JMP +(Class1.get7RA) +//CALLFUNC +@Class2.get8RA +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 +@0 +D=D-A +@5 +D=D-A +@ARG +M=D +@SP +D=M +@LCL +M=D +@Class2.get +0;JMP +(Class2.get8RA) +//CALLFUNC +(Sys.init$WHILE) +//LABEL +@Sys.init$WHILE +0;JMP +//GOTO +(Class1.set) +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +@Class1.0 +M=D +//pop STATIC +@1 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +@Class1.1 +M=D +//pop STATIC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN +(Class1.get) +@Class1.0 +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push STATIC +@Class1.1 +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push STATIC +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN +(Class2.set) +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +@Class2.0 +M=D +//pop STATIC +@1 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +@Class2.1 +M=D +//pop STATIC +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN +(Class2.get) +@Class2.0 +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push STATIC +@Class2.1 +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push STATIC +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@LCL +D=M +@R13 +M=D +@5 +D=A +@R13 +D=M-D +A=D +D=M +@R14 +M=D +@SP +A=M-1 +D=M +@ARG +A=M +M=D +@ARG +D=M+1 +@SP +M=D +@R13 +M=M-1 +A=M +D=M +@THAT +M=D +@R13 +M=M-1 +A=M +D=M +@THIS +M=D +@R13 +M=M-1 +A=M +D=M +@ARG +M=D +@R13 +M=M-1 +A=M +D=M +@LCL +M=D +@R14 +A=M +0;JMP +//RETURN diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTest.cmp b/projects/08/FunctionCalls/StaticsTest/StaticsTest.cmp new file mode 100755 index 0000000..5589f1e --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.cmp @@ -0,0 +1,2 @@ +| RAM[0] |RAM[261]|RAM[262]| +| 263 | -2 | 8 | diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTest.out b/projects/08/FunctionCalls/StaticsTest/StaticsTest.out new file mode 100755 index 0000000..5589f1e --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.out @@ -0,0 +1,2 @@ +| RAM[0] |RAM[261]|RAM[262]| +| 263 | -2 | 8 | diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTest.tst b/projects/08/FunctionCalls/StaticsTest/StaticsTest.tst new file mode 100755 index 0000000..1b9194e --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/StaticsTest/StaticsTest.tst + +load StaticsTest.asm, +output-file StaticsTest.out, +compare-to StaticsTest.cmp, +output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1 RAM[262]%D1.6.1; + +set RAM[0] 256, + +repeat 2500 { + ticktock; +} + +output; diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTestVME.tst b/projects/08/FunctionCalls/StaticsTest/StaticsTestVME.tst new file mode 100755 index 0000000..130ba66 --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/StaticsTestVME.tst @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/StaticsTest/StaticsTestVME.tst + +load, // loads all the VM files from the current directory. +output-file StaticsTest.out, +compare-to StaticsTest.cmp, +output-list RAM[0]%D1.6.1 RAM[261]%D1.6.1 RAM[262]%D1.6.1; + +set sp 261, + +repeat 36 { + vmstep; +} + +output; diff --git a/projects/08/FunctionCalls/StaticsTest/Sys.vm b/projects/08/FunctionCalls/StaticsTest/Sys.vm new file mode 100755 index 0000000..3708322 --- /dev/null +++ b/projects/08/FunctionCalls/StaticsTest/Sys.vm @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/FunctionCalls/StaticsTest/Sys.vm + +// Tests that different functions, stored in two different +// class files, manipulate the static segment correctly. +function Sys.init 0 +push constant 6 +push constant 8 +call Class1.set 2 +pop temp 0 // Dumps the return value +push constant 23 +push constant 15 +call Class2.set 2 +pop temp 0 // Dumps the return value +call Class1.get 0 +call Class2.get 0 +label WHILE +goto WHILE diff --git a/projects/08/ProgramFlow/BasicLoop/BasicLoop.asm b/projects/08/ProgramFlow/BasicLoop/BasicLoop.asm new file mode 100755 index 0000000..8443dcd --- /dev/null +++ b/projects/08/ProgramFlow/BasicLoop/BasicLoop.asm @@ -0,0 +1,142 @@ +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@0 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@0 +D=A +@LCL +M=M-D +//pop LOCAL +(Sys.init$LOOP_START) +//LABEL +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@0 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@0 +D=A +@LCL +M=M+D +@SP +M=M-1 +A=M +D=M +@LCL +A=M +M=D +@0 +D=A +@LCL +M=M-D +//pop LOCAL +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@0 +D=A +@ARG +M=M+D +@SP +M=M-1 +A=M +D=M +@ARG +A=M +M=D +@0 +D=A +@ARG +M=M-D +//pop ARG +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +@Sys.init$LOOP_START +D;JNE +//IFGOTO +@0 +D=A +@LCL +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push LOCAL diff --git a/projects/08/ProgramFlow/BasicLoop/BasicLoop.cmp b/projects/08/ProgramFlow/BasicLoop/BasicLoop.cmp new file mode 100755 index 0000000..00d35d2 --- /dev/null +++ b/projects/08/ProgramFlow/BasicLoop/BasicLoop.cmp @@ -0,0 +1,2 @@ +| RAM[0] |RAM[256]| +| 257 | 6 | diff --git a/projects/08/ProgramFlow/BasicLoop/BasicLoop.hack b/projects/08/ProgramFlow/BasicLoop/BasicLoop.hack new file mode 100755 index 0000000..763a9aa --- /dev/null +++ b/projects/08/ProgramFlow/BasicLoop/BasicLoop.hack @@ -0,0 +1,127 @@ +0000000000000000 +1110110000010000 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +0000000000000000 +1110110000010000 +0000000000000001 +1111000010001000 +0000000000000000 +1111110010001000 +1111110000100000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000000001 +1111000111001000 +0000000000000000 +1110110000010000 +0000000000000010 +1111000010100000 +1111110000010000 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +0000000000000000 +1110110000010000 +0000000000000001 +1111000010100000 +1111110000010000 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +0000000000000000 +1111110010001000 +1111110000100000 +1111110000010000 +1110110010100000 +1111000010001000 +0000000000000000 +1110110000010000 +0000000000000001 +1111000010001000 +0000000000000000 +1111110010001000 +1111110000100000 +1111110000010000 +0000000000000001 +1111110000100000 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000000001 +1111000111001000 +0000000000000000 +1110110000010000 +0000000000000010 +1111000010100000 +1111110000010000 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +0000000000000001 +1110110000010000 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +0000000000000000 +1111110010001000 +1111110000100000 +1111110000010000 +1110110010100000 +1111000111001000 +0000000000000000 +1110110000010000 +0000000000000010 +1111000010001000 +0000000000000000 +1111110010001000 +1111110000100000 +1111110000010000 +0000000000000010 +1111110000100000 +1110001100001000 +0000000000000000 +1110110000010000 +0000000000000010 +1111000111001000 +0000000000000000 +1110110000010000 +0000000000000010 +1111000010100000 +1111110000010000 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 +0000000000000000 +1111110010001000 +1111110000100000 +1111110000010000 +0000000000010110 +1110001100000101 +0000000000000000 +1110110000010000 +0000000000000001 +1111000010100000 +1111110000010000 +0000000000000000 +1111110000100000 +1110001100001000 +0000000000000000 +1111110111001000 diff --git a/projects/08/ProgramFlow/BasicLoop/BasicLoop.out b/projects/08/ProgramFlow/BasicLoop/BasicLoop.out new file mode 100755 index 0000000..a1c3d0c --- /dev/null +++ b/projects/08/ProgramFlow/BasicLoop/BasicLoop.out @@ -0,0 +1,2 @@ +| RAM[0] |RAM[256]| +| 256 | 1 | diff --git a/projects/08/ProgramFlow/BasicLoop/BasicLoop.tst b/projects/08/ProgramFlow/BasicLoop/BasicLoop.tst new file mode 100755 index 0000000..50ca118 --- /dev/null +++ b/projects/08/ProgramFlow/BasicLoop/BasicLoop.tst @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/ProgramFlow/BasicLoop/BasicLoop.tst + +load BasicLoop.asm, +output-file BasicLoop.out, +compare-to BasicLoop.cmp, +output-list RAM[0]%D1.6.1 RAM[256]%D1.6.1; + +set RAM[0] 256, +set RAM[1] 300, +set RAM[2] 400, +set RAM[400] 3, + +repeat 600 { + ticktock; +} + +output; diff --git a/projects/08/ProgramFlow/BasicLoop/BasicLoop.vm b/projects/08/ProgramFlow/BasicLoop/BasicLoop.vm new file mode 100755 index 0000000..dc5a92f --- /dev/null +++ b/projects/08/ProgramFlow/BasicLoop/BasicLoop.vm @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/ProgramFlow/BasicLoop/BasicLoop.vm + +// Computes the sum 1 + 2 + ... + argument[0] and pushes the +// result onto the stack. Argument[0] is initialized by the test +// script before this code starts running. +push constant 0 +pop local 0 // initializes sum = 0 +label LOOP_START +push argument 0 +push local 0 +add +pop local 0 // sum = sum + counter +push argument 0 +push constant 1 +sub +pop argument 0 // counter-- +push argument 0 +if-goto LOOP_START // If counter != 0, goto LOOP_START +push local 0 diff --git a/projects/08/ProgramFlow/BasicLoop/BasicLoopVME.tst b/projects/08/ProgramFlow/BasicLoop/BasicLoopVME.tst new file mode 100755 index 0000000..237fdff --- /dev/null +++ b/projects/08/ProgramFlow/BasicLoop/BasicLoopVME.tst @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/ProgramFlow/BasicLoop/BasicLoopVME.tst + +load BasicLoop.vm, +output-file BasicLoop.out, +compare-to BasicLoop.cmp, +output-list RAM[0]%D1.6.1 RAM[256]%D1.6.1; + +set sp 256, +set local 300, +set argument 400, +set argument[0] 3, + +repeat 33 { + vmstep; +} + +output; diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm new file mode 100755 index 0000000..1384c97 --- /dev/null +++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm @@ -0,0 +1,255 @@ +@1 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@0 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@0 +D=A +@THAT +M=M+D +@SP +M=M-1 +A=M +D=M +@THAT +A=M +M=D +@0 +D=A +@THAT +M=M-D +//pop THAT +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@1 +D=A +@THAT +M=M+D +@SP +M=M-1 +A=M +D=M +@THAT +A=M +M=D +@1 +D=A +@THAT +M=M-D +//pop THAT +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@2 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@0 +D=A +@ARG +M=M+D +@SP +M=M-1 +A=M +D=M +@ARG +A=M +M=D +@0 +D=A +@ARG +M=M-D +//pop ARG +(Sys.init$MAIN_LOOP_START) +//LABEL +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@SP +M=M-1 +A=M +D=M +@Sys.init$COMPUTE_ELEMENT +D;JNE +//IFGOTO +@Sys.init$END_PROGRAM +0;JMP +//GOTO +(Sys.init$COMPUTE_ELEMENT) +//LABEL +@0 +D=A +@THAT +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push THAT +@1 +D=A +@THAT +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push THAT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@2 +D=A +@THAT +M=M+D +@SP +M=M-1 +A=M +D=M +@THAT +A=M +M=D +@2 +D=A +@THAT +M=M-D +//pop THAT +@4 +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push POINTER +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M+D +//ADD +@SP +M=M-1 +A=M +D=M +@4 +M=D +//pop POINTER +@0 +D=A +@ARG +A=M+D +D=M +@SP +A=M +M=D +@SP +M=M+1 +//push ARGUMENT +@1 +D=A +@SP +A=M +M=D +@SP +M=M+1 +//push CONSTANT +@SP +M=M-1 +A=M +D=M +A=A-1 +M=M-D +//SUB +@0 +D=A +@ARG +M=M+D +@SP +M=M-1 +A=M +D=M +@ARG +A=M +M=D +@0 +D=A +@ARG +M=M-D +//pop ARG +@Sys.init$MAIN_LOOP_START +0;JMP +//GOTO +(Sys.init$END_PROGRAM) +//LABEL diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.cmp b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.cmp new file mode 100755 index 0000000..c262a4b --- /dev/null +++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.cmp @@ -0,0 +1,2 @@ +|RAM[3000]|RAM[3001]|RAM[3002]|RAM[3003]|RAM[3004]|RAM[3005]| +| 0 | 1 | 1 | 2 | 3 | 5 | diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.out b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.out new file mode 100755 index 0000000..c262a4b --- /dev/null +++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.out @@ -0,0 +1,2 @@ +|RAM[3000]|RAM[3001]|RAM[3002]|RAM[3003]|RAM[3004]|RAM[3005]| +| 0 | 1 | 1 | 2 | 3 | 5 | diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.tst b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.tst new file mode 100755 index 0000000..07df2b9 --- /dev/null +++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.tst @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.tst + +load FibonacciSeries.asm, +output-file FibonacciSeries.out, +compare-to FibonacciSeries.cmp, +output-list RAM[3000]%D1.6.2 RAM[3001]%D1.6.2 RAM[3002]%D1.6.2 + RAM[3003]%D1.6.2 RAM[3004]%D1.6.2 RAM[3005]%D1.6.2; + +set RAM[0] 256, +set RAM[1] 300, +set RAM[2] 400, +set RAM[400] 6, +set RAM[401] 3000, + +repeat 1100 { + ticktock; +} + +output; diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.vm b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.vm new file mode 100755 index 0000000..6a643b6 --- /dev/null +++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.vm @@ -0,0 +1,49 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.vm + +// Puts the first argument[0] elements of the Fibonacci series +// in the memory, starting in the address given in argument[1]. +// Argument[0] and argument[1] are initialized by the test script +// before this code starts running. + +push argument 1 +pop pointer 1 // that = argument[1] + +push constant 0 +pop that 0 // first element in the series = 0 +push constant 1 +pop that 1 // second element in the series = 1 + +push argument 0 +push constant 2 +sub +pop argument 0 // num_of_elements -= 2 (first 2 elements are set) + +label MAIN_LOOP_START + +push argument 0 +if-goto COMPUTE_ELEMENT // if num_of_elements > 0, goto COMPUTE_ELEMENT +goto END_PROGRAM // otherwise, goto END_PROGRAM + +label COMPUTE_ELEMENT + +push that 0 +push that 1 +add +pop that 2 // that[2] = that[0] + that[1] + +push pointer 1 +push constant 1 +add +pop pointer 1 // that += 1 + +push argument 0 +push constant 1 +sub +pop argument 0 // num_of_elements-- + +goto MAIN_LOOP_START + +label END_PROGRAM diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeriesVME.tst b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeriesVME.tst new file mode 100755 index 0000000..243f31b --- /dev/null +++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeriesVME.tst @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/08/ProgramFlow/FibonacciSeries/FibonacciSeriesVME.tst + +load FibonacciSeries.vm, +output-file FibonacciSeries.out, +compare-to FibonacciSeries.cmp, +output-list RAM[3000]%D1.6.2 RAM[3001]%D1.6.2 RAM[3002]%D1.6.2 + RAM[3003]%D1.6.2 RAM[3004]%D1.6.2 RAM[3005]%D1.6.2; + +set sp 256, +set local 300, +set argument 400, +set argument[0] 6, +set argument[1] 3000, + +repeat 73 { + vmstep; +} + +output; diff --git a/projects/08/VMTranslator.py b/projects/08/VMTranslator.py new file mode 100755 index 0000000..46f68e4 --- /dev/null +++ b/projects/08/VMTranslator.py @@ -0,0 +1,246 @@ +import os +from pathlib import Path + + +def clear_file(clearfile): + temp_string_cf = '' # clears the empty lines, comments and spaces and writes them in a string + for vmline in clearfile: + flag = 0 + if vmline == '\n': + continue + for index in range(len(vmline)): + if vmline[index:index + 2] == '//': + if flag == 1: + temp_string_cf += '\n' + break + if flag == 1 and vmline[index:index + 2] == ' ': + temp_string_cf += '\n' + break + temp_string_cf += vmline[index] + flag = 1 + return temp_string_cf + + +def push(pushline, funcname): + if 'this' in pushline: + number = int(pushline[10:]) + pushline = '@' + str(number) + '\nD=A\n@THIS\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push THIS\n' + elif 'that' in pushline: + number = int(pushline[10:]) + pushline = '@' + str(number) + '\nD=A\n@THAT\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push THAT\n' + elif 'temp' in pushline: + number = int(pushline[10:]) + number += 5 + pushline = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push TMP\n' + elif 'local' in pushline: + number = int(pushline[11:]) + pushline = '@' + str(number) + '\nD=A\n@LCL\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push LOCAL\n' + elif 'static' in pushline: + number = int(pushline[12:]) + pushline = '@' + funcname + '.' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push STATIC\n' + elif 'pointer' in pushline: + number = int(pushline[13:]) + number += 3 + pushline = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push POINTER\n' + elif 'argument' in pushline: + number = int(pushline[14:]) + pushline = '@' + str(number) + '\nD=A\n@ARG\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push ARGUMENT\n' + elif 'constant' in pushline: + number = pushline[14:] + pushline = '@' + str(number) + '\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push CONSTANT\n' + return pushline + + +def pop(popline, funcname): + if 'this' in popline: + number = int(popline[9:]) + popline = '@' + str(number) + '\nD=A\n@THIS\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THIS\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THIS\nM=M-D\n//pop THIS\n' + elif 'that' in popline: + number = int(popline[9:]) + popline = '@' + str(number) + '\nD=A\n@THAT\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THAT\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THAT\nM=M-D\n//pop THAT\n' + elif 'temp' in popline: + number = int(popline[9:]) + number = number + 5 + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n//pop TMP\n' + elif 'local' in popline: + number = int(popline[10:]) + popline = '@' + str(number) + '\nD=A\n@LCL\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@LCL\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@LCL\nM=M-D\n//pop LOCAL\n' + elif 'static' in popline: + number = int(popline[11:]) + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + funcname + '.' + str(number) + '\nM=D\n//pop STATIC\n' + elif 'pointer' in popline: + number = int(popline[12:]) + number = number + 3 + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n//pop POINTER\n' + elif 'argument' in popline: + number = int(popline[13:]) + popline = '@' + str(number) + '\nD=A\n@ARG\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@ARG\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@ARG\nM=M-D\n//pop ARG\n' + return popline + + +def aritmetic(armline): + global trueCounter + global falseCounter + if armline == 'add': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M+D\n//ADD\n" + elif armline == 'sub': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M-D\n//SUB\n" + elif armline == 'neg': + armline = "@SP\nA=M\nA=A-1\nM=-M\n//NEG\n" + elif armline == 'eq': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JEQ\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//EQ\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'gt': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JGT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//GT\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'lt': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JLT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//LT\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'and': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M&D\n//AND\n" + elif armline == 'or': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M|D\n//OR\n" + elif armline == 'not': + armline = "@SP\nA=M\nA=A-1\nM=!M\n//NOT\n" + return armline + + +def label(labelline): + labelline = '(' + func_label_name + '$' + labelline[6:] + ')\n//LABEL\n' + return labelline + + +def goto(gotoline): + gotoline = '@' + func_label_name + '$' + gotoline[5:] + '\n0;JMP\n//GOTO\n' + return gotoline + + +def if_goto(ifline): + ifline = '@SP\nM=M-1\nA=M\nD=M\n@' + func_label_name + '$' + ifline[8:] + '\nD;JNE\n//IFGOTO\n' + return ifline + + +def define_func(funcline): + global func_label_name + def_func_list = funcline.rsplit(' ') + func_label_name = def_func_list[1] + funcline = '(' + def_func_list[1] + ')\n' + for ind in range(int(def_func_list[2])): + funcline += '@0\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//DEFINEFUNC\n' + return funcline + + +def call_func(callline): + global f + call_func_list = callline.rsplit(' ') + callline = '@' + call_func_list[1] + str(f) + 'RA\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@LCL\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@ARG\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@THIS\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@THAT\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@SP\nD=M\n@' + call_func_list[2] + '\nD=D-A\n@5\nD=D-A\n@ARG\nM=D\n' + callline += '@SP\nD=M\n@LCL\nM=D\n' + callline += '@' + call_func_list[1] + '\n0;JMP\n' + callline += '(' + call_func_list[1] + str(f) + 'RA)\n//CALLFUNC\n' + f += 1 + return callline + + +def return_func(returnline): + returnline = '@LCL\nD=M\n@R13\nM=D\n' + returnline += '@5\nD=A\n@R13\nD=M-D\nA=D\nD=M\n@R14\nM=D\n' + returnline += '@SP\nA=M-1\nD=M\n@ARG\nA=M\nM=D\n' + returnline += '@ARG\nD=M+1\n@SP\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@THAT\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@THIS\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@ARG\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@LCL\nM=D\n' + returnline += '@R14\nA=M\n0;JMP\n//RETURN\n' + return returnline + + +def iterate(name_iterate, yourpath_iterate): + line = '' + new_string = '' + with open(Path(yourpath_iterate, name_iterate + '.vm'), "r+") as vmfile: + string_iterate = clear_file(vmfile) + for j in string_iterate: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + if line[:4] == 'push': + new_string += push(line, name_iterate) + line = '' + elif line[:3] == 'pop': + new_string += pop(line, name_iterate) + line = '' + elif line[:2] in aritmeticList2 or line[:3] in aritmeticList3: + new_string += aritmetic(line) + line = '' + elif line[:5] == 'label': + new_string += label(line) + line = '' + elif line[:4] == 'goto': + new_string += goto(line) + line = '' + elif line[:7] == 'if-goto': + new_string += if_goto(line) + line = '' + elif line[:8] == 'function': + new_string += define_func(line) + line = '' + elif line[:4] == 'call': + new_string += call_func(line) + line = '' + elif line[:6] == 'return': + new_string += return_func(line) + line = '' + return new_string + + +trueCounter = falseCounter = f = 0 +staticCounter = 16 +func_label_name = '' +aritmeticList3 = ['add', 'sub', 'neg', 'and', 'not'] +aritmeticList2 = ['or', 'gt', 'lt', 'eq'] +yourpath = os.getcwd() + +bootstrap = '''@256\nD=A\n@SP\nM=D\n@MainLoopXYZRA\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n@LCL\nD=M\n@SP\nA=M\nM=D\n@SP +M=M+1\n@ARG\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n@THIS\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n@THAT\nD=M\n@SP\nA=M\nM=D\n@SP +M=M+1\n@SP\nD=M\n@0\nD=D-A\n@5\nD=D-A\n@ARG\nM=D\n@SP\nD=M\n@LCL\nM=D\n@Sys.init\n0;JMP\n(MainLoopXYZRARA) +//CALLFUNC\n''' + +for root, dirs, files in os.walk(yourpath, topdown=False): + nameslist = [] + sysstring, functstring = '', '' + for name in files: + tempString = '' + if name[-3:] == '.vm': + nameslist += [name[:-3]] + for i in nameslist: + if i == 'Sys': + sysstring = bootstrap + sysstring += iterate(i, root) + + else: + functstring += iterate(i, root) + if nameslist: + with open(Path(root, f'{os.path.split(root)[1]}.asm'), 'w+') as newfile: + newfile.write(sysstring + functstring) + diff --git a/projects/08/Vmtraslotor_old.py b/projects/08/Vmtraslotor_old.py new file mode 100755 index 0000000..ecbbd02 --- /dev/null +++ b/projects/08/Vmtraslotor_old.py @@ -0,0 +1,253 @@ +import os + + +def clear_file(clearfile): + temp_string_cf = '' # clears the empty lines, comments and spaces and writes them in a string + for vmline in clearfile: + flag = 0 + if vmline == '\n': + continue + for index in range(len(vmline)): + if vmline[index:index + 2] == '//': + if flag == 1: + temp_string_cf += '\n' + break + if flag == 1 and vmline[index:index + 2] == ' ': + temp_string_cf += '\n' + break + temp_string_cf += vmline[index] + flag = 1 + return temp_string_cf + + +def push(pushline, funcname): + if 'this' in pushline: + number = int(pushline[10:]) + pushline = '@' + str(number) + '\nD=A\n@THIS\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push THIS\n' + elif 'that' in pushline: + number = int(pushline[10:]) + pushline = '@' + str(number) + '\nD=A\n@THAT\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push THAT\n' + elif 'temp' in pushline: + number = int(pushline[10:]) + number += 5 + pushline = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push TMP\n' + elif 'local' in pushline: + number = int(pushline[11:]) + pushline = '@' + str(number) + '\nD=A\n@LCL\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push LOCAL\n' + elif 'static' in pushline: + breakpoint() + number = int(pushline[12:]) + pushline = '@' + funcname + '.' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push STATIC\n' + elif 'pointer' in pushline: + number = int(pushline[13:]) + number += 3 + pushline = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push POINTER\n' + elif 'argument' in pushline: + number = int(pushline[14:]) + pushline = '@' + str(number) + '\nD=A\n@ARG\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push ARGUMENT\n' + elif 'constant' in pushline: + number = pushline[14:] + pushline = '@' + str(number) + '\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push CONSTANT\n' + return pushline + + +def pop(popline, funcname): + if 'this' in popline: + number = int(popline[9:]) + popline = '@' + str(number) + '\nD=A\n@THIS\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THIS\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THIS\nM=M-D\n//pop THIS\n' + elif 'that' in popline: + number = int(popline[9:]) + popline = '@' + str(number) + '\nD=A\n@THAT\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THAT\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THAT\nM=M-D\n//pop THAT\n' + elif 'temp' in popline: + number = int(popline[9:]) + number = number + 5 + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n//pop TMP\n' + elif 'local' in popline: + number = int(popline[10:]) + popline = '@' + str(number) + '\nD=A\n@LCL\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@LCL\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@LCL\nM=M-D\n//pop LOCAL\n' + elif 'static' in popline: + breakpoint() + number = int(popline[11:]) + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + funcname + '.' + str(number) + '\nM=D\n//pop STATIC\n' + elif 'pointer' in popline: + number = int(popline[12:]) + number = number + 3 + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n//pop POINTER\n' + elif 'argument' in popline: + number = int(popline[13:]) + popline = '@' + str(number) + '\nD=A\n@ARG\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@ARG\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@ARG\nM=M-D\n//pop ARG\n' + return popline + + +def aritmetic(armline): + global trueCounter + global falseCounter + if armline == 'add': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M+D\n//ADD\n" + elif armline == 'sub': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M-D\n//SUB\n" + elif armline == 'neg': + armline = "@SP\nA=M\nA=A-1\nM=-M\n//NEG\n" + elif armline == 'eq': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JEQ\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//EQ\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'gt': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JGT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//GT\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'lt': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JLT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//LT\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'and': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M&D\n//AND\n" + elif armline == 'or': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M|D\n//OR\n" + elif armline == 'not': + armline = "@SP\nA=M\nA=A-1\nM=!M\n//NOT\n" + return armline + + +def label(labelline): + labelline = '(' + func_label_name + '$' + labelline[6:] + ')\n//LABEL\n' + return labelline + + +def goto(gotoline): + gotoline = '@' + func_label_name + '$' + gotoline[5:] + '\n0;JMP\n//GOTO\n' + return gotoline + + +def if_goto(ifline): + ifline = '@SP\nM=M-1\nA=M\nD=M\n@' + func_label_name + '$' + ifline[8:] + '\nD;JNE\n//IFGOTO\n' + return ifline + + +def define_func(funcline): + global func_label_name + def_func_list = funcline.rsplit(' ') + func_label_name = def_func_list[1] + funcline = '(' + def_func_list[1] + ')\n' + for ind in range(int(def_func_list[2])): + funcline += '@0\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//DEFINEFUNC\n' + return funcline + + +def call_func(callline): + global f + call_func_list = callline.rsplit(' ') + callline = '@' + call_func_list[1] + str(f) + 'RA\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@LCL\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@ARG\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@THIS\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@THAT\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@SP\nD=M\n@' + call_func_list[2] + '\nD=D-A\n@5\nD=D-A\n@ARG\nM=D\n' + callline += '@SP\nD=M\n@LCL\nM=D\n' + callline += '@' + call_func_list[1] + '\n0;JMP\n' + callline += '(' + call_func_list[1] + str(f) + 'RA)\n//CALLFUNC\n' + f += 1 + return callline + + +def return_func(returnline): + returnline = '@LCL\nD=M\n@R13\nM=D\n' + returnline += '@5\nD=A\n@R13\nD=M-D\nA=D\nD=M\n@R14\nM=D\n' + returnline += '@SP\nA=M-1\nD=M\n@ARG\nA=M\nM=D\n' + returnline += '@ARG\nD=M+1\n@SP\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@THAT\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@THIS\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@ARG\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@LCL\nM=D\n' + returnline += '@R14\nA=M\n0;JMP\n//RETURN\n' + return returnline + + +def iterate(name_iterate, yourpath_iterate): + line = '' + new_string = '' + with open(yourpath_iterate + '/' + name_iterate + '.vm', "r+") as vmfile: + string_iterate = clear_file(vmfile) + print(string_iterate) + for j in string_iterate: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + if line[:4] == 'push': + new_string += push(line, name_iterate) + line = '' + elif line[:3] == 'pop': + new_string += pop(line, name_iterate) + line = '' + elif line[:2] in aritmeticList2 or line[:3] in aritmeticList3: + new_string += aritmetic(line) + line = '' + elif line[:5] == 'label': + new_string += label(line) + line = '' + elif line[:4] == 'goto': + new_string += goto(line) + line = '' + elif line[:7] == 'if-goto': + new_string += if_goto(line) + line = '' + elif line[:8] == 'function': + new_string += define_func(line) + line = '' + elif line[:4] == 'call': + new_string += call_func(line) + line = '' + elif line[:6] == 'return': + new_string += return_func(line) + line = '' + return new_string + + +trueCounter = 0 +falseCounter = 0 +staticCounter = 16 +f = 0 +func_label_name = '' +aritmeticList3 = ['add', 'sub', 'neg', 'and', 'not'] +aritmeticList2 = ['or', 'gt', 'lt', 'eq'] +yourpath = 'C:/Users/SQA-AGrudev/Desktop/nand2tetris/projects/08/FunctionCalls/NestedCall' +folder_name = '' +for c in reversed(yourpath): + if c != '/': + folder_name += c + else: + break +folder_name = folder_name[::-1] + +nameslist = [] +for root, dirs, files in os.walk(yourpath, topdown=False): + for name in files: + tempString = '' + if name[-3:] == '.vm': + nameslist += [name[:-3]] + +sysstring, functstring = '', '' + +for i in nameslist: + if i == 'Sys': + sysstring = iterate(i, yourpath) + else: + functstring += iterate(i, yourpath) +tempString1 ='@256\nD=A\n@SP\nM=D\n@Sys.init\n0;JMP\n'+ sysstring + functstring +with open(yourpath + '/' + folder_name + '.asm', 'w+') as newfile: # tva tqbva da se kazva papkata ne faila + # TODO before i write the whole things i think i should write SP=256 call Sys.init in assembler pretty sure i should + newfile.write(tempString1) +# TODO make it run more than 1 file diff --git a/projects/08/lang.txt b/projects/08/lang.txt new file mode 100755 index 0000000..140ecda --- /dev/null +++ b/projects/08/lang.txt @@ -0,0 +1,2 @@ +python3 +debug \ No newline at end of file diff --git a/projects/09/Average/Main.jack b/projects/09/Average/Main.jack new file mode 100755 index 0000000..a359602 --- /dev/null +++ b/projects/09/Average/Main.jack @@ -0,0 +1,27 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/Average/Main.jack + +// Inputs some numbers and computes their average +class Main { + function void main() { + var Array a; + var int length; + var int i, sum; + + let length = Keyboard.readInt("How many numbers? "); + let a = Array.new(length); // constructs the array + + let i = 0; + while (i < length) { + let a[i] = Keyboard.readInt("Enter a number: "); + let sum = sum + a[i]; + let i = i + 1; + } + + do Output.printString("The average is "); + do Output.printInt(sum / length); + return; + } +} diff --git a/projects/09/BitmapEditor/BitmapEditor.html b/projects/09/BitmapEditor/BitmapEditor.html new file mode 100755 index 0000000..fdb9e0b --- /dev/null +++ b/projects/09/BitmapEditor/BitmapEditor.html @@ -0,0 +1,200 @@ + + + + Sokoban Bitmap Editor + + + +

IDC Herzliya / Efi Arazi School of Computer Science / Digital Systems Construction, Spring 2011 / Project 09 / Golan Parashi

+

Sokoban Bitmap Editor

+

This javascript applicaiton is used to generate highly optimized jack code for drawing a 16x16 bitmap to the screen.

+

Using the mouse, click the desired cell to mark/unmark it. You may use 90 degrees rotation and vertical mirroring by
+ clicking the appropriate buttons.

+

When you are finished drawing, you may select function type and enter function's name.

+

+ + + + + + + + + + + + + + +
BitmapGenerated Jack Code
+
+ + + + + + + +
Function Type:
+ +
Function Name:
+
+
+ + + + +
+ + + + \ No newline at end of file diff --git a/projects/09/BitmapEditor/BitmapEditor.iml b/projects/09/BitmapEditor/BitmapEditor.iml new file mode 100755 index 0000000..ef582b1 --- /dev/null +++ b/projects/09/BitmapEditor/BitmapEditor.iml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/projects/09/Fraction/Fraction.jack b/projects/09/Fraction/Fraction.jack new file mode 100755 index 0000000..c86f0a5 --- /dev/null +++ b/projects/09/Fraction/Fraction.jack @@ -0,0 +1,65 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/Fraction/Fraction.jack + +/** Represents the Fraction type and related operations. */ +class Fraction { + field int numerator, denominator; // field = property = member variable. + + /** Constructs a (reduced) fraction from the given numerator and denominator. */ + constructor Fraction new(int x, int y) { + let numerator = x; + let denominator = y; + do reduce(); // reduces the fraction + return this; // a constructor is expected to return a reference to the new object + } + + // Reduces this fraction. + method void reduce() { + var int g; + let g = Fraction.gcd(numerator, denominator); + if (g > 1) { + let numerator = numerator / g; + let denominator = denominator / g; + } + return; + } + + /** Accessors. */ + method int getNumerator() { return numerator; } + method int getDenominator() { return denominator; } + + /** Returns the sum of this fraction and the other one. */ + method Fraction plus(Fraction other) { + var int sum; + let sum = (numerator * other.getDenominator()) + (other.getNumerator() * denominator); + return Fraction.new(sum, denominator * other.getDenominator()); + } + + // More fraction-related methods (minus, times, div, etc.) can be added here. + + /** Disposes this fraction. */ + method void dispose() { + do Memory.deAlloc(this); // uses an OS routine to recycle the memory held by the object + return; + } + + /** Prints this fraction in the format x/y. */ + method void print() { + do Output.printInt(numerator); + do Output.printString("/"); + do Output.printInt(denominator); + return; + } + + // Computes the greatest common divisor of the given integers. + function int gcd(int a, int b) { + var int r; + while (~(b = 0)) { // applies Euclid's algorithm + let r = a - (b * (a / b)); // r = remainder of the integer division a/b + let a = b; let b = r; + } + return a; + } +} diff --git a/projects/09/Fraction/Main.jack b/projects/09/Fraction/Main.jack new file mode 100755 index 0000000..43ddece --- /dev/null +++ b/projects/09/Fraction/Main.jack @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/Fraction/Main.jack + +// Computes the sum of 2/3 and 1/5. +class Main { + function void main() { + var Fraction a, b, c; + let a = Fraction.new(2,3); + let b = Fraction.new(1,5); + let c = a.plus(b); // Computes c = a + b + do c.print(); // Prints "13/15" + return; + } +} diff --git a/projects/09/HelloWorld/Main.jack b/projects/09/HelloWorld/Main.jack new file mode 100755 index 0000000..446b21b --- /dev/null +++ b/projects/09/HelloWorld/Main.jack @@ -0,0 +1,14 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/HelloWorld/Main.jack + +/** Hello World program. */ +class Main { + function void main() { + /* Prints some text using the standard library. */ + do Output.printString("Hello world!"); + do Output.println(); // New line + return; + } +} diff --git a/projects/09/Jack OS API.pdf b/projects/09/Jack OS API.pdf new file mode 100755 index 0000000..e653e86 Binary files /dev/null and b/projects/09/Jack OS API.pdf differ diff --git a/projects/09/List/List.jack b/projects/09/List/List.jack new file mode 100755 index 0000000..c62fe28 --- /dev/null +++ b/projects/09/List/List.jack @@ -0,0 +1,46 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/List/List.jack + +/** Represents a linked list of integers. */ +class List { + field int data; // a list consists of a data field, + field List next; // followed by a list + + /* Creates a List. */ + constructor List new(int car, List cdr) { + let data = car; // the identifiers car and cdr are used in + let next = cdr; // memory of the Lisp programming language + return this; + } + + /** Accessors. */ + method int getData() { return data; } + method int getNext() { return next; } + + /** Prints this list. */ + method void print() { + var List current; // initializes current to the first item + let current = this; // of this list + while (~(current = null)) { + do Output.printInt(current.getData()); + do Output.printChar(32); // prints a space + let current = current.getNext(); + } + return; + } + + /** Disposes this List by recursively disposing its tail. */ + method void dispose() { + if (~(next = null)) { + do next.dispose(); + } + // Uses an OS routine to recycle this object. + do Memory.deAlloc(this); + return; + } + + // More list processing methods can come here. + +} diff --git a/projects/09/List/Main.jack b/projects/09/List/Main.jack new file mode 100755 index 0000000..824eb6f --- /dev/null +++ b/projects/09/List/Main.jack @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/List/Main.jack + +/** Demonstrates the use of the List abstraction. */ +class Main { + function void main() { + // Creates and uses the list (2,3,5). + var List v; + let v = List.new(5,null); + let v = List.new(2,List.new(3,v)); + do v.print(); // prints 2 3 5 + do v.dispose(); // disposes the list + return; + } +} diff --git a/projects/09/New folder/Tetris.zip b/projects/09/New folder/Tetris.zip new file mode 100755 index 0000000..0ad7a0b Binary files /dev/null and b/projects/09/New folder/Tetris.zip differ diff --git a/projects/09/New folder/Tetris/Main.vm b/projects/09/New folder/Tetris/Main.vm new file mode 100755 index 0000000..9931b90 --- /dev/null +++ b/projects/09/New folder/Tetris/Main.vm @@ -0,0 +1,147 @@ +function Main.main 1 +push constant 1 +neg +pop local 0 +push constant 0 +push constant 20 +call Output.moveCursor 2 +pop temp 0 +push constant 17 +call String.new 1 +push constant 87 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push constant 2000 +call Sys.wait 1 +pop temp 0 +call Output.println 0 +pop temp 0 +call Output.println 0 +pop temp 0 +call Output.println 0 +pop temp 0 +label WHILE_EXP0 +push local 0 +push constant 0 +lt +push local 0 +push constant 100 +gt +or +not +if-goto WHILE_END0 +push constant 33 +call String.new 1 +push constant 69 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Keyboard.readInt 1 +pop local 0 +call Screen.clearScreen 0 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 2000 +call Sys.wait 1 +pop temp 0 +push local 0 +call Tetris.tetris 1 +pop temp 0 +push constant 0 +return diff --git a/projects/09/New folder/Tetris/Piece.vm b/projects/09/New folder/Tetris/Piece.vm new file mode 100755 index 0000000..eb6061b --- /dev/null +++ b/projects/09/New folder/Tetris/Piece.vm @@ -0,0 +1,2219 @@ +function Piece.new 0 +push constant 11 +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 argument 3 +pop this 3 +push argument 4 +pop this 4 +push argument 5 +pop this 5 +push argument 6 +pop this 6 +push argument 7 +pop this 7 +push argument 8 +pop this 8 +push constant 0 +pop this 9 +push constant 0 +not +pop this 10 +push pointer 0 +return +function Piece.init 1 +push constant 0 +pop static 0 +push constant 511 +pop static 1 +push constant 0 +pop static 2 +push constant 255 +pop static 3 +push constant 16 +call Array.new 1 +pop static 5 +push constant 0 +push static 5 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 5 +add +push local 0 +push constant 1 +sub +push static 5 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 5 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Piece.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function Piece.draw 1 +push argument 0 +pop pointer 0 +push constant 0 +not +pop local 0 +push this 0 +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push this 3 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +not +return +label IF_FALSE0 +push constant 0 +return +function Piece.erase 0 +push argument 0 +pop pointer 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 3 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Piece.sample 4 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push constant 32 +push argument 1 +call Math.multiply 2 +push local 3 +add +push constant 16384 +add +pop local 1 +push local 1 +push constant 24576 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push local 1 +call Memory.peek 1 +pop local 0 +push local 0 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +return +label IF_FALSE1 +push constant 0 +return +function Piece.getMove 0 +push argument 0 +pop pointer 0 +push this 10 +return +function Piece.fullSample 6 +push argument 0 +pop pointer 0 +push argument 1 +push constant 1 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 2 +push this 0 +sub +pop local 0 +push this 6 +push this 4 +sub +pop local 1 +push constant 0 +not +pop local 4 +label WHILE_EXP0 +push local 2 +push local 0 +lt +not +if-goto WHILE_END0 +push constant 0 +pop local 3 +push constant 0 +pop local 5 +label WHILE_EXP1 +push local 3 +push local 1 +lt +not +if-goto WHILE_END1 +push this 0 +push local 2 +add +push this 4 +push local 3 +add +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 5 +label IF_FALSE1 +push local 4 +push this 4 +push local 3 +add +push this 7 +push constant 1 +add +call Piece.sample 2 +and +pop local 4 +push local 3 +push constant 16 +add +pop local 3 +goto WHILE_EXP1 +label WHILE_END1 +push local 5 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 4 +push this 0 +push local 2 +add +push this 3 +push constant 1 +add +call Piece.sample 2 +and +pop local 4 +label IF_FALSE2 +push local 2 +push constant 16 +add +pop local 2 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +return +goto IF_END0 +label IF_FALSE0 +push argument 1 +push constant 2 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push this 3 +push this 1 +sub +pop local 0 +push this 7 +push this 5 +sub +pop local 1 +push constant 0 +not +pop local 4 +label WHILE_EXP2 +push local 2 +push local 0 +lt +not +if-goto WHILE_END2 +push constant 0 +pop local 3 +push constant 0 +pop local 5 +label WHILE_EXP3 +push local 3 +push local 1 +lt +not +if-goto WHILE_END3 +push this 1 +push local 2 +add +push this 5 +push local 3 +add +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 0 +not +pop local 5 +label IF_FALSE4 +push local 4 +push this 6 +push constant 1 +add +push this 5 +push local 3 +add +call Piece.sample 2 +and +pop local 4 +push local 3 +push constant 16 +add +pop local 3 +goto WHILE_EXP3 +label WHILE_END3 +push local 5 +not +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push local 4 +push this 2 +push constant 1 +add +push this 1 +push local 2 +add +call Piece.sample 2 +and +pop local 4 +label IF_FALSE5 +push local 2 +push constant 16 +add +pop local 2 +goto WHILE_EXP2 +label WHILE_END2 +push local 4 +return +goto IF_END3 +label IF_FALSE3 +push this 3 +push this 1 +sub +pop local 0 +push this 7 +push this 5 +sub +pop local 1 +push constant 0 +not +pop local 4 +label WHILE_EXP4 +push local 2 +push local 1 +lt +not +if-goto WHILE_END4 +push constant 0 +pop local 3 +push constant 0 +pop local 5 +label WHILE_EXP5 +push local 3 +push local 0 +lt +not +if-goto WHILE_END5 +push this 5 +push local 2 +add +push this 1 +push local 3 +add +eq +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push constant 0 +not +pop local 5 +label IF_FALSE6 +push local 4 +push this 0 +push constant 1 +sub +push this 1 +push local 3 +add +call Piece.sample 2 +and +pop local 4 +push local 3 +push constant 16 +add +pop local 3 +goto WHILE_EXP5 +label WHILE_END5 +push local 5 +not +if-goto IF_TRUE7 +goto IF_FALSE7 +label IF_TRUE7 +push local 4 +push this 4 +push constant 1 +sub +push this 5 +push local 2 +add +call Piece.sample 2 +and +pop local 4 +label IF_FALSE7 +push local 2 +push constant 16 +add +pop local 2 +goto WHILE_EXP4 +label WHILE_END4 +push local 4 +return +label IF_END3 +label IF_END0 +function Piece.moveDown 1 +push argument 0 +pop pointer 0 +push this 3 +push static 3 +lt +push this 7 +push static 3 +lt +and +push this 10 +and +push pointer 0 +push constant 1 +call Piece.fullSample 2 +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 1 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 5 +call Screen.drawRectangle 4 +pop temp 0 +push this 1 +push constant 1 +add +pop this 1 +push this 3 +push constant 1 +add +pop this 3 +push this 5 +push constant 1 +add +pop this 5 +push this 7 +push constant 1 +add +pop this 7 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 3 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 7 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +push constant 10 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +goto IF_END0 +label IF_FALSE0 +push constant 0 +pop this 10 +label IF_END0 +push constant 0 +return +function Piece.moveLeft 1 +push argument 0 +pop pointer 0 +push this 0 +push constant 15 +add +push static 0 +gt +push this 10 +and +push this 4 +push constant 15 +add +push static 0 +gt +and +push pointer 0 +push constant 0 +call Piece.fullSample 2 +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 2 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 6 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push this 0 +push constant 1 +sub +pop this 0 +push this 2 +push constant 1 +sub +pop this 2 +push this 4 +push constant 1 +sub +pop this 4 +push this 6 +push constant 1 +sub +pop this 6 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +push constant 10 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +label IF_FALSE0 +push constant 0 +return +function Piece.moveRight 1 +push argument 0 +pop pointer 0 +push this 6 +push static 1 +lt +push this 10 +and +push this 2 +push static 1 +lt +and +push pointer 0 +push constant 2 +call Piece.fullSample 2 +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 4 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push this 0 +push constant 1 +add +pop this 0 +push this 2 +push constant 1 +add +pop this 2 +push this 4 +push constant 1 +add +pop this 4 +push this 6 +push constant 1 +add +pop this 6 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +push constant 10 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +label IF_FALSE0 +push constant 0 +return +function Piece.reDraw 1 +push argument 0 +pop pointer 0 +push argument 1 +push constant 175 +lt +push argument 5 +push constant 175 +lt +or +push argument 3 +push constant 336 +gt +or +push argument 7 +push constant 336 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push argument 4 +push constant 255 +gt +push argument 8 +push constant 255 +gt +or +push argument 2 +push constant 0 +lt +or +push argument 6 +push constant 0 +lt +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +return +label IF_FALSE1 +push argument 1 +push argument 3 +gt +push argument 5 +push argument 7 +gt +or +push argument 2 +push argument 4 +gt +or +push argument 6 +push argument 8 +gt +or +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push constant 0 +return +label IF_FALSE2 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push argument 1 +pop this 0 +push argument 2 +pop this 1 +push argument 3 +pop this 2 +push argument 4 +pop this 3 +push argument 5 +pop this 4 +push argument 6 +pop this 5 +push argument 7 +pop this 6 +push argument 8 +pop this 7 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Piece.rotate 1 +push argument 0 +pop pointer 0 +push constant 0 +not +pop local 0 +push this 9 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 8 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push this 6 +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 1 +push constant 1 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push pointer 0 +push this 0 +push this 1 +push this 2 +push this 3 +push this 6 +push constant 15 +sub +push this 7 +push constant 47 +sub +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE2 +label IF_FALSE1 +push this 8 +push constant 1 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push this 0 +push constant 16 +add +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +push this 6 +push constant 16 +sub +push this 7 +push this 6 +push constant 15 +sub +push this 1 +push constant 16 +sub +push this 6 +push this 1 +push constant 1 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE4 +label IF_FALSE3 +push this 8 +push constant 2 +eq +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push constant 16 +sub +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +push this 4 +push constant 32 +add +push this 5 +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE6 +label IF_FALSE5 +push this 8 +push constant 3 +eq +if-goto IF_TRUE7 +goto IF_FALSE7 +label IF_TRUE7 +push this 4 +push constant 16 +add +push this 5 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 7 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE8 +goto IF_FALSE8 +label IF_TRUE8 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push this 2 +push this 3 +push constant 16 +add +push this 4 +push constant 16 +add +push this 5 +push constant 32 +sub +push this 6 +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE8 +label IF_FALSE7 +push this 8 +push constant 4 +eq +if-goto IF_TRUE9 +goto IF_FALSE9 +label IF_TRUE9 +push this 4 +push constant 32 +add +push this 5 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE10 +goto IF_FALSE10 +label IF_TRUE10 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +push this 4 +push constant 32 +add +push this 5 +push constant 32 +sub +push this 6 +push constant 16 +add +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE10 +label IF_FALSE9 +push this 8 +push constant 5 +eq +if-goto IF_TRUE11 +goto IF_FALSE11 +label IF_TRUE11 +push this 0 +push constant 32 +add +push this 1 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE12 +goto IF_FALSE12 +label IF_TRUE12 +push pointer 0 +push this 0 +push constant 32 +add +push this 1 +push constant 32 +sub +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push this 5 +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE12 +label IF_FALSE11 +goto IF_END0 +label IF_FALSE0 +push this 9 +push constant 1 +eq +if-goto IF_TRUE13 +goto IF_FALSE13 +label IF_TRUE13 +push this 8 +push constant 0 +eq +if-goto IF_TRUE14 +goto IF_FALSE14 +label IF_TRUE14 +push this 0 +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push constant 1 +sub +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE15 +goto IF_FALSE15 +label IF_TRUE15 +push pointer 0 +push this 0 +push constant 16 +sub +push this 5 +push this 6 +push this 5 +push constant 15 +add +push this 0 +push this 1 +push this 2 +push this 3 +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE15 +label IF_FALSE14 +push this 8 +push constant 1 +eq +if-goto IF_TRUE16 +goto IF_FALSE16 +label IF_TRUE16 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE17 +goto IF_FALSE17 +label IF_TRUE17 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +push this 6 +push this 7 +push constant 16 +add +push this 4 +push this 5 +push constant 32 +add +push this 6 +push this 3 +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE17 +label IF_FALSE16 +push this 8 +push constant 2 +eq +if-goto IF_TRUE18 +goto IF_FALSE18 +label IF_TRUE18 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 32 +sub +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE19 +goto IF_FALSE19 +label IF_TRUE19 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push constant 32 +sub +push this 5 +push this 6 +push constant 32 +sub +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE19 +label IF_FALSE18 +push this 8 +push constant 3 +eq +if-goto IF_TRUE20 +goto IF_FALSE20 +label IF_TRUE20 +push this 0 +push constant 16 +sub +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 7 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE21 +goto IF_FALSE21 +label IF_TRUE21 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push this 2 +push this 3 +push constant 16 +sub +push this 4 +push constant 16 +sub +push this 5 +push constant 32 +add +push this 6 +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE21 +label IF_FALSE20 +push this 8 +push constant 4 +eq +if-goto IF_TRUE22 +goto IF_FALSE22 +label IF_TRUE22 +push this 4 +push constant 32 +sub +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE23 +goto IF_FALSE23 +label IF_TRUE23 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push constant 32 +sub +push this 5 +push constant 32 +add +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE23 +label IF_FALSE22 +push this 8 +push constant 5 +eq +if-goto IF_TRUE24 +goto IF_FALSE24 +label IF_TRUE24 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +add +push this 5 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +add +push this 7 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE25 +goto IF_FALSE25 +label IF_TRUE25 +push pointer 0 +push this 0 +push constant 32 +sub +push this 1 +push constant 16 +add +push this 2 +push constant 16 +sub +push this 3 +push this 4 +push this 5 +push constant 16 +sub +push this 6 +push constant 16 +add +push this 7 +push constant 32 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE25 +label IF_FALSE24 +goto IF_END13 +label IF_FALSE13 +push this 9 +push constant 2 +eq +if-goto IF_TRUE26 +goto IF_FALSE26 +label IF_TRUE26 +push this 8 +push constant 0 +eq +if-goto IF_TRUE27 +goto IF_FALSE27 +label IF_TRUE27 +push this 0 +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push this 1 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE28 +goto IF_FALSE28 +label IF_TRUE28 +push pointer 0 +push this 0 +push this 1 +push this 0 +push constant 15 +add +push this 1 +push constant 47 +add +push this 4 +push this 5 +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE28 +label IF_FALSE27 +push this 8 +push constant 1 +eq +if-goto IF_TRUE29 +goto IF_FALSE29 +label IF_TRUE29 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE30 +goto IF_FALSE30 +label IF_TRUE30 +push pointer 0 +push this 0 +push this 1 +push constant 16 +add +push this 0 +push constant 15 +add +push this 1 +push constant 31 +add +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +push this 6 +push constant 16 +sub +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE30 +label IF_FALSE29 +push this 8 +push constant 2 +eq +if-goto IF_TRUE31 +goto IF_FALSE31 +label IF_TRUE31 +push this 0 +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 32 +add +push this 3 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE32 +goto IF_FALSE32 +label IF_TRUE32 +push pointer 0 +push this 0 +push this 1 +push constant 16 +sub +push this 2 +push constant 32 +sub +push this 3 +push constant 16 +sub +push this 4 +push constant 16 +add +push this 5 +push constant 32 +sub +push this 6 +push constant 16 +add +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE32 +label IF_FALSE31 +push this 8 +push constant 3 +eq +if-goto IF_TRUE33 +goto IF_FALSE33 +label IF_TRUE33 +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE34 +goto IF_FALSE34 +label IF_TRUE34 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +push this 4 +push this 5 +push constant 32 +sub +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE34 +label IF_FALSE33 +push this 8 +push constant 4 +eq +if-goto IF_TRUE35 +goto IF_FALSE35 +label IF_TRUE35 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 32 +sub +push this 3 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE36 +goto IF_FALSE36 +label IF_TRUE36 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +push this 2 +push constant 32 +sub +push this 3 +push this 4 +push constant 16 +add +push this 5 +push constant 16 +sub +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE36 +label IF_FALSE35 +push this 8 +push constant 5 +eq +if-goto IF_TRUE37 +goto IF_FALSE37 +label IF_TRUE37 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +sub +push this 7 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE38 +goto IF_FALSE38 +label IF_TRUE38 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +push this 2 +push this 3 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +add +push this 6 +push constant 32 +sub +push this 7 +push constant 32 +add +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE38 +label IF_FALSE37 +goto IF_END26 +label IF_FALSE26 +push this 8 +push constant 0 +eq +if-goto IF_TRUE39 +goto IF_FALSE39 +label IF_TRUE39 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE40 +goto IF_FALSE40 +label IF_TRUE40 +push pointer 0 +push this 4 +push this 5 +push this 6 +push this 7 +push this 0 +push this 1 +push constant 32 +add +push this 0 +push constant 47 +add +push this 1 +push constant 47 +add +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE40 +label IF_FALSE39 +push this 8 +push constant 1 +eq +if-goto IF_TRUE41 +goto IF_FALSE41 +label IF_TRUE41 +push this 0 +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE42 +goto IF_FALSE42 +label IF_TRUE42 +push pointer 0 +push this 0 +push this 1 +push constant 16 +sub +push this 2 +push this 3 +push constant 16 +sub +push this 0 +push this 1 +push this 6 +push constant 16 +add +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE42 +label IF_FALSE41 +push this 8 +push constant 2 +eq +if-goto IF_TRUE43 +goto IF_FALSE43 +label IF_TRUE43 +push this 0 +push constant 32 +add +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +sub +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE44 +goto IF_FALSE44 +label IF_TRUE44 +push pointer 0 +push this 0 +push constant 32 +add +push this 1 +push constant 16 +add +push this 2 +push constant 32 +add +push this 3 +push constant 16 +add +push this 4 +push constant 16 +sub +push this 5 +push constant 32 +add +push this 6 +push constant 16 +add +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE44 +label IF_FALSE43 +push this 8 +push constant 3 +eq +if-goto IF_TRUE45 +goto IF_FALSE45 +label IF_TRUE45 +push this 4 +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE46 +goto IF_FALSE46 +label IF_TRUE46 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push this 5 +push constant 32 +add +push this 6 +push constant 16 +add +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE46 +label IF_FALSE45 +push this 8 +push constant 4 +eq +if-goto IF_TRUE47 +goto IF_FALSE47 +label IF_TRUE47 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 32 +add +push this 3 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE48 +goto IF_FALSE48 +label IF_TRUE48 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +add +push this 2 +push constant 32 +add +push this 3 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +add +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE48 +label IF_FALSE47 +push this 8 +push constant 5 +eq +if-goto IF_TRUE49 +goto IF_FALSE49 +label IF_TRUE49 +push this 0 +push constant 16 +sub +push this 1 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +add +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +add +push this 7 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE50 +goto IF_FALSE50 +label IF_TRUE50 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 32 +add +push this 2 +push this 3 +push constant 16 +add +push this 4 +push constant 16 +add +push this 5 +push this 6 +push constant 32 +add +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE50 +label IF_FALSE49 +label IF_END26 +label IF_END13 +label IF_END0 +push constant 0 +return diff --git a/projects/09/New folder/Tetris/Tetris.vm b/projects/09/New folder/Tetris/Tetris.vm new file mode 100755 index 0000000..0ed5ac1 --- /dev/null +++ b/projects/09/New folder/Tetris/Tetris.vm @@ -0,0 +1,999 @@ +function Tetris.tetris 25 +call Piece.init 0 +pop temp 0 +call Tetris.border 0 +pop temp 0 +push constant 0 +pop static 0 +push constant 25 +call Array.new 1 +pop local 23 +push constant 0 +push local 23 +add +push constant 16 +push constant 0 +push constant 31 +push constant 15 +push constant 0 +push constant 16 +push constant 47 +push constant 31 +push constant 0 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 23 +add +push constant 0 +push constant 0 +push constant 15 +push constant 15 +push constant 0 +push constant 16 +push constant 47 +push constant 31 +push constant 1 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 23 +add +push constant 32 +push constant 16 +push constant 47 +push constant 31 +push constant 0 +push constant 32 +push constant 47 +push constant 47 +push constant 2 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 23 +add +push constant 0 +push constant 0 +push constant 31 +push constant 15 +push constant 16 +push constant 16 +push constant 47 +push constant 31 +push constant 3 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 23 +add +push constant 16 +push constant 0 +push constant 47 +push constant 15 +push constant 0 +push constant 16 +push constant 31 +push constant 31 +push constant 4 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 23 +add +push constant 0 +push constant 0 +push constant 31 +push constant 15 +push constant 32 +push constant 0 +push constant 63 +push constant 15 +push constant 5 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 23 +add +push constant 0 +push constant 0 +push constant 15 +push constant 31 +push constant 16 +push constant 0 +push constant 31 +push constant 31 +push constant 6 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push argument 0 +push constant 3 +call Math.multiply 2 +pop static 1 +call Tetris.randomNumber 0 +pop static 2 +push constant 0 +push constant 0 +call Output.moveCursor 2 +pop temp 0 +push constant 7 +call String.new 1 +push constant 80 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push static 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 12 +call String.new 1 +push constant 78 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 120 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 80 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +label WHILE_EXP0 +push constant 0 +not +not +if-goto WHILE_END0 +push static 2 +pop local 12 +call Tetris.randomNumber 0 +pop static 2 +push local 12 +push local 23 +add +pop pointer 1 +push that 0 +pop local 24 +push constant 0 +push local 24 +add +pop pointer 1 +push that 0 +pop local 3 +push constant 1 +push local 24 +add +pop pointer 1 +push that 0 +pop local 4 +push constant 2 +push local 24 +add +pop pointer 1 +push that 0 +pop local 5 +push constant 3 +push local 24 +add +pop pointer 1 +push that 0 +pop local 6 +push constant 4 +push local 24 +add +pop pointer 1 +push that 0 +pop local 7 +push constant 5 +push local 24 +add +pop pointer 1 +push that 0 +pop local 8 +push constant 6 +push local 24 +add +pop pointer 1 +push that 0 +pop local 9 +push constant 7 +push local 24 +add +pop pointer 1 +push that 0 +pop local 10 +push constant 8 +push local 24 +add +pop pointer 1 +push that 0 +pop local 14 +push local 3 +push constant 240 +add +push local 4 +push local 5 +push constant 240 +add +push local 6 +push local 7 +push constant 240 +add +push local 8 +push local 9 +push constant 240 +add +push local 10 +push local 14 +call Piece.new 9 +pop local 0 +push local 0 +call Piece.draw 1 +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Tetris.finish 0 +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +return +label IF_FALSE1 +label IF_FALSE0 +push static 2 +push local 23 +add +pop pointer 1 +push that 0 +pop local 24 +push constant 0 +push local 24 +add +pop pointer 1 +push that 0 +pop local 3 +push constant 1 +push local 24 +add +pop pointer 1 +push that 0 +pop local 4 +push constant 2 +push local 24 +add +pop pointer 1 +push that 0 +pop local 5 +push constant 3 +push local 24 +add +pop pointer 1 +push that 0 +pop local 6 +push constant 4 +push local 24 +add +pop pointer 1 +push that 0 +pop local 7 +push constant 5 +push local 24 +add +pop pointer 1 +push that 0 +pop local 8 +push constant 6 +push local 24 +add +pop pointer 1 +push that 0 +pop local 9 +push constant 7 +push local 24 +add +pop pointer 1 +push that 0 +pop local 10 +push constant 8 +push local 24 +add +pop pointer 1 +push that 0 +pop local 14 +push local 3 +push constant 16 +add +push local 4 +push constant 32 +add +push local 5 +push constant 16 +add +push local 6 +push constant 32 +add +push local 7 +push constant 16 +add +push local 8 +push constant 32 +add +push local 9 +push constant 16 +add +push local 10 +push constant 32 +add +push local 14 +call Piece.new 9 +pop local 1 +push local 1 +call Piece.draw 1 +pop temp 0 +label WHILE_EXP1 +push local 0 +call Piece.getMove 1 +not +if-goto WHILE_END1 +push constant 0 +pop local 15 +label WHILE_EXP2 +push local 15 +push constant 3 +lt +not +if-goto WHILE_END2 +call Keyboard.keyPressed 0 +pop local 11 +push local 11 +push constant 130 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +call Piece.moveLeft 1 +pop temp 0 +push constant 80 +call Sys.wait 1 +pop temp 0 +label IF_FALSE2 +push local 11 +push constant 132 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 0 +call Piece.moveRight 1 +pop temp 0 +push constant 80 +call Sys.wait 1 +pop temp 0 +label IF_FALSE3 +push local 11 +push constant 131 +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 0 +call Piece.rotate 1 +pop temp 0 +label IF_FALSE4 +push local 11 +push constant 133 +eq +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push local 0 +call Piece.moveDown 1 +pop temp 0 +push local 0 +call Piece.moveDown 1 +pop temp 0 +label IF_FALSE5 +push local 15 +push constant 1 +add +pop local 15 +goto WHILE_EXP2 +label WHILE_END2 +push local 0 +call Piece.moveDown 1 +pop temp 0 +push local 2 +push constant 1 +add +pop local 2 +push constant 80 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP1 +label WHILE_END1 +push constant 0 +pop local 2 +push local 0 +call Piece.dispose 1 +pop temp 0 +call Tetris.completeRow 0 +pop temp 0 +push constant 0 +push constant 7 +call Output.moveCursor 2 +pop temp 0 +push static 0 +call Output.printInt 1 +pop temp 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push constant 16 +push constant 32 +push constant 80 +push constant 96 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push local 1 +call Piece.dispose 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Tetris.completeRow 4 +push constant 16384 +push constant 11 +add +pop local 0 +push constant 15 +pop local 1 +label WHILE_EXP0 +push local 1 +push constant 0 +gt +not +if-goto WHILE_END0 +push constant 0 +not +pop local 3 +push constant 0 +pop local 2 +label WHILE_EXP1 +push local 2 +push constant 10 +lt +push local 3 +and +not +if-goto WHILE_END1 +push local 0 +push local 2 +add +push local 1 +push constant 512 +call Math.multiply 2 +add +call Memory.peek 1 +push local 3 +and +pop local 3 +push local 2 +push constant 1 +add +pop local 2 +goto WHILE_EXP1 +label WHILE_END1 +push local 3 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push constant 176 +push local 1 +push constant 16 +call Math.multiply 2 +push constant 335 +push local 1 +push constant 16 +call Math.multiply 2 +push constant 15 +add +call Screen.drawRectangle 4 +pop temp 0 +push static 0 +push constant 1 +add +pop static 0 +push local 1 +call Tetris.shift 1 +pop temp 0 +label IF_FALSE0 +push local 1 +push constant 1 +sub +pop local 1 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Tetris.shift 5 +push constant 16384 +push constant 11 +add +pop local 2 +label WHILE_EXP0 +push argument 0 +push constant 1 +gt +not +if-goto WHILE_END0 +push constant 0 +pop local 0 +label WHILE_EXP1 +push local 0 +push constant 10 +lt +not +if-goto WHILE_END1 +push constant 0 +pop local 4 +label WHILE_EXP2 +push local 4 +push constant 16 +lt +not +if-goto WHILE_END2 +push local 2 +push local 0 +add +push argument 0 +push constant 1 +sub +push constant 512 +call Math.multiply 2 +push local 4 +push constant 32 +call Math.multiply 2 +add +add +pop local 3 +push local 3 +call Memory.peek 1 +pop local 1 +push local 2 +push local 0 +add +push argument 0 +push constant 512 +call Math.multiply 2 +push local 4 +push constant 32 +call Math.multiply 2 +add +add +push local 1 +call Memory.poke 2 +pop temp 0 +push local 3 +push constant 0 +call Memory.poke 2 +pop temp 0 +push local 4 +push constant 1 +add +pop local 4 +goto WHILE_EXP2 +label WHILE_END2 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push argument 0 +push constant 1 +sub +pop argument 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Tetris.border 0 +push constant 175 +push constant 0 +push constant 175 +push constant 255 +call Screen.drawLine 4 +pop temp 0 +push constant 336 +push constant 0 +push constant 336 +push constant 255 +call Screen.drawLine 4 +pop temp 0 +push constant 0 +return +function Tetris.newPiece 1 +push constant 9 +call Array.new 1 +pop local 0 +push constant 0 +push local 0 +add +push argument 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 0 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 0 +add +push argument 3 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 0 +add +push argument 4 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 0 +add +push argument 5 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 0 +add +push argument 6 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 7 +push local 0 +add +push argument 7 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 8 +push local 0 +add +push argument 8 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +return +function Tetris.randomNumber 4 +push constant 7 +pop local 0 +push constant 13 +pop local 1 +push constant 1133 +pop local 2 +push local 0 +push static 1 +call Math.multiply 2 +push local 1 +add +pop local 3 +push local 3 +push local 2 +call Tetris.mod 2 +pop static 1 +push static 1 +push constant 7 +call Tetris.mod 2 +return +function Tetris.finish 1 +call Screen.clearScreen 0 +pop temp 0 +push constant 10 +push constant 24 +call Output.moveCursor 2 +pop temp 0 +push constant 12 +call String.new 1 +push constant 89 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push static 0 +call Output.printInt 1 +pop temp 0 +push constant 10000 +call Sys.wait 1 +pop temp 0 +call Screen.clearScreen 0 +pop temp 0 +push constant 10 +push constant 0 +call Output.moveCursor 2 +pop temp 0 +push constant 63 +call String.new 1 +push constant 87 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 44 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 89 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 78 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Keyboard.readChar 0 +pop local 0 +push local 0 +push constant 89 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Screen.clearScreen 0 +pop temp 0 +push constant 0 +return +label IF_FALSE0 +push local 0 +push constant 78 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +call Screen.clearScreen 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +label IF_FALSE1 +push constant 0 +not +return +function Tetris.mod 2 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +return +label IF_FALSE0 +push argument 0 +push argument 1 +call Math.divide 2 +push argument 1 +call Math.multiply 2 +pop local 1 +push argument 0 +push local 1 +sub +pop local 0 +push local 0 +return diff --git a/projects/09/New folder/Tetris/source/Main.jack b/projects/09/New folder/Tetris/source/Main.jack new file mode 100755 index 0000000..2dcf4ba --- /dev/null +++ b/projects/09/New folder/Tetris/source/Main.jack @@ -0,0 +1,19 @@ +class Main { + function void main (){ + var int s; + let s = -1; + do Output.moveCursor(0,20); + do Output.printString("Welcome to Tetris"); + do Sys.wait(2000); + do Output.println(); + do Output.println(); + do Output.println(); + while ((s < 0) | (s > 100)){ // gets a number used for seed for the random function + let s = Keyboard.readInt("Enter a number between 0 and 100:"); + do Screen.clearScreen(); + } + do Sys.wait(2000); + do Tetris.tetris(s); + return; + } +} \ No newline at end of file diff --git a/projects/09/New folder/Tetris/source/Piece.jack b/projects/09/New folder/Tetris/source/Piece.jack new file mode 100755 index 0000000..3ca2309 --- /dev/null +++ b/projects/09/New folder/Tetris/source/Piece.jack @@ -0,0 +1,473 @@ +class Piece { + static int lBorder, rBorder, uBorder, dBorder, st; + field int x1, y1, x2, y2, x3, y3, x4, y4, piece, direction; + field bool move; + static Array st; + + constructor Piece new(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4, int p) { + let x1 = Ax1; + let y1 = Ay1; + let x2 = Ax2; + let y2 = Ay2; + let x3 = Ax3; + let y3 = Ay3; + let x4 = Ax4; + let y4 = Ay4; + let piece = p; + let direction = 0; + let move = true; + return this; + } + + function void init(){ + var int a; + let lBorder = 0; + let rBorder = 511; + let uBorder = 0; + let dBorder = 255; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + return; + } + + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** draws 2 rectangles also checks if there is a piece at the spawn which will indicate end of the game. */ + method bool draw() { + var bool finish; + let finish = true; + let finish = Piece.sample(x1,y1) & finish; + let finish = Piece.sample(x2,y2) & finish; + let finish = Piece.sample(x3,y3) & finish; + let finish = Piece.sample(x4,y4) & finish; + if (finish){ + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return true; + } + return false; + } + + /** Erases the square from the screen. */ + method void erase() { + do Screen.setColor(false); + do Screen.drawRectangle(x1, y2, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return; + } + /** checks if those coodinates hold any value > 0. */ + function bool sample(int x, int y){ + var int value, address, bit, memBlock; + let memBlock = x / 16; + let address = (32 * y) + memBlock + 16384; + if (address > 24576){ + return false; + } + let value = Memory.peek(address); + if (value = 0){ + return true; + } + return false; + } + + method bool getMove(){ + return move; + } + + /** Checks if the piece can move in the given direction(dir). */ + method bool fullSample(int dir){ + var int size1, size2, i, j; + var bool result, flagUpon; + if (dir = 1){ //down + let size1 = x2 - x1; + let size2 = x4 - x3; + let result = true; + while (i < size1){ // for each block of the first rectangle + let j = 0; + let flagUpon = false; + while (j < size2){ // for each block of the second rectangle + if ((x1 + i) = (x3 + j)){ // if this block of the first rectangle sits upon a block of the second rectangle + let flagUpon = true; + } + let result = result & Piece.sample(x3 + j, y4 + 1); // if there is a block under the second rectangle + let j = j + 16; // sets the coords for the next block of the second rectangle + } + if (~(flagUpon)){ + let result = result & Piece.sample(x1 + i, y2 + 1); // if there is a block under the first rectangle + } + let i = i + 16; // sets the coords for the next block of the firs rectangle + } + return result; + } + else{ + if (dir = 2){ //right + let size1 = y2 - y1; + let size2 = y4 - y3; + let result = true; + while (i < size1){ + let j = 0; + let flagUpon = false; + while (j < size2){ + if ((y1 + i) = (y3 + j)){ + let flagUpon = true; + } + let result = result & Piece.sample(x4 + 1, (y3 + j)); + let j = j + 16; + } + if (~(flagUpon)){ + let result = result & Piece.sample(x2 + 1, (y1 + i)); + } + let i = i +16; + } + return result; + } + else{ // left + let size1 = y2 - y1; + let size2 = y4 - y3; + let result = true; + while (i < size2){ + let j = 0; + let flagUpon = false; + while (j < size1){ + if ((y3 + i) = (y1 + j)){ + let flagUpon = true; + } + let result = result & Piece.sample(x1 - 1, (y1 + j)); + let j = j + 16; + } + if (~(flagUpon)){ + let result = result & Piece.sample(x3 - 1, (y3 + i)); + } + let i = i + 16; + } + return result; + } + } + } + + /** Moves the game piece 16 pixels down. */ + method void moveDown() { + var int i; + if ((y2 < dBorder) & (y4 < dBorder) & (move) & fullSample(1)) { + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x2, y1); + do Screen.drawRectangle(x3, y3, x4, y3); + let y1 = y1 + 1; + let y2 = y2 + 1; + let y3 = y3 + 1; + let y4 = y4 + 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y2, x2, y2); + do Screen.drawRectangle(x3, y4, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + else{ + let move = false; + } + return; + } + + /** Moves the game piece 16 pixels to the left. */ + method void moveLeft() { + var int i; + if ((x1 + 15 > lBorder) & (move) & (x3 + 15 > lBorder)& fullSample(0)){ + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x2, y1, x2, y2); + do Screen.drawRectangle(x4, y3, x4, y4); + let x1 = x1 - 1; + let x2 = x2 - 1; + let x3 = x3 - 1; + let x4 = x4 - 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + return; + } + + /** Moves the game piece 16 pixels to the right. */ + method void moveRight() { + var int i; + if ((x4 < rBorder) & (move) & (x2 < rBorder) & fullSample(2)){ + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x1, y2); + do Screen.drawRectangle(x3, y3, x3, y4); + let x1 = x1 + 1; + let x2 = x2 + 1; + let x3 = x3 + 1; + let x4 = x4 + 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + return; + } + + /** Deletes the piece and draws it at the new coodinates. */ + method void reDraw(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4){ + var int absTmp; + if((Ax1 < 175) | (Ax3 < 175) | (Ax2 > 336) | (Ax4 > 336)){ + return; + } + if((Ay2 > 255) | (Ay4 > 255) | (Ay1 < 0) | (Ay3 < 0)){ + return; + } + if((Ax1 > Ax2) | (Ax3 > Ax4) | (Ay1 > Ay2) | (Ay3 > Ay4)){ + return; + } + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + do Screen.setColor(true); + let x1 = Ax1; + let y1 = Ay1; + let x2 = Ax2; + let y2 = Ay2; + let x3 = Ax3; + let y3 = Ay3; + let x4 = Ax4; + let y4 = Ay4; + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return; + } + + /** Rotates the piece clockwise. */ + method void rotate(){ + var bool samp; + let samp = true; + if (direction = 0){ // starting position + if (piece = 0){ // arrow + let samp = Piece.sample(x4, y1) & samp; // checks if the place at which the new piece will be drawn are free + let samp = Piece.sample(x4, y1 - 1) & samp; + if (samp){ + do reDraw(x1, y1, x2, y2, x4 - 15, y4 - 47, x4, y4); // redraws it at the new location + let direction = 1; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 + 16, y1) & samp; + let samp = Piece.sample(x1 + 16, y1 - 16) & samp; + let samp = Piece.sample(x4, y1 - 16) & samp; + if(samp){ + do reDraw(x1 + 16, y1 - 16, x4 - 16, y4, x4 - 15, y1 - 16, x4, y1 - 1); + let direction = 1; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 - 16, y1 - 16) & samp; + let samp = Piece.sample(x1 - 16, y1) & samp; + if (samp){ + do reDraw(x1 - 16, y1 - 16, x2 - 16, y2 + 16, x3 + 32, y3, x4, y4); + let direction = 1; + } + } + if (piece = 3){ + let samp = Piece.sample(x3 + 16, y3 - 32) & samp; + let samp = Piece.sample(x4, y4 - 16) & samp; + if (samp){ + do reDraw(x1 + 16, y1, x2, y2 + 16, x3 + 16, y3 - 32, x4, y4 - 16); + let direction = 1; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 + 32, y3 - 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 - 16, y2 + 16, x3 + 32, y3 - 32, x4 + 16, y4 - 16); + let direction = 1; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 + 32, y1 - 32) & samp; + let samp = Piece.sample(x2 + 16, y2 - 16) & samp; + let samp = Piece.sample(x4 - 16, y4 + 16) & samp; + if (samp){ + do reDraw(x1 + 32, y1 - 32, x2 + 16, y2 - 16, x3, y3, x4 - 16, y4 + 16); + let direction = 1; + } + } + } + else{ + if (direction = 1){ + if (piece = 0){ + let samp = Piece.sample(x1, y3) & samp; + let samp = Piece.sample(x1 - 1, y3) & samp; + if (samp){ + do reDraw(x1 - 16, y3, x4, y3 + 15, x1, y1, x2, y2); + let direction = 2; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3, y3 + 16) & samp; + let samp = Piece.sample(x3, y3 + 32) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 16, x4, y4 + 16, x3, y3 + 32, x4, y2); + let direction = 2; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x2 + 16, y2 - 16) & samp; + let samp = Piece.sample(x3 - 32, y3) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 16, x2 + 16, y2 - 16, x3 - 32, y3, x4 - 32, y4); + let direction = 2; + } + } + if (piece = 3){ + let samp = Piece.sample(x1 - 16, y1) & samp; + let samp = Piece.sample(x4, y4 + 16) & samp; + if (samp){ + do reDraw(x1 - 16, y1, x2, y2 - 16, x3 - 16, y3 +32, x4, y4 + 16); + let direction = 2; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 - 32, y3 + 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 + 16, y2 - 16, x3 - 32, y3 + 32, x4 - 16, y4 + 16); + let direction = 2; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3 + 16, y3 - 16) & samp; + let samp = Piece.sample(x4 + 32, y4 - 32) & samp; + if (samp){ + do reDraw(x1 - 32, y1 + 16, x2 - 16, y2, x3, y3 - 16, x4 + 16, y4 - 32); + let direction = 2; + } + } + } + else{ + if (direction = 2){ + if (piece = 0){ + let samp = Piece.sample(x1, y1+16) & samp; + let samp = Piece.sample(x1, y1+32) & samp; + if (samp){ + do reDraw(x1, y1, x1 + 15, y1 + 47, x3, y3, x4, y4); + let direction = 3; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3, y3 + 16) & samp; + let samp = Piece.sample(x3, y3 + 32) & samp; + if (samp){ + do reDraw(x1, y1 + 16, x1 + 15, y1 + 31, x1 + 16, y1 - 16, x4 - 16, y4); + let direction = 3; + } + } + if (piece = 2){ + let samp = Piece.sample(x1, y1 - 16) & samp; + let samp = Piece.sample(x2 + 32, y2 + 16) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1, y1 - 16, x2 - 32, y2 - 16, x3 + 16, y3 - 32, x4 + 16, y4); + let direction = 3; + } + } + if (piece = 3){ + let samp = Piece.sample(x2 - 16, y2 + 16) & samp; + let samp = Piece.sample(x3, y3 - 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 - 16, y2 + 16, x3, y3 - 32, x4 - 16, y4 - 16); + let direction = 3; + } + } + if (piece = 4){ + let samp = Piece.sample(x1 - 16, y1 - 16) & samp; + let samp = Piece.sample(x2 - 32, y2) & samp; + if (samp){ + do reDraw(x1 - 16, y1 - 16, x2 - 32, y2, x3 + 16, y3 - 16, x4, y4); + let direction = 3; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 + 16, y1 - 16) & samp; + let samp = Piece.sample(x3 - 16, y3 - 16) & samp; + let samp = Piece.sample(x4 - 32, y4 + 32) & samp; + if (samp){ + do reDraw(x1 + 16, y1 - 16, x2, y2, x3 - 16, y3 + 16, x4 - 32, y4 + 32); + let direction = 3; + } + } + } + else{ + if (piece = 0){ + let samp = Piece.sample(x4 + 16, y4) & samp; + let samp = Piece.sample(x4 + 32, y4) & samp; + if (samp){ + do reDraw(x3, y3, x4, y4, x1, y1 + 32, x1 + 47, y1 + 47); + let direction = 0; + } + } + if (piece = 1){ + let samp = Piece.sample(x1, y1 - 16) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1, y1 - 16, x2, y2 -16, x1, y1, x4 + 16, y4); + let direction = 0; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 + 32, y1 + 16) & samp; + let samp = Piece.sample(x3 - 16, y3 + 32) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1 + 32, y1 + 16, x2 + 32, y2 + 16, x3 - 16, y3 + 32, x4 + 16, y4); + let direction = 0; + } + } + if (piece = 3){ + let samp = Piece.sample(x3, y3 + 32) & samp; + let samp = Piece.sample(x4 + 16, y4 + 16) & samp; + if (samp){ + do reDraw(x1, y1, x2 + 16, y2 - 16, x3, y3 + 32, x4 + 16, y4 + 16); + let direction = 0; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 - 16, y3 + 16) & samp; + let samp = Piece.sample(x2 + 32, y2) & samp; + if (samp){ + do reDraw(x1 + 16, y1 + 16, x2 + 32, y2, x3 - 16, y3 + 16, x4, y4); + let direction = 0; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 - 16, y1 + 32) & samp; + let samp = Piece.sample(x3 + 16, y3) & samp; + let samp = Piece.sample(x4 + 32, y4 - 16) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 32, x2, y2 + 16, x3 + 16, y3, x4 + 32, y4 - 16); + let direction = 0; + } + } + } + } + } + return; + } +} + diff --git a/projects/09/New folder/Tetris/source/Tetris.jack b/projects/09/New folder/Tetris/source/Tetris.jack new file mode 100755 index 0000000..0d15797 --- /dev/null +++ b/projects/09/New folder/Tetris/source/Tetris.jack @@ -0,0 +1,203 @@ +class Tetris { + static int points, seed, next_seed; + + function void tetris(int z){ + var Piece p, nextPiece; + var int i, x1, y1, x2, y2, x3, y3, x4, y4, key, j, randTmp, piece_number, moves; + var Array left_g, right_g, box, stick, left_z, right_z,dick, all_piece, tmp; + do Piece.init(); + do Tetris.border(); + let points = 0; + let all_piece = Array.new(25); + let all_piece[0] = Tetris.newPiece(16,0,31,15, 0,16,47,31, 0); // arrow + let all_piece[1] = Tetris.newPiece(0,0,15,15, 0,16,47,31, 1); // right_L + let all_piece[2] = Tetris.newPiece(32,16,47,31, 0,32,47,47, 2); // left_L + let all_piece[3] = Tetris.newPiece(0,0,31,15, 16,16,47,31, 3); // left_z + let all_piece[4] = Tetris.newPiece(16,0,47,15, 0,16,31,31, 4); // right_z + let all_piece[5] = Tetris.newPiece(0,0,31,15, 32,0,63,15, 5); //stick + let all_piece[6] = Tetris.newPiece(0,0,15,31, 16,0,31,31, 6); //box + + + let seed = z * 3; // multiply by 3, because it gets in a loop on some even numbers + let next_seed = Tetris.randomNumber(); + do Output.moveCursor(0,0); + do Output.printString("Point: "); + do Output.printInt(points); + do Output.println(); + do Output.printString("Next Piece: "); + while (true){ // The main game loop + let j = next_seed; + let next_seed = Tetris.randomNumber(); + let tmp = all_piece[j]; // initializes the coords of the game piece + let x1 = tmp[0]; + let y1 = tmp[1]; + let x2 = tmp[2]; + let y2 = tmp[3]; + let x3 = tmp[4]; + let y3 = tmp[5]; + let x4 = tmp[6]; + let y4 = tmp[7]; + let piece_number = tmp[8]; + let p = Piece.new(x1 + 240, y1, x2 + 240, y2, x3 + 240, y3, x4 + 240, y4, piece_number); + if (~(p.draw())){ // if a piece tries to spawn above a limit the game ends + if (~(Tetris.finish())){ + return; + } + } + let tmp = all_piece[next_seed]; + let x1 = tmp[0]; // initializes the coords of the next game piece that is being displayed + let y1 = tmp[1]; + let x2 = tmp[2]; + let y2 = tmp[3]; + let x3 = tmp[4]; + let y3 = tmp[5]; + let x4 = tmp[6]; + let y4 = tmp[7]; + let piece_number = tmp[8]; + let nextPiece = Piece.new(x1 + 16, y1 + 32, x2+16, y2 + 32, x3+16, y3 + 32, x4 + 16, y4 + 32, piece_number); + do nextPiece.draw(); + while (p.getMove()){ + let moves = 0; + while (moves < 3){ // one can move its piece 3 times before it moves down automatically + let key = Keyboard.keyPressed(); + if (key = 130){ + do p.moveLeft(); + do Sys.wait(80); + } + if (key = 132){ + do p.moveRight(); + do Sys.wait(80); + } + if (key = 131){ + do p.rotate(); + } + if (key = 133){ + do p.moveDown(); + do p.moveDown(); + } + let moves = moves +1; + } + do p.moveDown(); + let i = i + 1; + do Sys.wait(80); + } + let i = 0; + do p.dispose(); + do Tetris.completeRow(); + do Output.moveCursor(0,7); + do Output.printInt(points); + do Screen.setColor(false); + do Screen.drawRectangle(16,32,80,96); + do Screen.setColor(true); + do nextPiece.dispose(); + } + return; + } + + function void completeRow(){ // checks if a row has been completed + var int adddress, row, colloum; + var bool complete; + let adddress = 16384 + 11; + let row = 15; + while (row > 0){ // for each row + let complete = true; + let colloum = 0; + while ((colloum < 10) & (complete)){ // for each collum + let complete = Memory.peek(adddress + colloum + (row * 512)) & complete; + let colloum = colloum + 1; + } + if (complete){ // removes the row + do Screen.setColor(false); + do Screen.drawRectangle(176, row * 16, 335, ((row * 16)+ 15) ); + let points = points + 1; + do Tetris.shift(row); + } + let row = row - 1; + } + return; + } + + function void shift(int rowShift){ // shifts all rows above the completed one + var int j, val, adddress, tmp, k; + let adddress = 16384 + 11; + while (rowShift > 1){ // each row + let j = 0; + while (j < 10){ // collum in the game field + let k = 0; + while (k < 16){ // each line a in 16 x 16 box + let tmp = adddress + j + (((rowShift - 1) * 512) + (k * 32)); + let val = Memory.peek(tmp); + do Memory.poke(adddress + j + ((rowShift * 512) + (k * 32)), val); + do Memory.poke(tmp,0); + let k = k+ 1; + } + let j = j + 1; + } + let rowShift = rowShift - 1; + } + return; + } + + function void border(){ // draws a border + do Screen.drawLine(175,0,175,255); + do Screen.drawLine(336,0,336,255); + return; + } + + function Array newPiece(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4,int p){ + var Array gamepice; + let gamepice = Array.new(9); + let gamepice[0] = Ax1; + let gamepice[1] = Ay1; + let gamepice[2] = Ax2; + let gamepice[3] = Ay2; + let gamepice[4] = Ax3; + let gamepice[5] = Ay3; + let gamepice[6] = Ax4; + let gamepice[7] = Ay4; + let gamepice[8] = p; + return gamepice; + } + + function int randomNumber(){ // radom number generator + var int multiplier,additor,moduler,toBeModulated; + let multiplier = 7; + let additor = 13; + let moduler = 1133; + let toBeModulated = (multiplier * seed) + additor; + let seed = Tetris.mod(toBeModulated,moduler); + return Tetris.mod(seed,7); + } + + function bool finish(){ // after finishing the game the player has 2 options to start onether or to end the game + var char c; + do Screen.clearScreen(); + do Output.moveCursor(10,24); + do Output.printString("Your score: "); + do Output.printInt(points); + do Sys.wait(10000); + do Screen.clearScreen(); + do Output.moveCursor(10,0); + do Output.printString("Would you like to play again, for yes click 'Y' and for no 'N':"); + let c = Keyboard.readChar(); + if (c = 89){ + do Screen.clearScreen(); + return false; + } + if (c = 78){ + do Screen.clearScreen(); + do Sys.halt(); + } + return true; + } + + function int mod(int tbm, int mo){ //simple moduler devision + var int val, tmp2; + if (tbm < mo){ + return tbm; + } + let tmp2 = (tbm / mo) * mo; + let val = tbm - tmp2; + return val; + } +} \ No newline at end of file diff --git a/projects/09/Square/Main.jack b/projects/09/Square/Main.jack new file mode 100755 index 0000000..8311cc2 --- /dev/null +++ b/projects/09/Square/Main.jack @@ -0,0 +1,15 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/Square/Main.jack + +/** Initializes a new Square Dance game and starts running it. */ +class Main { + function void main() { + var SquareGame game; + let game = SquareGame.new(); + do game.run(); + do game.dispose(); + return; + } +} diff --git a/projects/09/Square/Square.jack b/projects/09/Square/Square.jack new file mode 100755 index 0000000..38066e5 --- /dev/null +++ b/projects/09/Square/Square.jack @@ -0,0 +1,108 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/Square/Square.jack + +/** Implements a graphical square. */ +class Square { + + field int x, y; // screen location of the square's top-left corner + field int size; // length of this square, in pixels + + /** Constructs a new square with a given location and size. */ + constructor Square new(int Ax, int Ay, int Asize) { + let x = Ax; + let y = Ay; + let size = Asize; + do draw(); + return this; + } + + /** Disposes this square. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** Draws the square on the screen. */ + method void draw() { + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + size, y + size); + return; + } + + /** Erases the square from the screen. */ + method void erase() { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + size, y + size); + return; + } + + /** Increments the square size by 2 pixels. */ + method void incSize() { + if (((y + size) < 254) & ((x + size) < 510)) { + do erase(); + let size = size + 2; + do draw(); + } + return; + } + + /** Decrements the square size by 2 pixels. */ + method void decSize() { + if (size > 2) { + do erase(); + let size = size - 2; + do draw(); + } + return; + } + + /** Moves the square up by 2 pixels. */ + method void moveUp() { + if (y > 1) { + do Screen.setColor(false); + do Screen.drawRectangle(x, (y + size) - 1, x + size, y + size); + let y = y - 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + size, y + 1); + } + return; + } + + /** Moves the square down by 2 pixels. */ + method void moveDown() { + if ((y + size) < 254) { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + size, y + 1); + let y = y + 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, (y + size) - 1, x + size, y + size); + } + return; + } + + /** Moves the square left by 2 pixels. */ + method void moveLeft() { + if (x > 1) { + do Screen.setColor(false); + do Screen.drawRectangle((x + size) - 1, y, x + size, y + size); + let x = x - 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + 1, y + size); + } + return; + } + + /** Moves the square right by 2 pixels. */ + method void moveRight() { + if ((x + size) < 510) { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + 1, y + size); + let x = x + 2; + do Screen.setColor(true); + do Screen.drawRectangle((x + size) - 1, y, x + size, y + size); + } + return; + } +} diff --git a/projects/09/Square/SquareGame.jack b/projects/09/Square/SquareGame.jack new file mode 100755 index 0000000..02393e2 --- /dev/null +++ b/projects/09/Square/SquareGame.jack @@ -0,0 +1,79 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/09/Square/SquareGame.jack + +/** + * Implements the Square Dance game. + * This simple game allows the user to move a black square around + * the screen, and change the square's size during the movement. + * When the game starts, a square of 30 by 30 pixels is shown at the + * top-left corner of the screen. The user controls the square as follows. + * The 4 arrow keys are used to move the square up, down, left, and right. + * The 'z' and 'x' keys are used, respectively, to decrement and increment + * the square's size. The 'q' key is used to quit the game. + */ + +class SquareGame { + field Square square; // the square of this game + field int direction; // the square's current direction: + // 0=none, 1=up, 2=down, 3=left, 4=right + + /** Constructs a new Square Game. */ + constructor SquareGame new() { + // Creates a 30 by 30 pixels square and positions it at the top-left + // of the screen. + let square = Square.new(0, 0, 30); + let direction = 0; // initial state is no movement + return this; + } + + /** Disposes this game. */ + method void dispose() { + do square.dispose(); + do Memory.deAlloc(this); + return; + } + + /** Moves the square in the current direction. */ + method void moveSquare() { + if (direction = 1) { do square.moveUp(); } + if (direction = 2) { do square.moveDown(); } + if (direction = 3) { do square.moveLeft(); } + if (direction = 4) { do square.moveRight(); } + do Sys.wait(5); // delays the next movement + return; + } + + /** Runs the game: handles the user's inputs and moves the square accordingly */ + method void run() { + var char key; // the key currently pressed by the user + var boolean exit; + let exit = false; + + while (~exit) { + // waits for a key to be pressed + while (key = 0) { + let key = Keyboard.keyPressed(); + do moveSquare(); + } + if (key = 81) { let exit = true; } // q key + if (key = 90) { do square.decSize(); } // z key + if (key = 88) { do square.incSize(); } // x key + if (key = 131) { let direction = 1; } // up arrow + if (key = 133) { let direction = 2; } // down arrow + if (key = 130) { let direction = 3; } // left arrow + if (key = 132) { let direction = 4; } // right arrow + + // waits for the key to be released + while (~(key = 0)) { + let key = Keyboard.keyPressed(); + do moveSquare(); + } + } // while + return; + } +} + + + diff --git a/projects/09/Tetris/Assembler.bat b/projects/09/Tetris/Assembler.bat new file mode 100755 index 0000000..93260ec --- /dev/null +++ b/projects/09/Tetris/Assembler.bat @@ -0,0 +1,27 @@ +@echo off + +rem $Id: Assembler.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo Assembler Starts the assembler in interactive mode. + echo Assembler FILE[.asm] Assembles FILE.asm to FILE.hack. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Compilers.jar;bin/lib/AssemblerGUI.jar;bin/lib/TranslatorsGUI.jar" ^ + HackAssemblerMain +) else ( + echo Assembling "%_arg1%" + java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Compilers.jar;bin/lib/AssemblerGUI.jar;bin/lib/TranslatorsGUI.jar" ^ + HackAssemblerMain "%_arg1%" +) +popd diff --git a/projects/09/Tetris/Assembler.sh b/projects/09/Tetris/Assembler.sh new file mode 100755 index 0000000..70db569 --- /dev/null +++ b/projects/09/Tetris/Assembler.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +# $Id: Assembler.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the assembler in interactive mode." + echo " `basename "$0"` FILE[.asm] Assembles FILE.asm to FILE.hack." +elif [ $# -eq 0 ] +then + # Run assembler in interactive mode + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Compilers.jar:bin/lib/AssemblerGUI.jar:bin/lib/TranslatorsGUI.jar" HackAssemblerMain & +else + # Convert arg1 to an absolute path and run assembler with arg1. + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi + echo Assembling "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Compilers.jar:bin/lib/AssemblerGUI.jar:bin/lib/TranslatorsGUI.jar" HackAssemblerMain "$arg1" +fi + diff --git a/projects/09/Tetris/CPUEmulator.bat b/projects/09/Tetris/CPUEmulator.bat new file mode 100755 index 0000000..f92cf40 --- /dev/null +++ b/projects/09/Tetris/CPUEmulator.bat @@ -0,0 +1,29 @@ +@echo off + +rem $Id: CPUEmulator.bat,v 1.3 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo CPUEmulator Starts the CPU Emulator in interactive mode. + echo CPUEmulator FILE.tst Starts the CPU Emulator and runs the FILE.tst + echo test script. The success/failure message + echo is printed to the command console. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + CPUEmulatorMain +) else ( +rem echo Running "%_arg1%" + java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + CPUEmulatorMain "%_arg1%" +) +popd diff --git a/projects/09/Tetris/CPUEmulator.sh b/projects/09/Tetris/CPUEmulator.sh new file mode 100755 index 0000000..033d9d7 --- /dev/null +++ b/projects/09/Tetris/CPUEmulator.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +# $Id: CPUEmulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the CPU Emulator in interactive mode." + echo " `basename "$0"` FILE.tst Starts the CPU Emulator and runs the File.tst" + echo " test script. The success/failure message" + echo " is printed to the command console." +elif [ $# -eq 0 ] +then + # Run CPU emulator in interactive mode + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" CPUEmulatorMain & +else + # Convert arg1 to an absolute path and run CPU emulator with arg1 + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi +# echo Running "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" CPUEmulatorMain "$arg1" +fi diff --git a/projects/09/Tetris/HardwareSimulator.bat b/projects/09/Tetris/HardwareSimulator.bat new file mode 100755 index 0000000..76baa31 --- /dev/null +++ b/projects/09/Tetris/HardwareSimulator.bat @@ -0,0 +1,30 @@ +@echo off + +rem $Id: HardwareSimulator.bat,v 1.3 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo HardwareSimulator Starts the Hardware Simulator in + echo interactive mode. + echo HardwareSimulator FILE.tst Starts the Hardware Simulator and runs the + echo FILE.tst test script. The success/failure + echo message is printed to the command console. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + HardwareSimulatorMain +) else ( +rem echo Running "%_arg1%" + java -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + HardwareSimulatorMain "%_arg1%" +) +popd diff --git a/projects/09/Tetris/HardwareSimulator.sh b/projects/09/Tetris/HardwareSimulator.sh new file mode 100755 index 0000000..47e7482 --- /dev/null +++ b/projects/09/Tetris/HardwareSimulator.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh + +# $Id: HardwareSimulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the Hardware Simulator in" + echo " interactive mode." + echo " `basename "$0"` FILE.tst Starts the Hardware Simulator and runs the" + echo " FILE.tst test script. The success/failure" + echo " message is printed to the command console." +elif [ $# -eq 0 ] +then + # Run hardware simulator in interactive mode + java -classpath "${CLASSPATH}:bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" HardwareSimulatorMain & +else + # Convert arg1 to an absolute path and run hardware simulator with arg1 + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi +# echo Running "$arg1" + java -classpath "${CLASSPATH}:bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" HardwareSimulatorMain "$arg1" +fi diff --git a/projects/09/Tetris/JackCompiler.bat b/projects/09/Tetris/JackCompiler.bat new file mode 100755 index 0000000..9399b94 --- /dev/null +++ b/projects/09/Tetris/JackCompiler.bat @@ -0,0 +1,26 @@ +@echo off + +rem $Id: JackCompiler.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo JackCompiler Compiles all .jack files in the current + echo working directory. + echo JackCompiler DIRECTORY Compiles all .jack files in DIRECTORY. + echo JackCompiler FILE.jack Compiles FILE.jack to FILE.vm. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) else ( + set "_arg1=%CD%" +) +pushd "%~dp0" +echo Compiling "%_arg1%" +java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/Compilers.jar" ^ + Hack.Compiler.JackCompiler "%_arg1%" +popd diff --git a/projects/09/Tetris/JackCompiler.py b/projects/09/Tetris/JackCompiler.py new file mode 100755 index 0000000..5782f99 --- /dev/null +++ b/projects/09/Tetris/JackCompiler.py @@ -0,0 +1,350 @@ +import os +from pathlib import Path +from tokenizer import Tokenizer +from vmwriter import VMWriter +from symbol_table import SymbolTable + + +# TODO add names to variables when you call for them, aka current_vm_append(thingtobeappended=blablac) + +class CompilationEngine: + def __init__(self, tokenizer, full_path_vm): + self.string = self.sub_type = self.class_name = self.function_type = '' + self.tab = self.recursion_index = 0 + self.tokenizer = tokenizer + self.sym_table = [] + self.vmwriter = VMWriter(full_path_vm) + self.current_vm = [] # used to reverse some of the commands, eg a+b need to be a b + + + def search_kind_of_sym(self, current_vm): + if self.sym_table[-1].kind_of(current_vm) is not None: + return self.sym_table[-1].kind_of(current_vm), self.sym_table[-1].index_of(current_vm) + for i in range(len(self.sym_table) - 2, -1, + -1): # start from the amount of sym_tables -2 so it starts from one below the current, + # until it is bigger than -1, walking it backwards + if self.sym_table[i].kind_of(current_vm) in ('static', 'this'): + return self.sym_table[i].kind_of(current_vm), self.sym_table[i].index_of(current_vm) + + def search_type_of_sym(self, current_vm): + for i in range(len(self.sym_table) - 1, -1, -1): + if self.sym_table[i].type_of(current_vm) is not None: + return self.sym_table[i].type_of(current_vm) + + def write_token(self): + if self.tokenizer.token_type() == 'stringConstant': + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token.strip( + '"') + ' \n' + else: + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token + ' \n' + + def compile_class(self): + self.sym_table.append(SymbolTable()) + self.tokenizer.advance() # class -> + self.tokenizer.advance() # type -> + self.class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + self.tokenizer.advance() # { -> + while self.tokenizer.token != '}': + if self.tokenizer.token in ['static', 'field']: + self.compile_class_var_dec() + if self.tokenizer.token in ['constructor', 'function', 'method']: + self.compile_subroutine() + self.tokenizer.advance() + self.sym_table.pop() + self.vmwriter.close_vm_file() + + def compile_class_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_subroutine(self): + self.sym_table.append(SymbolTable()) + self.sub_type = self.tokenizer.token + self.tokenizer.advance() # subroutine type(function|method|constructor) -> + self.function_type = self.tokenizer.token + self.tokenizer.advance() # subroutine kind(int|void|etc..) -> + sub_name = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + if self.sub_type == 'method': + self.sym_table[-1].start_subroutine('this', self.class_name) + self.compile_parameter_list() + self.tokenizer.advance() # { -> + while self.tokenizer.token == 'var': # create only symbol teable entries + self.compile_var_dec() + if self.sub_type == 'constructor': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('constant', self.sym_table[-2].var_count('field')) + self.vmwriter.write_call('Memory.alloc', 1) + self.vmwriter.write_pop('pointer', 0) + elif self.sub_type == 'method': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('argument', 0) + self.vmwriter.write_pop('pointer', 0) + else: + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + while self.tokenizer.token != '}': + self.compile_statements() + self.tokenizer.advance() + self.sym_table.pop() + + def compile_parameter_list(self): + if self.tokenizer.token != ')': + var_type = self.tokenizer.token + self.tokenizer.advance() # var ype -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # var name -> + while self.tokenizer.token == ',': + self.tokenizer.advance() # , -> + var_type = self.tokenizer.token + self.tokenizer.advance() # type -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # name -> + self.tokenizer.advance() # )-> + + def compile_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_statements(self): + while True: + if self.tokenizer.token == 'let': + self.compile_let() + elif self.tokenizer.token == 'if': + self.compile_if() + elif self.tokenizer.token == 'while': + self.compile_while() + elif self.tokenizer.token == 'do': + self.compile_do() + elif self.tokenizer.token == 'return': + self.compile_return() + else: + break + + def compile_do(self): + self.tokenizer.advance() # do -> + class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + if self.tokenizer.token == '(': # method + self.vmwriter.write_push('pointer', 0) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{class_name}', count + 1) + elif self.tokenizer.token == '.': # method or function + self.tokenizer.advance() # . -> + fname = f'{class_name}.{self.tokenizer.token}' + sname = f'{self.search_type_of_sym(class_name)}.{self.tokenizer.token}' + self.tokenizer.advance() # name -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_push(*self.search_kind_of_sym(class_name)) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_call(f'{sname}', count + 1) + else: + self.vmwriter.write_call(f'{fname}', count) + self.vmwriter.write_pop('temp', '0') + self.tokenizer.advance() # ; -> + + def compile_let(self): + flag_array = 0 + self.tokenizer.advance() # let -> + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # var_name -> + if self.tokenizer.token == '[': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.tokenizer.advance() # [ -> + self.compile_expression() + self.tokenizer.advance() # ] -> + flag_array = 1 + self.tokenizer.advance() # = -> + self.compile_expression() + self.tokenizer.advance() # ; -> + if flag_array == 0: + self.vmwriter.write_pop(*self.search_kind_of_sym(self.current_vm[-1])) + else: + self.vmwriter.write_pop('temp', 1) + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('temp', 1) + self.vmwriter.write_pop('that', 0) + self.current_vm.pop() + + def compile_while(self): + self.tokenizer.advance() # while -> + label1 = self.vmwriter.label_index + self.vmwriter.write_lable(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label2 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_goto(label1) + self.vmwriter.write_lable(label2) + + def compile_return(self): + self.tokenizer.advance() # return -> + if self.tokenizer.token != ';': + self.compile_expression() + self.vmwriter.write_return(self.function_type) + self.tokenizer.advance() # ; -> + + def compile_if(self): + self.tokenizer.advance() # if -> + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label1 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + label2 = self.vmwriter.label_index + self.vmwriter.write_goto(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.vmwriter.write_lable(label1) + if self.tokenizer.token == 'else': + self.tokenizer.advance() # else -> + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_lable(label2) + + def compile_expression(self): + self.compile_term() + while self.tokenizer.token in ['+', '-', '*', '/', '|', '=', '>', '<', '&']: + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # symbol -> + self.compile_term() + self.vmwriter.write_arithmetic(self.current_vm[-1]) + self.current_vm.pop() + + def compile_term(self): + if self.tokenizer.token == '(': # expression () + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + elif self.tokenizer.token in ['~', '-']: # uniry op + self.current_vm.append(self.tokenizer.token) + tmp = 'neg' if self.tokenizer.token == '-' else self.tokenizer.token + self.tokenizer.advance() # ~ or - -> + self.compile_term() + self.vmwriter.write_arithmetic(tmp) + self.current_vm.pop() + elif self.tokenizer.token_type() != 'symbol': + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # integer, string, keyword, varnname, subroutine_name, class_name, var_name -> + if self.tokenizer.token == '[': # Array + self.tokenizer.advance() # [ -> + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + self.compile_expression() + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('that', 0) + self.tokenizer.advance() # ] -> + elif self.tokenizer.token == '(': # subroutine_name () + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{self.current_vm[-1]}', count) + self.current_vm.pop() + elif self.tokenizer.token == '.': # method + if self.search_type_of_sym(self.current_vm[-1]) is not None: + flag = 1 + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + else: + flag = 0 + self.tokenizer.advance() # . -> + fname = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if flag == 1: + self.vmwriter.write_call(f'{self.search_type_of_sym(self.current_vm[-1])}.{fname}', count + 1) + else: + self.vmwriter.write_call(f'{self.current_vm[-1]}.{fname}', count) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'stringConstant': + self.vmwriter.write_push('constant', len(self.current_vm[-1].strip('"'))) + self.vmwriter.write_call('String.new', 1) + for index, item in enumerate(self.current_vm[-1].strip('"')): + self.vmwriter.write_push('constant', ord(item)) + self.vmwriter.write_call('String.appendChar', 2) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'integerConstant': + self.vmwriter.write_push('constant', self.current_vm[-1]) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'identifier': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + elif self.current_vm[-1] == 'true': + self.vmwriter.write_push('constant', '1') + self.vmwriter.write_arithmetic('neg') + self.current_vm.pop() + elif self.current_vm[-1] == 'false' or self.current_vm[-1] == 'null': + self.vmwriter.write_push('constant', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'this': + self.vmwriter.write_push('pointer', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'that': + self.vmwriter.write_push('pointer', '1') + self.current_vm.pop() + + def compile_expression_list(self): + count_exp = 0 + if self.tokenizer.token in ['(', '~', '-'] or self.tokenizer.token_type() != 'symbol': + count_exp += 1 + self.compile_expression() + while self.tokenizer.token == ',': + count_exp += 1 + self.tokenizer.advance() # , + self.compile_expression() + return count_exp + + +if __name__ == '__main__': + path = os.getcwd() + for root, dirs, files in os.walk(path, topdown=False): + for name in files: + if name[-4:] == 'jack': + tokenizer_main = Tokenizer() + tokenizer_main.clear_file(Path(root, name)) + full_path = Path(root, name[:-4] + 'vm') + comp_eng_main = CompilationEngine(tokenizer_main, full_path) + comp_eng_main.compile_class() diff --git a/projects/09/Tetris/JackCompiler.sh b/projects/09/Tetris/JackCompiler.sh new file mode 100755 index 0000000..699dfb8 --- /dev/null +++ b/projects/09/Tetris/JackCompiler.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh + +# $Id: JackCompiler.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Compiles all .jack files in the current" + echo " working directory." + echo " `basename "$0"` DIRECTORY Compiles all .jack files in DIRECTORY." + echo " `basename "$0"` FILE.jack Compiles FILE.jack to FILE.vm." +else + if [ $# -eq 0 ] + then + # Use current directory as arg1 + arg1="$dir" + else + # Convert arg1 to an absolute path + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="$dir/$1" + fi + fi + echo Compiling "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/Compilers.jar" Hack.Compiler.JackCompiler "$arg1" +fi diff --git a/projects/09/Tetris/Main.jack b/projects/09/Tetris/Main.jack new file mode 100755 index 0000000..2dcf4ba --- /dev/null +++ b/projects/09/Tetris/Main.jack @@ -0,0 +1,19 @@ +class Main { + function void main (){ + var int s; + let s = -1; + do Output.moveCursor(0,20); + do Output.printString("Welcome to Tetris"); + do Sys.wait(2000); + do Output.println(); + do Output.println(); + do Output.println(); + while ((s < 0) | (s > 100)){ // gets a number used for seed for the random function + let s = Keyboard.readInt("Enter a number between 0 and 100:"); + do Screen.clearScreen(); + } + do Sys.wait(2000); + do Tetris.tetris(s); + return; + } +} \ No newline at end of file diff --git a/projects/09/Tetris/Main.vm b/projects/09/Tetris/Main.vm new file mode 100755 index 0000000..9931b90 --- /dev/null +++ b/projects/09/Tetris/Main.vm @@ -0,0 +1,147 @@ +function Main.main 1 +push constant 1 +neg +pop local 0 +push constant 0 +push constant 20 +call Output.moveCursor 2 +pop temp 0 +push constant 17 +call String.new 1 +push constant 87 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push constant 2000 +call Sys.wait 1 +pop temp 0 +call Output.println 0 +pop temp 0 +call Output.println 0 +pop temp 0 +call Output.println 0 +pop temp 0 +label WHILE_EXP0 +push local 0 +push constant 0 +lt +push local 0 +push constant 100 +gt +or +not +if-goto WHILE_END0 +push constant 33 +call String.new 1 +push constant 69 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Keyboard.readInt 1 +pop local 0 +call Screen.clearScreen 0 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 2000 +call Sys.wait 1 +pop temp 0 +push local 0 +call Tetris.tetris 1 +pop temp 0 +push constant 0 +return diff --git a/projects/09/Tetris/OS/Array.vm b/projects/09/Tetris/OS/Array.vm new file mode 100755 index 0000000..aa4c9e8 --- /dev/null +++ b/projects/09/Tetris/OS/Array.vm @@ -0,0 +1,23 @@ +function Array.new 0 +push argument 0 +push constant 0 +gt +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 2 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +call Memory.alloc 1 +return +function Array.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return diff --git a/projects/09/Tetris/OS/Keyboard.vm b/projects/09/Tetris/OS/Keyboard.vm new file mode 100755 index 0000000..a806c4e --- /dev/null +++ b/projects/09/Tetris/OS/Keyboard.vm @@ -0,0 +1,102 @@ +function Keyboard.init 0 +push constant 0 +return +function Keyboard.keyPressed 0 +push constant 24576 +call Memory.peek 1 +return +function Keyboard.readChar 2 +push constant 0 +call Output.printChar 1 +pop temp 0 +label WHILE_EXP0 +push local 1 +push constant 0 +eq +push local 0 +push constant 0 +gt +or +not +if-goto WHILE_END0 +call Keyboard.keyPressed 0 +pop local 0 +push local 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +pop local 1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +call String.backSpace 0 +call Output.printChar 1 +pop temp 0 +push local 1 +call Output.printChar 1 +pop temp 0 +push local 1 +return +function Keyboard.readLine 5 +push constant 80 +call String.new 1 +pop local 3 +push argument 0 +call Output.printString 1 +pop temp 0 +call String.newLine 0 +pop local 1 +call String.backSpace 0 +pop local 2 +label WHILE_EXP0 +push local 4 +not +not +if-goto WHILE_END0 +call Keyboard.readChar 0 +pop local 0 +push local 0 +push local 1 +eq +pop local 4 +push local 4 +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push local 2 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 3 +call String.eraseLastChar 1 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 3 +push local 0 +call String.appendChar 2 +pop local 3 +label IF_END1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +return +function Keyboard.readInt 2 +push argument 0 +call Keyboard.readLine 1 +pop local 0 +push local 0 +call String.intValue 1 +pop local 1 +push local 0 +call String.dispose 1 +pop temp 0 +push local 1 +return diff --git a/projects/09/Tetris/OS/Math.vm b/projects/09/Tetris/OS/Math.vm new file mode 100755 index 0000000..b660688 --- /dev/null +++ b/projects/09/Tetris/OS/Math.vm @@ -0,0 +1,408 @@ +function Math.init 1 +push constant 16 +call Array.new 1 +pop static 1 +push constant 16 +call Array.new 1 +pop static 0 +push constant 0 +push static 0 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 0 +add +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Math.abs 0 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +neg +pop argument 0 +label IF_FALSE0 +push argument 0 +return +function Math.multiply 5 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 4 +push argument 0 +call Math.abs 1 +pop argument 0 +push argument 1 +call Math.abs 1 +pop argument 1 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop local 1 +push argument 1 +pop argument 0 +push local 1 +pop argument 1 +label IF_FALSE0 +label WHILE_EXP0 +push local 2 +push constant 1 +sub +push argument 1 +push constant 1 +sub +lt +not +if-goto WHILE_END0 +push local 3 +push static 0 +add +pop pointer 1 +push that 0 +push argument 1 +and +push constant 0 +eq +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push argument 0 +add +pop local 0 +push local 2 +push local 3 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 2 +label IF_FALSE1 +push argument 0 +push argument 0 +add +pop argument 0 +push local 3 +push constant 1 +add +pop local 3 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +neg +pop local 0 +label IF_FALSE2 +push local 0 +return +function Math.divide 4 +push argument 1 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 3 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 2 +push constant 0 +push static 1 +add +push argument 1 +call Math.abs 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push argument 0 +call Math.abs 1 +pop argument 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +push local 3 +not +and +not +if-goto WHILE_END0 +push constant 32767 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +sub +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +lt +pop local 3 +push local 3 +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push constant 1 +add +push static 1 +add +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +push argument 0 +push constant 1 +sub +gt +pop local 3 +push local 3 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +label IF_FALSE1 +goto WHILE_EXP0 +label WHILE_END0 +label WHILE_EXP1 +push local 0 +push constant 1 +neg +gt +not +if-goto WHILE_END1 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +push argument 0 +push constant 1 +sub +gt +not +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 1 +push local 0 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 1 +push argument 0 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +sub +pop argument 0 +label IF_FALSE3 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 2 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 1 +neg +pop local 1 +label IF_FALSE4 +push local 1 +return +function Math.sqrt 4 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 4 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push constant 7 +pop local 0 +label WHILE_EXP0 +push local 0 +push constant 1 +neg +gt +not +if-goto WHILE_END0 +push local 3 +push local 0 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 1 +push local 1 +push local 1 +call Math.multiply 2 +pop local 2 +push local 2 +push argument 0 +gt +not +push local 2 +push constant 0 +lt +not +and +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 1 +pop local 3 +label IF_FALSE1 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +return +function Math.max 0 +push argument 0 +push argument 1 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop argument 1 +label IF_FALSE0 +push argument 1 +return +function Math.min 0 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop argument 1 +label IF_FALSE0 +push argument 1 +return diff --git a/projects/09/Tetris/OS/Memory.vm b/projects/09/Tetris/OS/Memory.vm new file mode 100755 index 0000000..8c74b87 --- /dev/null +++ b/projects/09/Tetris/OS/Memory.vm @@ -0,0 +1,376 @@ +function Memory.init 0 +push constant 0 +pop static 0 +push constant 2048 +push static 0 +add +push constant 14334 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2049 +push static 0 +add +push constant 2050 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Memory.peek 0 +push argument 0 +push static 0 +add +pop pointer 1 +push that 0 +return +function Memory.poke 0 +push argument 0 +push static 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Memory.alloc 2 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 5 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 1 +pop argument 0 +label IF_FALSE1 +push constant 2048 +pop local 0 +label WHILE_EXP0 +push local 0 +push constant 16383 +lt +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +lt +and +not +if-goto WHILE_END0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop local 1 +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push constant 0 +eq +push local 1 +push constant 16382 +gt +or +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +push constant 0 +eq +or +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 1 +pop local 0 +goto IF_END2 +label IF_FALSE2 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +push local 1 +push constant 2 +add +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 1 +push local 0 +add +push local 0 +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END3 +label IF_FALSE3 +push constant 1 +push local 0 +add +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END3 +label IF_END2 +goto WHILE_EXP0 +label WHILE_END0 +push local 0 +push argument 0 +add +push constant 16379 +gt +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 6 +call Sys.error 1 +pop temp 0 +label IF_FALSE4 +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +push constant 2 +add +gt +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push argument 0 +push constant 2 +add +push local 0 +add +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +sub +push constant 2 +sub +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 2 +add +eq +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push argument 0 +push constant 3 +add +push local 0 +add +push local 0 +push argument 0 +add +push constant 4 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END6 +label IF_FALSE6 +push argument 0 +push constant 3 +add +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END6 +push constant 1 +push local 0 +add +push local 0 +push argument 0 +add +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_FALSE5 +push constant 0 +push local 0 +add +push constant 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 2 +add +return +function Memory.deAlloc 2 +push argument 0 +push constant 2 +sub +pop local 0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop local 1 +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 2 +sub +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END0 +label IF_FALSE0 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +push local 1 +push constant 2 +add +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 1 +push local 0 +add +push local 0 +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END1 +label IF_FALSE1 +push constant 1 +push local 0 +add +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END1 +label IF_END0 +push constant 0 +return diff --git a/projects/09/Tetris/OS/Output.vm b/projects/09/Tetris/OS/Output.vm new file mode 100755 index 0000000..b8addd7 --- /dev/null +++ b/projects/09/Tetris/OS/Output.vm @@ -0,0 +1,1852 @@ +function Output.init 0 +push constant 16384 +pop static 4 +push constant 0 +not +pop static 2 +push constant 32 +pop static 1 +push constant 0 +pop static 0 +push constant 6 +call String.new 1 +pop static 3 +call Output.initMap 0 +pop temp 0 +call Output.createShiftedMap 0 +pop temp 0 +push constant 0 +return +function Output.initMap 0 +push constant 127 +call Array.new 1 +pop static 5 +push constant 0 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 32 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 33 +push constant 12 +push constant 30 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 34 +push constant 54 +push constant 54 +push constant 20 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 35 +push constant 0 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 36 +push constant 12 +push constant 30 +push constant 51 +push constant 3 +push constant 30 +push constant 48 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 37 +push constant 0 +push constant 0 +push constant 35 +push constant 51 +push constant 24 +push constant 12 +push constant 6 +push constant 51 +push constant 49 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 38 +push constant 12 +push constant 30 +push constant 30 +push constant 12 +push constant 54 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 39 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 40 +push constant 24 +push constant 12 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 41 +push constant 6 +push constant 12 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 42 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 63 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 43 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 63 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 44 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 45 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 46 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 47 +push constant 0 +push constant 0 +push constant 32 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 1 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 48 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 49 +push constant 12 +push constant 14 +push constant 15 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 50 +push constant 30 +push constant 51 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 51 +push constant 30 +push constant 51 +push constant 48 +push constant 48 +push constant 28 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 52 +push constant 16 +push constant 24 +push constant 28 +push constant 26 +push constant 25 +push constant 63 +push constant 24 +push constant 24 +push constant 60 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 53 +push constant 63 +push constant 3 +push constant 3 +push constant 31 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 54 +push constant 28 +push constant 6 +push constant 3 +push constant 3 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 55 +push constant 63 +push constant 49 +push constant 48 +push constant 48 +push constant 24 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 56 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 57 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 24 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 58 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 59 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 60 +push constant 0 +push constant 0 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 61 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 62 +push constant 0 +push constant 0 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 64 +push constant 30 +push constant 51 +push constant 51 +push constant 59 +push constant 59 +push constant 59 +push constant 27 +push constant 3 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 63 +push constant 30 +push constant 51 +push constant 51 +push constant 24 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 65 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 66 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 67 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 68 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 69 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 70 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 71 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 59 +push constant 51 +push constant 51 +push constant 54 +push constant 44 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 72 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 73 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 74 +push constant 60 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 27 +push constant 27 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 75 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 76 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 77 +push constant 33 +push constant 51 +push constant 63 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 78 +push constant 51 +push constant 51 +push constant 55 +push constant 55 +push constant 63 +push constant 59 +push constant 59 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 79 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 80 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 81 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 59 +push constant 30 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 82 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 83 +push constant 30 +push constant 51 +push constant 51 +push constant 6 +push constant 28 +push constant 48 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 84 +push constant 63 +push constant 63 +push constant 45 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 85 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 86 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 87 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 88 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 30 +push constant 30 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 89 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 90 +push constant 63 +push constant 51 +push constant 49 +push constant 24 +push constant 12 +push constant 6 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 91 +push constant 30 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 92 +push constant 0 +push constant 0 +push constant 1 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 48 +push constant 32 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 93 +push constant 30 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 94 +push constant 8 +push constant 28 +push constant 54 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 95 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 96 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 97 +push constant 0 +push constant 0 +push constant 0 +push constant 14 +push constant 24 +push constant 30 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 98 +push constant 3 +push constant 3 +push constant 3 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 99 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 3 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 100 +push constant 48 +push constant 48 +push constant 48 +push constant 60 +push constant 54 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 101 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 63 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 102 +push constant 28 +push constant 54 +push constant 38 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 103 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 104 +push constant 3 +push constant 3 +push constant 3 +push constant 27 +push constant 55 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 105 +push constant 12 +push constant 12 +push constant 0 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 106 +push constant 48 +push constant 48 +push constant 0 +push constant 56 +push constant 48 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 107 +push constant 3 +push constant 3 +push constant 3 +push constant 51 +push constant 27 +push constant 15 +push constant 15 +push constant 27 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 108 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 109 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 63 +push constant 43 +push constant 43 +push constant 43 +push constant 43 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 110 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 111 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 112 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 113 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 114 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 55 +push constant 51 +push constant 3 +push constant 3 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 115 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 6 +push constant 24 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 116 +push constant 4 +push constant 6 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 117 +push constant 0 +push constant 0 +push constant 0 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 118 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 119 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 120 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 121 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 24 +push constant 15 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 122 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 27 +push constant 12 +push constant 6 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 123 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 124 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 125 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 126 +push constant 38 +push constant 45 +push constant 25 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 0 +return +function Output.create 1 +push constant 11 +call Array.new 1 +pop local 0 +push argument 0 +push static 5 +add +push local 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +push local 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 0 +add +push argument 3 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 0 +add +push argument 4 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 0 +add +push argument 5 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 0 +add +push argument 6 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 0 +add +push argument 7 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 7 +push local 0 +add +push argument 8 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 8 +push local 0 +add +push argument 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 9 +push local 0 +add +push argument 10 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 10 +push local 0 +add +push argument 11 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Output.createShiftedMap 4 +push constant 127 +call Array.new 1 +pop static 6 +push constant 0 +pop local 2 +label WHILE_EXP0 +push local 2 +push constant 127 +lt +not +if-goto WHILE_END0 +push local 2 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +push constant 11 +call Array.new 1 +pop local 1 +push local 2 +push static 6 +add +push local 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +pop local 3 +label WHILE_EXP1 +push local 3 +push constant 11 +lt +not +if-goto WHILE_END1 +push local 3 +push local 1 +add +push local 3 +push local 0 +add +pop pointer 1 +push that 0 +push constant 256 +call Math.multiply 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 3 +push constant 1 +add +pop local 3 +goto WHILE_EXP1 +label WHILE_END1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop local 2 +goto IF_END0 +label IF_FALSE0 +push local 2 +push constant 1 +add +pop local 2 +label IF_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.getMap 1 +push argument 0 +push constant 32 +lt +push argument 0 +push constant 126 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +pop argument 0 +label IF_FALSE0 +push static 2 +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +push static 6 +add +pop pointer 1 +push that 0 +pop local 0 +label IF_END1 +push local 0 +return +function Output.drawChar 4 +push argument 0 +call Output.getMap 1 +pop local 2 +push static 1 +pop local 0 +label WHILE_EXP0 +push local 1 +push constant 11 +lt +not +if-goto WHILE_END0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 256 +neg +and +pop local 3 +goto IF_END0 +label IF_FALSE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 255 +and +pop local 3 +label IF_END0 +push local 0 +push static 4 +add +push local 1 +push local 2 +add +pop pointer 1 +push that 0 +push local 3 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 32 +add +pop local 0 +push local 1 +push constant 1 +add +pop local 1 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.moveCursor 0 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 22 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 63 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 20 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push constant 2 +call Math.divide 2 +pop static 0 +push constant 32 +push argument 0 +push constant 352 +call Math.multiply 2 +add +push static 0 +add +pop static 1 +push argument 1 +push static 0 +push constant 2 +call Math.multiply 2 +eq +pop static 2 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return +function Output.printChar 0 +push argument 0 +call String.newLine 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Output.println 0 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +call String.backSpace 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +call Output.backSpace 0 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +call Output.drawChar 1 +pop temp 0 +push static 2 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push static 0 +push constant 1 +add +pop static 0 +push static 1 +push constant 1 +add +pop static 1 +label IF_FALSE2 +push static 0 +push constant 32 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +call Output.println 0 +pop temp 0 +goto IF_END3 +label IF_FALSE3 +push static 2 +not +pop static 2 +label IF_END3 +label IF_END1 +label IF_END0 +push constant 0 +return +function Output.printString 2 +push argument 0 +call String.length 1 +pop local 1 +label WHILE_EXP0 +push local 0 +push local 1 +lt +not +if-goto WHILE_END0 +push argument 0 +push local 0 +call String.charAt 2 +call Output.printChar 1 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.printInt 0 +push static 3 +push argument 0 +call String.setInt 2 +pop temp 0 +push static 3 +call Output.printString 1 +pop temp 0 +push constant 0 +return +function Output.println 0 +push static 1 +push constant 352 +add +push static 0 +sub +pop static 1 +push constant 0 +pop static 0 +push constant 0 +not +pop static 2 +push static 1 +push constant 8128 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop static 1 +label IF_FALSE0 +push constant 0 +return +function Output.backSpace 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push static 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push static 0 +push constant 1 +sub +pop static 0 +push static 1 +push constant 1 +sub +pop static 1 +goto IF_END1 +label IF_FALSE1 +push constant 31 +pop static 0 +push static 1 +push constant 32 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push constant 8128 +pop static 1 +label IF_FALSE2 +push static 1 +push constant 321 +sub +pop static 1 +label IF_END1 +push constant 0 +pop static 2 +goto IF_END0 +label IF_FALSE0 +push constant 0 +not +pop static 2 +label IF_END0 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return diff --git a/projects/09/Tetris/OS/Screen.vm b/projects/09/Tetris/OS/Screen.vm new file mode 100755 index 0000000..fccafb5 --- /dev/null +++ b/projects/09/Tetris/OS/Screen.vm @@ -0,0 +1,806 @@ +function Screen.init 1 +push constant 16384 +pop static 1 +push constant 0 +not +pop static 2 +push constant 17 +call Array.new 1 +pop static 0 +push constant 0 +push static 0 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 0 +add +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.clearScreen 1 +label WHILE_EXP0 +push local 0 +push constant 8192 +lt +not +if-goto WHILE_END0 +push local 0 +push static 1 +add +push constant 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.updateLocation 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +not +and +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END0 +push constant 0 +return +function Screen.setColor 0 +push argument 0 +pop static 2 +push constant 0 +return +function Screen.drawPixel 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 7 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 0 +push argument 0 +push local 0 +push constant 16 +call Math.multiply 2 +sub +pop local 1 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 0 +add +pop local 2 +push local 2 +push local 1 +push static 0 +add +pop pointer 1 +push that 0 +call Screen.updateLocation 2 +pop temp 0 +push constant 0 +return +function Screen.drawConditional 0 +push argument 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 1 +push argument 0 +call Screen.drawPixel 2 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +label IF_END0 +push constant 0 +return +function Screen.drawLine 11 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 8 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 2 +push argument 0 +sub +call Math.abs 1 +pop local 3 +push argument 3 +push argument 1 +sub +call Math.abs 1 +pop local 2 +push local 3 +push local 2 +lt +pop local 6 +push local 6 +push argument 3 +push argument 1 +lt +and +push local 6 +not +push argument 2 +push argument 0 +lt +and +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +pop local 4 +push argument 2 +pop argument 0 +push local 4 +pop argument 2 +push argument 1 +pop local 4 +push argument 3 +pop argument 1 +push local 4 +pop argument 3 +label IF_FALSE1 +push local 6 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 3 +pop local 4 +push local 2 +pop local 3 +push local 4 +pop local 2 +push argument 1 +pop local 1 +push argument 0 +pop local 0 +push argument 3 +pop local 8 +push argument 0 +push argument 2 +gt +pop local 7 +goto IF_END2 +label IF_FALSE2 +push argument 0 +pop local 1 +push argument 1 +pop local 0 +push argument 2 +pop local 8 +push argument 1 +push argument 3 +gt +pop local 7 +label IF_END2 +push constant 2 +push local 2 +call Math.multiply 2 +push local 3 +sub +pop local 5 +push constant 2 +push local 2 +call Math.multiply 2 +pop local 9 +push constant 2 +push local 2 +push local 3 +sub +call Math.multiply 2 +pop local 10 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 8 +lt +not +if-goto WHILE_END0 +push local 5 +push constant 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 5 +push local 9 +add +pop local 5 +goto IF_END3 +label IF_FALSE3 +push local 5 +push local 10 +add +pop local 5 +push local 7 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 0 +push constant 1 +sub +pop local 0 +goto IF_END4 +label IF_FALSE4 +push local 0 +push constant 1 +add +pop local 0 +label IF_END4 +label IF_END3 +push local 1 +push constant 1 +add +pop local 1 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawRectangle 9 +push argument 0 +push argument 2 +gt +push argument 1 +push argument 3 +gt +or +push argument 0 +push constant 0 +lt +or +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 9 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push argument 0 +push local 3 +push constant 16 +call Math.multiply 2 +sub +pop local 7 +push argument 2 +push constant 16 +call Math.divide 2 +pop local 4 +push argument 2 +push local 4 +push constant 16 +call Math.multiply 2 +sub +pop local 8 +push local 7 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 6 +push local 8 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 5 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 3 +add +pop local 0 +push local 4 +push local 3 +sub +pop local 2 +label WHILE_EXP0 +push argument 1 +push argument 3 +gt +not +not +if-goto WHILE_END0 +push local 0 +push local 2 +add +pop local 1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 5 +push local 6 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 6 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP1 +push local 0 +push local 1 +lt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 1 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +push argument 1 +push constant 1 +add +pop argument 1 +push local 1 +push constant 32 +add +push local 2 +sub +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawHorizontal 11 +push argument 1 +push argument 2 +call Math.min 2 +pop local 7 +push argument 1 +push argument 2 +call Math.max 2 +pop local 8 +push argument 0 +push constant 1 +neg +gt +push argument 0 +push constant 256 +lt +and +push local 7 +push constant 512 +lt +and +push local 8 +push constant 1 +neg +gt +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 7 +push constant 0 +call Math.max 2 +pop local 7 +push local 8 +push constant 511 +call Math.min 2 +pop local 8 +push local 7 +push constant 16 +call Math.divide 2 +pop local 1 +push local 7 +push local 1 +push constant 16 +call Math.multiply 2 +sub +pop local 9 +push local 8 +push constant 16 +call Math.divide 2 +pop local 2 +push local 8 +push local 2 +push constant 16 +call Math.multiply 2 +sub +pop local 10 +push local 9 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 5 +push local 10 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 4 +push argument 0 +push constant 32 +call Math.multiply 2 +push local 1 +add +pop local 0 +push local 2 +push local 1 +sub +pop local 6 +push local 0 +push local 6 +add +pop local 3 +push local 6 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 4 +push local 5 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP0 +push local 0 +push local 3 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +push local 4 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +label IF_FALSE0 +push constant 0 +return +function Screen.drawSymetric 0 +push argument 1 +push argument 3 +sub +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 3 +add +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +sub +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +add +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push constant 0 +return +function Screen.drawCircle 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 12 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push argument 2 +sub +push constant 0 +lt +push argument 0 +push argument 2 +add +push constant 511 +gt +or +push argument 1 +push argument 2 +sub +push constant 0 +lt +or +push argument 1 +push argument 2 +add +push constant 255 +gt +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 13 +call Sys.error 1 +pop temp 0 +label IF_FALSE1 +push argument 2 +pop local 1 +push constant 1 +push argument 2 +sub +pop local 2 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 0 +gt +not +if-goto WHILE_END0 +push local 2 +push constant 0 +lt +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 2 +push constant 2 +push local 0 +call Math.multiply 2 +add +push constant 3 +add +pop local 2 +goto IF_END2 +label IF_FALSE2 +push local 2 +push constant 2 +push local 0 +push local 1 +sub +call Math.multiply 2 +add +push constant 5 +add +pop local 2 +push local 1 +push constant 1 +sub +pop local 1 +label IF_END2 +push local 0 +push constant 1 +add +pop local 0 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return diff --git a/projects/09/Tetris/OS/String.vm b/projects/09/Tetris/OS/String.vm new file mode 100755 index 0000000..9b7577e --- /dev/null +++ b/projects/09/Tetris/OS/String.vm @@ -0,0 +1,393 @@ +function String.new 0 +push constant 3 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 14 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +call Array.new 1 +pop this 1 +label IF_FALSE1 +push argument 0 +pop this 0 +push constant 0 +pop this 2 +push pointer 0 +return +function String.dispose 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 1 +call Array.dispose 1 +pop temp 0 +label IF_FALSE0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function String.length 0 +push argument 0 +pop pointer 0 +push this 2 +return +function String.charAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 15 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +pop pointer 1 +push that 0 +return +function String.setCharAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 16 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function String.appendChar 0 +push argument 0 +pop pointer 0 +push this 2 +push this 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 17 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push this 1 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +push pointer 0 +return +function String.eraseLastChar 0 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 18 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push constant 1 +sub +pop this 2 +push constant 0 +return +function String.intValue 5 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push constant 0 +not +pop local 3 +push constant 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 45 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 4 +push constant 1 +pop local 0 +label IF_FALSE1 +label WHILE_EXP0 +push local 0 +push this 2 +lt +push local 3 +and +not +if-goto WHILE_END0 +push local 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 48 +sub +pop local 2 +push local 2 +push constant 0 +lt +push local 2 +push constant 9 +gt +or +not +pop local 3 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 1 +push constant 10 +call Math.multiply 2 +push local 2 +add +pop local 1 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 1 +neg +pop local 1 +label IF_FALSE3 +push local 1 +return +function String.setInt 4 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push constant 6 +call Array.new 1 +pop local 2 +push argument 1 +push constant 0 +lt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 3 +push argument 1 +neg +pop argument 1 +label IF_FALSE1 +push argument 1 +pop local 1 +label WHILE_EXP0 +push local 1 +push constant 0 +gt +not +if-goto WHILE_END0 +push argument 1 +push constant 10 +call Math.divide 2 +pop local 1 +push local 0 +push local 2 +add +push constant 48 +push argument 1 +push local 1 +push constant 10 +call Math.multiply 2 +sub +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +push local 1 +pop argument 1 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +push local 2 +add +push constant 45 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +push this 0 +push local 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE3 +push local 0 +push constant 0 +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 0 +push this 1 +add +push constant 48 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +pop this 2 +goto IF_END4 +label IF_FALSE4 +push constant 0 +pop this 2 +label WHILE_EXP1 +push this 2 +push local 0 +lt +not +if-goto WHILE_END1 +push this 2 +push this 1 +add +push local 0 +push this 2 +push constant 1 +add +sub +push local 2 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +goto WHILE_EXP1 +label WHILE_END1 +label IF_END4 +push local 2 +call Array.dispose 1 +pop temp 0 +push constant 0 +return +function String.newLine 0 +push constant 128 +return +function String.backSpace 0 +push constant 129 +return +function String.doubleQuote 0 +push constant 34 +return diff --git a/projects/09/Tetris/OS/Sys.vm b/projects/09/Tetris/OS/Sys.vm new file mode 100755 index 0000000..c186dad --- /dev/null +++ b/projects/09/Tetris/OS/Sys.vm @@ -0,0 +1,83 @@ +function Sys.init 0 +call Memory.init 0 +pop temp 0 +call Math.init 0 +pop temp 0 +call Screen.init 0 +pop temp 0 +call Output.init 0 +pop temp 0 +call Keyboard.init 0 +pop temp 0 +call Main.main 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return +function Sys.halt 0 +label WHILE_EXP0 +push constant 0 +not +not +if-goto WHILE_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.wait 1 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 1 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +label WHILE_EXP0 +push argument 0 +push constant 0 +gt +not +if-goto WHILE_END0 +push constant 50 +pop local 0 +label WHILE_EXP1 +push local 0 +push constant 0 +gt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push argument 0 +push constant 1 +sub +pop argument 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.error 0 +push constant 69 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push argument 0 +call Output.printInt 1 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return diff --git a/projects/09/Tetris/Piece.jack b/projects/09/Tetris/Piece.jack new file mode 100755 index 0000000..3ca2309 --- /dev/null +++ b/projects/09/Tetris/Piece.jack @@ -0,0 +1,473 @@ +class Piece { + static int lBorder, rBorder, uBorder, dBorder, st; + field int x1, y1, x2, y2, x3, y3, x4, y4, piece, direction; + field bool move; + static Array st; + + constructor Piece new(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4, int p) { + let x1 = Ax1; + let y1 = Ay1; + let x2 = Ax2; + let y2 = Ay2; + let x3 = Ax3; + let y3 = Ay3; + let x4 = Ax4; + let y4 = Ay4; + let piece = p; + let direction = 0; + let move = true; + return this; + } + + function void init(){ + var int a; + let lBorder = 0; + let rBorder = 511; + let uBorder = 0; + let dBorder = 255; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + return; + } + + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** draws 2 rectangles also checks if there is a piece at the spawn which will indicate end of the game. */ + method bool draw() { + var bool finish; + let finish = true; + let finish = Piece.sample(x1,y1) & finish; + let finish = Piece.sample(x2,y2) & finish; + let finish = Piece.sample(x3,y3) & finish; + let finish = Piece.sample(x4,y4) & finish; + if (finish){ + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return true; + } + return false; + } + + /** Erases the square from the screen. */ + method void erase() { + do Screen.setColor(false); + do Screen.drawRectangle(x1, y2, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return; + } + /** checks if those coodinates hold any value > 0. */ + function bool sample(int x, int y){ + var int value, address, bit, memBlock; + let memBlock = x / 16; + let address = (32 * y) + memBlock + 16384; + if (address > 24576){ + return false; + } + let value = Memory.peek(address); + if (value = 0){ + return true; + } + return false; + } + + method bool getMove(){ + return move; + } + + /** Checks if the piece can move in the given direction(dir). */ + method bool fullSample(int dir){ + var int size1, size2, i, j; + var bool result, flagUpon; + if (dir = 1){ //down + let size1 = x2 - x1; + let size2 = x4 - x3; + let result = true; + while (i < size1){ // for each block of the first rectangle + let j = 0; + let flagUpon = false; + while (j < size2){ // for each block of the second rectangle + if ((x1 + i) = (x3 + j)){ // if this block of the first rectangle sits upon a block of the second rectangle + let flagUpon = true; + } + let result = result & Piece.sample(x3 + j, y4 + 1); // if there is a block under the second rectangle + let j = j + 16; // sets the coords for the next block of the second rectangle + } + if (~(flagUpon)){ + let result = result & Piece.sample(x1 + i, y2 + 1); // if there is a block under the first rectangle + } + let i = i + 16; // sets the coords for the next block of the firs rectangle + } + return result; + } + else{ + if (dir = 2){ //right + let size1 = y2 - y1; + let size2 = y4 - y3; + let result = true; + while (i < size1){ + let j = 0; + let flagUpon = false; + while (j < size2){ + if ((y1 + i) = (y3 + j)){ + let flagUpon = true; + } + let result = result & Piece.sample(x4 + 1, (y3 + j)); + let j = j + 16; + } + if (~(flagUpon)){ + let result = result & Piece.sample(x2 + 1, (y1 + i)); + } + let i = i +16; + } + return result; + } + else{ // left + let size1 = y2 - y1; + let size2 = y4 - y3; + let result = true; + while (i < size2){ + let j = 0; + let flagUpon = false; + while (j < size1){ + if ((y3 + i) = (y1 + j)){ + let flagUpon = true; + } + let result = result & Piece.sample(x1 - 1, (y1 + j)); + let j = j + 16; + } + if (~(flagUpon)){ + let result = result & Piece.sample(x3 - 1, (y3 + i)); + } + let i = i + 16; + } + return result; + } + } + } + + /** Moves the game piece 16 pixels down. */ + method void moveDown() { + var int i; + if ((y2 < dBorder) & (y4 < dBorder) & (move) & fullSample(1)) { + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x2, y1); + do Screen.drawRectangle(x3, y3, x4, y3); + let y1 = y1 + 1; + let y2 = y2 + 1; + let y3 = y3 + 1; + let y4 = y4 + 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y2, x2, y2); + do Screen.drawRectangle(x3, y4, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + else{ + let move = false; + } + return; + } + + /** Moves the game piece 16 pixels to the left. */ + method void moveLeft() { + var int i; + if ((x1 + 15 > lBorder) & (move) & (x3 + 15 > lBorder)& fullSample(0)){ + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x2, y1, x2, y2); + do Screen.drawRectangle(x4, y3, x4, y4); + let x1 = x1 - 1; + let x2 = x2 - 1; + let x3 = x3 - 1; + let x4 = x4 - 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + return; + } + + /** Moves the game piece 16 pixels to the right. */ + method void moveRight() { + var int i; + if ((x4 < rBorder) & (move) & (x2 < rBorder) & fullSample(2)){ + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x1, y2); + do Screen.drawRectangle(x3, y3, x3, y4); + let x1 = x1 + 1; + let x2 = x2 + 1; + let x3 = x3 + 1; + let x4 = x4 + 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + return; + } + + /** Deletes the piece and draws it at the new coodinates. */ + method void reDraw(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4){ + var int absTmp; + if((Ax1 < 175) | (Ax3 < 175) | (Ax2 > 336) | (Ax4 > 336)){ + return; + } + if((Ay2 > 255) | (Ay4 > 255) | (Ay1 < 0) | (Ay3 < 0)){ + return; + } + if((Ax1 > Ax2) | (Ax3 > Ax4) | (Ay1 > Ay2) | (Ay3 > Ay4)){ + return; + } + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + do Screen.setColor(true); + let x1 = Ax1; + let y1 = Ay1; + let x2 = Ax2; + let y2 = Ay2; + let x3 = Ax3; + let y3 = Ay3; + let x4 = Ax4; + let y4 = Ay4; + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return; + } + + /** Rotates the piece clockwise. */ + method void rotate(){ + var bool samp; + let samp = true; + if (direction = 0){ // starting position + if (piece = 0){ // arrow + let samp = Piece.sample(x4, y1) & samp; // checks if the place at which the new piece will be drawn are free + let samp = Piece.sample(x4, y1 - 1) & samp; + if (samp){ + do reDraw(x1, y1, x2, y2, x4 - 15, y4 - 47, x4, y4); // redraws it at the new location + let direction = 1; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 + 16, y1) & samp; + let samp = Piece.sample(x1 + 16, y1 - 16) & samp; + let samp = Piece.sample(x4, y1 - 16) & samp; + if(samp){ + do reDraw(x1 + 16, y1 - 16, x4 - 16, y4, x4 - 15, y1 - 16, x4, y1 - 1); + let direction = 1; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 - 16, y1 - 16) & samp; + let samp = Piece.sample(x1 - 16, y1) & samp; + if (samp){ + do reDraw(x1 - 16, y1 - 16, x2 - 16, y2 + 16, x3 + 32, y3, x4, y4); + let direction = 1; + } + } + if (piece = 3){ + let samp = Piece.sample(x3 + 16, y3 - 32) & samp; + let samp = Piece.sample(x4, y4 - 16) & samp; + if (samp){ + do reDraw(x1 + 16, y1, x2, y2 + 16, x3 + 16, y3 - 32, x4, y4 - 16); + let direction = 1; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 + 32, y3 - 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 - 16, y2 + 16, x3 + 32, y3 - 32, x4 + 16, y4 - 16); + let direction = 1; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 + 32, y1 - 32) & samp; + let samp = Piece.sample(x2 + 16, y2 - 16) & samp; + let samp = Piece.sample(x4 - 16, y4 + 16) & samp; + if (samp){ + do reDraw(x1 + 32, y1 - 32, x2 + 16, y2 - 16, x3, y3, x4 - 16, y4 + 16); + let direction = 1; + } + } + } + else{ + if (direction = 1){ + if (piece = 0){ + let samp = Piece.sample(x1, y3) & samp; + let samp = Piece.sample(x1 - 1, y3) & samp; + if (samp){ + do reDraw(x1 - 16, y3, x4, y3 + 15, x1, y1, x2, y2); + let direction = 2; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3, y3 + 16) & samp; + let samp = Piece.sample(x3, y3 + 32) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 16, x4, y4 + 16, x3, y3 + 32, x4, y2); + let direction = 2; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x2 + 16, y2 - 16) & samp; + let samp = Piece.sample(x3 - 32, y3) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 16, x2 + 16, y2 - 16, x3 - 32, y3, x4 - 32, y4); + let direction = 2; + } + } + if (piece = 3){ + let samp = Piece.sample(x1 - 16, y1) & samp; + let samp = Piece.sample(x4, y4 + 16) & samp; + if (samp){ + do reDraw(x1 - 16, y1, x2, y2 - 16, x3 - 16, y3 +32, x4, y4 + 16); + let direction = 2; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 - 32, y3 + 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 + 16, y2 - 16, x3 - 32, y3 + 32, x4 - 16, y4 + 16); + let direction = 2; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3 + 16, y3 - 16) & samp; + let samp = Piece.sample(x4 + 32, y4 - 32) & samp; + if (samp){ + do reDraw(x1 - 32, y1 + 16, x2 - 16, y2, x3, y3 - 16, x4 + 16, y4 - 32); + let direction = 2; + } + } + } + else{ + if (direction = 2){ + if (piece = 0){ + let samp = Piece.sample(x1, y1+16) & samp; + let samp = Piece.sample(x1, y1+32) & samp; + if (samp){ + do reDraw(x1, y1, x1 + 15, y1 + 47, x3, y3, x4, y4); + let direction = 3; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3, y3 + 16) & samp; + let samp = Piece.sample(x3, y3 + 32) & samp; + if (samp){ + do reDraw(x1, y1 + 16, x1 + 15, y1 + 31, x1 + 16, y1 - 16, x4 - 16, y4); + let direction = 3; + } + } + if (piece = 2){ + let samp = Piece.sample(x1, y1 - 16) & samp; + let samp = Piece.sample(x2 + 32, y2 + 16) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1, y1 - 16, x2 - 32, y2 - 16, x3 + 16, y3 - 32, x4 + 16, y4); + let direction = 3; + } + } + if (piece = 3){ + let samp = Piece.sample(x2 - 16, y2 + 16) & samp; + let samp = Piece.sample(x3, y3 - 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 - 16, y2 + 16, x3, y3 - 32, x4 - 16, y4 - 16); + let direction = 3; + } + } + if (piece = 4){ + let samp = Piece.sample(x1 - 16, y1 - 16) & samp; + let samp = Piece.sample(x2 - 32, y2) & samp; + if (samp){ + do reDraw(x1 - 16, y1 - 16, x2 - 32, y2, x3 + 16, y3 - 16, x4, y4); + let direction = 3; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 + 16, y1 - 16) & samp; + let samp = Piece.sample(x3 - 16, y3 - 16) & samp; + let samp = Piece.sample(x4 - 32, y4 + 32) & samp; + if (samp){ + do reDraw(x1 + 16, y1 - 16, x2, y2, x3 - 16, y3 + 16, x4 - 32, y4 + 32); + let direction = 3; + } + } + } + else{ + if (piece = 0){ + let samp = Piece.sample(x4 + 16, y4) & samp; + let samp = Piece.sample(x4 + 32, y4) & samp; + if (samp){ + do reDraw(x3, y3, x4, y4, x1, y1 + 32, x1 + 47, y1 + 47); + let direction = 0; + } + } + if (piece = 1){ + let samp = Piece.sample(x1, y1 - 16) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1, y1 - 16, x2, y2 -16, x1, y1, x4 + 16, y4); + let direction = 0; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 + 32, y1 + 16) & samp; + let samp = Piece.sample(x3 - 16, y3 + 32) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1 + 32, y1 + 16, x2 + 32, y2 + 16, x3 - 16, y3 + 32, x4 + 16, y4); + let direction = 0; + } + } + if (piece = 3){ + let samp = Piece.sample(x3, y3 + 32) & samp; + let samp = Piece.sample(x4 + 16, y4 + 16) & samp; + if (samp){ + do reDraw(x1, y1, x2 + 16, y2 - 16, x3, y3 + 32, x4 + 16, y4 + 16); + let direction = 0; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 - 16, y3 + 16) & samp; + let samp = Piece.sample(x2 + 32, y2) & samp; + if (samp){ + do reDraw(x1 + 16, y1 + 16, x2 + 32, y2, x3 - 16, y3 + 16, x4, y4); + let direction = 0; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 - 16, y1 + 32) & samp; + let samp = Piece.sample(x3 + 16, y3) & samp; + let samp = Piece.sample(x4 + 32, y4 - 16) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 32, x2, y2 + 16, x3 + 16, y3, x4 + 32, y4 - 16); + let direction = 0; + } + } + } + } + } + return; + } +} + diff --git a/projects/09/Tetris/Piece.vm b/projects/09/Tetris/Piece.vm new file mode 100755 index 0000000..eb6061b --- /dev/null +++ b/projects/09/Tetris/Piece.vm @@ -0,0 +1,2219 @@ +function Piece.new 0 +push constant 11 +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 argument 3 +pop this 3 +push argument 4 +pop this 4 +push argument 5 +pop this 5 +push argument 6 +pop this 6 +push argument 7 +pop this 7 +push argument 8 +pop this 8 +push constant 0 +pop this 9 +push constant 0 +not +pop this 10 +push pointer 0 +return +function Piece.init 1 +push constant 0 +pop static 0 +push constant 511 +pop static 1 +push constant 0 +pop static 2 +push constant 255 +pop static 3 +push constant 16 +call Array.new 1 +pop static 5 +push constant 0 +push static 5 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 5 +add +push local 0 +push constant 1 +sub +push static 5 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 5 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Piece.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function Piece.draw 1 +push argument 0 +pop pointer 0 +push constant 0 +not +pop local 0 +push this 0 +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push this 3 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +not +return +label IF_FALSE0 +push constant 0 +return +function Piece.erase 0 +push argument 0 +pop pointer 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 3 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Piece.sample 4 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push constant 32 +push argument 1 +call Math.multiply 2 +push local 3 +add +push constant 16384 +add +pop local 1 +push local 1 +push constant 24576 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push local 1 +call Memory.peek 1 +pop local 0 +push local 0 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +return +label IF_FALSE1 +push constant 0 +return +function Piece.getMove 0 +push argument 0 +pop pointer 0 +push this 10 +return +function Piece.fullSample 6 +push argument 0 +pop pointer 0 +push argument 1 +push constant 1 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 2 +push this 0 +sub +pop local 0 +push this 6 +push this 4 +sub +pop local 1 +push constant 0 +not +pop local 4 +label WHILE_EXP0 +push local 2 +push local 0 +lt +not +if-goto WHILE_END0 +push constant 0 +pop local 3 +push constant 0 +pop local 5 +label WHILE_EXP1 +push local 3 +push local 1 +lt +not +if-goto WHILE_END1 +push this 0 +push local 2 +add +push this 4 +push local 3 +add +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 5 +label IF_FALSE1 +push local 4 +push this 4 +push local 3 +add +push this 7 +push constant 1 +add +call Piece.sample 2 +and +pop local 4 +push local 3 +push constant 16 +add +pop local 3 +goto WHILE_EXP1 +label WHILE_END1 +push local 5 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 4 +push this 0 +push local 2 +add +push this 3 +push constant 1 +add +call Piece.sample 2 +and +pop local 4 +label IF_FALSE2 +push local 2 +push constant 16 +add +pop local 2 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +return +goto IF_END0 +label IF_FALSE0 +push argument 1 +push constant 2 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push this 3 +push this 1 +sub +pop local 0 +push this 7 +push this 5 +sub +pop local 1 +push constant 0 +not +pop local 4 +label WHILE_EXP2 +push local 2 +push local 0 +lt +not +if-goto WHILE_END2 +push constant 0 +pop local 3 +push constant 0 +pop local 5 +label WHILE_EXP3 +push local 3 +push local 1 +lt +not +if-goto WHILE_END3 +push this 1 +push local 2 +add +push this 5 +push local 3 +add +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 0 +not +pop local 5 +label IF_FALSE4 +push local 4 +push this 6 +push constant 1 +add +push this 5 +push local 3 +add +call Piece.sample 2 +and +pop local 4 +push local 3 +push constant 16 +add +pop local 3 +goto WHILE_EXP3 +label WHILE_END3 +push local 5 +not +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push local 4 +push this 2 +push constant 1 +add +push this 1 +push local 2 +add +call Piece.sample 2 +and +pop local 4 +label IF_FALSE5 +push local 2 +push constant 16 +add +pop local 2 +goto WHILE_EXP2 +label WHILE_END2 +push local 4 +return +goto IF_END3 +label IF_FALSE3 +push this 3 +push this 1 +sub +pop local 0 +push this 7 +push this 5 +sub +pop local 1 +push constant 0 +not +pop local 4 +label WHILE_EXP4 +push local 2 +push local 1 +lt +not +if-goto WHILE_END4 +push constant 0 +pop local 3 +push constant 0 +pop local 5 +label WHILE_EXP5 +push local 3 +push local 0 +lt +not +if-goto WHILE_END5 +push this 5 +push local 2 +add +push this 1 +push local 3 +add +eq +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push constant 0 +not +pop local 5 +label IF_FALSE6 +push local 4 +push this 0 +push constant 1 +sub +push this 1 +push local 3 +add +call Piece.sample 2 +and +pop local 4 +push local 3 +push constant 16 +add +pop local 3 +goto WHILE_EXP5 +label WHILE_END5 +push local 5 +not +if-goto IF_TRUE7 +goto IF_FALSE7 +label IF_TRUE7 +push local 4 +push this 4 +push constant 1 +sub +push this 5 +push local 2 +add +call Piece.sample 2 +and +pop local 4 +label IF_FALSE7 +push local 2 +push constant 16 +add +pop local 2 +goto WHILE_EXP4 +label WHILE_END4 +push local 4 +return +label IF_END3 +label IF_END0 +function Piece.moveDown 1 +push argument 0 +pop pointer 0 +push this 3 +push static 3 +lt +push this 7 +push static 3 +lt +and +push this 10 +and +push pointer 0 +push constant 1 +call Piece.fullSample 2 +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 1 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 5 +call Screen.drawRectangle 4 +pop temp 0 +push this 1 +push constant 1 +add +pop this 1 +push this 3 +push constant 1 +add +pop this 3 +push this 5 +push constant 1 +add +pop this 5 +push this 7 +push constant 1 +add +pop this 7 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 3 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 7 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +push constant 10 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +goto IF_END0 +label IF_FALSE0 +push constant 0 +pop this 10 +label IF_END0 +push constant 0 +return +function Piece.moveLeft 1 +push argument 0 +pop pointer 0 +push this 0 +push constant 15 +add +push static 0 +gt +push this 10 +and +push this 4 +push constant 15 +add +push static 0 +gt +and +push pointer 0 +push constant 0 +call Piece.fullSample 2 +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 2 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 6 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push this 0 +push constant 1 +sub +pop this 0 +push this 2 +push constant 1 +sub +pop this 2 +push this 4 +push constant 1 +sub +pop this 4 +push this 6 +push constant 1 +sub +pop this 6 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +push constant 10 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +label IF_FALSE0 +push constant 0 +return +function Piece.moveRight 1 +push argument 0 +pop pointer 0 +push this 6 +push static 1 +lt +push this 10 +and +push this 2 +push static 1 +lt +and +push pointer 0 +push constant 2 +call Piece.fullSample 2 +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 4 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push this 0 +push constant 1 +add +pop this 0 +push this 2 +push constant 1 +add +pop this 2 +push this 4 +push constant 1 +add +pop this 4 +push this 6 +push constant 1 +add +pop this 6 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +push constant 10 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +label IF_FALSE0 +push constant 0 +return +function Piece.reDraw 1 +push argument 0 +pop pointer 0 +push argument 1 +push constant 175 +lt +push argument 5 +push constant 175 +lt +or +push argument 3 +push constant 336 +gt +or +push argument 7 +push constant 336 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push argument 4 +push constant 255 +gt +push argument 8 +push constant 255 +gt +or +push argument 2 +push constant 0 +lt +or +push argument 6 +push constant 0 +lt +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +return +label IF_FALSE1 +push argument 1 +push argument 3 +gt +push argument 5 +push argument 7 +gt +or +push argument 2 +push argument 4 +gt +or +push argument 6 +push argument 8 +gt +or +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push constant 0 +return +label IF_FALSE2 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push argument 1 +pop this 0 +push argument 2 +pop this 1 +push argument 3 +pop this 2 +push argument 4 +pop this 3 +push argument 5 +pop this 4 +push argument 6 +pop this 5 +push argument 7 +pop this 6 +push argument 8 +pop this 7 +push this 0 +push this 1 +push this 2 +push this 3 +call Screen.drawRectangle 4 +pop temp 0 +push this 4 +push this 5 +push this 6 +push this 7 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Piece.rotate 1 +push argument 0 +pop pointer 0 +push constant 0 +not +pop local 0 +push this 9 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 8 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push this 6 +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 1 +push constant 1 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push pointer 0 +push this 0 +push this 1 +push this 2 +push this 3 +push this 6 +push constant 15 +sub +push this 7 +push constant 47 +sub +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE2 +label IF_FALSE1 +push this 8 +push constant 1 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push this 0 +push constant 16 +add +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +push this 6 +push constant 16 +sub +push this 7 +push this 6 +push constant 15 +sub +push this 1 +push constant 16 +sub +push this 6 +push this 1 +push constant 1 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE4 +label IF_FALSE3 +push this 8 +push constant 2 +eq +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push constant 16 +sub +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +push this 4 +push constant 32 +add +push this 5 +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE6 +label IF_FALSE5 +push this 8 +push constant 3 +eq +if-goto IF_TRUE7 +goto IF_FALSE7 +label IF_TRUE7 +push this 4 +push constant 16 +add +push this 5 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 7 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE8 +goto IF_FALSE8 +label IF_TRUE8 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push this 2 +push this 3 +push constant 16 +add +push this 4 +push constant 16 +add +push this 5 +push constant 32 +sub +push this 6 +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE8 +label IF_FALSE7 +push this 8 +push constant 4 +eq +if-goto IF_TRUE9 +goto IF_FALSE9 +label IF_TRUE9 +push this 4 +push constant 32 +add +push this 5 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE10 +goto IF_FALSE10 +label IF_TRUE10 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +push this 4 +push constant 32 +add +push this 5 +push constant 32 +sub +push this 6 +push constant 16 +add +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE10 +label IF_FALSE9 +push this 8 +push constant 5 +eq +if-goto IF_TRUE11 +goto IF_FALSE11 +label IF_TRUE11 +push this 0 +push constant 32 +add +push this 1 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE12 +goto IF_FALSE12 +label IF_TRUE12 +push pointer 0 +push this 0 +push constant 32 +add +push this 1 +push constant 32 +sub +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push this 5 +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 1 +pop this 9 +label IF_FALSE12 +label IF_FALSE11 +goto IF_END0 +label IF_FALSE0 +push this 9 +push constant 1 +eq +if-goto IF_TRUE13 +goto IF_FALSE13 +label IF_TRUE13 +push this 8 +push constant 0 +eq +if-goto IF_TRUE14 +goto IF_FALSE14 +label IF_TRUE14 +push this 0 +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push constant 1 +sub +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE15 +goto IF_FALSE15 +label IF_TRUE15 +push pointer 0 +push this 0 +push constant 16 +sub +push this 5 +push this 6 +push this 5 +push constant 15 +add +push this 0 +push this 1 +push this 2 +push this 3 +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE15 +label IF_FALSE14 +push this 8 +push constant 1 +eq +if-goto IF_TRUE16 +goto IF_FALSE16 +label IF_TRUE16 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE17 +goto IF_FALSE17 +label IF_TRUE17 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +push this 6 +push this 7 +push constant 16 +add +push this 4 +push this 5 +push constant 32 +add +push this 6 +push this 3 +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE17 +label IF_FALSE16 +push this 8 +push constant 2 +eq +if-goto IF_TRUE18 +goto IF_FALSE18 +label IF_TRUE18 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 32 +sub +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE19 +goto IF_FALSE19 +label IF_TRUE19 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push constant 32 +sub +push this 5 +push this 6 +push constant 32 +sub +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE19 +label IF_FALSE18 +push this 8 +push constant 3 +eq +if-goto IF_TRUE20 +goto IF_FALSE20 +label IF_TRUE20 +push this 0 +push constant 16 +sub +push this 1 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push this 7 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE21 +goto IF_FALSE21 +label IF_TRUE21 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push this 2 +push this 3 +push constant 16 +sub +push this 4 +push constant 16 +sub +push this 5 +push constant 32 +add +push this 6 +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE21 +label IF_FALSE20 +push this 8 +push constant 4 +eq +if-goto IF_TRUE22 +goto IF_FALSE22 +label IF_TRUE22 +push this 4 +push constant 32 +sub +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE23 +goto IF_FALSE23 +label IF_TRUE23 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push constant 32 +sub +push this 5 +push constant 32 +add +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE23 +label IF_FALSE22 +push this 8 +push constant 5 +eq +if-goto IF_TRUE24 +goto IF_FALSE24 +label IF_TRUE24 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +add +push this 5 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +add +push this 7 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE25 +goto IF_FALSE25 +label IF_TRUE25 +push pointer 0 +push this 0 +push constant 32 +sub +push this 1 +push constant 16 +add +push this 2 +push constant 16 +sub +push this 3 +push this 4 +push this 5 +push constant 16 +sub +push this 6 +push constant 16 +add +push this 7 +push constant 32 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 2 +pop this 9 +label IF_FALSE25 +label IF_FALSE24 +goto IF_END13 +label IF_FALSE13 +push this 9 +push constant 2 +eq +if-goto IF_TRUE26 +goto IF_FALSE26 +label IF_TRUE26 +push this 8 +push constant 0 +eq +if-goto IF_TRUE27 +goto IF_FALSE27 +label IF_TRUE27 +push this 0 +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 0 +push this 1 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE28 +goto IF_FALSE28 +label IF_TRUE28 +push pointer 0 +push this 0 +push this 1 +push this 0 +push constant 15 +add +push this 1 +push constant 47 +add +push this 4 +push this 5 +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE28 +label IF_FALSE27 +push this 8 +push constant 1 +eq +if-goto IF_TRUE29 +goto IF_FALSE29 +label IF_TRUE29 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE30 +goto IF_FALSE30 +label IF_TRUE30 +push pointer 0 +push this 0 +push this 1 +push constant 16 +add +push this 0 +push constant 15 +add +push this 1 +push constant 31 +add +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +push this 6 +push constant 16 +sub +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE30 +label IF_FALSE29 +push this 8 +push constant 2 +eq +if-goto IF_TRUE31 +goto IF_FALSE31 +label IF_TRUE31 +push this 0 +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 32 +add +push this 3 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE32 +goto IF_FALSE32 +label IF_TRUE32 +push pointer 0 +push this 0 +push this 1 +push constant 16 +sub +push this 2 +push constant 32 +sub +push this 3 +push constant 16 +sub +push this 4 +push constant 16 +add +push this 5 +push constant 32 +sub +push this 6 +push constant 16 +add +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE32 +label IF_FALSE31 +push this 8 +push constant 3 +eq +if-goto IF_TRUE33 +goto IF_FALSE33 +label IF_TRUE33 +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push this 5 +push constant 32 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE34 +goto IF_FALSE34 +label IF_TRUE34 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +sub +push this 3 +push constant 16 +add +push this 4 +push this 5 +push constant 32 +sub +push this 6 +push constant 16 +sub +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE34 +label IF_FALSE33 +push this 8 +push constant 4 +eq +if-goto IF_TRUE35 +goto IF_FALSE35 +label IF_TRUE35 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 32 +sub +push this 3 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE36 +goto IF_FALSE36 +label IF_TRUE36 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 16 +sub +push this 2 +push constant 32 +sub +push this 3 +push this 4 +push constant 16 +add +push this 5 +push constant 16 +sub +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE36 +label IF_FALSE35 +push this 8 +push constant 5 +eq +if-goto IF_TRUE37 +goto IF_FALSE37 +label IF_TRUE37 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +sub +push this 7 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE38 +goto IF_FALSE38 +label IF_TRUE38 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +sub +push this 2 +push this 3 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +add +push this 6 +push constant 32 +sub +push this 7 +push constant 32 +add +call Piece.reDraw 9 +pop temp 0 +push constant 3 +pop this 9 +label IF_FALSE38 +label IF_FALSE37 +goto IF_END26 +label IF_FALSE26 +push this 8 +push constant 0 +eq +if-goto IF_TRUE39 +goto IF_FALSE39 +label IF_TRUE39 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE40 +goto IF_FALSE40 +label IF_TRUE40 +push pointer 0 +push this 4 +push this 5 +push this 6 +push this 7 +push this 0 +push this 1 +push constant 32 +add +push this 0 +push constant 47 +add +push this 1 +push constant 47 +add +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE40 +label IF_FALSE39 +push this 8 +push constant 1 +eq +if-goto IF_TRUE41 +goto IF_FALSE41 +label IF_TRUE41 +push this 0 +push this 1 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE42 +goto IF_FALSE42 +label IF_TRUE42 +push pointer 0 +push this 0 +push this 1 +push constant 16 +sub +push this 2 +push this 3 +push constant 16 +sub +push this 0 +push this 1 +push this 6 +push constant 16 +add +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE42 +label IF_FALSE41 +push this 8 +push constant 2 +eq +if-goto IF_TRUE43 +goto IF_FALSE43 +label IF_TRUE43 +push this 0 +push constant 32 +add +push this 1 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +sub +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE44 +goto IF_FALSE44 +label IF_TRUE44 +push pointer 0 +push this 0 +push constant 32 +add +push this 1 +push constant 16 +add +push this 2 +push constant 32 +add +push this 3 +push constant 16 +add +push this 4 +push constant 16 +sub +push this 5 +push constant 32 +add +push this 6 +push constant 16 +add +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE44 +label IF_FALSE43 +push this 8 +push constant 3 +eq +if-goto IF_TRUE45 +goto IF_FALSE45 +label IF_TRUE45 +push this 4 +push this 5 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 16 +add +push this 7 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE46 +goto IF_FALSE46 +label IF_TRUE46 +push pointer 0 +push this 0 +push this 1 +push this 2 +push constant 16 +add +push this 3 +push constant 16 +sub +push this 4 +push this 5 +push constant 32 +add +push this 6 +push constant 16 +add +push this 7 +push constant 16 +add +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE46 +label IF_FALSE45 +push this 8 +push constant 4 +eq +if-goto IF_TRUE47 +goto IF_FALSE47 +label IF_TRUE47 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 2 +push constant 32 +add +push this 3 +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE48 +goto IF_FALSE48 +label IF_TRUE48 +push pointer 0 +push this 0 +push constant 16 +add +push this 1 +push constant 16 +add +push this 2 +push constant 32 +add +push this 3 +push this 4 +push constant 16 +sub +push this 5 +push constant 16 +add +push this 6 +push this 7 +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE48 +label IF_FALSE47 +push this 8 +push constant 5 +eq +if-goto IF_TRUE49 +goto IF_FALSE49 +label IF_TRUE49 +push this 0 +push constant 16 +sub +push this 1 +push constant 32 +add +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 4 +push constant 16 +add +push this 5 +call Piece.sample 2 +push local 0 +and +pop local 0 +push this 6 +push constant 32 +add +push this 7 +push constant 16 +sub +call Piece.sample 2 +push local 0 +and +pop local 0 +push local 0 +if-goto IF_TRUE50 +goto IF_FALSE50 +label IF_TRUE50 +push pointer 0 +push this 0 +push constant 16 +sub +push this 1 +push constant 32 +add +push this 2 +push this 3 +push constant 16 +add +push this 4 +push constant 16 +add +push this 5 +push this 6 +push constant 32 +add +push this 7 +push constant 16 +sub +call Piece.reDraw 9 +pop temp 0 +push constant 0 +pop this 9 +label IF_FALSE50 +label IF_FALSE49 +label IF_END26 +label IF_END13 +label IF_END0 +push constant 0 +return diff --git a/projects/09/Tetris/Tetris.jack b/projects/09/Tetris/Tetris.jack new file mode 100755 index 0000000..0d15797 --- /dev/null +++ b/projects/09/Tetris/Tetris.jack @@ -0,0 +1,203 @@ +class Tetris { + static int points, seed, next_seed; + + function void tetris(int z){ + var Piece p, nextPiece; + var int i, x1, y1, x2, y2, x3, y3, x4, y4, key, j, randTmp, piece_number, moves; + var Array left_g, right_g, box, stick, left_z, right_z,dick, all_piece, tmp; + do Piece.init(); + do Tetris.border(); + let points = 0; + let all_piece = Array.new(25); + let all_piece[0] = Tetris.newPiece(16,0,31,15, 0,16,47,31, 0); // arrow + let all_piece[1] = Tetris.newPiece(0,0,15,15, 0,16,47,31, 1); // right_L + let all_piece[2] = Tetris.newPiece(32,16,47,31, 0,32,47,47, 2); // left_L + let all_piece[3] = Tetris.newPiece(0,0,31,15, 16,16,47,31, 3); // left_z + let all_piece[4] = Tetris.newPiece(16,0,47,15, 0,16,31,31, 4); // right_z + let all_piece[5] = Tetris.newPiece(0,0,31,15, 32,0,63,15, 5); //stick + let all_piece[6] = Tetris.newPiece(0,0,15,31, 16,0,31,31, 6); //box + + + let seed = z * 3; // multiply by 3, because it gets in a loop on some even numbers + let next_seed = Tetris.randomNumber(); + do Output.moveCursor(0,0); + do Output.printString("Point: "); + do Output.printInt(points); + do Output.println(); + do Output.printString("Next Piece: "); + while (true){ // The main game loop + let j = next_seed; + let next_seed = Tetris.randomNumber(); + let tmp = all_piece[j]; // initializes the coords of the game piece + let x1 = tmp[0]; + let y1 = tmp[1]; + let x2 = tmp[2]; + let y2 = tmp[3]; + let x3 = tmp[4]; + let y3 = tmp[5]; + let x4 = tmp[6]; + let y4 = tmp[7]; + let piece_number = tmp[8]; + let p = Piece.new(x1 + 240, y1, x2 + 240, y2, x3 + 240, y3, x4 + 240, y4, piece_number); + if (~(p.draw())){ // if a piece tries to spawn above a limit the game ends + if (~(Tetris.finish())){ + return; + } + } + let tmp = all_piece[next_seed]; + let x1 = tmp[0]; // initializes the coords of the next game piece that is being displayed + let y1 = tmp[1]; + let x2 = tmp[2]; + let y2 = tmp[3]; + let x3 = tmp[4]; + let y3 = tmp[5]; + let x4 = tmp[6]; + let y4 = tmp[7]; + let piece_number = tmp[8]; + let nextPiece = Piece.new(x1 + 16, y1 + 32, x2+16, y2 + 32, x3+16, y3 + 32, x4 + 16, y4 + 32, piece_number); + do nextPiece.draw(); + while (p.getMove()){ + let moves = 0; + while (moves < 3){ // one can move its piece 3 times before it moves down automatically + let key = Keyboard.keyPressed(); + if (key = 130){ + do p.moveLeft(); + do Sys.wait(80); + } + if (key = 132){ + do p.moveRight(); + do Sys.wait(80); + } + if (key = 131){ + do p.rotate(); + } + if (key = 133){ + do p.moveDown(); + do p.moveDown(); + } + let moves = moves +1; + } + do p.moveDown(); + let i = i + 1; + do Sys.wait(80); + } + let i = 0; + do p.dispose(); + do Tetris.completeRow(); + do Output.moveCursor(0,7); + do Output.printInt(points); + do Screen.setColor(false); + do Screen.drawRectangle(16,32,80,96); + do Screen.setColor(true); + do nextPiece.dispose(); + } + return; + } + + function void completeRow(){ // checks if a row has been completed + var int adddress, row, colloum; + var bool complete; + let adddress = 16384 + 11; + let row = 15; + while (row > 0){ // for each row + let complete = true; + let colloum = 0; + while ((colloum < 10) & (complete)){ // for each collum + let complete = Memory.peek(adddress + colloum + (row * 512)) & complete; + let colloum = colloum + 1; + } + if (complete){ // removes the row + do Screen.setColor(false); + do Screen.drawRectangle(176, row * 16, 335, ((row * 16)+ 15) ); + let points = points + 1; + do Tetris.shift(row); + } + let row = row - 1; + } + return; + } + + function void shift(int rowShift){ // shifts all rows above the completed one + var int j, val, adddress, tmp, k; + let adddress = 16384 + 11; + while (rowShift > 1){ // each row + let j = 0; + while (j < 10){ // collum in the game field + let k = 0; + while (k < 16){ // each line a in 16 x 16 box + let tmp = adddress + j + (((rowShift - 1) * 512) + (k * 32)); + let val = Memory.peek(tmp); + do Memory.poke(adddress + j + ((rowShift * 512) + (k * 32)), val); + do Memory.poke(tmp,0); + let k = k+ 1; + } + let j = j + 1; + } + let rowShift = rowShift - 1; + } + return; + } + + function void border(){ // draws a border + do Screen.drawLine(175,0,175,255); + do Screen.drawLine(336,0,336,255); + return; + } + + function Array newPiece(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4,int p){ + var Array gamepice; + let gamepice = Array.new(9); + let gamepice[0] = Ax1; + let gamepice[1] = Ay1; + let gamepice[2] = Ax2; + let gamepice[3] = Ay2; + let gamepice[4] = Ax3; + let gamepice[5] = Ay3; + let gamepice[6] = Ax4; + let gamepice[7] = Ay4; + let gamepice[8] = p; + return gamepice; + } + + function int randomNumber(){ // radom number generator + var int multiplier,additor,moduler,toBeModulated; + let multiplier = 7; + let additor = 13; + let moduler = 1133; + let toBeModulated = (multiplier * seed) + additor; + let seed = Tetris.mod(toBeModulated,moduler); + return Tetris.mod(seed,7); + } + + function bool finish(){ // after finishing the game the player has 2 options to start onether or to end the game + var char c; + do Screen.clearScreen(); + do Output.moveCursor(10,24); + do Output.printString("Your score: "); + do Output.printInt(points); + do Sys.wait(10000); + do Screen.clearScreen(); + do Output.moveCursor(10,0); + do Output.printString("Would you like to play again, for yes click 'Y' and for no 'N':"); + let c = Keyboard.readChar(); + if (c = 89){ + do Screen.clearScreen(); + return false; + } + if (c = 78){ + do Screen.clearScreen(); + do Sys.halt(); + } + return true; + } + + function int mod(int tbm, int mo){ //simple moduler devision + var int val, tmp2; + if (tbm < mo){ + return tbm; + } + let tmp2 = (tbm / mo) * mo; + let val = tbm - tmp2; + return val; + } +} \ No newline at end of file diff --git a/projects/09/Tetris/Tetris.vm b/projects/09/Tetris/Tetris.vm new file mode 100755 index 0000000..0ed5ac1 --- /dev/null +++ b/projects/09/Tetris/Tetris.vm @@ -0,0 +1,999 @@ +function Tetris.tetris 25 +call Piece.init 0 +pop temp 0 +call Tetris.border 0 +pop temp 0 +push constant 0 +pop static 0 +push constant 25 +call Array.new 1 +pop local 23 +push constant 0 +push local 23 +add +push constant 16 +push constant 0 +push constant 31 +push constant 15 +push constant 0 +push constant 16 +push constant 47 +push constant 31 +push constant 0 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 23 +add +push constant 0 +push constant 0 +push constant 15 +push constant 15 +push constant 0 +push constant 16 +push constant 47 +push constant 31 +push constant 1 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 23 +add +push constant 32 +push constant 16 +push constant 47 +push constant 31 +push constant 0 +push constant 32 +push constant 47 +push constant 47 +push constant 2 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 23 +add +push constant 0 +push constant 0 +push constant 31 +push constant 15 +push constant 16 +push constant 16 +push constant 47 +push constant 31 +push constant 3 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 23 +add +push constant 16 +push constant 0 +push constant 47 +push constant 15 +push constant 0 +push constant 16 +push constant 31 +push constant 31 +push constant 4 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 23 +add +push constant 0 +push constant 0 +push constant 31 +push constant 15 +push constant 32 +push constant 0 +push constant 63 +push constant 15 +push constant 5 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 23 +add +push constant 0 +push constant 0 +push constant 15 +push constant 31 +push constant 16 +push constant 0 +push constant 31 +push constant 31 +push constant 6 +call Tetris.newPiece 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push argument 0 +push constant 3 +call Math.multiply 2 +pop static 1 +call Tetris.randomNumber 0 +pop static 2 +push constant 0 +push constant 0 +call Output.moveCursor 2 +pop temp 0 +push constant 7 +call String.new 1 +push constant 80 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push static 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 12 +call String.new 1 +push constant 78 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 120 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 80 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +label WHILE_EXP0 +push constant 0 +not +not +if-goto WHILE_END0 +push static 2 +pop local 12 +call Tetris.randomNumber 0 +pop static 2 +push local 12 +push local 23 +add +pop pointer 1 +push that 0 +pop local 24 +push constant 0 +push local 24 +add +pop pointer 1 +push that 0 +pop local 3 +push constant 1 +push local 24 +add +pop pointer 1 +push that 0 +pop local 4 +push constant 2 +push local 24 +add +pop pointer 1 +push that 0 +pop local 5 +push constant 3 +push local 24 +add +pop pointer 1 +push that 0 +pop local 6 +push constant 4 +push local 24 +add +pop pointer 1 +push that 0 +pop local 7 +push constant 5 +push local 24 +add +pop pointer 1 +push that 0 +pop local 8 +push constant 6 +push local 24 +add +pop pointer 1 +push that 0 +pop local 9 +push constant 7 +push local 24 +add +pop pointer 1 +push that 0 +pop local 10 +push constant 8 +push local 24 +add +pop pointer 1 +push that 0 +pop local 14 +push local 3 +push constant 240 +add +push local 4 +push local 5 +push constant 240 +add +push local 6 +push local 7 +push constant 240 +add +push local 8 +push local 9 +push constant 240 +add +push local 10 +push local 14 +call Piece.new 9 +pop local 0 +push local 0 +call Piece.draw 1 +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Tetris.finish 0 +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +return +label IF_FALSE1 +label IF_FALSE0 +push static 2 +push local 23 +add +pop pointer 1 +push that 0 +pop local 24 +push constant 0 +push local 24 +add +pop pointer 1 +push that 0 +pop local 3 +push constant 1 +push local 24 +add +pop pointer 1 +push that 0 +pop local 4 +push constant 2 +push local 24 +add +pop pointer 1 +push that 0 +pop local 5 +push constant 3 +push local 24 +add +pop pointer 1 +push that 0 +pop local 6 +push constant 4 +push local 24 +add +pop pointer 1 +push that 0 +pop local 7 +push constant 5 +push local 24 +add +pop pointer 1 +push that 0 +pop local 8 +push constant 6 +push local 24 +add +pop pointer 1 +push that 0 +pop local 9 +push constant 7 +push local 24 +add +pop pointer 1 +push that 0 +pop local 10 +push constant 8 +push local 24 +add +pop pointer 1 +push that 0 +pop local 14 +push local 3 +push constant 16 +add +push local 4 +push constant 32 +add +push local 5 +push constant 16 +add +push local 6 +push constant 32 +add +push local 7 +push constant 16 +add +push local 8 +push constant 32 +add +push local 9 +push constant 16 +add +push local 10 +push constant 32 +add +push local 14 +call Piece.new 9 +pop local 1 +push local 1 +call Piece.draw 1 +pop temp 0 +label WHILE_EXP1 +push local 0 +call Piece.getMove 1 +not +if-goto WHILE_END1 +push constant 0 +pop local 15 +label WHILE_EXP2 +push local 15 +push constant 3 +lt +not +if-goto WHILE_END2 +call Keyboard.keyPressed 0 +pop local 11 +push local 11 +push constant 130 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +call Piece.moveLeft 1 +pop temp 0 +push constant 80 +call Sys.wait 1 +pop temp 0 +label IF_FALSE2 +push local 11 +push constant 132 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 0 +call Piece.moveRight 1 +pop temp 0 +push constant 80 +call Sys.wait 1 +pop temp 0 +label IF_FALSE3 +push local 11 +push constant 131 +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 0 +call Piece.rotate 1 +pop temp 0 +label IF_FALSE4 +push local 11 +push constant 133 +eq +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push local 0 +call Piece.moveDown 1 +pop temp 0 +push local 0 +call Piece.moveDown 1 +pop temp 0 +label IF_FALSE5 +push local 15 +push constant 1 +add +pop local 15 +goto WHILE_EXP2 +label WHILE_END2 +push local 0 +call Piece.moveDown 1 +pop temp 0 +push local 2 +push constant 1 +add +pop local 2 +push constant 80 +call Sys.wait 1 +pop temp 0 +goto WHILE_EXP1 +label WHILE_END1 +push constant 0 +pop local 2 +push local 0 +call Piece.dispose 1 +pop temp 0 +call Tetris.completeRow 0 +pop temp 0 +push constant 0 +push constant 7 +call Output.moveCursor 2 +pop temp 0 +push static 0 +call Output.printInt 1 +pop temp 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push constant 16 +push constant 32 +push constant 80 +push constant 96 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +not +call Screen.setColor 1 +pop temp 0 +push local 1 +call Piece.dispose 1 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Tetris.completeRow 4 +push constant 16384 +push constant 11 +add +pop local 0 +push constant 15 +pop local 1 +label WHILE_EXP0 +push local 1 +push constant 0 +gt +not +if-goto WHILE_END0 +push constant 0 +not +pop local 3 +push constant 0 +pop local 2 +label WHILE_EXP1 +push local 2 +push constant 10 +lt +push local 3 +and +not +if-goto WHILE_END1 +push local 0 +push local 2 +add +push local 1 +push constant 512 +call Math.multiply 2 +add +call Memory.peek 1 +push local 3 +and +pop local 3 +push local 2 +push constant 1 +add +pop local 2 +goto WHILE_EXP1 +label WHILE_END1 +push local 3 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push constant 176 +push local 1 +push constant 16 +call Math.multiply 2 +push constant 335 +push local 1 +push constant 16 +call Math.multiply 2 +push constant 15 +add +call Screen.drawRectangle 4 +pop temp 0 +push static 0 +push constant 1 +add +pop static 0 +push local 1 +call Tetris.shift 1 +pop temp 0 +label IF_FALSE0 +push local 1 +push constant 1 +sub +pop local 1 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Tetris.shift 5 +push constant 16384 +push constant 11 +add +pop local 2 +label WHILE_EXP0 +push argument 0 +push constant 1 +gt +not +if-goto WHILE_END0 +push constant 0 +pop local 0 +label WHILE_EXP1 +push local 0 +push constant 10 +lt +not +if-goto WHILE_END1 +push constant 0 +pop local 4 +label WHILE_EXP2 +push local 4 +push constant 16 +lt +not +if-goto WHILE_END2 +push local 2 +push local 0 +add +push argument 0 +push constant 1 +sub +push constant 512 +call Math.multiply 2 +push local 4 +push constant 32 +call Math.multiply 2 +add +add +pop local 3 +push local 3 +call Memory.peek 1 +pop local 1 +push local 2 +push local 0 +add +push argument 0 +push constant 512 +call Math.multiply 2 +push local 4 +push constant 32 +call Math.multiply 2 +add +add +push local 1 +call Memory.poke 2 +pop temp 0 +push local 3 +push constant 0 +call Memory.poke 2 +pop temp 0 +push local 4 +push constant 1 +add +pop local 4 +goto WHILE_EXP2 +label WHILE_END2 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push argument 0 +push constant 1 +sub +pop argument 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Tetris.border 0 +push constant 175 +push constant 0 +push constant 175 +push constant 255 +call Screen.drawLine 4 +pop temp 0 +push constant 336 +push constant 0 +push constant 336 +push constant 255 +call Screen.drawLine 4 +pop temp 0 +push constant 0 +return +function Tetris.newPiece 1 +push constant 9 +call Array.new 1 +pop local 0 +push constant 0 +push local 0 +add +push argument 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 0 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 0 +add +push argument 3 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 0 +add +push argument 4 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 0 +add +push argument 5 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 0 +add +push argument 6 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 7 +push local 0 +add +push argument 7 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 8 +push local 0 +add +push argument 8 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +return +function Tetris.randomNumber 4 +push constant 7 +pop local 0 +push constant 13 +pop local 1 +push constant 1133 +pop local 2 +push local 0 +push static 1 +call Math.multiply 2 +push local 1 +add +pop local 3 +push local 3 +push local 2 +call Tetris.mod 2 +pop static 1 +push static 1 +push constant 7 +call Tetris.mod 2 +return +function Tetris.finish 1 +call Screen.clearScreen 0 +pop temp 0 +push constant 10 +push constant 24 +call Output.moveCursor 2 +pop temp 0 +push constant 12 +call String.new 1 +push constant 89 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push static 0 +call Output.printInt 1 +pop temp 0 +push constant 10000 +call Sys.wait 1 +pop temp 0 +call Screen.clearScreen 0 +pop temp 0 +push constant 10 +push constant 0 +call Output.moveCursor 2 +pop temp 0 +push constant 63 +call String.new 1 +push constant 87 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 44 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 89 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 78 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Keyboard.readChar 0 +pop local 0 +push local 0 +push constant 89 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Screen.clearScreen 0 +pop temp 0 +push constant 0 +return +label IF_FALSE0 +push local 0 +push constant 78 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +call Screen.clearScreen 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +label IF_FALSE1 +push constant 0 +not +return +function Tetris.mod 2 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +return +label IF_FALSE0 +push argument 0 +push argument 1 +call Math.divide 2 +push argument 1 +call Math.multiply 2 +pop local 1 +push argument 0 +push local 1 +sub +pop local 0 +push local 0 +return diff --git a/projects/09/Tetris/TextComparer.bat b/projects/09/Tetris/TextComparer.bat new file mode 100755 index 0000000..a036d00 --- /dev/null +++ b/projects/09/Tetris/TextComparer.bat @@ -0,0 +1,29 @@ +@echo off + +rem $Id: TextComparer.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%3"=="" goto :USAGE +if "%1"=="/?" goto :USAGE +if not "%~1"=="" ( + set "_arg1=%~f1" +) +if not "%~2"=="" ( + set "_arg2=%~f2" +) +pushd "%~dp0" +if NOT "%~1"=="" ( + if NOT "%~2"=="" ( + java -classpath "%CLASSPATH%;bin/classes" TextComparer ^ + "%_arg1%" "%_arg2%" + popd + exit /B + ) +) +:USAGE +echo Usage: +echo TextComparer FILE1 FILE2 Compares FILE1 and FILE2. The success +echo message or the first miscompared line +echo is printed to the command console. +popd diff --git a/projects/09/Tetris/TextComparer.sh b/projects/09/Tetris/TextComparer.sh new file mode 100755 index 0000000..c8b08af --- /dev/null +++ b/projects/09/Tetris/TextComparer.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +# $Id: TextComparer.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -ne 2 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + # print usage + echo "Usage:" + echo " `basename "$0"` FILE1 FILE2 Compares FILE1 and FILE2. The success" + echo " message or the first miscompared line" + echo " is printed to the command console." +else + # Convert arg1 to an absolute path + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="$dir/$1" + fi + # Convert arg2 to an absolute path + if [ `echo "$2" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg2="$2" + else + arg2="$dir/$2" + fi +# echo Comparing "$arg1" "$arg2" + java -classpath "${CLASSPATH}:bin/classes" TextComparer "$arg1" "$arg2" +fi diff --git a/projects/09/Tetris/VMEmulator.bat b/projects/09/Tetris/VMEmulator.bat new file mode 100755 index 0000000..1b15b72 --- /dev/null +++ b/projects/09/Tetris/VMEmulator.bat @@ -0,0 +1,29 @@ +@echo off + +rem $Id: VMEmulator.bat,v 1.3 2014/05/10 00:51:55 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo VMEmulator Starts the VM Emulator in interactive mode. + echo VMEmulator FILE.tst Starts the VM Emulator and runs the FILE.tst test + echo script. The success/failure message is + echo printed to the command console. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + VMEmulatorMain +) else ( +rem echo Running "%_arg1%" + java -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + VMEmulatorMain "%_arg1%" +) +popd diff --git a/projects/09/Tetris/VMEmulator.sh b/projects/09/Tetris/VMEmulator.sh new file mode 100755 index 0000000..48f4f0f --- /dev/null +++ b/projects/09/Tetris/VMEmulator.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +# $Id: VMEmulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the VM Emulator in interactive mode." + echo " `basename "$0"` FILE.tst Starts the VM Emulator and runs the FILE.tst test" + echo " script. The success/failure message is" + echo " printed to the command console." +elif [ $# -eq 0 ] +then + # Run VM emulator in interactive mode + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" VMEmulatorMain & +else + # Convert arg1 to an absolute path and run VM emulator with arg1 + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi +# echo Running "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" VMEmulatorMain "$arg1" +fi diff --git a/projects/09/Tetris/__pycache__/symbol_table.cpython-39.pyc b/projects/09/Tetris/__pycache__/symbol_table.cpython-39.pyc new file mode 100755 index 0000000..244e26d Binary files /dev/null and b/projects/09/Tetris/__pycache__/symbol_table.cpython-39.pyc differ diff --git a/projects/09/Tetris/__pycache__/tokenizer.cpython-39.pyc b/projects/09/Tetris/__pycache__/tokenizer.cpython-39.pyc new file mode 100755 index 0000000..fd65c50 Binary files /dev/null and b/projects/09/Tetris/__pycache__/tokenizer.cpython-39.pyc differ diff --git a/projects/09/Tetris/__pycache__/vmwriter.cpython-39.pyc b/projects/09/Tetris/__pycache__/vmwriter.cpython-39.pyc new file mode 100755 index 0000000..71cd27b Binary files /dev/null and b/projects/09/Tetris/__pycache__/vmwriter.cpython-39.pyc differ diff --git a/projects/09/Tetris/bin/Assembler.dat b/projects/09/Tetris/bin/Assembler.dat new file mode 100755 index 0000000..0f3be3f --- /dev/null +++ b/projects/09/Tetris/bin/Assembler.dat @@ -0,0 +1 @@ +C:\Users\SQA-AGrudev\Desktop\nand2tetris\projects\08\ProgramFlow\BasicLoop\BasicLoop.hack diff --git a/projects/09/Tetris/bin/CPU Emulator.dat b/projects/09/Tetris/bin/CPU Emulator.dat new file mode 100755 index 0000000..1343654 --- /dev/null +++ b/projects/09/Tetris/bin/CPU Emulator.dat @@ -0,0 +1 @@ +C:\Users\SQA-AGrudev\Desktop\nand2tetris\projects\08\FunctionCalls\NestedCall diff --git a/projects/09/Tetris/bin/Hardware Simulator.dat b/projects/09/Tetris/bin/Hardware Simulator.dat new file mode 100755 index 0000000..33d02db --- /dev/null +++ b/projects/09/Tetris/bin/Hardware Simulator.dat @@ -0,0 +1 @@ +C:\Users\Andrean\Desktop\nand2tetris\projects\03\a diff --git a/projects/09/Tetris/bin/Virtual Machine Emulator.dat b/projects/09/Tetris/bin/Virtual Machine Emulator.dat new file mode 100755 index 0000000..b68de42 --- /dev/null +++ b/projects/09/Tetris/bin/Virtual Machine Emulator.dat @@ -0,0 +1 @@ +C:\Users\SQA-AGrudev\Desktop\nand2tetris\projects\09\Tetris diff --git a/projects/09/Tetris/bin/classes/CPUEmulatorMain.class b/projects/09/Tetris/bin/classes/CPUEmulatorMain.class new file mode 100755 index 0000000..2c5b68f Binary files /dev/null and b/projects/09/Tetris/bin/classes/CPUEmulatorMain.class differ diff --git a/projects/09/Tetris/bin/classes/HackAssemblerMain.class b/projects/09/Tetris/bin/classes/HackAssemblerMain.class new file mode 100755 index 0000000..b912391 Binary files /dev/null and b/projects/09/Tetris/bin/classes/HackAssemblerMain.class differ diff --git a/projects/09/Tetris/bin/classes/HardwareSimulatorMain.class b/projects/09/Tetris/bin/classes/HardwareSimulatorMain.class new file mode 100755 index 0000000..5786077 Binary files /dev/null and b/projects/09/Tetris/bin/classes/HardwareSimulatorMain.class differ diff --git a/projects/09/Tetris/bin/classes/TextComparer.class b/projects/09/Tetris/bin/classes/TextComparer.class new file mode 100755 index 0000000..f2e076e Binary files /dev/null and b/projects/09/Tetris/bin/classes/TextComparer.class differ diff --git a/projects/09/Tetris/bin/classes/VMEmulatorMain.class b/projects/09/Tetris/bin/classes/VMEmulatorMain.class new file mode 100755 index 0000000..aa6b7ff Binary files /dev/null and b/projects/09/Tetris/bin/classes/VMEmulatorMain.class differ diff --git a/projects/09/Tetris/bin/help/asmAbout.html b/projects/09/Tetris/bin/help/asmAbout.html new file mode 100755 index 0000000..919e539 --- /dev/null +++ b/projects/09/Tetris/bin/help/asmAbout.html @@ -0,0 +1,96 @@ + + + + + + + + +About Assembler + + + + + + + +

+ +

Assembler, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/help/asmUsage.html b/projects/09/Tetris/bin/help/asmUsage.html new file mode 100755 index 0000000..1e18db2 --- /dev/null +++ b/projects/09/Tetris/bin/help/asmUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The Assembler Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/help/compiler.txt b/projects/09/Tetris/bin/help/compiler.txt new file mode 100755 index 0000000..07bbba9 --- /dev/null +++ b/projects/09/Tetris/bin/help/compiler.txt @@ -0,0 +1,9 @@ +Jack Compiler, Version 2.5 + +This program is part of www.nand2tetris.org +and the book "The Elements of Computing Systems" +by Nisan and Schocken, MIT Press. + +Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski + +Usage instruction and tips can be found in the relevant book chapters. diff --git a/projects/09/Tetris/bin/help/cpuAbout.html b/projects/09/Tetris/bin/help/cpuAbout.html new file mode 100755 index 0000000..f806d5e --- /dev/null +++ b/projects/09/Tetris/bin/help/cpuAbout.html @@ -0,0 +1,96 @@ + + + + + + + + +About CPU Emulator + + + + + + + +
+ +

CPU Emulator, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/help/cpuUsage.html b/projects/09/Tetris/bin/help/cpuUsage.html new file mode 100755 index 0000000..7e69482 --- /dev/null +++ b/projects/09/Tetris/bin/help/cpuUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The CPU Emulator Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/help/hwAbout.html b/projects/09/Tetris/bin/help/hwAbout.html new file mode 100755 index 0000000..67ad89b --- /dev/null +++ b/projects/09/Tetris/bin/help/hwAbout.html @@ -0,0 +1,96 @@ + + + + + + + + +About Hardware Simulator + + + + + + + +
+ +

Hardware Simulator, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/help/hwUsage.html b/projects/09/Tetris/bin/help/hwUsage.html new file mode 100755 index 0000000..4663f53 --- /dev/null +++ b/projects/09/Tetris/bin/help/hwUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The Hardware Simulator Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/help/vmAbout.html b/projects/09/Tetris/bin/help/vmAbout.html new file mode 100755 index 0000000..c5b296a --- /dev/null +++ b/projects/09/Tetris/bin/help/vmAbout.html @@ -0,0 +1,110 @@ + + + + + + + + +About Virtual Machine Emulator + + + + + + + +
+ +

Virtual Machine Emulator, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. +Gonczarowski

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/help/vmUsage.html b/projects/09/Tetris/bin/help/vmUsage.html new file mode 100755 index 0000000..611662b --- /dev/null +++ b/projects/09/Tetris/bin/help/vmUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The VM Emulator Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/projects/09/Tetris/bin/images/arrow2.gif b/projects/09/Tetris/bin/images/arrow2.gif new file mode 100755 index 0000000..c744eab Binary files /dev/null and b/projects/09/Tetris/bin/images/arrow2.gif differ diff --git a/projects/09/Tetris/bin/images/calculator2.gif b/projects/09/Tetris/bin/images/calculator2.gif new file mode 100755 index 0000000..834cb05 Binary files /dev/null and b/projects/09/Tetris/bin/images/calculator2.gif differ diff --git a/projects/09/Tetris/bin/images/cancel.gif b/projects/09/Tetris/bin/images/cancel.gif new file mode 100755 index 0000000..a8509fa Binary files /dev/null and b/projects/09/Tetris/bin/images/cancel.gif differ diff --git a/projects/09/Tetris/bin/images/chip.gif b/projects/09/Tetris/bin/images/chip.gif new file mode 100755 index 0000000..fbfbb02 Binary files /dev/null and b/projects/09/Tetris/bin/images/chip.gif differ diff --git a/projects/09/Tetris/bin/images/clock2.gif b/projects/09/Tetris/bin/images/clock2.gif new file mode 100755 index 0000000..addcf78 Binary files /dev/null and b/projects/09/Tetris/bin/images/clock2.gif differ diff --git a/projects/09/Tetris/bin/images/equal.gif b/projects/09/Tetris/bin/images/equal.gif new file mode 100755 index 0000000..3402556 Binary files /dev/null and b/projects/09/Tetris/bin/images/equal.gif differ diff --git a/projects/09/Tetris/bin/images/find.gif b/projects/09/Tetris/bin/images/find.gif new file mode 100755 index 0000000..e3f4c9d Binary files /dev/null and b/projects/09/Tetris/bin/images/find.gif differ diff --git a/projects/09/Tetris/bin/images/hex.gif b/projects/09/Tetris/bin/images/hex.gif new file mode 100755 index 0000000..68a851b Binary files /dev/null and b/projects/09/Tetris/bin/images/hex.gif differ diff --git a/projects/09/Tetris/bin/images/keyboard.gif b/projects/09/Tetris/bin/images/keyboard.gif new file mode 100755 index 0000000..823aaf8 Binary files /dev/null and b/projects/09/Tetris/bin/images/keyboard.gif differ diff --git a/projects/09/Tetris/bin/images/ok.gif b/projects/09/Tetris/bin/images/ok.gif new file mode 100755 index 0000000..fe6ed8d Binary files /dev/null and b/projects/09/Tetris/bin/images/ok.gif differ diff --git a/projects/09/Tetris/bin/images/ok2.gif b/projects/09/Tetris/bin/images/ok2.gif new file mode 100755 index 0000000..083909b Binary files /dev/null and b/projects/09/Tetris/bin/images/ok2.gif differ diff --git a/projects/09/Tetris/bin/images/open.gif b/projects/09/Tetris/bin/images/open.gif new file mode 100755 index 0000000..f69a024 Binary files /dev/null and b/projects/09/Tetris/bin/images/open.gif differ diff --git a/projects/09/Tetris/bin/images/open2.gif b/projects/09/Tetris/bin/images/open2.gif new file mode 100755 index 0000000..2b94682 Binary files /dev/null and b/projects/09/Tetris/bin/images/open2.gif differ diff --git a/projects/09/Tetris/bin/images/opendoc.gif b/projects/09/Tetris/bin/images/opendoc.gif new file mode 100755 index 0000000..e84f0d6 Binary files /dev/null and b/projects/09/Tetris/bin/images/opendoc.gif differ diff --git a/projects/09/Tetris/bin/images/redflag.gif b/projects/09/Tetris/bin/images/redflag.gif new file mode 100755 index 0000000..1b1a6b1 Binary files /dev/null and b/projects/09/Tetris/bin/images/redflag.gif differ diff --git a/projects/09/Tetris/bin/images/save.gif b/projects/09/Tetris/bin/images/save.gif new file mode 100755 index 0000000..7b5d5b9 Binary files /dev/null and b/projects/09/Tetris/bin/images/save.gif differ diff --git a/projects/09/Tetris/bin/images/scroll.gif b/projects/09/Tetris/bin/images/scroll.gif new file mode 100755 index 0000000..e00a9a1 Binary files /dev/null and b/projects/09/Tetris/bin/images/scroll.gif differ diff --git a/projects/09/Tetris/bin/images/smallcancel.gif b/projects/09/Tetris/bin/images/smallcancel.gif new file mode 100755 index 0000000..1f8cddc Binary files /dev/null and b/projects/09/Tetris/bin/images/smallcancel.gif differ diff --git a/projects/09/Tetris/bin/images/smallequal.gif b/projects/09/Tetris/bin/images/smallequal.gif new file mode 100755 index 0000000..a1db606 Binary files /dev/null and b/projects/09/Tetris/bin/images/smallequal.gif differ diff --git a/projects/09/Tetris/bin/images/smallminus.gif b/projects/09/Tetris/bin/images/smallminus.gif new file mode 100755 index 0000000..06492f5 Binary files /dev/null and b/projects/09/Tetris/bin/images/smallminus.gif differ diff --git a/projects/09/Tetris/bin/images/smallnew.gif b/projects/09/Tetris/bin/images/smallnew.gif new file mode 100755 index 0000000..c3137e5 Binary files /dev/null and b/projects/09/Tetris/bin/images/smallnew.gif differ diff --git a/projects/09/Tetris/bin/images/smallok.gif b/projects/09/Tetris/bin/images/smallok.gif new file mode 100755 index 0000000..9bef2b2 Binary files /dev/null and b/projects/09/Tetris/bin/images/smallok.gif differ diff --git a/projects/09/Tetris/bin/images/smallplus.gif b/projects/09/Tetris/bin/images/smallplus.gif new file mode 100755 index 0000000..9030b0b Binary files /dev/null and b/projects/09/Tetris/bin/images/smallplus.gif differ diff --git a/projects/09/Tetris/bin/images/vcrfastforward.gif b/projects/09/Tetris/bin/images/vcrfastforward.gif new file mode 100755 index 0000000..11c7235 Binary files /dev/null and b/projects/09/Tetris/bin/images/vcrfastforward.gif differ diff --git a/projects/09/Tetris/bin/images/vcrforward.gif b/projects/09/Tetris/bin/images/vcrforward.gif new file mode 100755 index 0000000..b58d649 Binary files /dev/null and b/projects/09/Tetris/bin/images/vcrforward.gif differ diff --git a/projects/09/Tetris/bin/images/vcrrewind.gif b/projects/09/Tetris/bin/images/vcrrewind.gif new file mode 100755 index 0000000..e55b4d6 Binary files /dev/null and b/projects/09/Tetris/bin/images/vcrrewind.gif differ diff --git a/projects/09/Tetris/bin/images/vcrstop.gif b/projects/09/Tetris/bin/images/vcrstop.gif new file mode 100755 index 0000000..abe2082 Binary files /dev/null and b/projects/09/Tetris/bin/images/vcrstop.gif differ diff --git a/projects/09/Tetris/bin/lib/AssemblerGUI.jar b/projects/09/Tetris/bin/lib/AssemblerGUI.jar new file mode 100755 index 0000000..c40d455 Binary files /dev/null and b/projects/09/Tetris/bin/lib/AssemblerGUI.jar differ diff --git a/projects/09/Tetris/bin/lib/Compilers.jar b/projects/09/Tetris/bin/lib/Compilers.jar new file mode 100755 index 0000000..9a78b05 Binary files /dev/null and b/projects/09/Tetris/bin/lib/Compilers.jar differ diff --git a/projects/09/Tetris/bin/lib/Hack.jar b/projects/09/Tetris/bin/lib/Hack.jar new file mode 100755 index 0000000..9d57398 Binary files /dev/null and b/projects/09/Tetris/bin/lib/Hack.jar differ diff --git a/projects/09/Tetris/bin/lib/HackGUI.jar b/projects/09/Tetris/bin/lib/HackGUI.jar new file mode 100755 index 0000000..22d4ff3 Binary files /dev/null and b/projects/09/Tetris/bin/lib/HackGUI.jar differ diff --git a/projects/09/Tetris/bin/lib/Simulators.jar b/projects/09/Tetris/bin/lib/Simulators.jar new file mode 100755 index 0000000..72b5db7 Binary files /dev/null and b/projects/09/Tetris/bin/lib/Simulators.jar differ diff --git a/projects/09/Tetris/bin/lib/SimulatorsGUI.jar b/projects/09/Tetris/bin/lib/SimulatorsGUI.jar new file mode 100755 index 0000000..4d36e64 Binary files /dev/null and b/projects/09/Tetris/bin/lib/SimulatorsGUI.jar differ diff --git a/projects/09/Tetris/bin/lib/TranslatorsGUI.jar b/projects/09/Tetris/bin/lib/TranslatorsGUI.jar new file mode 100755 index 0000000..f29f926 Binary files /dev/null and b/projects/09/Tetris/bin/lib/TranslatorsGUI.jar differ diff --git a/projects/09/Tetris/bin/scripts/defaultCPU.txt b/projects/09/Tetris/bin/scripts/defaultCPU.txt new file mode 100755 index 0000000..43b2720 --- /dev/null +++ b/projects/09/Tetris/bin/scripts/defaultCPU.txt @@ -0,0 +1,3 @@ +repeat { + ticktock; +} \ No newline at end of file diff --git a/projects/09/Tetris/bin/scripts/defaultHW.txt b/projects/09/Tetris/bin/scripts/defaultHW.txt new file mode 100755 index 0000000..bdb2261 --- /dev/null +++ b/projects/09/Tetris/bin/scripts/defaultHW.txt @@ -0,0 +1,4 @@ +repeat { + tick, + tock; +} \ No newline at end of file diff --git a/projects/09/Tetris/bin/scripts/defaultVM.txt b/projects/09/Tetris/bin/scripts/defaultVM.txt new file mode 100755 index 0000000..dbc64c4 --- /dev/null +++ b/projects/09/Tetris/bin/scripts/defaultVM.txt @@ -0,0 +1,3 @@ +repeat { + vmstep; +} \ No newline at end of file diff --git a/projects/09/Tetris/builtInChips/ALU.class b/projects/09/Tetris/builtInChips/ALU.class new file mode 100755 index 0000000..03f95dc Binary files /dev/null and b/projects/09/Tetris/builtInChips/ALU.class differ diff --git a/projects/09/Tetris/builtInChips/ALU.hdl b/projects/09/Tetris/builtInChips/ALU.hdl new file mode 100755 index 0000000..e5fd1f0 --- /dev/null +++ b/projects/09/Tetris/builtInChips/ALU.hdl @@ -0,0 +1,55 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/ALU.hdl + +/** + * The ALU. Computes one of the following functions: + * x+y, x-y, y–x, 0, 1, -1, x, y, -x, -y, !x, !y, + * x+1, y+1, x-1, y-1, x&y, x|y on two 16-bit inputs. + * Which function to compute is determined by 6 input bits + * denoted zx, nx, zy, ny, f, no. + * The computed function's value is called "out". + * In addition to computing out, the ALU computes two + * 1-bit outputs called zr and ng: + * if out == 0, zr = 1; otherwise zr = 0; + * If out < 0, ng = 1; otherwise ng = 0. + * The 6-bit combinations (zx,nx,zy,ny,f,no) and + * their effect are documented in the book. + */ + +// Implementation: the ALU manipulates the x and y +// inputs and then operates on the resulting values, +// as follows: +// if (zx == 1) sets x = 0 // 16-bit constant +// if (nx == 1) sets x = ~x // bitwise "not" +// if (zy == 1) sets y = 0 // 16-bit constant +// if (ny == 1) sets y = ~y // bitwise "not" +// if (f == 1) sets out = x + y // integer 2's-complement addition +// if (f == 0) sets out = x & y // bitwise And +// if (no == 1) sets out = ~out // bitwise Not +// if (out == 0) sets zr = 1 +// if (out < 0) sets ng = 1 + + +CHIP ALU { + + IN // 16-bit inputs: + x[16], y[16], + // Control bits: + zx, // Zero the x input + nx, // Negate the x input + zy, // Zero the y input + ny, // Negate the y input + f, // Function code: 1 for add, 0 for and + no; // Negate the out output + + OUT // 16-bit output + out[16], + + // ALU output flags + zr, // 1 if out=0, 0 otherwise + ng; // 1 if out<0, 0 otherwise + + BUILTIN ALU; +} diff --git a/projects/09/Tetris/builtInChips/ARegister.class b/projects/09/Tetris/builtInChips/ARegister.class new file mode 100755 index 0000000..ab9aadc Binary files /dev/null and b/projects/09/Tetris/builtInChips/ARegister.class differ diff --git a/projects/09/Tetris/builtInChips/ARegister.hdl b/projects/09/Tetris/builtInChips/ARegister.hdl new file mode 100755 index 0000000..23aee73 --- /dev/null +++ b/projects/09/Tetris/builtInChips/ARegister.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/ARegister.hdl + +/** + * A 16-Bit register called "A Register". + * If load[t-1]=1 then out[t] = in[t-1] + * else out does not change (out[t] = out[t-1]) + * + * This built-in chip implementation has the side effect of + * providing a GUI representation of a 16-bit register + * called "A register" (typically used to store an address). + */ + +CHIP ARegister { + + IN in[16], load; + OUT out[16]; + + BUILTIN ARegister; + CLOCKED in, load; +} + diff --git a/projects/09/Tetris/builtInChips/Add16.class b/projects/09/Tetris/builtInChips/Add16.class new file mode 100755 index 0000000..c3754ce Binary files /dev/null and b/projects/09/Tetris/builtInChips/Add16.class differ diff --git a/projects/09/Tetris/builtInChips/Add16.hdl b/projects/09/Tetris/builtInChips/Add16.hdl new file mode 100755 index 0000000..a494af4 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Add16.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Add16.hdl + +/* + * Adds two 16-bit values. + * The most significant carry bit is ignored. + */ + +CHIP Add16 { + + IN a[16], b[16]; + OUT out[16]; + + BUILTIN Add16; +} + diff --git a/projects/09/Tetris/builtInChips/And.class b/projects/09/Tetris/builtInChips/And.class new file mode 100755 index 0000000..2c7492b Binary files /dev/null and b/projects/09/Tetris/builtInChips/And.class differ diff --git a/projects/09/Tetris/builtInChips/And.hdl b/projects/09/Tetris/builtInChips/And.hdl new file mode 100755 index 0000000..d2c48b5 --- /dev/null +++ b/projects/09/Tetris/builtInChips/And.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/And.hdl + +/** + * And gate: out = 1 if {a == 1 and b == 1}, 0 otherwise + */ + +CHIP And { + + IN a, b; + OUT out; + + BUILTIN And; +} diff --git a/projects/09/Tetris/builtInChips/And16.hdl b/projects/09/Tetris/builtInChips/And16.hdl new file mode 100755 index 0000000..4c71874 --- /dev/null +++ b/projects/09/Tetris/builtInChips/And16.hdl @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/And16.hdl + +/** + * 16-bit-wise And gate: for i = 0..15: out[i] = a[i] and b[i] + */ + +CHIP And16 { + + IN a[16], b[16]; + OUT out[16]; + + BUILTIN And; +} + diff --git a/projects/09/Tetris/builtInChips/Bit.class b/projects/09/Tetris/builtInChips/Bit.class new file mode 100755 index 0000000..1e5a3c4 Binary files /dev/null and b/projects/09/Tetris/builtInChips/Bit.class differ diff --git a/projects/09/Tetris/builtInChips/Bit.hdl b/projects/09/Tetris/builtInChips/Bit.hdl new file mode 100755 index 0000000..a0a76bb --- /dev/null +++ b/projects/09/Tetris/builtInChips/Bit.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Bit.hdl + +/** + * 1-bit register. + * If load[t] == 1 then out[t+1] = in[t] + * else out[t+1] = out[t] (no change) + */ + +CHIP Bit { + + IN in, load; + OUT out; + + BUILTIN Bit; + CLOCKED in, load; +} diff --git a/projects/09/Tetris/builtInChips/DFF.class b/projects/09/Tetris/builtInChips/DFF.class new file mode 100755 index 0000000..49efcf1 Binary files /dev/null and b/projects/09/Tetris/builtInChips/DFF.class differ diff --git a/projects/09/Tetris/builtInChips/DFF.hdl b/projects/09/Tetris/builtInChips/DFF.hdl new file mode 100755 index 0000000..c66b796 --- /dev/null +++ b/projects/09/Tetris/builtInChips/DFF.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DFF.hdl + +/** + * Data Flip-flop: out(t) = in(t-1) + * where t is the current time unit, or clock cycle. + */ + +CHIP DFF { + + IN in; + OUT out; + + BUILTIN DFF; + CLOCKED in; +} diff --git a/projects/09/Tetris/builtInChips/DMux.class b/projects/09/Tetris/builtInChips/DMux.class new file mode 100755 index 0000000..8cf4e0b Binary files /dev/null and b/projects/09/Tetris/builtInChips/DMux.class differ diff --git a/projects/09/Tetris/builtInChips/DMux.hdl b/projects/09/Tetris/builtInChips/DMux.hdl new file mode 100755 index 0000000..80153d7 --- /dev/null +++ b/projects/09/Tetris/builtInChips/DMux.hdl @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DMux.hdl + +/** + * Dmultiplexor. + * {a,b} = {in,0} if sel == 0 + * {0,in} if sel == 1 + */ + + +CHIP DMux { + + IN in, sel; + OUT a, b; + + BUILTIN DMux; +} + diff --git a/projects/09/Tetris/builtInChips/DMux4Way.class b/projects/09/Tetris/builtInChips/DMux4Way.class new file mode 100755 index 0000000..ab72a17 Binary files /dev/null and b/projects/09/Tetris/builtInChips/DMux4Way.class differ diff --git a/projects/09/Tetris/builtInChips/DMux4Way.hdl b/projects/09/Tetris/builtInChips/DMux4Way.hdl new file mode 100755 index 0000000..110bb4e --- /dev/null +++ b/projects/09/Tetris/builtInChips/DMux4Way.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DMux4Way.hdl + +/** + * 4-way demultiplexor. + * {a,b,c,d} = {in,0,0,0} if sel == 00 + * {0,in,0,0} if sel == 01 + * {0,0,in,0} if sel == 10 + * {0,0,0,in} if sel == 11 + */ + + +CHIP DMux4Way { + + IN in, sel[2]; + OUT a, b, c, d; + + BUILTIN DMux4Way; +} + diff --git a/projects/09/Tetris/builtInChips/DMux8Way.class b/projects/09/Tetris/builtInChips/DMux8Way.class new file mode 100755 index 0000000..80e7437 Binary files /dev/null and b/projects/09/Tetris/builtInChips/DMux8Way.class differ diff --git a/projects/09/Tetris/builtInChips/DMux8Way.hdl b/projects/09/Tetris/builtInChips/DMux8Way.hdl new file mode 100755 index 0000000..c5536b8 --- /dev/null +++ b/projects/09/Tetris/builtInChips/DMux8Way.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DMux8Way.hdl + +/** + * 8-way demultiplexor. + * {a,b,c,d,e,f,g,h} = {in,0,0,0,0,0,0,0} if sel == 000 + * {0,in,0,0,0,0,0,0} if sel == 001 + * etc. + * {0,0,0,0,0,0,0,in} if sel == 111 + */ + + +CHIP DMux8Way { + + IN in, sel[3]; + OUT a, b, c, d, e, f, g, h; + + BUILTIN DMux8Way; +} + diff --git a/projects/09/Tetris/builtInChips/DRegister.class b/projects/09/Tetris/builtInChips/DRegister.class new file mode 100755 index 0000000..74a713d Binary files /dev/null and b/projects/09/Tetris/builtInChips/DRegister.class differ diff --git a/projects/09/Tetris/builtInChips/DRegister.hdl b/projects/09/Tetris/builtInChips/DRegister.hdl new file mode 100755 index 0000000..6c9a254 --- /dev/null +++ b/projects/09/Tetris/builtInChips/DRegister.hdl @@ -0,0 +1,24 @@ +// This file is part of the materials accompanying the book +// "The Elements of Computing Systems" by Nisan and Schocken, +// MIT Press. Book site: www.idc.ac.il/tecs +// File name: tools/builtIn/DRegister.hdl + +/** + * A 16-Bit register called "D Register". + * If load[t-1]=1 then out[t] = in[t-1] + * else out does not change (out[t] = out[t-1]) + * + * This built-in chip implementation has the side effect of + * providing a GUI representation of a 16-bit register + * called "D register" (typically used to store data). + */ + +CHIP DRegister { + + IN in[16], load; + OUT out[16]; + + BUILTIN DRegister; + CLOCKED in, load; +} + diff --git a/projects/09/Tetris/builtInChips/FullAdder.class b/projects/09/Tetris/builtInChips/FullAdder.class new file mode 100755 index 0000000..2ed9ead Binary files /dev/null and b/projects/09/Tetris/builtInChips/FullAdder.class differ diff --git a/projects/09/Tetris/builtInChips/FullAdder.hdl b/projects/09/Tetris/builtInChips/FullAdder.hdl new file mode 100755 index 0000000..a4caa56 --- /dev/null +++ b/projects/09/Tetris/builtInChips/FullAdder.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/FullAdder.hdl + +/** + * Full adder. Computes sum, the least significant bit of + * a + b + c, and carry, the most significant bit of a + b + c. + */ + +CHIP FullAdder { + + IN a, b, c; + OUT sum, // LSB of a + b + c + carry; // MSB of a + b + c + + BUILTIN FullAdder; +} + diff --git a/projects/09/Tetris/builtInChips/HalfAdder.class b/projects/09/Tetris/builtInChips/HalfAdder.class new file mode 100755 index 0000000..e7741ed Binary files /dev/null and b/projects/09/Tetris/builtInChips/HalfAdder.class differ diff --git a/projects/09/Tetris/builtInChips/HalfAdder.hdl b/projects/09/Tetris/builtInChips/HalfAdder.hdl new file mode 100755 index 0000000..1591b96 --- /dev/null +++ b/projects/09/Tetris/builtInChips/HalfAdder.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/HalfAdder.hdl + +/** + * Half adder. Computes sum, the least significnat bit of a + b, + * and carry, the most significnat bit of a + b. + */ + +CHIP HalfAdder { + + IN a, b; + OUT sum, // LSB of a + b + carry; // MSB of a + b + + BUILTIN HalfAdder; +} diff --git a/projects/09/Tetris/builtInChips/Inc16.class b/projects/09/Tetris/builtInChips/Inc16.class new file mode 100755 index 0000000..b5b2aeb Binary files /dev/null and b/projects/09/Tetris/builtInChips/Inc16.class differ diff --git a/projects/09/Tetris/builtInChips/Inc16.hdl b/projects/09/Tetris/builtInChips/Inc16.hdl new file mode 100755 index 0000000..9d2d49b --- /dev/null +++ b/projects/09/Tetris/builtInChips/Inc16.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Inc16.hdl + +/** + * 16-bit incrementer. out = in + 1 (16-bit addition). + * Overflow is neither detected nor handled. + */ + +CHIP Inc16 { + + IN in[16]; + OUT out[16]; + + BUILTIN Inc16; +} + diff --git a/projects/09/Tetris/builtInChips/Keyboard.class b/projects/09/Tetris/builtInChips/Keyboard.class new file mode 100755 index 0000000..090b7cc Binary files /dev/null and b/projects/09/Tetris/builtInChips/Keyboard.class differ diff --git a/projects/09/Tetris/builtInChips/Keyboard.hdl b/projects/09/Tetris/builtInChips/Keyboard.hdl new file mode 100755 index 0000000..26ca5ed --- /dev/null +++ b/projects/09/Tetris/builtInChips/Keyboard.hdl @@ -0,0 +1,23 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Keyboard.hdl + +/** + * The keyboard (memory map). + * Outputs the code of the currently pressed key. + * + * The built-in chip implementation has two side effects supplied + * by the simulator. First, the keyboard memory map is continuously + * being refreshed from the physical keyboard unit. Second, it + * displays a keyboard icon and data entry GUI. + */ + +CHIP Keyboard { + + OUT out[16]; // The ASCII code of the pressed key, + // or 0 if no key is currently pressed, + // or one the special codes listed in Figure 5.5. + + BUILTIN Keyboard; +} diff --git a/projects/09/Tetris/builtInChips/Mux.class b/projects/09/Tetris/builtInChips/Mux.class new file mode 100755 index 0000000..75c6645 Binary files /dev/null and b/projects/09/Tetris/builtInChips/Mux.class differ diff --git a/projects/09/Tetris/builtInChips/Mux.hdl b/projects/09/Tetris/builtInChips/Mux.hdl new file mode 100755 index 0000000..a0eefbc --- /dev/null +++ b/projects/09/Tetris/builtInChips/Mux.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux.hdl + +/** + * Multiplexor. If sel == 1 then out = b else out = a. + */ + +CHIP Mux { + + IN a, b, sel; + OUT out; + + BUILTIN Mux; +} diff --git a/projects/09/Tetris/builtInChips/Mux16.hdl b/projects/09/Tetris/builtInChips/Mux16.hdl new file mode 100755 index 0000000..676d1f4 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Mux16.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux16.hdl + +/** + * 16 bit multiplexor. If sel == 1 then out = b else out = a. + */ + +CHIP Mux16 { + + IN a[16], b[16], sel; + OUT out[16]; + + BUILTIN Mux; +} diff --git a/projects/09/Tetris/builtInChips/Mux4Way16.class b/projects/09/Tetris/builtInChips/Mux4Way16.class new file mode 100755 index 0000000..b2e2ed7 Binary files /dev/null and b/projects/09/Tetris/builtInChips/Mux4Way16.class differ diff --git a/projects/09/Tetris/builtInChips/Mux4Way16.hdl b/projects/09/Tetris/builtInChips/Mux4Way16.hdl new file mode 100755 index 0000000..9929e82 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Mux4Way16.hdl @@ -0,0 +1,21 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux4Way16.hdl + +/** + * 4-way 16-bit multiplexor. + * out = a if sel == 00 + * b if sel == 01 + * c if sel == 10 + * d if sel == 11 + */ + + +CHIP Mux4Way16 { + + IN a[16], b[16], c[16], d[16], sel[2]; + OUT out[16]; + + BUILTIN Mux4Way16; +} diff --git a/projects/09/Tetris/builtInChips/Mux8Way16.class b/projects/09/Tetris/builtInChips/Mux8Way16.class new file mode 100755 index 0000000..d8040ef Binary files /dev/null and b/projects/09/Tetris/builtInChips/Mux8Way16.class differ diff --git a/projects/09/Tetris/builtInChips/Mux8Way16.hdl b/projects/09/Tetris/builtInChips/Mux8Way16.hdl new file mode 100755 index 0000000..dc16861 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Mux8Way16.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux8Way16.hdl + +/** + * 8-way 16-bit multiplexor. + * out = a if sel == 000 + * b if sel == 001 + * etc. + * h if sel == 111 + */ + + +CHIP Mux8Way16 { + + IN a[16], b[16], c[16], d[16], + e[16], f[16], g[16], h[16], + sel[3]; + + OUT out[16]; + + BUILTIN Mux8Way16; +} \ No newline at end of file diff --git a/projects/09/Tetris/builtInChips/Nand.class b/projects/09/Tetris/builtInChips/Nand.class new file mode 100755 index 0000000..4b429ba Binary files /dev/null and b/projects/09/Tetris/builtInChips/Nand.class differ diff --git a/projects/09/Tetris/builtInChips/Nand.hdl b/projects/09/Tetris/builtInChips/Nand.hdl new file mode 100755 index 0000000..ae0204e --- /dev/null +++ b/projects/09/Tetris/builtInChips/Nand.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Nand.hdl + +/** + * Nand gate: out = a Nand b. + */ + +CHIP Nand { + + IN a, b; + OUT out; + + BUILTIN Nand; +} diff --git a/projects/09/Tetris/builtInChips/Not.class b/projects/09/Tetris/builtInChips/Not.class new file mode 100755 index 0000000..4726b67 Binary files /dev/null and b/projects/09/Tetris/builtInChips/Not.class differ diff --git a/projects/09/Tetris/builtInChips/Not.hdl b/projects/09/Tetris/builtInChips/Not.hdl new file mode 100755 index 0000000..5b9d897 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Not.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Not.hdl + +/** + * Not gate: out = not in + */ + +CHIP Not { + + IN in; + OUT out; + + BUILTIN Not; +} \ No newline at end of file diff --git a/projects/09/Tetris/builtInChips/Not16.class b/projects/09/Tetris/builtInChips/Not16.class new file mode 100755 index 0000000..ff3e68f Binary files /dev/null and b/projects/09/Tetris/builtInChips/Not16.class differ diff --git a/projects/09/Tetris/builtInChips/Not16.hdl b/projects/09/Tetris/builtInChips/Not16.hdl new file mode 100755 index 0000000..c50dab9 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Not16.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Not16.hdl + +/** + * 16-bit Not gate: for i = 0..15: out[i] = not in[i] + */ + +CHIP Not16 { + + IN in[16]; + OUT out[16]; + + BUILTIN Not16; +} \ No newline at end of file diff --git a/projects/09/Tetris/builtInChips/Or.class b/projects/09/Tetris/builtInChips/Or.class new file mode 100755 index 0000000..a5b64f9 Binary files /dev/null and b/projects/09/Tetris/builtInChips/Or.class differ diff --git a/projects/09/Tetris/builtInChips/Or.hdl b/projects/09/Tetris/builtInChips/Or.hdl new file mode 100755 index 0000000..4a3f14b --- /dev/null +++ b/projects/09/Tetris/builtInChips/Or.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Or.hdl + +/** + * Or gate: out = 1 if {a == 1 or b == 1}, 0 otherwise + */ + +CHIP Or { + + IN a, b; + OUT out; + + BUILTIN Or; +} diff --git a/projects/09/Tetris/builtInChips/Or16.hdl b/projects/09/Tetris/builtInChips/Or16.hdl new file mode 100755 index 0000000..6c124e8 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Or16.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Or16.hdl + +/** + * 16-bit bitwise Or gate: for i = 0..15 out[i] = a[i] or b[i]. + */ + +CHIP Or16 { + + IN a[16], b[16]; + OUT out[16]; + + BUILTIN Or; +} diff --git a/projects/09/Tetris/builtInChips/Or8Way.class b/projects/09/Tetris/builtInChips/Or8Way.class new file mode 100755 index 0000000..104804b Binary files /dev/null and b/projects/09/Tetris/builtInChips/Or8Way.class differ diff --git a/projects/09/Tetris/builtInChips/Or8Way.hdl b/projects/09/Tetris/builtInChips/Or8Way.hdl new file mode 100755 index 0000000..dccd61d --- /dev/null +++ b/projects/09/Tetris/builtInChips/Or8Way.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Or8Way.hdl + +/** + * 8-way Or gate: out = in[0] or in[1] or ... or in[7]. + */ + +CHIP Or8Way { + + IN in[8]; + OUT out; + + BUILTIN Or8Way; +} diff --git a/projects/09/Tetris/builtInChips/PC.class b/projects/09/Tetris/builtInChips/PC.class new file mode 100755 index 0000000..1e6ada1 Binary files /dev/null and b/projects/09/Tetris/builtInChips/PC.class differ diff --git a/projects/09/Tetris/builtInChips/PC.hdl b/projects/09/Tetris/builtInChips/PC.hdl new file mode 100755 index 0000000..f102d99 --- /dev/null +++ b/projects/09/Tetris/builtInChips/PC.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/PC.hdl + +/** + * 16-bit counter with load and reset controls. + * + * If reset(t-1) then out(t) = 0 + * else if load(t-1) then out(t) = in(t-1) + * else if inc(t-1) then out(t) = out(t-1) + 1 (integer addition) + * else out(t) = out(t-1) + */ + +CHIP PC { + + IN in[16], load, inc, reset; + OUT out[16]; + + BUILTIN PC; + CLOCKED in, load, inc, reset; +} diff --git a/projects/09/Tetris/builtInChips/RAM.class b/projects/09/Tetris/builtInChips/RAM.class new file mode 100755 index 0000000..e17050f Binary files /dev/null and b/projects/09/Tetris/builtInChips/RAM.class differ diff --git a/projects/09/Tetris/builtInChips/RAM16K.class b/projects/09/Tetris/builtInChips/RAM16K.class new file mode 100755 index 0000000..2f1e3fe Binary files /dev/null and b/projects/09/Tetris/builtInChips/RAM16K.class differ diff --git a/projects/09/Tetris/builtInChips/RAM16K.hdl b/projects/09/Tetris/builtInChips/RAM16K.hdl new file mode 100755 index 0000000..7031bf9 --- /dev/null +++ b/projects/09/Tetris/builtInChips/RAM16K.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM16K.hdl + +/** + * Memory of 16K registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM16K[address(t)](t) + * Write: If load(t-1) then RAM16K[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load=1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM16K { + + IN in[16], load, address[14]; + OUT out[16]; + + BUILTIN RAM16K; + CLOCKED in, load; +} diff --git a/projects/09/Tetris/builtInChips/RAM4K.class b/projects/09/Tetris/builtInChips/RAM4K.class new file mode 100755 index 0000000..164ebf8 Binary files /dev/null and b/projects/09/Tetris/builtInChips/RAM4K.class differ diff --git a/projects/09/Tetris/builtInChips/RAM4K.hdl b/projects/09/Tetris/builtInChips/RAM4K.hdl new file mode 100755 index 0000000..8f1b211 --- /dev/null +++ b/projects/09/Tetris/builtInChips/RAM4K.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM4K.hdl + +/** + * Memory of 4K registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM4K[address(t)](t) + * Write: If load(t-1) then RAM4K[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM4K { + + IN in[16], load, address[12]; + OUT out[16]; + + BUILTIN RAM4K; + CLOCKED in, load; +} diff --git a/projects/09/Tetris/builtInChips/RAM512.class b/projects/09/Tetris/builtInChips/RAM512.class new file mode 100755 index 0000000..69bff7a Binary files /dev/null and b/projects/09/Tetris/builtInChips/RAM512.class differ diff --git a/projects/09/Tetris/builtInChips/RAM512.hdl b/projects/09/Tetris/builtInChips/RAM512.hdl new file mode 100755 index 0000000..2a2f433 --- /dev/null +++ b/projects/09/Tetris/builtInChips/RAM512.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM512.hdl + +/** + * Memory of 512 registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM512[address(t)](t) + * Write: If load(t-1) then RAM512[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM512 { + + IN in[16], load, address[9]; + OUT out[16]; + + BUILTIN RAM512; + CLOCKED in, load; +} diff --git a/projects/09/Tetris/builtInChips/RAM64.class b/projects/09/Tetris/builtInChips/RAM64.class new file mode 100755 index 0000000..a1fe78a Binary files /dev/null and b/projects/09/Tetris/builtInChips/RAM64.class differ diff --git a/projects/09/Tetris/builtInChips/RAM64.hdl b/projects/09/Tetris/builtInChips/RAM64.hdl new file mode 100755 index 0000000..6f32f47 --- /dev/null +++ b/projects/09/Tetris/builtInChips/RAM64.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM64.hdl + +/** + * Memory of 64 registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM64[address(t)](t) + * Write: If load(t-1) then RAM64[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM64 { + + IN in[16], load, address[6]; + OUT out[16]; + + BUILTIN RAM64; + CLOCKED in, load; +} diff --git a/projects/09/Tetris/builtInChips/RAM8.class b/projects/09/Tetris/builtInChips/RAM8.class new file mode 100755 index 0000000..88f106e Binary files /dev/null and b/projects/09/Tetris/builtInChips/RAM8.class differ diff --git a/projects/09/Tetris/builtInChips/RAM8.hdl b/projects/09/Tetris/builtInChips/RAM8.hdl new file mode 100755 index 0000000..c08d62c --- /dev/null +++ b/projects/09/Tetris/builtInChips/RAM8.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM8.hdl + +/** + * Memory of 8 registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM8[address(t)](t) + * Write: If load(t-1) then RAM8[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM8 { + + IN in[16], load, address[3]; + OUT out[16]; + + BUILTIN RAM8; + CLOCKED in, load; +} diff --git a/projects/09/Tetris/builtInChips/ROM32K.class b/projects/09/Tetris/builtInChips/ROM32K.class new file mode 100755 index 0000000..c4320d8 Binary files /dev/null and b/projects/09/Tetris/builtInChips/ROM32K.class differ diff --git a/projects/09/Tetris/builtInChips/ROM32K.hdl b/projects/09/Tetris/builtInChips/ROM32K.hdl new file mode 100755 index 0000000..929f824 --- /dev/null +++ b/projects/09/Tetris/builtInChips/ROM32K.hdl @@ -0,0 +1,30 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/ROM32K.hdl + +/** + * Read-Only memory (ROM) of 16K registers, each 16-bit wide. + * The chip is designed to facilitate data read, as follows: + * out(t) = ROM32K[address(t)](t) + * In words: the chip always outputs the value stored at the + * memory location specified by address. + * + * The built-in chip implementation has a GUI side-effect, + * showing an array-like component that displays the ROM's + * contents. The ROM32K chip is supposed to be pre-loaded with + * a machine language program. To that end, the built-in chip + * implementation also knows how to handle the "ROM32K load Xxx" + * script command, where Xxx is the name of a text file containing + * a program written in the Hack machine language. When the + * simulator encounters such a command in a test script, the code + * found in the file is loaded into the simulated ROM32K unit. + */ + +CHIP ROM32K { + + IN address[15]; + OUT out[16]; + + BUILTIN ROM32K; +} diff --git a/projects/09/Tetris/builtInChips/Register.class b/projects/09/Tetris/builtInChips/Register.class new file mode 100755 index 0000000..3958fcd Binary files /dev/null and b/projects/09/Tetris/builtInChips/Register.class differ diff --git a/projects/09/Tetris/builtInChips/Register.hdl b/projects/09/Tetris/builtInChips/Register.hdl new file mode 100755 index 0000000..3b81e46 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Register.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Register.hdl + +/** + * 16-Bit register. + * If load[t-1]=1 then out[t] = in[t-1] + * else out does not change (out[t] = out[t-1]) + */ + +CHIP Register { + + IN in[16], load; + OUT out[16]; + + BUILTIN Register; + CLOCKED in, load; +} diff --git a/projects/09/Tetris/builtInChips/RegisterWithGUI.class b/projects/09/Tetris/builtInChips/RegisterWithGUI.class new file mode 100755 index 0000000..c80208c Binary files /dev/null and b/projects/09/Tetris/builtInChips/RegisterWithGUI.class differ diff --git a/projects/09/Tetris/builtInChips/Screen.class b/projects/09/Tetris/builtInChips/Screen.class new file mode 100755 index 0000000..100ed03 Binary files /dev/null and b/projects/09/Tetris/builtInChips/Screen.class differ diff --git a/projects/09/Tetris/builtInChips/Screen.hdl b/projects/09/Tetris/builtInChips/Screen.hdl new file mode 100755 index 0000000..5e7837b --- /dev/null +++ b/projects/09/Tetris/builtInChips/Screen.hdl @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Screen.hdl + +/** + * The Screen (memory map). + * Functions exactly like a 16-bit 8K RAM: + * 1. out(t)=Screen[address(t)](t) + * 2. If load(t-1) then Screen[address(t-1)](t)=in(t-1) + * + * The built-in chip implementation has the side effect of continuously + * refreshing a visual 256 by 512 black-and-white screen, simulated + * by the simulator. Each row in the visual screen is represented + * by 32 consecutive 16-bit words, starting at the top left corner + * of the visual screen. Thus the pixel at row r from the top and + * column c from the left (0<=r<=255, 0<=c<=511) reflects the c%16 + * bit (counting from LSB to MSB) of the word found in + * Screen[r*32+c/16]. + */ + +CHIP Screen { + + IN in[16], // what to write + load, // write-enable bit + address[13]; // where to read/write + OUT out[16]; // Screen value at the given address + + BUILTIN Screen; + CLOCKED in, load; +} + + + + \ No newline at end of file diff --git a/projects/09/Tetris/builtInChips/Xor.class b/projects/09/Tetris/builtInChips/Xor.class new file mode 100755 index 0000000..d99ad18 Binary files /dev/null and b/projects/09/Tetris/builtInChips/Xor.class differ diff --git a/projects/09/Tetris/builtInChips/Xor.hdl b/projects/09/Tetris/builtInChips/Xor.hdl new file mode 100755 index 0000000..8452d73 --- /dev/null +++ b/projects/09/Tetris/builtInChips/Xor.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Xor.hdl + +/** + * Exclusive-or gate: out = !(a == b). + */ + +CHIP Xor { + + IN a, b; + OUT out; + + BUILTIN Xor; +} diff --git a/projects/09/Tetris/builtInVMCode/Array.class b/projects/09/Tetris/builtInVMCode/Array.class new file mode 100755 index 0000000..c76b652 Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/Array.class differ diff --git a/projects/09/Tetris/builtInVMCode/JackOSClass.class b/projects/09/Tetris/builtInVMCode/JackOSClass.class new file mode 100755 index 0000000..25df72a Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/JackOSClass.class differ diff --git a/projects/09/Tetris/builtInVMCode/Keyboard.class b/projects/09/Tetris/builtInVMCode/Keyboard.class new file mode 100755 index 0000000..7366f75 Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/Keyboard.class differ diff --git a/projects/09/Tetris/builtInVMCode/Math.class b/projects/09/Tetris/builtInVMCode/Math.class new file mode 100755 index 0000000..71aef91 Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/Math.class differ diff --git a/projects/09/Tetris/builtInVMCode/Memory.class b/projects/09/Tetris/builtInVMCode/Memory.class new file mode 100755 index 0000000..e9bb7ad Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/Memory.class differ diff --git a/projects/09/Tetris/builtInVMCode/Output.class b/projects/09/Tetris/builtInVMCode/Output.class new file mode 100755 index 0000000..65b25b7 Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/Output.class differ diff --git a/projects/09/Tetris/builtInVMCode/Screen.class b/projects/09/Tetris/builtInVMCode/Screen.class new file mode 100755 index 0000000..8644e09 Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/Screen.class differ diff --git a/projects/09/Tetris/builtInVMCode/String.class b/projects/09/Tetris/builtInVMCode/String.class new file mode 100755 index 0000000..98c7f58 Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/String.class differ diff --git a/projects/09/Tetris/builtInVMCode/Sys.class b/projects/09/Tetris/builtInVMCode/Sys.class new file mode 100755 index 0000000..0c15f1b Binary files /dev/null and b/projects/09/Tetris/builtInVMCode/Sys.class differ diff --git a/projects/09/Tetris/symbol_table.py b/projects/09/Tetris/symbol_table.py new file mode 100755 index 0000000..7c62c3e --- /dev/null +++ b/projects/09/Tetris/symbol_table.py @@ -0,0 +1,62 @@ +class Symbol: + def __init__(self): + self.s_name = '' + self.s_kind = '' + self.s_type = '' + self.s_index = 0 + + +class SymbolTable: + def __init__(self): + self.sym = [] + + def define(self, s_name, s_type, s_kind): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = s_kind + self.sym[-1].s_index = self.var_count(s_kind) - 1 + + def start_subroutine(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'argument' + self.sym[-1].s_index = 0 + + def start_class(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = 'this' + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'field' + self.sym[-1].s_index = 0 + + def var_count(self, s_kind): + count = 0 # it is -1 so the first index is 0 + for i in self.sym: + if i.s_kind == s_kind: + count += 1 + return count + + def kind_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + if i.s_kind == 'var': + return 'local' + elif i.s_kind == 'field': + return 'this' + else: + return i.s_kind + return None + + def type_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_type + return None + + def index_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_index + return None diff --git a/projects/09/Tetris/tokenizer.py b/projects/09/Tetris/tokenizer.py new file mode 100755 index 0000000..aaaa873 --- /dev/null +++ b/projects/09/Tetris/tokenizer.py @@ -0,0 +1,78 @@ +import re + + +class Tokenizer: + + def __init__(self): + self.i = 0 + self.file = '' + self.symbols = ('(', ')', '[', ']', '}', '{', '>', '<', '=', '*', '+', '-', '/', '.', ';', ',', '&', '|', + '~') + self.key_word = ( + 'class', 'method', 'function', 'constructor', 'int', 'boolean', 'char', 'void', 'var', 'static', 'field', + 'let', 'do', 'if', 'else', 'while', 'return', 'true', 'false', 'null', 'this') + self.token = '' + + def token_type(self, token=None): + if token is None: + token = self.token + if token is None or token == '': + return None + if token in self.key_word: + return 'keyword' + elif token[0] == '"': + return 'stringConstant' + elif re.match(r"\d+", token): + return 'integerConstant' + elif token in self.symbols: + return 'symbol' + else: + return 'identifier' + + def advance(self): + token = '' + i = self.i + while i < len(self.file): + if re.match(r'\s', self.file[i]): + i = i + 1 + continue + else: + if self.file[i] in self.symbols: + self.token = self.file[i] + self.i = i + 1 + return + elif self.file[i] == '"': + i += 1 + while self.file[i] != '"': + token += self.file[i] + i += 1 + self.i = i + 1 + self.token = '"' + token + '"' + return + else: + while re.match(r'\w', self.file[i]): + token += self.file[i] + if i + 1 > len(self.file) - 1: + break + i += 1 + self.i = i + self.token = token + return + + def clear_file(self, directory): + with open(directory, "r") as my_file: + txt = my_file.read() + txt = re.sub(r"//.*", "", txt) + txt = re.sub(r"/[*][*].*[*]/", "", txt) + i = 0 + # TODO this should be a regex + while i < len(txt): + if txt[i] == '/' and txt[i + 1] == '*' and txt[i + 2] == '*': + start = i + while txt[i] != '*' or txt[i + 1] != '/': + i += 1 + stop = i + 2 + txt = txt[:start] + txt[stop:len(txt)] + i = start - 1 + i += 1 + self.file = txt diff --git a/projects/09/Tetris/vmwriter.py b/projects/09/Tetris/vmwriter.py new file mode 100755 index 0000000..98c4840 --- /dev/null +++ b/projects/09/Tetris/vmwriter.py @@ -0,0 +1,75 @@ +class VMWriter: + def __init__(self, vm_path): + self.my_vm = open(vm_path, "w+") + self.label_index = 0 + + def write_push(self, segment, index): + self.my_vm.write(f'push {segment} {index}\n') + #print(f'push {segment} {index}') + + def write_lable(self, label): + self.my_vm.write(f'label L{label}\n') + #print(f'label L{label}') + + def write_arithmetic(self, command): + if command == '+': + self.my_vm.write('add\n') + #print('add') + elif command == '-': + self.my_vm.write('sub\n') + #print('sub') + elif command == 'neg': + self.my_vm.write('neg\n') + #print('neg') + elif command == '=': + self.my_vm.write('eq\n') + #print('eq') + elif command == '>': + self.my_vm.write('gt\n') + #print('gt') + elif command == '<': + self.my_vm.write('lt\n') + #print('lt') + elif command == '&': + self.my_vm.write('and\n') + #print('and') + elif command == '|': + self.my_vm.write('or\n') + #print('or') + elif command == '~': + self.my_vm.write('not\n') + #print('not') + elif command == '*': + self.write_call('Math.multiply', 2) + elif command == '/': + self.write_call('Math.divide', 2) + + def write_pop(self, segment, index): + #print(f'pop {segment} {index}') + self.my_vm.write(f'pop {segment} {index}\n') + + def write_goto(self, label): + self.my_vm.write(f'goto L{label}\n') + #print(f'goto L{label}') + + def write_if(self, label): + self.write_arithmetic('~') + self.my_vm.write(f'if-goto L{label}\n') + #print(f'if-goto L{label}') + + def write_call(self, label, num_args): + self.my_vm.write(f'call {label} {num_args}\n') + #print(f'call {label} {num_args}') + + def write_function(self, label, num_locals): + self.my_vm.write(f'function {label} {num_locals}\n') + #print(f'function {label} {num_locals}') + + def write_return(self, func_type): + if func_type == 'void': + self.write_push('constant', '0') + self.my_vm.write('return\n') + #print(f'return') + + def close_vm_file(self): + self.my_vm.close() diff --git a/projects/10/ArrayTest/Main.jack b/projects/10/ArrayTest/Main.jack new file mode 100755 index 0000000..aa237b1 --- /dev/null +++ b/projects/10/ArrayTest/Main.jack @@ -0,0 +1,38 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/10/ArrayTest/Main.jack + +// (identical to projects/09/Average/Main.jack) + +/** Computes the average of a sequence of integers. */ +class Main { + function void main() { + var Array a; + var int length; + var int i, sum; + + let length = Keyboard.readInt("HOW MANY NUMBERS? "); + let a = Array.new(length); + let i = 0; + + while (i < length) { + let a[i] = Keyboard.readInt("ENTER THE NEXT NUMBER: "); + let i = i + 1; + } + + let i = 0; + let sum = 0; + + while (i < length) { + let sum = sum + a[i]; + let i = i + 1; + } + + do Output.printString("THE AVERAGE IS: "); + do Output.printInt(sum / length); + do Output.println(); + + return; + } +} diff --git a/projects/10/ArrayTest/Main.xml b/projects/10/ArrayTest/Main.xml new file mode 100755 index 0000000..0ea96df --- /dev/null +++ b/projects/10/ArrayTest/Main.xml @@ -0,0 +1,286 @@ + + class + Main + { + + function + void + main + ( + + + ) + + { + + var + Array + a + ; + + + var + int + length + ; + + + var + int + i + , + sum + ; + + + + let + length + = + + + Keyboard + . + readInt + ( + + + + HOW MANY NUMBERS? + + + + ) + + + ; + + + let + a + = + + + Array + . + new + ( + + + + length + + + + ) + + + ; + + + let + i + = + + + 0 + + + ; + + + while + ( + + + i + + < + + length + + + ) + { + + + let + a + [ + + + i + + + ] + = + + + Keyboard + . + readInt + ( + + + + ENTER THE NEXT NUMBER: + + + + ) + + + ; + + + let + i + = + + + i + + + + + 1 + + + ; + + + } + + + let + i + = + + + 0 + + + ; + + + let + sum + = + + + 0 + + + ; + + + while + ( + + + i + + < + + length + + + ) + { + + + let + sum + = + + + sum + + + + + a + [ + + + i + + + ] + + + ; + + + let + i + = + + + i + + + + + 1 + + + ; + + + } + + + do + Output + . + printString + ( + + + + THE AVERAGE IS: + + + + ) + ; + + + do + Output + . + printInt + ( + + + + sum + + / + + length + + + + ) + ; + + + do + Output + . + println + ( + + + ) + ; + + + return + ; + + + } + + + } + diff --git a/projects/10/ArrayTest/MainT.xml b/projects/10/ArrayTest/MainT.xml new file mode 100755 index 0000000..68721ec --- /dev/null +++ b/projects/10/ArrayTest/MainT.xml @@ -0,0 +1,142 @@ + + class + Main + { + function + void + main + ( + ) + { + var + Array + a + ; + var + int + length + ; + var + int + i + , + sum + ; + let + length + = + Keyboard + . + readInt + ( + HOW MANY NUMBERS? + ) + ; + let + a + = + Array + . + new + ( + length + ) + ; + let + i + = + 0 + ; + while + ( + i + < + length + ) + { + let + a + [ + i + ] + = + Keyboard + . + readInt + ( + ENTER THE NEXT NUMBER: + ) + ; + let + i + = + i + + + 1 + ; + } + let + i + = + 0 + ; + let + sum + = + 0 + ; + while + ( + i + < + length + ) + { + let + sum + = + sum + + + a + [ + i + ] + ; + let + i + = + i + + + 1 + ; + } + do + Output + . + printString + ( + THE AVERAGE IS: + ) + ; + do + Output + . + printInt + ( + sum + / + length + ) + ; + do + Output + . + println + ( + ) + ; + return + ; + } + } + diff --git a/projects/10/ExpressionLessSquare/Main.jack b/projects/10/ExpressionLessSquare/Main.jack new file mode 100755 index 0000000..94764ad --- /dev/null +++ b/projects/10/ExpressionLessSquare/Main.jack @@ -0,0 +1,28 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/10/ExpressionLessSquare/Main.jack + +/** Expressionless version of projects/10/Square/Main.jack. */ + +class Main { + static boolean test; // Added for testing -- there is no static keyword + // in the Square files. + + function void main() { + var SquareGame game; + let game = game; + do game.run(); + do game.dispose(); + return; + } + + function void more() { // Added to test Jack syntax that is not used in + var boolean b; // the Square files. + if (b) { + } + else { // There is no else keyword in the Square files. + } + return; + } +} diff --git a/projects/10/ExpressionLessSquare/Main.xml b/projects/10/ExpressionLessSquare/Main.xml new file mode 100755 index 0000000..f71a0ef --- /dev/null +++ b/projects/10/ExpressionLessSquare/Main.xml @@ -0,0 +1,114 @@ + + class + Main + { + + static + boolean + test + ; + + + function + void + main + ( + + + ) + + { + + var + SquareGame + game + ; + + + + let + game + = + + + game + + + ; + + + do + game + . + run + ( + + + ) + ; + + + do + game + . + dispose + ( + + + ) + ; + + + return + ; + + + } + + + + function + void + more + ( + + + ) + + { + + var + boolean + b + ; + + + + if + ( + + + b + + + ) + { + + + } + else + { + + + } + + + return + ; + + + } + + + } + diff --git a/projects/10/ExpressionLessSquare/MainT.xml b/projects/10/ExpressionLessSquare/MainT.xml new file mode 100755 index 0000000..441dfed --- /dev/null +++ b/projects/10/ExpressionLessSquare/MainT.xml @@ -0,0 +1,64 @@ + + class + Main + { + static + boolean + test + ; + function + void + main + ( + ) + { + var + SquareGame + game + ; + let + game + = + game + ; + do + game + . + run + ( + ) + ; + do + game + . + dispose + ( + ) + ; + return + ; + } + function + void + more + ( + ) + { + var + boolean + b + ; + if + ( + b + ) + { + } + else + { + } + return + ; + } + } + diff --git a/projects/10/ExpressionLessSquare/Square.jack b/projects/10/ExpressionLessSquare/Square.jack new file mode 100755 index 0000000..33a54ad --- /dev/null +++ b/projects/10/ExpressionLessSquare/Square.jack @@ -0,0 +1,99 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +/// File name: projects/10/ExpressionLessSquare/Square.jack + +/** Expressionless version of projects/10/Square/Square.jack. */ + +class Square { + + field int x, y; + field int size; + + constructor Square new(int Ax, int Ay, int Asize) { + let x = Ax; + let y = Ay; + let size = Asize; + do draw(); + return x; + } + + method void dispose() { + do Memory.deAlloc(this); + return; + } + + method void draw() { + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + return; + } + + method void erase() { + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + return; + } + + method void incSize() { + if (x) { + do erase(); + let size = size; + do draw(); + } + return; + } + + method void decSize() { + if (size) { + do erase(); + let size = size; + do draw(); + } + return; + } + + method void moveUp() { + if (y) { + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + let y = y; + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + } + return; + } + + method void moveDown() { + if (y) { + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + let y = y; + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + } + return; + } + + method void moveLeft() { + if (x) { + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + let x = x; + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + } + return; + } + + method void moveRight() { + if (x) { + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + let x = x; + do Screen.setColor(x); + do Screen.drawRectangle(x, y, x, y); + } + return; + } +} diff --git a/projects/10/ExpressionLessSquare/Square.xml b/projects/10/ExpressionLessSquare/Square.xml new file mode 100755 index 0000000..ed0e6ec --- /dev/null +++ b/projects/10/ExpressionLessSquare/Square.xml @@ -0,0 +1,967 @@ + + class + Square + { + + field + int + x + , + y + ; + + + field + int + size + ; + + + constructor + Square + new + ( + + int + Ax + , + int + Ay + , + int + Asize + + ) + + { + + + let + x + = + + + Ax + + + ; + + + let + y + = + + + Ay + + + ; + + + let + size + = + + + Asize + + + ; + + + do + draw + ( + + + ) + ; + + + return + + + x + + + ; + + + } + + + + method + void + dispose + ( + + + ) + + { + + + do + Memory + . + deAlloc + ( + + + + this + + + + ) + ; + + + return + ; + + + } + + + + method + void + draw + ( + + + ) + + { + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + return + ; + + + } + + + + method + void + erase + ( + + + ) + + { + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + return + ; + + + } + + + + method + void + incSize + ( + + + ) + + { + + + if + ( + + + x + + + ) + { + + + do + erase + ( + + + ) + ; + + + let + size + = + + + size + + + ; + + + do + draw + ( + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + decSize + ( + + + ) + + { + + + if + ( + + + size + + + ) + { + + + do + erase + ( + + + ) + ; + + + let + size + = + + + size + + + ; + + + do + draw + ( + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveUp + ( + + + ) + + { + + + if + ( + + + y + + + ) + { + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + let + y + = + + + y + + + ; + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveDown + ( + + + ) + + { + + + if + ( + + + y + + + ) + { + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + let + y + = + + + y + + + ; + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveLeft + ( + + + ) + + { + + + if + ( + + + x + + + ) + { + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + let + x + = + + + x + + + ; + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveRight + ( + + + ) + + { + + + if + ( + + + x + + + ) + { + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + let + x + = + + + x + + + ; + + + do + Screen + . + setColor + ( + + + + x + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + , + + + y + + + + ) + ; + + + } + + + return + ; + + + } + + + } + diff --git a/projects/10/ExpressionLessSquare/SquareGame.jack b/projects/10/ExpressionLessSquare/SquareGame.jack new file mode 100755 index 0000000..2866f0d --- /dev/null +++ b/projects/10/ExpressionLessSquare/SquareGame.jack @@ -0,0 +1,60 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/10/ExpressionLessSquare/SquareGame.jack + +/** Expressionless version of projects/10/Square/SquareGame.jack. */ + +class SquareGame { + field Square square; + field int direction; + + constructor SquareGame new() { + let square = square; + let direction = direction; + return square; + } + + method void dispose() { + do square.dispose(); + do Memory.deAlloc(square); + return; + } + + method void moveSquare() { + if (direction) { do square.moveUp(); } + if (direction) { do square.moveDown(); } + if (direction) { do square.moveLeft(); } + if (direction) { do square.moveRight(); } + do Sys.wait(direction); + return; + } + + method void run() { + var char key; + var boolean exit; + + let exit = key; + while (exit) { + while (key) { + let key = key; + do moveSquare(); + } + + if (key) { let exit = exit; } + if (key) { do square.decSize(); } + if (key) { do square.incSize(); } + if (key) { let direction = exit; } + if (key) { let direction = key; } + if (key) { let direction = square; } + if (key) { let direction = direction; } + + while (key) { + let key = key; + do moveSquare(); + } + } + return; + } +} + diff --git a/projects/10/ExpressionLessSquare/SquareGame.xml b/projects/10/ExpressionLessSquare/SquareGame.xml new file mode 100755 index 0000000..288c6cd --- /dev/null +++ b/projects/10/ExpressionLessSquare/SquareGame.xml @@ -0,0 +1,544 @@ + + class + SquareGame + { + + field + Square + square + ; + + + field + int + direction + ; + + + constructor + SquareGame + new + ( + + + ) + + { + + + let + square + = + + + square + + + ; + + + let + direction + = + + + direction + + + ; + + + return + + + square + + + ; + + + } + + + + method + void + dispose + ( + + + ) + + { + + + do + square + . + dispose + ( + + + ) + ; + + + do + Memory + . + deAlloc + ( + + + + square + + + + ) + ; + + + return + ; + + + } + + + + method + void + moveSquare + ( + + + ) + + { + + + if + ( + + + direction + + + ) + { + + + do + square + . + moveUp + ( + + + ) + ; + + + } + + + if + ( + + + direction + + + ) + { + + + do + square + . + moveDown + ( + + + ) + ; + + + } + + + if + ( + + + direction + + + ) + { + + + do + square + . + moveLeft + ( + + + ) + ; + + + } + + + if + ( + + + direction + + + ) + { + + + do + square + . + moveRight + ( + + + ) + ; + + + } + + + do + Sys + . + wait + ( + + + + direction + + + + ) + ; + + + return + ; + + + } + + + + method + void + run + ( + + + ) + + { + + var + char + key + ; + + + var + boolean + exit + ; + + + + let + exit + = + + + key + + + ; + + + while + ( + + + exit + + + ) + { + + + while + ( + + + key + + + ) + { + + + let + key + = + + + key + + + ; + + + do + moveSquare + ( + + + ) + ; + + + } + + + if + ( + + + key + + + ) + { + + + let + exit + = + + + exit + + + ; + + + } + + + if + ( + + + key + + + ) + { + + + do + square + . + decSize + ( + + + ) + ; + + + } + + + if + ( + + + key + + + ) + { + + + do + square + . + incSize + ( + + + ) + ; + + + } + + + if + ( + + + key + + + ) + { + + + let + direction + = + + + exit + + + ; + + + } + + + if + ( + + + key + + + ) + { + + + let + direction + = + + + key + + + ; + + + } + + + if + ( + + + key + + + ) + { + + + let + direction + = + + + square + + + ; + + + } + + + if + ( + + + key + + + ) + { + + + let + direction + = + + + direction + + + ; + + + } + + + while + ( + + + key + + + ) + { + + + let + key + = + + + key + + + ; + + + do + moveSquare + ( + + + ) + ; + + + } + + + } + + + return + ; + + + } + + + } + diff --git a/projects/10/ExpressionLessSquare/SquareGameT.xml b/projects/10/ExpressionLessSquare/SquareGameT.xml new file mode 100755 index 0000000..278a8a9 --- /dev/null +++ b/projects/10/ExpressionLessSquare/SquareGameT.xml @@ -0,0 +1,268 @@ + + class + SquareGame + { + field + Square + square + ; + field + int + direction + ; + constructor + SquareGame + new + ( + ) + { + let + square + = + square + ; + let + direction + = + direction + ; + return + square + ; + } + method + void + dispose + ( + ) + { + do + square + . + dispose + ( + ) + ; + do + Memory + . + deAlloc + ( + square + ) + ; + return + ; + } + method + void + moveSquare + ( + ) + { + if + ( + direction + ) + { + do + square + . + moveUp + ( + ) + ; + } + if + ( + direction + ) + { + do + square + . + moveDown + ( + ) + ; + } + if + ( + direction + ) + { + do + square + . + moveLeft + ( + ) + ; + } + if + ( + direction + ) + { + do + square + . + moveRight + ( + ) + ; + } + do + Sys + . + wait + ( + direction + ) + ; + return + ; + } + method + void + run + ( + ) + { + var + char + key + ; + var + boolean + exit + ; + let + exit + = + key + ; + while + ( + exit + ) + { + while + ( + key + ) + { + let + key + = + key + ; + do + moveSquare + ( + ) + ; + } + if + ( + key + ) + { + let + exit + = + exit + ; + } + if + ( + key + ) + { + do + square + . + decSize + ( + ) + ; + } + if + ( + key + ) + { + do + square + . + incSize + ( + ) + ; + } + if + ( + key + ) + { + let + direction + = + exit + ; + } + if + ( + key + ) + { + let + direction + = + key + ; + } + if + ( + key + ) + { + let + direction + = + square + ; + } + if + ( + key + ) + { + let + direction + = + direction + ; + } + while + ( + key + ) + { + let + key + = + key + ; + do + moveSquare + ( + ) + ; + } + } + return + ; + } + } + diff --git a/projects/10/ExpressionLessSquare/SquareT.xml b/projects/10/ExpressionLessSquare/SquareT.xml new file mode 100755 index 0000000..cd03a1e --- /dev/null +++ b/projects/10/ExpressionLessSquare/SquareT.xml @@ -0,0 +1,449 @@ + + class + Square + { + field + int + x + , + y + ; + field + int + size + ; + constructor + Square + new + ( + int + Ax + , + int + Ay + , + int + Asize + ) + { + let + x + = + Ax + ; + let + y + = + Ay + ; + let + size + = + Asize + ; + do + draw + ( + ) + ; + return + x + ; + } + method + void + dispose + ( + ) + { + do + Memory + . + deAlloc + ( + this + ) + ; + return + ; + } + method + void + draw + ( + ) + { + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + return + ; + } + method + void + erase + ( + ) + { + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + return + ; + } + method + void + incSize + ( + ) + { + if + ( + x + ) + { + do + erase + ( + ) + ; + let + size + = + size + ; + do + draw + ( + ) + ; + } + return + ; + } + method + void + decSize + ( + ) + { + if + ( + size + ) + { + do + erase + ( + ) + ; + let + size + = + size + ; + do + draw + ( + ) + ; + } + return + ; + } + method + void + moveUp + ( + ) + { + if + ( + y + ) + { + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + let + y + = + y + ; + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + } + return + ; + } + method + void + moveDown + ( + ) + { + if + ( + y + ) + { + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + let + y + = + y + ; + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + } + return + ; + } + method + void + moveLeft + ( + ) + { + if + ( + x + ) + { + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + let + x + = + x + ; + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + } + return + ; + } + method + void + moveRight + ( + ) + { + if + ( + x + ) + { + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + let + x + = + x + ; + do + Screen + . + setColor + ( + x + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + , + y + ) + ; + } + return + ; + } + } + diff --git a/projects/10/JackAnalyzer.py b/projects/10/JackAnalyzer.py new file mode 100755 index 0000000..d7f8f02 --- /dev/null +++ b/projects/10/JackAnalyzer.py @@ -0,0 +1,410 @@ +import re +import os +from pathlib import Path + + +class Tokenizer: + + def __init__(self): + self.i = 0 + self.file = '' + self.symbols = ('(', ')', '[', ']', '}', '{', '>', '<', '=', '*', '+', '-', '/', '.', ';', ',', '&', '|', + '~', '>', '<', '&') + self.key_word = ( + 'class', 'method', 'function', 'constructor', 'int', 'boolean', 'char', 'void', 'var', 'static', 'field', + 'let', 'do', 'if', 'else', 'while', 'return', 'true', 'false', 'null', 'this') + self.token = '' + + def token_type(self): + if self.token is None or self.token == '': + return None + if self.token in self.key_word: + return 'keyword' + elif self.token[0] == '"': + return 'stringConstant' + elif re.match(r"\d+", self.token): + return 'integerConstant' + elif self.token in self.symbols: + return 'symbol' + else: + return 'identifier' + + def advance(self): + token = '' + i = self.i + while i < len(self.file): + if re.match(r'\s', self.file[i]): + i = i + 1 + continue + else: + if self.file[i] in self.symbols: + if self.file[i] == '>': + self.token = '>' + elif self.file[i] == '<': + self.token = '<' + elif self.file[i] == '&': + self.token = '&' + else: + self.token = self.file[i] + # self.token = self.file[i] + self.i = i + 1 + return + elif self.file[i] == '"': + i += 1 + while self.file[i] != '"': + token += self.file[i] + i += 1 + self.i = i + 1 + self.token = '"' + token + '"' + return + else: + while re.match(r'\w', self.file[i]): + token += self.file[i] + if i + 1 > len(self.file) - 1: + break + i += 1 + self.i = i + self.token = token + return + + def clear_file(self, directory): + with open(directory, "r") as my_file: + txt = my_file.read() + txt = re.sub(r"//.*", "", txt) + txt = re.sub(r"/[*][*].*[*]/", "", txt) + txt = re.sub(r"/[*][*][\w*\W*]*[*]/", "", txt) + self.file = txt + + +class CompilationEngine: + def __init__(self): + self.string = '' + self.tab = 0 + + def write_token(self, tokenizer): + if tokenizer.token_type() == 'stringConstant': + self.string += ' ' * self.tab + '<' + tokenizer.token_type() + '> ' + tokenizer.token.strip('"') + ' \n' + else: + self.string += ' ' * self.tab + '<' + tokenizer.token_type() + '> ' + tokenizer.token + ' \n' + + def compile_class(self, tokenizer): + tokenizer.advance() + self.string += '\n' + ' ' * self.tab + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token != '}': + if tokenizer.token in ['static', 'field']: + self.compile_class_var_dec(tokenizer) + if tokenizer.token in ['constructor', 'function', 'method']: + self.compile_subroutine(tokenizer) + + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_class_var_dec(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_subroutine(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_parameter_list(tokenizer) + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token != '}': + if tokenizer.token == 'var': + self.compile_var_dec(tokenizer) + elif tokenizer.token in ['let', 'if', 'while', 'do', 'return']: + self.compile_statements(tokenizer) + self.write_token(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_parameter_list(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + while tokenizer.token != ')': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + self.write_token(tokenizer) + tokenizer.advance() + + def compile_var_dec(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_statements(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + while True: + if tokenizer.token == 'let': + self.compile_let(tokenizer) + elif tokenizer.token == 'if': + self.compile_if(tokenizer) + elif tokenizer.token == 'while': + self.compile_while(tokenizer) + elif tokenizer.token == 'do': + self.compile_do(tokenizer) + elif tokenizer.token == 'return': + self.compile_return(tokenizer) + else: + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + break + + def compile_do(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token == '(': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + elif tokenizer.token == '.': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_let(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token == '[': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_while(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_statements(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_return(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token != ';': + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_if(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_statements(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == 'else': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_statements(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_expression(self, tokenizer): + if tokenizer.token in ['(', '~', '-'] or tokenizer.token_type() != 'symbol': + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.compile_term(tokenizer) + while tokenizer.token in ['+', '-', '*', '/', '&', '|', '<', '>', '=']: + self.write_token(tokenizer) + tokenizer.advance() + self.compile_term(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_term(self, tokenizer): + if tokenizer.token == '(': + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token in ['~', '-']: + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.compile_term(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token_type() != 'symbol': + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token == '[': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token == '(': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token == '.': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + else: + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_expression_list(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.compile_expression(tokenizer) + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + +path = os.getcwd() +for root, dirs, files in os.walk(path, topdown=False): + for name in files: + if name[-4:] == 'jack': + tok = Tokenizer() + tok.clear_file(Path(root, name)) + ce = CompilationEngine() + ce.compile_class(tok) + with open(Path(root, name[:-4] + 'xml'), "w+") as my_xml: + my_xml.write(ce.string) diff --git a/projects/10/Square/Main.jack b/projects/10/Square/Main.jack new file mode 100755 index 0000000..a6fd2c2 --- /dev/null +++ b/projects/10/Square/Main.jack @@ -0,0 +1,36 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/10/Square/Main.jack + +// (derived from projects/09/Square/Main.jack, with testing additions) + +/** Initializes a new Square Dance game and starts running it. */ +class Main { + static boolean test; // Added for testing -- there is no static keyword + // in the Square files. + function void main() { + var SquareGame game; + let game = SquareGame.new(); + do game.run(); + do game.dispose(); + return; + } + + function void more() { // Added to test Jack syntax that is not used in + var int i, j; // the Square files. + var String s; + var Array a; + if (false) { + let s = "string constant"; + let s = null; + let a[1] = a[2]; + } + else { // There is no else keyword in the Square files. + let i = i * (-j); + let j = j / (-2); // note: unary negate constant 2 + let i = i | j; + } + return; + } +} diff --git a/projects/10/Square/Main.xml b/projects/10/Square/Main.xml new file mode 100755 index 0000000..8796fa9 --- /dev/null +++ b/projects/10/Square/Main.xml @@ -0,0 +1,244 @@ + + class + Main + { + + static + boolean + test + ; + + + function + void + main + ( + + + ) + + { + + var + SquareGame + game + ; + + + + let + game + = + + + SquareGame + . + new + ( + + + ) + + + ; + + + do + game + . + run + ( + + + ) + ; + + + do + game + . + dispose + ( + + + ) + ; + + + return + ; + + + } + + + + function + void + more + ( + + + ) + + { + + var + int + i + , + j + ; + + + var + String + s + ; + + + var + Array + a + ; + + + + if + ( + + + false + + + ) + { + + + let + s + = + + + string constant + + + ; + + + let + s + = + + + null + + + ; + + + let + a + [ + + + 1 + + + ] + = + + + a + [ + + + 2 + + + ] + + + ; + + + } + else + { + + + let + i + = + + + i + + * + + ( + + + - + + j + + + + ) + + + ; + + + let + j + = + + + j + + / + + ( + + + - + + 2 + + + + ) + + + ; + + + let + i + = + + + i + + | + + j + + + ; + + + } + + + return + ; + + + } + + + } + diff --git a/projects/10/Square/MainT.xml b/projects/10/Square/MainT.xml new file mode 100755 index 0000000..bc92200 --- /dev/null +++ b/projects/10/Square/MainT.xml @@ -0,0 +1,126 @@ + + class + Main + { + static + boolean + test + ; + function + void + main + ( + ) + { + var + SquareGame + game + ; + let + game + = + SquareGame + . + new + ( + ) + ; + do + game + . + run + ( + ) + ; + do + game + . + dispose + ( + ) + ; + return + ; + } + function + void + more + ( + ) + { + var + int + i + , + j + ; + var + String + s + ; + var + Array + a + ; + if + ( + false + ) + { + let + s + = + string constant + ; + let + s + = + null + ; + let + a + [ + 1 + ] + = + a + [ + 2 + ] + ; + } + else + { + let + i + = + i + * + ( + - + j + ) + ; + let + j + = + j + / + ( + - + 2 + ) + ; + let + i + = + i + | + j + ; + } + return + ; + } + } + diff --git a/projects/10/Square/Square.jack b/projects/10/Square/Square.jack new file mode 100755 index 0000000..3faf24f --- /dev/null +++ b/projects/10/Square/Square.jack @@ -0,0 +1,110 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/10/Square/Square.jack + +// (same as projects/09/Square/Square.jack) + +/** Implements a graphical square. */ +class Square { + + field int x, y; // screen location of the square's top-left corner + field int size; // length of this square, in pixels + + /** Constructs a new square with a given location and size. */ + constructor Square new(int Ax, int Ay, int Asize) { + let x = Ax; + let y = Ay; + let size = Asize; + do draw(); + return this; + } + + /** Disposes this square. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** Draws the square on the screen. */ + method void draw() { + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + size, y + size); + return; + } + + /** Erases the square from the screen. */ + method void erase() { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + size, y + size); + return; + } + + /** Increments the square size by 2 pixels. */ + method void incSize() { + if (((y + size) < 254) & ((x + size) < 510)) { + do erase(); + let size = size + 2; + do draw(); + } + return; + } + + /** Decrements the square size by 2 pixels. */ + method void decSize() { + if (size > 2) { + do erase(); + let size = size - 2; + do draw(); + } + return; + } + + /** Moves the square up by 2 pixels. */ + method void moveUp() { + if (y > 1) { + do Screen.setColor(false); + do Screen.drawRectangle(x, (y + size) - 1, x + size, y + size); + let y = y - 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + size, y + 1); + } + return; + } + + /** Moves the square down by 2 pixels. */ + method void moveDown() { + if ((y + size) < 254) { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + size, y + 1); + let y = y + 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, (y + size) - 1, x + size, y + size); + } + return; + } + + /** Moves the square left by 2 pixels. */ + method void moveLeft() { + if (x > 1) { + do Screen.setColor(false); + do Screen.drawRectangle((x + size) - 1, y, x + size, y + size); + let x = x - 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + 1, y + size); + } + return; + } + + /** Moves the square right by 2 pixels. */ + method void moveRight() { + if ((x + size) < 510) { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + 1, y + size); + let x = x + 2; + do Screen.setColor(true); + do Screen.drawRectangle((x + size) - 1, y, x + size, y + size); + } + return; + } +} diff --git a/projects/10/Square/Square.xml b/projects/10/Square/Square.xml new file mode 100755 index 0000000..ff5f235 --- /dev/null +++ b/projects/10/Square/Square.xml @@ -0,0 +1,1211 @@ + + class + Square + { + + field + int + x + , + y + ; + + + field + int + size + ; + + + constructor + Square + new + ( + + int + Ax + , + int + Ay + , + int + Asize + + ) + + { + + + let + x + = + + + Ax + + + ; + + + let + y + = + + + Ay + + + ; + + + let + size + = + + + Asize + + + ; + + + do + draw + ( + + + ) + ; + + + return + + + this + + + ; + + + } + + + + method + void + dispose + ( + + + ) + + { + + + do + Memory + . + deAlloc + ( + + + + this + + + + ) + ; + + + return + ; + + + } + + + + method + void + draw + ( + + + ) + + { + + + do + Screen + . + setColor + ( + + + + true + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + + + size + + + , + + + y + + + + + size + + + + ) + ; + + + return + ; + + + } + + + + method + void + erase + ( + + + ) + + { + + + do + Screen + . + setColor + ( + + + + false + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + + + size + + + , + + + y + + + + + size + + + + ) + ; + + + return + ; + + + } + + + + method + void + incSize + ( + + + ) + + { + + + if + ( + + + ( + + + ( + + + y + + + + + size + + + ) + + < + + 254 + + + ) + + & + + ( + + + ( + + + x + + + + + size + + + ) + + < + + 510 + + + ) + + + ) + { + + + do + erase + ( + + + ) + ; + + + let + size + = + + + size + + + + + 2 + + + ; + + + do + draw + ( + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + decSize + ( + + + ) + + { + + + if + ( + + + size + + > + + 2 + + + ) + { + + + do + erase + ( + + + ) + ; + + + let + size + = + + + size + + - + + 2 + + + ; + + + do + draw + ( + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveUp + ( + + + ) + + { + + + if + ( + + + y + + > + + 1 + + + ) + { + + + do + Screen + . + setColor + ( + + + + false + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + ( + + + y + + + + + size + + + ) + + - + + 1 + + + , + + + x + + + + + size + + + , + + + y + + + + + size + + + + ) + ; + + + let + y + = + + + y + + - + + 2 + + + ; + + + do + Screen + . + setColor + ( + + + + true + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + + + size + + + , + + + y + + + + + 1 + + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveDown + ( + + + ) + + { + + + if + ( + + + ( + + + y + + + + + size + + + ) + + < + + 254 + + + ) + { + + + do + Screen + . + setColor + ( + + + + false + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + + + size + + + , + + + y + + + + + 1 + + + + ) + ; + + + let + y + = + + + y + + + + + 2 + + + ; + + + do + Screen + . + setColor + ( + + + + true + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + ( + + + y + + + + + size + + + ) + + - + + 1 + + + , + + + x + + + + + size + + + , + + + y + + + + + size + + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveLeft + ( + + + ) + + { + + + if + ( + + + x + + > + + 1 + + + ) + { + + + do + Screen + . + setColor + ( + + + + false + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + ( + + + x + + + + + size + + + ) + + - + + 1 + + + , + + + y + + + , + + + x + + + + + size + + + , + + + y + + + + + size + + + + ) + ; + + + let + x + = + + + x + + - + + 2 + + + ; + + + do + Screen + . + setColor + ( + + + + true + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + + + 1 + + + , + + + y + + + + + size + + + + ) + ; + + + } + + + return + ; + + + } + + + + method + void + moveRight + ( + + + ) + + { + + + if + ( + + + ( + + + x + + + + + size + + + ) + + < + + 510 + + + ) + { + + + do + Screen + . + setColor + ( + + + + false + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + x + + + , + + + y + + + , + + + x + + + + + 1 + + + , + + + y + + + + + size + + + + ) + ; + + + let + x + = + + + x + + + + + 2 + + + ; + + + do + Screen + . + setColor + ( + + + + true + + + + ) + ; + + + do + Screen + . + drawRectangle + ( + + + + ( + + + x + + + + + size + + + ) + + - + + 1 + + + , + + + y + + + , + + + x + + + + + size + + + , + + + y + + + + + size + + + + ) + ; + + + } + + + return + ; + + + } + + + } + diff --git a/projects/10/Square/SquareGame.jack b/projects/10/Square/SquareGame.jack new file mode 100755 index 0000000..4f71b16 --- /dev/null +++ b/projects/10/Square/SquareGame.jack @@ -0,0 +1,81 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/10/Square/SquareGame.jack + +// (same as projects/09/Square/SquareGame.jack) + +/** + * Implements the Square Dance game. + * This simple game allows the user to move a black square around + * the screen, and change the square's size during the movement. + * When the game starts, a square of 30 by 30 pixels is shown at the + * top-left corner of the screen. The user controls the square as follows. + * The 4 arrow keys are used to move the square up, down, left, and right. + * The 'z' and 'x' keys are used, respectively, to decrement and increment + * the square's size. The 'q' key is used to quit the game. + */ + +class SquareGame { + field Square square; // the square of this game + field int direction; // the square's current direction: + // 0=none, 1=up, 2=down, 3=left, 4=right + + /** Constructs a new Square Game. */ + constructor SquareGame new() { + // Creates a 30 by 30 pixels square and positions it at the top-left + // of the screen. + let square = Square.new(0, 0, 30); + let direction = 0; // initial state is no movement + return this; + } + + /** Disposes this game. */ + method void dispose() { + do square.dispose(); + do Memory.deAlloc(this); + return; + } + + /** Moves the square in the current direction. */ + method void moveSquare() { + if (direction = 1) { do square.moveUp(); } + if (direction = 2) { do square.moveDown(); } + if (direction = 3) { do square.moveLeft(); } + if (direction = 4) { do square.moveRight(); } + do Sys.wait(5); // delays the next movement + return; + } + + /** Runs the game: handles the user's inputs and moves the square accordingly */ + method void run() { + var char key; // the key currently pressed by the user + var boolean exit; + let exit = false; + + while (~exit) { + // waits for a key to be pressed + while (key = 0) { + let key = Keyboard.keyPressed(); + do moveSquare(); + } + if (key = 81) { let exit = true; } // q key + if (key = 90) { do square.decSize(); } // z key + if (key = 88) { do square.incSize(); } // x key + if (key = 131) { let direction = 1; } // up arrow + if (key = 133) { let direction = 2; } // down arrow + if (key = 130) { let direction = 3; } // left arrow + if (key = 132) { let direction = 4; } // right arrow + + // waits for the key to be released + while (~(key = 0)) { + let key = Keyboard.keyPressed(); + do moveSquare(); + } + } // while + return; + } +} + + + diff --git a/projects/10/Square/SquareGame.xml b/projects/10/Square/SquareGame.xml new file mode 100755 index 0000000..ed3ab6e --- /dev/null +++ b/projects/10/Square/SquareGame.xml @@ -0,0 +1,643 @@ + + class + SquareGame + { + + field + Square + square + ; + + + field + int + direction + ; + + + constructor + SquareGame + new + ( + + + ) + + { + + + let + square + = + + + Square + . + new + ( + + + + 0 + + + , + + + 0 + + + , + + + 30 + + + + ) + + + ; + + + let + direction + = + + + 0 + + + ; + + + return + + + this + + + ; + + + } + + + + method + void + dispose + ( + + + ) + + { + + + do + square + . + dispose + ( + + + ) + ; + + + do + Memory + . + deAlloc + ( + + + + this + + + + ) + ; + + + return + ; + + + } + + + + method + void + moveSquare + ( + + + ) + + { + + + if + ( + + + direction + + = + + 1 + + + ) + { + + + do + square + . + moveUp + ( + + + ) + ; + + + } + + + if + ( + + + direction + + = + + 2 + + + ) + { + + + do + square + . + moveDown + ( + + + ) + ; + + + } + + + if + ( + + + direction + + = + + 3 + + + ) + { + + + do + square + . + moveLeft + ( + + + ) + ; + + + } + + + if + ( + + + direction + + = + + 4 + + + ) + { + + + do + square + . + moveRight + ( + + + ) + ; + + + } + + + do + Sys + . + wait + ( + + + + 5 + + + + ) + ; + + + return + ; + + + } + + + + method + void + run + ( + + + ) + + { + + var + char + key + ; + + + var + boolean + exit + ; + + + + let + exit + = + + + false + + + ; + + + while + ( + + + ~ + + exit + + + + ) + { + + + while + ( + + + key + + = + + 0 + + + ) + { + + + let + key + = + + + Keyboard + . + keyPressed + ( + + + ) + + + ; + + + do + moveSquare + ( + + + ) + ; + + + } + + + if + ( + + + key + + = + + 81 + + + ) + { + + + let + exit + = + + + true + + + ; + + + } + + + if + ( + + + key + + = + + 90 + + + ) + { + + + do + square + . + decSize + ( + + + ) + ; + + + } + + + if + ( + + + key + + = + + 88 + + + ) + { + + + do + square + . + incSize + ( + + + ) + ; + + + } + + + if + ( + + + key + + = + + 131 + + + ) + { + + + let + direction + = + + + 1 + + + ; + + + } + + + if + ( + + + key + + = + + 133 + + + ) + { + + + let + direction + = + + + 2 + + + ; + + + } + + + if + ( + + + key + + = + + 130 + + + ) + { + + + let + direction + = + + + 3 + + + ; + + + } + + + if + ( + + + key + + = + + 132 + + + ) + { + + + let + direction + = + + + 4 + + + ; + + + } + + + while + ( + + + ~ + + ( + + + key + + = + + 0 + + + ) + + + + ) + { + + + let + key + = + + + Keyboard + . + keyPressed + ( + + + ) + + + ; + + + do + moveSquare + ( + + + ) + ; + + + } + + + } + + + return + ; + + + } + + + } + diff --git a/projects/10/Square/SquareGameT.xml b/projects/10/Square/SquareGameT.xml new file mode 100755 index 0000000..3136af2 --- /dev/null +++ b/projects/10/Square/SquareGameT.xml @@ -0,0 +1,315 @@ + + class + SquareGame + { + field + Square + square + ; + field + int + direction + ; + constructor + SquareGame + new + ( + ) + { + let + square + = + Square + . + new + ( + 0 + , + 0 + , + 30 + ) + ; + let + direction + = + 0 + ; + return + this + ; + } + method + void + dispose + ( + ) + { + do + square + . + dispose + ( + ) + ; + do + Memory + . + deAlloc + ( + this + ) + ; + return + ; + } + method + void + moveSquare + ( + ) + { + if + ( + direction + = + 1 + ) + { + do + square + . + moveUp + ( + ) + ; + } + if + ( + direction + = + 2 + ) + { + do + square + . + moveDown + ( + ) + ; + } + if + ( + direction + = + 3 + ) + { + do + square + . + moveLeft + ( + ) + ; + } + if + ( + direction + = + 4 + ) + { + do + square + . + moveRight + ( + ) + ; + } + do + Sys + . + wait + ( + 5 + ) + ; + return + ; + } + method + void + run + ( + ) + { + var + char + key + ; + var + boolean + exit + ; + let + exit + = + false + ; + while + ( + ~ + exit + ) + { + while + ( + key + = + 0 + ) + { + let + key + = + Keyboard + . + keyPressed + ( + ) + ; + do + moveSquare + ( + ) + ; + } + if + ( + key + = + 81 + ) + { + let + exit + = + true + ; + } + if + ( + key + = + 90 + ) + { + do + square + . + decSize + ( + ) + ; + } + if + ( + key + = + 88 + ) + { + do + square + . + incSize + ( + ) + ; + } + if + ( + key + = + 131 + ) + { + let + direction + = + 1 + ; + } + if + ( + key + = + 133 + ) + { + let + direction + = + 2 + ; + } + if + ( + key + = + 130 + ) + { + let + direction + = + 3 + ; + } + if + ( + key + = + 132 + ) + { + let + direction + = + 4 + ; + } + while + ( + ~ + ( + key + = + 0 + ) + ) + { + let + key + = + Keyboard + . + keyPressed + ( + ) + ; + do + moveSquare + ( + ) + ; + } + } + return + ; + } + } + diff --git a/projects/10/Square/SquareT.xml b/projects/10/Square/SquareT.xml new file mode 100755 index 0000000..69a8ca0 --- /dev/null +++ b/projects/10/Square/SquareT.xml @@ -0,0 +1,561 @@ + + class + Square + { + field + int + x + , + y + ; + field + int + size + ; + constructor + Square + new + ( + int + Ax + , + int + Ay + , + int + Asize + ) + { + let + x + = + Ax + ; + let + y + = + Ay + ; + let + size + = + Asize + ; + do + draw + ( + ) + ; + return + this + ; + } + method + void + dispose + ( + ) + { + do + Memory + . + deAlloc + ( + this + ) + ; + return + ; + } + method + void + draw + ( + ) + { + do + Screen + . + setColor + ( + true + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + + + size + , + y + + + size + ) + ; + return + ; + } + method + void + erase + ( + ) + { + do + Screen + . + setColor + ( + false + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + + + size + , + y + + + size + ) + ; + return + ; + } + method + void + incSize + ( + ) + { + if + ( + ( + ( + y + + + size + ) + < + 254 + ) + & + ( + ( + x + + + size + ) + < + 510 + ) + ) + { + do + erase + ( + ) + ; + let + size + = + size + + + 2 + ; + do + draw + ( + ) + ; + } + return + ; + } + method + void + decSize + ( + ) + { + if + ( + size + > + 2 + ) + { + do + erase + ( + ) + ; + let + size + = + size + - + 2 + ; + do + draw + ( + ) + ; + } + return + ; + } + method + void + moveUp + ( + ) + { + if + ( + y + > + 1 + ) + { + do + Screen + . + setColor + ( + false + ) + ; + do + Screen + . + drawRectangle + ( + x + , + ( + y + + + size + ) + - + 1 + , + x + + + size + , + y + + + size + ) + ; + let + y + = + y + - + 2 + ; + do + Screen + . + setColor + ( + true + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + + + size + , + y + + + 1 + ) + ; + } + return + ; + } + method + void + moveDown + ( + ) + { + if + ( + ( + y + + + size + ) + < + 254 + ) + { + do + Screen + . + setColor + ( + false + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + + + size + , + y + + + 1 + ) + ; + let + y + = + y + + + 2 + ; + do + Screen + . + setColor + ( + true + ) + ; + do + Screen + . + drawRectangle + ( + x + , + ( + y + + + size + ) + - + 1 + , + x + + + size + , + y + + + size + ) + ; + } + return + ; + } + method + void + moveLeft + ( + ) + { + if + ( + x + > + 1 + ) + { + do + Screen + . + setColor + ( + false + ) + ; + do + Screen + . + drawRectangle + ( + ( + x + + + size + ) + - + 1 + , + y + , + x + + + size + , + y + + + size + ) + ; + let + x + = + x + - + 2 + ; + do + Screen + . + setColor + ( + true + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + + + 1 + , + y + + + size + ) + ; + } + return + ; + } + method + void + moveRight + ( + ) + { + if + ( + ( + x + + + size + ) + < + 510 + ) + { + do + Screen + . + setColor + ( + false + ) + ; + do + Screen + . + drawRectangle + ( + x + , + y + , + x + + + 1 + , + y + + + size + ) + ; + let + x + = + x + + + 2 + ; + do + Screen + . + setColor + ( + true + ) + ; + do + Screen + . + drawRectangle + ( + ( + x + + + size + ) + - + 1 + , + y + , + x + + + size + , + y + + + size + ) + ; + } + return + ; + } + } + diff --git a/projects/10/lang.txt b/projects/10/lang.txt new file mode 100755 index 0000000..d27c8d9 --- /dev/null +++ b/projects/10/lang.txt @@ -0,0 +1,2 @@ +python3 +debug diff --git a/projects/11/Average/Main.jack b/projects/11/Average/Main.jack new file mode 100755 index 0000000..d560bf1 --- /dev/null +++ b/projects/11/Average/Main.jack @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Average/Main.jack + +// (Same as projects/09/Average/Main.jack) + +// Inputs some numbers and computes their average +class Main { + function void main() { + var Array a; + var int length; + var int i, sum; + + let length = Keyboard.readInt("How many numbers? "); + let a = Array.new(length); // constructs the array + + let i = 0; + while (i < length) { + let a[i] = Keyboard.readInt("Enter a number: "); + let sum = sum + a[i]; + let i = i + 1; + } + + do Output.printString("The average is "); + do Output.printInt(sum / length); + return; + } +} diff --git a/projects/11/Average/Main.vm b/projects/11/Average/Main.vm new file mode 100755 index 0000000..89dd1a8 --- /dev/null +++ b/projects/11/Average/Main.vm @@ -0,0 +1,149 @@ +function Main.main 4 +push constant 18 +call String.new 1 +push constant 72 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 63 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Keyboard.readInt 1 +pop local 1 +push local 1 +call Array.new 1 +pop local 0 +push constant 0 +pop local 2 +label L0 +push local 2 +push local 1 +lt +not +if-goto L1 +push local 0 +push local 2 +push constant 16 +call String.new 1 +push constant 69 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Keyboard.readInt 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push local 0 +push local 2 +add +pop pointer 1 +push that 0 +add +pop local 3 +push local 2 +push constant 1 +add +pop local 2 +goto L0 +label L1 +push constant 15 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 118 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 3 +push local 1 +call Math.divide 2 +call Output.printInt 1 +pop temp 0 +push constant 0 +return diff --git a/projects/11/ComplexArrays/Main.jack b/projects/11/ComplexArrays/Main.jack new file mode 100755 index 0000000..fe51c20 --- /dev/null +++ b/projects/11/ComplexArrays/Main.jack @@ -0,0 +1,70 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/ComplexArrays/Main.jack + +/** + * Performs several complex array processing tests. + * For each test, the expected result is printed, along with the + * actual result. In each test, the two results should be equal. + */ +class Main { + + function void main() { + var Array a, b, c; + + let a = Array.new(10); + let b = Array.new(5); + let c = Array.new(1); + + let a[3] = 2; + let a[4] = 8; + let a[5] = 4; + let b[a[3]] = a[3] + 3; // b[2] = 5 + let a[b[a[3]]] = a[a[5]] * b[((7 - a[3]) - Main.double(2)) + 1]; // a[5] = 8 * 5 = 40 + let c[0] = null; + let c = c[0]; + + do Output.printString("Test 1: expected result: 5; actual result: "); + do Output.printInt(b[2]); + do Output.println(); + do Output.printString("Test 2: expected result: 40; actual result: "); + do Output.printInt(a[5]); + do Output.println(); + do Output.printString("Test 3: expected result: 0; actual result: "); + do Output.printInt(c); + do Output.println(); + + let c = null; + + if (c = null) { + do Main.fill(a, 10); + let c = a[3]; + let c[1] = 33; + let c = a[7]; + let c[1] = 77; + let b = a[3]; + let b[1] = b[1] + c[1]; // b[1] = 33 + 77 = 110; + } + + do Output.printString("Test 4: expected result: 77; actual result: "); + do Output.printInt(c[1]); + do Output.println(); + do Output.printString("Test 5: expected result: 110; actual result: "); + do Output.printInt(b[1]); + do Output.println(); + return; + } + + function int double(int a) { + return a * 2; + } + + function void fill(Array a, int size) { + while (size > 0) { + let size = size - 1; + let a[size] = Array.new(3); + } + return; + } +} diff --git a/projects/11/ComplexArrays/Main.vm b/projects/11/ComplexArrays/Main.vm new file mode 100755 index 0000000..574f01f --- /dev/null +++ b/projects/11/ComplexArrays/Main.vm @@ -0,0 +1,703 @@ +function Main.main 3 +push constant 10 +call Array.new 1 +pop local 0 +push constant 5 +call Array.new 1 +pop local 1 +push constant 1 +call Array.new 1 +pop local 2 +push local 0 +push constant 3 +push constant 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 4 +push constant 8 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 5 +push constant 4 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +push local 0 +push constant 3 +add +pop pointer 1 +push that 0 +push local 0 +push constant 3 +add +pop pointer 1 +push that 0 +push constant 3 +add +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push local 1 +push local 0 +push constant 3 +add +pop pointer 1 +push that 0 +add +pop pointer 1 +push that 0 +push local 0 +push local 0 +push constant 5 +add +pop pointer 1 +push that 0 +add +pop pointer 1 +push that 0 +push local 1 +push constant 7 +push local 0 +push constant 3 +add +pop pointer 1 +push that 0 +sub +push constant 2 +call Main.double 1 +sub +push constant 1 +add +add +pop pointer 1 +push that 0 +call Math.multiply 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +push constant 0 +push constant 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +push constant 0 +add +pop pointer 1 +push that 0 +pop local 2 +push constant 43 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 120 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 53 +call String.appendChar 2 +push constant 59 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 1 +push constant 2 +add +pop pointer 1 +push that 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 44 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 120 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 52 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 59 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +push constant 5 +add +pop pointer 1 +push that 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 43 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 120 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 59 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 2 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 0 +pop local 2 +push local 2 +push constant 0 +eq +not +if-goto L0 +push local 0 +push constant 10 +call Main.fill 2 +pop temp 0 +push local 0 +push constant 3 +add +pop pointer 1 +push that 0 +pop local 2 +push local 2 +push constant 1 +push constant 33 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 7 +add +pop pointer 1 +push that 0 +pop local 2 +push local 2 +push constant 1 +push constant 77 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 3 +add +pop pointer 1 +push that 0 +pop local 1 +push local 1 +push constant 1 +push local 1 +push constant 1 +add +pop pointer 1 +push that 0 +push local 2 +push constant 1 +add +pop pointer 1 +push that 0 +add +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L1 +label L0 +label L1 +push constant 44 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 52 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 120 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 55 +call String.appendChar 2 +push constant 55 +call String.appendChar 2 +push constant 59 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 2 +push constant 1 +add +pop pointer 1 +push that 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 45 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 53 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 120 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +push constant 59 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 1 +push constant 1 +add +pop pointer 1 +push that 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 0 +return +function Main.double 0 +push argument 0 +push constant 2 +call Math.multiply 2 +return +function Main.fill 0 +label L2 +push argument 1 +push constant 0 +gt +not +if-goto L3 +push argument 1 +push constant 1 +sub +pop argument 1 +push argument 0 +push argument 1 +push constant 3 +call Array.new 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L2 +label L3 +push constant 0 +return diff --git a/projects/11/ConvertToBin/Main.jack b/projects/11/ConvertToBin/Main.jack new file mode 100755 index 0000000..e627486 --- /dev/null +++ b/projects/11/ConvertToBin/Main.jack @@ -0,0 +1,82 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/ConvertToBin/Main.jack + +/** + * Unpacks a 16-bit number into its binary representation: + * Takes the 16-bit number stored in RAM[8000] and stores its individual + * bits in RAM[8001..8016] (each location will contain 0 or 1). + * Before the conversion, RAM[8001]..RAM[8016] are initialized to -1. + * + * The program should be tested as follows: + * 1) Load the program into the supplied VM emulator + * 2) Put some value in RAM[8000] + * 3) Switch to "no animation" + * 4) Run the program (give it enough time to run) + * 5) Stop the program + * 6) Check that RAM[8001]..RAM[8016] contains the correct binary result, and + * that none of these memory locations contains -1. + */ +class Main { + + /** + * Initializes RAM[8001]..RAM[8016] to -1, + * and converts the value in RAM[8000] to binary. + */ + function void main() { + var int value; + do Main.fillMemory(8001, 16, -1); // sets RAM[8001]..RAM[8016] to -1 + let value = Memory.peek(8000); // reads a value from RAM[8000] + do Main.convert(value); // performs the conversion + return; + } + + /** Converts the given decimal value to binary, and puts + * the resulting bits in RAM[8001]..RAM[8016]. */ + function void convert(int value) { + var int mask, position; + var boolean loop; + + let loop = true; + while (loop) { + let position = position + 1; + let mask = Main.nextMask(mask); + + if (~(position > 16)) { + + if (~((value & mask) = 0)) { + do Memory.poke(8000 + position, 1); + } + else { + do Memory.poke(8000 + position, 0); + } + } + else { + let loop = false; + } + } + return; + } + + /** Returns the next mask (the mask that should follow the given mask). */ + function int nextMask(int mask) { + if (mask = 0) { + return 1; + } + else { + return mask * 2; + } + } + + /** Fills 'length' consecutive memory locations with 'value', + * starting at 'startAddress'. */ + function void fillMemory(int startAddress, int length, int value) { + while (length > 0) { + do Memory.poke(startAddress, value); + let length = length - 1; + let startAddress = startAddress + 1; + } + return; + } +} diff --git a/projects/11/ConvertToBin/Main.vm b/projects/11/ConvertToBin/Main.vm new file mode 100755 index 0000000..71dd03c --- /dev/null +++ b/projects/11/ConvertToBin/Main.vm @@ -0,0 +1,106 @@ +function Main.main 1 +push constant 8001 +push constant 16 +push constant 1 +neg +call Main.fillMemory 3 +pop temp 0 +push constant 8000 +call Memory.peek 1 +pop local 0 +push local 0 +call Main.convert 1 +pop temp 0 +push constant 0 +return +function Main.convert 3 +push constant 1 +neg +pop local 2 +label L0 +push local 2 +not +if-goto L1 +push local 1 +push constant 1 +add +pop local 1 +push local 0 +call Main.nextMask 1 +pop local 0 +push local 1 +push constant 16 +gt +not +not +if-goto L2 +push argument 0 +push local 0 +and +push constant 0 +eq +not +not +if-goto L3 +push constant 8000 +push local 1 +add +push constant 1 +call Memory.poke 2 +pop temp 0 +goto L4 +label L3 +push constant 8000 +push local 1 +add +push constant 0 +call Memory.poke 2 +pop temp 0 +label L4 +goto L5 +label L2 +push constant 0 +pop local 2 +label L5 +goto L0 +label L1 +push constant 0 +return +function Main.nextMask 0 +push argument 0 +push constant 0 +eq +not +if-goto L6 +push constant 1 +return +goto L7 +label L6 +push argument 0 +push constant 2 +call Math.multiply 2 +return +label L7 +function Main.fillMemory 0 +label L8 +push argument 1 +push constant 0 +gt +not +if-goto L9 +push argument 0 +push argument 2 +call Memory.poke 2 +pop temp 0 +push argument 1 +push constant 1 +sub +pop argument 1 +push argument 0 +push constant 1 +add +pop argument 0 +goto L8 +label L9 +push constant 0 +return diff --git a/projects/11/JackCompiler.py b/projects/11/JackCompiler.py new file mode 100755 index 0000000..5782f99 --- /dev/null +++ b/projects/11/JackCompiler.py @@ -0,0 +1,350 @@ +import os +from pathlib import Path +from tokenizer import Tokenizer +from vmwriter import VMWriter +from symbol_table import SymbolTable + + +# TODO add names to variables when you call for them, aka current_vm_append(thingtobeappended=blablac) + +class CompilationEngine: + def __init__(self, tokenizer, full_path_vm): + self.string = self.sub_type = self.class_name = self.function_type = '' + self.tab = self.recursion_index = 0 + self.tokenizer = tokenizer + self.sym_table = [] + self.vmwriter = VMWriter(full_path_vm) + self.current_vm = [] # used to reverse some of the commands, eg a+b need to be a b + + + def search_kind_of_sym(self, current_vm): + if self.sym_table[-1].kind_of(current_vm) is not None: + return self.sym_table[-1].kind_of(current_vm), self.sym_table[-1].index_of(current_vm) + for i in range(len(self.sym_table) - 2, -1, + -1): # start from the amount of sym_tables -2 so it starts from one below the current, + # until it is bigger than -1, walking it backwards + if self.sym_table[i].kind_of(current_vm) in ('static', 'this'): + return self.sym_table[i].kind_of(current_vm), self.sym_table[i].index_of(current_vm) + + def search_type_of_sym(self, current_vm): + for i in range(len(self.sym_table) - 1, -1, -1): + if self.sym_table[i].type_of(current_vm) is not None: + return self.sym_table[i].type_of(current_vm) + + def write_token(self): + if self.tokenizer.token_type() == 'stringConstant': + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token.strip( + '"') + ' \n' + else: + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token + ' \n' + + def compile_class(self): + self.sym_table.append(SymbolTable()) + self.tokenizer.advance() # class -> + self.tokenizer.advance() # type -> + self.class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + self.tokenizer.advance() # { -> + while self.tokenizer.token != '}': + if self.tokenizer.token in ['static', 'field']: + self.compile_class_var_dec() + if self.tokenizer.token in ['constructor', 'function', 'method']: + self.compile_subroutine() + self.tokenizer.advance() + self.sym_table.pop() + self.vmwriter.close_vm_file() + + def compile_class_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_subroutine(self): + self.sym_table.append(SymbolTable()) + self.sub_type = self.tokenizer.token + self.tokenizer.advance() # subroutine type(function|method|constructor) -> + self.function_type = self.tokenizer.token + self.tokenizer.advance() # subroutine kind(int|void|etc..) -> + sub_name = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + if self.sub_type == 'method': + self.sym_table[-1].start_subroutine('this', self.class_name) + self.compile_parameter_list() + self.tokenizer.advance() # { -> + while self.tokenizer.token == 'var': # create only symbol teable entries + self.compile_var_dec() + if self.sub_type == 'constructor': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('constant', self.sym_table[-2].var_count('field')) + self.vmwriter.write_call('Memory.alloc', 1) + self.vmwriter.write_pop('pointer', 0) + elif self.sub_type == 'method': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('argument', 0) + self.vmwriter.write_pop('pointer', 0) + else: + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + while self.tokenizer.token != '}': + self.compile_statements() + self.tokenizer.advance() + self.sym_table.pop() + + def compile_parameter_list(self): + if self.tokenizer.token != ')': + var_type = self.tokenizer.token + self.tokenizer.advance() # var ype -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # var name -> + while self.tokenizer.token == ',': + self.tokenizer.advance() # , -> + var_type = self.tokenizer.token + self.tokenizer.advance() # type -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # name -> + self.tokenizer.advance() # )-> + + def compile_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_statements(self): + while True: + if self.tokenizer.token == 'let': + self.compile_let() + elif self.tokenizer.token == 'if': + self.compile_if() + elif self.tokenizer.token == 'while': + self.compile_while() + elif self.tokenizer.token == 'do': + self.compile_do() + elif self.tokenizer.token == 'return': + self.compile_return() + else: + break + + def compile_do(self): + self.tokenizer.advance() # do -> + class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + if self.tokenizer.token == '(': # method + self.vmwriter.write_push('pointer', 0) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{class_name}', count + 1) + elif self.tokenizer.token == '.': # method or function + self.tokenizer.advance() # . -> + fname = f'{class_name}.{self.tokenizer.token}' + sname = f'{self.search_type_of_sym(class_name)}.{self.tokenizer.token}' + self.tokenizer.advance() # name -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_push(*self.search_kind_of_sym(class_name)) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_call(f'{sname}', count + 1) + else: + self.vmwriter.write_call(f'{fname}', count) + self.vmwriter.write_pop('temp', '0') + self.tokenizer.advance() # ; -> + + def compile_let(self): + flag_array = 0 + self.tokenizer.advance() # let -> + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # var_name -> + if self.tokenizer.token == '[': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.tokenizer.advance() # [ -> + self.compile_expression() + self.tokenizer.advance() # ] -> + flag_array = 1 + self.tokenizer.advance() # = -> + self.compile_expression() + self.tokenizer.advance() # ; -> + if flag_array == 0: + self.vmwriter.write_pop(*self.search_kind_of_sym(self.current_vm[-1])) + else: + self.vmwriter.write_pop('temp', 1) + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('temp', 1) + self.vmwriter.write_pop('that', 0) + self.current_vm.pop() + + def compile_while(self): + self.tokenizer.advance() # while -> + label1 = self.vmwriter.label_index + self.vmwriter.write_lable(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label2 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_goto(label1) + self.vmwriter.write_lable(label2) + + def compile_return(self): + self.tokenizer.advance() # return -> + if self.tokenizer.token != ';': + self.compile_expression() + self.vmwriter.write_return(self.function_type) + self.tokenizer.advance() # ; -> + + def compile_if(self): + self.tokenizer.advance() # if -> + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label1 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + label2 = self.vmwriter.label_index + self.vmwriter.write_goto(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.vmwriter.write_lable(label1) + if self.tokenizer.token == 'else': + self.tokenizer.advance() # else -> + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_lable(label2) + + def compile_expression(self): + self.compile_term() + while self.tokenizer.token in ['+', '-', '*', '/', '|', '=', '>', '<', '&']: + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # symbol -> + self.compile_term() + self.vmwriter.write_arithmetic(self.current_vm[-1]) + self.current_vm.pop() + + def compile_term(self): + if self.tokenizer.token == '(': # expression () + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + elif self.tokenizer.token in ['~', '-']: # uniry op + self.current_vm.append(self.tokenizer.token) + tmp = 'neg' if self.tokenizer.token == '-' else self.tokenizer.token + self.tokenizer.advance() # ~ or - -> + self.compile_term() + self.vmwriter.write_arithmetic(tmp) + self.current_vm.pop() + elif self.tokenizer.token_type() != 'symbol': + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # integer, string, keyword, varnname, subroutine_name, class_name, var_name -> + if self.tokenizer.token == '[': # Array + self.tokenizer.advance() # [ -> + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + self.compile_expression() + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('that', 0) + self.tokenizer.advance() # ] -> + elif self.tokenizer.token == '(': # subroutine_name () + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{self.current_vm[-1]}', count) + self.current_vm.pop() + elif self.tokenizer.token == '.': # method + if self.search_type_of_sym(self.current_vm[-1]) is not None: + flag = 1 + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + else: + flag = 0 + self.tokenizer.advance() # . -> + fname = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if flag == 1: + self.vmwriter.write_call(f'{self.search_type_of_sym(self.current_vm[-1])}.{fname}', count + 1) + else: + self.vmwriter.write_call(f'{self.current_vm[-1]}.{fname}', count) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'stringConstant': + self.vmwriter.write_push('constant', len(self.current_vm[-1].strip('"'))) + self.vmwriter.write_call('String.new', 1) + for index, item in enumerate(self.current_vm[-1].strip('"')): + self.vmwriter.write_push('constant', ord(item)) + self.vmwriter.write_call('String.appendChar', 2) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'integerConstant': + self.vmwriter.write_push('constant', self.current_vm[-1]) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'identifier': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + elif self.current_vm[-1] == 'true': + self.vmwriter.write_push('constant', '1') + self.vmwriter.write_arithmetic('neg') + self.current_vm.pop() + elif self.current_vm[-1] == 'false' or self.current_vm[-1] == 'null': + self.vmwriter.write_push('constant', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'this': + self.vmwriter.write_push('pointer', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'that': + self.vmwriter.write_push('pointer', '1') + self.current_vm.pop() + + def compile_expression_list(self): + count_exp = 0 + if self.tokenizer.token in ['(', '~', '-'] or self.tokenizer.token_type() != 'symbol': + count_exp += 1 + self.compile_expression() + while self.tokenizer.token == ',': + count_exp += 1 + self.tokenizer.advance() # , + self.compile_expression() + return count_exp + + +if __name__ == '__main__': + path = os.getcwd() + for root, dirs, files in os.walk(path, topdown=False): + for name in files: + if name[-4:] == 'jack': + tokenizer_main = Tokenizer() + tokenizer_main.clear_file(Path(root, name)) + full_path = Path(root, name[:-4] + 'vm') + comp_eng_main = CompilationEngine(tokenizer_main, full_path) + comp_eng_main.compile_class() diff --git a/projects/11/Pong/Ball.jack b/projects/11/Pong/Ball.jack new file mode 100755 index 0000000..02e47f9 --- /dev/null +++ b/projects/11/Pong/Ball.jack @@ -0,0 +1,203 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Pong/Ball.jack + +/** + * A graphical ball. Characterized by a screen location and distance of + * last destination. Has methods for drawing, erasing and moving on the screen. + * The ball is displayed as a filled, 6-by-6 pixles rectangle. + */ +class Ball { + + field int x, y; // the ball's screen location (in pixels) + field int lengthx, lengthy; // distance of last destination (in pixels) + + field int d, straightD, diagonalD; // used for straight line movement computation + field boolean invert, positivex, positivey; // (same) + + field int leftWall, rightWall, topWall, bottomWall; // wall locations + + field int wall; // last wall that the ball was bounced off of + + /** Constructs a new ball with the given initial location and wall locations. */ + constructor Ball new(int Ax, int Ay, + int AleftWall, int ArightWall, int AtopWall, int AbottomWall) { + let x = Ax; + let y = Ay; + let leftWall = AleftWall; + let rightWall = ArightWall - 6; // -6 for ball size + let topWall = AtopWall; + let bottomWall = AbottomWall - 6; // -6 for ball size + let wall = 0; + do show(); + return this; + } + + /** Deallocates the Ball's memory. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** Shows the ball. */ + method void show() { + do Screen.setColor(true); + do draw(); + return; + } + + /** Hides the ball. */ + method void hide() { + do Screen.setColor(false); + do draw(); + return; + } + + /** Draws the ball. */ + method void draw() { + do Screen.drawRectangle(x, y, x + 5, y + 5); + return; + } + + /** Returns the ball's left edge. */ + method int getLeft() { + return x; + } + + /** Returns the ball's right edge. */ + method int getRight() { + return x + 5; + } + + /** Computes and sets the ball's destination. */ + method void setDestination(int destx, int desty) { + var int dx, dy, temp; + let lengthx = destx - x; + let lengthy = desty - y; + let dx = Math.abs(lengthx); + let dy = Math.abs(lengthy); + let invert = (dx < dy); + + if (invert) { + let temp = dx; // swap dx, dy + let dx = dy; + let dy = temp; + let positivex = (y < desty); + let positivey = (x < destx); + } + else { + let positivex = (x < destx); + let positivey = (y < desty); + } + + let d = (2 * dy) - dx; + let straightD = 2 * dy; + let diagonalD = 2 * (dy - dx); + + return; + } + + /** + * Moves the ball one unit towards its destination. + * If the ball has reached a wall, returns 0. + * Else, returns a value according to the wall: + * 1 (left wall), 2 (right wall), 3 (top wall), 4 (bottom wall). + */ + method int move() { + + do hide(); + + if (d < 0) { let d = d + straightD; } + else { + let d = d + diagonalD; + + if (positivey) { + if (invert) { let x = x + 4; } + else { let y = y + 4; } + } + else { + if (invert) { let x = x - 4; } + else { let y = y - 4; } + } + } + + if (positivex) { + if (invert) { let y = y + 4; } + else { let x = x + 4; } + } + else { + if (invert) { let y = y - 4; } + else { let x = x - 4; } + } + + if (~(x > leftWall)) { + let wall = 1; + let x = leftWall; + } + if (~(x < rightWall)) { + let wall = 2; + let x = rightWall; + } + if (~(y > topWall)) { + let wall = 3; + let y = topWall; + } + if (~(y < bottomWall)) { + let wall = 4; + let y = bottomWall; + } + + do show(); + + return wall; + } + + /** + * Bounces off the current wall: sets the new destination + * of the ball according to the ball's angle and the given + * bouncing direction (-1/0/1=left/center/right or up/center/down). + */ + method void bounce(int bouncingDirection) { + var int newx, newy, divLengthx, divLengthy, factor; + + // dividing by 10 first since results are too big + let divLengthx = lengthx / 10; + let divLengthy = lengthy / 10; + if (bouncingDirection = 0) { let factor = 10; } + else { + if (((~(lengthx < 0)) & (bouncingDirection = 1)) | ((lengthx < 0) & (bouncingDirection = (-1)))) { + let factor = 20; // bounce direction is in ball direction + } + else { let factor = 5; } // bounce direction is against ball direction + } + + if (wall = 1) { + let newx = 506; + let newy = (divLengthy * (-50)) / divLengthx; + let newy = y + (newy * factor); + } + else { + if (wall = 2) { + let newx = 0; + let newy = (divLengthy * 50) / divLengthx; + let newy = y + (newy * factor); + } + else { + if (wall = 3) { + let newy = 250; + let newx = (divLengthx * (-25)) / divLengthy; + let newx = x + (newx * factor); + } + else { // assumes wall = 4 + let newy = 0; + let newx = (divLengthx * 25) / divLengthy; + let newx = x + (newx * factor); + } + } + } + + do setDestination(newx, newy); + return; + } +} diff --git a/projects/11/Pong/Ball.vm b/projects/11/Pong/Ball.vm new file mode 100755 index 0000000..04f0872 --- /dev/null +++ b/projects/11/Pong/Ball.vm @@ -0,0 +1,435 @@ +function Ball.new 0 +push constant 15 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +pop this 0 +push argument 1 +pop this 1 +push argument 2 +pop this 10 +push argument 3 +push constant 6 +sub +pop this 11 +push argument 4 +pop this 12 +push argument 5 +push constant 6 +sub +pop this 13 +push constant 0 +pop this 14 +push pointer 0 +call Ball.show 1 +pop temp 0 +push pointer 0 +return +function Ball.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function Ball.show 0 +push argument 0 +pop pointer 0 +push constant 1 +neg +call Screen.setColor 1 +pop temp 0 +push pointer 0 +call Ball.draw 1 +pop temp 0 +push constant 0 +return +function Ball.hide 0 +push argument 0 +pop pointer 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push pointer 0 +call Ball.draw 1 +pop temp 0 +push constant 0 +return +function Ball.draw 0 +push argument 0 +pop pointer 0 +push this 0 +push this 1 +push this 0 +push constant 5 +add +push this 1 +push constant 5 +add +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Ball.getLeft 0 +push argument 0 +pop pointer 0 +push this 0 +return +function Ball.getRight 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 5 +add +return +function Ball.setDestination 3 +push argument 0 +pop pointer 0 +push argument 1 +push this 0 +sub +pop this 2 +push argument 2 +push this 1 +sub +pop this 3 +push this 2 +call Math.abs 1 +pop local 0 +push this 3 +call Math.abs 1 +pop local 1 +push local 0 +push local 1 +lt +pop this 7 +push this 7 +not +if-goto L0 +push local 0 +pop local 2 +push local 1 +pop local 0 +push local 2 +pop local 1 +push this 1 +push argument 2 +lt +pop this 8 +push this 0 +push argument 1 +lt +pop this 9 +goto L1 +label L0 +push this 0 +push argument 1 +lt +pop this 8 +push this 1 +push argument 2 +lt +pop this 9 +label L1 +push constant 2 +push local 1 +call Math.multiply 2 +push local 0 +sub +pop this 4 +push constant 2 +push local 1 +call Math.multiply 2 +pop this 5 +push constant 2 +push local 1 +push local 0 +sub +call Math.multiply 2 +pop this 6 +push constant 0 +return +function Ball.move 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Ball.hide 1 +pop temp 0 +push this 4 +push constant 0 +lt +not +if-goto L2 +push this 4 +push this 5 +add +pop this 4 +goto L3 +label L2 +push this 4 +push this 6 +add +pop this 4 +push this 9 +not +if-goto L4 +push this 7 +not +if-goto L5 +push this 0 +push constant 4 +add +pop this 0 +goto L6 +label L5 +push this 1 +push constant 4 +add +pop this 1 +label L6 +goto L7 +label L4 +push this 7 +not +if-goto L8 +push this 0 +push constant 4 +sub +pop this 0 +goto L9 +label L8 +push this 1 +push constant 4 +sub +pop this 1 +label L9 +label L7 +label L3 +push this 8 +not +if-goto L10 +push this 7 +not +if-goto L11 +push this 1 +push constant 4 +add +pop this 1 +goto L12 +label L11 +push this 0 +push constant 4 +add +pop this 0 +label L12 +goto L13 +label L10 +push this 7 +not +if-goto L14 +push this 1 +push constant 4 +sub +pop this 1 +goto L15 +label L14 +push this 0 +push constant 4 +sub +pop this 0 +label L15 +label L13 +push this 0 +push this 10 +gt +not +not +if-goto L16 +push constant 1 +pop this 14 +push this 10 +pop this 0 +goto L17 +label L16 +label L17 +push this 0 +push this 11 +lt +not +not +if-goto L18 +push constant 2 +pop this 14 +push this 11 +pop this 0 +goto L19 +label L18 +label L19 +push this 1 +push this 12 +gt +not +not +if-goto L20 +push constant 3 +pop this 14 +push this 12 +pop this 1 +goto L21 +label L20 +label L21 +push this 1 +push this 13 +lt +not +not +if-goto L22 +push constant 4 +pop this 14 +push this 13 +pop this 1 +goto L23 +label L22 +label L23 +push pointer 0 +call Ball.show 1 +pop temp 0 +push this 14 +return +function Ball.bounce 5 +push argument 0 +pop pointer 0 +push this 2 +push constant 10 +call Math.divide 2 +pop local 2 +push this 3 +push constant 10 +call Math.divide 2 +pop local 3 +push argument 1 +push constant 0 +eq +not +if-goto L24 +push constant 10 +pop local 4 +goto L25 +label L24 +push this 2 +push constant 0 +lt +not +push argument 1 +push constant 1 +eq +and +push this 2 +push constant 0 +lt +push argument 1 +push constant 1 +neg +eq +and +or +not +if-goto L26 +push constant 20 +pop local 4 +goto L27 +label L26 +push constant 5 +pop local 4 +label L27 +label L25 +push this 14 +push constant 1 +eq +not +if-goto L28 +push constant 506 +pop local 0 +push local 3 +push constant 50 +neg +call Math.multiply 2 +push local 2 +call Math.divide 2 +pop local 1 +push this 1 +push local 1 +push local 4 +call Math.multiply 2 +add +pop local 1 +goto L29 +label L28 +push this 14 +push constant 2 +eq +not +if-goto L30 +push constant 0 +pop local 0 +push local 3 +push constant 50 +call Math.multiply 2 +push local 2 +call Math.divide 2 +pop local 1 +push this 1 +push local 1 +push local 4 +call Math.multiply 2 +add +pop local 1 +goto L31 +label L30 +push this 14 +push constant 3 +eq +not +if-goto L32 +push constant 250 +pop local 1 +push local 2 +push constant 25 +neg +call Math.multiply 2 +push local 3 +call Math.divide 2 +pop local 0 +push this 0 +push local 0 +push local 4 +call Math.multiply 2 +add +pop local 0 +goto L33 +label L32 +push constant 0 +pop local 1 +push local 2 +push constant 25 +call Math.multiply 2 +push local 3 +call Math.divide 2 +pop local 0 +push this 0 +push local 0 +push local 4 +call Math.multiply 2 +add +pop local 0 +label L33 +label L31 +label L29 +push pointer 0 +push local 0 +push local 1 +call Ball.setDestination 3 +pop temp 0 +push constant 0 +return diff --git a/projects/11/Pong/Bat.jack b/projects/11/Pong/Bat.jack new file mode 100755 index 0000000..340760f --- /dev/null +++ b/projects/11/Pong/Bat.jack @@ -0,0 +1,103 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Pong/Bat.jack + +/** + * A graphical Pong bat. + * Displayed as a filled horizontal rectangle that has + * a screen location, a width and a height. + * Has methods for drawing, erasing, moving left and right, + * and changing its width (to make the hitting action more challenging). + * This class should have been called "paddle", following the + * standard Pong terminology. But, unaware of this terminology, + * we called it "bat", and then decided to stick to it. + */ +class Bat { + + field int x, y; // the bat's screen location + field int width, height; // the bat's width and height + field int direction; // direction of the bat's movement (1 = left, 2 = right) + + /** Constructs a new bat with the given location and width. */ + constructor Bat new(int Ax, int Ay, int Awidth, int Aheight) { + let x = Ax; + let y = Ay; + let width = Awidth; + let height = Aheight; + let direction = 2; + do show(); + return this; + } + + /** Deallocates the object's memory. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** Shows the bat. */ + method void show() { + do Screen.setColor(true); + do draw(); + return; + } + + /** Hides the bat. */ + method void hide() { + do Screen.setColor(false); + do draw(); + return; + } + + /** Draws the bat. */ + method void draw() { + do Screen.drawRectangle(x, y, x + width, y + height); + return; + } + + /** Sets the bat's direction (0=stop, 1=left, 2=right). */ + method void setDirection(int Adirection) { + let direction = Adirection; + return; + } + + /** Returns the bat's left edge. */ + method int getLeft() { + return x; + } + + /** Returns the bat's right edge. */ + method int getRight() { + return x + width; + } + + /** Sets the bat's width. */ + method void setWidth(int Awidth) { + do hide(); + let width = Awidth; + do show(); + return; + } + + /** Moves the bat one step in the bat's direction. */ + method void move() { + if (direction = 1) { + let x = x - 4; + if (x < 0) { let x = 0; } + do Screen.setColor(false); + do Screen.drawRectangle((x + width) + 1, y, (x + width) + 4, y + height); + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + 3, y + height); + } + else { + let x = x + 4; + if ((x + width) > 511) { let x = 511 - width; } + do Screen.setColor(false); + do Screen.drawRectangle(x - 4, y, x - 1, y + height); + do Screen.setColor(true); + do Screen.drawRectangle((x + width) - 3, y, x + width, y + height); + } + return; + } +} diff --git a/projects/11/Pong/Bat.vm b/projects/11/Pong/Bat.vm new file mode 100755 index 0000000..bb53b61 --- /dev/null +++ b/projects/11/Pong/Bat.vm @@ -0,0 +1,208 @@ +function Bat.new 0 +push constant 5 +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 argument 3 +pop this 3 +push constant 2 +pop this 4 +push pointer 0 +call Bat.show 1 +pop temp 0 +push pointer 0 +return +function Bat.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function Bat.show 0 +push argument 0 +pop pointer 0 +push constant 1 +neg +call Screen.setColor 1 +pop temp 0 +push pointer 0 +call Bat.draw 1 +pop temp 0 +push constant 0 +return +function Bat.hide 0 +push argument 0 +pop pointer 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push pointer 0 +call Bat.draw 1 +pop temp 0 +push constant 0 +return +function Bat.draw 0 +push argument 0 +pop pointer 0 +push this 0 +push this 1 +push this 0 +push this 2 +add +push this 1 +push this 3 +add +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +return +function Bat.setDirection 0 +push argument 0 +pop pointer 0 +push argument 1 +pop this 4 +push constant 0 +return +function Bat.getLeft 0 +push argument 0 +pop pointer 0 +push this 0 +return +function Bat.getRight 0 +push argument 0 +pop pointer 0 +push this 0 +push this 2 +add +return +function Bat.setWidth 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Bat.hide 1 +pop temp 0 +push argument 1 +pop this 2 +push pointer 0 +call Bat.show 1 +pop temp 0 +push constant 0 +return +function Bat.move 0 +push argument 0 +pop pointer 0 +push this 4 +push constant 1 +eq +not +if-goto L0 +push this 0 +push constant 4 +sub +pop this 0 +push this 0 +push constant 0 +lt +not +if-goto L1 +push constant 0 +pop this 0 +goto L2 +label L1 +label L2 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 2 +add +push constant 1 +add +push this 1 +push this 0 +push this 2 +add +push constant 4 +add +push this 1 +push this 3 +add +call Screen.drawRectangle 4 +pop temp 0 +push constant 1 +neg +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 1 +push this 0 +push constant 3 +add +push this 1 +push this 3 +add +call Screen.drawRectangle 4 +pop temp 0 +goto L3 +label L0 +push this 0 +push constant 4 +add +pop this 0 +push this 0 +push this 2 +add +push constant 511 +gt +not +if-goto L4 +push constant 511 +push this 2 +sub +pop this 0 +goto L5 +label L4 +label L5 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push this 0 +push constant 4 +sub +push this 1 +push this 0 +push constant 1 +sub +push this 1 +push this 3 +add +call Screen.drawRectangle 4 +pop temp 0 +push constant 1 +neg +call Screen.setColor 1 +pop temp 0 +push this 0 +push this 2 +add +push constant 3 +sub +push this 1 +push this 0 +push this 2 +add +push this 1 +push this 3 +add +call Screen.drawRectangle 4 +pop temp 0 +label L3 +push constant 0 +return diff --git a/projects/11/Pong/Main.jack b/projects/11/Pong/Main.jack new file mode 100755 index 0000000..ac5490e --- /dev/null +++ b/projects/11/Pong/Main.jack @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Pong/Main.jack + +/** + * The main class of the Pong game. + */ +class Main { + + /** Initializes a Pong game and starts running it. */ + function void main() { + var PongGame game; + do PongGame.newInstance(); + let game = PongGame.getInstance(); + do game.run(); + do game.dispose(); + return; + } +} \ No newline at end of file diff --git a/projects/11/Pong/Main.vm b/projects/11/Pong/Main.vm new file mode 100755 index 0000000..f1d0269 --- /dev/null +++ b/projects/11/Pong/Main.vm @@ -0,0 +1,13 @@ +function Main.main 1 +call PongGame.newInstance 0 +pop temp 0 +call PongGame.getInstance 0 +pop local 0 +push local 0 +call PongGame.run 1 +pop temp 0 +push local 0 +call PongGame.dispose 1 +pop temp 0 +push constant 0 +return diff --git a/projects/11/Pong/PongGame.jack b/projects/11/Pong/PongGame.jack new file mode 100755 index 0000000..7e1ae4c --- /dev/null +++ b/projects/11/Pong/PongGame.jack @@ -0,0 +1,137 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Pong/PongGame.jack + +/** + * Represents a Pong game. + */ +class PongGame { + + static PongGame instance; // the singelton, a Pong game instance + field Bat bat; // the bat + field Ball ball; // the ball + field int wall; // the current wall that the ball is bouncing off of. + field boolean exit; // true when the game is over + field int score; // the current score. + field int lastWall; // the last wall that the ball bounced off of. + + // The current width of the bat + field int batWidth; + + /** Constructs a new Pong game. */ + constructor PongGame new() { + do Screen.clearScreen(); + let batWidth = 50; // initial bat size + let bat = Bat.new(230, 229, batWidth, 7); + let ball = Ball.new(253, 222, 0, 511, 0, 229); + do ball.setDestination(400,0); + do Screen.drawRectangle(0, 238, 511, 240); + do Output.moveCursor(22,0); + do Output.printString("Score: 0"); + + let exit = false; + let score = 0; + let wall = 0; + let lastWall = 0; + + return this; + } + + /** Deallocates the object's memory. */ + method void dispose() { + do bat.dispose(); + do ball.dispose(); + do Memory.deAlloc(this); + return; + } + + /** Creates an instance of Pong game, and stores it. */ + function void newInstance() { + let instance = PongGame.new(); + return; + } + + /** Returns the single instance of this Pong game. */ + function PongGame getInstance() { + return instance; + } + + /** Starts the game, and andles inputs from the user that control + * the bat's movement direction. */ + method void run() { + var char key; + + while (~exit) { + // waits for a key to be pressed. + while ((key = 0) & (~exit)) { + let key = Keyboard.keyPressed(); + do bat.move(); + do moveBall(); + do Sys.wait(50); + } + + if (key = 130) { do bat.setDirection(1); } + else { + if (key = 132) { do bat.setDirection(2); } + else { + if (key = 140) { let exit = true; } + } + } + + // Waits for the key to be released. + while ((~(key = 0)) & (~exit)) { + let key = Keyboard.keyPressed(); + do bat.move(); + do moveBall(); + do Sys.wait(50); + } + } + + if (exit) { + do Output.moveCursor(10,27); + do Output.printString("Game Over"); + } + + return; + } + + /** + * Handles ball movement, including bouncing. + * If the ball bounces off a wall, finds its new direction. + * If the ball bounces off the bat, increases the score by one + * and shrinks the bat's size, to make the game more challenging. + */ + method void moveBall() { + var int bouncingDirection, batLeft, batRight, ballLeft, ballRight; + + let wall = ball.move(); + + if ((wall > 0) & (~(wall = lastWall))) { + let lastWall = wall; + let bouncingDirection = 0; + let batLeft = bat.getLeft(); + let batRight = bat.getRight(); + let ballLeft = ball.getLeft(); + let ballRight = ball.getRight(); + + if (wall = 4) { + let exit = (batLeft > ballRight) | (batRight < ballLeft); + if (~exit) { + if (ballRight < (batLeft + 10)) { let bouncingDirection = -1; } + else { + if (ballLeft > (batRight - 10)) { let bouncingDirection = 1; } + } + + let batWidth = batWidth - 2; + do bat.setWidth(batWidth); + let score = score + 1; + do Output.moveCursor(22,7); + do Output.printInt(score); + } + } + do ball.bounce(bouncingDirection); + } + return; + } +} \ No newline at end of file diff --git a/projects/11/Pong/PongGame.vm b/projects/11/Pong/PongGame.vm new file mode 100755 index 0000000..196a57a --- /dev/null +++ b/projects/11/Pong/PongGame.vm @@ -0,0 +1,321 @@ +function PongGame.new 0 +push constant 7 +call Memory.alloc 1 +pop pointer 0 +call Screen.clearScreen 0 +pop temp 0 +push constant 50 +pop this 6 +push constant 230 +push constant 229 +push this 6 +push constant 7 +call Bat.new 4 +pop this 0 +push constant 253 +push constant 222 +push constant 0 +push constant 511 +push constant 0 +push constant 229 +call Ball.new 6 +pop this 1 +push this 1 +push constant 400 +push constant 0 +call Ball.setDestination 3 +pop temp 0 +push constant 0 +push constant 238 +push constant 511 +push constant 240 +call Screen.drawRectangle 4 +pop temp 0 +push constant 22 +push constant 0 +call Output.moveCursor 2 +pop temp 0 +push constant 8 +call String.new 1 +push constant 83 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 48 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push constant 0 +pop this 3 +push constant 0 +pop this 4 +push constant 0 +pop this 2 +push constant 0 +pop this 5 +push pointer 0 +return +function PongGame.dispose 0 +push argument 0 +pop pointer 0 +push this 0 +call Bat.dispose 1 +pop temp 0 +push this 1 +call Ball.dispose 1 +pop temp 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function PongGame.newInstance 0 +call PongGame.new 0 +pop static 0 +push constant 0 +return +function PongGame.getInstance 0 +push static 0 +return +function PongGame.run 1 +push argument 0 +pop pointer 0 +label L0 +push this 3 +not +not +if-goto L1 +label L2 +push local 0 +push constant 0 +eq +push this 3 +not +and +not +if-goto L3 +call Keyboard.keyPressed 0 +pop local 0 +push this 0 +call Bat.move 1 +pop temp 0 +push pointer 0 +call PongGame.moveBall 1 +pop temp 0 +push constant 50 +call Sys.wait 1 +pop temp 0 +goto L2 +label L3 +push local 0 +push constant 130 +eq +not +if-goto L4 +push this 0 +push constant 1 +call Bat.setDirection 2 +pop temp 0 +goto L5 +label L4 +push local 0 +push constant 132 +eq +not +if-goto L6 +push this 0 +push constant 2 +call Bat.setDirection 2 +pop temp 0 +goto L7 +label L6 +push local 0 +push constant 140 +eq +not +if-goto L8 +push constant 1 +neg +pop this 3 +goto L9 +label L8 +label L9 +label L7 +label L5 +label L10 +push local 0 +push constant 0 +eq +not +push this 3 +not +and +not +if-goto L11 +call Keyboard.keyPressed 0 +pop local 0 +push this 0 +call Bat.move 1 +pop temp 0 +push pointer 0 +call PongGame.moveBall 1 +pop temp 0 +push constant 50 +call Sys.wait 1 +pop temp 0 +goto L10 +label L11 +goto L0 +label L1 +push this 3 +not +if-goto L12 +push constant 10 +push constant 27 +call Output.moveCursor 2 +pop temp 0 +push constant 9 +call String.new 1 +push constant 71 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 79 +call String.appendChar 2 +push constant 118 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +goto L13 +label L12 +label L13 +push constant 0 +return +function PongGame.moveBall 5 +push argument 0 +pop pointer 0 +push this 1 +call Ball.move 1 +pop this 2 +push this 2 +push constant 0 +gt +push this 2 +push this 5 +eq +not +and +not +if-goto L14 +push this 2 +pop this 5 +push constant 0 +pop local 0 +push this 0 +call Bat.getLeft 1 +pop local 1 +push this 0 +call Bat.getRight 1 +pop local 2 +push this 1 +call Ball.getLeft 1 +pop local 3 +push this 1 +call Ball.getRight 1 +pop local 4 +push this 2 +push constant 4 +eq +not +if-goto L15 +push local 1 +push local 4 +gt +push local 2 +push local 3 +lt +or +pop this 3 +push this 3 +not +not +if-goto L16 +push local 4 +push local 1 +push constant 10 +add +lt +not +if-goto L17 +push constant 1 +neg +pop local 0 +goto L18 +label L17 +push local 3 +push local 2 +push constant 10 +sub +gt +not +if-goto L19 +push constant 1 +pop local 0 +goto L20 +label L19 +label L20 +label L18 +push this 6 +push constant 2 +sub +pop this 6 +push this 0 +push this 6 +call Bat.setWidth 2 +pop temp 0 +push this 4 +push constant 1 +add +pop this 4 +push constant 22 +push constant 7 +call Output.moveCursor 2 +pop temp 0 +push this 4 +call Output.printInt 1 +pop temp 0 +goto L21 +label L16 +label L21 +goto L22 +label L15 +label L22 +push this 1 +push local 0 +call Ball.bounce 2 +pop temp 0 +goto L23 +label L14 +label L23 +push constant 0 +return diff --git a/projects/11/Seven/Main.jack b/projects/11/Seven/Main.jack new file mode 100755 index 0000000..067402e --- /dev/null +++ b/projects/11/Seven/Main.jack @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Seven/Main.jack + +/** + * Computes the value of 1 + (2 * 3) and prints the result + * at the top-left of the screen. + */ +class Main { + + function void main() { + do Output.printInt(1 + (2 * 3)); + return; + } + +} diff --git a/projects/11/Seven/Main.vm b/projects/11/Seven/Main.vm new file mode 100755 index 0000000..c0f49ca --- /dev/null +++ b/projects/11/Seven/Main.vm @@ -0,0 +1,10 @@ +function Main.main 0 +push constant 1 +push constant 2 +push constant 3 +call Math.multiply 2 +add +call Output.printInt 1 +pop temp 0 +push constant 0 +return diff --git a/projects/11/Square/Main.jack b/projects/11/Square/Main.jack new file mode 100755 index 0000000..0753893 --- /dev/null +++ b/projects/11/Square/Main.jack @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Square/Main.jack + +// (same as projects/09/Square/Main.jack) + +/** Initializes a new Square Dance game and starts running it. */ +class Main { + function void main() { + var SquareGame game; + let game = SquareGame.new(); + do game.run(); + do game.dispose(); + return; + } +} diff --git a/projects/11/Square/Main.vm b/projects/11/Square/Main.vm new file mode 100755 index 0000000..c070b0c --- /dev/null +++ b/projects/11/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/11/Square/Square.jack b/projects/11/Square/Square.jack new file mode 100755 index 0000000..5a92838 --- /dev/null +++ b/projects/11/Square/Square.jack @@ -0,0 +1,110 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Square/Square.jack + +// (same as projects/09/Square/Square.jack) + +/** Implements a graphical square. */ +class Square { + + field int x, y; // screen location of the square's top-left corner + field int size; // length of this square, in pixels + + /** Constructs a new square with a given location and size. */ + constructor Square new(int Ax, int Ay, int Asize) { + let x = Ax; + let y = Ay; + let size = Asize; + do draw(); + return this; + } + + /** Disposes this square. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** Draws the square on the screen. */ + method void draw() { + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + size, y + size); + return; + } + + /** Erases the square from the screen. */ + method void erase() { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + size, y + size); + return; + } + + /** Increments the square size by 2 pixels. */ + method void incSize() { + if (((y + size) < 254) & ((x + size) < 510)) { + do erase(); + let size = size + 2; + do draw(); + } + return; + } + + /** Decrements the square size by 2 pixels. */ + method void decSize() { + if (size > 2) { + do erase(); + let size = size - 2; + do draw(); + } + return; + } + + /** Moves the square up by 2 pixels. */ + method void moveUp() { + if (y > 1) { + do Screen.setColor(false); + do Screen.drawRectangle(x, (y + size) - 1, x + size, y + size); + let y = y - 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + size, y + 1); + } + return; + } + + /** Moves the square down by 2 pixels. */ + method void moveDown() { + if ((y + size) < 254) { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + size, y + 1); + let y = y + 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, (y + size) - 1, x + size, y + size); + } + return; + } + + /** Moves the square left by 2 pixels. */ + method void moveLeft() { + if (x > 1) { + do Screen.setColor(false); + do Screen.drawRectangle((x + size) - 1, y, x + size, y + size); + let x = x - 2; + do Screen.setColor(true); + do Screen.drawRectangle(x, y, x + 1, y + size); + } + return; + } + + /** Moves the square right by 2 pixels. */ + method void moveRight() { + if ((x + size) < 510) { + do Screen.setColor(false); + do Screen.drawRectangle(x, y, x + 1, y + size); + let x = x + 2; + do Screen.setColor(true); + do Screen.drawRectangle((x + size) - 1, y, x + size, y + size); + } + return; + } +} diff --git a/projects/11/Square/Square.vm b/projects/11/Square/Square.vm new file mode 100755 index 0000000..e64bb3f --- /dev/null +++ b/projects/11/Square/Square.vm @@ -0,0 +1,310 @@ +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 1 +neg +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 +not +if-goto L0 +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 +goto L1 +label L0 +label L1 +push constant 0 +return +function Square.decSize 0 +push argument 0 +pop pointer 0 +push this 2 +push constant 2 +gt +not +if-goto L2 +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 +goto L3 +label L2 +label L3 +push constant 0 +return +function Square.moveUp 0 +push argument 0 +pop pointer 0 +push this 1 +push constant 1 +gt +not +if-goto L4 +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 1 +neg +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 +goto L5 +label L4 +label L5 +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 +not +if-goto L6 +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 1 +neg +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 +goto L7 +label L6 +label L7 +push constant 0 +return +function Square.moveLeft 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 1 +gt +not +if-goto L8 +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 1 +neg +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 +goto L9 +label L8 +label L9 +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 +not +if-goto L10 +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 1 +neg +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 +goto L11 +label L10 +label L11 +push constant 0 +return diff --git a/projects/11/Square/SquareGame.jack b/projects/11/Square/SquareGame.jack new file mode 100755 index 0000000..4fe7e39 --- /dev/null +++ b/projects/11/Square/SquareGame.jack @@ -0,0 +1,81 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Square/SquareGame.jack + +// (same as projects/09/Square/SquareGame.jack) + +/** + * Implements the Square Dance game. + * This simple game allows the user to move a black square around + * the screen, and change the square's size during the movement. + * When the game starts, a square of 30 by 30 pixels is shown at the + * top-left corner of the screen. The user controls the square as follows. + * The 4 arrow keys are used to move the square up, down, left, and right. + * The 'z' and 'x' keys are used, respectively, to decrement and increment + * the square's size. The 'q' key is used to quit the game. + */ + +class SquareGame { + field Square square; // the square of this game + field int direction; // the square's current direction: + // 0=none, 1=up, 2=down, 3=left, 4=right + + /** Constructs a new Square Game. */ + constructor SquareGame new() { + // Creates a 30 by 30 pixels square and positions it at the top-left + // of the screen. + let square = Square.new(0, 0, 30); + let direction = 0; // initial state is no movement + return this; + } + + /** Disposes this game. */ + method void dispose() { + do square.dispose(); + do Memory.deAlloc(this); + return; + } + + /** Moves the square in the current direction. */ + method void moveSquare() { + if (direction = 1) { do square.moveUp(); } + if (direction = 2) { do square.moveDown(); } + if (direction = 3) { do square.moveLeft(); } + if (direction = 4) { do square.moveRight(); } + do Sys.wait(5); // delays the next movement + return; + } + + /** Runs the game: handles the user's inputs and moves the square accordingly */ + method void run() { + var char key; // the key currently pressed by the user + var boolean exit; + let exit = false; + + while (~exit) { + // waits for a key to be pressed + while (key = 0) { + let key = Keyboard.keyPressed(); + do moveSquare(); + } + if (key = 81) { let exit = true; } // q key + if (key = 90) { do square.decSize(); } // z key + if (key = 88) { do square.incSize(); } // x key + if (key = 131) { let direction = 1; } // up arrow + if (key = 133) { let direction = 2; } // down arrow + if (key = 130) { let direction = 3; } // left arrow + if (key = 132) { let direction = 4; } // right arrow + + // waits for the key to be released + while (~(key = 0)) { + let key = Keyboard.keyPressed(); + do moveSquare(); + } + } // while + return; + } +} + + + diff --git a/projects/11/Square/SquareGame.vm b/projects/11/Square/SquareGame.vm new file mode 100755 index 0000000..5cb10b8 --- /dev/null +++ b/projects/11/Square/SquareGame.vm @@ -0,0 +1,190 @@ +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 +not +if-goto L0 +push this 0 +call Square.moveUp 1 +pop temp 0 +goto L1 +label L0 +label L1 +push this 1 +push constant 2 +eq +not +if-goto L2 +push this 0 +call Square.moveDown 1 +pop temp 0 +goto L3 +label L2 +label L3 +push this 1 +push constant 3 +eq +not +if-goto L4 +push this 0 +call Square.moveLeft 1 +pop temp 0 +goto L5 +label L4 +label L5 +push this 1 +push constant 4 +eq +not +if-goto L6 +push this 0 +call Square.moveRight 1 +pop temp 0 +goto L7 +label L6 +label L7 +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 L8 +push local 1 +not +not +if-goto L9 +label L10 +push local 0 +push constant 0 +eq +not +if-goto L11 +call Keyboard.keyPressed 0 +pop local 0 +push pointer 0 +call SquareGame.moveSquare 1 +pop temp 0 +goto L10 +label L11 +push local 0 +push constant 81 +eq +not +if-goto L12 +push constant 1 +neg +pop local 1 +goto L13 +label L12 +label L13 +push local 0 +push constant 90 +eq +not +if-goto L14 +push this 0 +call Square.decSize 1 +pop temp 0 +goto L15 +label L14 +label L15 +push local 0 +push constant 88 +eq +not +if-goto L16 +push this 0 +call Square.incSize 1 +pop temp 0 +goto L17 +label L16 +label L17 +push local 0 +push constant 131 +eq +not +if-goto L18 +push constant 1 +pop this 1 +goto L19 +label L18 +label L19 +push local 0 +push constant 133 +eq +not +if-goto L20 +push constant 2 +pop this 1 +goto L21 +label L20 +label L21 +push local 0 +push constant 130 +eq +not +if-goto L22 +push constant 3 +pop this 1 +goto L23 +label L22 +label L23 +push local 0 +push constant 132 +eq +not +if-goto L24 +push constant 4 +pop this 1 +goto L25 +label L24 +label L25 +label L26 +push local 0 +push constant 0 +eq +not +not +if-goto L27 +call Keyboard.keyPressed 0 +pop local 0 +push pointer 0 +call SquareGame.moveSquare 1 +pop temp 0 +goto L26 +label L27 +goto L8 +label L9 +push constant 0 +return diff --git a/projects/11/__pycache__/symbol_table.cpython-39.pyc b/projects/11/__pycache__/symbol_table.cpython-39.pyc new file mode 100755 index 0000000..78e9c0a Binary files /dev/null and b/projects/11/__pycache__/symbol_table.cpython-39.pyc differ diff --git a/projects/11/__pycache__/tokenizer.cpython-39.pyc b/projects/11/__pycache__/tokenizer.cpython-39.pyc new file mode 100755 index 0000000..a3bcf76 Binary files /dev/null and b/projects/11/__pycache__/tokenizer.cpython-39.pyc differ diff --git a/projects/11/__pycache__/vmwriter.cpython-39.pyc b/projects/11/__pycache__/vmwriter.cpython-39.pyc new file mode 100755 index 0000000..9bc3b05 Binary files /dev/null and b/projects/11/__pycache__/vmwriter.cpython-39.pyc differ diff --git a/projects/11/lang.txt b/projects/11/lang.txt new file mode 100755 index 0000000..d27c8d9 --- /dev/null +++ b/projects/11/lang.txt @@ -0,0 +1,2 @@ +python3 +debug diff --git a/projects/11/symbol_table.py b/projects/11/symbol_table.py new file mode 100755 index 0000000..7c62c3e --- /dev/null +++ b/projects/11/symbol_table.py @@ -0,0 +1,62 @@ +class Symbol: + def __init__(self): + self.s_name = '' + self.s_kind = '' + self.s_type = '' + self.s_index = 0 + + +class SymbolTable: + def __init__(self): + self.sym = [] + + def define(self, s_name, s_type, s_kind): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = s_kind + self.sym[-1].s_index = self.var_count(s_kind) - 1 + + def start_subroutine(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'argument' + self.sym[-1].s_index = 0 + + def start_class(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = 'this' + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'field' + self.sym[-1].s_index = 0 + + def var_count(self, s_kind): + count = 0 # it is -1 so the first index is 0 + for i in self.sym: + if i.s_kind == s_kind: + count += 1 + return count + + def kind_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + if i.s_kind == 'var': + return 'local' + elif i.s_kind == 'field': + return 'this' + else: + return i.s_kind + return None + + def type_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_type + return None + + def index_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_index + return None diff --git a/projects/11/tokenizer.py b/projects/11/tokenizer.py new file mode 100755 index 0000000..aaaa873 --- /dev/null +++ b/projects/11/tokenizer.py @@ -0,0 +1,78 @@ +import re + + +class Tokenizer: + + def __init__(self): + self.i = 0 + self.file = '' + self.symbols = ('(', ')', '[', ']', '}', '{', '>', '<', '=', '*', '+', '-', '/', '.', ';', ',', '&', '|', + '~') + self.key_word = ( + 'class', 'method', 'function', 'constructor', 'int', 'boolean', 'char', 'void', 'var', 'static', 'field', + 'let', 'do', 'if', 'else', 'while', 'return', 'true', 'false', 'null', 'this') + self.token = '' + + def token_type(self, token=None): + if token is None: + token = self.token + if token is None or token == '': + return None + if token in self.key_word: + return 'keyword' + elif token[0] == '"': + return 'stringConstant' + elif re.match(r"\d+", token): + return 'integerConstant' + elif token in self.symbols: + return 'symbol' + else: + return 'identifier' + + def advance(self): + token = '' + i = self.i + while i < len(self.file): + if re.match(r'\s', self.file[i]): + i = i + 1 + continue + else: + if self.file[i] in self.symbols: + self.token = self.file[i] + self.i = i + 1 + return + elif self.file[i] == '"': + i += 1 + while self.file[i] != '"': + token += self.file[i] + i += 1 + self.i = i + 1 + self.token = '"' + token + '"' + return + else: + while re.match(r'\w', self.file[i]): + token += self.file[i] + if i + 1 > len(self.file) - 1: + break + i += 1 + self.i = i + self.token = token + return + + def clear_file(self, directory): + with open(directory, "r") as my_file: + txt = my_file.read() + txt = re.sub(r"//.*", "", txt) + txt = re.sub(r"/[*][*].*[*]/", "", txt) + i = 0 + # TODO this should be a regex + while i < len(txt): + if txt[i] == '/' and txt[i + 1] == '*' and txt[i + 2] == '*': + start = i + while txt[i] != '*' or txt[i + 1] != '/': + i += 1 + stop = i + 2 + txt = txt[:start] + txt[stop:len(txt)] + i = start - 1 + i += 1 + self.file = txt diff --git a/projects/11/vmwriter.py b/projects/11/vmwriter.py new file mode 100755 index 0000000..5bf6929 --- /dev/null +++ b/projects/11/vmwriter.py @@ -0,0 +1,75 @@ +class VMWriter: + def __init__(self, vm_path): + self.my_vm = open(vm_path, "w+") + self.label_index = 0 + + def write_push(self, segment, index): + self.my_vm.write(f'push {segment} {index}\n') + print(f'push {segment} {index}') + + def write_lable(self, label): + self.my_vm.write(f'label L{label}\n') + print(f'label L{label}') + + def write_arithmetic(self, command): + if command == '+': + self.my_vm.write('add\n') + print('add') + elif command == '-': + self.my_vm.write('sub\n') + print('sub') + elif command == 'neg': + self.my_vm.write('neg\n') + print('neg') + elif command == '=': + self.my_vm.write('eq\n') + print('eq') + elif command == '>': + self.my_vm.write('gt\n') + print('gt') + elif command == '<': + self.my_vm.write('lt\n') + print('lt') + elif command == '&': + self.my_vm.write('and\n') + print('and') + elif command == '|': + self.my_vm.write('or\n') + print('or') + elif command == '~': + self.my_vm.write('not\n') + print('not') + elif command == '*': + self.write_call('Math.multiply', 2) + elif command == '/': + self.write_call('Math.divide', 2) + + def write_pop(self, segment, index): + print(f'pop {segment} {index}') + self.my_vm.write(f'pop {segment} {index}\n') + + def write_goto(self, label): + self.my_vm.write(f'goto L{label}\n') + print(f'goto L{label}') + + def write_if(self, label): + self.write_arithmetic('~') + self.my_vm.write(f'if-goto L{label}\n') + print(f'if-goto L{label}') + + def write_call(self, label, num_args): + self.my_vm.write(f'call {label} {num_args}\n') + print(f'call {label} {num_args}') + + def write_function(self, label, num_locals): + self.my_vm.write(f'function {label} {num_locals}\n') + print(f'function {label} {num_locals}') + + def write_return(self, func_type): + if func_type == 'void': + self.write_push('constant', '0') + self.my_vm.write('return\n') + print(f'return') + + def close_vm_file(self): + self.my_vm.close() diff --git a/projects/12/Array.jack b/projects/12/Array.jack new file mode 100755 index 0000000..f16cad6 --- /dev/null +++ b/projects/12/Array.jack @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Array.jack + +/** + * Represents an array. + * In the Jack language, arrays are instances of the Array class. + * Once declared, the array entries can be accessed using the usual + * syntax arr[i]. Each array entry can hold a primitive data type as + * well as any object type. Different array entries can have different + * data types. + */ +class Array { + + /** Constructs a new Array of the given size. */ + function Array new(int size) { + if(size < 0){ + do Sys.error(7); + } + return Memory.alloc(size); + } + + /** Disposes this array. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } +} diff --git a/projects/12/ArrayTest/Array.jack b/projects/12/ArrayTest/Array.jack new file mode 100755 index 0000000..f16cad6 --- /dev/null +++ b/projects/12/ArrayTest/Array.jack @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Array.jack + +/** + * Represents an array. + * In the Jack language, arrays are instances of the Array class. + * Once declared, the array entries can be accessed using the usual + * syntax arr[i]. Each array entry can hold a primitive data type as + * well as any object type. Different array entries can have different + * data types. + */ +class Array { + + /** Constructs a new Array of the given size. */ + function Array new(int size) { + if(size < 0){ + do Sys.error(7); + } + return Memory.alloc(size); + } + + /** Disposes this array. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } +} diff --git a/projects/12/ArrayTest/Array.vm b/projects/12/ArrayTest/Array.vm new file mode 100755 index 0000000..60838ae --- /dev/null +++ b/projects/12/ArrayTest/Array.vm @@ -0,0 +1,23 @@ +function Array.new 0 +push argument 0 +push constant 0 +lt +not +if-goto L0 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L1 +label L0 +label L1 +push argument 0 +call Memory.alloc 1 +return +function Array.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/ArrayTest/ArrayTest.cmp b/projects/12/ArrayTest/ArrayTest.cmp new file mode 100755 index 0000000..d1a9798 --- /dev/null +++ b/projects/12/ArrayTest/ArrayTest.cmp @@ -0,0 +1,2 @@ +|RAM[8000]|RAM[8001]|RAM[8002]|RAM[8003]| +| 222 | 122 | 100 | 10 | diff --git a/projects/12/ArrayTest/ArrayTest.out b/projects/12/ArrayTest/ArrayTest.out new file mode 100755 index 0000000..e69de29 diff --git a/projects/12/ArrayTest/ArrayTest.tst b/projects/12/ArrayTest/ArrayTest.tst new file mode 100755 index 0000000..89934b9 --- /dev/null +++ b/projects/12/ArrayTest/ArrayTest.tst @@ -0,0 +1,15 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/ArrayTest/ArrayTest.tst + +load, +output-file ArrayTest.out, +compare-to ArrayTest.cmp, +output-list RAM[8000]%D2.6.1 RAM[8001]%D2.6.1 RAM[8002]%D2.6.1 RAM[8003]%D2.6.1; + +repeat 1000000 { + vmstep; +} + +output; diff --git a/projects/12/ArrayTest/Main.jack b/projects/12/ArrayTest/Main.jack new file mode 100755 index 0000000..439770a --- /dev/null +++ b/projects/12/ArrayTest/Main.jack @@ -0,0 +1,40 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/ArrayTest/Main.jack + +/** Test program for the OS Array class. */ +class Main { + + /** Performs several Array manipulations. */ + function void main() { + var Array r; // stores test results + var Array a, b, c; + + let r = 8000; + + let a = Array.new(3); + let a[2] = 222; + let r[0] = a[2]; // RAM[8000] = 222 + + let b = Array.new(3); + let b[1] = a[2] - 100; + let r[1] = b[1]; // RAM[8001] = 122 + + let c = Array.new(500); + let c[499] = a[2] - b[1]; + let r[2] = c[499]; // RAM[8002] = 100 + + do a.dispose(); + do b.dispose(); + + let b = Array.new(3); + let b[0] = c[499] - 90; + let r[3] = b[0]; // RAM[8003] = 10 + + do c.dispose(); + do b.dispose(); + + return; + } +} diff --git a/projects/12/ArrayTest/Main.vm b/projects/12/ArrayTest/Main.vm new file mode 100755 index 0000000..afe00a3 --- /dev/null +++ b/projects/12/ArrayTest/Main.vm @@ -0,0 +1,131 @@ +function Main.main 4 +push constant 8000 +pop local 0 +push constant 3 +call Array.new 1 +pop local 1 +push local 1 +push constant 2 +push constant 222 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 0 +push local 1 +push constant 2 +add +pop pointer 1 +push that 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 3 +call Array.new 1 +pop local 2 +push local 2 +push constant 1 +push local 1 +push constant 2 +add +pop pointer 1 +push that 0 +push constant 100 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 1 +push local 2 +push constant 1 +add +pop pointer 1 +push that 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 500 +call Array.new 1 +pop local 3 +push local 3 +push constant 499 +push local 1 +push constant 2 +add +pop pointer 1 +push that 0 +push local 2 +push constant 1 +add +pop pointer 1 +push that 0 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 2 +push local 3 +push constant 499 +add +pop pointer 1 +push that 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +call Array.dispose 1 +pop temp 0 +push local 2 +call Array.dispose 1 +pop temp 0 +push constant 3 +call Array.new 1 +pop local 2 +push local 2 +push constant 0 +push local 3 +push constant 499 +add +pop pointer 1 +push that 0 +push constant 90 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 3 +push local 2 +push constant 0 +add +pop pointer 1 +push that 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +call Array.dispose 1 +pop temp 0 +push local 2 +call Array.dispose 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/Keyboard.jack b/projects/12/Keyboard.jack new file mode 100755 index 0000000..5308b8c --- /dev/null +++ b/projects/12/Keyboard.jack @@ -0,0 +1,102 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Keyboard.jack + +/** + * A library for handling user input from the keyboard. + */ + +class Keyboard { + static Array mem; + /** Initializes the keyboard. */ + function void init() { + let mem = 0; + return; + } + + /** + * Returns the character of the currently pressed key on the keyboard; + * if no key is currently pressed, returns 0. + * + * Recognizes all ASCII characters, as well as the following keys: + * new line = 128 = String.newline() + * backspace = 129 = String.backspace() + * left arrow = 130 + * up arrow = 131 + * right arrow = 132 + * down arrow = 133 + * home = 134 + * End = 135 + * page up = 136 + * page down = 137 + * insert = 138 + * delete = 139 + * ESC = 140 + * F1 - F12 = 141 - 152 + */ + function char keyPressed() { + return mem[24576]; + } + + /** + * Waits until a key is pressed on the keyboard and released, + * then echoes the key to the screen, and returns the character + * of the pressed key. + */ + function char readChar() { + var char a, b; + do Output.printChar(0); + while ((b = 0) | (a > 0)){ + let a = Keyboard.keyPressed(); + if (a > 0){ + let b = a; + } + } + do Output.printChar(String.backSpace()); + do Output.printChar(b); + return b; + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its value. Also handles user backspaces. + */ + function String readLine(String message) { + var String s, b; + var char c; + let s = String.new(100); + do Output.printString(message); + while (true){ + let c = Keyboard.readChar(); + if (c = 128){ + return s; + } + else{ + if (c = 129){ + do s.eraseLastChar(); + } + else{ + do s.appendChar(c); + } + } + } + return; + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its integer value (until the first non-digit character in the + * entered text is detected). Also handles user backspaces. + */ + function int readInt(String message) { + var starting a; + var int b; + let a = Main.readLine_stolen(message); + let b = String.intValue(a); + do String.dispose(a); + return b; + } +} diff --git a/projects/12/KeyboardTest/Keyboard.jack b/projects/12/KeyboardTest/Keyboard.jack new file mode 100755 index 0000000..7d8dd47 --- /dev/null +++ b/projects/12/KeyboardTest/Keyboard.jack @@ -0,0 +1,101 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Keyboard.jack + +/** + * A library for handling user input from the keyboard. + */ + +class Keyboard { + static Array mem; + /** Initializes the keyboard. */ + function void init() { + let mem = 0; + return; + } + + /** + * Returns the character of the currently pressed key on the keyboard; + * if no key is currently pressed, returns 0. + * + * Recognizes all ASCII characters, as well as the following keys: + * new line = 128 = String.newline() + * backspace = 129 = String.backspace() + * left arrow = 130 + * up arrow = 131 + * right arrow = 132 + * down arrow = 133 + * home = 134 + * End = 135 + * page up = 136 + * page down = 137 + * insert = 138 + * delete = 139 + * ESC = 140 + * F1 - F12 = 141 - 152 + */ + function char keyPressed() { + return mem[24576]; + } + + /** + * Waits until a key is pressed on the keyboard and released, + * then echoes the key to the screen, and returns the character + * of the pressed key. + */ + function char readChar() { + var char a, b; + do Output.printChar(0); + while ((b = 0) | (a > 0)){ + let a = Keyboard.keyPressed(); + if (a > 0){ + let b = a; + } + } + do Output.printChar(String.backSpace()); + do Output.printChar(b); + return b; + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its value. Also handles user backspaces. + */ + function String readLine(String message) { + var String s, b; + var char c; + let s = String.new(100); + do Output.printString(message); + while (true){ + let c = Keyboard.readChar(); + if (c = 128){ + return s; + } + else{ + if (c = 129){ + do s.eraseLastChar(); + } + else{ + do s.appendChar(c); + } + } + } + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its integer value (until the first non-digit character in the + * entered text is detected). Also handles user backspaces. + */ + function int readInt(String message) { + var starting a; + var int b; + let a = Main.readLine_stolen(message); + let b = String.intValue(a); + do String.dispose(a); + return b; + } +} diff --git a/projects/12/KeyboardTest/Keyboard.vm b/projects/12/KeyboardTest/Keyboard.vm new file mode 100755 index 0000000..46d9e79 --- /dev/null +++ b/projects/12/KeyboardTest/Keyboard.vm @@ -0,0 +1,156 @@ +function Keyboard.init 0 +push constant 0 +pop static 0 +push constant 0 +return +function Keyboard.keyPressed 0 +push static 0 +push constant 24576 +add +pop pointer 1 +push that 0 +return +function Keyboard.readChar 2 +push constant 0 +call Output.printChar 1 +pop temp 0 +label L0 +push local 1 +push constant 0 +eq +push local 0 +push constant 0 +gt +or +not +if-goto L1 +call Keyboard.keyPressed 0 +pop local 0 +push local 0 +push constant 0 +gt +not +if-goto L2 +push local 0 +pop local 1 +goto L3 +label L2 +label L3 +goto L0 +label L1 +call String.backSpace 0 +call Output.printChar 1 +pop temp 0 +push local 1 +call Output.printChar 1 +pop temp 0 +push local 1 +return +function Keyboard.readLine 3 +push constant 100 +call String.new 1 +pop local 0 +push argument 0 +call Output.printString 1 +pop temp 0 +label L4 +push constant 1 +neg +not +if-goto L5 +call Keyboard.readChar 0 +pop local 2 +push local 2 +push constant 128 +eq +not +if-goto L6 +push local 0 +return +goto L7 +label L6 +push local 2 +push constant 129 +eq +not +if-goto L8 +push local 0 +call String.eraseLastChar 1 +pop temp 0 +goto L9 +label L8 +push local 0 +push local 2 +call String.appendChar 2 +pop temp 0 +label L9 +label L7 +goto L4 +label L5 +function Keyboard.readInt 2 +push constant 100 +call String.new 1 +pop local 0 +push argument 0 +call Output.printString 1 +pop temp 0 +label L10 +push constant 1 +neg +not +if-goto L11 +push local 1 +call Keyboard.readChar 1 +pop local 1 +push local 1 +push constant 128 +eq +not +if-goto L12 +push local 0 +call String.intValue 1 +return +goto L13 +label L12 +push local 1 +push constant 129 +eq +not +if-goto L14 +push local 0 +call String.eraseLastChar 1 +pop temp 0 +goto L15 +label L14 +push local 1 +push constant 47 +gt +push local 1 +push constant 57 +lt +and +not +if-goto L16 +push local 0 +push local 1 +call String.appendChar 2 +pop temp 0 +goto L17 +label L16 +label L17 +push local 1 +push constant 45 +eq +not +if-goto L18 +push local 0 +push local 1 +call String.appendChar 2 +pop temp 0 +goto L19 +label L18 +label L19 +label L15 +label L13 +goto L10 +label L11 diff --git a/projects/12/KeyboardTest/KeyboardTestOutput.gif b/projects/12/KeyboardTest/KeyboardTestOutput.gif new file mode 100755 index 0000000..944983a Binary files /dev/null and b/projects/12/KeyboardTest/KeyboardTestOutput.gif differ diff --git a/projects/12/KeyboardTest/Main.jack b/projects/12/KeyboardTest/Main.jack new file mode 100755 index 0000000..e89182c --- /dev/null +++ b/projects/12/KeyboardTest/Main.jack @@ -0,0 +1,93 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/KeyboardTest/Main.jack + +/** Test program for the OS Keyboard class. */ +class Main { + + /** Gets input from the user and verifies its contents. */ + function void main() { + var char c, key; + var String s; + var int i; + var boolean ok; + + let ok = false; + do Output.printString("keyPressed test:"); + do Output.println(); + while (~ok) { + do Output.printString("Please press the 'Page Down' key"); + while (key = 0) { + let key = Keyboard.keyPressed(); + } + let c = key; + while (~(key = 0)) { + let key = Keyboard.keyPressed(); + } + + do Output.println(); + + if (c = 137) { + do Output.printString("ok"); + do Output.println(); + let ok = true; + } + } + + let ok = false; + do Output.printString("readChar test:"); + do Output.println(); + do Output.printString("(Verify that the pressed character is echoed to the screen)"); + do Output.println(); + while (~ok) { + do Output.printString("Please press the number '3': "); + let c = Keyboard.readChar(); + + do Output.println(); + + if (c = 51) { + do Output.printString("ok"); + do Output.println(); + let ok = true; + } + } + + let ok = false; + do Output.printString("readLine test:"); + do Output.println(); + do Output.printString("(Verify echo and usage of 'backspace')"); + do Output.println(); + while (~ok) { + let s = Keyboard.readLine("Please type 'JACK' and press enter: "); + + if (s.length() = 4) { + if ((s.charAt(0) = 74) & (s.charAt(1) = 65) & (s.charAt(2) = 67) & (s.charAt(3) = 75)) { + do Output.printString("ok"); + do Output.println(); + let ok = true; + } + } + } + + let ok = false; + do Output.printString("readInt test:"); + do Output.println(); + do Output.printString("(Verify echo and usage of 'backspace')"); + do Output.println(); + while (~ok) { + let i = Keyboard.readInt("Please type '-32123' and press enter: "); + + if (i = (-32123)) { + do Output.printString("ok"); + do Output.println(); + let ok = true; + } + } + + do Output.println(); + do Output.printString("Test completed successfully"); + + return; + } +} diff --git a/projects/12/KeyboardTest/Main.vm b/projects/12/KeyboardTest/Main.vm new file mode 100755 index 0000000..c03efe8 --- /dev/null +++ b/projects/12/KeyboardTest/Main.vm @@ -0,0 +1,954 @@ +function Main.main 5 +push constant 0 +pop local 4 +push constant 16 +call String.new 1 +push constant 107 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 80 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +label L0 +push local 4 +not +not +if-goto L1 +push constant 32 +call String.new 1 +push constant 80 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 80 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 68 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +label L2 +push local 1 +push constant 0 +eq +not +if-goto L3 +call Keyboard.keyPressed 0 +pop local 1 +goto L2 +label L3 +push local 1 +pop local 0 +label L4 +push local 1 +push constant 0 +eq +not +not +if-goto L5 +call Keyboard.keyPressed 0 +pop local 1 +goto L4 +label L5 +call Output.println 0 +pop temp 0 +push local 0 +push constant 137 +eq +not +if-goto L6 +push constant 2 +call String.new 1 +push constant 111 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 1 +neg +pop local 4 +goto L7 +label L6 +label L7 +goto L0 +label L1 +push constant 0 +pop local 4 +push constant 14 +call String.new 1 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 67 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 59 +call String.new 1 +push constant 40 +call String.appendChar 2 +push constant 86 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 41 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +label L8 +push local 4 +not +not +if-goto L9 +push constant 29 +call String.new 1 +push constant 80 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Keyboard.readChar 0 +pop local 0 +call Output.println 0 +pop temp 0 +push local 0 +push constant 51 +eq +not +if-goto L10 +push constant 2 +call String.new 1 +push constant 111 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 1 +neg +pop local 4 +goto L11 +label L10 +label L11 +goto L8 +label L9 +push constant 0 +pop local 4 +push constant 14 +call String.new 1 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 76 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 38 +call String.new 1 +push constant 40 +call String.appendChar 2 +push constant 86 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 41 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +label L12 +push local 4 +not +not +if-goto L13 +push constant 36 +call String.new 1 +push constant 80 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 74 +call String.appendChar 2 +push constant 65 +call String.appendChar 2 +push constant 67 +call String.appendChar 2 +push constant 75 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Keyboard.readLine 1 +pop local 2 +push local 2 +call String.length 1 +push constant 4 +eq +not +if-goto L14 +push local 2 +push constant 0 +call String.charAt 2 +push constant 74 +eq +push local 2 +push constant 1 +call String.charAt 2 +push constant 65 +eq +and +push local 2 +push constant 2 +call String.charAt 2 +push constant 67 +eq +and +push local 2 +push constant 3 +call String.charAt 2 +push constant 75 +eq +and +not +if-goto L15 +push constant 2 +call String.new 1 +push constant 111 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 1 +neg +pop local 4 +goto L16 +label L15 +label L16 +goto L17 +label L14 +label L17 +goto L12 +label L13 +push constant 0 +pop local 4 +push constant 13 +call String.new 1 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 73 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 38 +call String.new 1 +push constant 40 +call String.appendChar 2 +push constant 86 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 41 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +label L18 +push local 4 +not +not +if-goto L19 +push constant 38 +call String.new 1 +push constant 80 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 45 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Keyboard.readInt 1 +pop local 3 +push local 3 +push constant 32123 +neg +eq +not +if-goto L20 +push constant 2 +call String.new 1 +push constant 111 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 1 +neg +pop local 4 +goto L21 +label L20 +label L21 +goto L18 +label L19 +call Output.println 0 +pop temp 0 +push constant 27 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/Math.jack b/projects/12/Math.jack new file mode 100755 index 0000000..1730de4 --- /dev/null +++ b/projects/12/Math.jack @@ -0,0 +1,143 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Math.jack + +/** + * A library of commonly used mathematical functions. + * Note: Jack compilers implement multiplication and division using OS method calls. + */ +class Math { + static Array st; + static int division_tmp, f; + + /** Initializes the library. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + return; + } + + /** Returns the absolute value of x. */ + function int abs(int x) { + if (x > 0){ + return x; + } + return -x; + } + + /** Returns the product of x and y. + * When a Jack compiler detects the multiplication operator '*' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x*y and multiply(x,y) return the same value. + */ + function int multiply(int x, int y) { + var int sum, temp, y_comp, i, neg; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (x < y){ + let temp = x; + let x = y; + let y = temp; + } + if (y = 1){ + if(neg){ + return -x; + } + return x; + } + while((y_comp - 1) < (y - 1)){ + if ((st[i] & y) > 0) { + let sum = sum + x; + let y_comp = y_comp + st[i]; + } + let x = x + x; + let i = i + 1; + } + if(neg){ + let sum = -sum; + } + return sum; + } + + /** Returns the integer part of x/y. + * When a Jack compiler detects the multiplication operator '/' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x/y and divide(x,y) return the same value. + */ + function int divide(int x, int y) { + var int q, neg; + if (f = 0){ + let division_tmp = 0; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (y = 0){ + do Sys.error(3); + } + let f = 1; + } + if ((y > x) | (y < 0)){ + return 0; + } + let q = Math.divide(x, y + y); + let f = 0; + let q = Math.abs(q); + if ((q & 1) = 1){ + let division_tmp = division_tmp + y + y; + } + if (x - division_tmp < y){ + if (neg){ + return -(q + q); + } + return q + q; + } + else{ + if (neg){ + return -(q + q + 1); + } + return q + q + 1; + } + } + + /** Returns the integer part of the square root of x. */ + function int sqrt(int x) { + var int j, b, d, y; + + if (x < 0){ + do Sys.error(4); + } + let j = 7; + while (j > -1){ + let d = y + st[j]; + let b = d * d; + if ((~(b > x)) & (b > 0)){ + let y = d; + } + let j = j - 1; + } + return y; + } + + /** Returns the greater number. */ + function int max(int a, int b) { + if (a > b){ + return a; + } + return b; + } + + /** Returns the smaller number. */ + function int min(int a, int b) { + if (a < b){ + return a; + } + return b; + } +} diff --git a/projects/12/MathTest/Array.vm b/projects/12/MathTest/Array.vm new file mode 100755 index 0000000..aa4c9e8 --- /dev/null +++ b/projects/12/MathTest/Array.vm @@ -0,0 +1,23 @@ +function Array.new 0 +push argument 0 +push constant 0 +gt +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 2 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +call Memory.alloc 1 +return +function Array.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/MathTest/Keyboard.vm b/projects/12/MathTest/Keyboard.vm new file mode 100755 index 0000000..a806c4e --- /dev/null +++ b/projects/12/MathTest/Keyboard.vm @@ -0,0 +1,102 @@ +function Keyboard.init 0 +push constant 0 +return +function Keyboard.keyPressed 0 +push constant 24576 +call Memory.peek 1 +return +function Keyboard.readChar 2 +push constant 0 +call Output.printChar 1 +pop temp 0 +label WHILE_EXP0 +push local 1 +push constant 0 +eq +push local 0 +push constant 0 +gt +or +not +if-goto WHILE_END0 +call Keyboard.keyPressed 0 +pop local 0 +push local 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +pop local 1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +call String.backSpace 0 +call Output.printChar 1 +pop temp 0 +push local 1 +call Output.printChar 1 +pop temp 0 +push local 1 +return +function Keyboard.readLine 5 +push constant 80 +call String.new 1 +pop local 3 +push argument 0 +call Output.printString 1 +pop temp 0 +call String.newLine 0 +pop local 1 +call String.backSpace 0 +pop local 2 +label WHILE_EXP0 +push local 4 +not +not +if-goto WHILE_END0 +call Keyboard.readChar 0 +pop local 0 +push local 0 +push local 1 +eq +pop local 4 +push local 4 +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push local 2 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 3 +call String.eraseLastChar 1 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 3 +push local 0 +call String.appendChar 2 +pop local 3 +label IF_END1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +return +function Keyboard.readInt 2 +push argument 0 +call Keyboard.readLine 1 +pop local 0 +push local 0 +call String.intValue 1 +pop local 1 +push local 0 +call String.dispose 1 +pop temp 0 +push local 1 +return diff --git a/projects/12/MathTest/Main.jack b/projects/12/MathTest/Main.jack new file mode 100755 index 0000000..de5cec2 --- /dev/null +++ b/projects/12/MathTest/Main.jack @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/MathTest/Main.jack + +/** Test program for the OS Math class. */ +class Main { + + /** Performs various mathematical operations, using calls to the Math class methods. */ + function void main() { + var Array r; // stores the test results; + + let r = 8000; + + let r[0] = 2 * 3; // 6 + let r[1] = r[0] * (-30); // 6 * (-30) = -180 + let r[2] = r[1] * 100; // (-180) * 100 = -18000 + let r[3] = 1 * r[2]; // 1 * (-18000) = -18000 + let r[4] = r[3] * 0; // 0 + + let r[5] = 9 / 3; // 3 + let r[6] = (-18000) / 6; // -3000 + let r[7] = 32766 / (-32767); // 0 + + let r[8] = Math.sqrt(9); // 3 + let r[9] = Math.sqrt(32767); // 181 + + let r[10] = Math.min(345, 123); // 123 + let r[11] = Math.max(123, -345); // 123 + let r[12] = Math.abs(27); // 27 + let r[13] = Math.abs(-32767); // 32767 + + return; + } +} diff --git a/projects/12/MathTest/Main.vm b/projects/12/MathTest/Main.vm new file mode 100755 index 0000000..21f5221 --- /dev/null +++ b/projects/12/MathTest/Main.vm @@ -0,0 +1,162 @@ +function Main.main 1 +push constant 8000 +pop local 0 +push local 0 +push constant 0 +push constant 2 +push constant 3 +call Math.multiply 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 1 +push local 0 +push constant 0 +add +pop pointer 1 +push that 0 +push constant 30 +neg +call Math.multiply 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 2 +push local 0 +push constant 1 +add +pop pointer 1 +push that 0 +push constant 100 +call Math.multiply 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 3 +push constant 1 +push local 0 +push constant 2 +add +pop pointer 1 +push that 0 +call Math.multiply 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 4 +push local 0 +push constant 3 +add +pop pointer 1 +push that 0 +push constant 0 +call Math.multiply 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 5 +push constant 9 +push constant 3 +call Math.divide 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 6 +push constant 18000 +neg +push constant 6 +call Math.divide 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 7 +push constant 32766 +push constant 32767 +neg +call Math.divide 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 8 +push constant 9 +call Math.sqrt 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 9 +push constant 32767 +call Math.sqrt 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 10 +push constant 345 +push constant 123 +call Math.min 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 11 +push constant 123 +push constant 345 +neg +call Math.max 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 12 +push constant 27 +call Math.abs 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 13 +push constant 32767 +neg +call Math.abs 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return diff --git a/projects/12/MathTest/Math.jack b/projects/12/MathTest/Math.jack new file mode 100755 index 0000000..de479be --- /dev/null +++ b/projects/12/MathTest/Math.jack @@ -0,0 +1,143 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Math.jack + +/** + * A library of commonly used mathematical functions. + * Note: Jack compilers implement multiplication and division using OS method calls. + */ +class Math { + static Array st; + static int division_tmp, f; + + /** Initializes the library. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + return; + } + + /** Returns the absolute value of x. */ + function int abs(int x) { + if (x > 0){ + return x; + } + return -x; + } + + /** Returns the product of x and y. + * When a Jack compiler detects the multiplication operator '*' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x*y and multiply(x,y) return the same value. + */ + function int multiply(int x, int y) { + var int sum, temp, y_comp, i, neg; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (x < y){ + let temp = x; + let x = y; + let y = temp; + } + if (y = 1){ + if(neg){ + return -x; + } + return x; + } + while((y_comp - 1) < (y - 1)){ + if ((st[i] & y) > 0) { + let sum = sum + x; + let y_comp = y_comp + st[i]; + } + let x = x + x; + let i = i + 1; + } + if(neg){ + let sum = -sum; + } + return sum; + } + + /** Returns the integer part of x/y. + * When a Jack compiler detects the multiplication operator '/' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x/y and divide(x,y) return the same value. + */ + function int divide(int x, int y) { + var int q, neg; + if (f = 0){ + let division_tmp = 0; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (y = 0){ + do Sys.error(3); + } + let f = 1; + } + if ((y > x) | (y < 0)){ + return 0; + } + let q = divide(x, y + y); + let f = 0; + let q = Math.abs(q); + if ((q & 1) = 1){ + let division_tmp = division_tmp + y + y; + } + if (x - division_tmp < y){ + if (neg){ + return -(q + q); + } + return q + q; + } + else{ + if (neg){ + return -(q + q + 1); + } + return q + q + 1; + } + } + + /** Returns the integer part of the square root of x. */ + function int sqrt(int x) { + var int j, b, d, y; + + if (x < 0){ + do Sys.error(4); + } + let j = 7; + while (j > -1){ + let d = y + st[j]; + let b = d * d; + if ((~(b > x)) & (b > 0)){ + let y = d; + } + let j = j - 1; + } + return y; + } + + /** Returns the greater number. */ + function int max(int a, int b) { + if (a > b){ + return a; + } + return b; + } + + /** Returns the smaller number. */ + function int min(int a, int b) { + if (a < b){ + return a; + } + return b; + } +} diff --git a/projects/12/MathTest/Math.vm b/projects/12/MathTest/Math.vm new file mode 100755 index 0000000..5f85428 --- /dev/null +++ b/projects/12/MathTest/Math.vm @@ -0,0 +1,388 @@ +function Math.init 1 +push constant 16 +call Array.new 1 +pop static 0 +push static 0 +push constant 0 +push constant 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L0 +push local 0 +push constant 15 +lt +not +if-goto L1 +push local 0 +push constant 1 +add +pop local 0 +push static 0 +push local 0 +push static 0 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +push static 0 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +add +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L0 +label L1 +push constant 0 +return +function Math.abs 0 +push argument 0 +push constant 0 +gt +not +if-goto L2 +push argument 0 +return +goto L3 +label L2 +label L3 +push argument 0 +neg +return +function Math.multiply 5 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 4 +push argument 0 +call Math.abs 1 +pop argument 0 +push argument 1 +call Math.abs 1 +pop argument 1 +push argument 0 +push argument 1 +lt +not +if-goto L4 +push argument 0 +pop local 1 +push argument 1 +pop argument 0 +push local 1 +pop argument 1 +goto L5 +label L4 +label L5 +push argument 1 +push constant 1 +eq +not +if-goto L6 +push local 4 +not +if-goto L7 +push argument 0 +neg +return +goto L8 +label L7 +label L8 +push argument 0 +return +goto L9 +label L6 +label L9 +label L10 +push local 2 +push constant 1 +sub +push argument 1 +push constant 1 +sub +lt +not +if-goto L11 +push static 0 +push local 3 +add +pop pointer 1 +push that 0 +push argument 1 +and +push constant 0 +gt +not +if-goto L12 +push local 0 +push argument 0 +add +pop local 0 +push local 2 +push static 0 +push local 3 +add +pop pointer 1 +push that 0 +add +pop local 2 +goto L13 +label L12 +label L13 +push argument 0 +push argument 0 +add +pop argument 0 +push local 3 +push constant 1 +add +pop local 3 +goto L10 +label L11 +push local 4 +not +if-goto L14 +push local 0 +neg +pop local 0 +goto L15 +label L14 +label L15 +push local 0 +return +function Math.divide 2 +push static 2 +push constant 0 +eq +not +if-goto L16 +push constant 0 +pop static 1 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 1 +push argument 0 +call Math.abs 1 +pop argument 0 +push argument 1 +call Math.abs 1 +pop argument 1 +push argument 1 +push constant 0 +eq +not +if-goto L17 +push constant 3 +call Sys.error 1 +pop temp 0 +goto L18 +label L17 +label L18 +push constant 1 +pop static 2 +goto L19 +label L16 +label L19 +push argument 1 +push argument 0 +gt +push argument 1 +push constant 0 +lt +or +not +if-goto L20 +push constant 0 +return +goto L21 +label L20 +label L21 +push argument 0 +push argument 1 +push argument 1 +add +call Math.divide 2 +pop local 0 +push constant 0 +pop static 2 +push local 0 +call Math.abs 1 +pop local 0 +push local 0 +push constant 1 +and +push constant 1 +eq +not +if-goto L22 +push static 1 +push argument 1 +add +push argument 1 +add +pop static 1 +goto L23 +label L22 +label L23 +push argument 0 +push static 1 +sub +push argument 1 +lt +not +if-goto L24 +push local 1 +not +if-goto L25 +push local 0 +push local 0 +add +neg +return +goto L26 +label L25 +label L26 +push local 0 +push local 0 +add +return +goto L27 +label L24 +push local 1 +not +if-goto L28 +push local 0 +push local 0 +add +push constant 1 +add +neg +return +goto L29 +label L28 +label L29 +push local 0 +push local 0 +add +push constant 1 +add +return +label L27 +function Math.sqrt 4 +push argument 0 +push constant 0 +lt +not +if-goto L30 +push constant 4 +call Sys.error 1 +pop temp 0 +goto L31 +label L30 +label L31 +push constant 7 +pop local 0 +label L32 +push local 0 +push constant 1 +neg +gt +not +if-goto L33 +push local 3 +push static 0 +push local 0 +add +pop pointer 1 +push that 0 +add +pop local 2 +push local 2 +push local 2 +call Math.multiply 2 +pop local 1 +push local 1 +push argument 0 +gt +not +push local 1 +push constant 0 +gt +and +not +if-goto L34 +push local 2 +pop local 3 +goto L35 +label L34 +label L35 +push local 0 +push constant 1 +sub +pop local 0 +goto L32 +label L33 +push local 3 +return +function Math.max 0 +push argument 0 +push argument 1 +gt +not +if-goto L36 +push argument 0 +return +goto L37 +label L36 +label L37 +push argument 1 +return +function Math.min 0 +push argument 0 +push argument 1 +lt +not +if-goto L38 +push argument 0 +return +goto L39 +label L38 +label L39 +push argument 1 +return diff --git a/projects/12/MathTest/MathTest.cmp b/projects/12/MathTest/MathTest.cmp new file mode 100755 index 0000000..703c1be --- /dev/null +++ b/projects/12/MathTest/MathTest.cmp @@ -0,0 +1,2 @@ +|RAM[8000]|RAM[8001]|RAM[8002]|RAM[8003]|RAM[8004]|RAM[8005]|RAM[8006]|RAM[8007]|RAM[8008]|RAM[8009]|RAM[8010]|RAM[8011]|RAM[8012]|RAM[8013]| +| 6 | -180 | -18000 | -18000 | 0 | 3 | -3000 | 0 | 3 | 181 | 123 | 123 | 27 | 32767 | diff --git a/projects/12/MathTest/MathTest.out b/projects/12/MathTest/MathTest.out new file mode 100755 index 0000000..e69de29 diff --git a/projects/12/MathTest/MathTest.tst b/projects/12/MathTest/MathTest.tst new file mode 100755 index 0000000..bac6e6c --- /dev/null +++ b/projects/12/MathTest/MathTest.tst @@ -0,0 +1,15 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/MathTest/MathTest.tst + +load, +output-file MathTest.out, +compare-to MathTest.cmp, +output-list RAM[8000]%D2.6.1 RAM[8001]%D2.6.1 RAM[8002]%D2.6.1 RAM[8003]%D2.6.1 RAM[8004]%D2.6.1 RAM[8005]%D2.6.1 RAM[8006]%D2.6.1 RAM[8007]%D2.6.1 RAM[8008]%D2.6.1 RAM[8009]%D2.6.1 RAM[8010]%D2.6.1 RAM[8011]%D2.6.1 RAM[8012]%D2.6.1 RAM[8013]%D2.6.1; + +repeat 1150000 { + vmstep; +} + +output; diff --git a/projects/12/MathTest/Memory.vm b/projects/12/MathTest/Memory.vm new file mode 100755 index 0000000..8c74b87 --- /dev/null +++ b/projects/12/MathTest/Memory.vm @@ -0,0 +1,376 @@ +function Memory.init 0 +push constant 0 +pop static 0 +push constant 2048 +push static 0 +add +push constant 14334 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2049 +push static 0 +add +push constant 2050 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Memory.peek 0 +push argument 0 +push static 0 +add +pop pointer 1 +push that 0 +return +function Memory.poke 0 +push argument 0 +push static 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Memory.alloc 2 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 5 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 1 +pop argument 0 +label IF_FALSE1 +push constant 2048 +pop local 0 +label WHILE_EXP0 +push local 0 +push constant 16383 +lt +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +lt +and +not +if-goto WHILE_END0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop local 1 +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push constant 0 +eq +push local 1 +push constant 16382 +gt +or +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +push constant 0 +eq +or +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 1 +pop local 0 +goto IF_END2 +label IF_FALSE2 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +push local 1 +push constant 2 +add +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 1 +push local 0 +add +push local 0 +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END3 +label IF_FALSE3 +push constant 1 +push local 0 +add +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END3 +label IF_END2 +goto WHILE_EXP0 +label WHILE_END0 +push local 0 +push argument 0 +add +push constant 16379 +gt +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 6 +call Sys.error 1 +pop temp 0 +label IF_FALSE4 +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +push constant 2 +add +gt +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push argument 0 +push constant 2 +add +push local 0 +add +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +sub +push constant 2 +sub +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 2 +add +eq +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push argument 0 +push constant 3 +add +push local 0 +add +push local 0 +push argument 0 +add +push constant 4 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END6 +label IF_FALSE6 +push argument 0 +push constant 3 +add +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END6 +push constant 1 +push local 0 +add +push local 0 +push argument 0 +add +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_FALSE5 +push constant 0 +push local 0 +add +push constant 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 2 +add +return +function Memory.deAlloc 2 +push argument 0 +push constant 2 +sub +pop local 0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop local 1 +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 2 +sub +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END0 +label IF_FALSE0 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +push local 1 +push constant 2 +add +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 1 +push local 0 +add +push local 0 +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END1 +label IF_FALSE1 +push constant 1 +push local 0 +add +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END1 +label IF_END0 +push constant 0 +return diff --git a/projects/12/MathTest/Output.vm b/projects/12/MathTest/Output.vm new file mode 100755 index 0000000..b8addd7 --- /dev/null +++ b/projects/12/MathTest/Output.vm @@ -0,0 +1,1852 @@ +function Output.init 0 +push constant 16384 +pop static 4 +push constant 0 +not +pop static 2 +push constant 32 +pop static 1 +push constant 0 +pop static 0 +push constant 6 +call String.new 1 +pop static 3 +call Output.initMap 0 +pop temp 0 +call Output.createShiftedMap 0 +pop temp 0 +push constant 0 +return +function Output.initMap 0 +push constant 127 +call Array.new 1 +pop static 5 +push constant 0 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 32 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 33 +push constant 12 +push constant 30 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 34 +push constant 54 +push constant 54 +push constant 20 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 35 +push constant 0 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 36 +push constant 12 +push constant 30 +push constant 51 +push constant 3 +push constant 30 +push constant 48 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 37 +push constant 0 +push constant 0 +push constant 35 +push constant 51 +push constant 24 +push constant 12 +push constant 6 +push constant 51 +push constant 49 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 38 +push constant 12 +push constant 30 +push constant 30 +push constant 12 +push constant 54 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 39 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 40 +push constant 24 +push constant 12 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 41 +push constant 6 +push constant 12 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 42 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 63 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 43 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 63 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 44 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 45 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 46 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 47 +push constant 0 +push constant 0 +push constant 32 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 1 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 48 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 49 +push constant 12 +push constant 14 +push constant 15 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 50 +push constant 30 +push constant 51 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 51 +push constant 30 +push constant 51 +push constant 48 +push constant 48 +push constant 28 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 52 +push constant 16 +push constant 24 +push constant 28 +push constant 26 +push constant 25 +push constant 63 +push constant 24 +push constant 24 +push constant 60 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 53 +push constant 63 +push constant 3 +push constant 3 +push constant 31 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 54 +push constant 28 +push constant 6 +push constant 3 +push constant 3 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 55 +push constant 63 +push constant 49 +push constant 48 +push constant 48 +push constant 24 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 56 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 57 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 24 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 58 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 59 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 60 +push constant 0 +push constant 0 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 61 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 62 +push constant 0 +push constant 0 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 64 +push constant 30 +push constant 51 +push constant 51 +push constant 59 +push constant 59 +push constant 59 +push constant 27 +push constant 3 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 63 +push constant 30 +push constant 51 +push constant 51 +push constant 24 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 65 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 66 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 67 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 68 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 69 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 70 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 71 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 59 +push constant 51 +push constant 51 +push constant 54 +push constant 44 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 72 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 73 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 74 +push constant 60 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 27 +push constant 27 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 75 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 76 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 77 +push constant 33 +push constant 51 +push constant 63 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 78 +push constant 51 +push constant 51 +push constant 55 +push constant 55 +push constant 63 +push constant 59 +push constant 59 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 79 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 80 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 81 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 59 +push constant 30 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 82 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 83 +push constant 30 +push constant 51 +push constant 51 +push constant 6 +push constant 28 +push constant 48 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 84 +push constant 63 +push constant 63 +push constant 45 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 85 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 86 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 87 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 88 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 30 +push constant 30 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 89 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 90 +push constant 63 +push constant 51 +push constant 49 +push constant 24 +push constant 12 +push constant 6 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 91 +push constant 30 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 92 +push constant 0 +push constant 0 +push constant 1 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 48 +push constant 32 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 93 +push constant 30 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 94 +push constant 8 +push constant 28 +push constant 54 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 95 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 96 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 97 +push constant 0 +push constant 0 +push constant 0 +push constant 14 +push constant 24 +push constant 30 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 98 +push constant 3 +push constant 3 +push constant 3 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 99 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 3 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 100 +push constant 48 +push constant 48 +push constant 48 +push constant 60 +push constant 54 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 101 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 63 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 102 +push constant 28 +push constant 54 +push constant 38 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 103 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 104 +push constant 3 +push constant 3 +push constant 3 +push constant 27 +push constant 55 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 105 +push constant 12 +push constant 12 +push constant 0 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 106 +push constant 48 +push constant 48 +push constant 0 +push constant 56 +push constant 48 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 107 +push constant 3 +push constant 3 +push constant 3 +push constant 51 +push constant 27 +push constant 15 +push constant 15 +push constant 27 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 108 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 109 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 63 +push constant 43 +push constant 43 +push constant 43 +push constant 43 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 110 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 111 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 112 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 113 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 114 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 55 +push constant 51 +push constant 3 +push constant 3 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 115 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 6 +push constant 24 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 116 +push constant 4 +push constant 6 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 117 +push constant 0 +push constant 0 +push constant 0 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 118 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 119 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 120 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 121 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 24 +push constant 15 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 122 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 27 +push constant 12 +push constant 6 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 123 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 124 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 125 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 126 +push constant 38 +push constant 45 +push constant 25 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 0 +return +function Output.create 1 +push constant 11 +call Array.new 1 +pop local 0 +push argument 0 +push static 5 +add +push local 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +push local 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 0 +add +push argument 3 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 0 +add +push argument 4 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 0 +add +push argument 5 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 0 +add +push argument 6 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 0 +add +push argument 7 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 7 +push local 0 +add +push argument 8 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 8 +push local 0 +add +push argument 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 9 +push local 0 +add +push argument 10 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 10 +push local 0 +add +push argument 11 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Output.createShiftedMap 4 +push constant 127 +call Array.new 1 +pop static 6 +push constant 0 +pop local 2 +label WHILE_EXP0 +push local 2 +push constant 127 +lt +not +if-goto WHILE_END0 +push local 2 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +push constant 11 +call Array.new 1 +pop local 1 +push local 2 +push static 6 +add +push local 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +pop local 3 +label WHILE_EXP1 +push local 3 +push constant 11 +lt +not +if-goto WHILE_END1 +push local 3 +push local 1 +add +push local 3 +push local 0 +add +pop pointer 1 +push that 0 +push constant 256 +call Math.multiply 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 3 +push constant 1 +add +pop local 3 +goto WHILE_EXP1 +label WHILE_END1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop local 2 +goto IF_END0 +label IF_FALSE0 +push local 2 +push constant 1 +add +pop local 2 +label IF_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.getMap 1 +push argument 0 +push constant 32 +lt +push argument 0 +push constant 126 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +pop argument 0 +label IF_FALSE0 +push static 2 +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +push static 6 +add +pop pointer 1 +push that 0 +pop local 0 +label IF_END1 +push local 0 +return +function Output.drawChar 4 +push argument 0 +call Output.getMap 1 +pop local 2 +push static 1 +pop local 0 +label WHILE_EXP0 +push local 1 +push constant 11 +lt +not +if-goto WHILE_END0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 256 +neg +and +pop local 3 +goto IF_END0 +label IF_FALSE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 255 +and +pop local 3 +label IF_END0 +push local 0 +push static 4 +add +push local 1 +push local 2 +add +pop pointer 1 +push that 0 +push local 3 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 32 +add +pop local 0 +push local 1 +push constant 1 +add +pop local 1 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.moveCursor 0 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 22 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 63 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 20 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push constant 2 +call Math.divide 2 +pop static 0 +push constant 32 +push argument 0 +push constant 352 +call Math.multiply 2 +add +push static 0 +add +pop static 1 +push argument 1 +push static 0 +push constant 2 +call Math.multiply 2 +eq +pop static 2 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return +function Output.printChar 0 +push argument 0 +call String.newLine 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Output.println 0 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +call String.backSpace 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +call Output.backSpace 0 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +call Output.drawChar 1 +pop temp 0 +push static 2 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push static 0 +push constant 1 +add +pop static 0 +push static 1 +push constant 1 +add +pop static 1 +label IF_FALSE2 +push static 0 +push constant 32 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +call Output.println 0 +pop temp 0 +goto IF_END3 +label IF_FALSE3 +push static 2 +not +pop static 2 +label IF_END3 +label IF_END1 +label IF_END0 +push constant 0 +return +function Output.printString 2 +push argument 0 +call String.length 1 +pop local 1 +label WHILE_EXP0 +push local 0 +push local 1 +lt +not +if-goto WHILE_END0 +push argument 0 +push local 0 +call String.charAt 2 +call Output.printChar 1 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.printInt 0 +push static 3 +push argument 0 +call String.setInt 2 +pop temp 0 +push static 3 +call Output.printString 1 +pop temp 0 +push constant 0 +return +function Output.println 0 +push static 1 +push constant 352 +add +push static 0 +sub +pop static 1 +push constant 0 +pop static 0 +push constant 0 +not +pop static 2 +push static 1 +push constant 8128 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop static 1 +label IF_FALSE0 +push constant 0 +return +function Output.backSpace 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push static 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push static 0 +push constant 1 +sub +pop static 0 +push static 1 +push constant 1 +sub +pop static 1 +goto IF_END1 +label IF_FALSE1 +push constant 31 +pop static 0 +push static 1 +push constant 32 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push constant 8128 +pop static 1 +label IF_FALSE2 +push static 1 +push constant 321 +sub +pop static 1 +label IF_END1 +push constant 0 +pop static 2 +goto IF_END0 +label IF_FALSE0 +push constant 0 +not +pop static 2 +label IF_END0 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/MathTest/Screen.vm b/projects/12/MathTest/Screen.vm new file mode 100755 index 0000000..fccafb5 --- /dev/null +++ b/projects/12/MathTest/Screen.vm @@ -0,0 +1,806 @@ +function Screen.init 1 +push constant 16384 +pop static 1 +push constant 0 +not +pop static 2 +push constant 17 +call Array.new 1 +pop static 0 +push constant 0 +push static 0 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 0 +add +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.clearScreen 1 +label WHILE_EXP0 +push local 0 +push constant 8192 +lt +not +if-goto WHILE_END0 +push local 0 +push static 1 +add +push constant 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.updateLocation 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +not +and +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END0 +push constant 0 +return +function Screen.setColor 0 +push argument 0 +pop static 2 +push constant 0 +return +function Screen.drawPixel 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 7 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 0 +push argument 0 +push local 0 +push constant 16 +call Math.multiply 2 +sub +pop local 1 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 0 +add +pop local 2 +push local 2 +push local 1 +push static 0 +add +pop pointer 1 +push that 0 +call Screen.updateLocation 2 +pop temp 0 +push constant 0 +return +function Screen.drawConditional 0 +push argument 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 1 +push argument 0 +call Screen.drawPixel 2 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +label IF_END0 +push constant 0 +return +function Screen.drawLine 11 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 8 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 2 +push argument 0 +sub +call Math.abs 1 +pop local 3 +push argument 3 +push argument 1 +sub +call Math.abs 1 +pop local 2 +push local 3 +push local 2 +lt +pop local 6 +push local 6 +push argument 3 +push argument 1 +lt +and +push local 6 +not +push argument 2 +push argument 0 +lt +and +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +pop local 4 +push argument 2 +pop argument 0 +push local 4 +pop argument 2 +push argument 1 +pop local 4 +push argument 3 +pop argument 1 +push local 4 +pop argument 3 +label IF_FALSE1 +push local 6 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 3 +pop local 4 +push local 2 +pop local 3 +push local 4 +pop local 2 +push argument 1 +pop local 1 +push argument 0 +pop local 0 +push argument 3 +pop local 8 +push argument 0 +push argument 2 +gt +pop local 7 +goto IF_END2 +label IF_FALSE2 +push argument 0 +pop local 1 +push argument 1 +pop local 0 +push argument 2 +pop local 8 +push argument 1 +push argument 3 +gt +pop local 7 +label IF_END2 +push constant 2 +push local 2 +call Math.multiply 2 +push local 3 +sub +pop local 5 +push constant 2 +push local 2 +call Math.multiply 2 +pop local 9 +push constant 2 +push local 2 +push local 3 +sub +call Math.multiply 2 +pop local 10 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 8 +lt +not +if-goto WHILE_END0 +push local 5 +push constant 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 5 +push local 9 +add +pop local 5 +goto IF_END3 +label IF_FALSE3 +push local 5 +push local 10 +add +pop local 5 +push local 7 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 0 +push constant 1 +sub +pop local 0 +goto IF_END4 +label IF_FALSE4 +push local 0 +push constant 1 +add +pop local 0 +label IF_END4 +label IF_END3 +push local 1 +push constant 1 +add +pop local 1 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawRectangle 9 +push argument 0 +push argument 2 +gt +push argument 1 +push argument 3 +gt +or +push argument 0 +push constant 0 +lt +or +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 9 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push argument 0 +push local 3 +push constant 16 +call Math.multiply 2 +sub +pop local 7 +push argument 2 +push constant 16 +call Math.divide 2 +pop local 4 +push argument 2 +push local 4 +push constant 16 +call Math.multiply 2 +sub +pop local 8 +push local 7 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 6 +push local 8 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 5 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 3 +add +pop local 0 +push local 4 +push local 3 +sub +pop local 2 +label WHILE_EXP0 +push argument 1 +push argument 3 +gt +not +not +if-goto WHILE_END0 +push local 0 +push local 2 +add +pop local 1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 5 +push local 6 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 6 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP1 +push local 0 +push local 1 +lt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 1 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +push argument 1 +push constant 1 +add +pop argument 1 +push local 1 +push constant 32 +add +push local 2 +sub +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawHorizontal 11 +push argument 1 +push argument 2 +call Math.min 2 +pop local 7 +push argument 1 +push argument 2 +call Math.max 2 +pop local 8 +push argument 0 +push constant 1 +neg +gt +push argument 0 +push constant 256 +lt +and +push local 7 +push constant 512 +lt +and +push local 8 +push constant 1 +neg +gt +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 7 +push constant 0 +call Math.max 2 +pop local 7 +push local 8 +push constant 511 +call Math.min 2 +pop local 8 +push local 7 +push constant 16 +call Math.divide 2 +pop local 1 +push local 7 +push local 1 +push constant 16 +call Math.multiply 2 +sub +pop local 9 +push local 8 +push constant 16 +call Math.divide 2 +pop local 2 +push local 8 +push local 2 +push constant 16 +call Math.multiply 2 +sub +pop local 10 +push local 9 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 5 +push local 10 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 4 +push argument 0 +push constant 32 +call Math.multiply 2 +push local 1 +add +pop local 0 +push local 2 +push local 1 +sub +pop local 6 +push local 0 +push local 6 +add +pop local 3 +push local 6 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 4 +push local 5 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP0 +push local 0 +push local 3 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +push local 4 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +label IF_FALSE0 +push constant 0 +return +function Screen.drawSymetric 0 +push argument 1 +push argument 3 +sub +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 3 +add +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +sub +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +add +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push constant 0 +return +function Screen.drawCircle 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 12 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push argument 2 +sub +push constant 0 +lt +push argument 0 +push argument 2 +add +push constant 511 +gt +or +push argument 1 +push argument 2 +sub +push constant 0 +lt +or +push argument 1 +push argument 2 +add +push constant 255 +gt +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 13 +call Sys.error 1 +pop temp 0 +label IF_FALSE1 +push argument 2 +pop local 1 +push constant 1 +push argument 2 +sub +pop local 2 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 0 +gt +not +if-goto WHILE_END0 +push local 2 +push constant 0 +lt +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 2 +push constant 2 +push local 0 +call Math.multiply 2 +add +push constant 3 +add +pop local 2 +goto IF_END2 +label IF_FALSE2 +push local 2 +push constant 2 +push local 0 +push local 1 +sub +call Math.multiply 2 +add +push constant 5 +add +pop local 2 +push local 1 +push constant 1 +sub +pop local 1 +label IF_END2 +push local 0 +push constant 1 +add +pop local 0 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return diff --git a/projects/12/MathTest/String.vm b/projects/12/MathTest/String.vm new file mode 100755 index 0000000..9b7577e --- /dev/null +++ b/projects/12/MathTest/String.vm @@ -0,0 +1,393 @@ +function String.new 0 +push constant 3 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 14 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +call Array.new 1 +pop this 1 +label IF_FALSE1 +push argument 0 +pop this 0 +push constant 0 +pop this 2 +push pointer 0 +return +function String.dispose 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 1 +call Array.dispose 1 +pop temp 0 +label IF_FALSE0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function String.length 0 +push argument 0 +pop pointer 0 +push this 2 +return +function String.charAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 15 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +pop pointer 1 +push that 0 +return +function String.setCharAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 16 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function String.appendChar 0 +push argument 0 +pop pointer 0 +push this 2 +push this 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 17 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push this 1 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +push pointer 0 +return +function String.eraseLastChar 0 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 18 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push constant 1 +sub +pop this 2 +push constant 0 +return +function String.intValue 5 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push constant 0 +not +pop local 3 +push constant 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 45 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 4 +push constant 1 +pop local 0 +label IF_FALSE1 +label WHILE_EXP0 +push local 0 +push this 2 +lt +push local 3 +and +not +if-goto WHILE_END0 +push local 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 48 +sub +pop local 2 +push local 2 +push constant 0 +lt +push local 2 +push constant 9 +gt +or +not +pop local 3 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 1 +push constant 10 +call Math.multiply 2 +push local 2 +add +pop local 1 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 1 +neg +pop local 1 +label IF_FALSE3 +push local 1 +return +function String.setInt 4 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push constant 6 +call Array.new 1 +pop local 2 +push argument 1 +push constant 0 +lt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 3 +push argument 1 +neg +pop argument 1 +label IF_FALSE1 +push argument 1 +pop local 1 +label WHILE_EXP0 +push local 1 +push constant 0 +gt +not +if-goto WHILE_END0 +push argument 1 +push constant 10 +call Math.divide 2 +pop local 1 +push local 0 +push local 2 +add +push constant 48 +push argument 1 +push local 1 +push constant 10 +call Math.multiply 2 +sub +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +push local 1 +pop argument 1 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +push local 2 +add +push constant 45 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +push this 0 +push local 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE3 +push local 0 +push constant 0 +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 0 +push this 1 +add +push constant 48 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +pop this 2 +goto IF_END4 +label IF_FALSE4 +push constant 0 +pop this 2 +label WHILE_EXP1 +push this 2 +push local 0 +lt +not +if-goto WHILE_END1 +push this 2 +push this 1 +add +push local 0 +push this 2 +push constant 1 +add +sub +push local 2 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +goto WHILE_EXP1 +label WHILE_END1 +label IF_END4 +push local 2 +call Array.dispose 1 +pop temp 0 +push constant 0 +return +function String.newLine 0 +push constant 128 +return +function String.backSpace 0 +push constant 129 +return +function String.doubleQuote 0 +push constant 34 +return diff --git a/projects/12/MathTest/Sys.vm b/projects/12/MathTest/Sys.vm new file mode 100755 index 0000000..c186dad --- /dev/null +++ b/projects/12/MathTest/Sys.vm @@ -0,0 +1,83 @@ +function Sys.init 0 +call Memory.init 0 +pop temp 0 +call Math.init 0 +pop temp 0 +call Screen.init 0 +pop temp 0 +call Output.init 0 +pop temp 0 +call Keyboard.init 0 +pop temp 0 +call Main.main 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return +function Sys.halt 0 +label WHILE_EXP0 +push constant 0 +not +not +if-goto WHILE_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.wait 1 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 1 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +label WHILE_EXP0 +push argument 0 +push constant 0 +gt +not +if-goto WHILE_END0 +push constant 50 +pop local 0 +label WHILE_EXP1 +push local 0 +push constant 0 +gt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push argument 0 +push constant 1 +sub +pop argument 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.error 0 +push constant 69 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push argument 0 +call Output.printInt 1 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return diff --git a/projects/12/Memory.jack b/projects/12/Memory.jack new file mode 100755 index 0000000..14305f1 --- /dev/null +++ b/projects/12/Memory.jack @@ -0,0 +1,63 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Memory.jack + +/** + * This library provides two services: direct access to the computer's main + * memory (RAM), and allocation and recycling of memory blocks. The Hack RAM + * consists of 32,768 words, each holding a 16-bit binary number. + */ +class Memory { + static Array mem; + /** Initializes the class. */ + function void init() { + let mem = 0; + let mem[2048] = 14334; + let mem[2049] = -1; + return; + } + + /** Returns the RAM value at the given address. */ + function int peek(int address) { + return mem[address]; + } + + /** Sets the RAM value at the given address to the given value. */ + function void poke(int address, int value) { + let mem[address] = value; + return; + } + + /** Finds an available RAM block of the given size and returns + * a reference to its base address. */ + function int alloc(int size) { + var Array current_block; + var int tmp; + let current_block = 2048; + if (size < 0){ + do Sys.error(5); + } + if (size = 0){ + let size = 1; + } + while (current_block[0] < (size + 2)) { + let current_block = current_block[1]; + } + let current_block[0] = current_block[0] - size - 2; + let current_block = current_block + current_block[0] + 2; + let current_block[0] = size; + return current_block + 2; + } + + /** De-allocates the given object (cast as an array) by making + * it available for future allocations. */ + function void deAlloc(Array o) { + var Array current_block; + let current_block = 2048; + let o[1]= current_block[1]; + let current_block[1] = o; + return; + + } +} diff --git a/projects/12/MemoryTest/Array.vm b/projects/12/MemoryTest/Array.vm new file mode 100755 index 0000000..aa4c9e8 --- /dev/null +++ b/projects/12/MemoryTest/Array.vm @@ -0,0 +1,23 @@ +function Array.new 0 +push argument 0 +push constant 0 +gt +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 2 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +call Memory.alloc 1 +return +function Array.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/MemoryTest/Keyboard.vm b/projects/12/MemoryTest/Keyboard.vm new file mode 100755 index 0000000..a806c4e --- /dev/null +++ b/projects/12/MemoryTest/Keyboard.vm @@ -0,0 +1,102 @@ +function Keyboard.init 0 +push constant 0 +return +function Keyboard.keyPressed 0 +push constant 24576 +call Memory.peek 1 +return +function Keyboard.readChar 2 +push constant 0 +call Output.printChar 1 +pop temp 0 +label WHILE_EXP0 +push local 1 +push constant 0 +eq +push local 0 +push constant 0 +gt +or +not +if-goto WHILE_END0 +call Keyboard.keyPressed 0 +pop local 0 +push local 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +pop local 1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +call String.backSpace 0 +call Output.printChar 1 +pop temp 0 +push local 1 +call Output.printChar 1 +pop temp 0 +push local 1 +return +function Keyboard.readLine 5 +push constant 80 +call String.new 1 +pop local 3 +push argument 0 +call Output.printString 1 +pop temp 0 +call String.newLine 0 +pop local 1 +call String.backSpace 0 +pop local 2 +label WHILE_EXP0 +push local 4 +not +not +if-goto WHILE_END0 +call Keyboard.readChar 0 +pop local 0 +push local 0 +push local 1 +eq +pop local 4 +push local 4 +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push local 2 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 3 +call String.eraseLastChar 1 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 3 +push local 0 +call String.appendChar 2 +pop local 3 +label IF_END1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +return +function Keyboard.readInt 2 +push argument 0 +call Keyboard.readLine 1 +pop local 0 +push local 0 +call String.intValue 1 +pop local 1 +push local 0 +call String.dispose 1 +pop temp 0 +push local 1 +return diff --git a/projects/12/MemoryTest/Main.jack b/projects/12/MemoryTest/Main.jack new file mode 100755 index 0000000..a9817f4 --- /dev/null +++ b/projects/12/MemoryTest/Main.jack @@ -0,0 +1,53 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/MemoryTest/Main.jack + +/** Test program for the OS Memory class. */ +class Main { + + /** Performs various memory manipulations. */ + function void main() { + var int temp, err; + var Array a, b, c; + + do Memory.poke(8000, 333); // RAM[8000] = 333 + let temp = Memory.peek(8000); + do Memory.poke(8001, temp + 1); // RAM[8001] = 334 + + let a = Array.new(3); // uses Memory.alloc + let a[2] = 222; + do Memory.poke(8002, a[2]); // RAM[8002] = 222 + + let err = 0; + let b = Array.new(3); + let b[1] = a[2] - 100; + if (b = a) { // Fail compare if b = a + let err = 1; } + do Memory.poke(8003, b[1] + err); // RAM[8003] = 122 + + let err = 0; + let c = Array.new(500); + let c[499] = a[2] - b[1]; + if (c = a) { // Fail compare if c = a + let err = 1; } + if (c = b) { // Fail compare if c = b + let err = err + 10; } + do Memory.poke(8004, c[499]+err); // RAM[8004] = 100 + + do a.dispose(); // uses Memory.deAlloc + do b.dispose(); + + let err = 0; + let b = Array.new(3); + let b[0] = c[499] - 90; + if (b = c) { // Fail compare if b = c + let err = 1; } + do Memory.poke(8005, b[0] + err); // RAM[8005] = 10 + + do c.dispose(); + do b.dispose(); + + return; + } +} diff --git a/projects/12/MemoryTest/Main.vm b/projects/12/MemoryTest/Main.vm new file mode 100755 index 0000000..00c9ad7 --- /dev/null +++ b/projects/12/MemoryTest/Main.vm @@ -0,0 +1,180 @@ +function Main.main 5 +push constant 8000 +push constant 333 +call Memory.poke 2 +pop temp 0 +push constant 8000 +call Memory.peek 1 +pop local 0 +push constant 8001 +push local 0 +push constant 1 +add +call Memory.poke 2 +pop temp 0 +push constant 3 +call Array.new 1 +pop local 2 +push local 2 +push constant 2 +push constant 222 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 8002 +push local 2 +push constant 2 +add +pop pointer 1 +push that 0 +call Memory.poke 2 +pop temp 0 +push constant 0 +pop local 1 +push constant 3 +call Array.new 1 +pop local 3 +push local 3 +push constant 1 +push local 2 +push constant 2 +add +pop pointer 1 +push that 0 +push constant 100 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push local 2 +eq +not +if-goto L0 +push constant 1 +pop local 1 +goto L1 +label L0 +label L1 +push constant 8003 +push local 3 +push constant 1 +add +pop pointer 1 +push that 0 +push local 1 +add +call Memory.poke 2 +pop temp 0 +push constant 0 +pop local 1 +push constant 500 +call Array.new 1 +pop local 4 +push local 4 +push constant 499 +push local 2 +push constant 2 +add +pop pointer 1 +push that 0 +push local 3 +push constant 1 +add +pop pointer 1 +push that 0 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push local 2 +eq +not +if-goto L2 +push constant 1 +pop local 1 +goto L3 +label L2 +label L3 +push local 4 +push local 3 +eq +not +if-goto L4 +push local 1 +push constant 10 +add +pop local 1 +goto L5 +label L4 +label L5 +push constant 8004 +push local 4 +push constant 499 +add +pop pointer 1 +push that 0 +push local 1 +add +call Memory.poke 2 +pop temp 0 +push local 2 +call Array.dispose 1 +pop temp 0 +push local 3 +call Array.dispose 1 +pop temp 0 +push constant 0 +pop local 1 +push constant 3 +call Array.new 1 +pop local 3 +push local 3 +push constant 0 +push local 4 +push constant 499 +add +pop pointer 1 +push that 0 +push constant 90 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push local 4 +eq +not +if-goto L6 +push constant 1 +pop local 1 +goto L7 +label L6 +label L7 +push constant 8005 +push local 3 +push constant 0 +add +pop pointer 1 +push that 0 +push local 1 +add +call Memory.poke 2 +pop temp 0 +push local 4 +call Array.dispose 1 +pop temp 0 +push local 3 +call Array.dispose 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/MemoryTest/Math.vm b/projects/12/MemoryTest/Math.vm new file mode 100755 index 0000000..b660688 --- /dev/null +++ b/projects/12/MemoryTest/Math.vm @@ -0,0 +1,408 @@ +function Math.init 1 +push constant 16 +call Array.new 1 +pop static 1 +push constant 16 +call Array.new 1 +pop static 0 +push constant 0 +push static 0 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 0 +add +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Math.abs 0 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +neg +pop argument 0 +label IF_FALSE0 +push argument 0 +return +function Math.multiply 5 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 4 +push argument 0 +call Math.abs 1 +pop argument 0 +push argument 1 +call Math.abs 1 +pop argument 1 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop local 1 +push argument 1 +pop argument 0 +push local 1 +pop argument 1 +label IF_FALSE0 +label WHILE_EXP0 +push local 2 +push constant 1 +sub +push argument 1 +push constant 1 +sub +lt +not +if-goto WHILE_END0 +push local 3 +push static 0 +add +pop pointer 1 +push that 0 +push argument 1 +and +push constant 0 +eq +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push argument 0 +add +pop local 0 +push local 2 +push local 3 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 2 +label IF_FALSE1 +push argument 0 +push argument 0 +add +pop argument 0 +push local 3 +push constant 1 +add +pop local 3 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +neg +pop local 0 +label IF_FALSE2 +push local 0 +return +function Math.divide 4 +push argument 1 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 3 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 2 +push constant 0 +push static 1 +add +push argument 1 +call Math.abs 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push argument 0 +call Math.abs 1 +pop argument 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +push local 3 +not +and +not +if-goto WHILE_END0 +push constant 32767 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +sub +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +lt +pop local 3 +push local 3 +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push constant 1 +add +push static 1 +add +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +push argument 0 +push constant 1 +sub +gt +pop local 3 +push local 3 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +label IF_FALSE1 +goto WHILE_EXP0 +label WHILE_END0 +label WHILE_EXP1 +push local 0 +push constant 1 +neg +gt +not +if-goto WHILE_END1 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +push argument 0 +push constant 1 +sub +gt +not +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 1 +push local 0 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 1 +push argument 0 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +sub +pop argument 0 +label IF_FALSE3 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 2 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 1 +neg +pop local 1 +label IF_FALSE4 +push local 1 +return +function Math.sqrt 4 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 4 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push constant 7 +pop local 0 +label WHILE_EXP0 +push local 0 +push constant 1 +neg +gt +not +if-goto WHILE_END0 +push local 3 +push local 0 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 1 +push local 1 +push local 1 +call Math.multiply 2 +pop local 2 +push local 2 +push argument 0 +gt +not +push local 2 +push constant 0 +lt +not +and +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 1 +pop local 3 +label IF_FALSE1 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +return +function Math.max 0 +push argument 0 +push argument 1 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop argument 1 +label IF_FALSE0 +push argument 1 +return +function Math.min 0 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop argument 1 +label IF_FALSE0 +push argument 1 +return diff --git a/projects/12/MemoryTest/Memory.jack b/projects/12/MemoryTest/Memory.jack new file mode 100755 index 0000000..14305f1 --- /dev/null +++ b/projects/12/MemoryTest/Memory.jack @@ -0,0 +1,63 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Memory.jack + +/** + * This library provides two services: direct access to the computer's main + * memory (RAM), and allocation and recycling of memory blocks. The Hack RAM + * consists of 32,768 words, each holding a 16-bit binary number. + */ +class Memory { + static Array mem; + /** Initializes the class. */ + function void init() { + let mem = 0; + let mem[2048] = 14334; + let mem[2049] = -1; + return; + } + + /** Returns the RAM value at the given address. */ + function int peek(int address) { + return mem[address]; + } + + /** Sets the RAM value at the given address to the given value. */ + function void poke(int address, int value) { + let mem[address] = value; + return; + } + + /** Finds an available RAM block of the given size and returns + * a reference to its base address. */ + function int alloc(int size) { + var Array current_block; + var int tmp; + let current_block = 2048; + if (size < 0){ + do Sys.error(5); + } + if (size = 0){ + let size = 1; + } + while (current_block[0] < (size + 2)) { + let current_block = current_block[1]; + } + let current_block[0] = current_block[0] - size - 2; + let current_block = current_block + current_block[0] + 2; + let current_block[0] = size; + return current_block + 2; + } + + /** De-allocates the given object (cast as an array) by making + * it available for future allocations. */ + function void deAlloc(Array o) { + var Array current_block; + let current_block = 2048; + let o[1]= current_block[1]; + let current_block[1] = o; + return; + + } +} diff --git a/projects/12/MemoryTest/Memory.vm b/projects/12/MemoryTest/Memory.vm new file mode 100755 index 0000000..a19cd86 --- /dev/null +++ b/projects/12/MemoryTest/Memory.vm @@ -0,0 +1,147 @@ +function Memory.init 0 +push constant 0 +pop static 0 +push static 0 +push constant 2048 +push constant 14334 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push static 0 +push constant 2049 +push constant 1 +neg +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function Memory.peek 0 +push static 0 +push argument 0 +add +pop pointer 1 +push that 0 +return +function Memory.poke 0 +push static 0 +push argument 0 +push argument 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function Memory.alloc 2 +push constant 2048 +pop local 0 +push argument 0 +push constant 0 +lt +not +if-goto L0 +push constant 5 +call Sys.error 1 +pop temp 0 +goto L1 +label L0 +label L1 +push argument 0 +push constant 0 +eq +not +if-goto L2 +push constant 1 +pop argument 0 +goto L3 +label L2 +label L3 +label L4 +push local 0 +push constant 0 +add +pop pointer 1 +push that 0 +push argument 0 +push constant 2 +add +lt +not +if-goto L5 +push local 0 +push constant 1 +add +pop pointer 1 +push that 0 +pop local 0 +goto L4 +label L5 +push local 0 +push constant 0 +push local 0 +push constant 0 +add +pop pointer 1 +push that 0 +push argument 0 +sub +push constant 2 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push local 0 +push constant 0 +add +pop pointer 1 +push that 0 +add +push constant 2 +add +pop local 0 +push local 0 +push constant 0 +push argument 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 2 +add +return +function Memory.deAlloc 1 +push constant 2048 +pop local 0 +push argument 0 +push constant 1 +push local 0 +push constant 1 +add +pop pointer 1 +push that 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 1 +push argument 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return diff --git a/projects/12/MemoryTest/MemoryDiag/Main.jack b/projects/12/MemoryTest/MemoryDiag/Main.jack new file mode 100755 index 0000000..de439d0 --- /dev/null +++ b/projects/12/MemoryTest/MemoryDiag/Main.jack @@ -0,0 +1,183 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/MemoryTest/Main.jack + +/** Test program for the OS Memory class. */ +class Main { + + /** Test Memory.peek(), poke(), alloc() and deAlloc(). + * + * This test is also a diagnostic. RAM[17000] is incremented before and + * after every call so that the failure point can be accurately determined + * when using command line testing. Return values from all alloc() calls + * are also stored in the test results to aid debugging. + */ + function void main() { + var int temp; + var Array a, b, c, out; + + let out = 17000; // Address where test results will be stored. + + // Test poke() and peek(). + + let out[0] = 10; // poke test + do Memory.poke(out + 1, 333); // RAM[17001] = 333 + + let out[0] = 11; // peek test + let temp = Memory.peek(out + 1); + let out[2] = temp + 1; // RAM[17002] = 334 + let out[0] = 12; // peek/poke test complete + + // Allocate a memory block. + // Validate that the returned block is entirely within the heap, + // Test aborts if the block is not valid. + + let out[0] = 20; + let a = Memory.alloc(20); + let out[3] = a; // RAM[17003] = block address + + let out[0] = 21; + do Main.checkRange(a, 20); + let out[0] = 22; + + // Allocate a SMALLER memory block. + // Validate that the returned block is entirely within the heap, + // and that it does not overlap block 'a'. + // Test aborts if the block is not valid or overlaps. + // + // Common failure: first block was not removed from free list so space + // for this block was found within the first block. + + let out[0] = 30; + let b = Memory.alloc(3); + let out[4] = b; // RAM[17004] = block address + + let out[0] = 31; + do Main.checkRange(b, 3); + let out[0] = 32; + do Main.checkOverlap(b, 3, a, 3); + let out[0] = 33; + + // Allocate a memory block. + // Validate that the returned block is entirely within the heap, + // and that it does not overlap blocks 'a' or 'b'. + // Test aborts if the block is not valid or overlaps. + + let out[0] = 40; + let c = Memory.alloc(500); + let out[5] = c; // RAM[17005] = block address + + let out[0] = 41; + do Main.checkRange(c, 500); + let out[0] = 42; + do Main.checkOverlap(c, 500, a, 3); + let out[0] = 43; + do Main.checkOverlap(c, 500, b, 3); + let out[0] = 44; + + // Deallocate blocks 'a' and 'b', retaining 'c'. + // + // Common failure: free list corrupted by deAlloc(). + + let out[0] = 50; + do Memory.deAlloc(a); + + let out[0] = 51; + do Memory.deAlloc(b); + let out[0] = 52; + + // Allocate a memory block. + // Validate that the returned block is entirely within the heap, + // and that it does not overlap blocks 'c'. + // Test aborts if the block is not valid or overlaps. + // + // Common failure: free list corrupted by deAlloc(). + + let out[0] = 60; + let b = Memory.alloc(3); + let out[6] = b; // RAM[17006] = block address + + let out[0] = 61; + do Main.checkRange(b, 3); + let out[0] = 62; + do Main.checkOverlap(b, 3, c, 500); + let out[0] = 63; + + // Deallocate blocks 'b' and 'c'. + + let out[0] = 70; + do Memory.deAlloc(c); + + let out[0] = 71; + do Memory.deAlloc(b); + let out[0] = 72; + + // Test that deallocated blocks are placed on the free list and can + // be reused. + + let out[0] = 70; + let a = Memory.alloc(8000); + let out[7] = a; // RAM[17007] = block address + + let out[0] = 71; + do Main.checkRange(a, 8000); + + let out[0] = 72; + do Memory.deAlloc(a); + + let out[0] = 73; + let a = Memory.alloc(7000); + + let out[0] = 74; + do Main.checkRange(a, 7000); + + let out[0] = 75; + do Memory.deAlloc(a); + let out[8] = a; // RAM[17008] = block address + + // Test complete. + let out[0] = 100; + + // At this point all allocated blocks have been deallocated. + // + // You can inspect the free list and confirm that all of the heap is + // contained in the free segments. + // + // If you implemented defragmentation in dealloc(), the free list + // should contain only one segment, consisting of the entire heap. + + return; + } + + + /** Check that block a(a_len) is in the heap. + * + * If the block begins or ends outside of the heap, calls Sys.halt() + */ + function void checkRange(int a, int a_len) { + var int a_high; + let a_high = (a + a_len)-1; + if ((a < 2048) | ((a_high) > 16383)) { + // Block is not entirely within heap. + do Sys.halt(); + } + return; + } + + /** Check that block a(a_len) does not overlap block b(b_len). + * Assumes that both blocks have been range checked. + * + * If the blocks overlap, calls Sys.halt() + */ + function void checkOverlap(int a, int a_len, int b, int b_len) { + var int a_high, b_high; + let a_high = (a + a_len)-1; + let b_high = (b + b_len)-1; + if ( ~ ((a > b_high) | (a_high < b))) { + // Block overlaps excluded range. + do Sys.halt(); + } + return; + } +} diff --git a/projects/12/MemoryTest/MemoryDiag/Main.vm b/projects/12/MemoryTest/MemoryDiag/Main.vm new file mode 100755 index 0000000..11ca0ba --- /dev/null +++ b/projects/12/MemoryTest/MemoryDiag/Main.vm @@ -0,0 +1,467 @@ +function Main.main 5 +push constant 17000 +pop local 4 +push local 4 +push constant 0 +push constant 10 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 1 +add +push constant 333 +call Memory.poke 2 +pop temp 0 +push local 4 +push constant 0 +push constant 11 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 1 +add +call Memory.peek 1 +pop local 0 +push local 4 +push constant 2 +push local 0 +push constant 1 +add +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 12 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 20 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 20 +call Memory.alloc 1 +pop local 1 +push local 4 +push constant 3 +push local 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 21 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +push constant 20 +call Main.checkRange 2 +pop temp 0 +push local 4 +push constant 0 +push constant 22 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 30 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 3 +call Memory.alloc 1 +pop local 2 +push local 4 +push constant 4 +push local 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 31 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +push constant 3 +call Main.checkRange 2 +pop temp 0 +push local 4 +push constant 0 +push constant 32 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +push constant 3 +push local 1 +push constant 3 +call Main.checkOverlap 4 +pop temp 0 +push local 4 +push constant 0 +push constant 33 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 40 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 500 +call Memory.alloc 1 +pop local 3 +push local 4 +push constant 5 +push local 3 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 41 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push constant 500 +call Main.checkRange 2 +pop temp 0 +push local 4 +push constant 0 +push constant 42 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push constant 500 +push local 1 +push constant 3 +call Main.checkOverlap 4 +pop temp 0 +push local 4 +push constant 0 +push constant 43 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push constant 500 +push local 2 +push constant 3 +call Main.checkOverlap 4 +pop temp 0 +push local 4 +push constant 0 +push constant 44 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 50 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +call Memory.deAlloc 1 +pop temp 0 +push local 4 +push constant 0 +push constant 51 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +call Memory.deAlloc 1 +pop temp 0 +push local 4 +push constant 0 +push constant 52 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 60 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 3 +call Memory.alloc 1 +pop local 2 +push local 4 +push constant 6 +push local 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 61 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +push constant 3 +call Main.checkRange 2 +pop temp 0 +push local 4 +push constant 0 +push constant 62 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +push constant 3 +push local 3 +push constant 500 +call Main.checkOverlap 4 +pop temp 0 +push local 4 +push constant 0 +push constant 63 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 70 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +call Memory.deAlloc 1 +pop temp 0 +push local 4 +push constant 0 +push constant 71 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 2 +call Memory.deAlloc 1 +pop temp 0 +push local 4 +push constant 0 +push constant 72 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 70 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 8000 +call Memory.alloc 1 +pop local 1 +push local 4 +push constant 7 +push local 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 71 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +push constant 8000 +call Main.checkRange 2 +pop temp 0 +push local 4 +push constant 0 +push constant 72 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +call Memory.deAlloc 1 +pop temp 0 +push local 4 +push constant 0 +push constant 73 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 7000 +call Memory.alloc 1 +pop local 1 +push local 4 +push constant 0 +push constant 74 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +push constant 7000 +call Main.checkRange 2 +pop temp 0 +push local 4 +push constant 0 +push constant 75 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 1 +call Memory.deAlloc 1 +pop temp 0 +push local 4 +push constant 8 +push local 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 4 +push constant 0 +push constant 100 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function Main.checkRange 1 +push argument 0 +push argument 1 +add +push constant 1 +sub +pop local 0 +push argument 0 +push constant 2048 +lt +push local 0 +push constant 16383 +gt +or +not +if-goto L0 +call Sys.halt 0 +pop temp 0 +goto L1 +label L0 +label L1 +push constant 0 +return +function Main.checkOverlap 2 +push argument 0 +push argument 1 +add +push constant 1 +sub +pop local 0 +push argument 2 +push argument 3 +add +push constant 1 +sub +pop local 1 +push argument 0 +push local 1 +gt +push local 0 +push argument 2 +lt +or +not +not +if-goto L2 +call Sys.halt 0 +pop temp 0 +goto L3 +label L2 +label L3 +push constant 0 +return diff --git a/projects/12/MemoryTest/MemoryDiag/MemoryDiag.cmp b/projects/12/MemoryTest/MemoryDiag/MemoryDiag.cmp new file mode 100755 index 0000000..808e2ce --- /dev/null +++ b/projects/12/MemoryTest/MemoryDiag/MemoryDiag.cmp @@ -0,0 +1,2 @@ +|RAM[17000|RAM[17001|RAM[17002|RAM[17003|RAM[17004|RAM[17005|RAM[17006|RAM[17007|RAM[17008| +| 100 | 333 | 334 |*********|*********|*********|*********|*********|*********| diff --git a/projects/12/MemoryTest/MemoryDiag/MemoryDiag.tst b/projects/12/MemoryTest/MemoryDiag/MemoryDiag.tst new file mode 100755 index 0000000..94cd921 --- /dev/null +++ b/projects/12/MemoryTest/MemoryDiag/MemoryDiag.tst @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/MemoryTest/MemoryDiag/MemoryDiag.tst + +echo "At the end of this test it is normal to see some pixels set on the screen"; +load, +output-file MemoryDiag.out, +compare-to MemoryDiag.cmp, +output-list RAM[17000]%D2.6.1 RAM[17001]%D2.6.1 RAM[17002]%D2.6.1 + RAM[17003]%D2.6.1 RAM[17004]%D2.6.1 RAM[17005]%D2.6.1 RAM[17006]%D2.6.1 + RAM[17007]%D2.6.1 RAM[17008]%D2.6.1; + +repeat 1000000 { + vmstep; +} + +output; diff --git a/projects/12/MemoryTest/MemoryDiag/README.html b/projects/12/MemoryTest/MemoryDiag/README.html new file mode 100755 index 0000000..587847e --- /dev/null +++ b/projects/12/MemoryTest/MemoryDiag/README.html @@ -0,0 +1,55 @@ + +

MemoryDiag is both a pass/fail test and a diagnostic.

+

+MemoryDiag tests the following: +

    +
  1. Memory.peek() and Memory.poke() read from and write to the specified memory address.
  2. +
  3. Memory.alloc() returns RAM blocks that are fully contained within the heap address range 2048-16383.
  4. +
  5. Memory.alloc() does not return RAM blocks that overlap each other.
  6. +
  7. RAM blocks deallocated by Memory.deAlloc() are made available for Memory.alloc() to reuse.
  8. +
+The block reuse test allocates and deallocates an 8000 word block. It then tries to allocates a 7000 word block which must be allocated from the deallocated 8000 word block. If the 8000 word block is not available for reuse, there will only be about 6300 words available in the heap so you will get an ERR6. +

+At the end of this test it is normal to see some pixels set on the screen. This is because the results of the test are written to RAM[17000] – RAM[17008] which is in the Screen memory. MemoryDiag does not put its results in the first 16K of RAM because it must not interfere with the Memory.jack that is being tested. + + +

Using MemoryDiag as a diagnostic

+ +RAM[17000] is set to a unique value before every system call and address validation. This allows the exact failure location in the test to be identified when automated testing is used. At the end of the test, RAM[17000] is set to 100. +

+When the test fails to compare, look at the MemoryDiag.out file and note the RAM[17000] value. This is the test step that failed. Look through the Main.jack code and find the corresponding
+  let out[0] = step;
+statement. The function immediately following this statement is where the failure occurred. +

+For example, if RAM[17000] is 51, the
+  do Memory.deAlloc(b);
+call did not return. Either there was a simulation error like a bad address or deAlloc() got stuck in a loop. + + +

Sample MemoryDiag output files

+ +Note that RAM[17003] – RAM[17008] are "don't care" values in the MemoryDiag.cmp file. +

+Supplied Memory.vm passes: +

+|RAM[17000|RAM[17001|RAM[17002|RAM[17003|RAM[17004|RAM[17005|RAM[17006|RAM[17007|RAM[17008|
+|     100 |     333 |     334 |    2050 |    2072 |    2077 |    2050 |    2050 |    2050 |
+
+Memory.Jack using the Coursera implementation passes: +
+|RAM[17000|RAM[17001|RAM[17002|RAM[17003|RAM[17004|RAM[17005|RAM[17006|RAM[17007|RAM[17008|
+|     100 |     333 |     334 |   16364 |   16359 |   15857 |   15852 |    7850 |    8850 |
+
+Broken Memory.jack fails (alloc() returns duplicate block address): +
+|RAM[17000|RAM[17001|RAM[17002|RAM[17003|RAM[17004|RAM[17005|RAM[17006|RAM[17007|RAM[17008|
+|      32 |     333 |     334 |    2050 |    2050 |       0 |       0 |       0 |       0 |
+
+Broken Memory.jack fails (deAlloc() does not recycle memory blocks): +
+|RAM[17000|RAM[17001|RAM[17002|RAM[17003|RAM[17004|RAM[17005|RAM[17006|RAM[17007|RAM[17008|
+|      73 |     333 |     334 |   16364 |   16359 |   15857 |   15852 |    7850 |       0 |
+
+ + +

\ No newline at end of file diff --git a/projects/12/MemoryTest/MemoryTest.cmp b/projects/12/MemoryTest/MemoryTest.cmp new file mode 100755 index 0000000..057958b --- /dev/null +++ b/projects/12/MemoryTest/MemoryTest.cmp @@ -0,0 +1,2 @@ +|RAM[8000]|RAM[8001]|RAM[8002]|RAM[8003]|RAM[8004]|RAM[8005]| +| 333 | 334 | 222 | 122 | 100 | 10 | diff --git a/projects/12/MemoryTest/MemoryTest.out b/projects/12/MemoryTest/MemoryTest.out new file mode 100755 index 0000000..057958b --- /dev/null +++ b/projects/12/MemoryTest/MemoryTest.out @@ -0,0 +1,2 @@ +|RAM[8000]|RAM[8001]|RAM[8002]|RAM[8003]|RAM[8004]|RAM[8005]| +| 333 | 334 | 222 | 122 | 100 | 10 | diff --git a/projects/12/MemoryTest/MemoryTest.tst b/projects/12/MemoryTest/MemoryTest.tst new file mode 100755 index 0000000..1da34fd --- /dev/null +++ b/projects/12/MemoryTest/MemoryTest.tst @@ -0,0 +1,15 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/MemoryTest/MemoryTest.tst + +load, +output-file MemoryTest.out, +compare-to MemoryTest.cmp, +output-list RAM[8000]%D2.6.1 RAM[8001]%D2.6.1 RAM[8002]%D2.6.1 RAM[8003]%D2.6.1 RAM[8004]%D2.6.1 RAM[8005]%D2.6.1; + +repeat 1000000 { + vmstep; +} + +output; diff --git a/projects/12/MemoryTest/Output.vm b/projects/12/MemoryTest/Output.vm new file mode 100755 index 0000000..b8addd7 --- /dev/null +++ b/projects/12/MemoryTest/Output.vm @@ -0,0 +1,1852 @@ +function Output.init 0 +push constant 16384 +pop static 4 +push constant 0 +not +pop static 2 +push constant 32 +pop static 1 +push constant 0 +pop static 0 +push constant 6 +call String.new 1 +pop static 3 +call Output.initMap 0 +pop temp 0 +call Output.createShiftedMap 0 +pop temp 0 +push constant 0 +return +function Output.initMap 0 +push constant 127 +call Array.new 1 +pop static 5 +push constant 0 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 32 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 33 +push constant 12 +push constant 30 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 34 +push constant 54 +push constant 54 +push constant 20 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 35 +push constant 0 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 36 +push constant 12 +push constant 30 +push constant 51 +push constant 3 +push constant 30 +push constant 48 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 37 +push constant 0 +push constant 0 +push constant 35 +push constant 51 +push constant 24 +push constant 12 +push constant 6 +push constant 51 +push constant 49 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 38 +push constant 12 +push constant 30 +push constant 30 +push constant 12 +push constant 54 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 39 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 40 +push constant 24 +push constant 12 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 41 +push constant 6 +push constant 12 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 42 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 63 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 43 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 63 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 44 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 45 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 46 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 47 +push constant 0 +push constant 0 +push constant 32 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 1 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 48 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 49 +push constant 12 +push constant 14 +push constant 15 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 50 +push constant 30 +push constant 51 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 51 +push constant 30 +push constant 51 +push constant 48 +push constant 48 +push constant 28 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 52 +push constant 16 +push constant 24 +push constant 28 +push constant 26 +push constant 25 +push constant 63 +push constant 24 +push constant 24 +push constant 60 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 53 +push constant 63 +push constant 3 +push constant 3 +push constant 31 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 54 +push constant 28 +push constant 6 +push constant 3 +push constant 3 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 55 +push constant 63 +push constant 49 +push constant 48 +push constant 48 +push constant 24 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 56 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 57 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 24 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 58 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 59 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 60 +push constant 0 +push constant 0 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 61 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 62 +push constant 0 +push constant 0 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 64 +push constant 30 +push constant 51 +push constant 51 +push constant 59 +push constant 59 +push constant 59 +push constant 27 +push constant 3 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 63 +push constant 30 +push constant 51 +push constant 51 +push constant 24 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 65 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 66 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 67 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 68 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 69 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 70 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 71 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 59 +push constant 51 +push constant 51 +push constant 54 +push constant 44 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 72 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 73 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 74 +push constant 60 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 27 +push constant 27 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 75 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 76 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 77 +push constant 33 +push constant 51 +push constant 63 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 78 +push constant 51 +push constant 51 +push constant 55 +push constant 55 +push constant 63 +push constant 59 +push constant 59 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 79 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 80 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 81 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 59 +push constant 30 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 82 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 83 +push constant 30 +push constant 51 +push constant 51 +push constant 6 +push constant 28 +push constant 48 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 84 +push constant 63 +push constant 63 +push constant 45 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 85 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 86 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 87 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 88 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 30 +push constant 30 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 89 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 90 +push constant 63 +push constant 51 +push constant 49 +push constant 24 +push constant 12 +push constant 6 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 91 +push constant 30 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 92 +push constant 0 +push constant 0 +push constant 1 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 48 +push constant 32 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 93 +push constant 30 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 94 +push constant 8 +push constant 28 +push constant 54 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 95 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 96 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 97 +push constant 0 +push constant 0 +push constant 0 +push constant 14 +push constant 24 +push constant 30 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 98 +push constant 3 +push constant 3 +push constant 3 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 99 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 3 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 100 +push constant 48 +push constant 48 +push constant 48 +push constant 60 +push constant 54 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 101 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 63 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 102 +push constant 28 +push constant 54 +push constant 38 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 103 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 104 +push constant 3 +push constant 3 +push constant 3 +push constant 27 +push constant 55 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 105 +push constant 12 +push constant 12 +push constant 0 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 106 +push constant 48 +push constant 48 +push constant 0 +push constant 56 +push constant 48 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 107 +push constant 3 +push constant 3 +push constant 3 +push constant 51 +push constant 27 +push constant 15 +push constant 15 +push constant 27 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 108 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 109 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 63 +push constant 43 +push constant 43 +push constant 43 +push constant 43 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 110 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 111 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 112 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 113 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 114 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 55 +push constant 51 +push constant 3 +push constant 3 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 115 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 6 +push constant 24 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 116 +push constant 4 +push constant 6 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 117 +push constant 0 +push constant 0 +push constant 0 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 118 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 119 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 120 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 121 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 24 +push constant 15 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 122 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 27 +push constant 12 +push constant 6 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 123 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 124 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 125 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 126 +push constant 38 +push constant 45 +push constant 25 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 0 +return +function Output.create 1 +push constant 11 +call Array.new 1 +pop local 0 +push argument 0 +push static 5 +add +push local 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +push local 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 0 +add +push argument 3 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 0 +add +push argument 4 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 0 +add +push argument 5 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 0 +add +push argument 6 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 0 +add +push argument 7 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 7 +push local 0 +add +push argument 8 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 8 +push local 0 +add +push argument 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 9 +push local 0 +add +push argument 10 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 10 +push local 0 +add +push argument 11 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Output.createShiftedMap 4 +push constant 127 +call Array.new 1 +pop static 6 +push constant 0 +pop local 2 +label WHILE_EXP0 +push local 2 +push constant 127 +lt +not +if-goto WHILE_END0 +push local 2 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +push constant 11 +call Array.new 1 +pop local 1 +push local 2 +push static 6 +add +push local 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +pop local 3 +label WHILE_EXP1 +push local 3 +push constant 11 +lt +not +if-goto WHILE_END1 +push local 3 +push local 1 +add +push local 3 +push local 0 +add +pop pointer 1 +push that 0 +push constant 256 +call Math.multiply 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 3 +push constant 1 +add +pop local 3 +goto WHILE_EXP1 +label WHILE_END1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop local 2 +goto IF_END0 +label IF_FALSE0 +push local 2 +push constant 1 +add +pop local 2 +label IF_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.getMap 1 +push argument 0 +push constant 32 +lt +push argument 0 +push constant 126 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +pop argument 0 +label IF_FALSE0 +push static 2 +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +push static 6 +add +pop pointer 1 +push that 0 +pop local 0 +label IF_END1 +push local 0 +return +function Output.drawChar 4 +push argument 0 +call Output.getMap 1 +pop local 2 +push static 1 +pop local 0 +label WHILE_EXP0 +push local 1 +push constant 11 +lt +not +if-goto WHILE_END0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 256 +neg +and +pop local 3 +goto IF_END0 +label IF_FALSE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 255 +and +pop local 3 +label IF_END0 +push local 0 +push static 4 +add +push local 1 +push local 2 +add +pop pointer 1 +push that 0 +push local 3 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 32 +add +pop local 0 +push local 1 +push constant 1 +add +pop local 1 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.moveCursor 0 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 22 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 63 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 20 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push constant 2 +call Math.divide 2 +pop static 0 +push constant 32 +push argument 0 +push constant 352 +call Math.multiply 2 +add +push static 0 +add +pop static 1 +push argument 1 +push static 0 +push constant 2 +call Math.multiply 2 +eq +pop static 2 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return +function Output.printChar 0 +push argument 0 +call String.newLine 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Output.println 0 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +call String.backSpace 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +call Output.backSpace 0 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +call Output.drawChar 1 +pop temp 0 +push static 2 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push static 0 +push constant 1 +add +pop static 0 +push static 1 +push constant 1 +add +pop static 1 +label IF_FALSE2 +push static 0 +push constant 32 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +call Output.println 0 +pop temp 0 +goto IF_END3 +label IF_FALSE3 +push static 2 +not +pop static 2 +label IF_END3 +label IF_END1 +label IF_END0 +push constant 0 +return +function Output.printString 2 +push argument 0 +call String.length 1 +pop local 1 +label WHILE_EXP0 +push local 0 +push local 1 +lt +not +if-goto WHILE_END0 +push argument 0 +push local 0 +call String.charAt 2 +call Output.printChar 1 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.printInt 0 +push static 3 +push argument 0 +call String.setInt 2 +pop temp 0 +push static 3 +call Output.printString 1 +pop temp 0 +push constant 0 +return +function Output.println 0 +push static 1 +push constant 352 +add +push static 0 +sub +pop static 1 +push constant 0 +pop static 0 +push constant 0 +not +pop static 2 +push static 1 +push constant 8128 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop static 1 +label IF_FALSE0 +push constant 0 +return +function Output.backSpace 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push static 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push static 0 +push constant 1 +sub +pop static 0 +push static 1 +push constant 1 +sub +pop static 1 +goto IF_END1 +label IF_FALSE1 +push constant 31 +pop static 0 +push static 1 +push constant 32 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push constant 8128 +pop static 1 +label IF_FALSE2 +push static 1 +push constant 321 +sub +pop static 1 +label IF_END1 +push constant 0 +pop static 2 +goto IF_END0 +label IF_FALSE0 +push constant 0 +not +pop static 2 +label IF_END0 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/MemoryTest/README.txt b/projects/12/MemoryTest/README.txt new file mode 100755 index 0000000..15ad0c8 --- /dev/null +++ b/projects/12/MemoryTest/README.txt @@ -0,0 +1,9 @@ +There are some specific wrong values that indicate that your Memory.jack +returned identical pointers to allocated segments. Look at Main.jack to +see where the pointers a, b and c are used. + +RAM[8003] = 123 b = a +RAM[8004] = 101 c = a +RAM[8004] = 110 c = b +RAM[8004] = 111 c = a and c = b +RAM[8005] = 11 new b = c diff --git a/projects/12/MemoryTest/Screen.vm b/projects/12/MemoryTest/Screen.vm new file mode 100755 index 0000000..fccafb5 --- /dev/null +++ b/projects/12/MemoryTest/Screen.vm @@ -0,0 +1,806 @@ +function Screen.init 1 +push constant 16384 +pop static 1 +push constant 0 +not +pop static 2 +push constant 17 +call Array.new 1 +pop static 0 +push constant 0 +push static 0 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 0 +add +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.clearScreen 1 +label WHILE_EXP0 +push local 0 +push constant 8192 +lt +not +if-goto WHILE_END0 +push local 0 +push static 1 +add +push constant 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.updateLocation 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +not +and +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END0 +push constant 0 +return +function Screen.setColor 0 +push argument 0 +pop static 2 +push constant 0 +return +function Screen.drawPixel 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 7 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 0 +push argument 0 +push local 0 +push constant 16 +call Math.multiply 2 +sub +pop local 1 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 0 +add +pop local 2 +push local 2 +push local 1 +push static 0 +add +pop pointer 1 +push that 0 +call Screen.updateLocation 2 +pop temp 0 +push constant 0 +return +function Screen.drawConditional 0 +push argument 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 1 +push argument 0 +call Screen.drawPixel 2 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +label IF_END0 +push constant 0 +return +function Screen.drawLine 11 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 8 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 2 +push argument 0 +sub +call Math.abs 1 +pop local 3 +push argument 3 +push argument 1 +sub +call Math.abs 1 +pop local 2 +push local 3 +push local 2 +lt +pop local 6 +push local 6 +push argument 3 +push argument 1 +lt +and +push local 6 +not +push argument 2 +push argument 0 +lt +and +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +pop local 4 +push argument 2 +pop argument 0 +push local 4 +pop argument 2 +push argument 1 +pop local 4 +push argument 3 +pop argument 1 +push local 4 +pop argument 3 +label IF_FALSE1 +push local 6 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 3 +pop local 4 +push local 2 +pop local 3 +push local 4 +pop local 2 +push argument 1 +pop local 1 +push argument 0 +pop local 0 +push argument 3 +pop local 8 +push argument 0 +push argument 2 +gt +pop local 7 +goto IF_END2 +label IF_FALSE2 +push argument 0 +pop local 1 +push argument 1 +pop local 0 +push argument 2 +pop local 8 +push argument 1 +push argument 3 +gt +pop local 7 +label IF_END2 +push constant 2 +push local 2 +call Math.multiply 2 +push local 3 +sub +pop local 5 +push constant 2 +push local 2 +call Math.multiply 2 +pop local 9 +push constant 2 +push local 2 +push local 3 +sub +call Math.multiply 2 +pop local 10 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 8 +lt +not +if-goto WHILE_END0 +push local 5 +push constant 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 5 +push local 9 +add +pop local 5 +goto IF_END3 +label IF_FALSE3 +push local 5 +push local 10 +add +pop local 5 +push local 7 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 0 +push constant 1 +sub +pop local 0 +goto IF_END4 +label IF_FALSE4 +push local 0 +push constant 1 +add +pop local 0 +label IF_END4 +label IF_END3 +push local 1 +push constant 1 +add +pop local 1 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawRectangle 9 +push argument 0 +push argument 2 +gt +push argument 1 +push argument 3 +gt +or +push argument 0 +push constant 0 +lt +or +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 9 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push argument 0 +push local 3 +push constant 16 +call Math.multiply 2 +sub +pop local 7 +push argument 2 +push constant 16 +call Math.divide 2 +pop local 4 +push argument 2 +push local 4 +push constant 16 +call Math.multiply 2 +sub +pop local 8 +push local 7 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 6 +push local 8 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 5 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 3 +add +pop local 0 +push local 4 +push local 3 +sub +pop local 2 +label WHILE_EXP0 +push argument 1 +push argument 3 +gt +not +not +if-goto WHILE_END0 +push local 0 +push local 2 +add +pop local 1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 5 +push local 6 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 6 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP1 +push local 0 +push local 1 +lt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 1 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +push argument 1 +push constant 1 +add +pop argument 1 +push local 1 +push constant 32 +add +push local 2 +sub +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawHorizontal 11 +push argument 1 +push argument 2 +call Math.min 2 +pop local 7 +push argument 1 +push argument 2 +call Math.max 2 +pop local 8 +push argument 0 +push constant 1 +neg +gt +push argument 0 +push constant 256 +lt +and +push local 7 +push constant 512 +lt +and +push local 8 +push constant 1 +neg +gt +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 7 +push constant 0 +call Math.max 2 +pop local 7 +push local 8 +push constant 511 +call Math.min 2 +pop local 8 +push local 7 +push constant 16 +call Math.divide 2 +pop local 1 +push local 7 +push local 1 +push constant 16 +call Math.multiply 2 +sub +pop local 9 +push local 8 +push constant 16 +call Math.divide 2 +pop local 2 +push local 8 +push local 2 +push constant 16 +call Math.multiply 2 +sub +pop local 10 +push local 9 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 5 +push local 10 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 4 +push argument 0 +push constant 32 +call Math.multiply 2 +push local 1 +add +pop local 0 +push local 2 +push local 1 +sub +pop local 6 +push local 0 +push local 6 +add +pop local 3 +push local 6 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 4 +push local 5 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP0 +push local 0 +push local 3 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +push local 4 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +label IF_FALSE0 +push constant 0 +return +function Screen.drawSymetric 0 +push argument 1 +push argument 3 +sub +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 3 +add +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +sub +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +add +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push constant 0 +return +function Screen.drawCircle 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 12 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push argument 2 +sub +push constant 0 +lt +push argument 0 +push argument 2 +add +push constant 511 +gt +or +push argument 1 +push argument 2 +sub +push constant 0 +lt +or +push argument 1 +push argument 2 +add +push constant 255 +gt +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 13 +call Sys.error 1 +pop temp 0 +label IF_FALSE1 +push argument 2 +pop local 1 +push constant 1 +push argument 2 +sub +pop local 2 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 0 +gt +not +if-goto WHILE_END0 +push local 2 +push constant 0 +lt +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 2 +push constant 2 +push local 0 +call Math.multiply 2 +add +push constant 3 +add +pop local 2 +goto IF_END2 +label IF_FALSE2 +push local 2 +push constant 2 +push local 0 +push local 1 +sub +call Math.multiply 2 +add +push constant 5 +add +pop local 2 +push local 1 +push constant 1 +sub +pop local 1 +label IF_END2 +push local 0 +push constant 1 +add +pop local 0 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return diff --git a/projects/12/MemoryTest/String.vm b/projects/12/MemoryTest/String.vm new file mode 100755 index 0000000..9b7577e --- /dev/null +++ b/projects/12/MemoryTest/String.vm @@ -0,0 +1,393 @@ +function String.new 0 +push constant 3 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 14 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +call Array.new 1 +pop this 1 +label IF_FALSE1 +push argument 0 +pop this 0 +push constant 0 +pop this 2 +push pointer 0 +return +function String.dispose 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 1 +call Array.dispose 1 +pop temp 0 +label IF_FALSE0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function String.length 0 +push argument 0 +pop pointer 0 +push this 2 +return +function String.charAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 15 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +pop pointer 1 +push that 0 +return +function String.setCharAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 16 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function String.appendChar 0 +push argument 0 +pop pointer 0 +push this 2 +push this 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 17 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push this 1 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +push pointer 0 +return +function String.eraseLastChar 0 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 18 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push constant 1 +sub +pop this 2 +push constant 0 +return +function String.intValue 5 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push constant 0 +not +pop local 3 +push constant 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 45 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 4 +push constant 1 +pop local 0 +label IF_FALSE1 +label WHILE_EXP0 +push local 0 +push this 2 +lt +push local 3 +and +not +if-goto WHILE_END0 +push local 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 48 +sub +pop local 2 +push local 2 +push constant 0 +lt +push local 2 +push constant 9 +gt +or +not +pop local 3 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 1 +push constant 10 +call Math.multiply 2 +push local 2 +add +pop local 1 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 1 +neg +pop local 1 +label IF_FALSE3 +push local 1 +return +function String.setInt 4 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push constant 6 +call Array.new 1 +pop local 2 +push argument 1 +push constant 0 +lt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 3 +push argument 1 +neg +pop argument 1 +label IF_FALSE1 +push argument 1 +pop local 1 +label WHILE_EXP0 +push local 1 +push constant 0 +gt +not +if-goto WHILE_END0 +push argument 1 +push constant 10 +call Math.divide 2 +pop local 1 +push local 0 +push local 2 +add +push constant 48 +push argument 1 +push local 1 +push constant 10 +call Math.multiply 2 +sub +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +push local 1 +pop argument 1 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +push local 2 +add +push constant 45 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +push this 0 +push local 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE3 +push local 0 +push constant 0 +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 0 +push this 1 +add +push constant 48 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +pop this 2 +goto IF_END4 +label IF_FALSE4 +push constant 0 +pop this 2 +label WHILE_EXP1 +push this 2 +push local 0 +lt +not +if-goto WHILE_END1 +push this 2 +push this 1 +add +push local 0 +push this 2 +push constant 1 +add +sub +push local 2 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +goto WHILE_EXP1 +label WHILE_END1 +label IF_END4 +push local 2 +call Array.dispose 1 +pop temp 0 +push constant 0 +return +function String.newLine 0 +push constant 128 +return +function String.backSpace 0 +push constant 129 +return +function String.doubleQuote 0 +push constant 34 +return diff --git a/projects/12/MemoryTest/Sys.vm b/projects/12/MemoryTest/Sys.vm new file mode 100755 index 0000000..c186dad --- /dev/null +++ b/projects/12/MemoryTest/Sys.vm @@ -0,0 +1,83 @@ +function Sys.init 0 +call Memory.init 0 +pop temp 0 +call Math.init 0 +pop temp 0 +call Screen.init 0 +pop temp 0 +call Output.init 0 +pop temp 0 +call Keyboard.init 0 +pop temp 0 +call Main.main 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return +function Sys.halt 0 +label WHILE_EXP0 +push constant 0 +not +not +if-goto WHILE_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.wait 1 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 1 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +label WHILE_EXP0 +push argument 0 +push constant 0 +gt +not +if-goto WHILE_END0 +push constant 50 +pop local 0 +label WHILE_EXP1 +push local 0 +push constant 0 +gt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push argument 0 +push constant 1 +sub +pop argument 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.error 0 +push constant 69 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push argument 0 +call Output.printInt 1 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return diff --git a/projects/12/MemoryTest/__pycache__/symbol_table.cpython-39.pyc b/projects/12/MemoryTest/__pycache__/symbol_table.cpython-39.pyc new file mode 100755 index 0000000..d9511dd Binary files /dev/null and b/projects/12/MemoryTest/__pycache__/symbol_table.cpython-39.pyc differ diff --git a/projects/12/MemoryTest/__pycache__/tokenizer.cpython-39.pyc b/projects/12/MemoryTest/__pycache__/tokenizer.cpython-39.pyc new file mode 100755 index 0000000..5e076e8 Binary files /dev/null and b/projects/12/MemoryTest/__pycache__/tokenizer.cpython-39.pyc differ diff --git a/projects/12/MemoryTest/__pycache__/vmwriter.cpython-39.pyc b/projects/12/MemoryTest/__pycache__/vmwriter.cpython-39.pyc new file mode 100755 index 0000000..3234455 Binary files /dev/null and b/projects/12/MemoryTest/__pycache__/vmwriter.cpython-39.pyc differ diff --git a/projects/12/Output.jack b/projects/12/Output.jack new file mode 100755 index 0000000..774a265 --- /dev/null +++ b/projects/12/Output.jack @@ -0,0 +1,301 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Output.jack + +/** + * A library of functions for writing text on the screen. + * The Hack physical screen consists of 512 rows of 256 pixels each. + * The library uses a fixed font, in which each character is displayed + * within a frame which is 11 pixels high (including 1 pixel for inter-line + * spacing) and 8 pixels wide (including 2 pixels for inter-character spacing). + * The resulting grid accommodates 23 rows (indexed 0..22, top to bottom) + * of 64 characters each (indexed 0..63, left to right). The top left + * character position on the screen is indexed (0,0). A cursor, implemented + * as a small filled square, indicates where the next character will be displayed. + */ +class Output { + + // Character map for displaying characters + static Array charMaps; + static int address; + static bool half; + + /** Initializes the screen, and locates the cursor at the screen's top-left. */ + function void init() { + do Output.initMap(); + do Output.moveCursor(0, 0); + return; + } + + // Initializes the character map array + function void initMap() { + var int i; + + let charMaps = Array.new(127); + + // Black square, used for displaying non-printable characters. + do Output.create(0,63,63,63,63,63,63,63,63,63,0,0); + + // Assigns the bitmap for each character in the charachter set. + // The first parameter is the character index, the next 11 numbers + // are the values of each row in the frame that represents this character. + do Output.create(32,0,0,0,0,0,0,0,0,0,0,0); // + do Output.create(33,12,30,30,30,12,12,0,12,12,0,0); // ! + do Output.create(34,54,54,20,0,0,0,0,0,0,0,0); // " + do Output.create(35,0,18,18,63,18,18,63,18,18,0,0); // # + do Output.create(36,12,30,51,3,30,48,51,30,12,12,0); // $ + do Output.create(37,0,0,35,51,24,12,6,51,49,0,0); // % + do Output.create(38,12,30,30,12,54,27,27,27,54,0,0); // & + do Output.create(39,12,12,6,0,0,0,0,0,0,0,0); // ' + do Output.create(40,24,12,6,6,6,6,6,12,24,0,0); // ( + do Output.create(41,6,12,24,24,24,24,24,12,6,0,0); // ) + do Output.create(42,0,0,0,51,30,63,30,51,0,0,0); // * + do Output.create(43,0,0,0,12,12,63,12,12,0,0,0); // + + do Output.create(44,0,0,0,0,0,0,0,12,12,6,0); // , + do Output.create(45,0,0,0,0,0,63,0,0,0,0,0); // - + do Output.create(46,0,0,0,0,0,0,0,12,12,0,0); // . + do Output.create(47,0,0,32,48,24,12,6,3,1,0,0); // / + + do Output.create(48,12,30,51,51,51,51,51,30,12,0,0); // 0 + do Output.create(49,12,14,15,12,12,12,12,12,63,0,0); // 1 + do Output.create(50,30,51,48,24,12,6,3,51,63,0,0); // 2 + do Output.create(51,30,51,48,48,28,48,48,51,30,0,0); // 3 + do Output.create(52,16,24,28,26,25,63,24,24,60,0,0); // 4 + do Output.create(53,63,3,3,31,48,48,48,51,30,0,0); // 5 + do Output.create(54,28,6,3,3,31,51,51,51,30,0,0); // 6 + do Output.create(55,63,49,48,48,24,12,12,12,12,0,0); // 7 + do Output.create(56,30,51,51,51,30,51,51,51,30,0,0); // 8 + do Output.create(57,30,51,51,51,62,48,48,24,14,0,0); // 9 + + do Output.create(58,0,0,12,12,0,0,12,12,0,0,0); // : + do Output.create(59,0,0,12,12,0,0,12,12,6,0,0); // ; + do Output.create(60,0,0,24,12,6,3,6,12,24,0,0); // < + do Output.create(61,0,0,0,63,0,0,63,0,0,0,0); // = + do Output.create(62,0,0,3,6,12,24,12,6,3,0,0); // > + do Output.create(64,30,51,51,59,59,59,27,3,30,0,0); // @ + do Output.create(63,30,51,51,24,12,12,0,12,12,0,0); // ? + + do Output.create(65,12,30,51,51,63,51,51,51,51,0,0); // A ** TO BE FILLED ** + do Output.create(66,31,51,51,51,31,51,51,51,31,0,0); // B + do Output.create(67,28,54,35,3,3,3,35,54,28,0,0); // C + do Output.create(68,15,27,51,51,51,51,51,27,15,0,0); // D + do Output.create(69,63,51,35,11,15,11,35,51,63,0,0); // E + do Output.create(70,63,51,35,11,15,11,3,3,3,0,0); // F + do Output.create(71,28,54,35,3,59,51,51,54,44,0,0); // G + do Output.create(72,51,51,51,51,63,51,51,51,51,0,0); // H + do Output.create(73,30,12,12,12,12,12,12,12,30,0,0); // I + do Output.create(74,60,24,24,24,24,24,27,27,14,0,0); // J + do Output.create(75,51,51,51,27,15,27,51,51,51,0,0); // K + do Output.create(76,3,3,3,3,3,3,35,51,63,0,0); // L + do Output.create(77,33,51,63,63,51,51,51,51,51,0,0); // M + do Output.create(78,51,51,55,55,63,59,59,51,51,0,0); // N + do Output.create(79,30,51,51,51,51,51,51,51,30,0,0); // O + do Output.create(80,31,51,51,51,31,3,3,3,3,0,0); // P + do Output.create(81,30,51,51,51,51,51,63,59,30,48,0);// Q + do Output.create(82,31,51,51,51,31,27,51,51,51,0,0); // R + do Output.create(83,30,51,51,6,28,48,51,51,30,0,0); // S + do Output.create(84,63,63,45,12,12,12,12,12,30,0,0); // T + do Output.create(85,51,51,51,51,51,51,51,51,30,0,0); // U + do Output.create(86,51,51,51,51,51,30,30,12,12,0,0); // V + do Output.create(87,51,51,51,51,51,63,63,63,18,0,0); // W + do Output.create(88,51,51,30,30,12,30,30,51,51,0,0); // X + do Output.create(89,51,51,51,51,30,12,12,12,30,0,0); // Y + do Output.create(90,63,51,49,24,12,6,35,51,63,0,0); // Z + + do Output.create(91,30,6,6,6,6,6,6,6,30,0,0); // [ + do Output.create(92,0,0,1,3,6,12,24,48,32,0,0); // \ + do Output.create(93,30,24,24,24,24,24,24,24,30,0,0); // ] + do Output.create(94,8,28,54,0,0,0,0,0,0,0,0); // ^ + do Output.create(95,0,0,0,0,0,0,0,0,0,63,0); // _ + do Output.create(96,6,12,24,0,0,0,0,0,0,0,0); // ` + + do Output.create(97,0,0,0,14,24,30,27,27,54,0,0); // a + do Output.create(98,3,3,3,15,27,51,51,51,30,0,0); // b + do Output.create(99,0,0,0,30,51,3,3,51,30,0,0); // c + do Output.create(100,48,48,48,60,54,51,51,51,30,0,0); // d + do Output.create(101,0,0,0,30,51,63,3,51,30,0,0); // e + do Output.create(102,28,54,38,6,15,6,6,6,15,0,0); // f + do Output.create(103,0,0,30,51,51,51,62,48,51,30,0); // g + do Output.create(104,3,3,3,27,55,51,51,51,51,0,0); // h + do Output.create(105,12,12,0,14,12,12,12,12,30,0,0); // i + do Output.create(106,48,48,0,56,48,48,48,48,51,30,0); // j + do Output.create(107,3,3,3,51,27,15,15,27,51,0,0); // k + do Output.create(108,14,12,12,12,12,12,12,12,30,0,0); // l + do Output.create(109,0,0,0,29,63,43,43,43,43,0,0); // m + do Output.create(110,0,0,0,29,51,51,51,51,51,0,0); // n + do Output.create(111,0,0,0,30,51,51,51,51,30,0,0); // o + do Output.create(112,0,0,0,30,51,51,51,31,3,3,0); // p + do Output.create(113,0,0,0,30,51,51,51,62,48,48,0); // q + do Output.create(114,0,0,0,29,55,51,3,3,7,0,0); // r + do Output.create(115,0,0,0,30,51,6,24,51,30,0,0); // s + do Output.create(116,4,6,6,15,6,6,6,54,28,0,0); // t + do Output.create(117,0,0,0,27,27,27,27,27,54,0,0); // u + do Output.create(118,0,0,0,51,51,51,51,30,12,0,0); // v + do Output.create(119,0,0,0,51,51,51,63,63,18,0,0); // w + do Output.create(120,0,0,0,51,30,12,12,30,51,0,0); // x + do Output.create(121,0,0,0,51,51,51,62,48,24,15,0); // y + do Output.create(122,0,0,0,63,27,12,6,51,63,0,0); // z + + do Output.create(123,56,12,12,12,7,12,12,12,56,0,0); // { + do Output.create(124,12,12,12,12,12,12,12,12,12,0,0); // | + do Output.create(125,7,12,12,12,56,12,12,12,7,0,0); // } + do Output.create(126,38,45,25,0,0,0,0,0,0,0,0); // ~ + + return; + } + + // Creates the character map array of the given character index, using the given values. + function void create(int index, int a, int b, int c, int d, int e, + int f, int g, int h, int i, int j, int k) { + var Array map; + + let map = Array.new(11); + let charMaps[index] = map; + + let map[0] = a; + let map[1] = b; + let map[2] = c; + let map[3] = d; + let map[4] = e; + let map[5] = f; + let map[6] = g; + let map[7] = h; + let map[8] = i; + let map[9] = j; + let map[10] = k; + + return; + } + + // Returns the character map (array of size 11) of the given character. + // If the given character is invalid or non-printable, returns the + // character map of a black square. + function Array getMap(char c) { + if ((c < 32) | (c > 126)) { + let c = 0; + } + return charMaps[c]; + } + + /** Moves the cursor to the j-th column of the i-th row, + * and erases the character displayed there. */ + function void moveCursor(int i, int j) { + var int count; + var int display; + var Array r; + var Array char; + if (j = 0){ + let half = true; + } + else{ + let half = (j / 2) * 2 = j; // chetno true, 1vaa chast + } + let address = (352 * i) + (j / 2) + 16384; + let char = Output.getMap(32); + + while (count < 11){ + if (half){ + let display = r[address] & (-256); + let r[address] = char[count] | display; + } + else{ + let display = r[address] & 255; + let r[address] = (char[count]*256) | display; + } + let count = count + 1; + let address = address + 32; + } + let address = address - 352; + return; + } + + /** Displays the given character at the cursor location, + * and advances the cursor one column forward. */ + function void printChar(char c) { + var Array char; + var Array r; + var int count; + var int display; + let char = Output.getMap(c); + while (count < 11){ + if (half){ + let display = r[address] & (-256); + let r[address] = char[count] | display; + } + else{ + let display = r[address] & 255; + let r[address] = (char[count]*256) | display; + } + let count = count + 1; + let address = address + 32; + } + + if (half){ + let address = address - 352; + let half = false; + } + else{ + if (address > 24480){ + let address = 16384; + let half = true; + } + else{ + let address = address - 351; + let half = true; + } + } + return; + } + + /** displays the given string starting at the cursor location, + * and advances the cursor appropriately. */ + function void printString(String s) { + var int i, length; + let length = s.length(); + while (i < length){ + do Output.printChar(s[i+2]); + let i = i + 1; + } + return; + } + + /** Displays the given integer starting at the cursor location, + * and advances the cursor appropriately. */ + function void printInt(int i) { + var String s; + let s = String.new(6); + do s.setInt(i); + do Output.printString(s); + return; + } + + /** Advances the cursor to the beginning of the next line. */ + function void println() { + var int row; + let row = (((address - 16384) / 32)/11) + 1; + if (row > 32){ + let row = 0; + } + do Output.moveCursor(row, 0); + return; + } + + /** Moves the cursor one column back. */ + function void backSpace() { + if (address = 16384){ + let address = 24191; + let half = true; + return; + } + if (half){ + + let address = address - 1; + let half = false; + } + else{ + let half = true; + } + return; + } +} diff --git a/projects/12/OutputTest/Main.jack b/projects/12/OutputTest/Main.jack new file mode 100755 index 0000000..f243068 --- /dev/null +++ b/projects/12/OutputTest/Main.jack @@ -0,0 +1,42 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/OutputTest/Main.jack + +/** Test program for the OS Output class. */ +class Main { + + /** Outputs the entire character set to the screen using all the + * methods of the Output class. */ + function void main() { + var String s; + + let s = String.new(1); + do s.appendChar(String.doubleQuote()); + + do Output.moveCursor(0, 63); + do Output.printChar(66); + do Output.moveCursor(22, 0); + do Output.printChar(67); + do Output.moveCursor(22, 63); + do Output.printChar(68); + do Output.printChar(65); + + do Output.moveCursor(2, 0); + do Output.printString("0123456789"); + do Output.println(); + + do Output.printString("ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"); + do Output.println(); + + do Output.printString("!#$%&'()*+,-./:;<=>?@[\]^_`{|}~"); + do Output.printString(s); + do Output.println(); + + do Output.printInt(-12345); + do Output.backSpace(); + do Output.printInt(6789); + + return; + } +} diff --git a/projects/12/OutputTest/OutputTestOutput.gif b/projects/12/OutputTest/OutputTestOutput.gif new file mode 100755 index 0000000..b8ec2c0 Binary files /dev/null and b/projects/12/OutputTest/OutputTestOutput.gif differ diff --git a/projects/12/OutputTest/__pycache__/symbol_table.cpython-39.pyc b/projects/12/OutputTest/__pycache__/symbol_table.cpython-39.pyc new file mode 100755 index 0000000..d0534a7 Binary files /dev/null and b/projects/12/OutputTest/__pycache__/symbol_table.cpython-39.pyc differ diff --git a/projects/12/OutputTest/__pycache__/tokenizer.cpython-39.pyc b/projects/12/OutputTest/__pycache__/tokenizer.cpython-39.pyc new file mode 100755 index 0000000..7382823 Binary files /dev/null and b/projects/12/OutputTest/__pycache__/tokenizer.cpython-39.pyc differ diff --git a/projects/12/OutputTest/__pycache__/vmwriter.cpython-39.pyc b/projects/12/OutputTest/__pycache__/vmwriter.cpython-39.pyc new file mode 100755 index 0000000..f93075a Binary files /dev/null and b/projects/12/OutputTest/__pycache__/vmwriter.cpython-39.pyc differ diff --git a/projects/12/Screen.jack b/projects/12/Screen.jack new file mode 100755 index 0000000..006a905 --- /dev/null +++ b/projects/12/Screen.jack @@ -0,0 +1,206 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Screen.jack + +/** + * A library of functions for displaying graphics on the screen. + * The Hack physical screen consists of 256 rows (indexed 0..255, top to bottom) + * of 512 pixels each (indexed 0..511, left to right). The top left pixel on + * the screen is indexed (0,0). + */ +class Screen { + + static Array mem; + static Array st; + static boolean color; + /** Initializes the Screen. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + let color = true; + return; + } + + /** Erases the entire screen. */ + function void clearScreen() { + var int a; + let a = 16384; + while (a < 24575){ + let mem[a] = 0; + let a = a + 1; + } + return; + } + + /** Sets the current color, to be used for all subsequent drawXXX commands. + * Black is represented by true, white by false. */ + function void setColor(boolean b) { + let color = b; + return; + } + + /** Draws the (x,y) pixel, using the current color. */ + function void drawPixel(int x, int y) { + var int value, address, bit, mem_block; + if ((x > 511) | (x < 0) | (y > 255) | (y < 0)){ + do Sys.error(7); + } + let mem_block = x / 16; + let address = (32 * y) + mem_block + 16384; + let value = mem[address]; + let bit = x - (mem_block * 16); + if (color){ + let mem[address] = st[bit] | value; + } + else{ + let mem[address] = (~st[bit])& value; + } + return; + } + + /** Draws a line from pixel (x1,y1) to pixel (x2,y2), using the current color. */ + function void drawLine(int x1, int y1, int x2, int y2) { + var int diff, dx, dy, a, b; + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let dx = x2 - x1; + let dy = y2 - y1; + if (dx = 0){ + if (dy > 0){ + while(~(b > dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b + 1; + } + return; + } + else{ + while(~(b < dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b - 1; + } + return; + } + } + if (dy = 0){ + if (dx > 0){ + while(~(a > dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a + 1; + } + return; + } + else{ + while(~(a < dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a - 1; + } + return; + } + } + if (dx < 0){ + if (dy < 0){ + while ((~(a < dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff + dx; + } + } + } + else{ + while ((~(a < dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff + dx; + } + } + } + } + else{ + if (dy < 0){ + while ((~(a > dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff - dx; + } + } + } + else{ + while ((~(a > dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff - dx; + } + } + } + } + + return; + } + + /** Draws a filled rectangle whose top left corner is (x1, y1) + * and bottom right corner is (x2,y2), using the current color. */ + function void drawRectangle(int x1, int y1, int x2, int y2) { + var int a, tmp; + if (x1 > x2){ + let tmp = x1; + let x1 = x2; + let x2 = tmp; + } + if (y1 > y2){ + let tmp = y1; + let y1 = y2; + let y2 = tmp; + } + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let tmp = y2 - y1; + while(a < tmp){ + do Screen.drawLine(x1, y1 + a, x2, y1 + a); + let a = a + 1; + } + return; + } + + /** Draws a filled circle of radius r<=181 around (x,y), using the current color. */ + function void drawCircle(int x, int y, int r) { + var int dy, dx, tmp; + if(r > 181){ + do Sys.error(7); + } + let dy = - r; + while (dy < r){ + let tmp = Math.sqrt((r * r) - (dy * dy)); + do Screen.drawLine(x - tmp, y + dy, x + tmp, y + dy); + let dy = dy + 1; + } + return; + } +} diff --git a/projects/12/ScreenTest/Main.jack b/projects/12/ScreenTest/Main.jack new file mode 100755 index 0000000..00f36bd --- /dev/null +++ b/projects/12/ScreenTest/Main.jack @@ -0,0 +1,36 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/ScreenTest/Main.jack + +/** Test program for the OS Screen class. */ +class Main { + + /** Draws a sample pictue on the screen using lines and circles. */ + function void main() { + + do Screen.drawLine(0,220,511,220); // base line + do Screen.drawRectangle(280,90,410,220); // house + + do Screen.setColor(false); + do Screen.drawRectangle(350,120,390,219); // door + do Screen.drawRectangle(292,120,332,150); // window + + do Screen.setColor(true); + do Screen.drawCircle(360,170,3); // door handle + do Screen.drawLine(280,90,345,35); // roof + do Screen.drawLine(345,35,410,90); // roof + + do Screen.drawCircle(140,60,30); // sun + do Screen.drawLine(140,26, 140, 6); + do Screen.drawLine(163,35,178,20); + do Screen.drawLine(174,60,194,60); + do Screen.drawLine(163,85,178,100); + do Screen.drawLine(140,94,140,114); + do Screen.drawLine(117,85,102,100); + do Screen.drawLine(106,60,86,60); + do Screen.drawLine(117,35,102,20); + + return; + } +} diff --git a/projects/12/ScreenTest/Main.vm b/projects/12/ScreenTest/Main.vm new file mode 100755 index 0000000..31c8c16 --- /dev/null +++ b/projects/12/ScreenTest/Main.vm @@ -0,0 +1,104 @@ +function Main.main 0 +push constant 0 +push constant 220 +push constant 511 +push constant 220 +call Screen.drawLine 4 +pop temp 0 +push constant 280 +push constant 90 +push constant 410 +push constant 220 +call Screen.drawRectangle 4 +pop temp 0 +push constant 0 +call Screen.setColor 1 +pop temp 0 +push constant 350 +push constant 120 +push constant 390 +push constant 219 +call Screen.drawRectangle 4 +pop temp 0 +push constant 292 +push constant 120 +push constant 332 +push constant 150 +call Screen.drawRectangle 4 +pop temp 0 +push constant 1 +neg +call Screen.setColor 1 +pop temp 0 +push constant 360 +push constant 170 +push constant 3 +call Screen.drawCircle 3 +pop temp 0 +push constant 280 +push constant 90 +push constant 345 +push constant 35 +call Screen.drawLine 4 +pop temp 0 +push constant 345 +push constant 35 +push constant 410 +push constant 90 +call Screen.drawLine 4 +pop temp 0 +push constant 140 +push constant 60 +push constant 30 +call Screen.drawCircle 3 +pop temp 0 +push constant 140 +push constant 26 +push constant 140 +push constant 6 +call Screen.drawLine 4 +pop temp 0 +push constant 163 +push constant 35 +push constant 178 +push constant 20 +call Screen.drawLine 4 +pop temp 0 +push constant 174 +push constant 60 +push constant 194 +push constant 60 +call Screen.drawLine 4 +pop temp 0 +push constant 163 +push constant 85 +push constant 178 +push constant 100 +call Screen.drawLine 4 +pop temp 0 +push constant 140 +push constant 94 +push constant 140 +push constant 114 +call Screen.drawLine 4 +pop temp 0 +push constant 117 +push constant 85 +push constant 102 +push constant 100 +call Screen.drawLine 4 +pop temp 0 +push constant 106 +push constant 60 +push constant 86 +push constant 60 +call Screen.drawLine 4 +pop temp 0 +push constant 117 +push constant 35 +push constant 102 +push constant 20 +call Screen.drawLine 4 +pop temp 0 +push constant 0 +return diff --git a/projects/12/ScreenTest/Screen.jack b/projects/12/ScreenTest/Screen.jack new file mode 100755 index 0000000..006a905 --- /dev/null +++ b/projects/12/ScreenTest/Screen.jack @@ -0,0 +1,206 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Screen.jack + +/** + * A library of functions for displaying graphics on the screen. + * The Hack physical screen consists of 256 rows (indexed 0..255, top to bottom) + * of 512 pixels each (indexed 0..511, left to right). The top left pixel on + * the screen is indexed (0,0). + */ +class Screen { + + static Array mem; + static Array st; + static boolean color; + /** Initializes the Screen. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + let color = true; + return; + } + + /** Erases the entire screen. */ + function void clearScreen() { + var int a; + let a = 16384; + while (a < 24575){ + let mem[a] = 0; + let a = a + 1; + } + return; + } + + /** Sets the current color, to be used for all subsequent drawXXX commands. + * Black is represented by true, white by false. */ + function void setColor(boolean b) { + let color = b; + return; + } + + /** Draws the (x,y) pixel, using the current color. */ + function void drawPixel(int x, int y) { + var int value, address, bit, mem_block; + if ((x > 511) | (x < 0) | (y > 255) | (y < 0)){ + do Sys.error(7); + } + let mem_block = x / 16; + let address = (32 * y) + mem_block + 16384; + let value = mem[address]; + let bit = x - (mem_block * 16); + if (color){ + let mem[address] = st[bit] | value; + } + else{ + let mem[address] = (~st[bit])& value; + } + return; + } + + /** Draws a line from pixel (x1,y1) to pixel (x2,y2), using the current color. */ + function void drawLine(int x1, int y1, int x2, int y2) { + var int diff, dx, dy, a, b; + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let dx = x2 - x1; + let dy = y2 - y1; + if (dx = 0){ + if (dy > 0){ + while(~(b > dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b + 1; + } + return; + } + else{ + while(~(b < dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b - 1; + } + return; + } + } + if (dy = 0){ + if (dx > 0){ + while(~(a > dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a + 1; + } + return; + } + else{ + while(~(a < dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a - 1; + } + return; + } + } + if (dx < 0){ + if (dy < 0){ + while ((~(a < dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff + dx; + } + } + } + else{ + while ((~(a < dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff + dx; + } + } + } + } + else{ + if (dy < 0){ + while ((~(a > dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff - dx; + } + } + } + else{ + while ((~(a > dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff - dx; + } + } + } + } + + return; + } + + /** Draws a filled rectangle whose top left corner is (x1, y1) + * and bottom right corner is (x2,y2), using the current color. */ + function void drawRectangle(int x1, int y1, int x2, int y2) { + var int a, tmp; + if (x1 > x2){ + let tmp = x1; + let x1 = x2; + let x2 = tmp; + } + if (y1 > y2){ + let tmp = y1; + let y1 = y2; + let y2 = tmp; + } + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let tmp = y2 - y1; + while(a < tmp){ + do Screen.drawLine(x1, y1 + a, x2, y1 + a); + let a = a + 1; + } + return; + } + + /** Draws a filled circle of radius r<=181 around (x,y), using the current color. */ + function void drawCircle(int x, int y, int r) { + var int dy, dx, tmp; + if(r > 181){ + do Sys.error(7); + } + let dy = - r; + while (dy < r){ + let tmp = Math.sqrt((r * r) - (dy * dy)); + do Screen.drawLine(x - tmp, y + dy, x + tmp, y + dy); + let dy = dy + 1; + } + return; + } +} diff --git a/projects/12/ScreenTest/Screen.vm b/projects/12/ScreenTest/Screen.vm new file mode 100755 index 0000000..d08813b --- /dev/null +++ b/projects/12/ScreenTest/Screen.vm @@ -0,0 +1,656 @@ +function Screen.init 1 +push constant 16 +call Array.new 1 +pop static 1 +push static 1 +push constant 0 +push constant 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L0 +push local 0 +push constant 15 +lt +not +if-goto L1 +push local 0 +push constant 1 +add +pop local 0 +push static 1 +push local 0 +push static 1 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +push static 1 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +add +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L0 +label L1 +push constant 1 +neg +pop static 2 +push constant 0 +return +function Screen.clearScreen 1 +push constant 16384 +pop local 0 +label L2 +push local 0 +push constant 24575 +lt +not +if-goto L3 +push static 0 +push local 0 +push constant 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +goto L2 +label L3 +push constant 0 +return +function Screen.setColor 0 +push argument 0 +pop static 2 +push constant 0 +return +function Screen.drawPixel 4 +push argument 0 +push constant 511 +gt +push argument 0 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +push argument 1 +push constant 0 +lt +or +not +if-goto L4 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L5 +label L4 +label L5 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push constant 32 +push argument 1 +call Math.multiply 2 +push local 3 +add +push constant 16384 +add +pop local 1 +push static 0 +push local 1 +add +pop pointer 1 +push that 0 +pop local 0 +push argument 0 +push local 3 +push constant 16 +call Math.multiply 2 +sub +pop local 2 +push static 2 +not +if-goto L6 +push static 0 +push local 1 +push static 1 +push local 2 +add +pop pointer 1 +push that 0 +push local 0 +or +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L7 +label L6 +push static 0 +push local 1 +push static 1 +push local 2 +add +pop pointer 1 +push that 0 +not +push local 0 +and +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L7 +push constant 0 +return +function Screen.drawLine 5 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +not +if-goto L8 +push constant 8 +call Sys.error 1 +pop temp 0 +goto L9 +label L8 +label L9 +push argument 2 +push argument 0 +sub +pop local 1 +push argument 3 +push argument 1 +sub +pop local 2 +push local 1 +push constant 0 +eq +not +if-goto L10 +push local 2 +push constant 0 +gt +not +if-goto L11 +label L12 +push local 4 +push local 2 +gt +not +not +if-goto L13 +push argument 0 +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 4 +push constant 1 +add +pop local 4 +goto L12 +label L13 +push constant 0 +return +goto L14 +label L11 +label L15 +push local 4 +push local 2 +lt +not +not +if-goto L16 +push argument 0 +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 4 +push constant 1 +sub +pop local 4 +goto L15 +label L16 +push constant 0 +return +label L14 +goto L17 +label L10 +label L17 +push local 2 +push constant 0 +eq +not +if-goto L18 +push local 1 +push constant 0 +gt +not +if-goto L19 +label L20 +push local 3 +push local 1 +gt +not +not +if-goto L21 +push argument 0 +push local 3 +add +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +push local 3 +push constant 1 +add +pop local 3 +goto L20 +label L21 +push constant 0 +return +goto L22 +label L19 +label L23 +push local 3 +push local 1 +lt +not +not +if-goto L24 +push argument 0 +push local 3 +add +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +push local 3 +push constant 1 +sub +pop local 3 +goto L23 +label L24 +push constant 0 +return +label L22 +goto L25 +label L18 +label L25 +push local 1 +push constant 0 +lt +not +if-goto L26 +push local 2 +push constant 0 +lt +not +if-goto L27 +label L28 +push local 3 +push local 1 +lt +not +push local 4 +push local 2 +lt +not +and +not +if-goto L29 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L30 +push local 3 +push constant 1 +sub +pop local 3 +push local 0 +push local 2 +sub +pop local 0 +goto L31 +label L30 +push local 4 +push constant 1 +sub +pop local 4 +push local 0 +push local 1 +add +pop local 0 +label L31 +goto L28 +label L29 +goto L32 +label L27 +label L33 +push local 3 +push local 1 +lt +not +push local 4 +push local 2 +gt +not +and +not +if-goto L34 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L35 +push local 3 +push constant 1 +sub +pop local 3 +push local 0 +push local 2 +add +pop local 0 +goto L36 +label L35 +push local 4 +push constant 1 +add +pop local 4 +push local 0 +push local 1 +add +pop local 0 +label L36 +goto L33 +label L34 +label L32 +goto L37 +label L26 +push local 2 +push constant 0 +lt +not +if-goto L38 +label L39 +push local 3 +push local 1 +gt +not +push local 4 +push local 2 +lt +not +and +not +if-goto L40 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L41 +push local 3 +push constant 1 +add +pop local 3 +push local 0 +push local 2 +sub +pop local 0 +goto L42 +label L41 +push local 4 +push constant 1 +sub +pop local 4 +push local 0 +push local 1 +sub +pop local 0 +label L42 +goto L39 +label L40 +goto L43 +label L38 +label L44 +push local 3 +push local 1 +gt +not +push local 4 +push local 2 +gt +not +and +not +if-goto L45 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L46 +push local 3 +push constant 1 +add +pop local 3 +push local 0 +push local 2 +add +pop local 0 +goto L47 +label L46 +push local 4 +push constant 1 +add +pop local 4 +push local 0 +push local 1 +sub +pop local 0 +label L47 +goto L44 +label L45 +label L43 +label L37 +push constant 0 +return +function Screen.drawRectangle 2 +push argument 0 +push argument 2 +gt +not +if-goto L48 +push argument 0 +pop local 1 +push argument 2 +pop argument 0 +push local 1 +pop argument 2 +goto L49 +label L48 +label L49 +push argument 1 +push argument 3 +gt +not +if-goto L50 +push argument 1 +pop local 1 +push argument 3 +pop argument 1 +push local 1 +pop argument 3 +goto L51 +label L50 +label L51 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +not +if-goto L52 +push constant 8 +call Sys.error 1 +pop temp 0 +goto L53 +label L52 +label L53 +push argument 3 +push argument 1 +sub +pop local 1 +label L54 +push local 0 +push local 1 +lt +not +if-goto L55 +push argument 0 +push argument 1 +push local 0 +add +push argument 2 +push argument 1 +push local 0 +add +call Screen.drawLine 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto L54 +label L55 +push constant 0 +return +function Screen.drawCircle 3 +push argument 2 +push constant 181 +gt +not +if-goto L56 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L57 +label L56 +label L57 +push argument 2 +neg +pop local 0 +label L58 +push local 0 +push argument 2 +lt +not +if-goto L59 +push argument 2 +push argument 2 +call Math.multiply 2 +push local 0 +push local 0 +call Math.multiply 2 +sub +call Math.sqrt 1 +pop local 2 +push argument 0 +push local 2 +sub +push argument 1 +push local 0 +add +push argument 0 +push local 2 +add +push argument 1 +push local 0 +add +call Screen.drawLine 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto L58 +label L59 +push constant 0 +return diff --git a/projects/12/ScreenTest/ScreenTestOutput.gif b/projects/12/ScreenTest/ScreenTestOutput.gif new file mode 100755 index 0000000..f1742cc Binary files /dev/null and b/projects/12/ScreenTest/ScreenTestOutput.gif differ diff --git a/projects/12/String.jack b/projects/12/String.jack new file mode 100755 index 0000000..6a70740 --- /dev/null +++ b/projects/12/String.jack @@ -0,0 +1,148 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/String.jack + +/** + * Represents character strings. In addition for constructing and disposing + * strings, the class features methods for getting and setting individual + * characters of the string, for erasing the string's last character, + * for appending a character to the string's end, and more typical + * string-oriented operations. + */ +class String { + field Array str; + field int length; + static bool neg; + + /** constructs a new empty string with a maximum length of maxLength + * and initial length of 0. */ + constructor String new(int maxLength) { + if (maxLength > 0){ + let str = Array.new(maxLength); + } + let length = 0; + return this; + } + + /** Disposes this string. */ + method void dispose() { + if(length > 0){ + do str.dispose(); + } + do Memory.deAlloc(this); + return; + } + + /** Returns the current length of this string. */ + method int length() { + return length; + } + + /** Returns the character at the j-th location of this string. */ + method char charAt(int j) { + if(j > length){ + do Sys.error(7); + } + return str[j]; + } + + /** Sets the character at the j-th location of this string to c. */ + method void setCharAt(int j, char c) { + if(j > length){ + do Sys.error(7); + } + let str[j] = c; + return; + } + + /** Appends c to this string's end and returns this string. */ + method String appendChar(char c) { + let str[length] = c; + let length = length + 1; + return this; + } + + /** Erases the last character from this string. */ + method void eraseLastChar() { + let str[length] = 0; + let length = length - 1; + return; + } + + /** Returns the integer value of this string, + * until a non-digit character is detected. */ + method int intValue() { + var int d, sum, i; + var bool f; + while(i < length){ + let d = str[i]; // kak da go zavyrtq v realen int + if ((d > 47) & (d < 58)){ + let sum = (sum * 10) + (d - 48); + } + else{ + if((i = 0) & (d = 45)){ + let f = true; + } + else{ + let i = length; + } + } + let i = i + 1; + } + if (f){ + return -sum; + } + return sum; + } + + /** Sets this string to hold a representation of the given value. */ + method void setInt(int val) { + var int lastDigit, a, i; + var char c; + if(val < 0){ + let neg = true; + let val = -val; + } + let a = val / 10; + let lastDigit = val - (a * 10); + let i = 48; + while (i < 58){ + if (i = (48 + lastDigit)){ + let c = i; + let i = 59; + } + let i = i + 1; + } + if (val < 10){ + let length = 0; + if (neg){ + let neg = false; + do this.appendChar("-"); + } + + do this.appendChar(c); + return; + } + else{ + do this.setInt(a); + do this.appendChar(c); + } + return; + } + + /** Returns the new line character. */ + function char newLine() { + return 128; + } + + /** Returns the backspace character. */ + function char backSpace() { + return 129; + } + + /** Returns the double quote (") character. */ + function char doubleQuote() { + return 34; + } +} diff --git a/projects/12/StringTest/JackCompiler.py b/projects/12/StringTest/JackCompiler.py new file mode 100755 index 0000000..5782f99 --- /dev/null +++ b/projects/12/StringTest/JackCompiler.py @@ -0,0 +1,350 @@ +import os +from pathlib import Path +from tokenizer import Tokenizer +from vmwriter import VMWriter +from symbol_table import SymbolTable + + +# TODO add names to variables when you call for them, aka current_vm_append(thingtobeappended=blablac) + +class CompilationEngine: + def __init__(self, tokenizer, full_path_vm): + self.string = self.sub_type = self.class_name = self.function_type = '' + self.tab = self.recursion_index = 0 + self.tokenizer = tokenizer + self.sym_table = [] + self.vmwriter = VMWriter(full_path_vm) + self.current_vm = [] # used to reverse some of the commands, eg a+b need to be a b + + + def search_kind_of_sym(self, current_vm): + if self.sym_table[-1].kind_of(current_vm) is not None: + return self.sym_table[-1].kind_of(current_vm), self.sym_table[-1].index_of(current_vm) + for i in range(len(self.sym_table) - 2, -1, + -1): # start from the amount of sym_tables -2 so it starts from one below the current, + # until it is bigger than -1, walking it backwards + if self.sym_table[i].kind_of(current_vm) in ('static', 'this'): + return self.sym_table[i].kind_of(current_vm), self.sym_table[i].index_of(current_vm) + + def search_type_of_sym(self, current_vm): + for i in range(len(self.sym_table) - 1, -1, -1): + if self.sym_table[i].type_of(current_vm) is not None: + return self.sym_table[i].type_of(current_vm) + + def write_token(self): + if self.tokenizer.token_type() == 'stringConstant': + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token.strip( + '"') + ' \n' + else: + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token + ' \n' + + def compile_class(self): + self.sym_table.append(SymbolTable()) + self.tokenizer.advance() # class -> + self.tokenizer.advance() # type -> + self.class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + self.tokenizer.advance() # { -> + while self.tokenizer.token != '}': + if self.tokenizer.token in ['static', 'field']: + self.compile_class_var_dec() + if self.tokenizer.token in ['constructor', 'function', 'method']: + self.compile_subroutine() + self.tokenizer.advance() + self.sym_table.pop() + self.vmwriter.close_vm_file() + + def compile_class_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_subroutine(self): + self.sym_table.append(SymbolTable()) + self.sub_type = self.tokenizer.token + self.tokenizer.advance() # subroutine type(function|method|constructor) -> + self.function_type = self.tokenizer.token + self.tokenizer.advance() # subroutine kind(int|void|etc..) -> + sub_name = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + if self.sub_type == 'method': + self.sym_table[-1].start_subroutine('this', self.class_name) + self.compile_parameter_list() + self.tokenizer.advance() # { -> + while self.tokenizer.token == 'var': # create only symbol teable entries + self.compile_var_dec() + if self.sub_type == 'constructor': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('constant', self.sym_table[-2].var_count('field')) + self.vmwriter.write_call('Memory.alloc', 1) + self.vmwriter.write_pop('pointer', 0) + elif self.sub_type == 'method': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('argument', 0) + self.vmwriter.write_pop('pointer', 0) + else: + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + while self.tokenizer.token != '}': + self.compile_statements() + self.tokenizer.advance() + self.sym_table.pop() + + def compile_parameter_list(self): + if self.tokenizer.token != ')': + var_type = self.tokenizer.token + self.tokenizer.advance() # var ype -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # var name -> + while self.tokenizer.token == ',': + self.tokenizer.advance() # , -> + var_type = self.tokenizer.token + self.tokenizer.advance() # type -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # name -> + self.tokenizer.advance() # )-> + + def compile_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_statements(self): + while True: + if self.tokenizer.token == 'let': + self.compile_let() + elif self.tokenizer.token == 'if': + self.compile_if() + elif self.tokenizer.token == 'while': + self.compile_while() + elif self.tokenizer.token == 'do': + self.compile_do() + elif self.tokenizer.token == 'return': + self.compile_return() + else: + break + + def compile_do(self): + self.tokenizer.advance() # do -> + class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + if self.tokenizer.token == '(': # method + self.vmwriter.write_push('pointer', 0) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{class_name}', count + 1) + elif self.tokenizer.token == '.': # method or function + self.tokenizer.advance() # . -> + fname = f'{class_name}.{self.tokenizer.token}' + sname = f'{self.search_type_of_sym(class_name)}.{self.tokenizer.token}' + self.tokenizer.advance() # name -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_push(*self.search_kind_of_sym(class_name)) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_call(f'{sname}', count + 1) + else: + self.vmwriter.write_call(f'{fname}', count) + self.vmwriter.write_pop('temp', '0') + self.tokenizer.advance() # ; -> + + def compile_let(self): + flag_array = 0 + self.tokenizer.advance() # let -> + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # var_name -> + if self.tokenizer.token == '[': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.tokenizer.advance() # [ -> + self.compile_expression() + self.tokenizer.advance() # ] -> + flag_array = 1 + self.tokenizer.advance() # = -> + self.compile_expression() + self.tokenizer.advance() # ; -> + if flag_array == 0: + self.vmwriter.write_pop(*self.search_kind_of_sym(self.current_vm[-1])) + else: + self.vmwriter.write_pop('temp', 1) + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('temp', 1) + self.vmwriter.write_pop('that', 0) + self.current_vm.pop() + + def compile_while(self): + self.tokenizer.advance() # while -> + label1 = self.vmwriter.label_index + self.vmwriter.write_lable(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label2 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_goto(label1) + self.vmwriter.write_lable(label2) + + def compile_return(self): + self.tokenizer.advance() # return -> + if self.tokenizer.token != ';': + self.compile_expression() + self.vmwriter.write_return(self.function_type) + self.tokenizer.advance() # ; -> + + def compile_if(self): + self.tokenizer.advance() # if -> + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label1 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + label2 = self.vmwriter.label_index + self.vmwriter.write_goto(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.vmwriter.write_lable(label1) + if self.tokenizer.token == 'else': + self.tokenizer.advance() # else -> + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_lable(label2) + + def compile_expression(self): + self.compile_term() + while self.tokenizer.token in ['+', '-', '*', '/', '|', '=', '>', '<', '&']: + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # symbol -> + self.compile_term() + self.vmwriter.write_arithmetic(self.current_vm[-1]) + self.current_vm.pop() + + def compile_term(self): + if self.tokenizer.token == '(': # expression () + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + elif self.tokenizer.token in ['~', '-']: # uniry op + self.current_vm.append(self.tokenizer.token) + tmp = 'neg' if self.tokenizer.token == '-' else self.tokenizer.token + self.tokenizer.advance() # ~ or - -> + self.compile_term() + self.vmwriter.write_arithmetic(tmp) + self.current_vm.pop() + elif self.tokenizer.token_type() != 'symbol': + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # integer, string, keyword, varnname, subroutine_name, class_name, var_name -> + if self.tokenizer.token == '[': # Array + self.tokenizer.advance() # [ -> + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + self.compile_expression() + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('that', 0) + self.tokenizer.advance() # ] -> + elif self.tokenizer.token == '(': # subroutine_name () + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{self.current_vm[-1]}', count) + self.current_vm.pop() + elif self.tokenizer.token == '.': # method + if self.search_type_of_sym(self.current_vm[-1]) is not None: + flag = 1 + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + else: + flag = 0 + self.tokenizer.advance() # . -> + fname = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if flag == 1: + self.vmwriter.write_call(f'{self.search_type_of_sym(self.current_vm[-1])}.{fname}', count + 1) + else: + self.vmwriter.write_call(f'{self.current_vm[-1]}.{fname}', count) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'stringConstant': + self.vmwriter.write_push('constant', len(self.current_vm[-1].strip('"'))) + self.vmwriter.write_call('String.new', 1) + for index, item in enumerate(self.current_vm[-1].strip('"')): + self.vmwriter.write_push('constant', ord(item)) + self.vmwriter.write_call('String.appendChar', 2) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'integerConstant': + self.vmwriter.write_push('constant', self.current_vm[-1]) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'identifier': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + elif self.current_vm[-1] == 'true': + self.vmwriter.write_push('constant', '1') + self.vmwriter.write_arithmetic('neg') + self.current_vm.pop() + elif self.current_vm[-1] == 'false' or self.current_vm[-1] == 'null': + self.vmwriter.write_push('constant', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'this': + self.vmwriter.write_push('pointer', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'that': + self.vmwriter.write_push('pointer', '1') + self.current_vm.pop() + + def compile_expression_list(self): + count_exp = 0 + if self.tokenizer.token in ['(', '~', '-'] or self.tokenizer.token_type() != 'symbol': + count_exp += 1 + self.compile_expression() + while self.tokenizer.token == ',': + count_exp += 1 + self.tokenizer.advance() # , + self.compile_expression() + return count_exp + + +if __name__ == '__main__': + path = os.getcwd() + for root, dirs, files in os.walk(path, topdown=False): + for name in files: + if name[-4:] == 'jack': + tokenizer_main = Tokenizer() + tokenizer_main.clear_file(Path(root, name)) + full_path = Path(root, name[:-4] + 'vm') + comp_eng_main = CompilationEngine(tokenizer_main, full_path) + comp_eng_main.compile_class() diff --git a/projects/12/StringTest/Main.jack b/projects/12/StringTest/Main.jack new file mode 100755 index 0000000..73331ef --- /dev/null +++ b/projects/12/StringTest/Main.jack @@ -0,0 +1,83 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/StringTest/Main.jack + +/** Test program for the OS String class. */ +class Main { + + /** Performs various string manipulations and displays their results. */ + function void main() { + var String s; + var String i; + + let s = String.new(0); // a zero-capacity string should be supported + do s.dispose(); + + let s = String.new(6); // capacity 6, make sure that length 5 is displayed + let s = s.appendChar(97); + let s = s.appendChar(98); + let s = s.appendChar(99); + let s = s.appendChar(100); + let s = s.appendChar(101); + do Output.printString("new: "); + do Output.printString(s); // new, appendChar: abcde + do Output.println(); + + let i = String.new(6); + do i.setInt(12345); + do Output.printString("setInt: "); + do Output.printString(i); // setInt: 12345 + do Output.println(); + + do i.setInt(-32767); + do Output.printString("setInt: "); + do Output.printString(i); // setInt: -32767 + do Output.println(); + + do Output.printString("length: "); + do Output.printInt(s.length()); // length: 5 + do Output.println(); + + do Output.printString("charAt[2]: "); + do Output.printInt(s.charAt(2)); // charAt[2]: 99 + do Output.println(); + + do s.setCharAt(2, 45); + do Output.printString("setCharAt(2,'-'): "); + do Output.printString(s); // setCharAt(2,'-'): ab-de + do Output.println(); + + do s.eraseLastChar(); + do Output.printString("eraseLastChar: "); + do Output.printString(s); // eraseLastChar: ab-d + do Output.println(); + + let s = "456"; + do Output.printString("intValue: "); + do Output.printInt(s.intValue()); // intValue: 456 + do Output.println(); + + let s = "-32123"; + do Output.printString("intValue: "); + do Output.printInt(s.intValue()); // intValue: -32123 + do Output.println(); + + do Output.printString("backSpace: "); + do Output.printInt(String.backSpace()); // backSpace: 129 + do Output.println(); + + do Output.printString("doubleQuote: "); + do Output.printInt(String.doubleQuote());// doubleQuote: 34 + do Output.println(); + + do Output.printString("newLine: "); + do Output.printInt(String.newLine()); // newLine: 128 + do Output.println(); + + do i.dispose(); + do s.dispose(); + + return; + } +} diff --git a/projects/12/StringTest/Main.vm b/projects/12/StringTest/Main.vm new file mode 100755 index 0000000..edf09b5 --- /dev/null +++ b/projects/12/StringTest/Main.vm @@ -0,0 +1,447 @@ +function Main.main 2 +push constant 0 +call String.new 1 +pop local 0 +push local 0 +call String.dispose 1 +pop temp 0 +push constant 6 +call String.new 1 +pop local 0 +push local 0 +push constant 97 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 98 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 99 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 100 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 101 +call String.appendChar 2 +pop local 0 +push constant 5 +call String.new 1 +push constant 110 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 6 +call String.new 1 +pop local 1 +push local 1 +push constant 12345 +call String.setInt 2 +pop temp 0 +push constant 8 +call String.new 1 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 73 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 1 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 1 +push constant 32767 +neg +call String.setInt 2 +pop temp 0 +push constant 8 +call String.new 1 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 73 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 1 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 8 +call String.new 1 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call String.length 1 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 11 +call String.new 1 +push constant 99 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 65 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 91 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 93 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +push constant 2 +call String.charAt 2 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 0 +push constant 2 +push constant 45 +call String.setCharAt 3 +pop temp 0 +push constant 18 +call String.new 1 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 67 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 65 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 40 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 44 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 45 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 41 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 0 +call String.eraseLastChar 1 +pop temp 0 +push constant 15 +call String.new 1 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 76 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 67 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 3 +call String.new 1 +push constant 52 +call String.appendChar 2 +push constant 53 +call String.appendChar 2 +push constant 54 +call String.appendChar 2 +pop local 0 +push constant 10 +call String.new 1 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 86 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call String.intValue 1 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 6 +call String.new 1 +push constant 45 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +pop local 0 +push constant 10 +call String.new 1 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 86 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call String.intValue 1 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 11 +call String.new 1 +push constant 98 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 83 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call String.backSpace 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 13 +call String.new 1 +push constant 100 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 81 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call String.doubleQuote 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 9 +call String.new 1 +push constant 110 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 76 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call String.newLine 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 1 +call String.dispose 1 +pop temp 0 +push local 0 +call String.dispose 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/StringTest/String.jack b/projects/12/StringTest/String.jack new file mode 100755 index 0000000..f64ff57 --- /dev/null +++ b/projects/12/StringTest/String.jack @@ -0,0 +1,147 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/String.jack + +/** + * Represents character strings. In addition for constructing and disposing + * strings, the class features methods for getting and setting individual + * characters of the string, for erasing the string's last character, + * for appending a character to the string's end, and more typical + * string-oriented operations. + */ +class String { + field Array str; + field int length; + static bool neg; + + /** constructs a new empty string with a maximum length of maxLength + * and initial length of 0. */ + constructor String new(int maxLength) { + if (maxLength > 0){ + let str = Array.new(maxLength); + } + let length = 0; + return this; + } + + /** Disposes this string. */ + method void dispose() { + if(length > 0){ + do str.dispose(); + } + do Memory.deAlloc(this); + return; + } + + /** Returns the current length of this string. */ + method int length() { + return length; + } + + /** Returns the character at the j-th location of this string. */ + method char charAt(int j) { + if(j > length){ + do Sys.error(7); + } + return str[j]; + } + + /** Sets the character at the j-th location of this string to c. */ + method void setCharAt(int j, char c) { + if(j > length){ + do Sys.error(7); + } + let str[j] = c; + return; + } + + /** Appends c to this string's end and returns this string. */ + method String appendChar(char c) { + let str[length] = c; + let length = length + 1; + return this; + } + + /** Erases the last character from this string. */ + method void eraseLastChar() { + let str[length] = 0; + let length = length - 1; + return; + } + + /** Returns the integer value of this string, + * until a non-digit character is detected. */ + method int intValue() { + var int d, sum, i; + var bool f; + while(i < length){ + let d = str[i]; // kak da go zavyrtq v realen int + if ((d > 47) & (d < 58)){ + let sum = (sum * 10) + (d - 48); + } + else{ + if((i = 0) & (d = 45)){ + let f = true; + } + else{ + let i = length; + } + } + let i = i + 1; + } + if (f){ + return -sum; + } + return sum; + } + + /** Sets this string to hold a representation of the given value. */ + method void setInt(int val) { + var int lastDigit, a, i; + var char c; + if(val < 0){ + let neg = true; + let val = -val; + } + let a = val / 10; + let lastDigit = val - (a * 10); + let i = 48; + while (i < 58){ + if (i = (48 + lastDigit)){ + let c = i; + let i = 59; + } + let i = i + 1; + } + if (val < 10){ + let length = 0; + if (neg){ + let neg = false; + do this.appendChar("-"); + } + do this.appendChar(c); + return; + } + else{ + do this.setInt(a); + do this.appendChar(c); + } + return; + } + + /** Returns the new line character. */ + function char newLine() { + return 128; + } + + /** Returns the backspace character. */ + function char backSpace() { + return 129; + } + + /** Returns the double quote (") character. */ + function char doubleQuote() { + return 34; + } +} diff --git a/projects/12/StringTest/String.vm b/projects/12/StringTest/String.vm new file mode 100755 index 0000000..96c9780 --- /dev/null +++ b/projects/12/StringTest/String.vm @@ -0,0 +1,295 @@ +function String.new 0 +push constant 2 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +push constant 0 +gt +not +if-goto L0 +push argument 0 +call Array.new 1 +pop this 0 +goto L1 +label L0 +label L1 +push constant 0 +pop this 1 +push pointer 0 +return +function String.dispose 0 +push argument 0 +pop pointer 0 +push this 1 +push constant 0 +gt +not +if-goto L2 +push this 0 +call Array.dispose 1 +pop temp 0 +goto L3 +label L2 +label L3 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function String.length 0 +push argument 0 +pop pointer 0 +push this 1 +return +function String.charAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push this 1 +gt +not +if-goto L4 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L5 +label L4 +label L5 +push this 0 +push argument 1 +add +pop pointer 1 +push that 0 +return +function String.setCharAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push this 1 +gt +not +if-goto L6 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L7 +label L6 +label L7 +push this 0 +push argument 1 +push argument 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function String.appendChar 0 +push argument 0 +pop pointer 0 +push this 0 +push this 1 +push argument 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push this 1 +push constant 1 +add +pop this 1 +push pointer 0 +return +function String.eraseLastChar 0 +push argument 0 +pop pointer 0 +push this 0 +push this 1 +push constant 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push this 1 +push constant 1 +sub +pop this 1 +push constant 0 +return +function String.intValue 4 +push argument 0 +pop pointer 0 +label L8 +push local 2 +push this 1 +lt +not +if-goto L9 +push this 0 +push local 2 +add +pop pointer 1 +push that 0 +pop local 0 +push local 0 +push constant 47 +gt +push local 0 +push constant 58 +lt +and +not +if-goto L10 +push local 1 +push constant 10 +call Math.multiply 2 +push local 0 +push constant 48 +sub +add +pop local 1 +goto L11 +label L10 +push local 2 +push constant 0 +eq +push local 0 +push constant 45 +eq +and +not +if-goto L12 +push constant 1 +neg +pop local 3 +goto L13 +label L12 +push this 1 +pop local 2 +label L13 +label L11 +push local 2 +push constant 1 +add +pop local 2 +goto L8 +label L9 +push local 3 +not +if-goto L14 +push local 1 +neg +return +goto L15 +label L14 +label L15 +push local 1 +return +function String.setInt 4 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +not +if-goto L16 +push constant 1 +neg +pop static 0 +push argument 1 +neg +pop argument 1 +goto L17 +label L16 +label L17 +push argument 1 +push constant 10 +call Math.divide 2 +pop local 1 +push argument 1 +push local 1 +push constant 10 +call Math.multiply 2 +sub +pop local 0 +push constant 48 +pop local 2 +label L18 +push local 2 +push constant 58 +lt +not +if-goto L19 +push local 2 +push constant 48 +push local 0 +add +eq +not +if-goto L20 +push local 2 +pop local 3 +push constant 59 +pop local 2 +goto L21 +label L20 +label L21 +push local 2 +push constant 1 +add +pop local 2 +goto L18 +label L19 +push argument 1 +push constant 10 +lt +not +if-goto L22 +push constant 0 +pop this 1 +push static 0 +not +if-goto L23 +push constant 0 +pop static 0 +push argument 0 +push constant 1 +call String.new 1 +push constant 45 +call String.appendChar 2 +call String.appendChar 2 +pop temp 0 +goto L24 +label L23 +label L24 +push argument 0 +push local 3 +call String.appendChar 2 +pop temp 0 +push constant 0 +return +goto L25 +label L22 +push argument 0 +push local 1 +call String.setInt 2 +pop temp 0 +push argument 0 +push local 3 +call String.appendChar 2 +pop temp 0 +label L25 +push constant 0 +return +function String.newLine 0 +push constant 128 +return +function String.backSpace 0 +push constant 129 +return +function String.doubleQuote 0 +push constant 34 +return diff --git a/projects/12/StringTest/StringTestOutput.gif b/projects/12/StringTest/StringTestOutput.gif new file mode 100755 index 0000000..5c2932c Binary files /dev/null and b/projects/12/StringTest/StringTestOutput.gif differ diff --git a/projects/12/StringTest/__pycache__/symbol_table.cpython-39.pyc b/projects/12/StringTest/__pycache__/symbol_table.cpython-39.pyc new file mode 100755 index 0000000..74bcb5c Binary files /dev/null and b/projects/12/StringTest/__pycache__/symbol_table.cpython-39.pyc differ diff --git a/projects/12/StringTest/__pycache__/tokenizer.cpython-39.pyc b/projects/12/StringTest/__pycache__/tokenizer.cpython-39.pyc new file mode 100755 index 0000000..d49ace6 Binary files /dev/null and b/projects/12/StringTest/__pycache__/tokenizer.cpython-39.pyc differ diff --git a/projects/12/StringTest/__pycache__/vmwriter.cpython-39.pyc b/projects/12/StringTest/__pycache__/vmwriter.cpython-39.pyc new file mode 100755 index 0000000..7e2ab5f Binary files /dev/null and b/projects/12/StringTest/__pycache__/vmwriter.cpython-39.pyc differ diff --git a/projects/12/StringTest/symbol_table.py b/projects/12/StringTest/symbol_table.py new file mode 100755 index 0000000..7c62c3e --- /dev/null +++ b/projects/12/StringTest/symbol_table.py @@ -0,0 +1,62 @@ +class Symbol: + def __init__(self): + self.s_name = '' + self.s_kind = '' + self.s_type = '' + self.s_index = 0 + + +class SymbolTable: + def __init__(self): + self.sym = [] + + def define(self, s_name, s_type, s_kind): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = s_kind + self.sym[-1].s_index = self.var_count(s_kind) - 1 + + def start_subroutine(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'argument' + self.sym[-1].s_index = 0 + + def start_class(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = 'this' + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'field' + self.sym[-1].s_index = 0 + + def var_count(self, s_kind): + count = 0 # it is -1 so the first index is 0 + for i in self.sym: + if i.s_kind == s_kind: + count += 1 + return count + + def kind_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + if i.s_kind == 'var': + return 'local' + elif i.s_kind == 'field': + return 'this' + else: + return i.s_kind + return None + + def type_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_type + return None + + def index_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_index + return None diff --git a/projects/12/StringTest/tokenizer.py b/projects/12/StringTest/tokenizer.py new file mode 100755 index 0000000..aaaa873 --- /dev/null +++ b/projects/12/StringTest/tokenizer.py @@ -0,0 +1,78 @@ +import re + + +class Tokenizer: + + def __init__(self): + self.i = 0 + self.file = '' + self.symbols = ('(', ')', '[', ']', '}', '{', '>', '<', '=', '*', '+', '-', '/', '.', ';', ',', '&', '|', + '~') + self.key_word = ( + 'class', 'method', 'function', 'constructor', 'int', 'boolean', 'char', 'void', 'var', 'static', 'field', + 'let', 'do', 'if', 'else', 'while', 'return', 'true', 'false', 'null', 'this') + self.token = '' + + def token_type(self, token=None): + if token is None: + token = self.token + if token is None or token == '': + return None + if token in self.key_word: + return 'keyword' + elif token[0] == '"': + return 'stringConstant' + elif re.match(r"\d+", token): + return 'integerConstant' + elif token in self.symbols: + return 'symbol' + else: + return 'identifier' + + def advance(self): + token = '' + i = self.i + while i < len(self.file): + if re.match(r'\s', self.file[i]): + i = i + 1 + continue + else: + if self.file[i] in self.symbols: + self.token = self.file[i] + self.i = i + 1 + return + elif self.file[i] == '"': + i += 1 + while self.file[i] != '"': + token += self.file[i] + i += 1 + self.i = i + 1 + self.token = '"' + token + '"' + return + else: + while re.match(r'\w', self.file[i]): + token += self.file[i] + if i + 1 > len(self.file) - 1: + break + i += 1 + self.i = i + self.token = token + return + + def clear_file(self, directory): + with open(directory, "r") as my_file: + txt = my_file.read() + txt = re.sub(r"//.*", "", txt) + txt = re.sub(r"/[*][*].*[*]/", "", txt) + i = 0 + # TODO this should be a regex + while i < len(txt): + if txt[i] == '/' and txt[i + 1] == '*' and txt[i + 2] == '*': + start = i + while txt[i] != '*' or txt[i + 1] != '/': + i += 1 + stop = i + 2 + txt = txt[:start] + txt[stop:len(txt)] + i = start - 1 + i += 1 + self.file = txt diff --git a/projects/12/StringTest/vmwriter.py b/projects/12/StringTest/vmwriter.py new file mode 100755 index 0000000..5bf6929 --- /dev/null +++ b/projects/12/StringTest/vmwriter.py @@ -0,0 +1,75 @@ +class VMWriter: + def __init__(self, vm_path): + self.my_vm = open(vm_path, "w+") + self.label_index = 0 + + def write_push(self, segment, index): + self.my_vm.write(f'push {segment} {index}\n') + print(f'push {segment} {index}') + + def write_lable(self, label): + self.my_vm.write(f'label L{label}\n') + print(f'label L{label}') + + def write_arithmetic(self, command): + if command == '+': + self.my_vm.write('add\n') + print('add') + elif command == '-': + self.my_vm.write('sub\n') + print('sub') + elif command == 'neg': + self.my_vm.write('neg\n') + print('neg') + elif command == '=': + self.my_vm.write('eq\n') + print('eq') + elif command == '>': + self.my_vm.write('gt\n') + print('gt') + elif command == '<': + self.my_vm.write('lt\n') + print('lt') + elif command == '&': + self.my_vm.write('and\n') + print('and') + elif command == '|': + self.my_vm.write('or\n') + print('or') + elif command == '~': + self.my_vm.write('not\n') + print('not') + elif command == '*': + self.write_call('Math.multiply', 2) + elif command == '/': + self.write_call('Math.divide', 2) + + def write_pop(self, segment, index): + print(f'pop {segment} {index}') + self.my_vm.write(f'pop {segment} {index}\n') + + def write_goto(self, label): + self.my_vm.write(f'goto L{label}\n') + print(f'goto L{label}') + + def write_if(self, label): + self.write_arithmetic('~') + self.my_vm.write(f'if-goto L{label}\n') + print(f'if-goto L{label}') + + def write_call(self, label, num_args): + self.my_vm.write(f'call {label} {num_args}\n') + print(f'call {label} {num_args}') + + def write_function(self, label, num_locals): + self.my_vm.write(f'function {label} {num_locals}\n') + print(f'function {label} {num_locals}') + + def write_return(self, func_type): + if func_type == 'void': + self.write_push('constant', '0') + self.my_vm.write('return\n') + print(f'return') + + def close_vm_file(self): + self.my_vm.close() diff --git a/projects/12/Sys.jack b/projects/12/Sys.jack new file mode 100755 index 0000000..0eed65b --- /dev/null +++ b/projects/12/Sys.jack @@ -0,0 +1,53 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Sys.jack + +/** + * A library that supports various program execution services. + */ +class Sys { + + /** Performs all the initializations required by the OS. */ + function void init() { + do Memory.init(); + do Math.init(); + do Output.init(); + do Screen.init(); + do Keyboard.init(); + do Main.main(); + do Sys.halt(); + return; + } + + /** Halts the program execution. */ + function void halt() { + while(true){ + } + return; + } + + /** Waits approximately duration milliseconds and returns. */ + function void wait(int duration) { + var int i; + while (duration > 0){ + let i = 100; + while(i > 0){ + let i = i -1; + } + let duration = duration - 1; + } + return; + } + + /** Displays the given error code in the form "ERR", + * and halts the program's execution. */ + function void error(int errorCode) { + var String s; + let s = String.new(3); + do s.setInt(errorCode); + do Output.printString("ERR"); + do Output.printString(s); + return; + } +} diff --git a/projects/12/SysTest/Main.jack b/projects/12/SysTest/Main.jack new file mode 100755 index 0000000..a153b25 --- /dev/null +++ b/projects/12/SysTest/Main.jack @@ -0,0 +1,31 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/SysTest/Main.jack + +/** Test program for the OS Sys class. */ +class Main { + + /** Tests the wait method of the Sys class. */ + function void main() { + var char key; + + do Output.printString("Wait test:"); + do Output.println(); + do Output.printString("Press any key. After 2 seconds, another message will be printed:"); + + while (key = 0) { + let key = Keyboard.keyPressed(); + } + while (~(key = 0)) { + let key = Keyboard.keyPressed(); + } + + do Sys.wait(2000); + + do Output.println(); + do Output.printString("Time is up. Make sure that 2 seconds elapsed."); + + return; + } +} diff --git a/projects/12/SysTest/Main.vm b/projects/12/SysTest/Main.vm new file mode 100755 index 0000000..21b5a2a --- /dev/null +++ b/projects/12/SysTest/Main.vm @@ -0,0 +1,281 @@ +function Main.main 1 +push constant 10 +call String.new 1 +push constant 87 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 64 +call String.new 1 +push constant 80 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 121 +call String.appendChar 2 +push constant 46 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 65 +call String.appendChar 2 +push constant 102 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 44 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +label L0 +push local 0 +push constant 0 +eq +not +if-goto L1 +call Keyboard.keyPressed 0 +pop local 0 +goto L0 +label L1 +label L2 +push local 0 +push constant 0 +eq +not +not +if-goto L3 +call Keyboard.keyPressed 0 +pop local 0 +goto L2 +label L3 +push constant 2000 +call Sys.wait 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 45 +call String.new 1 +push constant 84 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 109 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 46 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 77 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 100 +call String.appendChar 2 +push constant 46 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/SysTest/Sys.jack b/projects/12/SysTest/Sys.jack new file mode 100755 index 0000000..5d6a5f1 --- /dev/null +++ b/projects/12/SysTest/Sys.jack @@ -0,0 +1,51 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Sys.jack + +/** + * A library that supports various program execution services. + */ +class Sys { + + /** Performs all the initializations required by the OS. */ + function void init() { + do Math.init(); + do Keyboard.init(); + do Memory.init(); + do Output.init(); + do Screen.init(); + do Main.main(); + do Sys.halt(); + } + + /** Halts the program execution. */ + function void halt() { + while(true){ + } + } + + /** Waits approximately duration milliseconds and returns. */ + function void wait(int duration) { + var int i; + while (duration > 0){ + let i = 100; + while(i > 0){ + let i = i -1; + } + let duration = duration - 1; + } + return; + } + + /** Displays the given error code in the form "ERR", + * and halts the program's execution. */ + function void error(int errorCode) { + var String s; + let s = String.new(3); + do s.setInt(errorCode); + do Output.printString("ERR"); + do Output.printString(s); + return; + } +} diff --git a/projects/12/SysTest/Sys.vm b/projects/12/SysTest/Sys.vm new file mode 100755 index 0000000..ffbadbf --- /dev/null +++ b/projects/12/SysTest/Sys.vm @@ -0,0 +1,75 @@ +function Sys.init 0 +call Math.init 0 +pop temp 0 +call Keyboard.init 0 +pop temp 0 +call Memory.init 0 +pop temp 0 +call Output.init 0 +pop temp 0 +call Screen.init 0 +pop temp 0 +call Main.main 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +function Sys.halt 0 +label L0 +push constant 1 +neg +not +if-goto L1 +goto L0 +label L1 +function Sys.wait 1 +label L2 +push argument 0 +push constant 0 +gt +not +if-goto L3 +push constant 100 +pop local 0 +label L4 +push local 0 +push constant 0 +gt +not +if-goto L5 +push local 0 +push constant 1 +sub +pop local 0 +goto L4 +label L5 +push argument 0 +push constant 1 +sub +pop argument 0 +goto L2 +label L3 +push constant 0 +return +function Sys.error 1 +push constant 3 +call String.new 1 +pop local 0 +push local 0 +push argument 0 +call String.setInt 2 +pop temp 0 +push constant 3 +call String.new 1 +push constant 69 +call String.appendChar 2 +push constant 82 +call String.appendChar 2 +push constant 82 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/archive/Main.jack b/projects/12/archive/Main.jack new file mode 100755 index 0000000..cc64493 --- /dev/null +++ b/projects/12/archive/Main.jack @@ -0,0 +1,132 @@ +class Main{ + static Array mem; + + + /** Initializes the screen, and locates the cursor at the screen's top-left. */ + function void test_init() { + let mem = 0; + return; + } + + function void main(){ + var String s; + var int i; + let s = String.new(10); + do Main.test_init(); + let s = Main.readLine("String: "); + let i = Main.readInt("INT: "); + do Output.printString(s); + do Output.printInt(i); + return; + } + + + function char keyPressed(){ + return mem[24576]; + } + + function int readInt_stolen(String message){ + var starting a; + var int b; + let a = Main.readLine_stolen(message); + let b = String.intValue(a); + do String.dispose(a); + return b; + } + function string readLine_stolen(String message){ + var char a, b ,c; + var String d; + var bool e; + let d = String.new(80); + do Output.printString(message); + let b = String.newLine(); + let c = String.backSpace(); + while (~e){ + let a = Main.readChar(); + let e = a = b; + if (~e){ + if (a = c){ + do d.eraseLastChar(); + } + else{ + do d.appendChar(a); + } + } + } + return d; + } + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its value. Also handles user backspaces. + */ + function String readLine(String message){ + var String s, b; + var char c; + let s = String.new(100); + do Output.printString(message); + while (true){ + let c = Main.readChar(); + if (c = 128){ + return s; + } + else{ + if (c = 129){ + do s.eraseLastChar(); + } + else{ + do s.appendChar(c); + } + } + } + } + /** + * Waits until a key is pressed on the keyboard and released, + * then echoes the key to the screen, and returns the character + * of the pressed key. + */ + function char readChar(){ + var char a, b; + do Output.printChar(0); + while ((b = 0) | (a > 0)){ + let a = Main.keyPressed(); + if (a > 0){ + let b = a; + } + } + do Output.printChar(String.backSpace()); + do Output.printChar(b); + return b; + } + + + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its integer value (until the first non-digit character in the + * entered text is detected). Also handles user backspaces. + */ + function int readInt(String message) { + var String s; + var char c; + let s = String.new(100); + do Output.printString(message); + while (true){ + let c = Main.readChar(c); + if (c = 128){ + return s.intValue(); + } + else{ + if (c = 129){ + let s = s.eraseLastChar(); + } + else{ + if ((c > 47) & (c < 57)){ + let s = s.appendChar(c); + } + } + } + } + } +} \ No newline at end of file diff --git a/projects/12/archive/Main_math_memory_screen.jack b/projects/12/archive/Main_math_memory_screen.jack new file mode 100755 index 0000000..5960bb1 --- /dev/null +++ b/projects/12/archive/Main_math_memory_screen.jack @@ -0,0 +1,341 @@ +class Main { + + static int division_tmp; + static Array mem; + static Array st; + static int f; + static boolean color; + + /** Initializes the library. */ + function void init_test() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + let color = 1; + return; + } + + + function void main(){ + do Main.init_test(); + do Main.test_drawPixel(256,128); + do Main.test_drawPixel(255,128); + do Main.test_drawPixel(257,128); + do Main.test_changeColor(0); + do Main.test_drawPixel(256,128); + return; + } + function void test_changeColor(boolean x){ + let color = x; + return; + } + function void test_clearScreen(){ + var int a; + let a = 16384; + while (a < 24575){ + let mem[a] = 0; + let a = a + 1; + } + return; + } + function void test_drawRectangle(int x1, int y1, int x2, int y2){ + var int a, tmp; + if (x1 > x2){ + let tmp = x1; + let x1 = x2; + let x2 = tmp; + } + if (y1 > y2){ + let tmp = y1; + let y1 = y2; + let y2 = tmp; + } + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + while(a < y2){ + do Screen.drawLine(x1, y1 + a, x2, y1 + a); + let a = a + 1; + } + return; + } + function void test_drawCicle(int x, int y, int r){ + var int dy, dx, tmp; + if(r > 181){ + do Sys.error(7); + } + let dy = - r; + while (dy < r){ + let tmp = Math.sqrt((r * r) - (dy * dy)); + do Screen.drawLine(x - tmp, y + dy, x + tmp, y + dy); + let dy = dy + 1; + } + return; + } + function void test_drawLine_optimize(int x1, int y1, int x2, int y2){ + var int diff, dx, dy, a, b, tmp; + if (x1 > x2){ + let tmp = x1; + let x1 = x2; + let x2 = tmp; + } + if (y1 > y2){ + let tmp = y1; + let y1 = y2; + let y2 = tmp; + } + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let dx = x2 - x1; + let dy = y2 - y1; + if (dx = 0){ + while(~(b > dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b + 1; + } + return; + } + if (dy = 0){ + while(~(a > dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a + 1; + } + return; + } + while ((~(a > dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff - dx; + } + } + return; + } + + function void test_drawPixel(int x, int y) { + var int value, address, bit, mem_block; + if ((x > 511) | (x < 0) | (y > 255) | (y < 0)){ + do Sys.error(7); + } + let mem_block = x / 16; + let address = (32 * y) + mem_block + 16384; + let value = mem[address]; + let bit = x - (mem_block * 16); + if (color = 1){ + let mem[address] = st[bit] | value; + } + else{ + let mem[address] = (~st[bit])& value; + } + return; + } + + + function int test_multiply(int x, int y){ + var int sum, temp, y_comp, i, neg; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (x < y){ + let temp = x; + let x = y; + let y = temp; + } + if (y = 1){ + if(neg){ + return -x; + } + return x; + } + while((y_comp - 1) < (y - 1)){ + if ((st[i] & y) > 0) { + let sum = sum + x; + let y_comp = y_comp + st[i]; + } + let x = x + x; + let i = i + 1; + } + if(neg){ + let sum = -sum; + } + return sum; + } + function int test_max(int x, int y){ + if (x > y){ + return x; + } + return y; + } + + function int test_min(int x, int y){ + if (x < y){ + return x; + } + return y; + } + function int test_sqrt(int x) { + var int j, b, d, y; + if (x < 0){ + do Sys.error(4); + } + let j = 7; + while (j > -1){ + let d = y + st[j]; + let b = Main.test_multiply(d,d); + if ((~(b > x)) & (b > 0)){ + let y = d; + } + let j = j - 1; + } + return y; + } + function int test_divide(int x, int y) { + var int q, neg; + if (f = 0){ + let division_tmp = 0; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (y = 0){ + do Sys.error(3); + } + let f = 1; + } + if ((y > x) | (y < 0)){ + return 0; + } + let q = test_divide(x, y + y); + let f = 0; + let q = Math.abs(q); + if ((q & 1) = 1){ + let division_tmp = division_tmp + y + y; + } + if (x - division_tmp < y){ + if (neg){ + return -(q + q); + } + return q + q; + } + else{ + if (neg){ + return -(q + q + 1); + } + return q + q + 1; + } + } + + + function int test_abs(int x) { + if (x > 0){ + return x; + } + return -x; + } + + function int test_peek(int x){ + return mem[x]; + } + + function void test_poke(int x, int y){ + let mem[x] = y; + return; + } + + function int test_dealloc_stolen(Array x){ + var int obj_add,b; + let obj_add = x - 2; + let b = obj_add[1]; + if (b[0] = 0){ + let obj_add[0] = obj_add[1] - obj_add -2; + } + else{ + let obj_add[0] = obj_add[1] - obj_add + b[0]; + if (b[1] = b +2){ + let obj_add[1] = obj_add + 2; + } + else{ + let obj_add[1] = b[1]; + } + } + } + + function void test_dealloc(Array o){ + var Array current_block; + let current_block = 2048; + let o[1]= current_block[1]; + let current_block[1] = o; + } + + function int test_alloc(int size){ + var Array current_block; + var int tmp; + let current_block = 2048; + if (size < 0){ + do Sys.error(5); + } + if (size = 0){ + let size = 1; + } + while (current_block[0] < (size + 2)) { + let current_block = current_block[1]; + } + let current_block[0] = current_block[0] - size - 2; + let current_block = current_block + current_block[0] + 2; + let current_block[0] = size; + return current_block + 2; + } + + function int test_alloc_stolen(int x){ + var Array curret_block, next_block; + if (x < 0){ + do Sys.error(5); + } + if (x = 0){ + let x = 1; + } + let curret_block = 2048; + let curret_block[0] = 14334; + let curret_block[1] = 2050; + while ((curret_block < 16383) & (curret_block[0] < x)){ + let next_block = curret_block[1]; + if ((curret_block[0] = 0) | (next_block > 16382) | (next_block[0] = 0)){ // this sends directly out of while + let curret_block = next_block; + } + else { + let curret_block[0] = curret_block[1] - curret_block + next_block[0]; // cb size = + if (next_block[1] = next_block + 2){ + let curret_block[1] = curret_block + 2; + } + else{ + let curret_block[1] = next_block[1]; + } + } + } + if ((curret_block + x) > 16379){ + do Sys.error(6); + } + if (curret_block[0] > (x + 2)){ // if current block fills the desired size perfectly + let curret_block[x + 2] = curret_block[0] - x -2; + if (curret_block[1] = curret_block + 2){ + let curret_block[x + 3] = curret_block + x + 4; + } + else{ + let curret_block[x + 3] = curret_block[1]; + } + } + let curret_block[0] = 0; + return (curret_block + 2); + } + + +} + diff --git a/projects/12/archive/Main_output.jack b/projects/12/archive/Main_output.jack new file mode 100755 index 0000000..0f1942e --- /dev/null +++ b/projects/12/archive/Main_output.jack @@ -0,0 +1,280 @@ +class Main { + + + static Array charMaps; + static int address; + static bool half; + + + /** Initializes the screen, and locates the cursor at the screen's top-left. */ + function void test_init() { + do Main.initMap(); + do Main.moveCursor(0, 0); + return; + } + + function void main(){tInt(i); + + return; + } + + // Returns the character map (array of size 11) of the given character. + // If the given character is invalid or non-printable, returns the + // character map of a black square. + function Array getMap(char c) { + if ((c < 32) | (c > 126)) { + let c = 0; + } + return charMaps[c]; + } + + /** Moves the cursor to the j-th column of the i-th row, + * and erases the character displayed there. */ + function void moveCursor(int i, int j) { + var int count, display; + var Array r, char; + if (j = 0){ + let half = true; + } + else{ + let half = (j / 2) * 2 = j; // chetno true, 1vaa chast + } + let address = (352 * i) + (j / 2) + 16384; + let char = Main.getMap(32); + + while (count < 11){ + if (half){ + let display = r[address] & (-256); + let r[address] = char[count] | display; + } + else{ + let display = r[address] & 255; + let r[address] = (char[count]*256) | display; + } + let count = count + 1; + let address = address + 32; + } + let address = address - 352; + return; + } + + /** Displays the given character at the cursor location, + * and advances the cursor one column forward. */ + function void printChar(char c) { + var Array char, r; + var int count, display; + let char = Main.getMap(c); + while (count < 11){ + if (half){ + let display = r[address] & (-256); + let r[address] = char[count] | display; + } + else{ + let display = r[address] & 255; + let r[address] = (char[count]*256) | display; + } + let count = count + 1; + let address = address + 32; + } + + if (half){ + let address = address - 352; + let half = false; + } + else{ + if (address > 24480){ + let address = 16384; + let half = true; + } + else{ + let address = address - 351; + let half = true; + } + } + return; + } + + /** displays the given string starting at the cursor location, + * and advances the cursor appropriately. */ + function void printString(String s) { + var int i, length; + let length = s.length(); + while (i < length){ + do Main.printChar(s[i+2]); + let i = i + 1; + } + return; + } + + /** Displays the given integer starting at the cursor location, + * and advances the cursor appropriately. */ + function void printInt(int i) { + var String s; + let s = String.new(6); + do s.setInt(i); + do Main.printString(s); + return; + } + + /** Advances the cursor to the beginning of the next line. */ + function void println() { + var int row; + let row = (((address - 16384) / 32)/11) + 1; + if (row > 32){ + let row = 0; + } + do Main.moveCursor(row, 0); + return; + } + + /** Moves the cursor one column back. */ + function void backSpace() { + if (address = 16384){ + let address = 24191; + let half = true; + return; + } + if (half){ + + let address = address - 1; + let half = false; + } + else{ + let half = true; + } + return; + } + // Initializes the character map array + function void initMap() { + var int i; + + let charMaps = Array.new(127); + + // Black square, used for displaying non-printable characters. + do Main.create(0,63,63,63,63,63,63,63,63,63,0,0); + // Assigns the bitmap for each character in the charachter set. + // The first parameter is the character index, the next 11 numbers + // are the values of each row in the frame that represents this character. + do Main.create(32,0,0,0,0,0,0,0,0,0,0,0); // + do Main.create(33,12,30,30,30,12,12,0,12,12,0,0); // ! + do Main.create(34,54,54,20,0,0,0,0,0,0,0,0); // " + do Main.create(35,0,18,18,63,18,18,63,18,18,0,0); // # + do Main.create(36,12,30,51,3,30,48,51,30,12,12,0); // $ + do Main.create(37,0,0,35,51,24,12,6,51,49,0,0); // % + do Main.create(38,12,30,30,12,54,27,27,27,54,0,0); // & + do Main.create(39,12,12,6,0,0,0,0,0,0,0,0); // ' + do Main.create(40,24,12,6,6,6,6,6,12,24,0,0); // ( + do Main.create(41,6,12,24,24,24,24,24,12,6,0,0); // ) + do Main.create(42,0,0,0,51,30,63,30,51,0,0,0); // * + do Main.create(43,0,0,0,12,12,63,12,12,0,0,0); // + + do Main.create(44,0,0,0,0,0,0,0,12,12,6,0); // , + do Main.create(45,0,0,0,0,0,63,0,0,0,0,0); // - + do Main.create(46,0,0,0,0,0,0,0,12,12,0,0); // . + do Main.create(47,0,0,32,48,24,12,6,3,1,0,0); // / + do Main.create(48,12,30,51,51,51,51,51,30,12,0,0); // 0 + do Main.create(49,12,14,15,12,12,12,12,12,63,0,0); // 1 + do Main.create(50,30,51,48,24,12,6,3,51,63,0,0); // 2 + do Main.create(51,30,51,48,48,28,48,48,51,30,0,0); // 3 + do Main.create(52,16,24,28,26,25,63,24,24,60,0,0); // 4 + do Main.create(53,63,3,3,31,48,48,48,51,30,0,0); // 5 + do Main.create(54,28,6,3,3,31,51,51,51,30,0,0); // 6 + do Main.create(55,63,49,48,48,24,12,12,12,12,0,0); // 7 + do Main.create(56,30,51,51,51,30,51,51,51,30,0,0); // 8 + do Main.create(57,30,51,51,51,62,48,48,24,14,0,0); // 9 + do Main.create(58,0,0,12,12,0,0,12,12,0,0,0); // : + do Main.create(59,0,0,12,12,0,0,12,12,6,0,0); // ; + do Main.create(60,0,0,24,12,6,3,6,12,24,0,0); // < + do Main.create(61,0,0,0,63,0,0,63,0,0,0,0); // = + do Main.create(62,0,0,3,6,12,24,12,6,3,0,0); // > + do Main.create(64,30,51,51,59,59,59,27,3,30,0,0); // @ + do Main.create(63,30,51,51,24,12,12,0,12,12,0,0); // ? + do Main.create(65,12,30,51,51,63,51,51,51,51,0,0); // A + do Main.create(66,31,51,51,51,31,51,51,51,31,0,0); // B + do Main.create(67,28,54,35,3,3,3,35,54,28,0,0); // C + do Main.create(68,15,27,51,51,51,51,51,27,15,0,0); // D + do Main.create(69,63,51,35,11,15,11,35,51,63,0,0); // E + do Main.create(70,63,51,35,11,15,11,3,3,3,0,0); // F + do Main.create(71,28,54,35,3,59,51,51,54,44,0,0); // G + do Main.create(72,51,51,51,51,63,51,51,51,51,0,0); // H + do Main.create(73,30,12,12,12,12,12,12,12,30,0,0); // I + do Main.create(74,60,24,24,24,24,24,27,27,14,0,0); // J + do Main.create(75,51,51,51,27,15,27,51,51,51,0,0); // K + do Main.create(76,3,3,3,3,3,3,35,51,63,0,0); // L + do Main.create(77,33,51,63,63,51,51,51,51,51,0,0); // M + do Main.create(78,51,51,55,55,63,59,59,51,51,0,0); // N + do Main.create(79,30,51,51,51,51,51,51,51,30,0,0); // O + do Main.create(80,31,51,51,51,31,3,3,3,3,0,0); // P + do Main.create(81,30,51,51,51,51,51,63,59,30,48,0);// Q + do Main.create(82,31,51,51,51,31,27,51,51,51,0,0); // R + do Main.create(83,30,51,51,6,28,48,51,51,30,0,0); // S + do Main.create(84,63,63,45,12,12,12,12,12,30,0,0); // T + do Main.create(85,51,51,51,51,51,51,51,51,30,0,0); // U + do Main.create(86,51,51,51,51,51,30,30,12,12,0,0); // V + do Main.create(87,51,51,51,51,51,63,63,63,18,0,0); // W + do Main.create(88,51,51,30,30,12,30,30,51,51,0,0); // X + do Main.create(89,51,51,51,51,30,12,12,12,30,0,0); // Y + do Main.create(90,63,51,49,24,12,6,35,51,63,0,0); // Z + + do Main.create(91,30,6,6,6,6,6,6,6,30,0,0); // [ + do Main.create(92,0,0,1,3,6,12,24,48,32,0,0); // \ + do Main.create(93,30,24,24,24,24,24,24,24,30,0,0); // ] + do Main.create(94,8,28,54,0,0,0,0,0,0,0,0); // ^ + do Main.create(95,0,0,0,0,0,0,0,0,0,63,0); // _ + do Main.create(96,6,12,24,0,0,0,0,0,0,0,0); // ` + do Main.create(97,0,0,0,14,24,30,27,27,54,0,0); // a + do Main.create(98,3,3,3,15,27,51,51,51,30,0,0); // b + do Main.create(99,0,0,0,30,51,3,3,51,30,0,0); // c + do Main.create(100,48,48,48,60,54,51,51,51,30,0,0); // d + do Main.create(101,0,0,0,30,51,63,3,51,30,0,0); // e + do Main.create(102,28,54,38,6,15,6,6,6,15,0,0); // f + do Main.create(103,0,0,30,51,51,51,62,48,51,30,0); // g + do Main.create(104,3,3,3,27,55,51,51,51,51,0,0); // h + do Main.create(105,12,12,0,14,12,12,12,12,30,0,0); // i + do Main.create(106,48,48,0,56,48,48,48,48,51,30,0); // j + do Main.create(107,3,3,3,51,27,15,15,27,51,0,0); // k + do Main.create(108,14,12,12,12,12,12,12,12,30,0,0); // l + do Main.create(109,0,0,0,29,63,43,43,43,43,0,0); // m + do Main.create(110,0,0,0,29,51,51,51,51,51,0,0); // n + do Main.create(111,0,0,0,30,51,51,51,51,30,0,0); // o + do Main.create(112,0,0,0,30,51,51,51,31,3,3,0); // p + do Main.create(113,0,0,0,30,51,51,51,62,48,48,0); // q + do Main.create(114,0,0,0,29,55,51,3,3,7,0,0); // r + do Main.create(115,0,0,0,30,51,6,24,51,30,0,0); // s + do Main.create(116,4,6,6,15,6,6,6,54,28,0,0); // t + do Main.create(117,0,0,0,27,27,27,27,27,54,0,0); // u + do Main.create(118,0,0,0,51,51,51,51,30,12,0,0); // v + do Main.create(119,0,0,0,51,51,51,63,63,18,0,0); // w + do Main.create(120,0,0,0,51,30,12,12,30,51,0,0); // x + do Main.create(121,0,0,0,51,51,51,62,48,24,15,0); // y + do Main.create(122,0,0,0,63,27,12,6,51,63,0,0); // z + do Main.create(123,56,12,12,12,7,12,12,12,56,0,0); // { + do Main.create(124,12,12,12,12,12,12,12,12,12,0,0); // | + do Main.create(125,7,12,12,12,56,12,12,12,7,0,0); // } + do Main.create(126,38,45,25,0,0,0,0,0,0,0,0); // ~ + + return; + } + + // Creates the character map array of the given character index, using the given values. + function void create(int index, int a, int b, int c, int d, int e, + int f, int g, int h, int i, int j, int k) { + var Array map; + + let map = Array.new(11); + let charMaps[index] = map; + + let map[0] = a; + let map[1] = b; + let map[2] = c; + let map[3] = d; + let map[4] = e; + let map[5] = f; + let map[6] = g; + let map[7] = h; + let map[8] = i; + let map[9] = j; + let map[10] = k; + + return; + } +} diff --git a/projects/12/archive/String.jack b/projects/12/archive/String.jack new file mode 100755 index 0000000..2e8d90e --- /dev/null +++ b/projects/12/archive/String.jack @@ -0,0 +1,148 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/String.jack + +/** + * Represents character strings. In addition for constructing and disposing + * strings, the class features methods for getting and setting individual + * characters of the string, for erasing the string's last character, + * for appending a character to the string's end, and more typical + * string-oriented operations. + */ +class String { + field Array str; + field int length; + static bool neg; + + /** constructs a new empty string with a maximum length of maxLength + * and initial length of 0. */ + constructor String new(int maxLength) { + if (maxLength > 0){ + let str = Array.new(maxLength); + } + let length = 0; + return this; + } + + /** Disposes this string. */ + method void dispose() { + if(length > 0){ + do str.dispose(); + } + do Memory.deAlloc(this); + return; + } + + /** Returns the current length of this string. */ + method int length() { + return length; + } + + /** Returns the character at the j-th location of this string. */ + method char charAt(int j) { + if(j > length){ + do Sys.error(7); + } + return str[j]; + } + + /** Sets the character at the j-th location of this string to c. */ + method void setCharAt(int j, char c) { + if(j > length){ + do Sys.error(7); + } + let str[j] = c; + return; + } + + /** Appends c to this string's end and returns this string. */ + method String appendChar(char c) { + let str[length] = c; + let length = length + 1; + return this; + } + + /** Erases the last character from this string. */ + method void eraseLastChar() { + let str[length] = 0; + let length = length - 1; + return; + } + + /** Returns the integer value of this string, + * until a non-digit character is detected. */ + method int intValue() { + var int d, sum, i; + var bool f; + while(i < length){ + let d = str[i]; // kak da go zavyrtq v realen int + if ((d > 47) & (d < 58)){ + let sum = (sum * 10) + (d - 48); + } + else{ + if((i = 0) & (d = 45)){ + let f = true; + } + else{ + let i = length; + } + } + let i = i + 1; + } + if (f){ + return -sum; + } + return sum; + } + + /** Sets this string to hold a representation of the given value. */ + method void setInt(int val) { + var int lastDigit, a,i; + var char c; + if(val < 0){ + let neg = true; + let val = -val; + } + let a = val / 10; + let lastDigit = val - (a * 10); + let i = 48; + while (i < 58){ + if (i = (48 + lastDigit)){ + let c = i; + let i = 59; + } + let i = i + 1; + } + if (val < 10){ + let length = 0; + if (neg){ + let neg = false; + do this.appendChar(45); + } + + do this.appendChar(c); + return; + } + else{ + do this.setInt(a); + do this.appendChar(c); + } + return; + } + + /** Returns the new line character. */ + function char newLine() { + return 128; + } + + /** Returns the backspace character. */ + function char backSpace() { + return 129; + } + + /** Returns the double quote (") character. */ + function char doubleQuote() { + return 34; + } +} diff --git a/projects/12/test/Array.jack b/projects/12/test/Array.jack new file mode 100755 index 0000000..f16cad6 --- /dev/null +++ b/projects/12/test/Array.jack @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Array.jack + +/** + * Represents an array. + * In the Jack language, arrays are instances of the Array class. + * Once declared, the array entries can be accessed using the usual + * syntax arr[i]. Each array entry can hold a primitive data type as + * well as any object type. Different array entries can have different + * data types. + */ +class Array { + + /** Constructs a new Array of the given size. */ + function Array new(int size) { + if(size < 0){ + do Sys.error(7); + } + return Memory.alloc(size); + } + + /** Disposes this array. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } +} diff --git a/projects/12/test/Array.vm b/projects/12/test/Array.vm new file mode 100755 index 0000000..60838ae --- /dev/null +++ b/projects/12/test/Array.vm @@ -0,0 +1,23 @@ +function Array.new 0 +push argument 0 +push constant 0 +lt +not +if-goto L0 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L1 +label L0 +label L1 +push argument 0 +call Memory.alloc 1 +return +function Array.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/test/JackCompiler.py b/projects/12/test/JackCompiler.py new file mode 100755 index 0000000..5782f99 --- /dev/null +++ b/projects/12/test/JackCompiler.py @@ -0,0 +1,350 @@ +import os +from pathlib import Path +from tokenizer import Tokenizer +from vmwriter import VMWriter +from symbol_table import SymbolTable + + +# TODO add names to variables when you call for them, aka current_vm_append(thingtobeappended=blablac) + +class CompilationEngine: + def __init__(self, tokenizer, full_path_vm): + self.string = self.sub_type = self.class_name = self.function_type = '' + self.tab = self.recursion_index = 0 + self.tokenizer = tokenizer + self.sym_table = [] + self.vmwriter = VMWriter(full_path_vm) + self.current_vm = [] # used to reverse some of the commands, eg a+b need to be a b + + + def search_kind_of_sym(self, current_vm): + if self.sym_table[-1].kind_of(current_vm) is not None: + return self.sym_table[-1].kind_of(current_vm), self.sym_table[-1].index_of(current_vm) + for i in range(len(self.sym_table) - 2, -1, + -1): # start from the amount of sym_tables -2 so it starts from one below the current, + # until it is bigger than -1, walking it backwards + if self.sym_table[i].kind_of(current_vm) in ('static', 'this'): + return self.sym_table[i].kind_of(current_vm), self.sym_table[i].index_of(current_vm) + + def search_type_of_sym(self, current_vm): + for i in range(len(self.sym_table) - 1, -1, -1): + if self.sym_table[i].type_of(current_vm) is not None: + return self.sym_table[i].type_of(current_vm) + + def write_token(self): + if self.tokenizer.token_type() == 'stringConstant': + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token.strip( + '"') + ' \n' + else: + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token + ' \n' + + def compile_class(self): + self.sym_table.append(SymbolTable()) + self.tokenizer.advance() # class -> + self.tokenizer.advance() # type -> + self.class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + self.tokenizer.advance() # { -> + while self.tokenizer.token != '}': + if self.tokenizer.token in ['static', 'field']: + self.compile_class_var_dec() + if self.tokenizer.token in ['constructor', 'function', 'method']: + self.compile_subroutine() + self.tokenizer.advance() + self.sym_table.pop() + self.vmwriter.close_vm_file() + + def compile_class_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_subroutine(self): + self.sym_table.append(SymbolTable()) + self.sub_type = self.tokenizer.token + self.tokenizer.advance() # subroutine type(function|method|constructor) -> + self.function_type = self.tokenizer.token + self.tokenizer.advance() # subroutine kind(int|void|etc..) -> + sub_name = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + if self.sub_type == 'method': + self.sym_table[-1].start_subroutine('this', self.class_name) + self.compile_parameter_list() + self.tokenizer.advance() # { -> + while self.tokenizer.token == 'var': # create only symbol teable entries + self.compile_var_dec() + if self.sub_type == 'constructor': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('constant', self.sym_table[-2].var_count('field')) + self.vmwriter.write_call('Memory.alloc', 1) + self.vmwriter.write_pop('pointer', 0) + elif self.sub_type == 'method': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('argument', 0) + self.vmwriter.write_pop('pointer', 0) + else: + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + while self.tokenizer.token != '}': + self.compile_statements() + self.tokenizer.advance() + self.sym_table.pop() + + def compile_parameter_list(self): + if self.tokenizer.token != ')': + var_type = self.tokenizer.token + self.tokenizer.advance() # var ype -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # var name -> + while self.tokenizer.token == ',': + self.tokenizer.advance() # , -> + var_type = self.tokenizer.token + self.tokenizer.advance() # type -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # name -> + self.tokenizer.advance() # )-> + + def compile_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_statements(self): + while True: + if self.tokenizer.token == 'let': + self.compile_let() + elif self.tokenizer.token == 'if': + self.compile_if() + elif self.tokenizer.token == 'while': + self.compile_while() + elif self.tokenizer.token == 'do': + self.compile_do() + elif self.tokenizer.token == 'return': + self.compile_return() + else: + break + + def compile_do(self): + self.tokenizer.advance() # do -> + class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + if self.tokenizer.token == '(': # method + self.vmwriter.write_push('pointer', 0) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{class_name}', count + 1) + elif self.tokenizer.token == '.': # method or function + self.tokenizer.advance() # . -> + fname = f'{class_name}.{self.tokenizer.token}' + sname = f'{self.search_type_of_sym(class_name)}.{self.tokenizer.token}' + self.tokenizer.advance() # name -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_push(*self.search_kind_of_sym(class_name)) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_call(f'{sname}', count + 1) + else: + self.vmwriter.write_call(f'{fname}', count) + self.vmwriter.write_pop('temp', '0') + self.tokenizer.advance() # ; -> + + def compile_let(self): + flag_array = 0 + self.tokenizer.advance() # let -> + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # var_name -> + if self.tokenizer.token == '[': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.tokenizer.advance() # [ -> + self.compile_expression() + self.tokenizer.advance() # ] -> + flag_array = 1 + self.tokenizer.advance() # = -> + self.compile_expression() + self.tokenizer.advance() # ; -> + if flag_array == 0: + self.vmwriter.write_pop(*self.search_kind_of_sym(self.current_vm[-1])) + else: + self.vmwriter.write_pop('temp', 1) + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('temp', 1) + self.vmwriter.write_pop('that', 0) + self.current_vm.pop() + + def compile_while(self): + self.tokenizer.advance() # while -> + label1 = self.vmwriter.label_index + self.vmwriter.write_lable(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label2 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_goto(label1) + self.vmwriter.write_lable(label2) + + def compile_return(self): + self.tokenizer.advance() # return -> + if self.tokenizer.token != ';': + self.compile_expression() + self.vmwriter.write_return(self.function_type) + self.tokenizer.advance() # ; -> + + def compile_if(self): + self.tokenizer.advance() # if -> + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label1 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + label2 = self.vmwriter.label_index + self.vmwriter.write_goto(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.vmwriter.write_lable(label1) + if self.tokenizer.token == 'else': + self.tokenizer.advance() # else -> + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_lable(label2) + + def compile_expression(self): + self.compile_term() + while self.tokenizer.token in ['+', '-', '*', '/', '|', '=', '>', '<', '&']: + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # symbol -> + self.compile_term() + self.vmwriter.write_arithmetic(self.current_vm[-1]) + self.current_vm.pop() + + def compile_term(self): + if self.tokenizer.token == '(': # expression () + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + elif self.tokenizer.token in ['~', '-']: # uniry op + self.current_vm.append(self.tokenizer.token) + tmp = 'neg' if self.tokenizer.token == '-' else self.tokenizer.token + self.tokenizer.advance() # ~ or - -> + self.compile_term() + self.vmwriter.write_arithmetic(tmp) + self.current_vm.pop() + elif self.tokenizer.token_type() != 'symbol': + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # integer, string, keyword, varnname, subroutine_name, class_name, var_name -> + if self.tokenizer.token == '[': # Array + self.tokenizer.advance() # [ -> + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + self.compile_expression() + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('that', 0) + self.tokenizer.advance() # ] -> + elif self.tokenizer.token == '(': # subroutine_name () + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{self.current_vm[-1]}', count) + self.current_vm.pop() + elif self.tokenizer.token == '.': # method + if self.search_type_of_sym(self.current_vm[-1]) is not None: + flag = 1 + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + else: + flag = 0 + self.tokenizer.advance() # . -> + fname = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if flag == 1: + self.vmwriter.write_call(f'{self.search_type_of_sym(self.current_vm[-1])}.{fname}', count + 1) + else: + self.vmwriter.write_call(f'{self.current_vm[-1]}.{fname}', count) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'stringConstant': + self.vmwriter.write_push('constant', len(self.current_vm[-1].strip('"'))) + self.vmwriter.write_call('String.new', 1) + for index, item in enumerate(self.current_vm[-1].strip('"')): + self.vmwriter.write_push('constant', ord(item)) + self.vmwriter.write_call('String.appendChar', 2) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'integerConstant': + self.vmwriter.write_push('constant', self.current_vm[-1]) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'identifier': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + elif self.current_vm[-1] == 'true': + self.vmwriter.write_push('constant', '1') + self.vmwriter.write_arithmetic('neg') + self.current_vm.pop() + elif self.current_vm[-1] == 'false' or self.current_vm[-1] == 'null': + self.vmwriter.write_push('constant', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'this': + self.vmwriter.write_push('pointer', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'that': + self.vmwriter.write_push('pointer', '1') + self.current_vm.pop() + + def compile_expression_list(self): + count_exp = 0 + if self.tokenizer.token in ['(', '~', '-'] or self.tokenizer.token_type() != 'symbol': + count_exp += 1 + self.compile_expression() + while self.tokenizer.token == ',': + count_exp += 1 + self.tokenizer.advance() # , + self.compile_expression() + return count_exp + + +if __name__ == '__main__': + path = os.getcwd() + for root, dirs, files in os.walk(path, topdown=False): + for name in files: + if name[-4:] == 'jack': + tokenizer_main = Tokenizer() + tokenizer_main.clear_file(Path(root, name)) + full_path = Path(root, name[:-4] + 'vm') + comp_eng_main = CompilationEngine(tokenizer_main, full_path) + comp_eng_main.compile_class() diff --git a/projects/12/test/Keyboard.jack b/projects/12/test/Keyboard.jack new file mode 100755 index 0000000..81e4cc6 --- /dev/null +++ b/projects/12/test/Keyboard.jack @@ -0,0 +1,102 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Keyboard.jack + +/** + * A library for handling user input from the keyboard. + */ + +class Keyboard { + static Array mem; + /** Initializes the keyboard. */ + function void init() { + let mem = 0; + return; + } + + /** + * Returns the character of the currently pressed key on the keyboard; + * if no key is currently pressed, returns 0. + * + * Recognizes all ASCII characters, as well as the following keys: + * new line = 128 = String.newline() + * backspace = 129 = String.backspace() + * left arrow = 130 + * up arrow = 131 + * right arrow = 132 + * down arrow = 133 + * home = 134 + * End = 135 + * page up = 136 + * page down = 137 + * insert = 138 + * delete = 139 + * ESC = 140 + * F1 - F12 = 141 - 152 + */ + function char keyPressed() { + return mem[24576]; + } + + /** + * Waits until a key is pressed on the keyboard and released, + * then echoes the key to the screen, and returns the character + * of the pressed key. + */ + function char readChar() { + var char a, b; + do Output.printChar(0); + while ((b = 0) | (a > 0)){ + let a = Keyboard.keyPressed(); + if (a > 0){ + let b = a; + } + } + do Output.printChar(String.backSpace()); + do Output.printChar(b); + return b; + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its value. Also handles user backspaces. + */ + function String readLine(String message) { + var String s, b; + var char c; + let s = String.new(100); + do Output.printString(message); + while (true){ + let c = Keyboard.readChar(); + if (c = 128){ + return s; + } + else{ + if (c = 129){ + do s.eraseLastChar(); + } + else{ + do s.appendChar(c); + } + } + } + return s; + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its integer value (until the first non-digit character in the + * entered text is detected). Also handles user backspaces. + */ + function int readInt(String message) { + var starting a; + var int b; + let a = Keyboard.readLine(message); + let b = String.intValue(a); + do String.dispose(a); + return b; + } +} diff --git a/projects/12/test/Keyboard.vm b/projects/12/test/Keyboard.vm new file mode 100755 index 0000000..47c4a9c --- /dev/null +++ b/projects/12/test/Keyboard.vm @@ -0,0 +1,103 @@ +function Keyboard.init 0 +push constant 0 +pop static 0 +push constant 0 +return +function Keyboard.keyPressed 0 +push static 0 +push constant 24576 +add +pop pointer 1 +push that 0 +return +function Keyboard.readChar 2 +push constant 0 +call Output.printChar 1 +pop temp 0 +label L0 +push local 1 +push constant 0 +eq +push local 0 +push constant 0 +gt +or +not +if-goto L1 +call Keyboard.keyPressed 0 +pop local 0 +push local 0 +push constant 0 +gt +not +if-goto L2 +push local 0 +pop local 1 +goto L3 +label L2 +label L3 +goto L0 +label L1 +call String.backSpace 0 +call Output.printChar 1 +pop temp 0 +push local 1 +call Output.printChar 1 +pop temp 0 +push local 1 +return +function Keyboard.readLine 3 +push constant 100 +call String.new 1 +pop local 0 +push argument 0 +call Output.printString 1 +pop temp 0 +label L4 +push constant 1 +neg +not +if-goto L5 +call Keyboard.readChar 0 +pop local 2 +push local 2 +push constant 128 +eq +not +if-goto L6 +push local 0 +return +goto L7 +label L6 +push local 2 +push constant 129 +eq +not +if-goto L8 +push local 0 +call String.eraseLastChar 1 +pop temp 0 +goto L9 +label L8 +push local 0 +push local 2 +call String.appendChar 2 +pop temp 0 +label L9 +label L7 +goto L4 +label L5 +push local 0 +return +function Keyboard.readInt 2 +push argument 0 +call Keyboard.readLine 1 +pop local 0 +push local 0 +call String.intValue 1 +pop local 1 +push local 0 +call String.dispose 1 +pop temp 0 +push local 1 +return diff --git a/projects/12/test/Main.jack b/projects/12/test/Main.jack new file mode 100755 index 0000000..73331ef --- /dev/null +++ b/projects/12/test/Main.jack @@ -0,0 +1,83 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/StringTest/Main.jack + +/** Test program for the OS String class. */ +class Main { + + /** Performs various string manipulations and displays their results. */ + function void main() { + var String s; + var String i; + + let s = String.new(0); // a zero-capacity string should be supported + do s.dispose(); + + let s = String.new(6); // capacity 6, make sure that length 5 is displayed + let s = s.appendChar(97); + let s = s.appendChar(98); + let s = s.appendChar(99); + let s = s.appendChar(100); + let s = s.appendChar(101); + do Output.printString("new: "); + do Output.printString(s); // new, appendChar: abcde + do Output.println(); + + let i = String.new(6); + do i.setInt(12345); + do Output.printString("setInt: "); + do Output.printString(i); // setInt: 12345 + do Output.println(); + + do i.setInt(-32767); + do Output.printString("setInt: "); + do Output.printString(i); // setInt: -32767 + do Output.println(); + + do Output.printString("length: "); + do Output.printInt(s.length()); // length: 5 + do Output.println(); + + do Output.printString("charAt[2]: "); + do Output.printInt(s.charAt(2)); // charAt[2]: 99 + do Output.println(); + + do s.setCharAt(2, 45); + do Output.printString("setCharAt(2,'-'): "); + do Output.printString(s); // setCharAt(2,'-'): ab-de + do Output.println(); + + do s.eraseLastChar(); + do Output.printString("eraseLastChar: "); + do Output.printString(s); // eraseLastChar: ab-d + do Output.println(); + + let s = "456"; + do Output.printString("intValue: "); + do Output.printInt(s.intValue()); // intValue: 456 + do Output.println(); + + let s = "-32123"; + do Output.printString("intValue: "); + do Output.printInt(s.intValue()); // intValue: -32123 + do Output.println(); + + do Output.printString("backSpace: "); + do Output.printInt(String.backSpace()); // backSpace: 129 + do Output.println(); + + do Output.printString("doubleQuote: "); + do Output.printInt(String.doubleQuote());// doubleQuote: 34 + do Output.println(); + + do Output.printString("newLine: "); + do Output.printInt(String.newLine()); // newLine: 128 + do Output.println(); + + do i.dispose(); + do s.dispose(); + + return; + } +} diff --git a/projects/12/test/Main.vm b/projects/12/test/Main.vm new file mode 100755 index 0000000..edf09b5 --- /dev/null +++ b/projects/12/test/Main.vm @@ -0,0 +1,447 @@ +function Main.main 2 +push constant 0 +call String.new 1 +pop local 0 +push local 0 +call String.dispose 1 +pop temp 0 +push constant 6 +call String.new 1 +pop local 0 +push local 0 +push constant 97 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 98 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 99 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 100 +call String.appendChar 2 +pop local 0 +push local 0 +push constant 101 +call String.appendChar 2 +pop local 0 +push constant 5 +call String.new 1 +push constant 110 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 6 +call String.new 1 +pop local 1 +push local 1 +push constant 12345 +call String.setInt 2 +pop temp 0 +push constant 8 +call String.new 1 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 73 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 1 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 1 +push constant 32767 +neg +call String.setInt 2 +pop temp 0 +push constant 8 +call String.new 1 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 73 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 1 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 8 +call String.new 1 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 103 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call String.length 1 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 11 +call String.new 1 +push constant 99 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 65 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 91 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 93 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +push constant 2 +call String.charAt 2 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 0 +push constant 2 +push constant 45 +call String.setCharAt 3 +pop temp 0 +push constant 18 +call String.new 1 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 67 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 65 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 40 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 44 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 45 +call String.appendChar 2 +push constant 39 +call String.appendChar 2 +push constant 41 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 0 +call String.eraseLastChar 1 +pop temp 0 +push constant 15 +call String.new 1 +push constant 101 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 76 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 115 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 67 +call String.appendChar 2 +push constant 104 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 114 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 3 +call String.new 1 +push constant 52 +call String.appendChar 2 +push constant 53 +call String.appendChar 2 +push constant 54 +call String.appendChar 2 +pop local 0 +push constant 10 +call String.new 1 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 86 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call String.intValue 1 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 6 +call String.new 1 +push constant 45 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 49 +call String.appendChar 2 +push constant 50 +call String.appendChar 2 +push constant 51 +call String.appendChar 2 +pop local 0 +push constant 10 +call String.new 1 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 86 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call String.intValue 1 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 11 +call String.new 1 +push constant 98 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 107 +call String.appendChar 2 +push constant 83 +call String.appendChar 2 +push constant 112 +call String.appendChar 2 +push constant 97 +call String.appendChar 2 +push constant 99 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call String.backSpace 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 13 +call String.new 1 +push constant 100 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 98 +call String.appendChar 2 +push constant 108 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 81 +call String.appendChar 2 +push constant 117 +call String.appendChar 2 +push constant 111 +call String.appendChar 2 +push constant 116 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call String.doubleQuote 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push constant 9 +call String.new 1 +push constant 110 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 119 +call String.appendChar 2 +push constant 76 +call String.appendChar 2 +push constant 105 +call String.appendChar 2 +push constant 110 +call String.appendChar 2 +push constant 101 +call String.appendChar 2 +push constant 58 +call String.appendChar 2 +push constant 32 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +call String.newLine 0 +call Output.printInt 1 +pop temp 0 +call Output.println 0 +pop temp 0 +push local 1 +call String.dispose 1 +pop temp 0 +push local 0 +call String.dispose 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/test/Math.jack b/projects/12/test/Math.jack new file mode 100755 index 0000000..1730de4 --- /dev/null +++ b/projects/12/test/Math.jack @@ -0,0 +1,143 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Math.jack + +/** + * A library of commonly used mathematical functions. + * Note: Jack compilers implement multiplication and division using OS method calls. + */ +class Math { + static Array st; + static int division_tmp, f; + + /** Initializes the library. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + return; + } + + /** Returns the absolute value of x. */ + function int abs(int x) { + if (x > 0){ + return x; + } + return -x; + } + + /** Returns the product of x and y. + * When a Jack compiler detects the multiplication operator '*' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x*y and multiply(x,y) return the same value. + */ + function int multiply(int x, int y) { + var int sum, temp, y_comp, i, neg; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (x < y){ + let temp = x; + let x = y; + let y = temp; + } + if (y = 1){ + if(neg){ + return -x; + } + return x; + } + while((y_comp - 1) < (y - 1)){ + if ((st[i] & y) > 0) { + let sum = sum + x; + let y_comp = y_comp + st[i]; + } + let x = x + x; + let i = i + 1; + } + if(neg){ + let sum = -sum; + } + return sum; + } + + /** Returns the integer part of x/y. + * When a Jack compiler detects the multiplication operator '/' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x/y and divide(x,y) return the same value. + */ + function int divide(int x, int y) { + var int q, neg; + if (f = 0){ + let division_tmp = 0; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (y = 0){ + do Sys.error(3); + } + let f = 1; + } + if ((y > x) | (y < 0)){ + return 0; + } + let q = Math.divide(x, y + y); + let f = 0; + let q = Math.abs(q); + if ((q & 1) = 1){ + let division_tmp = division_tmp + y + y; + } + if (x - division_tmp < y){ + if (neg){ + return -(q + q); + } + return q + q; + } + else{ + if (neg){ + return -(q + q + 1); + } + return q + q + 1; + } + } + + /** Returns the integer part of the square root of x. */ + function int sqrt(int x) { + var int j, b, d, y; + + if (x < 0){ + do Sys.error(4); + } + let j = 7; + while (j > -1){ + let d = y + st[j]; + let b = d * d; + if ((~(b > x)) & (b > 0)){ + let y = d; + } + let j = j - 1; + } + return y; + } + + /** Returns the greater number. */ + function int max(int a, int b) { + if (a > b){ + return a; + } + return b; + } + + /** Returns the smaller number. */ + function int min(int a, int b) { + if (a < b){ + return a; + } + return b; + } +} diff --git a/projects/12/test/Math.vm b/projects/12/test/Math.vm new file mode 100755 index 0000000..5f85428 --- /dev/null +++ b/projects/12/test/Math.vm @@ -0,0 +1,388 @@ +function Math.init 1 +push constant 16 +call Array.new 1 +pop static 0 +push static 0 +push constant 0 +push constant 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L0 +push local 0 +push constant 15 +lt +not +if-goto L1 +push local 0 +push constant 1 +add +pop local 0 +push static 0 +push local 0 +push static 0 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +push static 0 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +add +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L0 +label L1 +push constant 0 +return +function Math.abs 0 +push argument 0 +push constant 0 +gt +not +if-goto L2 +push argument 0 +return +goto L3 +label L2 +label L3 +push argument 0 +neg +return +function Math.multiply 5 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 4 +push argument 0 +call Math.abs 1 +pop argument 0 +push argument 1 +call Math.abs 1 +pop argument 1 +push argument 0 +push argument 1 +lt +not +if-goto L4 +push argument 0 +pop local 1 +push argument 1 +pop argument 0 +push local 1 +pop argument 1 +goto L5 +label L4 +label L5 +push argument 1 +push constant 1 +eq +not +if-goto L6 +push local 4 +not +if-goto L7 +push argument 0 +neg +return +goto L8 +label L7 +label L8 +push argument 0 +return +goto L9 +label L6 +label L9 +label L10 +push local 2 +push constant 1 +sub +push argument 1 +push constant 1 +sub +lt +not +if-goto L11 +push static 0 +push local 3 +add +pop pointer 1 +push that 0 +push argument 1 +and +push constant 0 +gt +not +if-goto L12 +push local 0 +push argument 0 +add +pop local 0 +push local 2 +push static 0 +push local 3 +add +pop pointer 1 +push that 0 +add +pop local 2 +goto L13 +label L12 +label L13 +push argument 0 +push argument 0 +add +pop argument 0 +push local 3 +push constant 1 +add +pop local 3 +goto L10 +label L11 +push local 4 +not +if-goto L14 +push local 0 +neg +pop local 0 +goto L15 +label L14 +label L15 +push local 0 +return +function Math.divide 2 +push static 2 +push constant 0 +eq +not +if-goto L16 +push constant 0 +pop static 1 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 1 +push argument 0 +call Math.abs 1 +pop argument 0 +push argument 1 +call Math.abs 1 +pop argument 1 +push argument 1 +push constant 0 +eq +not +if-goto L17 +push constant 3 +call Sys.error 1 +pop temp 0 +goto L18 +label L17 +label L18 +push constant 1 +pop static 2 +goto L19 +label L16 +label L19 +push argument 1 +push argument 0 +gt +push argument 1 +push constant 0 +lt +or +not +if-goto L20 +push constant 0 +return +goto L21 +label L20 +label L21 +push argument 0 +push argument 1 +push argument 1 +add +call Math.divide 2 +pop local 0 +push constant 0 +pop static 2 +push local 0 +call Math.abs 1 +pop local 0 +push local 0 +push constant 1 +and +push constant 1 +eq +not +if-goto L22 +push static 1 +push argument 1 +add +push argument 1 +add +pop static 1 +goto L23 +label L22 +label L23 +push argument 0 +push static 1 +sub +push argument 1 +lt +not +if-goto L24 +push local 1 +not +if-goto L25 +push local 0 +push local 0 +add +neg +return +goto L26 +label L25 +label L26 +push local 0 +push local 0 +add +return +goto L27 +label L24 +push local 1 +not +if-goto L28 +push local 0 +push local 0 +add +push constant 1 +add +neg +return +goto L29 +label L28 +label L29 +push local 0 +push local 0 +add +push constant 1 +add +return +label L27 +function Math.sqrt 4 +push argument 0 +push constant 0 +lt +not +if-goto L30 +push constant 4 +call Sys.error 1 +pop temp 0 +goto L31 +label L30 +label L31 +push constant 7 +pop local 0 +label L32 +push local 0 +push constant 1 +neg +gt +not +if-goto L33 +push local 3 +push static 0 +push local 0 +add +pop pointer 1 +push that 0 +add +pop local 2 +push local 2 +push local 2 +call Math.multiply 2 +pop local 1 +push local 1 +push argument 0 +gt +not +push local 1 +push constant 0 +gt +and +not +if-goto L34 +push local 2 +pop local 3 +goto L35 +label L34 +label L35 +push local 0 +push constant 1 +sub +pop local 0 +goto L32 +label L33 +push local 3 +return +function Math.max 0 +push argument 0 +push argument 1 +gt +not +if-goto L36 +push argument 0 +return +goto L37 +label L36 +label L37 +push argument 1 +return +function Math.min 0 +push argument 0 +push argument 1 +lt +not +if-goto L38 +push argument 0 +return +goto L39 +label L38 +label L39 +push argument 1 +return diff --git a/projects/12/test/Memory.jack b/projects/12/test/Memory.jack new file mode 100755 index 0000000..14305f1 --- /dev/null +++ b/projects/12/test/Memory.jack @@ -0,0 +1,63 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Memory.jack + +/** + * This library provides two services: direct access to the computer's main + * memory (RAM), and allocation and recycling of memory blocks. The Hack RAM + * consists of 32,768 words, each holding a 16-bit binary number. + */ +class Memory { + static Array mem; + /** Initializes the class. */ + function void init() { + let mem = 0; + let mem[2048] = 14334; + let mem[2049] = -1; + return; + } + + /** Returns the RAM value at the given address. */ + function int peek(int address) { + return mem[address]; + } + + /** Sets the RAM value at the given address to the given value. */ + function void poke(int address, int value) { + let mem[address] = value; + return; + } + + /** Finds an available RAM block of the given size and returns + * a reference to its base address. */ + function int alloc(int size) { + var Array current_block; + var int tmp; + let current_block = 2048; + if (size < 0){ + do Sys.error(5); + } + if (size = 0){ + let size = 1; + } + while (current_block[0] < (size + 2)) { + let current_block = current_block[1]; + } + let current_block[0] = current_block[0] - size - 2; + let current_block = current_block + current_block[0] + 2; + let current_block[0] = size; + return current_block + 2; + } + + /** De-allocates the given object (cast as an array) by making + * it available for future allocations. */ + function void deAlloc(Array o) { + var Array current_block; + let current_block = 2048; + let o[1]= current_block[1]; + let current_block[1] = o; + return; + + } +} diff --git a/projects/12/test/Memory.vm b/projects/12/test/Memory.vm new file mode 100755 index 0000000..a19cd86 --- /dev/null +++ b/projects/12/test/Memory.vm @@ -0,0 +1,147 @@ +function Memory.init 0 +push constant 0 +pop static 0 +push static 0 +push constant 2048 +push constant 14334 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push static 0 +push constant 2049 +push constant 1 +neg +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function Memory.peek 0 +push static 0 +push argument 0 +add +pop pointer 1 +push that 0 +return +function Memory.poke 0 +push static 0 +push argument 0 +push argument 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function Memory.alloc 2 +push constant 2048 +pop local 0 +push argument 0 +push constant 0 +lt +not +if-goto L0 +push constant 5 +call Sys.error 1 +pop temp 0 +goto L1 +label L0 +label L1 +push argument 0 +push constant 0 +eq +not +if-goto L2 +push constant 1 +pop argument 0 +goto L3 +label L2 +label L3 +label L4 +push local 0 +push constant 0 +add +pop pointer 1 +push that 0 +push argument 0 +push constant 2 +add +lt +not +if-goto L5 +push local 0 +push constant 1 +add +pop pointer 1 +push that 0 +pop local 0 +goto L4 +label L5 +push local 0 +push constant 0 +push local 0 +push constant 0 +add +pop pointer 1 +push that 0 +push argument 0 +sub +push constant 2 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push local 0 +push constant 0 +add +pop pointer 1 +push that 0 +add +push constant 2 +add +pop local 0 +push local 0 +push constant 0 +push argument 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 2 +add +return +function Memory.deAlloc 1 +push constant 2048 +pop local 0 +push argument 0 +push constant 1 +push local 0 +push constant 1 +add +pop pointer 1 +push that 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 1 +push argument 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return diff --git a/projects/12/test/Output.jack b/projects/12/test/Output.jack new file mode 100755 index 0000000..9132280 --- /dev/null +++ b/projects/12/test/Output.jack @@ -0,0 +1,299 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Output.jack + +/** + * A library of functions for writing text on the screen. + * The Hack physical screen consists of 512 rows of 256 pixels each. + * The library uses a fixed font, in which each character is displayed + * within a frame which is 11 pixels high (including 1 pixel for inter-line + * spacing) and 8 pixels wide (including 2 pixels for inter-character spacing). + * The resulting grid accommodates 23 rows (indexed 0..22, top to bottom) + * of 64 characters each (indexed 0..63, left to right). The top left + * character position on the screen is indexed (0,0). A cursor, implemented + * as a small filled square, indicates where the next character will be displayed. + */ +class Output { + + // Character map for displaying characters + static Array charMaps; + static int address; + static bool half; + + /** Initializes the screen, and locates the cursor at the screen's top-left. */ + function void init() { + do Output.initMap(); + do Output.moveCursor(0, 0); + return; + } + + // Initializes the character map array + function void initMap() { + var int i; + + let charMaps = Array.new(127); + + // Black square, used for displaying non-printable characters. + do Output.create(0,63,63,63,63,63,63,63,63,63,0,0); + + // Assigns the bitmap for each character in the charachter set. + // The first parameter is the character index, the next 11 numbers + // are the values of each row in the frame that represents this character. + do Output.create(32,0,0,0,0,0,0,0,0,0,0,0); // + do Output.create(33,12,30,30,30,12,12,0,12,12,0,0); // ! + do Output.create(34,54,54,20,0,0,0,0,0,0,0,0); // " + do Output.create(35,0,18,18,63,18,18,63,18,18,0,0); // # + do Output.create(36,12,30,51,3,30,48,51,30,12,12,0); // $ + do Output.create(37,0,0,35,51,24,12,6,51,49,0,0); // % + do Output.create(38,12,30,30,12,54,27,27,27,54,0,0); // & + do Output.create(39,12,12,6,0,0,0,0,0,0,0,0); // ' + do Output.create(40,24,12,6,6,6,6,6,12,24,0,0); // ( + do Output.create(41,6,12,24,24,24,24,24,12,6,0,0); // ) + do Output.create(42,0,0,0,51,30,63,30,51,0,0,0); // * + do Output.create(43,0,0,0,12,12,63,12,12,0,0,0); // + + do Output.create(44,0,0,0,0,0,0,0,12,12,6,0); // , + do Output.create(45,0,0,0,0,0,63,0,0,0,0,0); // - + do Output.create(46,0,0,0,0,0,0,0,12,12,0,0); // . + do Output.create(47,0,0,32,48,24,12,6,3,1,0,0); // / + + do Output.create(48,12,30,51,51,51,51,51,30,12,0,0); // 0 + do Output.create(49,12,14,15,12,12,12,12,12,63,0,0); // 1 + do Output.create(50,30,51,48,24,12,6,3,51,63,0,0); // 2 + do Output.create(51,30,51,48,48,28,48,48,51,30,0,0); // 3 + do Output.create(52,16,24,28,26,25,63,24,24,60,0,0); // 4 + do Output.create(53,63,3,3,31,48,48,48,51,30,0,0); // 5 + do Output.create(54,28,6,3,3,31,51,51,51,30,0,0); // 6 + do Output.create(55,63,49,48,48,24,12,12,12,12,0,0); // 7 + do Output.create(56,30,51,51,51,30,51,51,51,30,0,0); // 8 + do Output.create(57,30,51,51,51,62,48,48,24,14,0,0); // 9 + + do Output.create(58,0,0,12,12,0,0,12,12,0,0,0); // : + do Output.create(59,0,0,12,12,0,0,12,12,6,0,0); // ; + do Output.create(60,0,0,24,12,6,3,6,12,24,0,0); // < + do Output.create(61,0,0,0,63,0,0,63,0,0,0,0); // = + do Output.create(62,0,0,3,6,12,24,12,6,3,0,0); // > + do Output.create(64,30,51,51,59,59,59,27,3,30,0,0); // @ + do Output.create(63,30,51,51,24,12,12,0,12,12,0,0); // ? + + do Output.create(65,12,30,51,51,63,51,51,51,51,0,0); // A ** TO BE FILLED ** + do Output.create(66,31,51,51,51,31,51,51,51,31,0,0); // B + do Output.create(67,28,54,35,3,3,3,35,54,28,0,0); // C + do Output.create(68,15,27,51,51,51,51,51,27,15,0,0); // D + do Output.create(69,63,51,35,11,15,11,35,51,63,0,0); // E + do Output.create(70,63,51,35,11,15,11,3,3,3,0,0); // F + do Output.create(71,28,54,35,3,59,51,51,54,44,0,0); // G + do Output.create(72,51,51,51,51,63,51,51,51,51,0,0); // H + do Output.create(73,30,12,12,12,12,12,12,12,30,0,0); // I + do Output.create(74,60,24,24,24,24,24,27,27,14,0,0); // J + do Output.create(75,51,51,51,27,15,27,51,51,51,0,0); // K + do Output.create(76,3,3,3,3,3,3,35,51,63,0,0); // L + do Output.create(77,33,51,63,63,51,51,51,51,51,0,0); // M + do Output.create(78,51,51,55,55,63,59,59,51,51,0,0); // N + do Output.create(79,30,51,51,51,51,51,51,51,30,0,0); // O + do Output.create(80,31,51,51,51,31,3,3,3,3,0,0); // P + do Output.create(81,30,51,51,51,51,51,63,59,30,48,0);// Q + do Output.create(82,31,51,51,51,31,27,51,51,51,0,0); // R + do Output.create(83,30,51,51,6,28,48,51,51,30,0,0); // S + do Output.create(84,63,63,45,12,12,12,12,12,30,0,0); // T + do Output.create(85,51,51,51,51,51,51,51,51,30,0,0); // U + do Output.create(86,51,51,51,51,51,30,30,12,12,0,0); // V + do Output.create(87,51,51,51,51,51,63,63,63,18,0,0); // W + do Output.create(88,51,51,30,30,12,30,30,51,51,0,0); // X + do Output.create(89,51,51,51,51,30,12,12,12,30,0,0); // Y + do Output.create(90,63,51,49,24,12,6,35,51,63,0,0); // Z + + do Output.create(91,30,6,6,6,6,6,6,6,30,0,0); // [ + do Output.create(92,0,0,1,3,6,12,24,48,32,0,0); // \ + do Output.create(93,30,24,24,24,24,24,24,24,30,0,0); // ] + do Output.create(94,8,28,54,0,0,0,0,0,0,0,0); // ^ + do Output.create(95,0,0,0,0,0,0,0,0,0,63,0); // _ + do Output.create(96,6,12,24,0,0,0,0,0,0,0,0); // ` + + do Output.create(97,0,0,0,14,24,30,27,27,54,0,0); // a + do Output.create(98,3,3,3,15,27,51,51,51,30,0,0); // b + do Output.create(99,0,0,0,30,51,3,3,51,30,0,0); // c + do Output.create(100,48,48,48,60,54,51,51,51,30,0,0); // d + do Output.create(101,0,0,0,30,51,63,3,51,30,0,0); // e + do Output.create(102,28,54,38,6,15,6,6,6,15,0,0); // f + do Output.create(103,0,0,30,51,51,51,62,48,51,30,0); // g + do Output.create(104,3,3,3,27,55,51,51,51,51,0,0); // h + do Output.create(105,12,12,0,14,12,12,12,12,30,0,0); // i + do Output.create(106,48,48,0,56,48,48,48,48,51,30,0); // j + do Output.create(107,3,3,3,51,27,15,15,27,51,0,0); // k + do Output.create(108,14,12,12,12,12,12,12,12,30,0,0); // l + do Output.create(109,0,0,0,29,63,43,43,43,43,0,0); // m + do Output.create(110,0,0,0,29,51,51,51,51,51,0,0); // n + do Output.create(111,0,0,0,30,51,51,51,51,30,0,0); // o + do Output.create(112,0,0,0,30,51,51,51,31,3,3,0); // p + do Output.create(113,0,0,0,30,51,51,51,62,48,48,0); // q + do Output.create(114,0,0,0,29,55,51,3,3,7,0,0); // r + do Output.create(115,0,0,0,30,51,6,24,51,30,0,0); // s + do Output.create(116,4,6,6,15,6,6,6,54,28,0,0); // t + do Output.create(117,0,0,0,27,27,27,27,27,54,0,0); // u + do Output.create(118,0,0,0,51,51,51,51,30,12,0,0); // v + do Output.create(119,0,0,0,51,51,51,63,63,18,0,0); // w + do Output.create(120,0,0,0,51,30,12,12,30,51,0,0); // x + do Output.create(121,0,0,0,51,51,51,62,48,24,15,0); // y + do Output.create(122,0,0,0,63,27,12,6,51,63,0,0); // z + + do Output.create(123,56,12,12,12,7,12,12,12,56,0,0); // { + do Output.create(124,12,12,12,12,12,12,12,12,12,0,0); // | + do Output.create(125,7,12,12,12,56,12,12,12,7,0,0); // } + do Output.create(126,38,45,25,0,0,0,0,0,0,0,0); // ~ + + return; + } + + // Creates the character map array of the given character index, using the given values. + function void create(int index, int a, int b, int c, int d, int e, + int f, int g, int h, int i, int j, int k) { + var Array map; + + let map = Array.new(11); + let charMaps[index] = map; + + let map[0] = a; + let map[1] = b; + let map[2] = c; + let map[3] = d; + let map[4] = e; + let map[5] = f; + let map[6] = g; + let map[7] = h; + let map[8] = i; + let map[9] = j; + let map[10] = k; + + return; + } + + // Returns the character map (array of size 11) of the given character. + // If the given character is invalid or non-printable, returns the + // character map of a black square. + function Array getMap(char c) { + if ((c < 32) | (c > 126)) { + let c = 0; + } + return charMaps[c]; + } + + /** Moves the cursor to the j-th column of the i-th row, + * and erases the character displayed there. */ + function void moveCursor(int i, int j) { + var int co,display; + var Array r,ch; + if (j = 0){ + let half = true; + } + else{ + let half = (j / 2) * 2 = j; // chetno true, 1vaa chast + } + let address = (352 * i) + (j / 2) + 16384; + let ch = Output.getMap(32); + + while (co < 11){ + if (half){ + let display = r[address] & (-256); + let r[address] = ch[co] | display; + } + else{ + let display = r[address] & 255; + let r[address] = (ch[co]*256) | display; + } + let co = co + 1; + let address = address + 32; + } + let address = address - 352; + return; + } + + /** Displays the given character at the cursor location, + * and advances the cursor one column forward. */ + function void printChar(char c) { + var Array ch; + var Array r; + var int co; + var int ds; + let ch = Output.getMap(c); + while (co < 11){ + if (half){ + let ds = r[address] & (-256); + let r[address] = ch[co] | ds; + } + else{ + let ds = r[address] & 255; + let r[address] = (ch[co]*256) | ds; + } + let co = co + 1; + let address = address + 32; + } + + if (half){ + let address = address - 352; + let half = false; + } + else{ + if (address > 24480){ + let address = 16384; + let half = true; + } + else{ + let address = address - 351; + let half = true; + } + } + return; + } + + /** displays the given string starting at the cursor location, + * and advances the cursor appropriately. */ + function void printString(String s) { + var int i, length; + let length = s.length(); + while (i < length){ + do Output.printChar(s.charAt(i)); + let i = i + 1; + } + return; + } + + /** Displays the given integer starting at the cursor location, + * and advances the cursor appropriately. */ + function void printInt(int i) { + var String s; + let s = String.new(6); + do s.setInt(i); + do Output.printString(s); + return; + } + + /** Advances the cursor to the beginning of the next line. */ + function void println() { + var int row; + let row = (((address - 16384) / 32)/11) + 1; + if (row > 32){ + let row = 0; + } + do Output.moveCursor(row, 0); + return; + } + + /** Moves the cursor one column back. */ + function void backSpace() { + if (address = 16384){ + let address = 24191; + let half = true; + return; + } + if (half){ + + let address = address - 1; + let half = false; + } + else{ + let half = true; + } + return; + } +} diff --git a/projects/12/test/Output.vm b/projects/12/test/Output.vm new file mode 100755 index 0000000..63a6cc0 --- /dev/null +++ b/projects/12/test/Output.vm @@ -0,0 +1,1793 @@ +function Output.init 0 +call Output.initMap 0 +pop temp 0 +push constant 0 +push constant 0 +call Output.moveCursor 2 +pop temp 0 +push constant 0 +return +function Output.initMap 1 +push constant 127 +call Array.new 1 +pop static 0 +push constant 0 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 32 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 33 +push constant 12 +push constant 30 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 34 +push constant 54 +push constant 54 +push constant 20 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 35 +push constant 0 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 36 +push constant 12 +push constant 30 +push constant 51 +push constant 3 +push constant 30 +push constant 48 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 37 +push constant 0 +push constant 0 +push constant 35 +push constant 51 +push constant 24 +push constant 12 +push constant 6 +push constant 51 +push constant 49 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 38 +push constant 12 +push constant 30 +push constant 30 +push constant 12 +push constant 54 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 39 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 40 +push constant 24 +push constant 12 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 41 +push constant 6 +push constant 12 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 42 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 63 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 43 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 63 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 44 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 45 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 46 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 47 +push constant 0 +push constant 0 +push constant 32 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 1 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 48 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 49 +push constant 12 +push constant 14 +push constant 15 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 50 +push constant 30 +push constant 51 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 51 +push constant 30 +push constant 51 +push constant 48 +push constant 48 +push constant 28 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 52 +push constant 16 +push constant 24 +push constant 28 +push constant 26 +push constant 25 +push constant 63 +push constant 24 +push constant 24 +push constant 60 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 53 +push constant 63 +push constant 3 +push constant 3 +push constant 31 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 54 +push constant 28 +push constant 6 +push constant 3 +push constant 3 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 55 +push constant 63 +push constant 49 +push constant 48 +push constant 48 +push constant 24 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 56 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 57 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 24 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 58 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 59 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 60 +push constant 0 +push constant 0 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 61 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 62 +push constant 0 +push constant 0 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 64 +push constant 30 +push constant 51 +push constant 51 +push constant 59 +push constant 59 +push constant 59 +push constant 27 +push constant 3 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 63 +push constant 30 +push constant 51 +push constant 51 +push constant 24 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 65 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 66 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 67 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 68 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 69 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 70 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 71 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 59 +push constant 51 +push constant 51 +push constant 54 +push constant 44 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 72 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 73 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 74 +push constant 60 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 27 +push constant 27 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 75 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 76 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 77 +push constant 33 +push constant 51 +push constant 63 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 78 +push constant 51 +push constant 51 +push constant 55 +push constant 55 +push constant 63 +push constant 59 +push constant 59 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 79 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 80 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 81 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 59 +push constant 30 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 82 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 83 +push constant 30 +push constant 51 +push constant 51 +push constant 6 +push constant 28 +push constant 48 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 84 +push constant 63 +push constant 63 +push constant 45 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 85 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 86 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 87 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 88 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 30 +push constant 30 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 89 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 90 +push constant 63 +push constant 51 +push constant 49 +push constant 24 +push constant 12 +push constant 6 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 91 +push constant 30 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 92 +push constant 0 +push constant 0 +push constant 1 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 48 +push constant 32 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 93 +push constant 30 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 94 +push constant 8 +push constant 28 +push constant 54 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 95 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 96 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 97 +push constant 0 +push constant 0 +push constant 0 +push constant 14 +push constant 24 +push constant 30 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 98 +push constant 3 +push constant 3 +push constant 3 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 99 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 3 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 100 +push constant 48 +push constant 48 +push constant 48 +push constant 60 +push constant 54 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 101 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 63 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 102 +push constant 28 +push constant 54 +push constant 38 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 103 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 104 +push constant 3 +push constant 3 +push constant 3 +push constant 27 +push constant 55 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 105 +push constant 12 +push constant 12 +push constant 0 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 106 +push constant 48 +push constant 48 +push constant 0 +push constant 56 +push constant 48 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 107 +push constant 3 +push constant 3 +push constant 3 +push constant 51 +push constant 27 +push constant 15 +push constant 15 +push constant 27 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 108 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 109 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 63 +push constant 43 +push constant 43 +push constant 43 +push constant 43 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 110 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 111 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 112 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 113 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 114 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 55 +push constant 51 +push constant 3 +push constant 3 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 115 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 6 +push constant 24 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 116 +push constant 4 +push constant 6 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 117 +push constant 0 +push constant 0 +push constant 0 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 118 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 119 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 120 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 121 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 24 +push constant 15 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 122 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 27 +push constant 12 +push constant 6 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 123 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 124 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 125 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 126 +push constant 38 +push constant 45 +push constant 25 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 0 +return +function Output.create 1 +push constant 11 +call Array.new 1 +pop local 0 +push static 0 +push argument 0 +push local 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 0 +push argument 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 1 +push argument 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 2 +push argument 3 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 3 +push argument 4 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 4 +push argument 5 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 5 +push argument 6 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 6 +push argument 7 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 7 +push argument 8 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 8 +push argument 9 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 9 +push argument 10 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 10 +push argument 11 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function Output.getMap 0 +push argument 0 +push constant 32 +lt +push argument 0 +push constant 126 +gt +or +not +if-goto L0 +push constant 0 +pop argument 0 +goto L1 +label L0 +label L1 +push static 0 +push argument 0 +add +pop pointer 1 +push that 0 +return +function Output.moveCursor 4 +push argument 1 +push constant 0 +eq +not +if-goto L2 +push constant 1 +neg +pop static 2 +goto L3 +label L2 +push argument 1 +push constant 2 +call Math.divide 2 +push constant 2 +call Math.multiply 2 +push argument 1 +eq +pop static 2 +label L3 +push constant 352 +push argument 0 +call Math.multiply 2 +push argument 1 +push constant 2 +call Math.divide 2 +add +push constant 16384 +add +pop static 1 +push constant 32 +call Output.getMap 1 +pop local 3 +label L4 +push local 0 +push constant 11 +lt +not +if-goto L5 +push static 2 +not +if-goto L6 +push local 2 +push static 1 +add +pop pointer 1 +push that 0 +push constant 256 +neg +and +pop local 1 +push local 2 +push static 1 +push local 3 +push local 0 +add +pop pointer 1 +push that 0 +push local 1 +or +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L7 +label L6 +push local 2 +push static 1 +add +pop pointer 1 +push that 0 +push constant 255 +and +pop local 1 +push local 2 +push static 1 +push local 3 +push local 0 +add +pop pointer 1 +push that 0 +push constant 256 +call Math.multiply 2 +push local 1 +or +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L7 +push local 0 +push constant 1 +add +pop local 0 +push static 1 +push constant 32 +add +pop static 1 +goto L4 +label L5 +push static 1 +push constant 352 +sub +pop static 1 +push constant 0 +return +function Output.printChar 4 +push argument 0 +call Output.getMap 1 +pop local 0 +label L8 +push local 2 +push constant 11 +lt +not +if-goto L9 +push static 2 +not +if-goto L10 +push local 1 +push static 1 +add +pop pointer 1 +push that 0 +push constant 256 +neg +and +pop local 3 +push local 1 +push static 1 +push local 0 +push local 2 +add +pop pointer 1 +push that 0 +push local 3 +or +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L11 +label L10 +push local 1 +push static 1 +add +pop pointer 1 +push that 0 +push constant 255 +and +pop local 3 +push local 1 +push static 1 +push local 0 +push local 2 +add +pop pointer 1 +push that 0 +push constant 256 +call Math.multiply 2 +push local 3 +or +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L11 +push local 2 +push constant 1 +add +pop local 2 +push static 1 +push constant 32 +add +pop static 1 +goto L8 +label L9 +push static 2 +not +if-goto L12 +push static 1 +push constant 352 +sub +pop static 1 +push constant 0 +pop static 2 +goto L13 +label L12 +push static 1 +push constant 24480 +gt +not +if-goto L14 +push constant 16384 +pop static 1 +push constant 1 +neg +pop static 2 +goto L15 +label L14 +push static 1 +push constant 351 +sub +pop static 1 +push constant 1 +neg +pop static 2 +label L15 +label L13 +push constant 0 +return +function Output.printString 2 +push argument 0 +call String.length 1 +pop local 1 +label L16 +push local 0 +push local 1 +lt +not +if-goto L17 +push argument 0 +push local 0 +call String.charAt 2 +call Output.printChar 1 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto L16 +label L17 +push constant 0 +return +function Output.printInt 1 +push constant 6 +call String.new 1 +pop local 0 +push local 0 +push argument 0 +call String.setInt 2 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +push constant 0 +return +function Output.println 1 +push static 1 +push constant 16384 +sub +push constant 32 +call Math.divide 2 +push constant 11 +call Math.divide 2 +push constant 1 +add +pop local 0 +push local 0 +push constant 32 +gt +not +if-goto L18 +push constant 0 +pop local 0 +goto L19 +label L18 +label L19 +push local 0 +push constant 0 +call Output.moveCursor 2 +pop temp 0 +push constant 0 +return +function Output.backSpace 0 +push static 1 +push constant 16384 +eq +not +if-goto L20 +push constant 24191 +pop static 1 +push constant 1 +neg +pop static 2 +push constant 0 +return +goto L21 +label L20 +label L21 +push static 2 +not +if-goto L22 +push static 1 +push constant 1 +sub +pop static 1 +push constant 0 +pop static 2 +goto L23 +label L22 +push constant 1 +neg +pop static 2 +label L23 +push constant 0 +return diff --git a/projects/12/test/Screen.jack b/projects/12/test/Screen.jack new file mode 100755 index 0000000..006a905 --- /dev/null +++ b/projects/12/test/Screen.jack @@ -0,0 +1,206 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Screen.jack + +/** + * A library of functions for displaying graphics on the screen. + * The Hack physical screen consists of 256 rows (indexed 0..255, top to bottom) + * of 512 pixels each (indexed 0..511, left to right). The top left pixel on + * the screen is indexed (0,0). + */ +class Screen { + + static Array mem; + static Array st; + static boolean color; + /** Initializes the Screen. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + let color = true; + return; + } + + /** Erases the entire screen. */ + function void clearScreen() { + var int a; + let a = 16384; + while (a < 24575){ + let mem[a] = 0; + let a = a + 1; + } + return; + } + + /** Sets the current color, to be used for all subsequent drawXXX commands. + * Black is represented by true, white by false. */ + function void setColor(boolean b) { + let color = b; + return; + } + + /** Draws the (x,y) pixel, using the current color. */ + function void drawPixel(int x, int y) { + var int value, address, bit, mem_block; + if ((x > 511) | (x < 0) | (y > 255) | (y < 0)){ + do Sys.error(7); + } + let mem_block = x / 16; + let address = (32 * y) + mem_block + 16384; + let value = mem[address]; + let bit = x - (mem_block * 16); + if (color){ + let mem[address] = st[bit] | value; + } + else{ + let mem[address] = (~st[bit])& value; + } + return; + } + + /** Draws a line from pixel (x1,y1) to pixel (x2,y2), using the current color. */ + function void drawLine(int x1, int y1, int x2, int y2) { + var int diff, dx, dy, a, b; + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let dx = x2 - x1; + let dy = y2 - y1; + if (dx = 0){ + if (dy > 0){ + while(~(b > dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b + 1; + } + return; + } + else{ + while(~(b < dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b - 1; + } + return; + } + } + if (dy = 0){ + if (dx > 0){ + while(~(a > dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a + 1; + } + return; + } + else{ + while(~(a < dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a - 1; + } + return; + } + } + if (dx < 0){ + if (dy < 0){ + while ((~(a < dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff + dx; + } + } + } + else{ + while ((~(a < dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff + dx; + } + } + } + } + else{ + if (dy < 0){ + while ((~(a > dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff - dx; + } + } + } + else{ + while ((~(a > dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff - dx; + } + } + } + } + + return; + } + + /** Draws a filled rectangle whose top left corner is (x1, y1) + * and bottom right corner is (x2,y2), using the current color. */ + function void drawRectangle(int x1, int y1, int x2, int y2) { + var int a, tmp; + if (x1 > x2){ + let tmp = x1; + let x1 = x2; + let x2 = tmp; + } + if (y1 > y2){ + let tmp = y1; + let y1 = y2; + let y2 = tmp; + } + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let tmp = y2 - y1; + while(a < tmp){ + do Screen.drawLine(x1, y1 + a, x2, y1 + a); + let a = a + 1; + } + return; + } + + /** Draws a filled circle of radius r<=181 around (x,y), using the current color. */ + function void drawCircle(int x, int y, int r) { + var int dy, dx, tmp; + if(r > 181){ + do Sys.error(7); + } + let dy = - r; + while (dy < r){ + let tmp = Math.sqrt((r * r) - (dy * dy)); + do Screen.drawLine(x - tmp, y + dy, x + tmp, y + dy); + let dy = dy + 1; + } + return; + } +} diff --git a/projects/12/test/Screen.vm b/projects/12/test/Screen.vm new file mode 100755 index 0000000..d08813b --- /dev/null +++ b/projects/12/test/Screen.vm @@ -0,0 +1,656 @@ +function Screen.init 1 +push constant 16 +call Array.new 1 +pop static 1 +push static 1 +push constant 0 +push constant 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L0 +push local 0 +push constant 15 +lt +not +if-goto L1 +push local 0 +push constant 1 +add +pop local 0 +push static 1 +push local 0 +push static 1 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +push static 1 +push local 0 +push constant 1 +sub +add +pop pointer 1 +push that 0 +add +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L0 +label L1 +push constant 1 +neg +pop static 2 +push constant 0 +return +function Screen.clearScreen 1 +push constant 16384 +pop local 0 +label L2 +push local 0 +push constant 24575 +lt +not +if-goto L3 +push static 0 +push local 0 +push constant 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +goto L2 +label L3 +push constant 0 +return +function Screen.setColor 0 +push argument 0 +pop static 2 +push constant 0 +return +function Screen.drawPixel 4 +push argument 0 +push constant 511 +gt +push argument 0 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +push argument 1 +push constant 0 +lt +or +not +if-goto L4 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L5 +label L4 +label L5 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push constant 32 +push argument 1 +call Math.multiply 2 +push local 3 +add +push constant 16384 +add +pop local 1 +push static 0 +push local 1 +add +pop pointer 1 +push that 0 +pop local 0 +push argument 0 +push local 3 +push constant 16 +call Math.multiply 2 +sub +pop local 2 +push static 2 +not +if-goto L6 +push static 0 +push local 1 +push static 1 +push local 2 +add +pop pointer 1 +push that 0 +push local 0 +or +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +goto L7 +label L6 +push static 0 +push local 1 +push static 1 +push local 2 +add +pop pointer 1 +push that 0 +not +push local 0 +and +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +label L7 +push constant 0 +return +function Screen.drawLine 5 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +not +if-goto L8 +push constant 8 +call Sys.error 1 +pop temp 0 +goto L9 +label L8 +label L9 +push argument 2 +push argument 0 +sub +pop local 1 +push argument 3 +push argument 1 +sub +pop local 2 +push local 1 +push constant 0 +eq +not +if-goto L10 +push local 2 +push constant 0 +gt +not +if-goto L11 +label L12 +push local 4 +push local 2 +gt +not +not +if-goto L13 +push argument 0 +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 4 +push constant 1 +add +pop local 4 +goto L12 +label L13 +push constant 0 +return +goto L14 +label L11 +label L15 +push local 4 +push local 2 +lt +not +not +if-goto L16 +push argument 0 +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 4 +push constant 1 +sub +pop local 4 +goto L15 +label L16 +push constant 0 +return +label L14 +goto L17 +label L10 +label L17 +push local 2 +push constant 0 +eq +not +if-goto L18 +push local 1 +push constant 0 +gt +not +if-goto L19 +label L20 +push local 3 +push local 1 +gt +not +not +if-goto L21 +push argument 0 +push local 3 +add +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +push local 3 +push constant 1 +add +pop local 3 +goto L20 +label L21 +push constant 0 +return +goto L22 +label L19 +label L23 +push local 3 +push local 1 +lt +not +not +if-goto L24 +push argument 0 +push local 3 +add +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +push local 3 +push constant 1 +sub +pop local 3 +goto L23 +label L24 +push constant 0 +return +label L22 +goto L25 +label L18 +label L25 +push local 1 +push constant 0 +lt +not +if-goto L26 +push local 2 +push constant 0 +lt +not +if-goto L27 +label L28 +push local 3 +push local 1 +lt +not +push local 4 +push local 2 +lt +not +and +not +if-goto L29 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L30 +push local 3 +push constant 1 +sub +pop local 3 +push local 0 +push local 2 +sub +pop local 0 +goto L31 +label L30 +push local 4 +push constant 1 +sub +pop local 4 +push local 0 +push local 1 +add +pop local 0 +label L31 +goto L28 +label L29 +goto L32 +label L27 +label L33 +push local 3 +push local 1 +lt +not +push local 4 +push local 2 +gt +not +and +not +if-goto L34 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L35 +push local 3 +push constant 1 +sub +pop local 3 +push local 0 +push local 2 +add +pop local 0 +goto L36 +label L35 +push local 4 +push constant 1 +add +pop local 4 +push local 0 +push local 1 +add +pop local 0 +label L36 +goto L33 +label L34 +label L32 +goto L37 +label L26 +push local 2 +push constant 0 +lt +not +if-goto L38 +label L39 +push local 3 +push local 1 +gt +not +push local 4 +push local 2 +lt +not +and +not +if-goto L40 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L41 +push local 3 +push constant 1 +add +pop local 3 +push local 0 +push local 2 +sub +pop local 0 +goto L42 +label L41 +push local 4 +push constant 1 +sub +pop local 4 +push local 0 +push local 1 +sub +pop local 0 +label L42 +goto L39 +label L40 +goto L43 +label L38 +label L44 +push local 3 +push local 1 +gt +not +push local 4 +push local 2 +gt +not +and +not +if-goto L45 +push argument 0 +push local 3 +add +push argument 1 +push local 4 +add +call Screen.drawPixel 2 +pop temp 0 +push local 0 +push constant 0 +lt +not +if-goto L46 +push local 3 +push constant 1 +add +pop local 3 +push local 0 +push local 2 +add +pop local 0 +goto L47 +label L46 +push local 4 +push constant 1 +add +pop local 4 +push local 0 +push local 1 +sub +pop local 0 +label L47 +goto L44 +label L45 +label L43 +label L37 +push constant 0 +return +function Screen.drawRectangle 2 +push argument 0 +push argument 2 +gt +not +if-goto L48 +push argument 0 +pop local 1 +push argument 2 +pop argument 0 +push local 1 +pop argument 2 +goto L49 +label L48 +label L49 +push argument 1 +push argument 3 +gt +not +if-goto L50 +push argument 1 +pop local 1 +push argument 3 +pop argument 1 +push local 1 +pop argument 3 +goto L51 +label L50 +label L51 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +not +if-goto L52 +push constant 8 +call Sys.error 1 +pop temp 0 +goto L53 +label L52 +label L53 +push argument 3 +push argument 1 +sub +pop local 1 +label L54 +push local 0 +push local 1 +lt +not +if-goto L55 +push argument 0 +push argument 1 +push local 0 +add +push argument 2 +push argument 1 +push local 0 +add +call Screen.drawLine 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto L54 +label L55 +push constant 0 +return +function Screen.drawCircle 3 +push argument 2 +push constant 181 +gt +not +if-goto L56 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L57 +label L56 +label L57 +push argument 2 +neg +pop local 0 +label L58 +push local 0 +push argument 2 +lt +not +if-goto L59 +push argument 2 +push argument 2 +call Math.multiply 2 +push local 0 +push local 0 +call Math.multiply 2 +sub +call Math.sqrt 1 +pop local 2 +push argument 0 +push local 2 +sub +push argument 1 +push local 0 +add +push argument 0 +push local 2 +add +push argument 1 +push local 0 +add +call Screen.drawLine 4 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto L58 +label L59 +push constant 0 +return diff --git a/projects/12/test/String.jack b/projects/12/test/String.jack new file mode 100755 index 0000000..4d936cb --- /dev/null +++ b/projects/12/test/String.jack @@ -0,0 +1,154 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/String.jack + +/** + * Represents character strings. In addition for constructing and disposing + * strings, the class features methods for getting and setting individual + * characters of the string, for erasing the string's last character, + * for appending a character to the string's end, and more typical + * string-oriented operations. + */ +class String { + field Array str; + field int length; + field int strLength; + + /** constructs a new empty string with a mavalimum length of mavalLength + * and initial length of 0. */ + constructor String new(int mavalLength) { + if (mavalLength > 0){ + let str = Array.new(mavalLength); + } + let strLength = mavalLength; + let length = 0; + return this; + } + + /** Disposes this string. */ + method void dispose() { + if(length > 0){ + do str.dispose(); + } + do Memory.deAlloc(this); + return; + } + + /** Returns the current length of this string. */ + method int length() { + return length; + } + + /** Returns the character at the j-th location of this string. */ + method char charAt(int j) { + if(j > length){ + do Sys.error(7); + } + return str[j]; + } + + /** Sets the character at the j-th location of this string to c. */ + method void setCharAt(int j, char c) { + if(j > length){ + do Sys.error(7); + } + let str[j] = c; + return; + } + + /** Appends c to this string's end and returns this string. */ + method String appendChar(char c) { + if(strLength = length){ + do Sys.error(7); + } + let str[length] = c; + let length = length + 1; + return this; + } + + /** Erases the last character from this string. */ + method void eraseLastChar() { + if (length = 0){ + do Sys.error(7); + } + let str[length] = 0; + let length = length - 1; + return; + } + + /** Returns the integer value of this string, + * until a non-digit character is detected. */ + method int intValue() { + var int d, sum, i; + var bool f; + while(i < length){ + let d = str[i]; + if ((d > 47) & (d < 58)){ + let sum = (sum * 10) + (d - 48); + } + else{ + if((i = 0) & (d = 45)){ + let f = true; + } + else{ + let i = length; + } + } + let i = i + 1; + } + if (f){ + return -sum; + } + return sum; + } + + /** Sets this string to hold a representation of the given value. */ + method void setInt(int val) { + var Array c; + var int d, b, a; + let c = Array.new(6); + if (val < 0){ + let d = ~0; + let val = -val; + } + let b = val; + while(b > 0){ + let b = val / 10; + let c[a] = 48 + val - (b * 10); + let a = a + 1; + let val = b; + } + if (d){ + let c[a] = 45; + let a = a + 1; + } + if (a = 0){ + let str[0] = 48; + let length = 1; + } + else{ + let length = 0; + while (length < a){ + let str[length] = c[a - 1 - length]; + let length = length + 1; + } + } + do Array.dispose(c); + return; + } + /** Returns the new line character. */ + function char newLine() { + return 128; + } + + /** Returns the backspace character. */ + function char backSpace() { + return 129; + } + + /** Returns the double quote (") character. */ + function char doubleQuote() { + return 34; + } +} diff --git a/projects/12/test/String.vm b/projects/12/test/String.vm new file mode 100755 index 0000000..4d1b86c --- /dev/null +++ b/projects/12/test/String.vm @@ -0,0 +1,348 @@ +function String.new 0 +push constant 3 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +push constant 0 +gt +not +if-goto L0 +push argument 0 +call Array.new 1 +pop this 0 +goto L1 +label L0 +label L1 +push argument 0 +pop this 2 +push constant 0 +pop this 1 +push pointer 0 +return +function String.dispose 0 +push argument 0 +pop pointer 0 +push this 1 +push constant 0 +gt +not +if-goto L2 +push this 0 +call Array.dispose 1 +pop temp 0 +goto L3 +label L2 +label L3 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function String.length 0 +push argument 0 +pop pointer 0 +push this 1 +return +function String.charAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push this 1 +gt +not +if-goto L4 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L5 +label L4 +label L5 +push this 0 +push argument 1 +add +pop pointer 1 +push that 0 +return +function String.setCharAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push this 1 +gt +not +if-goto L6 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L7 +label L6 +label L7 +push this 0 +push argument 1 +push argument 2 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 0 +return +function String.appendChar 0 +push argument 0 +pop pointer 0 +push this 2 +push this 1 +eq +not +if-goto L8 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L9 +label L8 +label L9 +push this 0 +push this 1 +push argument 1 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push this 1 +push constant 1 +add +pop this 1 +push pointer 0 +return +function String.eraseLastChar 0 +push argument 0 +pop pointer 0 +push this 1 +push constant 0 +eq +not +if-goto L10 +push constant 7 +call Sys.error 1 +pop temp 0 +goto L11 +label L10 +label L11 +push this 0 +push this 1 +push constant 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push this 1 +push constant 1 +sub +pop this 1 +push constant 0 +return +function String.intValue 4 +push argument 0 +pop pointer 0 +label L12 +push local 2 +push this 1 +lt +not +if-goto L13 +push this 0 +push local 2 +add +pop pointer 1 +push that 0 +pop local 0 +push local 0 +push constant 47 +gt +push local 0 +push constant 58 +lt +and +not +if-goto L14 +push local 1 +push constant 10 +call Math.multiply 2 +push local 0 +push constant 48 +sub +add +pop local 1 +goto L15 +label L14 +push local 2 +push constant 0 +eq +push local 0 +push constant 45 +eq +and +not +if-goto L16 +push constant 1 +neg +pop local 3 +goto L17 +label L16 +push this 1 +pop local 2 +label L17 +label L15 +push local 2 +push constant 1 +add +pop local 2 +goto L12 +label L13 +push local 3 +not +if-goto L18 +push local 1 +neg +return +goto L19 +label L18 +label L19 +push local 1 +return +function String.setInt 4 +push argument 0 +pop pointer 0 +push constant 6 +call Array.new 1 +pop local 0 +push argument 1 +push constant 0 +lt +not +if-goto L20 +push constant 0 +not +pop local 1 +push argument 1 +neg +pop argument 1 +goto L21 +label L20 +label L21 +push argument 1 +pop local 2 +label L22 +push local 2 +push constant 0 +gt +not +if-goto L23 +push argument 1 +push constant 10 +call Math.divide 2 +pop local 2 +push local 0 +push local 3 +push constant 48 +push argument 1 +add +push local 2 +push constant 10 +call Math.multiply 2 +sub +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push constant 1 +add +pop local 3 +push local 2 +pop argument 1 +goto L22 +label L23 +push local 1 +not +if-goto L24 +push local 0 +push local 3 +push constant 45 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push local 3 +push constant 1 +add +pop local 3 +goto L25 +label L24 +label L25 +push local 3 +push constant 0 +eq +not +if-goto L26 +push this 0 +push constant 0 +push constant 48 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push constant 1 +pop this 1 +goto L27 +label L26 +push constant 0 +pop this 1 +label L28 +push this 1 +push local 3 +lt +not +if-goto L29 +push this 0 +push this 1 +push local 0 +push local 3 +push constant 1 +sub +push this 1 +sub +add +pop pointer 1 +push that 0 +pop temp 1 +add +pop pointer 1 +push temp 1 +pop that 0 +push this 1 +push constant 1 +add +pop this 1 +goto L28 +label L29 +label L27 +push local 0 +call Array.dispose 1 +pop temp 0 +push constant 0 +return +function String.newLine 0 +push constant 128 +return +function String.backSpace 0 +push constant 129 +return +function String.doubleQuote 0 +push constant 34 +return diff --git a/projects/12/test/Sys.jack b/projects/12/test/Sys.jack new file mode 100755 index 0000000..0eed65b --- /dev/null +++ b/projects/12/test/Sys.jack @@ -0,0 +1,53 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Sys.jack + +/** + * A library that supports various program execution services. + */ +class Sys { + + /** Performs all the initializations required by the OS. */ + function void init() { + do Memory.init(); + do Math.init(); + do Output.init(); + do Screen.init(); + do Keyboard.init(); + do Main.main(); + do Sys.halt(); + return; + } + + /** Halts the program execution. */ + function void halt() { + while(true){ + } + return; + } + + /** Waits approximately duration milliseconds and returns. */ + function void wait(int duration) { + var int i; + while (duration > 0){ + let i = 100; + while(i > 0){ + let i = i -1; + } + let duration = duration - 1; + } + return; + } + + /** Displays the given error code in the form "ERR", + * and halts the program's execution. */ + function void error(int errorCode) { + var String s; + let s = String.new(3); + do s.setInt(errorCode); + do Output.printString("ERR"); + do Output.printString(s); + return; + } +} diff --git a/projects/12/test/Sys.vm b/projects/12/test/Sys.vm new file mode 100755 index 0000000..c95e21d --- /dev/null +++ b/projects/12/test/Sys.vm @@ -0,0 +1,79 @@ +function Sys.init 0 +call Memory.init 0 +pop temp 0 +call Math.init 0 +pop temp 0 +call Output.init 0 +pop temp 0 +call Screen.init 0 +pop temp 0 +call Keyboard.init 0 +pop temp 0 +call Main.main 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return +function Sys.halt 0 +label L0 +push constant 1 +neg +not +if-goto L1 +goto L0 +label L1 +push constant 0 +return +function Sys.wait 1 +label L2 +push argument 0 +push constant 0 +gt +not +if-goto L3 +push constant 100 +pop local 0 +label L4 +push local 0 +push constant 0 +gt +not +if-goto L5 +push local 0 +push constant 1 +sub +pop local 0 +goto L4 +label L5 +push argument 0 +push constant 1 +sub +pop argument 0 +goto L2 +label L3 +push constant 0 +return +function Sys.error 1 +push constant 3 +call String.new 1 +pop local 0 +push local 0 +push argument 0 +call String.setInt 2 +pop temp 0 +push constant 3 +call String.new 1 +push constant 69 +call String.appendChar 2 +push constant 82 +call String.appendChar 2 +push constant 82 +call String.appendChar 2 +call Output.printString 1 +pop temp 0 +push local 0 +call Output.printString 1 +pop temp 0 +push constant 0 +return diff --git a/projects/12/test/__pycache__/symbol_table.cpython-39.pyc b/projects/12/test/__pycache__/symbol_table.cpython-39.pyc new file mode 100755 index 0000000..e6bb655 Binary files /dev/null and b/projects/12/test/__pycache__/symbol_table.cpython-39.pyc differ diff --git a/projects/12/test/__pycache__/tokenizer.cpython-39.pyc b/projects/12/test/__pycache__/tokenizer.cpython-39.pyc new file mode 100755 index 0000000..75d8856 Binary files /dev/null and b/projects/12/test/__pycache__/tokenizer.cpython-39.pyc differ diff --git a/projects/12/test/__pycache__/vmwriter.cpython-39.pyc b/projects/12/test/__pycache__/vmwriter.cpython-39.pyc new file mode 100755 index 0000000..a048be9 Binary files /dev/null and b/projects/12/test/__pycache__/vmwriter.cpython-39.pyc differ diff --git a/projects/12/test/project12.zip b/projects/12/test/project12.zip new file mode 100755 index 0000000..0a2df83 Binary files /dev/null and b/projects/12/test/project12.zip differ diff --git a/projects/12/test/symbol_table.py b/projects/12/test/symbol_table.py new file mode 100755 index 0000000..7c62c3e --- /dev/null +++ b/projects/12/test/symbol_table.py @@ -0,0 +1,62 @@ +class Symbol: + def __init__(self): + self.s_name = '' + self.s_kind = '' + self.s_type = '' + self.s_index = 0 + + +class SymbolTable: + def __init__(self): + self.sym = [] + + def define(self, s_name, s_type, s_kind): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = s_kind + self.sym[-1].s_index = self.var_count(s_kind) - 1 + + def start_subroutine(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'argument' + self.sym[-1].s_index = 0 + + def start_class(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = 'this' + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'field' + self.sym[-1].s_index = 0 + + def var_count(self, s_kind): + count = 0 # it is -1 so the first index is 0 + for i in self.sym: + if i.s_kind == s_kind: + count += 1 + return count + + def kind_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + if i.s_kind == 'var': + return 'local' + elif i.s_kind == 'field': + return 'this' + else: + return i.s_kind + return None + + def type_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_type + return None + + def index_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_index + return None diff --git a/projects/12/test/tokenizer.py b/projects/12/test/tokenizer.py new file mode 100755 index 0000000..aaaa873 --- /dev/null +++ b/projects/12/test/tokenizer.py @@ -0,0 +1,78 @@ +import re + + +class Tokenizer: + + def __init__(self): + self.i = 0 + self.file = '' + self.symbols = ('(', ')', '[', ']', '}', '{', '>', '<', '=', '*', '+', '-', '/', '.', ';', ',', '&', '|', + '~') + self.key_word = ( + 'class', 'method', 'function', 'constructor', 'int', 'boolean', 'char', 'void', 'var', 'static', 'field', + 'let', 'do', 'if', 'else', 'while', 'return', 'true', 'false', 'null', 'this') + self.token = '' + + def token_type(self, token=None): + if token is None: + token = self.token + if token is None or token == '': + return None + if token in self.key_word: + return 'keyword' + elif token[0] == '"': + return 'stringConstant' + elif re.match(r"\d+", token): + return 'integerConstant' + elif token in self.symbols: + return 'symbol' + else: + return 'identifier' + + def advance(self): + token = '' + i = self.i + while i < len(self.file): + if re.match(r'\s', self.file[i]): + i = i + 1 + continue + else: + if self.file[i] in self.symbols: + self.token = self.file[i] + self.i = i + 1 + return + elif self.file[i] == '"': + i += 1 + while self.file[i] != '"': + token += self.file[i] + i += 1 + self.i = i + 1 + self.token = '"' + token + '"' + return + else: + while re.match(r'\w', self.file[i]): + token += self.file[i] + if i + 1 > len(self.file) - 1: + break + i += 1 + self.i = i + self.token = token + return + + def clear_file(self, directory): + with open(directory, "r") as my_file: + txt = my_file.read() + txt = re.sub(r"//.*", "", txt) + txt = re.sub(r"/[*][*].*[*]/", "", txt) + i = 0 + # TODO this should be a regex + while i < len(txt): + if txt[i] == '/' and txt[i + 1] == '*' and txt[i + 2] == '*': + start = i + while txt[i] != '*' or txt[i + 1] != '/': + i += 1 + stop = i + 2 + txt = txt[:start] + txt[stop:len(txt)] + i = start - 1 + i += 1 + self.file = txt diff --git a/projects/12/test/vmwriter.py b/projects/12/test/vmwriter.py new file mode 100755 index 0000000..5bf6929 --- /dev/null +++ b/projects/12/test/vmwriter.py @@ -0,0 +1,75 @@ +class VMWriter: + def __init__(self, vm_path): + self.my_vm = open(vm_path, "w+") + self.label_index = 0 + + def write_push(self, segment, index): + self.my_vm.write(f'push {segment} {index}\n') + print(f'push {segment} {index}') + + def write_lable(self, label): + self.my_vm.write(f'label L{label}\n') + print(f'label L{label}') + + def write_arithmetic(self, command): + if command == '+': + self.my_vm.write('add\n') + print('add') + elif command == '-': + self.my_vm.write('sub\n') + print('sub') + elif command == 'neg': + self.my_vm.write('neg\n') + print('neg') + elif command == '=': + self.my_vm.write('eq\n') + print('eq') + elif command == '>': + self.my_vm.write('gt\n') + print('gt') + elif command == '<': + self.my_vm.write('lt\n') + print('lt') + elif command == '&': + self.my_vm.write('and\n') + print('and') + elif command == '|': + self.my_vm.write('or\n') + print('or') + elif command == '~': + self.my_vm.write('not\n') + print('not') + elif command == '*': + self.write_call('Math.multiply', 2) + elif command == '/': + self.write_call('Math.divide', 2) + + def write_pop(self, segment, index): + print(f'pop {segment} {index}') + self.my_vm.write(f'pop {segment} {index}\n') + + def write_goto(self, label): + self.my_vm.write(f'goto L{label}\n') + print(f'goto L{label}') + + def write_if(self, label): + self.write_arithmetic('~') + self.my_vm.write(f'if-goto L{label}\n') + print(f'if-goto L{label}') + + def write_call(self, label, num_args): + self.my_vm.write(f'call {label} {num_args}\n') + print(f'call {label} {num_args}') + + def write_function(self, label, num_locals): + self.my_vm.write(f'function {label} {num_locals}\n') + print(f'function {label} {num_locals}') + + def write_return(self, func_type): + if func_type == 'void': + self.write_push('constant', '0') + self.my_vm.write('return\n') + print(f'return') + + def close_vm_file(self): + self.my_vm.close() diff --git a/projects/13/more fun to go.txt b/projects/13/more fun to go.txt new file mode 100755 index 0000000..a7f066e --- /dev/null +++ b/projects/13/more fun to go.txt @@ -0,0 +1,9 @@ +See Chapter 13. It's your call! + +And, if you develop something cool, please let us know about it. + +We hope that you enjoyed the course! + +-- Noam and Shimon + +www.nand2tetris.org \ No newline at end of file diff --git a/solutions_only/project 01/And16.hdl b/solutions_only/project 01/And16.hdl new file mode 100755 index 0000000..1fbcabe --- /dev/null +++ b/solutions_only/project 01/And16.hdl @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/And16.hdl + +/** + * 16-bit bitwise And: + * for i = 0..15: out[i] = (a[i] and b[i]) + */ + +CHIP And16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + + And(a=a[0],b=b[0],out=out[0]); + And(a=a[1],b=b[1],out=out[1]); + And(a=a[2],b=b[2],out=out[2]); + And(a=a[3],b=b[3],out=out[3]); + And(a=a[4],b=b[4],out=out[4]); + And(a=a[5],b=b[5],out=out[5]); + And(a=a[6],b=b[6],out=out[6]); + And(a=a[7],b=b[7],out=out[7]); + And(a=a[8],b=b[8],out=out[8]); + And(a=a[9],b=b[9],out=out[9]); + And(a=a[10],b=b[10],out=out[10]); + And(a=a[11],b=b[11],out=out[11]); + And(a=a[12],b=b[12],out=out[12]); + And(a=a[13],b=b[13],out=out[13]); + And(a=a[14],b=b[14],out=out[14]); + And(a=a[15],b=b[15],out=out[15]); + + +} \ No newline at end of file diff --git a/solutions_only/project 01/DMux.hdl b/solutions_only/project 01/DMux.hdl new file mode 100755 index 0000000..ede6878 --- /dev/null +++ b/solutions_only/project 01/DMux.hdl @@ -0,0 +1,21 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux.hdl + +/** + * Demultiplexor: + * {a, b} = {in, 0} if sel == 0 + * {0, in} if sel == 1 + */ + +CHIP DMux { + IN in, sel; + OUT a, b; + + PARTS: + Not(in=sel,out=notsel); + And(a=in,b=notsel,out=a); + And(a=in,b=sel,out=b); + +} diff --git a/solutions_only/project 01/DMux4Way.hdl b/solutions_only/project 01/DMux4Way.hdl new file mode 100755 index 0000000..7346e03 --- /dev/null +++ b/solutions_only/project 01/DMux4Way.hdl @@ -0,0 +1,32 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux4Way.hdl + +/** + * 4-way demultiplexor: + * {a, b, c, d} = {in, 0, 0, 0} if sel == 00 + * {0, in, 0, 0} if sel == 01 + * {0, 0, in, 0} if sel == 10 + * {0, 0, 0, in} if sel == 11 + */ + +CHIP DMux4Way { + IN in, sel[2]; + OUT a, b, c, d; + + PARTS: + Not(in=sel[1],out=notsel1); + Not(in=sel[0],out=notsel0); + + And(a=notsel1,b=notsel0,out=out1); + And(a=notsel1,b=sel[0],out=out2); + And(a=sel[1],b=notsel0,out=out3); + And(a=sel[1],b=sel[0],out=out4); + + And(a=in,b=out1,out=a); + And(a=in,b=out2,out=b); + And(a=in,b=out3,out=c); + And(a=in,b=out4,out=d); + +} \ No newline at end of file diff --git a/solutions_only/project 01/DMux8Way.hdl b/solutions_only/project 01/DMux8Way.hdl new file mode 100755 index 0000000..04d82ca --- /dev/null +++ b/solutions_only/project 01/DMux8Way.hdl @@ -0,0 +1,47 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux8Way.hdl + +/** + * 8-way demultiplexor: + * {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000 + * {0, in, 0, 0, 0, 0, 0, 0} if sel == 001 + * etc. + * {0, 0, 0, 0, 0, 0, 0, in} if sel == 111 + */ + +CHIP DMux8Way { + IN in, sel[3]; + OUT a, b, c, d, e, f, g, h; + + PARTS: + Not(in=sel[0],out=notsel0); + Not(in=sel[1],out=notsel1); + Not(in=sel[2],out=notsel2); + + And(a=notsel2,b=notsel1,out=out1); + And(a=out1,b=notsel0,out=outA); + And(a=out1,b=sel[0],out=outB); + + And(a=notsel2,b=sel[1],out=out2); + And(a=out2,b=notsel0,out=outC); + And(a=out2,b=sel[0],out=outD); + + And(a=sel[2],b=notsel1,out=out3); + And(a=out3,b=notsel0,out=outE); + And(a=out3,b=sel[0],out=outF); + + And(a=sel[2],b=sel[1],out=out4); + And(a=out4,b=notsel0,out=outG); + And(a=out4,b=sel[0],out=outH); + + And(a=in,b=outA,out=a); + And(a=in,b=outB,out=b); + And(a=in,b=outC,out=c); + And(a=in,b=outD,out=d); + And(a=in,b=outE,out=e); + And(a=in,b=outF,out=f); + And(a=in,b=outG,out=g); + And(a=in,b=outH,out=h); +} \ No newline at end of file diff --git a/solutions_only/project 01/Mux.hdl b/solutions_only/project 01/Mux.hdl new file mode 100755 index 0000000..1afeb7b --- /dev/null +++ b/solutions_only/project 01/Mux.hdl @@ -0,0 +1,17 @@ + +/** + * Multiplexor: + * out = a if sel == 0 + * b otherwise + */ + +CHIP Mux { + IN a, b, sel; + OUT out; + + PARTS: + Not(in=sel,out=notsel); + And(a=a,b=notsel,out=out1); + And(a=b,b=sel,out=out2); + Or(a=out1,b=out2,out=out); +} \ No newline at end of file diff --git a/solutions_only/project 01/Mux16.hdl b/solutions_only/project 01/Mux16.hdl new file mode 100755 index 0000000..21b0184 --- /dev/null +++ b/solutions_only/project 01/Mux16.hdl @@ -0,0 +1,34 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Mux16.hdl + +/** + * 16-bit multiplexor: + * for i = 1..15 out[i] = a[i] if sel == 1 + * b[i] if sel == 1 + */ + +CHIP Mux16 { + IN a[16], b[16], sel; + OUT out[16]; + + PARTS: + Mux(a=a[0],b=b[0],sel=sel,out=out[0]); + Mux(a=a[1],b=b[1],sel=sel,out=out[1]); + Mux(a=a[2],b=b[2],sel=sel,out=out[2]); + Mux(a=a[3],b=b[3],sel=sel,out=out[3]); + Mux(a=a[4],b=b[4],sel=sel,out=out[4]); + Mux(a=a[5],b=b[5],sel=sel,out=out[5]); + Mux(a=a[6],b=b[6],sel=sel,out=out[6]); + Mux(a=a[7],b=b[7],sel=sel,out=out[7]); + Mux(a=a[8],b=b[8],sel=sel,out=out[8]); + Mux(a=a[9],b=b[9],sel=sel,out=out[9]); + Mux(a=a[10],b=b[10],sel=sel,out=out[10]); + Mux(a=a[11],b=b[11],sel=sel,out=out[11]); + Mux(a=a[12],b=b[12],sel=sel,out=out[12]); + Mux(a=a[13],b=b[13],sel=sel,out=out[13]); + Mux(a=a[14],b=b[14],sel=sel,out=out[14]); + Mux(a=a[15],b=b[15],sel=sel,out=out[15]); + +} \ No newline at end of file diff --git a/solutions_only/project 01/Mux4Way.hdl b/solutions_only/project 01/Mux4Way.hdl new file mode 100755 index 0000000..fca2c16 --- /dev/null +++ b/solutions_only/project 01/Mux4Way.hdl @@ -0,0 +1,21 @@ +CHIP Mux4Way { + IN a, b, c, d, sel0, sel1; + OUT out; + + PARTS: + Not(in=sel0,out=notsel0); + Not(in=sel1,out=notsel1); + + And(a=notsel0,b=notsel1,out=outA); + And(a=sel0,b=notsel1,out=outB); + And(a=notsel0,b=sel1,out=outC); + And(a=sel0,b=sel1,out=outD); + + And(a=outA,b=a,out=outA1); + And(a=outB,b=b,out=outB1); + And(a=outC,b=c,out=outC1); + And(a=outD,b=d,out=outD1); + Or(a=outA1,b=outB1,out=out1); + Or(a=outC1,b=outD1,out=out2); + Or(a=out1,b=out2,out=out); +} \ No newline at end of file diff --git a/solutions_only/project 01/Mux4Way16.hdl b/solutions_only/project 01/Mux4Way16.hdl new file mode 100755 index 0000000..64fbffc --- /dev/null +++ b/solutions_only/project 01/Mux4Way16.hdl @@ -0,0 +1,38 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux4Way16.hdl + +/** + * 4-way 16-bit multiplexor: + * out = a if sel == 00 + * b if sel == 01 + * c if sel == 10 + * d if sel == 11 + */ + +CHIP Mux4Way16 { + IN a[16], b[16], c[16], d[16], sel[2]; + OUT out[16]; + + PARTS: + + Mux4Way(a=a[0],b=b[0],c=c[0],d=d[0],sel0=sel[0],sel1=sel[1],out=out[0]); + Mux4Way(a=a[1],b=b[1],c=c[1],d=d[1],sel0=sel[0],sel1=sel[1],out=out[1]); + Mux4Way(a=a[2],b=b[2],c=c[2],d=d[2],sel0=sel[0],sel1=sel[1],out=out[2]); + Mux4Way(a=a[3],b=b[3],c=c[3],d=d[3],sel0=sel[0],sel1=sel[1],out=out[3]); + Mux4Way(a=a[4],b=b[4],c=c[4],d=d[4],sel0=sel[0],sel1=sel[1],out=out[4]); + Mux4Way(a=a[5],b=b[5],c=c[5],d=d[5],sel0=sel[0],sel1=sel[1],out=out[5]); + Mux4Way(a=a[6],b=b[6],c=c[6],d=d[6],sel0=sel[0],sel1=sel[1],out=out[6]); + Mux4Way(a=a[7],b=b[7],c=c[7],d=d[7],sel0=sel[0],sel1=sel[1],out=out[7]); + Mux4Way(a=a[8],b=b[8],c=c[8],d=d[8],sel0=sel[0],sel1=sel[1],out=out[8]); + Mux4Way(a=a[9],b=b[9],c=c[9],d=d[9],sel0=sel[0],sel1=sel[1],out=out[9]); + + Mux4Way(a=a[10],b=b[10],c=c[10],d=d[10],sel0=sel[0],sel1=sel[1],out=out[10]); + Mux4Way(a=a[11],b=b[11],c=c[11],d=d[11],sel0=sel[0],sel1=sel[1],out=out[11]); + Mux4Way(a=a[12],b=b[12],c=c[12],d=d[12],sel0=sel[0],sel1=sel[1],out=out[12]); + Mux4Way(a=a[13],b=b[13],c=c[13],d=d[13],sel0=sel[0],sel1=sel[1],out=out[13]); + Mux4Way(a=a[14],b=b[14],c=c[14],d=d[14],sel0=sel[0],sel1=sel[1],out=out[14]); + Mux4Way(a=a[15],b=b[15],c=c[15],d=d[15],sel0=sel[0],sel1=sel[1],out=out[15]); + +} \ No newline at end of file diff --git a/solutions_only/project 01/Mux8Way.hdl b/solutions_only/project 01/Mux8Way.hdl new file mode 100755 index 0000000..00816be --- /dev/null +++ b/solutions_only/project 01/Mux8Way.hdl @@ -0,0 +1,41 @@ +CHIP Mux8Way { + IN a, b, c, d, e, f, g, h, sel0, sel1, sel2; + OUT out; + + PARTS: + Not(in=sel0,out=notsel0); + Not(in=sel1,out=notsel1); + Not(in=sel2,out=notsel2); + + + And(a=notsel0,b=notsel1,out=outA); + And(a=notsel0,b=sel2,out=outC); + And(a=sel0,b=notsel1,out=outE); + And(a=sel0,b=sel1,out=outG); + + And(a=outA,b=notsel2,out=outA1); + And(a=outC,b=notsel2,out=outC1); + And(a=outE,b=notsel2,out=outE1); + And(a=outG,b=notsel2,out=outG1); + And(a=outA,b=sel2,out=outB1); + And(a=outG,b=sel2,out=outH1); + And(a=outC,b=sel2,out=outD1); + And(a=outE,b=sel2,out=outF1); + + And(a=outA1,b=a,out=outA2); + And(a=outB1,b=b,out=outB2); + And(a=outC1,b=c,out=outC2); + And(a=outD1,b=d,out=outD2); + And(a=outE1,b=e,out=outE2); + And(a=outF1,b=f,out=outF2); + And(a=outG1,b=g,out=outG2); + And(a=outH1,b=h,out=outH2); + + Or(a=outA2,b=outB2,out=out1); + Or(a=outC2,b=outD2,out=out2); + Or(a=outE2,b=outF2,out=out4); + Or(a=outG2,b=outH2,out=out5); + Or(a=out4,b=out5,out=out6); + Or(a=out1,b=out2,out=out3); + Or(a=out3,b=out6,out=out); +} diff --git a/solutions_only/project 01/Mux8Way16.hdl b/solutions_only/project 01/Mux8Way16.hdl new file mode 100755 index 0000000..960aa7d --- /dev/null +++ b/solutions_only/project 01/Mux8Way16.hdl @@ -0,0 +1,38 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux8Way16.hdl + +/** + * 8-way 16-bit multiplexor: + * out = a if sel == 000 + * b if sel == 001 + * etc. + * h if sel == 111 + */ + +CHIP Mux8Way16 { + IN a[16], b[16], c[16], d[16], + e[16], f[16], g[16], h[16], + sel[3]; + OUT out[16]; + + PARTS: + Mux8Way(a=a[0],b=b[0],c=c[0],d=d[0],e=e[0],f=f[0],g=g[0],h=h[0],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[0]); + Mux8Way(a=a[1],b=b[1],c=c[1],d=d[1],e=e[1],f=f[1],g=g[1],h=h[1],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[1]); + Mux8Way(a=a[2],b=b[2],c=c[2],d=d[2],e=e[2],f=f[2],g=g[2],h=h[2],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[2]); + Mux8Way(a=a[3],b=b[3],c=c[3],d=d[3],e=e[3],f=f[3],g=g[3],h=h[3],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[3]); + Mux8Way(a=a[4],b=b[4],c=c[4],d=d[4],e=e[4],f=f[4],g=g[4],h=h[4],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[4]); + Mux8Way(a=a[5],b=b[5],c=c[5],d=d[5],e=e[5],f=f[5],g=g[5],h=h[5],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[5]); + Mux8Way(a=a[6],b=b[6],c=c[6],d=d[6],e=e[6],f=f[6],g=g[6],h=h[6],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[6]); + Mux8Way(a=a[7],b=b[7],c=c[7],d=d[7],e=e[7],f=f[7],g=g[7],h=h[7],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[7]); + Mux8Way(a=a[8],b=b[8],c=c[8],d=d[8],e=e[8],f=f[8],g=g[8],h=h[8],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[8]); + Mux8Way(a=a[9],b=b[9],c=c[9],d=d[9],e=e[9],f=f[9],g=g[9],h=h[9],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[9]); + + Mux8Way(a=a[11],b=b[11],c=c[11],d=d[11],e=e[11],f=f[11],g=g[11],h=h[11],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[11]); + Mux8Way(a=a[12],b=b[12],c=c[12],d=d[12],e=e[12],f=f[12],g=g[12],h=h[12],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[12]); + Mux8Way(a=a[14],b=b[14],c=c[14],d=d[14],e=e[14],f=f[14],g=g[14],h=h[14],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[14]); + Mux8Way(a=a[13],b=b[13],c=c[13],d=d[13],e=e[13],f=f[13],g=g[13],h=h[13],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[13]); + Mux8Way(a=a[15],b=b[15],c=c[15],d=d[15],e=e[15],f=f[15],g=g[15],h=h[15],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[15]); + Mux8Way(a=a[10],b=b[10],c=c[10],d=d[10],e=e[10],f=f[10],g=g[10],h=h[10],sel0=sel[0],sel1=sel[1],sel2=sel[2],out=out[10]); +} \ No newline at end of file diff --git a/solutions_only/project 01/Not.hdl b/solutions_only/project 01/Not.hdl new file mode 100755 index 0000000..5b75a10 --- /dev/null +++ b/solutions_only/project 01/Not.hdl @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Not.hdl + +/** + * Not gate: + * out = not in + */ + +CHIP Not { + IN in; + OUT out; + + PARTS: + Nand(a=in,b=in,out=out); +} \ No newline at end of file diff --git a/solutions_only/project 01/Not16.hdl b/solutions_only/project 01/Not16.hdl new file mode 100755 index 0000000..88fb6b6 --- /dev/null +++ b/solutions_only/project 01/Not16.hdl @@ -0,0 +1,33 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Not16.hdl + +/** + * 16-bit Not: + * for i=0..15: out[i] = not in[i] + */ + +CHIP Not16 { + IN in[16]; + OUT out[16]; + + PARTS: + Not(in=in[0],out=out[0]); + Not(in=in[1],out=out[1]); + Not(in=in[2],out=out[2]); + Not(in=in[3],out=out[3]); + Not(in=in[4],out=out[4]); + Not(in=in[5],out=out[5]); + Not(in=in[6],out=out[6]); + Not(in=in[7],out=out[7]); + Not(in=in[8],out=out[8]); + Not(in=in[9],out=out[9]); + Not(in=in[10],out=out[10]); + Not(in=in[11],out=out[11]); + Not(in=in[12],out=out[12]); + Not(in=in[13],out=out[13]); + Not(in=in[14],out=out[14]); + Not(in=in[15],out=out[15]); + +} \ No newline at end of file diff --git a/solutions_only/project 01/Or.hdl b/solutions_only/project 01/Or.hdl new file mode 100755 index 0000000..283c7d5 --- /dev/null +++ b/solutions_only/project 01/Or.hdl @@ -0,0 +1,9 @@ +CHIP Or { + IN a, b; + OUT out; + + PARTS: + Not(in=a,out=nota); + Not(in=b,out=notb); + Nand(a=nota,b=notb,out=out); +} diff --git a/solutions_only/project 01/Or16.hdl b/solutions_only/project 01/Or16.hdl new file mode 100755 index 0000000..7708c5b --- /dev/null +++ b/solutions_only/project 01/Or16.hdl @@ -0,0 +1,33 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/11/Or16.hdl + +/** + * 16-bit bitwise Or: + * for i = 1..15 out[i] = (a[i] or b[i]) + */ + +CHIP Or16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + Or(a=a[0],b=b[0],out=out[0]); + Or(a=a[1],b=b[1],out=out[1]); + Or(a=a[2],b=b[2],out=out[2]); + Or(a=a[3],b=b[3],out=out[3]); + Or(a=a[4],b=b[4],out=out[4]); + Or(a=a[5],b=b[5],out=out[5]); + Or(a=a[6],b=b[6],out=out[6]); + Or(a=a[7],b=b[7],out=out[7]); + Or(a=a[8],b=b[8],out=out[8]); + Or(a=a[9],b=b[9],out=out[9]); + Or(a=a[10],b=b[10],out=out[10]); + Or(a=a[11],b=b[11],out=out[11]); + Or(a=a[12],b=b[12],out=out[12]); + Or(a=a[13],b=b[13],out=out[13]); + Or(a=a[14],b=b[14],out=out[14]); + Or(a=a[15],b=b[15],out=out[15]); + +} \ No newline at end of file diff --git a/solutions_only/project 01/Or8Way.hdl b/solutions_only/project 01/Or8Way.hdl new file mode 100755 index 0000000..667b506 --- /dev/null +++ b/solutions_only/project 01/Or8Way.hdl @@ -0,0 +1,25 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or8Way.hdl + +/** + * 8-way Or: + * out = (in[0] or in[1] or ... or in[7]) + */ + +CHIP Or8Way { + IN in[8]; + OUT out; + + PARTS: + Or(a=in[0],b=in[1],out=out1); + Or(a=out1,b=in[2],out=out2); + Or(a=out2,b=in[3],out=out3); + Or(a=out3,b=in[4],out=out4); + Or(a=out4,b=in[5],out=out5); + Or(a=out5,b=in[6],out=out6); + Or(a=out6,b=in[7],out=out); + + +} \ No newline at end of file diff --git a/solutions_only/project 02/ALU.hdl b/solutions_only/project 02/ALU.hdl new file mode 100755 index 0000000..856ebf4 --- /dev/null +++ b/solutions_only/project 02/ALU.hdl @@ -0,0 +1,66 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/ALU.hdl + +/** + * The ALU (Arithmetic Logic Unit). + * Computes one of the following functions: + * x+y, x-y, y-x, 0, 1, -1, x, y, -x, -y, !x, !y, + * x+1, y+1, x-1, y-1, x&y, x|y on two 16-bit inputs, + * according to 6 input bits denoted zx,nx,zy,ny,f,no. + * In addition, the ALU computes two 1-bit outputs: + * if the ALU output == 0, zr is set to 1; otherwise zr is set to 0; + * if the ALU output < 0, ng is set to 1; otherwise ng is set to 0. + */ + +// Implementation: the ALU logic manipulates the x and y inputs +// and operates on the resulting values, as follows: +// if (zx == 1) set x = 0 // 16-bit constant +// if (nx == 1) set x = !x // bitwise not +// if (zy == 1) set y = 0 // 16-bit constant +// if (ny == 1) set y = !y // bitwise not +// if (f == 1) set out = x + y // integer 2's complement addition +// if (f == 0) set out = x & y // bitwise and +// if (no == 1) set out = !out // bitwise not +// if (out == 0) set zr = 1 +// if (out < 0) set ng = 1 + +CHIP ALU { + IN + x[16], y[16], // 16-bit inputs + zx, // zero the x input? + nx, // negate the x input? + zy, // zero the y input? + ny, // negate the y input? + f, // compute out = x + y (if 1) or x & y (if 0) + no; // negate the out output? + + OUT + out[16], // 16-bit output + zr, // 1 if (out == 0), 0 otherwise + ng; // 1 if (out < 0), 0 otherwise + + PARTS: + Mux16(a=x,b[0..15]=false,sel=zx,out=outZx);//zx + + Mux16(a=y,b[0..15]=false,sel=zy,out=outZy);//zy + + + Not16(in=outZx,out=outNx1);//nx1 + Not16(in=outZy,out=outNy1);//ny1 + Mux16(a=outZx,b=outNx1,sel=nx,out=outNx);//nx + + Mux16(a=outZy,b=outNy1,sel=ny,out=outNy);//ny + + + Add16(a=outNx,b=outNy,out=outF1);//f1 + + And16(a=outNy,b=outNx,out=outF0);//f0 + + Mux16(a=outF0,b=outF1,sel=f,out=outF);//f + + Not16(in=outF,out=outNo1);//no + + Mux16(a=outF, b=outNo1, sel=no, out=out, out[15]=ng, out[0..7]=zr1, out[8..15]=zr2); + + + Or8Way(in=zr1,out=out2); + Or8Way(in=zr2,out=out3); + Not(in=out2,out=out4); + Not(in=out3,out=out5); + And(a=out4,b=out5,out=zr); + +} \ No newline at end of file diff --git a/solutions_only/project 02/Add16.hdl b/solutions_only/project 02/Add16.hdl new file mode 100755 index 0000000..a33305e --- /dev/null +++ b/solutions_only/project 02/Add16.hdl @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/Adder16.hdl + +/** + * Adds two 16-bit values. + * The most significant carry bit is ignored. + */ + +CHIP Add16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + HalfAdder(a=a[0], b=b[0], sum=out[0], carry=carry1); + FullAdder(a=a[1], b=b[1], c=carry1, sum=out[1], carry=carry2); + FullAdder(a=a[2], b=b[2], c=carry2, sum=out[2], carry=carry3); + FullAdder(a=a[3], b=b[3], c=carry3, sum=out[3], carry=carry4); + FullAdder(a=a[4], b=b[4], c=carry4, sum=out[4], carry=carry5); + FullAdder(a=a[5], b=b[5], c=carry5, sum=out[5], carry=carry6); + FullAdder(a=a[6], b=b[6], c=carry6, sum=out[6], carry=carry7); + FullAdder(a=a[7], b=b[7], c=carry7, sum=out[7], carry=carry8); + FullAdder(a=a[8], b=b[8], c=carry8, sum=out[8], carry=carry9); + FullAdder(a=a[9], b=b[9], c=carry9, sum=out[9], carry=carry10); + + FullAdder(a=a[10],b=b[10],c=carry10,sum=out[10],carry=carry11); + FullAdder(a=a[11],b=b[11],c=carry11,sum=out[11],carry=carry12); + FullAdder(a=a[12],b=b[12],c=carry12,sum=out[12],carry=carry13); + FullAdder(a=a[13],b=b[13],c=carry13,sum=out[13],carry=carry14); + FullAdder(a=a[14],b=b[14],c=carry14,sum=out[14],carry=carry15); + FullAdder(a=a[15],b=b[15],c=carry15,sum=out[15],carry=carry16); + + +} \ No newline at end of file diff --git a/solutions_only/project 02/FullAdder.hdl b/solutions_only/project 02/FullAdder.hdl new file mode 100755 index 0000000..e87e8a7 --- /dev/null +++ b/solutions_only/project 02/FullAdder.hdl @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/FullAdder.hdl + +/** + * Computes the sum of three bits. + */ + +CHIP FullAdder { + IN a, b, c; // 1-bit inputs + OUT sum, // Right bit of a + b + c + carry; // Left bit of a + b + c + + PARTS: + HalfAdder(a=b,b=c,sum=sum1,carry=carry1); + HalfAdder(a=a,b=sum1,sum=sum,carry=carry2); + Or(a=carry1,b=carry2,out=carry); + +} \ No newline at end of file diff --git a/solutions_only/project 02/HalfAdder.hdl b/solutions_only/project 02/HalfAdder.hdl new file mode 100755 index 0000000..27ada40 --- /dev/null +++ b/solutions_only/project 02/HalfAdder.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/HalfAdder.hdl + +/** + * Computes the sum of two bits. + */ + +CHIP HalfAdder { + IN a, b; // 1-bit inputs + OUT sum, // Right bit of a + b + carry; // Left bit of a + b + + PARTS: + Xor(a=a,b=b,out=sum); + And(a=a,b=b,out=carry); +} diff --git a/solutions_only/project 02/Inc16.hdl b/solutions_only/project 02/Inc16.hdl new file mode 100755 index 0000000..23c872e --- /dev/null +++ b/solutions_only/project 02/Inc16.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/02/Inc16.hdl + +/** + * 16-bit incrementer: + * out = in + 1 (arithmetic addition) + */ + +CHIP Inc16 { + IN in[16]; + OUT out[16]; + + PARTS: + Add16(a=in, b[1..15]=false, b[0]=true , out=out); + +} \ No newline at end of file diff --git a/solutions_only/project 03/Bit.hdl b/solutions_only/project 03/Bit.hdl new file mode 100755 index 0000000..a85e716 --- /dev/null +++ b/solutions_only/project 03/Bit.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/Bit.hdl + +/** + * 1-bit register: + * If load[t] == 1 then out[t+1] = in[t] + * else out does not change (out[t+1] = out[t]) + */ + +CHIP Bit { + IN in, load; + OUT out; + + PARTS: + Mux(a=out2,b=in,sel=load,out=out1); + DFF(in=out1,out=out2,out=out); +} diff --git a/solutions_only/project 03/DMux8Way16.hdl b/solutions_only/project 03/DMux8Way16.hdl new file mode 100755 index 0000000..1029f09 --- /dev/null +++ b/solutions_only/project 03/DMux8Way16.hdl @@ -0,0 +1,22 @@ +CHIP DMux8Way16 { + IN in[16], sel[3]; + OUT a[16], b[16], c[16], d[16], e[16], f[16], g[16], h[16]; + + PARTS: + DMux8Way(a=a[0],b=b[0],c=c[0],d=d[0],e=e[0],f=f[0],g=g[0],h=h[0],sel=sel,in=in[0]); + DMux8Way(a=a[1],b=b[1],c=c[1],d=d[1],e=e[1],f=f[1],g=g[1],h=h[1],sel=sel,in=in[1]); + DMux8Way(a=a[2],b=b[2],c=c[2],d=d[2],e=e[2],f=f[2],g=g[2],h=h[2],sel=sel,in=in[2]); + DMux8Way(a=a[3],b=b[3],c=c[3],d=d[3],e=e[3],f=f[3],g=g[3],h=h[3],sel=sel,in=in[3]); + DMux8Way(a=a[4],b=b[4],c=c[4],d=d[4],e=e[4],f=f[4],g=g[4],h=h[4],sel=sel,in=in[4]); + DMux8Way(a=a[5],b=b[5],c=c[5],d=d[5],e=e[5],f=f[5],g=g[5],h=h[5],sel=sel,in=in[5]); + DMux8Way(a=a[6],b=b[6],c=c[6],d=d[6],e=e[6],f=f[6],g=g[6],h=h[6],sel=sel,in=in[6]); + DMux8Way(a=a[7],b=b[7],c=c[7],d=d[7],e=e[7],f=f[7],g=g[7],h=h[7],sel=sel,in=in[7]); + DMux8Way(a=a[8],b=b[8],c=c[8],d=d[8],e=e[8],f=f[8],g=g[8],h=h[8],sel=sel,in=in[8]); + DMux8Way(a=a[9],b=b[9],c=c[9],d=d[9],e=e[9],f=f[9],g=g[9],h=h[9],sel=sel,in=in[9]); + DMux8Way(a=a[10],b=b[10],c=c[10],d=d[10],e=e[10],f=f[10],g=g[10],h=h[10],sel=sel,in=in[10]); + DMux8Way(a=a[11],b=b[11],c=c[11],d=d[11],e=e[11],f=f[11],g=g[11],h=h[11],sel=sel,in=in[11]); + DMux8Way(a=a[12],b=b[12],c=c[12],d=d[12],e=e[12],f=f[12],g=g[12],h=h[12],sel=sel,in=in[12]); + DMux8Way(a=a[13],b=b[13],c=c[13],d=d[13],e=e[13],f=f[13],g=g[13],h=h[13],sel=sel,in=in[13]); + DMux8Way(a=a[14],b=b[14],c=c[14],d=d[14],e=e[14],f=f[14],g=g[14],h=h[14],sel=sel,in=in[14]); + DMux8Way(a=a[15],b=b[15],c=c[15],d=d[15],e=e[15],f=f[15],g=g[15],h=h[15],sel=sel,in=in[15]); +} \ No newline at end of file diff --git a/solutions_only/project 03/PC.hdl b/solutions_only/project 03/PC.hdl new file mode 100755 index 0000000..448e6c2 --- /dev/null +++ b/solutions_only/project 03/PC.hdl @@ -0,0 +1,44 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/PC.hdl + +/** + * A 16-bit counter with load and reset control bits. + * if (reset[t] == 1) out[t+1] = 0 + * else if (load[t] == 1) out[t+1] = in[t] + * else if (inc[t] == 1) out[t+1] = out[t] + 1 (integer addition) + * else out[t+1] = out[t] + */ + +CHIP PC { + IN in[16],load,inc,reset; + OUT out[16]; + + PARTS: + DMux8Way(in=true,sel[0]=reset,sel[1]=load,sel[2]=inc,a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + + DFF(in=inc,out=inct); + And(a=inc,b=inct,out=out1); + Mux16(a=in,b=out4,sel=out1,out=out2); + Inc16(in=out2,out=out3); + Register(in=out3,load=load,out=out4,out=out); + + Not(in=a,out=notа); + Register(in=in,load=notа,out=outA); + + And16(a[0..15]=false,b[0..15]=false,out=outB); + + Register(in=in,load=c,out=outC); + + And16(a[0..15]=false,b[0..15]=false,out=outD); + + + And16(a[0..15]=false,b[0..15]=false,out=outF); + + Register(in=in,load=g,out=outG); + + And16(a[0..15]=false,b[0..15]=false,out=outH); + And16(a[0..15]=false,b[0..15]=false,out=outE); + Mux8Way16(a=outA,b=outB,c=outC,d=outD,e=outE,f=outF,g=outG,h=outH,sel[0]=reset,sel[1]=load,sel[2]=inc,out=out67); + } \ No newline at end of file diff --git a/solutions_only/project 03/RAM16K.hdl b/solutions_only/project 03/RAM16K.hdl new file mode 100755 index 0000000..31127b0 --- /dev/null +++ b/solutions_only/project 03/RAM16K.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/b/RAM16K.hdl + +/** + * Memory of 16K registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM16K { + IN in[16], load, address[14]; + OUT out[16]; + + PARTS: + DMux4Way(in=load,sel=address[0..1],a=a,b=b,c=c,d=d); + RAM4K(in=in,load=a,address=address[2..13],out=outa); + RAM4K(in=in,load=b,address=address[2..13],out=outb); + RAM4K(in=in,load=c,address=address[2..13],out=outc); + RAM4K(in=in,load=d,address=address[2..13],out=outd); + Mux4Way16(a=outa,b=outb,c=outc,d=outd,sel=address[0..1],out=out); +} \ No newline at end of file diff --git a/solutions_only/project 03/RAM4K.hdl b/solutions_only/project 03/RAM4K.hdl new file mode 100755 index 0000000..1f969ef --- /dev/null +++ b/solutions_only/project 03/RAM4K.hdl @@ -0,0 +1,28 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/b/RAM4K.hdl + +/** + * Memory of 4K registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM4K { + IN in[16], load, address[12]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address[0..2],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + RAM512(in=in,load=a,address=address[3..11],out=outa); + RAM512(in=in,load=b,address=address[3..11],out=outb); + RAM512(in=in,load=c,address=address[3..11],out=outc); + RAM512(in=in,load=d,address=address[3..11],out=outd); + RAM512(in=in,load=e,address=address[3..11],out=oute); + RAM512(in=in,load=f,address=address[3..11],out=outf); + RAM512(in=in,load=g,address=address[3..11],out=outg); + RAM512(in=in,load=h,address=address[3..11],out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address[0..2],out=out); +} \ No newline at end of file diff --git a/solutions_only/project 03/RAM512.hdl b/solutions_only/project 03/RAM512.hdl new file mode 100755 index 0000000..e62e717 --- /dev/null +++ b/solutions_only/project 03/RAM512.hdl @@ -0,0 +1,28 @@ +// This file is part of the materials accompanying the book +// "The Elements of Computing Systems" by Nisan and Schocken, +// MIT Press. Book site: www.idc.ac.il/tecs +// File name: projects/03/b/RAM512.hdl + +/** + * Memory of 512 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM512 { + IN in[16], load, address[9]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address[0..2],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + RAM64(in=in,load=a,address=address[3..8],out=outa); + RAM64(in=in,load=b,address=address[3..8],out=outb); + RAM64(in=in,load=c,address=address[3..8],out=outc); + RAM64(in=in,load=d,address=address[3..8],out=outd); + RAM64(in=in,load=e,address=address[3..8],out=oute); + RAM64(in=in,load=f,address=address[3..8],out=outf); + RAM64(in=in,load=g,address=address[3..8],out=outg); + RAM64(in=in,load=h,address=address[3..8],out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address[0..2],out=out); +} \ No newline at end of file diff --git a/solutions_only/project 03/RAM64.hdl b/solutions_only/project 03/RAM64.hdl new file mode 100755 index 0000000..44d11bf --- /dev/null +++ b/solutions_only/project 03/RAM64.hdl @@ -0,0 +1,28 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/RAM64.hdl + +/** + * Memory of 64 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM64 { + IN in[16], load, address[6]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address[0..2],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + RAM8(in=in,load=a,address=address[3..5],out=outa); + RAM8(in=in,load=b,address=address[3..5],out=outb); + RAM8(in=in,load=c,address=address[3..5],out=outc); + RAM8(in=in,load=d,address=address[3..5],out=outd); + RAM8(in=in,load=e,address=address[3..5],out=oute); + RAM8(in=in,load=f,address=address[3..5],out=outf); + RAM8(in=in,load=g,address=address[3..5],out=outg); + RAM8(in=in,load=h,address=address[3..5],out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address[0..2],out=out); +} \ No newline at end of file diff --git a/solutions_only/project 03/RAM8.hdl b/solutions_only/project 03/RAM8.hdl new file mode 100755 index 0000000..9562736 --- /dev/null +++ b/solutions_only/project 03/RAM8.hdl @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/RAM8.hdl + +/** + * Memory of 8 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load==1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out from the next time step onward). + */ + +CHIP RAM8 { + IN in[16], load, address[3]; + OUT out[16]; + + PARTS: + DMux8Way(in=load,sel=address,a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + + Register(in=in,load=a,out=outa); + Register(in=in,load=b,out=outb); + Register(in=in,load=c,out=outc); + Register(in=in,load=d,out=outd); + Register(in=in,load=e,out=oute); + Register(in=in,load=f,out=outf); + Register(in=in,load=g,out=outg); + Register(in=in,load=h,out=outh); + Mux8Way16(a=outa,b=outb,c=outc,d=outd,e=oute,f=outf,g=outg,h=outh,sel=address,out=out); +} \ No newline at end of file diff --git a/solutions_only/project 03/Register.hdl b/solutions_only/project 03/Register.hdl new file mode 100755 index 0000000..257c7a0 --- /dev/null +++ b/solutions_only/project 03/Register.hdl @@ -0,0 +1,34 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/03/a/Register.hdl + +/** + * 16-bit register: + * If load[t] == 1 then out[t+1] = in[t] + * else out does not change + */ + +CHIP Register { + IN in[16], load; + OUT out[16]; + + PARTS: + Bit(in=in[0],load=load,out=out[0]); + Bit(in=in[1],load=load,out=out[1]); + Bit(in=in[2],load=load,out=out[2]); + Bit(in=in[3],load=load,out=out[3]); + Bit(in=in[4],load=load,out=out[4]); + Bit(in=in[5],load=load,out=out[5]); + Bit(in=in[6],load=load,out=out[6]); + Bit(in=in[7],load=load,out=out[7]); + Bit(in=in[8],load=load,out=out[8]); + Bit(in=in[9],load=load,out=out[9]); + Bit(in=in[10],load=load,out=out[10]); + Bit(in=in[11],load=load,out=out[11]); + Bit(in=in[12],load=load,out=out[12]); + Bit(in=in[13],load=load,out=out[13]); + Bit(in=in[14],load=load,out=out[14]); + Bit(in=in[15],load=load,out=out[15]); + +} diff --git a/solutions_only/project 04/Fill.asm b/solutions_only/project 04/Fill.asm new file mode 100755 index 0000000..c96edc6 --- /dev/null +++ b/solutions_only/project 04/Fill.asm @@ -0,0 +1,97 @@ +@END //check if button is pressed +0;JMP + +(BLACK) +//start= 16384 the start of the screen memory +@SCREEN +D=A +@start +M=D + +//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen +@8192 +D=A +@n +M=D + +//i=0 this is the index for each group of pixels +@i +M=0 + +(LOOP1) +//if i==n goto end +@i +D=M +@n +D=D-M +@END +D;JEQ + +//start+1=-1 set each group of pixels to -1 which is = 111111111111 +@start +D=M +@i +A=D+M +M=-1 + +// increment i by 1 +@i +M=M+1 + +// go back to the start of the loop +@LOOP1 +0;JMP + +(WHITE) +//start= 16384 the start of the screen memory +@SCREEN +D=A +@start +M=D + +//n=8,192 this is the memory for the display =addreass of the keyboard - address of the screen +@8192 +D=A +@n +M=D + +//i=0 this is the index for each group of pixels +@i +M=0 + +(LOOP2) +//if i==n goto end +@i +D=M +@n +D=D-M +@END +D;JEQ + +//start+1=-1 set each group of pixels to 0 which is = 00000000 +@start +D=M +@i +A=D+M +M=0 + +// increment i by 1 +@i +M=M+1 + +// go back to the start of the loop +@LOOP2 +0;JMP + +//check if button is pressed +(END) +@KBD +D=M +@WHITE +D;JEQ +@KBD +D=M +@BLACK +D;JNE +@END +0;JMP \ No newline at end of file diff --git a/solutions_only/project 04/Mult.asm b/solutions_only/project 04/Mult.asm new file mode 100755 index 0000000..59bb1ac --- /dev/null +++ b/solutions_only/project 04/Mult.asm @@ -0,0 +1,24 @@ +@R2 +M=0 +@sum +M=0 +(LOOP) +@1 +D=M +@END +D;JEQ // if R1==0 goto end +@R0 +D=M // D=R0 +@sum +M=M+D // sum=sum+R0 +@R1 +M=M-1 //R1=R1-1 +@sum +D=M +@R2 +M=D +@LOOP +0;JMP +(END) +@END +0;JMP \ No newline at end of file diff --git a/solutions_only/project 05/CPU.hdl b/solutions_only/project 05/CPU.hdl new file mode 100755 index 0000000..1b03712 --- /dev/null +++ b/solutions_only/project 05/CPU.hdl @@ -0,0 +1,115 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/CPU.hdl + +/** + * The Hack CPU (Central Processing unit), consisting of an ALU, + * two registers named A and D, and a program counter named PC. + * The CPU is designed to fetch and execute instructions written in + * the Hack machine language. In particular, functions as follows: + * Executes the inputted instruction according to the Hack machine + * language specification. The D and A in the language specification + * refer to CPU-resident registers, while M refers to the external + * memory location addressed by A, i.e. to Memory[A]. The inM input + * holds the value of this location. If the current instruction needs + * to write a value to M, the value is placed in outM, the address + * of the target location is placed in the addressM output, and the + * writeM control bit is asserted. (When writeM==0, any value may + * appear in outM). The outM and writeM outputs are combinational: + * they are affected instantaneously by the execution of the current + * instruction. The addressM and pc outputs are clocked: although they + * are affected by the execution of the current instruction, they commit + * to their new values only in the next time step. If reset==1 then the + * CPU jumps to address 0 (i.e. pc is set to 0 in next time step) rather + * than to the address resulting from executing the current instruction. + */ + +CHIP CPU { + + IN inM[16], // M value input (M = contents of RAM[A]) + instruction[16], // Instruction for execution + reset; // Signals whether to re-start the current + // program (reset==1) or continue executing + // the current program (reset==0). + + OUT outM[16], // M value output + writeM, // Write to M? + addressM[15], // Address in data memory (of M) + pc[15]; // address of next instruction + + PARTS: + Mux16(a=instruction ,b=ALUout ,sel=instruction[15] ,out=outToAreg ); + ARegister(in=outToAreg ,load=loadAreg ,out=outAreg,out[0..14]=addressM ); + DRegister(in=ALUout ,load=loadDreg ,out=outDreg ); + Mux16(a=outAreg ,b=inM ,sel=instruction[12] ,out=outToALU ); + ALU(x=outDreg ,y=outToALU ,zx=instruction[11] ,nx=instruction[10] ,zy=instruction[9] ,ny=instruction[8] ,f=instruction[7] ,no=instruction[6] ,out=ALUout,out=outM ,zr=zr ,ng=ng ); + And(a=instruction[3],b=instruction[15],out=writeM); + + //when to load A reg + Not(in=instruction[5],out=notd5); + Nand(a=instruction[15],b=notd5,out=loadAreg); + Not(in=ng,out=notNg); + Not(in=zr,out=notZr); + + //when to load D reg + And(a=instruction[4],b=instruction[15],out=loadDreg); + + //checking if instruction is a or c before jump decision is made + And(a=instruction[2],b=instruction[15],out=J1); + And(a=instruction[1],b=instruction[15],out=J2); + And(a=instruction[0],b=instruction[15],out=J3); + + //NULL + Nand(a=J1,b=J2,out=NandJ1J2); + Nand(a=NandJ1J2,b=J3,out=NoJump); + //JGT + And(a=J3,b=J3,out=AndJ3J3); + Or(a=zr,b=ng,out=orZrNg); + Not(in=orZrNg,out=NorZrNg); + And(a=AndJ3J3,b=NorZrNg,out=JGT); + + //JEQ + And(a=J2,b=J2,out=AndJ2J2); + And(a=zr,b=zr,out=AndZrZr); + And(a=AndZrZr,b=AndJ2J2,out=JEQ); + + //JGE + And(a=J3,b=J2,out=AndJ3J2); + Or(a=zr,b=notNg,out=AndZrNotNg); + And(a=AndZrNotNg,b=AndJ3J2,out=JGE); + + //JLT + And(a=J1,b=J1,out=AndJ1J1); + And(a=ng,b=ng,out=AndNgNg); + And(a=AndJ1J1,b=AndNgNg,out=JLT); + + //JNE + And(a=J3,b=J1,out=AndJ3J1); + And(a=notZr,b=notZr,out=AndNotZrNotZr); + And(a=AndNotZrNotZr,b=AndJ3J1,out=JNE); + + //JLE + And(a=J2,b=J1,out=AndJ2J1); + And(a=AndJ2J1,b=orZrNg,out=JLE); + + //JMP + And(a=AndJ3J1,b=J2,out=JMP); + + Not(in=outToLoad,out=outToLoad1); // once needted to know when to increes but also needed to not it so it dosent load the reg when J1J2J3=000 + + //4wayMux one + Mux(a=JMP,b=JGT,sel=instruction[0] ,out=out1); + Mux(a=JEQ,b=JGE,sel=instruction[0] ,out=out2); + Mux(a=out1,b=out2, sel=instruction[1] ,out=out5); + + //4wayMux two + Mux(a=JLT,b=JNE,sel=instruction[0] ,out=out3); + Mux(a=JLE,b=JMP,sel=instruction[0] ,out=out4); + Mux(a=out3,b=out4,sel=instruction[1] ,out=out6); + + //2wayMux + Mux(a=out5,b=out6,sel= instruction[2],out=outToLoad); + + PC(in=outAreg ,load=outToLoad ,inc=outToLoad1 ,reset=reset ,out[0..14]=pc); +} \ No newline at end of file diff --git a/solutions_only/project 05/Computer.hdl b/solutions_only/project 05/Computer.hdl new file mode 100755 index 0000000..ea198e4 --- /dev/null +++ b/solutions_only/project 05/Computer.hdl @@ -0,0 +1,25 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/Computer.hdl + +/** + * The HACK computer, including CPU, ROM and RAM. + * When reset is 0, the program stored in the computer's ROM executes. + * When reset is 1, the execution of the program restarts. + * Thus, to start a program's execution, reset must be pushed "up" (1) + * and "down" (0). From this point onward the user is at the mercy of + * the software. In particular, depending on the program's code, the + * screen may show some output and the user may be able to interact + * with the computer via the keyboard. + */ + +CHIP Computer { + + IN reset; + + PARTS: + CPU(inM=inM ,instruction=inst ,reset=reset ,outM=outM ,writeM=writeM ,addressM=addressM ,pc=pc ); + Memory(in=outM ,load=writeM ,address= addressM,out=inM ); + ROM32K(address=pc ,out=inst ); +} diff --git a/solutions_only/project 05/Memory.hdl b/solutions_only/project 05/Memory.hdl new file mode 100755 index 0000000..6aff3c3 --- /dev/null +++ b/solutions_only/project 05/Memory.hdl @@ -0,0 +1,36 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/05/Memory.hdl + +/** + * The complete address space of the Hack computer's memory, + * including RAM and memory-mapped I/O. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = Memory[address(t)](t) + * Write: if load(t-1) then Memory[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load==1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output from the next time step onward. + * Address space rules: + * Only the upper 16K+8K+1 words of the Memory chip are used. + * Access to address>0x6000 is invalid. Access to any address in + * the range 0x4000-0x5FFF results in accessing the screen memory + * map. Access to address 0x6000 results in accessing the keyboard + * memory map. The behavior in these addresses is described in the + * Screen and Keyboard chip specifications given in the book. + */ + +CHIP Memory { + IN in[16], load, address[15]; + OUT out[16]; + + PARTS: + DMux4Way(in=load,sel[0]=address[13],sel[1]=address[14] ,a=ram16k ,b=ram16k2,c=ramScreen); + Or(a=ram16k ,b=ram16k2 ,out=ram16end); + RAM16K(in=in ,load=ram16end ,address=address[0..13] ,out=out1); + Screen(in=in ,load=ramScreen ,address=address[0..12] ,out=out2); + Keyboard(out=outKey); + Mux4Way16(a=out1 ,b=out1 ,c=out2 ,d=outKey ,sel[0]=address[13],sel[1]=address[14] ,out=out); +} \ No newline at end of file diff --git a/solutions_only/project 06/assembler.py b/solutions_only/project 06/assembler.py new file mode 100755 index 0000000..22765fd --- /dev/null +++ b/solutions_only/project 06/assembler.py @@ -0,0 +1,230 @@ +def a_instruct(string): # covert the A instruction to bits + string = string.strip('@\n') + x = "{0:b}".format(int(string)) # convert the number to binary, problem if the number is too big + while len(x) < 16: # need to be 16 bits and 1 for \n + x = "0" + x + return x # return th 16 bit value + + +def c_instruct(string): # priema edna liniq koeto e edna instrukciq i q prevryshta v bit kod + string = string + "\n" + flag1, flag2, p = 0, 0, 0 + dest_s = '' + comp_s = '' + jump_s = '' + for c in range(len(string)): + if string[c] == '=': # ako ima ravno znachi predi nego ima destination + i = 0 + flag1 = 1 # diga flag za destination + while i < c: + p = c + dest_s += string[i] + i += 1 + dest_s = destDic.get(dest_s) # convert t to Destination + if string[c] == ';': # ako ima ; znachi predi nego ima computation + flag2 = 1 # diga flag za Jump + if flag1 == 0: # ako flaga za destination ne e dignat zapochvame ot nachaloto na liniqta + p = 0 + else: # ako e zapochvame ot kydeto e ravnoto koeto se pazi vyv var i + p = i + while p < c: + comp_s += string[p] + p += 1 + comp_s = compDic.get(comp_s) # convert t1 to Computation + + if string[c] == '\n': + if flag2 == 1: # ako ima flag za jump to vzimame stoinosta na jumpa + j = p + 1 + while j < c: + jump_s += string[j] + j += 1 + jump_s = jumpDic.get(jump_s) + else: # ako nqma togava vzima stoinosta na computationa + j = i + 1 + while j < c: + comp_s += string[j] + j += 1 + comp_s = compDic.get(comp_s) + final_result = '111' + comp_s # dobavqme 111 koeto e standart za C instrukt i computation bez koeto nqma instrukciq + if dest_s != '': # ako e imalo dest go dobavqme + final_result = final_result + dest_s + else: # inache dobavqme 3 nuli + final_result = final_result + '000' + if jump_s != '': # ako e imalo jump go dobavqme + final_result = final_result + jump_s + else: # inache dobavqme 3 nuli + final_result = final_result + '000' + return final_result + + +def check_a_or_c(temp_string): + line = '' + temp_string1 = '' + for j in temp_string: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + for index in range(len(line)): # proverqva vseki simvol ot liniqta + if line[index] == "@": # ako liniqta zapochva s @ znachi e a instrukciq + temp_string1 += a_instruct(line) + '\n' + line = '' + break + else: # ako ne zapochva s @ znachi e C instrukciq + temp_string1 += c_instruct(line) + '\n' + line = '' + break + return temp_string1 + + +def clear_file(temp_string_cf): # clears the empty lines, comments and spaces and writes them in a string + for line in asmfile: + f = 0 + if line == '\n': # removes empty lines + continue + for index in range(len(line)): + if line[index] == "/" and line[index + 1] == '/': # checks if it is comment + if f == 1: # maybe a problem if the last element of a line is / since it will stay + temp_string_cf += '\n' + break + if line[index] != ' ': # removes all of the whitespaces except newlines + temp_string_cf += line[index] + f = 1 + return temp_string_cf + + +def label(temp_string): # removes the labels and adds them to the dictionary writes all in a string + line = '' + temp_string_l = '' + global rowasm + for j in temp_string: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + f = 0 + for index in range(len(line)): # loops through the lines char by char + if line[index] == "(": + # checks if it is a label, will be a problem if there is only "(" and no closing bracket alse need to check label syntax + if bool(labelDic.get(line.strip('()'))) == False: # check if label is already in the Dictionary + labelDic[line.strip("()")] = str(rowasm) # adds the label to the dictionary + rowasm -= 1 # need to pay attention to the counting cause im not sure + f = 1 + break # brake so i don't write this line in the string since it needs to be removed + if f != 1: + temp_string_l += line + temp_string_l += '\n' + rowasm += 1 + line = '' + return temp_string_l + + +def variable(temp_string): # replaces the variables with the correct address + global variableCount + line = '' + temp_string_v = '' + for j in temp_string: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + for index in range(len(line)): + if line[index] == '@' and numbers.find(line[index + 1]) < 0: # checks if the line holds a variable + if bool(labelDic.get(line.strip('@'))): # check if variable is already in the Dictionary + line = '@' + labelDic[line.strip('@')] # replaces the variable with address i hope + else: + labelDic[line.strip('@')] = str(variableCount) # if isn't it adds it + line = '@' + str(variableCount) # replaces the variable with address i hope + variableCount += 1 # increases the variable counter so i don't write them all in address 16 + break + temp_string_v += line + '\n' # appends the line to the string + line = '' + return temp_string_v + + +destDic = {'None': '000', + 'M': '001', + 'D': '010', + 'MD': '011', + 'A': '100', + 'AM': '101', + 'AD': '110', + 'AMD': '111', } # contains all destinations and their bit equivalent +jumpDic = {'None': '000', + 'JGT': '001', + 'JQE': '010', + 'JGE': '011', + 'JLT': '100', + 'JNE': '101', + 'JLE': '110', + 'JMP': '111', } # contains all jumps and their bit equivalent +compDic = {'0': '0101010', + '1': '0111111', + '-1': '0111010', + 'D': '0001100', + 'A': '0110000', + '!D': '0001101', + '!A': '0110001', + '-D': '0001111', + '-A': '0110011', + 'D+1': '0011111', + 'A+1': '0110111', + 'D-1': '0001110', + 'A-1': '0110010', + 'D+A': '0000010', + 'D-A': '0010011', + 'A-D': '0000111', + 'D&A': '0000000', + 'D|A': '0010101', + 'M': '1110000', + '!M': '1110001', + '-M': '1110011', + 'M+1': '1110111', + 'M-1': '1110010', + 'D+M': '1000010', + 'D-M': '1010011', + 'M-D': '1000111', + 'D&M': '1000000', + 'D|M': '1010101', + } # contains all computations and their bit equivalent +tempString = '' # create empty string +rowasm = 0 +numbers = '0123456789' # used to check if given instruction calls to variable +variableCount = 16 # keeps count of the variable address + +labelDic = {'SP': '0', + 'LCL': '1', + 'ARG': '2', + 'THIS': '3', + 'THAT': '4', + 'SCREEN': '16384', + 'KBD': '24576', + 'R0': '0', + 'R1': '1', + 'R2': '2', + 'R3': '3', + 'R4': '4', + 'R5': '5', + 'R6': '6', + 'R7': '7', + 'R8': '8', + 'R9': '9', + 'R10': '10', + 'R11': '11', + 'R12': '12', + 'R13': '13', + 'R14': '14', + 'R15': '15', + } # dictionary containing Labels and Variables in format: AddressNumber : LabelName/ VariableName +with open("C:/Users/AGrudev/Desktop/n2t/nand2tetris/projects/06/pong/Pong.asm", "r+") as asmfile: + tempString = clear_file(tempString) +print(tempString + '----------') + +tempString = label(tempString) +print(tempString + '----------') + +tempString = variable(tempString) +print(tempString + '----------') + +tempString = check_a_or_c(tempString) +print(tempString + '----------') + +with open("C:/Users/AGrudev/Desktop/n2t/nand2tetris/projects/06/pong/Pong.hack", "w+") as destfile: + destfile.write(tempString) diff --git a/solutions_only/project 07/VMTranslator.py b/solutions_only/project 07/VMTranslator.py new file mode 100755 index 0000000..9afbca4 --- /dev/null +++ b/solutions_only/project 07/VMTranslator.py @@ -0,0 +1,160 @@ +import os +import sys +from pathlib import Path + +trueCounter = 0 +falseCounter = 0 +staticCounter = 16 + + +def clear_file(temp_string_cf, asmfile): # clears the empty lines, comments and spaces and writes them in a string + for line in asmfile: + f = 0 + if line == '\n': # removes empty lines + continue + for index in range(len(line)): + if line[index] == "/" and line[index + 1] == '/': # checks if it is comment + if f == 1: # maybe a problem if the last element of a line is / since it will stay + temp_string_cf += '\n' + break + if line[index] != ' ': # removes all of the whitespaces except newlines + temp_string_cf += line[index] + f = 1 + return temp_string_cf + + +def push(line): + global tempString1 + if line[4:8] == 'this': + number = int(line[8:]) + line = '@' + str(number) + '\nD=A\n@THIS\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:8] == 'that': + number = int(line[8:]) + line = '@' + str(number) + '\nD=A\n@THAT\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:8] == 'temp': + number = int(line[8:]) + number += 5 + line = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:9] == 'local': + number = int(line[9:]) + line = '@' + str(number) + '\nD=A\n@LCL\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:10] == 'static': + number = int(line[10:]) + line = '@' + name1 + '.' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:11] == 'pointer': + number = int(line[11:]) + number += 3 + line = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:12] == 'argument': + number = int(line[12:]) + line = '@' + str(number) + '\nD=A\n@ARG\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + elif line[4:12] == 'constant': + number = line[12:] + line = '@' + str(number) + '\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + tempString1 += line + + +def pop(line): + global SP + global tempString1 + if line[3:7] == 'this': + number = int(line[7:]) + line = '@' + str(number) + '\nD=A\n@THIS\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THIS\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THIS\nM=M-D\n' + elif line[3:7] == 'that': + number = int(line[7:]) + line = '@' + str(number) + '\nD=A\n@THAT\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THAT\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THAT\nM=M-D\n' + elif line[3:7] == 'temp': + number = int(line[7:]) + number = number + 5 + line = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n' + elif line[3:8] == 'local': + number = int(line[8:]) + line = '@' + str(number) + '\nD=A\n@LCL\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@LCL\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@LCL\nM=M-D\n' + elif line[3:9] == 'static': + number = int(line[9:]) + line = '@SP\nM=M-1\nA=M\nD=M\n@' + name1 + '.' + str(number) + '\nM=D\n' + elif line[3:10] == 'pointer': + number = int(line[10:]) + number = number + 3 + line = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n' + elif line[3:11] == 'argument': + number = int(line[11:]) + line = '@' + str(number) + '\nD=A\n@ARG\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@ARG\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@ARG\nM=M-D\n' + tempString1 += line + + +def aritmetic(line): + global trueCounter + global falseCounter + global tempString1 + if line == 'add': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M+D\n" + elif line == 'sub': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M-D\n" + elif line == 'neg': + line = "@SP\nA=M\nA=A-1\nM=-M\n" + elif line == 'eq': + line = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JEQ\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n' + trueCounter += 1 + falseCounter += 1 + elif line == 'gt': + line = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JGT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n' + trueCounter += 1 + falseCounter += 1 + elif line == 'lt': + line = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JLT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n' + trueCounter += 1 + falseCounter += 1 + elif line == 'and': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M&D\n" + elif line == 'or': + line = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M|D\n" + elif line == 'not': + line = "@SP\nA=M\nA=A-1\nM=!M\n" + tempString1 += line + + +name1 = None +line, tempString = '', '' +tempString1 = '' +aritmeticList3 = ['add', 'sub', 'neg', 'and', 'not'] +aritmeticList2 = ['or', 'gt', 'lt', 'eq'] +yourpath = os.getcwd() +for root, dirs, files in os.walk(yourpath, topdown=False): + nam1 = '' + for name in files: + if name[-3:] == '.vm': + name1 = name + tempString1 = '' + tempString = '' + with open(Path(root, name), "r+") as vmfile: + tempString = clear_file(tempString, vmfile) + for j in tempString: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + if line[:4] == 'push': + push(line) + line = '' + elif line[:3] == 'pop': + pop(line) + line = '' + elif line[:2] in aritmeticList2 or line[:3] in aritmeticList3: + aritmetic(line) + line = '' + if name1 == name: + with open(Path(root, f'{name1[:-3]}.asm'), 'w+') as newfile: + newfile.write(tempString1) diff --git a/solutions_only/project 08/VMTranslator.py b/solutions_only/project 08/VMTranslator.py new file mode 100755 index 0000000..46f68e4 --- /dev/null +++ b/solutions_only/project 08/VMTranslator.py @@ -0,0 +1,246 @@ +import os +from pathlib import Path + + +def clear_file(clearfile): + temp_string_cf = '' # clears the empty lines, comments and spaces and writes them in a string + for vmline in clearfile: + flag = 0 + if vmline == '\n': + continue + for index in range(len(vmline)): + if vmline[index:index + 2] == '//': + if flag == 1: + temp_string_cf += '\n' + break + if flag == 1 and vmline[index:index + 2] == ' ': + temp_string_cf += '\n' + break + temp_string_cf += vmline[index] + flag = 1 + return temp_string_cf + + +def push(pushline, funcname): + if 'this' in pushline: + number = int(pushline[10:]) + pushline = '@' + str(number) + '\nD=A\n@THIS\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push THIS\n' + elif 'that' in pushline: + number = int(pushline[10:]) + pushline = '@' + str(number) + '\nD=A\n@THAT\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push THAT\n' + elif 'temp' in pushline: + number = int(pushline[10:]) + number += 5 + pushline = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push TMP\n' + elif 'local' in pushline: + number = int(pushline[11:]) + pushline = '@' + str(number) + '\nD=A\n@LCL\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push LOCAL\n' + elif 'static' in pushline: + number = int(pushline[12:]) + pushline = '@' + funcname + '.' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push STATIC\n' + elif 'pointer' in pushline: + number = int(pushline[13:]) + number += 3 + pushline = '@' + str(number) + '\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push POINTER\n' + elif 'argument' in pushline: + number = int(pushline[14:]) + pushline = '@' + str(number) + '\nD=A\n@ARG\nA=M+D\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push ARGUMENT\n' + elif 'constant' in pushline: + number = pushline[14:] + pushline = '@' + str(number) + '\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//push CONSTANT\n' + return pushline + + +def pop(popline, funcname): + if 'this' in popline: + number = int(popline[9:]) + popline = '@' + str(number) + '\nD=A\n@THIS\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THIS\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THIS\nM=M-D\n//pop THIS\n' + elif 'that' in popline: + number = int(popline[9:]) + popline = '@' + str(number) + '\nD=A\n@THAT\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@THAT\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@THAT\nM=M-D\n//pop THAT\n' + elif 'temp' in popline: + number = int(popline[9:]) + number = number + 5 + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n//pop TMP\n' + elif 'local' in popline: + number = int(popline[10:]) + popline = '@' + str(number) + '\nD=A\n@LCL\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@LCL\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@LCL\nM=M-D\n//pop LOCAL\n' + elif 'static' in popline: + number = int(popline[11:]) + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + funcname + '.' + str(number) + '\nM=D\n//pop STATIC\n' + elif 'pointer' in popline: + number = int(popline[12:]) + number = number + 3 + popline = '@SP\nM=M-1\nA=M\nD=M\n@' + str(number) + '\nM=D\n//pop POINTER\n' + elif 'argument' in popline: + number = int(popline[13:]) + popline = '@' + str(number) + '\nD=A\n@ARG\nM=M+D\n@SP\nM=M-1\nA=M\nD=M\n@ARG\nA=M\nM=D\n' + '@' + str( + number) + '\nD=A\n@ARG\nM=M-D\n//pop ARG\n' + return popline + + +def aritmetic(armline): + global trueCounter + global falseCounter + if armline == 'add': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M+D\n//ADD\n" + elif armline == 'sub': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M-D\n//SUB\n" + elif armline == 'neg': + armline = "@SP\nA=M\nA=A-1\nM=-M\n//NEG\n" + elif armline == 'eq': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JEQ\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//EQ\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'gt': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JGT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//GT\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'lt': + armline = '@SP\nM=M-1\nA=M\nD=M\nA=A-1\nD=M-D\n@TRUE' + str( + trueCounter) + '\nD;JLT\n@SP\nA=M\nA=A-1\nM=0\n@FALSE' + str( + falseCounter) + '\n0;JMP\n(TRUE' + str(trueCounter) + ')\n@SP\nA=M\nA=A-1\nM=-1\n(FALSE' + str( + falseCounter) + ')\n//LT\n' + trueCounter += 1 + falseCounter += 1 + elif armline == 'and': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M&D\n//AND\n" + elif armline == 'or': + armline = "@SP\nM=M-1\nA=M\nD=M\nA=A-1\nM=M|D\n//OR\n" + elif armline == 'not': + armline = "@SP\nA=M\nA=A-1\nM=!M\n//NOT\n" + return armline + + +def label(labelline): + labelline = '(' + func_label_name + '$' + labelline[6:] + ')\n//LABEL\n' + return labelline + + +def goto(gotoline): + gotoline = '@' + func_label_name + '$' + gotoline[5:] + '\n0;JMP\n//GOTO\n' + return gotoline + + +def if_goto(ifline): + ifline = '@SP\nM=M-1\nA=M\nD=M\n@' + func_label_name + '$' + ifline[8:] + '\nD;JNE\n//IFGOTO\n' + return ifline + + +def define_func(funcline): + global func_label_name + def_func_list = funcline.rsplit(' ') + func_label_name = def_func_list[1] + funcline = '(' + def_func_list[1] + ')\n' + for ind in range(int(def_func_list[2])): + funcline += '@0\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n//DEFINEFUNC\n' + return funcline + + +def call_func(callline): + global f + call_func_list = callline.rsplit(' ') + callline = '@' + call_func_list[1] + str(f) + 'RA\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@LCL\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@ARG\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@THIS\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@THAT\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n' + callline += '@SP\nD=M\n@' + call_func_list[2] + '\nD=D-A\n@5\nD=D-A\n@ARG\nM=D\n' + callline += '@SP\nD=M\n@LCL\nM=D\n' + callline += '@' + call_func_list[1] + '\n0;JMP\n' + callline += '(' + call_func_list[1] + str(f) + 'RA)\n//CALLFUNC\n' + f += 1 + return callline + + +def return_func(returnline): + returnline = '@LCL\nD=M\n@R13\nM=D\n' + returnline += '@5\nD=A\n@R13\nD=M-D\nA=D\nD=M\n@R14\nM=D\n' + returnline += '@SP\nA=M-1\nD=M\n@ARG\nA=M\nM=D\n' + returnline += '@ARG\nD=M+1\n@SP\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@THAT\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@THIS\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@ARG\nM=D\n' + returnline += '@R13\nM=M-1\nA=M\nD=M\n@LCL\nM=D\n' + returnline += '@R14\nA=M\n0;JMP\n//RETURN\n' + return returnline + + +def iterate(name_iterate, yourpath_iterate): + line = '' + new_string = '' + with open(Path(yourpath_iterate, name_iterate + '.vm'), "r+") as vmfile: + string_iterate = clear_file(vmfile) + for j in string_iterate: # zapisva liniqta v string koito posle se obrabotva + if j != '\n': + line += j + else: + if line[:4] == 'push': + new_string += push(line, name_iterate) + line = '' + elif line[:3] == 'pop': + new_string += pop(line, name_iterate) + line = '' + elif line[:2] in aritmeticList2 or line[:3] in aritmeticList3: + new_string += aritmetic(line) + line = '' + elif line[:5] == 'label': + new_string += label(line) + line = '' + elif line[:4] == 'goto': + new_string += goto(line) + line = '' + elif line[:7] == 'if-goto': + new_string += if_goto(line) + line = '' + elif line[:8] == 'function': + new_string += define_func(line) + line = '' + elif line[:4] == 'call': + new_string += call_func(line) + line = '' + elif line[:6] == 'return': + new_string += return_func(line) + line = '' + return new_string + + +trueCounter = falseCounter = f = 0 +staticCounter = 16 +func_label_name = '' +aritmeticList3 = ['add', 'sub', 'neg', 'and', 'not'] +aritmeticList2 = ['or', 'gt', 'lt', 'eq'] +yourpath = os.getcwd() + +bootstrap = '''@256\nD=A\n@SP\nM=D\n@MainLoopXYZRA\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n@LCL\nD=M\n@SP\nA=M\nM=D\n@SP +M=M+1\n@ARG\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n@THIS\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n@THAT\nD=M\n@SP\nA=M\nM=D\n@SP +M=M+1\n@SP\nD=M\n@0\nD=D-A\n@5\nD=D-A\n@ARG\nM=D\n@SP\nD=M\n@LCL\nM=D\n@Sys.init\n0;JMP\n(MainLoopXYZRARA) +//CALLFUNC\n''' + +for root, dirs, files in os.walk(yourpath, topdown=False): + nameslist = [] + sysstring, functstring = '', '' + for name in files: + tempString = '' + if name[-3:] == '.vm': + nameslist += [name[:-3]] + for i in nameslist: + if i == 'Sys': + sysstring = bootstrap + sysstring += iterate(i, root) + + else: + functstring += iterate(i, root) + if nameslist: + with open(Path(root, f'{os.path.split(root)[1]}.asm'), 'w+') as newfile: + newfile.write(sysstring + functstring) + diff --git a/solutions_only/project 09/Tetris/Main.jack b/solutions_only/project 09/Tetris/Main.jack new file mode 100755 index 0000000..2dcf4ba --- /dev/null +++ b/solutions_only/project 09/Tetris/Main.jack @@ -0,0 +1,19 @@ +class Main { + function void main (){ + var int s; + let s = -1; + do Output.moveCursor(0,20); + do Output.printString("Welcome to Tetris"); + do Sys.wait(2000); + do Output.println(); + do Output.println(); + do Output.println(); + while ((s < 0) | (s > 100)){ // gets a number used for seed for the random function + let s = Keyboard.readInt("Enter a number between 0 and 100:"); + do Screen.clearScreen(); + } + do Sys.wait(2000); + do Tetris.tetris(s); + return; + } +} \ No newline at end of file diff --git a/solutions_only/project 09/Tetris/Piece.jack b/solutions_only/project 09/Tetris/Piece.jack new file mode 100755 index 0000000..3ca2309 --- /dev/null +++ b/solutions_only/project 09/Tetris/Piece.jack @@ -0,0 +1,473 @@ +class Piece { + static int lBorder, rBorder, uBorder, dBorder, st; + field int x1, y1, x2, y2, x3, y3, x4, y4, piece, direction; + field bool move; + static Array st; + + constructor Piece new(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4, int p) { + let x1 = Ax1; + let y1 = Ay1; + let x2 = Ax2; + let y2 = Ay2; + let x3 = Ax3; + let y3 = Ay3; + let x4 = Ax4; + let y4 = Ay4; + let piece = p; + let direction = 0; + let move = true; + return this; + } + + function void init(){ + var int a; + let lBorder = 0; + let rBorder = 511; + let uBorder = 0; + let dBorder = 255; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + return; + } + + method void dispose() { + do Memory.deAlloc(this); + return; + } + + /** draws 2 rectangles also checks if there is a piece at the spawn which will indicate end of the game. */ + method bool draw() { + var bool finish; + let finish = true; + let finish = Piece.sample(x1,y1) & finish; + let finish = Piece.sample(x2,y2) & finish; + let finish = Piece.sample(x3,y3) & finish; + let finish = Piece.sample(x4,y4) & finish; + if (finish){ + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return true; + } + return false; + } + + /** Erases the square from the screen. */ + method void erase() { + do Screen.setColor(false); + do Screen.drawRectangle(x1, y2, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return; + } + /** checks if those coodinates hold any value > 0. */ + function bool sample(int x, int y){ + var int value, address, bit, memBlock; + let memBlock = x / 16; + let address = (32 * y) + memBlock + 16384; + if (address > 24576){ + return false; + } + let value = Memory.peek(address); + if (value = 0){ + return true; + } + return false; + } + + method bool getMove(){ + return move; + } + + /** Checks if the piece can move in the given direction(dir). */ + method bool fullSample(int dir){ + var int size1, size2, i, j; + var bool result, flagUpon; + if (dir = 1){ //down + let size1 = x2 - x1; + let size2 = x4 - x3; + let result = true; + while (i < size1){ // for each block of the first rectangle + let j = 0; + let flagUpon = false; + while (j < size2){ // for each block of the second rectangle + if ((x1 + i) = (x3 + j)){ // if this block of the first rectangle sits upon a block of the second rectangle + let flagUpon = true; + } + let result = result & Piece.sample(x3 + j, y4 + 1); // if there is a block under the second rectangle + let j = j + 16; // sets the coords for the next block of the second rectangle + } + if (~(flagUpon)){ + let result = result & Piece.sample(x1 + i, y2 + 1); // if there is a block under the first rectangle + } + let i = i + 16; // sets the coords for the next block of the firs rectangle + } + return result; + } + else{ + if (dir = 2){ //right + let size1 = y2 - y1; + let size2 = y4 - y3; + let result = true; + while (i < size1){ + let j = 0; + let flagUpon = false; + while (j < size2){ + if ((y1 + i) = (y3 + j)){ + let flagUpon = true; + } + let result = result & Piece.sample(x4 + 1, (y3 + j)); + let j = j + 16; + } + if (~(flagUpon)){ + let result = result & Piece.sample(x2 + 1, (y1 + i)); + } + let i = i +16; + } + return result; + } + else{ // left + let size1 = y2 - y1; + let size2 = y4 - y3; + let result = true; + while (i < size2){ + let j = 0; + let flagUpon = false; + while (j < size1){ + if ((y3 + i) = (y1 + j)){ + let flagUpon = true; + } + let result = result & Piece.sample(x1 - 1, (y1 + j)); + let j = j + 16; + } + if (~(flagUpon)){ + let result = result & Piece.sample(x3 - 1, (y3 + i)); + } + let i = i + 16; + } + return result; + } + } + } + + /** Moves the game piece 16 pixels down. */ + method void moveDown() { + var int i; + if ((y2 < dBorder) & (y4 < dBorder) & (move) & fullSample(1)) { + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x2, y1); + do Screen.drawRectangle(x3, y3, x4, y3); + let y1 = y1 + 1; + let y2 = y2 + 1; + let y3 = y3 + 1; + let y4 = y4 + 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y2, x2, y2); + do Screen.drawRectangle(x3, y4, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + else{ + let move = false; + } + return; + } + + /** Moves the game piece 16 pixels to the left. */ + method void moveLeft() { + var int i; + if ((x1 + 15 > lBorder) & (move) & (x3 + 15 > lBorder)& fullSample(0)){ + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x2, y1, x2, y2); + do Screen.drawRectangle(x4, y3, x4, y4); + let x1 = x1 - 1; + let x2 = x2 - 1; + let x3 = x3 - 1; + let x4 = x4 - 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + return; + } + + /** Moves the game piece 16 pixels to the right. */ + method void moveRight() { + var int i; + if ((x4 < rBorder) & (move) & (x2 < rBorder) & fullSample(2)){ + while (i < 16){ + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x1, y2); + do Screen.drawRectangle(x3, y3, x3, y4); + let x1 = x1 + 1; + let x2 = x2 + 1; + let x3 = x3 + 1; + let x4 = x4 + 1; + do Screen.setColor(true); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + let i = i + 1; + do Sys.wait(10); + } + } + return; + } + + /** Deletes the piece and draws it at the new coodinates. */ + method void reDraw(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4){ + var int absTmp; + if((Ax1 < 175) | (Ax3 < 175) | (Ax2 > 336) | (Ax4 > 336)){ + return; + } + if((Ay2 > 255) | (Ay4 > 255) | (Ay1 < 0) | (Ay3 < 0)){ + return; + } + if((Ax1 > Ax2) | (Ax3 > Ax4) | (Ay1 > Ay2) | (Ay3 > Ay4)){ + return; + } + do Screen.setColor(false); + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + do Screen.setColor(true); + let x1 = Ax1; + let y1 = Ay1; + let x2 = Ax2; + let y2 = Ay2; + let x3 = Ax3; + let y3 = Ay3; + let x4 = Ax4; + let y4 = Ay4; + do Screen.drawRectangle(x1, y1, x2, y2); + do Screen.drawRectangle(x3, y3, x4, y4); + return; + } + + /** Rotates the piece clockwise. */ + method void rotate(){ + var bool samp; + let samp = true; + if (direction = 0){ // starting position + if (piece = 0){ // arrow + let samp = Piece.sample(x4, y1) & samp; // checks if the place at which the new piece will be drawn are free + let samp = Piece.sample(x4, y1 - 1) & samp; + if (samp){ + do reDraw(x1, y1, x2, y2, x4 - 15, y4 - 47, x4, y4); // redraws it at the new location + let direction = 1; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 + 16, y1) & samp; + let samp = Piece.sample(x1 + 16, y1 - 16) & samp; + let samp = Piece.sample(x4, y1 - 16) & samp; + if(samp){ + do reDraw(x1 + 16, y1 - 16, x4 - 16, y4, x4 - 15, y1 - 16, x4, y1 - 1); + let direction = 1; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 - 16, y1 - 16) & samp; + let samp = Piece.sample(x1 - 16, y1) & samp; + if (samp){ + do reDraw(x1 - 16, y1 - 16, x2 - 16, y2 + 16, x3 + 32, y3, x4, y4); + let direction = 1; + } + } + if (piece = 3){ + let samp = Piece.sample(x3 + 16, y3 - 32) & samp; + let samp = Piece.sample(x4, y4 - 16) & samp; + if (samp){ + do reDraw(x1 + 16, y1, x2, y2 + 16, x3 + 16, y3 - 32, x4, y4 - 16); + let direction = 1; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 + 32, y3 - 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 - 16, y2 + 16, x3 + 32, y3 - 32, x4 + 16, y4 - 16); + let direction = 1; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 + 32, y1 - 32) & samp; + let samp = Piece.sample(x2 + 16, y2 - 16) & samp; + let samp = Piece.sample(x4 - 16, y4 + 16) & samp; + if (samp){ + do reDraw(x1 + 32, y1 - 32, x2 + 16, y2 - 16, x3, y3, x4 - 16, y4 + 16); + let direction = 1; + } + } + } + else{ + if (direction = 1){ + if (piece = 0){ + let samp = Piece.sample(x1, y3) & samp; + let samp = Piece.sample(x1 - 1, y3) & samp; + if (samp){ + do reDraw(x1 - 16, y3, x4, y3 + 15, x1, y1, x2, y2); + let direction = 2; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3, y3 + 16) & samp; + let samp = Piece.sample(x3, y3 + 32) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 16, x4, y4 + 16, x3, y3 + 32, x4, y2); + let direction = 2; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x2 + 16, y2 - 16) & samp; + let samp = Piece.sample(x3 - 32, y3) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 16, x2 + 16, y2 - 16, x3 - 32, y3, x4 - 32, y4); + let direction = 2; + } + } + if (piece = 3){ + let samp = Piece.sample(x1 - 16, y1) & samp; + let samp = Piece.sample(x4, y4 + 16) & samp; + if (samp){ + do reDraw(x1 - 16, y1, x2, y2 - 16, x3 - 16, y3 +32, x4, y4 + 16); + let direction = 2; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 - 32, y3 + 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 + 16, y2 - 16, x3 - 32, y3 + 32, x4 - 16, y4 + 16); + let direction = 2; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3 + 16, y3 - 16) & samp; + let samp = Piece.sample(x4 + 32, y4 - 32) & samp; + if (samp){ + do reDraw(x1 - 32, y1 + 16, x2 - 16, y2, x3, y3 - 16, x4 + 16, y4 - 32); + let direction = 2; + } + } + } + else{ + if (direction = 2){ + if (piece = 0){ + let samp = Piece.sample(x1, y1+16) & samp; + let samp = Piece.sample(x1, y1+32) & samp; + if (samp){ + do reDraw(x1, y1, x1 + 15, y1 + 47, x3, y3, x4, y4); + let direction = 3; + } + } + if (piece = 1){ + let samp = Piece.sample(x1 - 16, y1 + 16) & samp; + let samp = Piece.sample(x3, y3 + 16) & samp; + let samp = Piece.sample(x3, y3 + 32) & samp; + if (samp){ + do reDraw(x1, y1 + 16, x1 + 15, y1 + 31, x1 + 16, y1 - 16, x4 - 16, y4); + let direction = 3; + } + } + if (piece = 2){ + let samp = Piece.sample(x1, y1 - 16) & samp; + let samp = Piece.sample(x2 + 32, y2 + 16) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1, y1 - 16, x2 - 32, y2 - 16, x3 + 16, y3 - 32, x4 + 16, y4); + let direction = 3; + } + } + if (piece = 3){ + let samp = Piece.sample(x2 - 16, y2 + 16) & samp; + let samp = Piece.sample(x3, y3 - 32) & samp; + if (samp){ + do reDraw(x1, y1, x2 - 16, y2 + 16, x3, y3 - 32, x4 - 16, y4 - 16); + let direction = 3; + } + } + if (piece = 4){ + let samp = Piece.sample(x1 - 16, y1 - 16) & samp; + let samp = Piece.sample(x2 - 32, y2) & samp; + if (samp){ + do reDraw(x1 - 16, y1 - 16, x2 - 32, y2, x3 + 16, y3 - 16, x4, y4); + let direction = 3; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 + 16, y1 - 16) & samp; + let samp = Piece.sample(x3 - 16, y3 - 16) & samp; + let samp = Piece.sample(x4 - 32, y4 + 32) & samp; + if (samp){ + do reDraw(x1 + 16, y1 - 16, x2, y2, x3 - 16, y3 + 16, x4 - 32, y4 + 32); + let direction = 3; + } + } + } + else{ + if (piece = 0){ + let samp = Piece.sample(x4 + 16, y4) & samp; + let samp = Piece.sample(x4 + 32, y4) & samp; + if (samp){ + do reDraw(x3, y3, x4, y4, x1, y1 + 32, x1 + 47, y1 + 47); + let direction = 0; + } + } + if (piece = 1){ + let samp = Piece.sample(x1, y1 - 16) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1, y1 - 16, x2, y2 -16, x1, y1, x4 + 16, y4); + let direction = 0; + } + } + if (piece = 2){ + let samp = Piece.sample(x1 + 32, y1 + 16) & samp; + let samp = Piece.sample(x3 - 16, y3 + 32) & samp; + let samp = Piece.sample(x4 + 16, y4) & samp; + if (samp){ + do reDraw(x1 + 32, y1 + 16, x2 + 32, y2 + 16, x3 - 16, y3 + 32, x4 + 16, y4); + let direction = 0; + } + } + if (piece = 3){ + let samp = Piece.sample(x3, y3 + 32) & samp; + let samp = Piece.sample(x4 + 16, y4 + 16) & samp; + if (samp){ + do reDraw(x1, y1, x2 + 16, y2 - 16, x3, y3 + 32, x4 + 16, y4 + 16); + let direction = 0; + } + } + if (piece = 4){ + let samp = Piece.sample(x3 - 16, y3 + 16) & samp; + let samp = Piece.sample(x2 + 32, y2) & samp; + if (samp){ + do reDraw(x1 + 16, y1 + 16, x2 + 32, y2, x3 - 16, y3 + 16, x4, y4); + let direction = 0; + } + } + if (piece = 5){ + let samp = Piece.sample(x1 - 16, y1 + 32) & samp; + let samp = Piece.sample(x3 + 16, y3) & samp; + let samp = Piece.sample(x4 + 32, y4 - 16) & samp; + if (samp){ + do reDraw(x1 - 16, y1 + 32, x2, y2 + 16, x3 + 16, y3, x4 + 32, y4 - 16); + let direction = 0; + } + } + } + } + } + return; + } +} + diff --git a/solutions_only/project 09/Tetris/Tetris.jack b/solutions_only/project 09/Tetris/Tetris.jack new file mode 100755 index 0000000..0d15797 --- /dev/null +++ b/solutions_only/project 09/Tetris/Tetris.jack @@ -0,0 +1,203 @@ +class Tetris { + static int points, seed, next_seed; + + function void tetris(int z){ + var Piece p, nextPiece; + var int i, x1, y1, x2, y2, x3, y3, x4, y4, key, j, randTmp, piece_number, moves; + var Array left_g, right_g, box, stick, left_z, right_z,dick, all_piece, tmp; + do Piece.init(); + do Tetris.border(); + let points = 0; + let all_piece = Array.new(25); + let all_piece[0] = Tetris.newPiece(16,0,31,15, 0,16,47,31, 0); // arrow + let all_piece[1] = Tetris.newPiece(0,0,15,15, 0,16,47,31, 1); // right_L + let all_piece[2] = Tetris.newPiece(32,16,47,31, 0,32,47,47, 2); // left_L + let all_piece[3] = Tetris.newPiece(0,0,31,15, 16,16,47,31, 3); // left_z + let all_piece[4] = Tetris.newPiece(16,0,47,15, 0,16,31,31, 4); // right_z + let all_piece[5] = Tetris.newPiece(0,0,31,15, 32,0,63,15, 5); //stick + let all_piece[6] = Tetris.newPiece(0,0,15,31, 16,0,31,31, 6); //box + + + let seed = z * 3; // multiply by 3, because it gets in a loop on some even numbers + let next_seed = Tetris.randomNumber(); + do Output.moveCursor(0,0); + do Output.printString("Point: "); + do Output.printInt(points); + do Output.println(); + do Output.printString("Next Piece: "); + while (true){ // The main game loop + let j = next_seed; + let next_seed = Tetris.randomNumber(); + let tmp = all_piece[j]; // initializes the coords of the game piece + let x1 = tmp[0]; + let y1 = tmp[1]; + let x2 = tmp[2]; + let y2 = tmp[3]; + let x3 = tmp[4]; + let y3 = tmp[5]; + let x4 = tmp[6]; + let y4 = tmp[7]; + let piece_number = tmp[8]; + let p = Piece.new(x1 + 240, y1, x2 + 240, y2, x3 + 240, y3, x4 + 240, y4, piece_number); + if (~(p.draw())){ // if a piece tries to spawn above a limit the game ends + if (~(Tetris.finish())){ + return; + } + } + let tmp = all_piece[next_seed]; + let x1 = tmp[0]; // initializes the coords of the next game piece that is being displayed + let y1 = tmp[1]; + let x2 = tmp[2]; + let y2 = tmp[3]; + let x3 = tmp[4]; + let y3 = tmp[5]; + let x4 = tmp[6]; + let y4 = tmp[7]; + let piece_number = tmp[8]; + let nextPiece = Piece.new(x1 + 16, y1 + 32, x2+16, y2 + 32, x3+16, y3 + 32, x4 + 16, y4 + 32, piece_number); + do nextPiece.draw(); + while (p.getMove()){ + let moves = 0; + while (moves < 3){ // one can move its piece 3 times before it moves down automatically + let key = Keyboard.keyPressed(); + if (key = 130){ + do p.moveLeft(); + do Sys.wait(80); + } + if (key = 132){ + do p.moveRight(); + do Sys.wait(80); + } + if (key = 131){ + do p.rotate(); + } + if (key = 133){ + do p.moveDown(); + do p.moveDown(); + } + let moves = moves +1; + } + do p.moveDown(); + let i = i + 1; + do Sys.wait(80); + } + let i = 0; + do p.dispose(); + do Tetris.completeRow(); + do Output.moveCursor(0,7); + do Output.printInt(points); + do Screen.setColor(false); + do Screen.drawRectangle(16,32,80,96); + do Screen.setColor(true); + do nextPiece.dispose(); + } + return; + } + + function void completeRow(){ // checks if a row has been completed + var int adddress, row, colloum; + var bool complete; + let adddress = 16384 + 11; + let row = 15; + while (row > 0){ // for each row + let complete = true; + let colloum = 0; + while ((colloum < 10) & (complete)){ // for each collum + let complete = Memory.peek(adddress + colloum + (row * 512)) & complete; + let colloum = colloum + 1; + } + if (complete){ // removes the row + do Screen.setColor(false); + do Screen.drawRectangle(176, row * 16, 335, ((row * 16)+ 15) ); + let points = points + 1; + do Tetris.shift(row); + } + let row = row - 1; + } + return; + } + + function void shift(int rowShift){ // shifts all rows above the completed one + var int j, val, adddress, tmp, k; + let adddress = 16384 + 11; + while (rowShift > 1){ // each row + let j = 0; + while (j < 10){ // collum in the game field + let k = 0; + while (k < 16){ // each line a in 16 x 16 box + let tmp = adddress + j + (((rowShift - 1) * 512) + (k * 32)); + let val = Memory.peek(tmp); + do Memory.poke(adddress + j + ((rowShift * 512) + (k * 32)), val); + do Memory.poke(tmp,0); + let k = k+ 1; + } + let j = j + 1; + } + let rowShift = rowShift - 1; + } + return; + } + + function void border(){ // draws a border + do Screen.drawLine(175,0,175,255); + do Screen.drawLine(336,0,336,255); + return; + } + + function Array newPiece(int Ax1, int Ay1, int Ax2, int Ay2, int Ax3, int Ay3, int Ax4, int Ay4,int p){ + var Array gamepice; + let gamepice = Array.new(9); + let gamepice[0] = Ax1; + let gamepice[1] = Ay1; + let gamepice[2] = Ax2; + let gamepice[3] = Ay2; + let gamepice[4] = Ax3; + let gamepice[5] = Ay3; + let gamepice[6] = Ax4; + let gamepice[7] = Ay4; + let gamepice[8] = p; + return gamepice; + } + + function int randomNumber(){ // radom number generator + var int multiplier,additor,moduler,toBeModulated; + let multiplier = 7; + let additor = 13; + let moduler = 1133; + let toBeModulated = (multiplier * seed) + additor; + let seed = Tetris.mod(toBeModulated,moduler); + return Tetris.mod(seed,7); + } + + function bool finish(){ // after finishing the game the player has 2 options to start onether or to end the game + var char c; + do Screen.clearScreen(); + do Output.moveCursor(10,24); + do Output.printString("Your score: "); + do Output.printInt(points); + do Sys.wait(10000); + do Screen.clearScreen(); + do Output.moveCursor(10,0); + do Output.printString("Would you like to play again, for yes click 'Y' and for no 'N':"); + let c = Keyboard.readChar(); + if (c = 89){ + do Screen.clearScreen(); + return false; + } + if (c = 78){ + do Screen.clearScreen(); + do Sys.halt(); + } + return true; + } + + function int mod(int tbm, int mo){ //simple moduler devision + var int val, tmp2; + if (tbm < mo){ + return tbm; + } + let tmp2 = (tbm / mo) * mo; + let val = tbm - tmp2; + return val; + } +} \ No newline at end of file diff --git a/solutions_only/project 10/JackAnalyzer.py b/solutions_only/project 10/JackAnalyzer.py new file mode 100755 index 0000000..d7f8f02 --- /dev/null +++ b/solutions_only/project 10/JackAnalyzer.py @@ -0,0 +1,410 @@ +import re +import os +from pathlib import Path + + +class Tokenizer: + + def __init__(self): + self.i = 0 + self.file = '' + self.symbols = ('(', ')', '[', ']', '}', '{', '>', '<', '=', '*', '+', '-', '/', '.', ';', ',', '&', '|', + '~', '>', '<', '&') + self.key_word = ( + 'class', 'method', 'function', 'constructor', 'int', 'boolean', 'char', 'void', 'var', 'static', 'field', + 'let', 'do', 'if', 'else', 'while', 'return', 'true', 'false', 'null', 'this') + self.token = '' + + def token_type(self): + if self.token is None or self.token == '': + return None + if self.token in self.key_word: + return 'keyword' + elif self.token[0] == '"': + return 'stringConstant' + elif re.match(r"\d+", self.token): + return 'integerConstant' + elif self.token in self.symbols: + return 'symbol' + else: + return 'identifier' + + def advance(self): + token = '' + i = self.i + while i < len(self.file): + if re.match(r'\s', self.file[i]): + i = i + 1 + continue + else: + if self.file[i] in self.symbols: + if self.file[i] == '>': + self.token = '>' + elif self.file[i] == '<': + self.token = '<' + elif self.file[i] == '&': + self.token = '&' + else: + self.token = self.file[i] + # self.token = self.file[i] + self.i = i + 1 + return + elif self.file[i] == '"': + i += 1 + while self.file[i] != '"': + token += self.file[i] + i += 1 + self.i = i + 1 + self.token = '"' + token + '"' + return + else: + while re.match(r'\w', self.file[i]): + token += self.file[i] + if i + 1 > len(self.file) - 1: + break + i += 1 + self.i = i + self.token = token + return + + def clear_file(self, directory): + with open(directory, "r") as my_file: + txt = my_file.read() + txt = re.sub(r"//.*", "", txt) + txt = re.sub(r"/[*][*].*[*]/", "", txt) + txt = re.sub(r"/[*][*][\w*\W*]*[*]/", "", txt) + self.file = txt + + +class CompilationEngine: + def __init__(self): + self.string = '' + self.tab = 0 + + def write_token(self, tokenizer): + if tokenizer.token_type() == 'stringConstant': + self.string += ' ' * self.tab + '<' + tokenizer.token_type() + '> ' + tokenizer.token.strip('"') + ' \n' + else: + self.string += ' ' * self.tab + '<' + tokenizer.token_type() + '> ' + tokenizer.token + ' \n' + + def compile_class(self, tokenizer): + tokenizer.advance() + self.string += '\n' + ' ' * self.tab + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token != '}': + if tokenizer.token in ['static', 'field']: + self.compile_class_var_dec(tokenizer) + if tokenizer.token in ['constructor', 'function', 'method']: + self.compile_subroutine(tokenizer) + + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_class_var_dec(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_subroutine(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_parameter_list(tokenizer) + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token != '}': + if tokenizer.token == 'var': + self.compile_var_dec(tokenizer) + elif tokenizer.token in ['let', 'if', 'while', 'do', 'return']: + self.compile_statements(tokenizer) + self.write_token(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_parameter_list(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + while tokenizer.token != ')': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + self.write_token(tokenizer) + tokenizer.advance() + + def compile_var_dec(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_statements(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + while True: + if tokenizer.token == 'let': + self.compile_let(tokenizer) + elif tokenizer.token == 'if': + self.compile_if(tokenizer) + elif tokenizer.token == 'while': + self.compile_while(tokenizer) + elif tokenizer.token == 'do': + self.compile_do(tokenizer) + elif tokenizer.token == 'return': + self.compile_return(tokenizer) + else: + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + break + + def compile_do(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token == '(': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + elif tokenizer.token == '.': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_let(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token == '[': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_while(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_statements(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_return(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token != ';': + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_if(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_statements(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + while tokenizer.token == 'else': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_statements(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_expression(self, tokenizer): + if tokenizer.token in ['(', '~', '-'] or tokenizer.token_type() != 'symbol': + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.compile_term(tokenizer) + while tokenizer.token in ['+', '-', '*', '/', '&', '|', '<', '>', '=']: + self.write_token(tokenizer) + tokenizer.advance() + self.compile_term(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_term(self, tokenizer): + if tokenizer.token == '(': + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token in ['~', '-']: + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + self.compile_term(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token_type() != 'symbol': + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.write_token(tokenizer) + tokenizer.advance() + if tokenizer.token == '[': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token == '(': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + elif tokenizer.token == '.': + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression_list(tokenizer) + self.write_token(tokenizer) + tokenizer.advance() + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + else: + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + def compile_expression_list(self, tokenizer): + self.string += ' ' * self.tab + '\n' + self.tab += 2 + self.compile_expression(tokenizer) + while tokenizer.token == ',': + self.write_token(tokenizer) + tokenizer.advance() + self.compile_expression(tokenizer) + self.tab -= 2 + self.string += ' ' * self.tab + '\n' + + +path = os.getcwd() +for root, dirs, files in os.walk(path, topdown=False): + for name in files: + if name[-4:] == 'jack': + tok = Tokenizer() + tok.clear_file(Path(root, name)) + ce = CompilationEngine() + ce.compile_class(tok) + with open(Path(root, name[:-4] + 'xml'), "w+") as my_xml: + my_xml.write(ce.string) diff --git a/solutions_only/project 11/JackCompiler.py b/solutions_only/project 11/JackCompiler.py new file mode 100755 index 0000000..5782f99 --- /dev/null +++ b/solutions_only/project 11/JackCompiler.py @@ -0,0 +1,350 @@ +import os +from pathlib import Path +from tokenizer import Tokenizer +from vmwriter import VMWriter +from symbol_table import SymbolTable + + +# TODO add names to variables when you call for them, aka current_vm_append(thingtobeappended=blablac) + +class CompilationEngine: + def __init__(self, tokenizer, full_path_vm): + self.string = self.sub_type = self.class_name = self.function_type = '' + self.tab = self.recursion_index = 0 + self.tokenizer = tokenizer + self.sym_table = [] + self.vmwriter = VMWriter(full_path_vm) + self.current_vm = [] # used to reverse some of the commands, eg a+b need to be a b + + + def search_kind_of_sym(self, current_vm): + if self.sym_table[-1].kind_of(current_vm) is not None: + return self.sym_table[-1].kind_of(current_vm), self.sym_table[-1].index_of(current_vm) + for i in range(len(self.sym_table) - 2, -1, + -1): # start from the amount of sym_tables -2 so it starts from one below the current, + # until it is bigger than -1, walking it backwards + if self.sym_table[i].kind_of(current_vm) in ('static', 'this'): + return self.sym_table[i].kind_of(current_vm), self.sym_table[i].index_of(current_vm) + + def search_type_of_sym(self, current_vm): + for i in range(len(self.sym_table) - 1, -1, -1): + if self.sym_table[i].type_of(current_vm) is not None: + return self.sym_table[i].type_of(current_vm) + + def write_token(self): + if self.tokenizer.token_type() == 'stringConstant': + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token.strip( + '"') + ' \n' + else: + self.string += ' ' * self.tab + '<' + self.tokenizer.token_type() + '> ' + self.tokenizer.token + ' \n' + + def compile_class(self): + self.sym_table.append(SymbolTable()) + self.tokenizer.advance() # class -> + self.tokenizer.advance() # type -> + self.class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + self.tokenizer.advance() # { -> + while self.tokenizer.token != '}': + if self.tokenizer.token in ['static', 'field']: + self.compile_class_var_dec() + if self.tokenizer.token in ['constructor', 'function', 'method']: + self.compile_subroutine() + self.tokenizer.advance() + self.sym_table.pop() + self.vmwriter.close_vm_file() + + def compile_class_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_subroutine(self): + self.sym_table.append(SymbolTable()) + self.sub_type = self.tokenizer.token + self.tokenizer.advance() # subroutine type(function|method|constructor) -> + self.function_type = self.tokenizer.token + self.tokenizer.advance() # subroutine kind(int|void|etc..) -> + sub_name = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + if self.sub_type == 'method': + self.sym_table[-1].start_subroutine('this', self.class_name) + self.compile_parameter_list() + self.tokenizer.advance() # { -> + while self.tokenizer.token == 'var': # create only symbol teable entries + self.compile_var_dec() + if self.sub_type == 'constructor': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('constant', self.sym_table[-2].var_count('field')) + self.vmwriter.write_call('Memory.alloc', 1) + self.vmwriter.write_pop('pointer', 0) + elif self.sub_type == 'method': + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + self.vmwriter.write_push('argument', 0) + self.vmwriter.write_pop('pointer', 0) + else: + self.vmwriter.write_function(f'{self.class_name}.{sub_name}', self.sym_table[-1].var_count('var')) + while self.tokenizer.token != '}': + self.compile_statements() + self.tokenizer.advance() + self.sym_table.pop() + + def compile_parameter_list(self): + if self.tokenizer.token != ')': + var_type = self.tokenizer.token + self.tokenizer.advance() # var ype -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # var name -> + while self.tokenizer.token == ',': + self.tokenizer.advance() # , -> + var_type = self.tokenizer.token + self.tokenizer.advance() # type -> + var_name = self.tokenizer.token + self.sym_table[-1].define(var_name, var_type, 'argument') + self.tokenizer.advance() # name -> + self.tokenizer.advance() # )-> + + def compile_var_dec(self): + var_kind = tokenizer_main.token + self.tokenizer.advance() + var_type = tokenizer_main.token + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + while self.tokenizer.token == ',': + self.tokenizer.advance() + var_name = tokenizer_main.token + self.sym_table[-1].define(var_name, var_type, var_kind) + self.tokenizer.advance() + self.tokenizer.advance() + + def compile_statements(self): + while True: + if self.tokenizer.token == 'let': + self.compile_let() + elif self.tokenizer.token == 'if': + self.compile_if() + elif self.tokenizer.token == 'while': + self.compile_while() + elif self.tokenizer.token == 'do': + self.compile_do() + elif self.tokenizer.token == 'return': + self.compile_return() + else: + break + + def compile_do(self): + self.tokenizer.advance() # do -> + class_name = self.tokenizer.token + self.tokenizer.advance() # name -> + if self.tokenizer.token == '(': # method + self.vmwriter.write_push('pointer', 0) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{class_name}', count + 1) + elif self.tokenizer.token == '.': # method or function + self.tokenizer.advance() # . -> + fname = f'{class_name}.{self.tokenizer.token}' + sname = f'{self.search_type_of_sym(class_name)}.{self.tokenizer.token}' + self.tokenizer.advance() # name -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_push(*self.search_kind_of_sym(class_name)) + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if self.search_kind_of_sym(class_name) is not None: + self.vmwriter.write_call(f'{sname}', count + 1) + else: + self.vmwriter.write_call(f'{fname}', count) + self.vmwriter.write_pop('temp', '0') + self.tokenizer.advance() # ; -> + + def compile_let(self): + flag_array = 0 + self.tokenizer.advance() # let -> + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # var_name -> + if self.tokenizer.token == '[': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.tokenizer.advance() # [ -> + self.compile_expression() + self.tokenizer.advance() # ] -> + flag_array = 1 + self.tokenizer.advance() # = -> + self.compile_expression() + self.tokenizer.advance() # ; -> + if flag_array == 0: + self.vmwriter.write_pop(*self.search_kind_of_sym(self.current_vm[-1])) + else: + self.vmwriter.write_pop('temp', 1) + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('temp', 1) + self.vmwriter.write_pop('that', 0) + self.current_vm.pop() + + def compile_while(self): + self.tokenizer.advance() # while -> + label1 = self.vmwriter.label_index + self.vmwriter.write_lable(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label2 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_goto(label1) + self.vmwriter.write_lable(label2) + + def compile_return(self): + self.tokenizer.advance() # return -> + if self.tokenizer.token != ';': + self.compile_expression() + self.vmwriter.write_return(self.function_type) + self.tokenizer.advance() # ; -> + + def compile_if(self): + self.tokenizer.advance() # if -> + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + label1 = self.vmwriter.label_index + self.vmwriter.write_if(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + label2 = self.vmwriter.label_index + self.vmwriter.write_goto(self.vmwriter.label_index) + self.vmwriter.label_index += 1 + self.vmwriter.write_lable(label1) + if self.tokenizer.token == 'else': + self.tokenizer.advance() # else -> + self.tokenizer.advance() # { -> + self.compile_statements() + self.tokenizer.advance() # } -> + self.vmwriter.write_lable(label2) + + def compile_expression(self): + self.compile_term() + while self.tokenizer.token in ['+', '-', '*', '/', '|', '=', '>', '<', '&']: + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # symbol -> + self.compile_term() + self.vmwriter.write_arithmetic(self.current_vm[-1]) + self.current_vm.pop() + + def compile_term(self): + if self.tokenizer.token == '(': # expression () + self.tokenizer.advance() # ( -> + self.compile_expression() + self.tokenizer.advance() # ) -> + elif self.tokenizer.token in ['~', '-']: # uniry op + self.current_vm.append(self.tokenizer.token) + tmp = 'neg' if self.tokenizer.token == '-' else self.tokenizer.token + self.tokenizer.advance() # ~ or - -> + self.compile_term() + self.vmwriter.write_arithmetic(tmp) + self.current_vm.pop() + elif self.tokenizer.token_type() != 'symbol': + self.current_vm.append(self.tokenizer.token) + self.tokenizer.advance() # integer, string, keyword, varnname, subroutine_name, class_name, var_name -> + if self.tokenizer.token == '[': # Array + self.tokenizer.advance() # [ -> + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + self.compile_expression() + self.vmwriter.write_arithmetic('+') + self.vmwriter.write_pop('pointer', 1) + self.vmwriter.write_push('that', 0) + self.tokenizer.advance() # ] -> + elif self.tokenizer.token == '(': # subroutine_name () + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + self.vmwriter.write_call(f'{self.class_name}.{self.current_vm[-1]}', count) + self.current_vm.pop() + elif self.tokenizer.token == '.': # method + if self.search_type_of_sym(self.current_vm[-1]) is not None: + flag = 1 + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + else: + flag = 0 + self.tokenizer.advance() # . -> + fname = self.tokenizer.token + self.tokenizer.advance() # subroutine name -> + self.tokenizer.advance() # ( -> + count = self.compile_expression_list() + self.tokenizer.advance() # ) -> + if flag == 1: + self.vmwriter.write_call(f'{self.search_type_of_sym(self.current_vm[-1])}.{fname}', count + 1) + else: + self.vmwriter.write_call(f'{self.current_vm[-1]}.{fname}', count) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'stringConstant': + self.vmwriter.write_push('constant', len(self.current_vm[-1].strip('"'))) + self.vmwriter.write_call('String.new', 1) + for index, item in enumerate(self.current_vm[-1].strip('"')): + self.vmwriter.write_push('constant', ord(item)) + self.vmwriter.write_call('String.appendChar', 2) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'integerConstant': + self.vmwriter.write_push('constant', self.current_vm[-1]) + self.current_vm.pop() + elif self.tokenizer.token_type(self.current_vm[-1]) == 'identifier': + self.vmwriter.write_push(*self.search_kind_of_sym(self.current_vm[-1])) + self.current_vm.pop() + elif self.current_vm[-1] == 'true': + self.vmwriter.write_push('constant', '1') + self.vmwriter.write_arithmetic('neg') + self.current_vm.pop() + elif self.current_vm[-1] == 'false' or self.current_vm[-1] == 'null': + self.vmwriter.write_push('constant', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'this': + self.vmwriter.write_push('pointer', '0') + self.current_vm.pop() + elif self.current_vm[-1] == 'that': + self.vmwriter.write_push('pointer', '1') + self.current_vm.pop() + + def compile_expression_list(self): + count_exp = 0 + if self.tokenizer.token in ['(', '~', '-'] or self.tokenizer.token_type() != 'symbol': + count_exp += 1 + self.compile_expression() + while self.tokenizer.token == ',': + count_exp += 1 + self.tokenizer.advance() # , + self.compile_expression() + return count_exp + + +if __name__ == '__main__': + path = os.getcwd() + for root, dirs, files in os.walk(path, topdown=False): + for name in files: + if name[-4:] == 'jack': + tokenizer_main = Tokenizer() + tokenizer_main.clear_file(Path(root, name)) + full_path = Path(root, name[:-4] + 'vm') + comp_eng_main = CompilationEngine(tokenizer_main, full_path) + comp_eng_main.compile_class() diff --git a/solutions_only/project 11/symbol_table.py b/solutions_only/project 11/symbol_table.py new file mode 100755 index 0000000..7c62c3e --- /dev/null +++ b/solutions_only/project 11/symbol_table.py @@ -0,0 +1,62 @@ +class Symbol: + def __init__(self): + self.s_name = '' + self.s_kind = '' + self.s_type = '' + self.s_index = 0 + + +class SymbolTable: + def __init__(self): + self.sym = [] + + def define(self, s_name, s_type, s_kind): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = s_kind + self.sym[-1].s_index = self.var_count(s_kind) - 1 + + def start_subroutine(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = s_name + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'argument' + self.sym[-1].s_index = 0 + + def start_class(self, s_name, s_type): + self.sym.append(Symbol()) + self.sym[-1].s_name = 'this' + self.sym[-1].s_type = s_type + self.sym[-1].s_kind = 'field' + self.sym[-1].s_index = 0 + + def var_count(self, s_kind): + count = 0 # it is -1 so the first index is 0 + for i in self.sym: + if i.s_kind == s_kind: + count += 1 + return count + + def kind_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + if i.s_kind == 'var': + return 'local' + elif i.s_kind == 'field': + return 'this' + else: + return i.s_kind + return None + + def type_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_type + return None + + def index_of(self, s_name): + for i in self.sym: + if i.s_name == s_name: + return i.s_index + return None diff --git a/solutions_only/project 11/tokenizer.py b/solutions_only/project 11/tokenizer.py new file mode 100755 index 0000000..aaaa873 --- /dev/null +++ b/solutions_only/project 11/tokenizer.py @@ -0,0 +1,78 @@ +import re + + +class Tokenizer: + + def __init__(self): + self.i = 0 + self.file = '' + self.symbols = ('(', ')', '[', ']', '}', '{', '>', '<', '=', '*', '+', '-', '/', '.', ';', ',', '&', '|', + '~') + self.key_word = ( + 'class', 'method', 'function', 'constructor', 'int', 'boolean', 'char', 'void', 'var', 'static', 'field', + 'let', 'do', 'if', 'else', 'while', 'return', 'true', 'false', 'null', 'this') + self.token = '' + + def token_type(self, token=None): + if token is None: + token = self.token + if token is None or token == '': + return None + if token in self.key_word: + return 'keyword' + elif token[0] == '"': + return 'stringConstant' + elif re.match(r"\d+", token): + return 'integerConstant' + elif token in self.symbols: + return 'symbol' + else: + return 'identifier' + + def advance(self): + token = '' + i = self.i + while i < len(self.file): + if re.match(r'\s', self.file[i]): + i = i + 1 + continue + else: + if self.file[i] in self.symbols: + self.token = self.file[i] + self.i = i + 1 + return + elif self.file[i] == '"': + i += 1 + while self.file[i] != '"': + token += self.file[i] + i += 1 + self.i = i + 1 + self.token = '"' + token + '"' + return + else: + while re.match(r'\w', self.file[i]): + token += self.file[i] + if i + 1 > len(self.file) - 1: + break + i += 1 + self.i = i + self.token = token + return + + def clear_file(self, directory): + with open(directory, "r") as my_file: + txt = my_file.read() + txt = re.sub(r"//.*", "", txt) + txt = re.sub(r"/[*][*].*[*]/", "", txt) + i = 0 + # TODO this should be a regex + while i < len(txt): + if txt[i] == '/' and txt[i + 1] == '*' and txt[i + 2] == '*': + start = i + while txt[i] != '*' or txt[i + 1] != '/': + i += 1 + stop = i + 2 + txt = txt[:start] + txt[stop:len(txt)] + i = start - 1 + i += 1 + self.file = txt diff --git a/solutions_only/project 11/vmwriter.py b/solutions_only/project 11/vmwriter.py new file mode 100755 index 0000000..5bf6929 --- /dev/null +++ b/solutions_only/project 11/vmwriter.py @@ -0,0 +1,75 @@ +class VMWriter: + def __init__(self, vm_path): + self.my_vm = open(vm_path, "w+") + self.label_index = 0 + + def write_push(self, segment, index): + self.my_vm.write(f'push {segment} {index}\n') + print(f'push {segment} {index}') + + def write_lable(self, label): + self.my_vm.write(f'label L{label}\n') + print(f'label L{label}') + + def write_arithmetic(self, command): + if command == '+': + self.my_vm.write('add\n') + print('add') + elif command == '-': + self.my_vm.write('sub\n') + print('sub') + elif command == 'neg': + self.my_vm.write('neg\n') + print('neg') + elif command == '=': + self.my_vm.write('eq\n') + print('eq') + elif command == '>': + self.my_vm.write('gt\n') + print('gt') + elif command == '<': + self.my_vm.write('lt\n') + print('lt') + elif command == '&': + self.my_vm.write('and\n') + print('and') + elif command == '|': + self.my_vm.write('or\n') + print('or') + elif command == '~': + self.my_vm.write('not\n') + print('not') + elif command == '*': + self.write_call('Math.multiply', 2) + elif command == '/': + self.write_call('Math.divide', 2) + + def write_pop(self, segment, index): + print(f'pop {segment} {index}') + self.my_vm.write(f'pop {segment} {index}\n') + + def write_goto(self, label): + self.my_vm.write(f'goto L{label}\n') + print(f'goto L{label}') + + def write_if(self, label): + self.write_arithmetic('~') + self.my_vm.write(f'if-goto L{label}\n') + print(f'if-goto L{label}') + + def write_call(self, label, num_args): + self.my_vm.write(f'call {label} {num_args}\n') + print(f'call {label} {num_args}') + + def write_function(self, label, num_locals): + self.my_vm.write(f'function {label} {num_locals}\n') + print(f'function {label} {num_locals}') + + def write_return(self, func_type): + if func_type == 'void': + self.write_push('constant', '0') + self.my_vm.write('return\n') + print(f'return') + + def close_vm_file(self): + self.my_vm.close() diff --git a/solutions_only/project 12/Array.jack b/solutions_only/project 12/Array.jack new file mode 100755 index 0000000..f16cad6 --- /dev/null +++ b/solutions_only/project 12/Array.jack @@ -0,0 +1,29 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Array.jack + +/** + * Represents an array. + * In the Jack language, arrays are instances of the Array class. + * Once declared, the array entries can be accessed using the usual + * syntax arr[i]. Each array entry can hold a primitive data type as + * well as any object type. Different array entries can have different + * data types. + */ +class Array { + + /** Constructs a new Array of the given size. */ + function Array new(int size) { + if(size < 0){ + do Sys.error(7); + } + return Memory.alloc(size); + } + + /** Disposes this array. */ + method void dispose() { + do Memory.deAlloc(this); + return; + } +} diff --git a/solutions_only/project 12/Keyboard.jack b/solutions_only/project 12/Keyboard.jack new file mode 100755 index 0000000..81e4cc6 --- /dev/null +++ b/solutions_only/project 12/Keyboard.jack @@ -0,0 +1,102 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Keyboard.jack + +/** + * A library for handling user input from the keyboard. + */ + +class Keyboard { + static Array mem; + /** Initializes the keyboard. */ + function void init() { + let mem = 0; + return; + } + + /** + * Returns the character of the currently pressed key on the keyboard; + * if no key is currently pressed, returns 0. + * + * Recognizes all ASCII characters, as well as the following keys: + * new line = 128 = String.newline() + * backspace = 129 = String.backspace() + * left arrow = 130 + * up arrow = 131 + * right arrow = 132 + * down arrow = 133 + * home = 134 + * End = 135 + * page up = 136 + * page down = 137 + * insert = 138 + * delete = 139 + * ESC = 140 + * F1 - F12 = 141 - 152 + */ + function char keyPressed() { + return mem[24576]; + } + + /** + * Waits until a key is pressed on the keyboard and released, + * then echoes the key to the screen, and returns the character + * of the pressed key. + */ + function char readChar() { + var char a, b; + do Output.printChar(0); + while ((b = 0) | (a > 0)){ + let a = Keyboard.keyPressed(); + if (a > 0){ + let b = a; + } + } + do Output.printChar(String.backSpace()); + do Output.printChar(b); + return b; + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its value. Also handles user backspaces. + */ + function String readLine(String message) { + var String s, b; + var char c; + let s = String.new(100); + do Output.printString(message); + while (true){ + let c = Keyboard.readChar(); + if (c = 128){ + return s; + } + else{ + if (c = 129){ + do s.eraseLastChar(); + } + else{ + do s.appendChar(c); + } + } + } + return s; + } + + /** + * Displays the message on the screen, reads from the keyboard the entered + * text until a newline character is detected, echoes the text to the screen, + * and returns its integer value (until the first non-digit character in the + * entered text is detected). Also handles user backspaces. + */ + function int readInt(String message) { + var starting a; + var int b; + let a = Keyboard.readLine(message); + let b = String.intValue(a); + do String.dispose(a); + return b; + } +} diff --git a/solutions_only/project 12/Main.jack b/solutions_only/project 12/Main.jack new file mode 100755 index 0000000..73331ef --- /dev/null +++ b/solutions_only/project 12/Main.jack @@ -0,0 +1,83 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/StringTest/Main.jack + +/** Test program for the OS String class. */ +class Main { + + /** Performs various string manipulations and displays their results. */ + function void main() { + var String s; + var String i; + + let s = String.new(0); // a zero-capacity string should be supported + do s.dispose(); + + let s = String.new(6); // capacity 6, make sure that length 5 is displayed + let s = s.appendChar(97); + let s = s.appendChar(98); + let s = s.appendChar(99); + let s = s.appendChar(100); + let s = s.appendChar(101); + do Output.printString("new: "); + do Output.printString(s); // new, appendChar: abcde + do Output.println(); + + let i = String.new(6); + do i.setInt(12345); + do Output.printString("setInt: "); + do Output.printString(i); // setInt: 12345 + do Output.println(); + + do i.setInt(-32767); + do Output.printString("setInt: "); + do Output.printString(i); // setInt: -32767 + do Output.println(); + + do Output.printString("length: "); + do Output.printInt(s.length()); // length: 5 + do Output.println(); + + do Output.printString("charAt[2]: "); + do Output.printInt(s.charAt(2)); // charAt[2]: 99 + do Output.println(); + + do s.setCharAt(2, 45); + do Output.printString("setCharAt(2,'-'): "); + do Output.printString(s); // setCharAt(2,'-'): ab-de + do Output.println(); + + do s.eraseLastChar(); + do Output.printString("eraseLastChar: "); + do Output.printString(s); // eraseLastChar: ab-d + do Output.println(); + + let s = "456"; + do Output.printString("intValue: "); + do Output.printInt(s.intValue()); // intValue: 456 + do Output.println(); + + let s = "-32123"; + do Output.printString("intValue: "); + do Output.printInt(s.intValue()); // intValue: -32123 + do Output.println(); + + do Output.printString("backSpace: "); + do Output.printInt(String.backSpace()); // backSpace: 129 + do Output.println(); + + do Output.printString("doubleQuote: "); + do Output.printInt(String.doubleQuote());// doubleQuote: 34 + do Output.println(); + + do Output.printString("newLine: "); + do Output.printInt(String.newLine()); // newLine: 128 + do Output.println(); + + do i.dispose(); + do s.dispose(); + + return; + } +} diff --git a/solutions_only/project 12/Math.jack b/solutions_only/project 12/Math.jack new file mode 100755 index 0000000..1730de4 --- /dev/null +++ b/solutions_only/project 12/Math.jack @@ -0,0 +1,143 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Math.jack + +/** + * A library of commonly used mathematical functions. + * Note: Jack compilers implement multiplication and division using OS method calls. + */ +class Math { + static Array st; + static int division_tmp, f; + + /** Initializes the library. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + return; + } + + /** Returns the absolute value of x. */ + function int abs(int x) { + if (x > 0){ + return x; + } + return -x; + } + + /** Returns the product of x and y. + * When a Jack compiler detects the multiplication operator '*' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x*y and multiply(x,y) return the same value. + */ + function int multiply(int x, int y) { + var int sum, temp, y_comp, i, neg; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (x < y){ + let temp = x; + let x = y; + let y = temp; + } + if (y = 1){ + if(neg){ + return -x; + } + return x; + } + while((y_comp - 1) < (y - 1)){ + if ((st[i] & y) > 0) { + let sum = sum + x; + let y_comp = y_comp + st[i]; + } + let x = x + x; + let i = i + 1; + } + if(neg){ + let sum = -sum; + } + return sum; + } + + /** Returns the integer part of x/y. + * When a Jack compiler detects the multiplication operator '/' in the + * program's code, it handles it by invoking this method. In other words, + * the Jack expressions x/y and divide(x,y) return the same value. + */ + function int divide(int x, int y) { + var int q, neg; + if (f = 0){ + let division_tmp = 0; + let neg = ((x < 0) & (y > 0)) | ((x > 0) & (y < 0)); + let x = Math.abs(x); + let y = Math.abs(y); + if (y = 0){ + do Sys.error(3); + } + let f = 1; + } + if ((y > x) | (y < 0)){ + return 0; + } + let q = Math.divide(x, y + y); + let f = 0; + let q = Math.abs(q); + if ((q & 1) = 1){ + let division_tmp = division_tmp + y + y; + } + if (x - division_tmp < y){ + if (neg){ + return -(q + q); + } + return q + q; + } + else{ + if (neg){ + return -(q + q + 1); + } + return q + q + 1; + } + } + + /** Returns the integer part of the square root of x. */ + function int sqrt(int x) { + var int j, b, d, y; + + if (x < 0){ + do Sys.error(4); + } + let j = 7; + while (j > -1){ + let d = y + st[j]; + let b = d * d; + if ((~(b > x)) & (b > 0)){ + let y = d; + } + let j = j - 1; + } + return y; + } + + /** Returns the greater number. */ + function int max(int a, int b) { + if (a > b){ + return a; + } + return b; + } + + /** Returns the smaller number. */ + function int min(int a, int b) { + if (a < b){ + return a; + } + return b; + } +} diff --git a/solutions_only/project 12/Memory.jack b/solutions_only/project 12/Memory.jack new file mode 100755 index 0000000..14305f1 --- /dev/null +++ b/solutions_only/project 12/Memory.jack @@ -0,0 +1,63 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Memory.jack + +/** + * This library provides two services: direct access to the computer's main + * memory (RAM), and allocation and recycling of memory blocks. The Hack RAM + * consists of 32,768 words, each holding a 16-bit binary number. + */ +class Memory { + static Array mem; + /** Initializes the class. */ + function void init() { + let mem = 0; + let mem[2048] = 14334; + let mem[2049] = -1; + return; + } + + /** Returns the RAM value at the given address. */ + function int peek(int address) { + return mem[address]; + } + + /** Sets the RAM value at the given address to the given value. */ + function void poke(int address, int value) { + let mem[address] = value; + return; + } + + /** Finds an available RAM block of the given size and returns + * a reference to its base address. */ + function int alloc(int size) { + var Array current_block; + var int tmp; + let current_block = 2048; + if (size < 0){ + do Sys.error(5); + } + if (size = 0){ + let size = 1; + } + while (current_block[0] < (size + 2)) { + let current_block = current_block[1]; + } + let current_block[0] = current_block[0] - size - 2; + let current_block = current_block + current_block[0] + 2; + let current_block[0] = size; + return current_block + 2; + } + + /** De-allocates the given object (cast as an array) by making + * it available for future allocations. */ + function void deAlloc(Array o) { + var Array current_block; + let current_block = 2048; + let o[1]= current_block[1]; + let current_block[1] = o; + return; + + } +} diff --git a/solutions_only/project 12/Output.jack b/solutions_only/project 12/Output.jack new file mode 100755 index 0000000..9132280 --- /dev/null +++ b/solutions_only/project 12/Output.jack @@ -0,0 +1,299 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Output.jack + +/** + * A library of functions for writing text on the screen. + * The Hack physical screen consists of 512 rows of 256 pixels each. + * The library uses a fixed font, in which each character is displayed + * within a frame which is 11 pixels high (including 1 pixel for inter-line + * spacing) and 8 pixels wide (including 2 pixels for inter-character spacing). + * The resulting grid accommodates 23 rows (indexed 0..22, top to bottom) + * of 64 characters each (indexed 0..63, left to right). The top left + * character position on the screen is indexed (0,0). A cursor, implemented + * as a small filled square, indicates where the next character will be displayed. + */ +class Output { + + // Character map for displaying characters + static Array charMaps; + static int address; + static bool half; + + /** Initializes the screen, and locates the cursor at the screen's top-left. */ + function void init() { + do Output.initMap(); + do Output.moveCursor(0, 0); + return; + } + + // Initializes the character map array + function void initMap() { + var int i; + + let charMaps = Array.new(127); + + // Black square, used for displaying non-printable characters. + do Output.create(0,63,63,63,63,63,63,63,63,63,0,0); + + // Assigns the bitmap for each character in the charachter set. + // The first parameter is the character index, the next 11 numbers + // are the values of each row in the frame that represents this character. + do Output.create(32,0,0,0,0,0,0,0,0,0,0,0); // + do Output.create(33,12,30,30,30,12,12,0,12,12,0,0); // ! + do Output.create(34,54,54,20,0,0,0,0,0,0,0,0); // " + do Output.create(35,0,18,18,63,18,18,63,18,18,0,0); // # + do Output.create(36,12,30,51,3,30,48,51,30,12,12,0); // $ + do Output.create(37,0,0,35,51,24,12,6,51,49,0,0); // % + do Output.create(38,12,30,30,12,54,27,27,27,54,0,0); // & + do Output.create(39,12,12,6,0,0,0,0,0,0,0,0); // ' + do Output.create(40,24,12,6,6,6,6,6,12,24,0,0); // ( + do Output.create(41,6,12,24,24,24,24,24,12,6,0,0); // ) + do Output.create(42,0,0,0,51,30,63,30,51,0,0,0); // * + do Output.create(43,0,0,0,12,12,63,12,12,0,0,0); // + + do Output.create(44,0,0,0,0,0,0,0,12,12,6,0); // , + do Output.create(45,0,0,0,0,0,63,0,0,0,0,0); // - + do Output.create(46,0,0,0,0,0,0,0,12,12,0,0); // . + do Output.create(47,0,0,32,48,24,12,6,3,1,0,0); // / + + do Output.create(48,12,30,51,51,51,51,51,30,12,0,0); // 0 + do Output.create(49,12,14,15,12,12,12,12,12,63,0,0); // 1 + do Output.create(50,30,51,48,24,12,6,3,51,63,0,0); // 2 + do Output.create(51,30,51,48,48,28,48,48,51,30,0,0); // 3 + do Output.create(52,16,24,28,26,25,63,24,24,60,0,0); // 4 + do Output.create(53,63,3,3,31,48,48,48,51,30,0,0); // 5 + do Output.create(54,28,6,3,3,31,51,51,51,30,0,0); // 6 + do Output.create(55,63,49,48,48,24,12,12,12,12,0,0); // 7 + do Output.create(56,30,51,51,51,30,51,51,51,30,0,0); // 8 + do Output.create(57,30,51,51,51,62,48,48,24,14,0,0); // 9 + + do Output.create(58,0,0,12,12,0,0,12,12,0,0,0); // : + do Output.create(59,0,0,12,12,0,0,12,12,6,0,0); // ; + do Output.create(60,0,0,24,12,6,3,6,12,24,0,0); // < + do Output.create(61,0,0,0,63,0,0,63,0,0,0,0); // = + do Output.create(62,0,0,3,6,12,24,12,6,3,0,0); // > + do Output.create(64,30,51,51,59,59,59,27,3,30,0,0); // @ + do Output.create(63,30,51,51,24,12,12,0,12,12,0,0); // ? + + do Output.create(65,12,30,51,51,63,51,51,51,51,0,0); // A ** TO BE FILLED ** + do Output.create(66,31,51,51,51,31,51,51,51,31,0,0); // B + do Output.create(67,28,54,35,3,3,3,35,54,28,0,0); // C + do Output.create(68,15,27,51,51,51,51,51,27,15,0,0); // D + do Output.create(69,63,51,35,11,15,11,35,51,63,0,0); // E + do Output.create(70,63,51,35,11,15,11,3,3,3,0,0); // F + do Output.create(71,28,54,35,3,59,51,51,54,44,0,0); // G + do Output.create(72,51,51,51,51,63,51,51,51,51,0,0); // H + do Output.create(73,30,12,12,12,12,12,12,12,30,0,0); // I + do Output.create(74,60,24,24,24,24,24,27,27,14,0,0); // J + do Output.create(75,51,51,51,27,15,27,51,51,51,0,0); // K + do Output.create(76,3,3,3,3,3,3,35,51,63,0,0); // L + do Output.create(77,33,51,63,63,51,51,51,51,51,0,0); // M + do Output.create(78,51,51,55,55,63,59,59,51,51,0,0); // N + do Output.create(79,30,51,51,51,51,51,51,51,30,0,0); // O + do Output.create(80,31,51,51,51,31,3,3,3,3,0,0); // P + do Output.create(81,30,51,51,51,51,51,63,59,30,48,0);// Q + do Output.create(82,31,51,51,51,31,27,51,51,51,0,0); // R + do Output.create(83,30,51,51,6,28,48,51,51,30,0,0); // S + do Output.create(84,63,63,45,12,12,12,12,12,30,0,0); // T + do Output.create(85,51,51,51,51,51,51,51,51,30,0,0); // U + do Output.create(86,51,51,51,51,51,30,30,12,12,0,0); // V + do Output.create(87,51,51,51,51,51,63,63,63,18,0,0); // W + do Output.create(88,51,51,30,30,12,30,30,51,51,0,0); // X + do Output.create(89,51,51,51,51,30,12,12,12,30,0,0); // Y + do Output.create(90,63,51,49,24,12,6,35,51,63,0,0); // Z + + do Output.create(91,30,6,6,6,6,6,6,6,30,0,0); // [ + do Output.create(92,0,0,1,3,6,12,24,48,32,0,0); // \ + do Output.create(93,30,24,24,24,24,24,24,24,30,0,0); // ] + do Output.create(94,8,28,54,0,0,0,0,0,0,0,0); // ^ + do Output.create(95,0,0,0,0,0,0,0,0,0,63,0); // _ + do Output.create(96,6,12,24,0,0,0,0,0,0,0,0); // ` + + do Output.create(97,0,0,0,14,24,30,27,27,54,0,0); // a + do Output.create(98,3,3,3,15,27,51,51,51,30,0,0); // b + do Output.create(99,0,0,0,30,51,3,3,51,30,0,0); // c + do Output.create(100,48,48,48,60,54,51,51,51,30,0,0); // d + do Output.create(101,0,0,0,30,51,63,3,51,30,0,0); // e + do Output.create(102,28,54,38,6,15,6,6,6,15,0,0); // f + do Output.create(103,0,0,30,51,51,51,62,48,51,30,0); // g + do Output.create(104,3,3,3,27,55,51,51,51,51,0,0); // h + do Output.create(105,12,12,0,14,12,12,12,12,30,0,0); // i + do Output.create(106,48,48,0,56,48,48,48,48,51,30,0); // j + do Output.create(107,3,3,3,51,27,15,15,27,51,0,0); // k + do Output.create(108,14,12,12,12,12,12,12,12,30,0,0); // l + do Output.create(109,0,0,0,29,63,43,43,43,43,0,0); // m + do Output.create(110,0,0,0,29,51,51,51,51,51,0,0); // n + do Output.create(111,0,0,0,30,51,51,51,51,30,0,0); // o + do Output.create(112,0,0,0,30,51,51,51,31,3,3,0); // p + do Output.create(113,0,0,0,30,51,51,51,62,48,48,0); // q + do Output.create(114,0,0,0,29,55,51,3,3,7,0,0); // r + do Output.create(115,0,0,0,30,51,6,24,51,30,0,0); // s + do Output.create(116,4,6,6,15,6,6,6,54,28,0,0); // t + do Output.create(117,0,0,0,27,27,27,27,27,54,0,0); // u + do Output.create(118,0,0,0,51,51,51,51,30,12,0,0); // v + do Output.create(119,0,0,0,51,51,51,63,63,18,0,0); // w + do Output.create(120,0,0,0,51,30,12,12,30,51,0,0); // x + do Output.create(121,0,0,0,51,51,51,62,48,24,15,0); // y + do Output.create(122,0,0,0,63,27,12,6,51,63,0,0); // z + + do Output.create(123,56,12,12,12,7,12,12,12,56,0,0); // { + do Output.create(124,12,12,12,12,12,12,12,12,12,0,0); // | + do Output.create(125,7,12,12,12,56,12,12,12,7,0,0); // } + do Output.create(126,38,45,25,0,0,0,0,0,0,0,0); // ~ + + return; + } + + // Creates the character map array of the given character index, using the given values. + function void create(int index, int a, int b, int c, int d, int e, + int f, int g, int h, int i, int j, int k) { + var Array map; + + let map = Array.new(11); + let charMaps[index] = map; + + let map[0] = a; + let map[1] = b; + let map[2] = c; + let map[3] = d; + let map[4] = e; + let map[5] = f; + let map[6] = g; + let map[7] = h; + let map[8] = i; + let map[9] = j; + let map[10] = k; + + return; + } + + // Returns the character map (array of size 11) of the given character. + // If the given character is invalid or non-printable, returns the + // character map of a black square. + function Array getMap(char c) { + if ((c < 32) | (c > 126)) { + let c = 0; + } + return charMaps[c]; + } + + /** Moves the cursor to the j-th column of the i-th row, + * and erases the character displayed there. */ + function void moveCursor(int i, int j) { + var int co,display; + var Array r,ch; + if (j = 0){ + let half = true; + } + else{ + let half = (j / 2) * 2 = j; // chetno true, 1vaa chast + } + let address = (352 * i) + (j / 2) + 16384; + let ch = Output.getMap(32); + + while (co < 11){ + if (half){ + let display = r[address] & (-256); + let r[address] = ch[co] | display; + } + else{ + let display = r[address] & 255; + let r[address] = (ch[co]*256) | display; + } + let co = co + 1; + let address = address + 32; + } + let address = address - 352; + return; + } + + /** Displays the given character at the cursor location, + * and advances the cursor one column forward. */ + function void printChar(char c) { + var Array ch; + var Array r; + var int co; + var int ds; + let ch = Output.getMap(c); + while (co < 11){ + if (half){ + let ds = r[address] & (-256); + let r[address] = ch[co] | ds; + } + else{ + let ds = r[address] & 255; + let r[address] = (ch[co]*256) | ds; + } + let co = co + 1; + let address = address + 32; + } + + if (half){ + let address = address - 352; + let half = false; + } + else{ + if (address > 24480){ + let address = 16384; + let half = true; + } + else{ + let address = address - 351; + let half = true; + } + } + return; + } + + /** displays the given string starting at the cursor location, + * and advances the cursor appropriately. */ + function void printString(String s) { + var int i, length; + let length = s.length(); + while (i < length){ + do Output.printChar(s.charAt(i)); + let i = i + 1; + } + return; + } + + /** Displays the given integer starting at the cursor location, + * and advances the cursor appropriately. */ + function void printInt(int i) { + var String s; + let s = String.new(6); + do s.setInt(i); + do Output.printString(s); + return; + } + + /** Advances the cursor to the beginning of the next line. */ + function void println() { + var int row; + let row = (((address - 16384) / 32)/11) + 1; + if (row > 32){ + let row = 0; + } + do Output.moveCursor(row, 0); + return; + } + + /** Moves the cursor one column back. */ + function void backSpace() { + if (address = 16384){ + let address = 24191; + let half = true; + return; + } + if (half){ + + let address = address - 1; + let half = false; + } + else{ + let half = true; + } + return; + } +} diff --git a/solutions_only/project 12/Screen.jack b/solutions_only/project 12/Screen.jack new file mode 100755 index 0000000..006a905 --- /dev/null +++ b/solutions_only/project 12/Screen.jack @@ -0,0 +1,206 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Screen.jack + +/** + * A library of functions for displaying graphics on the screen. + * The Hack physical screen consists of 256 rows (indexed 0..255, top to bottom) + * of 512 pixels each (indexed 0..511, left to right). The top left pixel on + * the screen is indexed (0,0). + */ +class Screen { + + static Array mem; + static Array st; + static boolean color; + /** Initializes the Screen. */ + function void init() { + var int a; + let st = Array.new(16); + let st[0] = 1; + while (a < 15){ + let a = a + 1; + let st[a] = st[a - 1] + st[a - 1]; + } + let color = true; + return; + } + + /** Erases the entire screen. */ + function void clearScreen() { + var int a; + let a = 16384; + while (a < 24575){ + let mem[a] = 0; + let a = a + 1; + } + return; + } + + /** Sets the current color, to be used for all subsequent drawXXX commands. + * Black is represented by true, white by false. */ + function void setColor(boolean b) { + let color = b; + return; + } + + /** Draws the (x,y) pixel, using the current color. */ + function void drawPixel(int x, int y) { + var int value, address, bit, mem_block; + if ((x > 511) | (x < 0) | (y > 255) | (y < 0)){ + do Sys.error(7); + } + let mem_block = x / 16; + let address = (32 * y) + mem_block + 16384; + let value = mem[address]; + let bit = x - (mem_block * 16); + if (color){ + let mem[address] = st[bit] | value; + } + else{ + let mem[address] = (~st[bit])& value; + } + return; + } + + /** Draws a line from pixel (x1,y1) to pixel (x2,y2), using the current color. */ + function void drawLine(int x1, int y1, int x2, int y2) { + var int diff, dx, dy, a, b; + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let dx = x2 - x1; + let dy = y2 - y1; + if (dx = 0){ + if (dy > 0){ + while(~(b > dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b + 1; + } + return; + } + else{ + while(~(b < dy)){ + do Screen.drawPixel(x1, y1 + b); + let b = b - 1; + } + return; + } + } + if (dy = 0){ + if (dx > 0){ + while(~(a > dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a + 1; + } + return; + } + else{ + while(~(a < dx)){ + do Screen.drawPixel(x1 + a, y1); + let a = a - 1; + } + return; + } + } + if (dx < 0){ + if (dy < 0){ + while ((~(a < dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff + dx; + } + } + } + else{ + while ((~(a < dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a - 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff + dx; + } + } + } + } + else{ + if (dy < 0){ + while ((~(a > dx)) & (~(b < dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff - dy; + } + else{ + let b = b - 1; + let diff = diff - dx; + } + } + } + else{ + while ((~(a > dx)) & (~(b > dy))){ + do Screen.drawPixel(x1 + a, y1 + b); + if (diff < 0){ + let a = a + 1; + let diff = diff + dy; + } + else{ + let b = b + 1; + let diff = diff - dx; + } + } + } + } + + return; + } + + /** Draws a filled rectangle whose top left corner is (x1, y1) + * and bottom right corner is (x2,y2), using the current color. */ + function void drawRectangle(int x1, int y1, int x2, int y2) { + var int a, tmp; + if (x1 > x2){ + let tmp = x1; + let x1 = x2; + let x2 = tmp; + } + if (y1 > y2){ + let tmp = y1; + let y1 = y2; + let y2 = tmp; + } + if((x1 < 0) | (x2 > 511) | (y1 < 0) | (y2 > 255)){ + do Sys.error(8); + } + let tmp = y2 - y1; + while(a < tmp){ + do Screen.drawLine(x1, y1 + a, x2, y1 + a); + let a = a + 1; + } + return; + } + + /** Draws a filled circle of radius r<=181 around (x,y), using the current color. */ + function void drawCircle(int x, int y, int r) { + var int dy, dx, tmp; + if(r > 181){ + do Sys.error(7); + } + let dy = - r; + while (dy < r){ + let tmp = Math.sqrt((r * r) - (dy * dy)); + do Screen.drawLine(x - tmp, y + dy, x + tmp, y + dy); + let dy = dy + 1; + } + return; + } +} diff --git a/solutions_only/project 12/String.jack b/solutions_only/project 12/String.jack new file mode 100755 index 0000000..4d936cb --- /dev/null +++ b/solutions_only/project 12/String.jack @@ -0,0 +1,154 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/String.jack + +/** + * Represents character strings. In addition for constructing and disposing + * strings, the class features methods for getting and setting individual + * characters of the string, for erasing the string's last character, + * for appending a character to the string's end, and more typical + * string-oriented operations. + */ +class String { + field Array str; + field int length; + field int strLength; + + /** constructs a new empty string with a mavalimum length of mavalLength + * and initial length of 0. */ + constructor String new(int mavalLength) { + if (mavalLength > 0){ + let str = Array.new(mavalLength); + } + let strLength = mavalLength; + let length = 0; + return this; + } + + /** Disposes this string. */ + method void dispose() { + if(length > 0){ + do str.dispose(); + } + do Memory.deAlloc(this); + return; + } + + /** Returns the current length of this string. */ + method int length() { + return length; + } + + /** Returns the character at the j-th location of this string. */ + method char charAt(int j) { + if(j > length){ + do Sys.error(7); + } + return str[j]; + } + + /** Sets the character at the j-th location of this string to c. */ + method void setCharAt(int j, char c) { + if(j > length){ + do Sys.error(7); + } + let str[j] = c; + return; + } + + /** Appends c to this string's end and returns this string. */ + method String appendChar(char c) { + if(strLength = length){ + do Sys.error(7); + } + let str[length] = c; + let length = length + 1; + return this; + } + + /** Erases the last character from this string. */ + method void eraseLastChar() { + if (length = 0){ + do Sys.error(7); + } + let str[length] = 0; + let length = length - 1; + return; + } + + /** Returns the integer value of this string, + * until a non-digit character is detected. */ + method int intValue() { + var int d, sum, i; + var bool f; + while(i < length){ + let d = str[i]; + if ((d > 47) & (d < 58)){ + let sum = (sum * 10) + (d - 48); + } + else{ + if((i = 0) & (d = 45)){ + let f = true; + } + else{ + let i = length; + } + } + let i = i + 1; + } + if (f){ + return -sum; + } + return sum; + } + + /** Sets this string to hold a representation of the given value. */ + method void setInt(int val) { + var Array c; + var int d, b, a; + let c = Array.new(6); + if (val < 0){ + let d = ~0; + let val = -val; + } + let b = val; + while(b > 0){ + let b = val / 10; + let c[a] = 48 + val - (b * 10); + let a = a + 1; + let val = b; + } + if (d){ + let c[a] = 45; + let a = a + 1; + } + if (a = 0){ + let str[0] = 48; + let length = 1; + } + else{ + let length = 0; + while (length < a){ + let str[length] = c[a - 1 - length]; + let length = length + 1; + } + } + do Array.dispose(c); + return; + } + /** Returns the new line character. */ + function char newLine() { + return 128; + } + + /** Returns the backspace character. */ + function char backSpace() { + return 129; + } + + /** Returns the double quote (") character. */ + function char doubleQuote() { + return 34; + } +} diff --git a/solutions_only/project 12/Sys.jack b/solutions_only/project 12/Sys.jack new file mode 100755 index 0000000..0eed65b --- /dev/null +++ b/solutions_only/project 12/Sys.jack @@ -0,0 +1,53 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/12/Sys.jack + +/** + * A library that supports various program execution services. + */ +class Sys { + + /** Performs all the initializations required by the OS. */ + function void init() { + do Memory.init(); + do Math.init(); + do Output.init(); + do Screen.init(); + do Keyboard.init(); + do Main.main(); + do Sys.halt(); + return; + } + + /** Halts the program execution. */ + function void halt() { + while(true){ + } + return; + } + + /** Waits approximately duration milliseconds and returns. */ + function void wait(int duration) { + var int i; + while (duration > 0){ + let i = 100; + while(i > 0){ + let i = i -1; + } + let duration = duration - 1; + } + return; + } + + /** Displays the given error code in the form "ERR", + * and halts the program's execution. */ + function void error(int errorCode) { + var String s; + let s = String.new(3); + do s.setInt(errorCode); + do Output.printString("ERR"); + do Output.printString(s); + return; + } +} diff --git a/tools/Assembler.bat b/tools/Assembler.bat new file mode 100755 index 0000000..93260ec --- /dev/null +++ b/tools/Assembler.bat @@ -0,0 +1,27 @@ +@echo off + +rem $Id: Assembler.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo Assembler Starts the assembler in interactive mode. + echo Assembler FILE[.asm] Assembles FILE.asm to FILE.hack. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Compilers.jar;bin/lib/AssemblerGUI.jar;bin/lib/TranslatorsGUI.jar" ^ + HackAssemblerMain +) else ( + echo Assembling "%_arg1%" + java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Compilers.jar;bin/lib/AssemblerGUI.jar;bin/lib/TranslatorsGUI.jar" ^ + HackAssemblerMain "%_arg1%" +) +popd diff --git a/tools/Assembler.sh b/tools/Assembler.sh new file mode 100755 index 0000000..70db569 --- /dev/null +++ b/tools/Assembler.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +# $Id: Assembler.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the assembler in interactive mode." + echo " `basename "$0"` FILE[.asm] Assembles FILE.asm to FILE.hack." +elif [ $# -eq 0 ] +then + # Run assembler in interactive mode + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Compilers.jar:bin/lib/AssemblerGUI.jar:bin/lib/TranslatorsGUI.jar" HackAssemblerMain & +else + # Convert arg1 to an absolute path and run assembler with arg1. + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi + echo Assembling "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Compilers.jar:bin/lib/AssemblerGUI.jar:bin/lib/TranslatorsGUI.jar" HackAssemblerMain "$arg1" +fi + diff --git a/tools/CPUEmulator.bat b/tools/CPUEmulator.bat new file mode 100755 index 0000000..f92cf40 --- /dev/null +++ b/tools/CPUEmulator.bat @@ -0,0 +1,29 @@ +@echo off + +rem $Id: CPUEmulator.bat,v 1.3 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo CPUEmulator Starts the CPU Emulator in interactive mode. + echo CPUEmulator FILE.tst Starts the CPU Emulator and runs the FILE.tst + echo test script. The success/failure message + echo is printed to the command console. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + CPUEmulatorMain +) else ( +rem echo Running "%_arg1%" + java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + CPUEmulatorMain "%_arg1%" +) +popd diff --git a/tools/CPUEmulator.sh b/tools/CPUEmulator.sh new file mode 100755 index 0000000..033d9d7 --- /dev/null +++ b/tools/CPUEmulator.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +# $Id: CPUEmulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the CPU Emulator in interactive mode." + echo " `basename "$0"` FILE.tst Starts the CPU Emulator and runs the File.tst" + echo " test script. The success/failure message" + echo " is printed to the command console." +elif [ $# -eq 0 ] +then + # Run CPU emulator in interactive mode + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" CPUEmulatorMain & +else + # Convert arg1 to an absolute path and run CPU emulator with arg1 + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi +# echo Running "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" CPUEmulatorMain "$arg1" +fi diff --git a/tools/HardwareSimulator.bat b/tools/HardwareSimulator.bat new file mode 100755 index 0000000..76baa31 --- /dev/null +++ b/tools/HardwareSimulator.bat @@ -0,0 +1,30 @@ +@echo off + +rem $Id: HardwareSimulator.bat,v 1.3 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo HardwareSimulator Starts the Hardware Simulator in + echo interactive mode. + echo HardwareSimulator FILE.tst Starts the Hardware Simulator and runs the + echo FILE.tst test script. The success/failure + echo message is printed to the command console. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + HardwareSimulatorMain +) else ( +rem echo Running "%_arg1%" + java -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + HardwareSimulatorMain "%_arg1%" +) +popd diff --git a/tools/HardwareSimulator.sh b/tools/HardwareSimulator.sh new file mode 100755 index 0000000..47e7482 --- /dev/null +++ b/tools/HardwareSimulator.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh + +# $Id: HardwareSimulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the Hardware Simulator in" + echo " interactive mode." + echo " `basename "$0"` FILE.tst Starts the Hardware Simulator and runs the" + echo " FILE.tst test script. The success/failure" + echo " message is printed to the command console." +elif [ $# -eq 0 ] +then + # Run hardware simulator in interactive mode + java -classpath "${CLASSPATH}:bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" HardwareSimulatorMain & +else + # Convert arg1 to an absolute path and run hardware simulator with arg1 + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi +# echo Running "$arg1" + java -classpath "${CLASSPATH}:bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" HardwareSimulatorMain "$arg1" +fi diff --git a/tools/JackCompiler.bat b/tools/JackCompiler.bat new file mode 100755 index 0000000..9399b94 --- /dev/null +++ b/tools/JackCompiler.bat @@ -0,0 +1,26 @@ +@echo off + +rem $Id: JackCompiler.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo JackCompiler Compiles all .jack files in the current + echo working directory. + echo JackCompiler DIRECTORY Compiles all .jack files in DIRECTORY. + echo JackCompiler FILE.jack Compiles FILE.jack to FILE.vm. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) else ( + set "_arg1=%CD%" +) +pushd "%~dp0" +echo Compiling "%_arg1%" +java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/Compilers.jar" ^ + Hack.Compiler.JackCompiler "%_arg1%" +popd diff --git a/tools/JackCompiler.sh b/tools/JackCompiler.sh new file mode 100755 index 0000000..699dfb8 --- /dev/null +++ b/tools/JackCompiler.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh + +# $Id: JackCompiler.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Compiles all .jack files in the current" + echo " working directory." + echo " `basename "$0"` DIRECTORY Compiles all .jack files in DIRECTORY." + echo " `basename "$0"` FILE.jack Compiles FILE.jack to FILE.vm." +else + if [ $# -eq 0 ] + then + # Use current directory as arg1 + arg1="$dir" + else + # Convert arg1 to an absolute path + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="$dir/$1" + fi + fi + echo Compiling "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/Compilers.jar" Hack.Compiler.JackCompiler "$arg1" +fi diff --git a/tools/OS/Array.vm b/tools/OS/Array.vm new file mode 100755 index 0000000..aa4c9e8 --- /dev/null +++ b/tools/OS/Array.vm @@ -0,0 +1,23 @@ +function Array.new 0 +push argument 0 +push constant 0 +gt +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 2 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +call Memory.alloc 1 +return +function Array.dispose 0 +push argument 0 +pop pointer 0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return diff --git a/tools/OS/Keyboard.vm b/tools/OS/Keyboard.vm new file mode 100755 index 0000000..a806c4e --- /dev/null +++ b/tools/OS/Keyboard.vm @@ -0,0 +1,102 @@ +function Keyboard.init 0 +push constant 0 +return +function Keyboard.keyPressed 0 +push constant 24576 +call Memory.peek 1 +return +function Keyboard.readChar 2 +push constant 0 +call Output.printChar 1 +pop temp 0 +label WHILE_EXP0 +push local 1 +push constant 0 +eq +push local 0 +push constant 0 +gt +or +not +if-goto WHILE_END0 +call Keyboard.keyPressed 0 +pop local 0 +push local 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +pop local 1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +call String.backSpace 0 +call Output.printChar 1 +pop temp 0 +push local 1 +call Output.printChar 1 +pop temp 0 +push local 1 +return +function Keyboard.readLine 5 +push constant 80 +call String.new 1 +pop local 3 +push argument 0 +call Output.printString 1 +pop temp 0 +call String.newLine 0 +pop local 1 +call String.backSpace 0 +pop local 2 +label WHILE_EXP0 +push local 4 +not +not +if-goto WHILE_END0 +call Keyboard.readChar 0 +pop local 0 +push local 0 +push local 1 +eq +pop local 4 +push local 4 +not +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push local 2 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 3 +call String.eraseLastChar 1 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 3 +push local 0 +call String.appendChar 2 +pop local 3 +label IF_END1 +label IF_FALSE0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +return +function Keyboard.readInt 2 +push argument 0 +call Keyboard.readLine 1 +pop local 0 +push local 0 +call String.intValue 1 +pop local 1 +push local 0 +call String.dispose 1 +pop temp 0 +push local 1 +return diff --git a/tools/OS/Math.vm b/tools/OS/Math.vm new file mode 100755 index 0000000..b660688 --- /dev/null +++ b/tools/OS/Math.vm @@ -0,0 +1,408 @@ +function Math.init 1 +push constant 16 +call Array.new 1 +pop static 1 +push constant 16 +call Array.new 1 +pop static 0 +push constant 0 +push static 0 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 0 +add +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Math.abs 0 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +neg +pop argument 0 +label IF_FALSE0 +push argument 0 +return +function Math.multiply 5 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 4 +push argument 0 +call Math.abs 1 +pop argument 0 +push argument 1 +call Math.abs 1 +pop argument 1 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop local 1 +push argument 1 +pop argument 0 +push local 1 +pop argument 1 +label IF_FALSE0 +label WHILE_EXP0 +push local 2 +push constant 1 +sub +push argument 1 +push constant 1 +sub +lt +not +if-goto WHILE_END0 +push local 3 +push static 0 +add +pop pointer 1 +push that 0 +push argument 1 +and +push constant 0 +eq +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push argument 0 +add +pop local 0 +push local 2 +push local 3 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 2 +label IF_FALSE1 +push argument 0 +push argument 0 +add +pop argument 0 +push local 3 +push constant 1 +add +pop local 3 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +neg +pop local 0 +label IF_FALSE2 +push local 0 +return +function Math.divide 4 +push argument 1 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 3 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +lt +push argument 1 +push constant 0 +gt +and +push argument 0 +push constant 0 +gt +push argument 1 +push constant 0 +lt +and +or +pop local 2 +push constant 0 +push static 1 +add +push argument 1 +call Math.abs 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push argument 0 +call Math.abs 1 +pop argument 0 +label WHILE_EXP0 +push local 0 +push constant 15 +lt +push local 3 +not +and +not +if-goto WHILE_END0 +push constant 32767 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +sub +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +lt +pop local 3 +push local 3 +not +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push constant 1 +add +push static 1 +add +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +push argument 0 +push constant 1 +sub +gt +pop local 3 +push local 3 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +label IF_FALSE1 +goto WHILE_EXP0 +label WHILE_END0 +label WHILE_EXP1 +push local 0 +push constant 1 +neg +gt +not +if-goto WHILE_END1 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +push constant 1 +sub +push argument 0 +push constant 1 +sub +gt +not +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 1 +push local 0 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 1 +push argument 0 +push local 0 +push static 1 +add +pop pointer 1 +push that 0 +sub +pop argument 0 +label IF_FALSE3 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 2 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 1 +neg +pop local 1 +label IF_FALSE4 +push local 1 +return +function Math.sqrt 4 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 4 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push constant 7 +pop local 0 +label WHILE_EXP0 +push local 0 +push constant 1 +neg +gt +not +if-goto WHILE_END0 +push local 3 +push local 0 +push static 0 +add +pop pointer 1 +push that 0 +add +pop local 1 +push local 1 +push local 1 +call Math.multiply 2 +pop local 2 +push local 2 +push argument 0 +gt +not +push local 2 +push constant 0 +lt +not +and +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 1 +pop local 3 +label IF_FALSE1 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +return +function Math.max 0 +push argument 0 +push argument 1 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop argument 1 +label IF_FALSE0 +push argument 1 +return +function Math.min 0 +push argument 0 +push argument 1 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +pop argument 1 +label IF_FALSE0 +push argument 1 +return diff --git a/tools/OS/Memory.vm b/tools/OS/Memory.vm new file mode 100755 index 0000000..8c74b87 --- /dev/null +++ b/tools/OS/Memory.vm @@ -0,0 +1,376 @@ +function Memory.init 0 +push constant 0 +pop static 0 +push constant 2048 +push static 0 +add +push constant 14334 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2049 +push static 0 +add +push constant 2050 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Memory.peek 0 +push argument 0 +push static 0 +add +pop pointer 1 +push that 0 +return +function Memory.poke 0 +push argument 0 +push static 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Memory.alloc 2 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 5 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 1 +pop argument 0 +label IF_FALSE1 +push constant 2048 +pop local 0 +label WHILE_EXP0 +push local 0 +push constant 16383 +lt +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +lt +and +not +if-goto WHILE_END0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop local 1 +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push constant 0 +eq +push local 1 +push constant 16382 +gt +or +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +push constant 0 +eq +or +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 1 +pop local 0 +goto IF_END2 +label IF_FALSE2 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +push local 1 +push constant 2 +add +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 1 +push local 0 +add +push local 0 +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END3 +label IF_FALSE3 +push constant 1 +push local 0 +add +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END3 +label IF_END2 +goto WHILE_EXP0 +label WHILE_END0 +push local 0 +push argument 0 +add +push constant 16379 +gt +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 6 +call Sys.error 1 +pop temp 0 +label IF_FALSE4 +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +push constant 2 +add +gt +if-goto IF_TRUE5 +goto IF_FALSE5 +label IF_TRUE5 +push argument 0 +push constant 2 +add +push local 0 +add +push constant 0 +push local 0 +add +pop pointer 1 +push that 0 +push argument 0 +sub +push constant 2 +sub +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 2 +add +eq +if-goto IF_TRUE6 +goto IF_FALSE6 +label IF_TRUE6 +push argument 0 +push constant 3 +add +push local 0 +add +push local 0 +push argument 0 +add +push constant 4 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END6 +label IF_FALSE6 +push argument 0 +push constant 3 +add +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END6 +push constant 1 +push local 0 +add +push local 0 +push argument 0 +add +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_FALSE5 +push constant 0 +push local 0 +add +push constant 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 2 +add +return +function Memory.deAlloc 2 +push argument 0 +push constant 2 +sub +pop local 0 +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +pop local 1 +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 2 +sub +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END0 +label IF_FALSE0 +push constant 0 +push local 0 +add +push constant 1 +push local 0 +add +pop pointer 1 +push that 0 +push local 0 +sub +push constant 0 +push local 1 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +push local 1 +push constant 2 +add +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 1 +push local 0 +add +push local 0 +push constant 2 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END1 +label IF_FALSE1 +push constant 1 +push local 0 +add +push constant 1 +push local 1 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END1 +label IF_END0 +push constant 0 +return diff --git a/tools/OS/Output.vm b/tools/OS/Output.vm new file mode 100755 index 0000000..b8addd7 --- /dev/null +++ b/tools/OS/Output.vm @@ -0,0 +1,1852 @@ +function Output.init 0 +push constant 16384 +pop static 4 +push constant 0 +not +pop static 2 +push constant 32 +pop static 1 +push constant 0 +pop static 0 +push constant 6 +call String.new 1 +pop static 3 +call Output.initMap 0 +pop temp 0 +call Output.createShiftedMap 0 +pop temp 0 +push constant 0 +return +function Output.initMap 0 +push constant 127 +call Array.new 1 +pop static 5 +push constant 0 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 32 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 33 +push constant 12 +push constant 30 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 34 +push constant 54 +push constant 54 +push constant 20 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 35 +push constant 0 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 63 +push constant 18 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 36 +push constant 12 +push constant 30 +push constant 51 +push constant 3 +push constant 30 +push constant 48 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 37 +push constant 0 +push constant 0 +push constant 35 +push constant 51 +push constant 24 +push constant 12 +push constant 6 +push constant 51 +push constant 49 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 38 +push constant 12 +push constant 30 +push constant 30 +push constant 12 +push constant 54 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 39 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 40 +push constant 24 +push constant 12 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 41 +push constant 6 +push constant 12 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 42 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 63 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 43 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 63 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 44 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 45 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 46 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 47 +push constant 0 +push constant 0 +push constant 32 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 1 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 48 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 49 +push constant 12 +push constant 14 +push constant 15 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 50 +push constant 30 +push constant 51 +push constant 48 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 51 +push constant 30 +push constant 51 +push constant 48 +push constant 48 +push constant 28 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 52 +push constant 16 +push constant 24 +push constant 28 +push constant 26 +push constant 25 +push constant 63 +push constant 24 +push constant 24 +push constant 60 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 53 +push constant 63 +push constant 3 +push constant 3 +push constant 31 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 54 +push constant 28 +push constant 6 +push constant 3 +push constant 3 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 55 +push constant 63 +push constant 49 +push constant 48 +push constant 48 +push constant 24 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 56 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 57 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 24 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 58 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 59 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +push constant 12 +push constant 12 +push constant 6 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 60 +push constant 0 +push constant 0 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 61 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 62 +push constant 0 +push constant 0 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 12 +push constant 6 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 64 +push constant 30 +push constant 51 +push constant 51 +push constant 59 +push constant 59 +push constant 59 +push constant 27 +push constant 3 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 63 +push constant 30 +push constant 51 +push constant 51 +push constant 24 +push constant 12 +push constant 12 +push constant 0 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 65 +push constant 12 +push constant 30 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 66 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 67 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 68 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 69 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 70 +push constant 63 +push constant 51 +push constant 35 +push constant 11 +push constant 15 +push constant 11 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 71 +push constant 28 +push constant 54 +push constant 35 +push constant 3 +push constant 59 +push constant 51 +push constant 51 +push constant 54 +push constant 44 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 72 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 73 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 74 +push constant 60 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 27 +push constant 27 +push constant 14 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 75 +push constant 51 +push constant 51 +push constant 51 +push constant 27 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 76 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 77 +push constant 33 +push constant 51 +push constant 63 +push constant 63 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 78 +push constant 51 +push constant 51 +push constant 55 +push constant 55 +push constant 63 +push constant 59 +push constant 59 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 79 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 80 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 3 +push constant 3 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 81 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 59 +push constant 30 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 82 +push constant 31 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 83 +push constant 30 +push constant 51 +push constant 51 +push constant 6 +push constant 28 +push constant 48 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 84 +push constant 63 +push constant 63 +push constant 45 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 85 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 86 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 87 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 88 +push constant 51 +push constant 51 +push constant 30 +push constant 30 +push constant 12 +push constant 30 +push constant 30 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 89 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 90 +push constant 63 +push constant 51 +push constant 49 +push constant 24 +push constant 12 +push constant 6 +push constant 35 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 91 +push constant 30 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 6 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 92 +push constant 0 +push constant 0 +push constant 1 +push constant 3 +push constant 6 +push constant 12 +push constant 24 +push constant 48 +push constant 32 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 93 +push constant 30 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 24 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 94 +push constant 8 +push constant 28 +push constant 54 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 95 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 96 +push constant 6 +push constant 12 +push constant 24 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 97 +push constant 0 +push constant 0 +push constant 0 +push constant 14 +push constant 24 +push constant 30 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 98 +push constant 3 +push constant 3 +push constant 3 +push constant 15 +push constant 27 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 99 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 3 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 100 +push constant 48 +push constant 48 +push constant 48 +push constant 60 +push constant 54 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 101 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 63 +push constant 3 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 102 +push constant 28 +push constant 54 +push constant 38 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 15 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 103 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 104 +push constant 3 +push constant 3 +push constant 3 +push constant 27 +push constant 55 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 105 +push constant 12 +push constant 12 +push constant 0 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 106 +push constant 48 +push constant 48 +push constant 0 +push constant 56 +push constant 48 +push constant 48 +push constant 48 +push constant 48 +push constant 51 +push constant 30 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 107 +push constant 3 +push constant 3 +push constant 3 +push constant 51 +push constant 27 +push constant 15 +push constant 15 +push constant 27 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 108 +push constant 14 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 109 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 63 +push constant 43 +push constant 43 +push constant 43 +push constant 43 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 110 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 111 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 112 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 31 +push constant 3 +push constant 3 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 113 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 48 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 114 +push constant 0 +push constant 0 +push constant 0 +push constant 29 +push constant 55 +push constant 51 +push constant 3 +push constant 3 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 115 +push constant 0 +push constant 0 +push constant 0 +push constant 30 +push constant 51 +push constant 6 +push constant 24 +push constant 51 +push constant 30 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 116 +push constant 4 +push constant 6 +push constant 6 +push constant 15 +push constant 6 +push constant 6 +push constant 6 +push constant 54 +push constant 28 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 117 +push constant 0 +push constant 0 +push constant 0 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 27 +push constant 54 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 118 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 51 +push constant 30 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 119 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 63 +push constant 63 +push constant 18 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 120 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 30 +push constant 12 +push constant 12 +push constant 30 +push constant 51 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 121 +push constant 0 +push constant 0 +push constant 0 +push constant 51 +push constant 51 +push constant 51 +push constant 62 +push constant 48 +push constant 24 +push constant 15 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 122 +push constant 0 +push constant 0 +push constant 0 +push constant 63 +push constant 27 +push constant 12 +push constant 6 +push constant 51 +push constant 63 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 123 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 124 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 12 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 125 +push constant 7 +push constant 12 +push constant 12 +push constant 12 +push constant 56 +push constant 12 +push constant 12 +push constant 12 +push constant 7 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 126 +push constant 38 +push constant 45 +push constant 25 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +push constant 0 +call Output.create 12 +pop temp 0 +push constant 0 +return +function Output.create 1 +push constant 11 +call Array.new 1 +pop local 0 +push argument 0 +push static 5 +add +push local 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +push local 0 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +push local 0 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 2 +push local 0 +add +push argument 3 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 3 +push local 0 +add +push argument 4 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 4 +push local 0 +add +push argument 5 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 5 +push local 0 +add +push argument 6 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 6 +push local 0 +add +push argument 7 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 7 +push local 0 +add +push argument 8 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 8 +push local 0 +add +push argument 9 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 9 +push local 0 +add +push argument 10 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 10 +push local 0 +add +push argument 11 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function Output.createShiftedMap 4 +push constant 127 +call Array.new 1 +pop static 6 +push constant 0 +pop local 2 +label WHILE_EXP0 +push local 2 +push constant 127 +lt +not +if-goto WHILE_END0 +push local 2 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +push constant 11 +call Array.new 1 +pop local 1 +push local 2 +push static 6 +add +push local 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +pop local 3 +label WHILE_EXP1 +push local 3 +push constant 11 +lt +not +if-goto WHILE_END1 +push local 3 +push local 1 +add +push local 3 +push local 0 +add +pop pointer 1 +push that 0 +push constant 256 +call Math.multiply 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 3 +push constant 1 +add +pop local 3 +goto WHILE_EXP1 +label WHILE_END1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop local 2 +goto IF_END0 +label IF_FALSE0 +push local 2 +push constant 1 +add +pop local 2 +label IF_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.getMap 1 +push argument 0 +push constant 32 +lt +push argument 0 +push constant 126 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +pop argument 0 +label IF_FALSE0 +push static 2 +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +push static 5 +add +pop pointer 1 +push that 0 +pop local 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +push static 6 +add +pop pointer 1 +push that 0 +pop local 0 +label IF_END1 +push local 0 +return +function Output.drawChar 4 +push argument 0 +call Output.getMap 1 +pop local 2 +push static 1 +pop local 0 +label WHILE_EXP0 +push local 1 +push constant 11 +lt +not +if-goto WHILE_END0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 256 +neg +and +pop local 3 +goto IF_END0 +label IF_FALSE0 +push local 0 +push static 4 +add +pop pointer 1 +push that 0 +push constant 255 +and +pop local 3 +label IF_END0 +push local 0 +push static 4 +add +push local 1 +push local 2 +add +pop pointer 1 +push that 0 +push local 3 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 32 +add +pop local 0 +push local 1 +push constant 1 +add +pop local 1 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.moveCursor 0 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 22 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 63 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 20 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push constant 2 +call Math.divide 2 +pop static 0 +push constant 32 +push argument 0 +push constant 352 +call Math.multiply 2 +add +push static 0 +add +pop static 1 +push argument 1 +push static 0 +push constant 2 +call Math.multiply 2 +eq +pop static 2 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return +function Output.printChar 0 +push argument 0 +call String.newLine 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +call Output.println 0 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +call String.backSpace 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +call Output.backSpace 0 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push argument 0 +call Output.drawChar 1 +pop temp 0 +push static 2 +not +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push static 0 +push constant 1 +add +pop static 0 +push static 1 +push constant 1 +add +pop static 1 +label IF_FALSE2 +push static 0 +push constant 32 +eq +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +call Output.println 0 +pop temp 0 +goto IF_END3 +label IF_FALSE3 +push static 2 +not +pop static 2 +label IF_END3 +label IF_END1 +label IF_END0 +push constant 0 +return +function Output.printString 2 +push argument 0 +call String.length 1 +pop local 1 +label WHILE_EXP0 +push local 0 +push local 1 +lt +not +if-goto WHILE_END0 +push argument 0 +push local 0 +call String.charAt 2 +call Output.printChar 1 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Output.printInt 0 +push static 3 +push argument 0 +call String.setInt 2 +pop temp 0 +push static 3 +call Output.printString 1 +pop temp 0 +push constant 0 +return +function Output.println 0 +push static 1 +push constant 352 +add +push static 0 +sub +pop static 1 +push constant 0 +pop static 0 +push constant 0 +not +pop static 2 +push static 1 +push constant 8128 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 32 +pop static 1 +label IF_FALSE0 +push constant 0 +return +function Output.backSpace 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push static 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push static 0 +push constant 1 +sub +pop static 0 +push static 1 +push constant 1 +sub +pop static 1 +goto IF_END1 +label IF_FALSE1 +push constant 31 +pop static 0 +push static 1 +push constant 32 +eq +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push constant 8128 +pop static 1 +label IF_FALSE2 +push static 1 +push constant 321 +sub +pop static 1 +label IF_END1 +push constant 0 +pop static 2 +goto IF_END0 +label IF_FALSE0 +push constant 0 +not +pop static 2 +label IF_END0 +push constant 32 +call Output.drawChar 1 +pop temp 0 +push constant 0 +return diff --git a/tools/OS/Screen.vm b/tools/OS/Screen.vm new file mode 100755 index 0000000..fccafb5 --- /dev/null +++ b/tools/OS/Screen.vm @@ -0,0 +1,806 @@ +function Screen.init 1 +push constant 16384 +pop static 1 +push constant 0 +not +pop static 2 +push constant 17 +call Array.new 1 +pop static 0 +push constant 0 +push static 0 +add +push constant 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label WHILE_EXP0 +push local 0 +push constant 16 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +add +pop local 0 +push local 0 +push static 0 +add +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +push local 0 +push constant 1 +sub +push static 0 +add +pop pointer 1 +push that 0 +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.clearScreen 1 +label WHILE_EXP0 +push local 0 +push constant 8192 +lt +not +if-goto WHILE_END0 +push local 0 +push static 1 +add +push constant 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.updateLocation 0 +push static 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +or +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push static 1 +add +push argument 0 +push static 1 +add +pop pointer 1 +push that 0 +push argument 1 +not +and +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +label IF_END0 +push constant 0 +return +function Screen.setColor 0 +push argument 0 +pop static 2 +push constant 0 +return +function Screen.drawPixel 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 7 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 0 +push argument 0 +push local 0 +push constant 16 +call Math.multiply 2 +sub +pop local 1 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 0 +add +pop local 2 +push local 2 +push local 1 +push static 0 +add +pop pointer 1 +push that 0 +call Screen.updateLocation 2 +pop temp 0 +push constant 0 +return +function Screen.drawConditional 0 +push argument 2 +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push argument 1 +push argument 0 +call Screen.drawPixel 2 +pop temp 0 +goto IF_END0 +label IF_FALSE0 +push argument 0 +push argument 1 +call Screen.drawPixel 2 +pop temp 0 +label IF_END0 +push constant 0 +return +function Screen.drawLine 11 +push argument 0 +push constant 0 +lt +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 8 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 2 +push argument 0 +sub +call Math.abs 1 +pop local 3 +push argument 3 +push argument 1 +sub +call Math.abs 1 +pop local 2 +push local 3 +push local 2 +lt +pop local 6 +push local 6 +push argument 3 +push argument 1 +lt +and +push local 6 +not +push argument 2 +push argument 0 +lt +and +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +pop local 4 +push argument 2 +pop argument 0 +push local 4 +pop argument 2 +push argument 1 +pop local 4 +push argument 3 +pop argument 1 +push local 4 +pop argument 3 +label IF_FALSE1 +push local 6 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 3 +pop local 4 +push local 2 +pop local 3 +push local 4 +pop local 2 +push argument 1 +pop local 1 +push argument 0 +pop local 0 +push argument 3 +pop local 8 +push argument 0 +push argument 2 +gt +pop local 7 +goto IF_END2 +label IF_FALSE2 +push argument 0 +pop local 1 +push argument 1 +pop local 0 +push argument 2 +pop local 8 +push argument 1 +push argument 3 +gt +pop local 7 +label IF_END2 +push constant 2 +push local 2 +call Math.multiply 2 +push local 3 +sub +pop local 5 +push constant 2 +push local 2 +call Math.multiply 2 +pop local 9 +push constant 2 +push local 2 +push local 3 +sub +call Math.multiply 2 +pop local 10 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 8 +lt +not +if-goto WHILE_END0 +push local 5 +push constant 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 5 +push local 9 +add +pop local 5 +goto IF_END3 +label IF_FALSE3 +push local 5 +push local 10 +add +pop local 5 +push local 7 +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push local 0 +push constant 1 +sub +pop local 0 +goto IF_END4 +label IF_FALSE4 +push local 0 +push constant 1 +add +pop local 0 +label IF_END4 +label IF_END3 +push local 1 +push constant 1 +add +pop local 1 +push local 1 +push local 0 +push local 6 +call Screen.drawConditional 3 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawRectangle 9 +push argument 0 +push argument 2 +gt +push argument 1 +push argument 3 +gt +or +push argument 0 +push constant 0 +lt +or +push argument 2 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 3 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 9 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 16 +call Math.divide 2 +pop local 3 +push argument 0 +push local 3 +push constant 16 +call Math.multiply 2 +sub +pop local 7 +push argument 2 +push constant 16 +call Math.divide 2 +pop local 4 +push argument 2 +push local 4 +push constant 16 +call Math.multiply 2 +sub +pop local 8 +push local 7 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 6 +push local 8 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 5 +push argument 1 +push constant 32 +call Math.multiply 2 +push local 3 +add +pop local 0 +push local 4 +push local 3 +sub +pop local 2 +label WHILE_EXP0 +push argument 1 +push argument 3 +gt +not +not +if-goto WHILE_END0 +push local 0 +push local 2 +add +pop local 1 +push local 2 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 5 +push local 6 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 6 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP1 +push local 0 +push local 1 +lt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push local 1 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +push argument 1 +push constant 1 +add +pop argument 1 +push local 1 +push constant 32 +add +push local 2 +sub +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Screen.drawHorizontal 11 +push argument 1 +push argument 2 +call Math.min 2 +pop local 7 +push argument 1 +push argument 2 +call Math.max 2 +pop local 8 +push argument 0 +push constant 1 +neg +gt +push argument 0 +push constant 256 +lt +and +push local 7 +push constant 512 +lt +and +push local 8 +push constant 1 +neg +gt +and +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push local 7 +push constant 0 +call Math.max 2 +pop local 7 +push local 8 +push constant 511 +call Math.min 2 +pop local 8 +push local 7 +push constant 16 +call Math.divide 2 +pop local 1 +push local 7 +push local 1 +push constant 16 +call Math.multiply 2 +sub +pop local 9 +push local 8 +push constant 16 +call Math.divide 2 +pop local 2 +push local 8 +push local 2 +push constant 16 +call Math.multiply 2 +sub +pop local 10 +push local 9 +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +not +pop local 5 +push local 10 +push constant 1 +add +push static 0 +add +pop pointer 1 +push that 0 +push constant 1 +sub +pop local 4 +push argument 0 +push constant 32 +call Math.multiply 2 +push local 1 +add +pop local 0 +push local 2 +push local 1 +sub +pop local 6 +push local 0 +push local 6 +add +pop local 3 +push local 6 +push constant 0 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push local 0 +push local 4 +push local 5 +and +call Screen.updateLocation 2 +pop temp 0 +goto IF_END1 +label IF_FALSE1 +push local 0 +push local 5 +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +label WHILE_EXP0 +push local 0 +push local 3 +lt +not +if-goto WHILE_END0 +push local 0 +push constant 1 +neg +call Screen.updateLocation 2 +pop temp 0 +push local 0 +push constant 1 +add +pop local 0 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +push local 4 +call Screen.updateLocation 2 +pop temp 0 +label IF_END1 +label IF_FALSE0 +push constant 0 +return +function Screen.drawSymetric 0 +push argument 1 +push argument 3 +sub +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 3 +add +push argument 0 +push argument 2 +add +push argument 0 +push argument 2 +sub +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +sub +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push argument 1 +push argument 2 +add +push argument 0 +push argument 3 +sub +push argument 0 +push argument 3 +add +call Screen.drawHorizontal 3 +pop temp 0 +push constant 0 +return +function Screen.drawCircle 3 +push argument 0 +push constant 0 +lt +push argument 0 +push constant 511 +gt +or +push argument 1 +push constant 0 +lt +or +push argument 1 +push constant 255 +gt +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 12 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push argument 2 +sub +push constant 0 +lt +push argument 0 +push argument 2 +add +push constant 511 +gt +or +push argument 1 +push argument 2 +sub +push constant 0 +lt +or +push argument 1 +push argument 2 +add +push constant 255 +gt +or +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 13 +call Sys.error 1 +pop temp 0 +label IF_FALSE1 +push argument 2 +pop local 1 +push constant 1 +push argument 2 +sub +pop local 2 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +label WHILE_EXP0 +push local 1 +push local 0 +gt +not +if-goto WHILE_END0 +push local 2 +push constant 0 +lt +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 2 +push constant 2 +push local 0 +call Math.multiply 2 +add +push constant 3 +add +pop local 2 +goto IF_END2 +label IF_FALSE2 +push local 2 +push constant 2 +push local 0 +push local 1 +sub +call Math.multiply 2 +add +push constant 5 +add +pop local 2 +push local 1 +push constant 1 +sub +pop local 1 +label IF_END2 +push local 0 +push constant 1 +add +pop local 0 +push argument 0 +push argument 1 +push local 0 +push local 1 +call Screen.drawSymetric 4 +pop temp 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return diff --git a/tools/OS/String.vm b/tools/OS/String.vm new file mode 100755 index 0000000..9b7577e --- /dev/null +++ b/tools/OS/String.vm @@ -0,0 +1,393 @@ +function String.new 0 +push constant 3 +call Memory.alloc 1 +pop pointer 0 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 14 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 0 +push constant 0 +gt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push argument 0 +call Array.new 1 +pop this 1 +label IF_FALSE1 +push argument 0 +pop this 0 +push constant 0 +pop this 2 +push pointer 0 +return +function String.dispose 0 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +gt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push this 1 +call Array.dispose 1 +pop temp 0 +label IF_FALSE0 +push pointer 0 +call Memory.deAlloc 1 +pop temp 0 +push constant 0 +return +function String.length 0 +push argument 0 +pop pointer 0 +push this 2 +return +function String.charAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 15 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +pop pointer 1 +push that 0 +return +function String.setCharAt 0 +push argument 0 +pop pointer 0 +push argument 1 +push constant 0 +lt +push argument 1 +push this 2 +gt +or +push argument 1 +push this 2 +eq +or +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 16 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push argument 1 +push this 1 +add +push argument 2 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 0 +return +function String.appendChar 0 +push argument 0 +pop pointer 0 +push this 2 +push this 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 17 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push this 1 +add +push argument 1 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +push pointer 0 +return +function String.eraseLastChar 0 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 18 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push this 2 +push constant 1 +sub +pop this 2 +push constant 0 +return +function String.intValue 5 +push argument 0 +pop pointer 0 +push this 2 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 0 +return +label IF_FALSE0 +push constant 0 +not +pop local 3 +push constant 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 45 +eq +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 4 +push constant 1 +pop local 0 +label IF_FALSE1 +label WHILE_EXP0 +push local 0 +push this 2 +lt +push local 3 +and +not +if-goto WHILE_END0 +push local 0 +push this 1 +add +pop pointer 1 +push that 0 +push constant 48 +sub +pop local 2 +push local 2 +push constant 0 +lt +push local 2 +push constant 9 +gt +or +not +pop local 3 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 1 +push constant 10 +call Math.multiply 2 +push local 2 +add +pop local 1 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +goto WHILE_EXP0 +label WHILE_END0 +push local 4 +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push local 1 +neg +pop local 1 +label IF_FALSE3 +push local 1 +return +function String.setInt 4 +push argument 0 +pop pointer 0 +push this 0 +push constant 0 +eq +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +push constant 6 +call Array.new 1 +pop local 2 +push argument 1 +push constant 0 +lt +if-goto IF_TRUE1 +goto IF_FALSE1 +label IF_TRUE1 +push constant 0 +not +pop local 3 +push argument 1 +neg +pop argument 1 +label IF_FALSE1 +push argument 1 +pop local 1 +label WHILE_EXP0 +push local 1 +push constant 0 +gt +not +if-goto WHILE_END0 +push argument 1 +push constant 10 +call Math.divide 2 +pop local 1 +push local 0 +push local 2 +add +push constant 48 +push argument 1 +push local 1 +push constant 10 +call Math.multiply 2 +sub +add +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +push local 1 +pop argument 1 +goto WHILE_EXP0 +label WHILE_END0 +push local 3 +if-goto IF_TRUE2 +goto IF_FALSE2 +label IF_TRUE2 +push local 0 +push local 2 +add +push constant 45 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push local 0 +push constant 1 +add +pop local 0 +label IF_FALSE2 +push this 0 +push local 0 +lt +if-goto IF_TRUE3 +goto IF_FALSE3 +label IF_TRUE3 +push constant 19 +call Sys.error 1 +pop temp 0 +label IF_FALSE3 +push local 0 +push constant 0 +eq +if-goto IF_TRUE4 +goto IF_FALSE4 +label IF_TRUE4 +push constant 0 +push this 1 +add +push constant 48 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push constant 1 +pop this 2 +goto IF_END4 +label IF_FALSE4 +push constant 0 +pop this 2 +label WHILE_EXP1 +push this 2 +push local 0 +lt +not +if-goto WHILE_END1 +push this 2 +push this 1 +add +push local 0 +push this 2 +push constant 1 +add +sub +push local 2 +add +pop pointer 1 +push that 0 +pop temp 0 +pop pointer 1 +push temp 0 +pop that 0 +push this 2 +push constant 1 +add +pop this 2 +goto WHILE_EXP1 +label WHILE_END1 +label IF_END4 +push local 2 +call Array.dispose 1 +pop temp 0 +push constant 0 +return +function String.newLine 0 +push constant 128 +return +function String.backSpace 0 +push constant 129 +return +function String.doubleQuote 0 +push constant 34 +return diff --git a/tools/OS/Sys.vm b/tools/OS/Sys.vm new file mode 100755 index 0000000..c186dad --- /dev/null +++ b/tools/OS/Sys.vm @@ -0,0 +1,83 @@ +function Sys.init 0 +call Memory.init 0 +pop temp 0 +call Math.init 0 +pop temp 0 +call Screen.init 0 +pop temp 0 +call Output.init 0 +pop temp 0 +call Keyboard.init 0 +pop temp 0 +call Main.main 0 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return +function Sys.halt 0 +label WHILE_EXP0 +push constant 0 +not +not +if-goto WHILE_END0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.wait 1 +push argument 0 +push constant 0 +lt +if-goto IF_TRUE0 +goto IF_FALSE0 +label IF_TRUE0 +push constant 1 +call Sys.error 1 +pop temp 0 +label IF_FALSE0 +label WHILE_EXP0 +push argument 0 +push constant 0 +gt +not +if-goto WHILE_END0 +push constant 50 +pop local 0 +label WHILE_EXP1 +push local 0 +push constant 0 +gt +not +if-goto WHILE_END1 +push local 0 +push constant 1 +sub +pop local 0 +goto WHILE_EXP1 +label WHILE_END1 +push argument 0 +push constant 1 +sub +pop argument 0 +goto WHILE_EXP0 +label WHILE_END0 +push constant 0 +return +function Sys.error 0 +push constant 69 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push constant 82 +call Output.printChar 1 +pop temp 0 +push argument 0 +call Output.printInt 1 +pop temp 0 +call Sys.halt 0 +pop temp 0 +push constant 0 +return diff --git a/tools/TextComparer.bat b/tools/TextComparer.bat new file mode 100755 index 0000000..a036d00 --- /dev/null +++ b/tools/TextComparer.bat @@ -0,0 +1,29 @@ +@echo off + +rem $Id: TextComparer.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%3"=="" goto :USAGE +if "%1"=="/?" goto :USAGE +if not "%~1"=="" ( + set "_arg1=%~f1" +) +if not "%~2"=="" ( + set "_arg2=%~f2" +) +pushd "%~dp0" +if NOT "%~1"=="" ( + if NOT "%~2"=="" ( + java -classpath "%CLASSPATH%;bin/classes" TextComparer ^ + "%_arg1%" "%_arg2%" + popd + exit /B + ) +) +:USAGE +echo Usage: +echo TextComparer FILE1 FILE2 Compares FILE1 and FILE2. The success +echo message or the first miscompared line +echo is printed to the command console. +popd diff --git a/tools/TextComparer.sh b/tools/TextComparer.sh new file mode 100755 index 0000000..c8b08af --- /dev/null +++ b/tools/TextComparer.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +# $Id: TextComparer.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -ne 2 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + # print usage + echo "Usage:" + echo " `basename "$0"` FILE1 FILE2 Compares FILE1 and FILE2. The success" + echo " message or the first miscompared line" + echo " is printed to the command console." +else + # Convert arg1 to an absolute path + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="$dir/$1" + fi + # Convert arg2 to an absolute path + if [ `echo "$2" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg2="$2" + else + arg2="$dir/$2" + fi +# echo Comparing "$arg1" "$arg2" + java -classpath "${CLASSPATH}:bin/classes" TextComparer "$arg1" "$arg2" +fi diff --git a/tools/VMEmulator.bat b/tools/VMEmulator.bat new file mode 100755 index 0000000..1b15b72 --- /dev/null +++ b/tools/VMEmulator.bat @@ -0,0 +1,29 @@ +@echo off + +rem $Id: VMEmulator.bat,v 1.3 2014/05/10 00:51:55 marka Exp $ +rem mark.armbrust@pobox.com + +setlocal +if not "%2"=="" goto :USAGE +if "%~1"=="/?" ( +:USAGE + echo Usage: + echo VMEmulator Starts the VM Emulator in interactive mode. + echo VMEmulator FILE.tst Starts the VM Emulator and runs the FILE.tst test + echo script. The success/failure message is + echo printed to the command console. + exit -b +) +if not "%~1"=="" ( + set "_arg1=%~f1" +) +pushd "%~dp0" +if "%~1"=="" ( + start javaw -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + VMEmulatorMain +) else ( +rem echo Running "%_arg1%" + java -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" ^ + VMEmulatorMain "%_arg1%" +) +popd diff --git a/tools/VMEmulator.sh b/tools/VMEmulator.sh new file mode 100755 index 0000000..48f4f0f --- /dev/null +++ b/tools/VMEmulator.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +# $Id: VMEmulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ +# mark.armbrust@pobox.com + +# User's CDPATH can interfere with cd in this script +unset CDPATH +# Get the true name of this script +script="`test -L "$0" && readlink -n "$0" || echo "$0"`" +dir="$PWD" +cd "`dirname "$script"`" +if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] +then + echo "Usage:" + echo " `basename "$0"` Starts the VM Emulator in interactive mode." + echo " `basename "$0"` FILE.tst Starts the VM Emulator and runs the FILE.tst test" + echo " script. The success/failure message is" + echo " printed to the command console." +elif [ $# -eq 0 ] +then + # Run VM emulator in interactive mode + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" VMEmulatorMain & +else + # Convert arg1 to an absolute path and run VM emulator with arg1 + if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] + then + arg1="$1" + else + arg1="${dir}/$1" + fi +# echo Running "$arg1" + java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar" VMEmulatorMain "$arg1" +fi diff --git a/tools/bin/Assembler.dat b/tools/bin/Assembler.dat new file mode 100755 index 0000000..0f3be3f --- /dev/null +++ b/tools/bin/Assembler.dat @@ -0,0 +1 @@ +C:\Users\SQA-AGrudev\Desktop\nand2tetris\projects\08\ProgramFlow\BasicLoop\BasicLoop.hack diff --git a/tools/bin/CPU Emulator.dat b/tools/bin/CPU Emulator.dat new file mode 100755 index 0000000..1343654 --- /dev/null +++ b/tools/bin/CPU Emulator.dat @@ -0,0 +1 @@ +C:\Users\SQA-AGrudev\Desktop\nand2tetris\projects\08\FunctionCalls\NestedCall diff --git a/tools/bin/Hardware Simulator.dat b/tools/bin/Hardware Simulator.dat new file mode 100755 index 0000000..33d02db --- /dev/null +++ b/tools/bin/Hardware Simulator.dat @@ -0,0 +1 @@ +C:\Users\Andrean\Desktop\nand2tetris\projects\03\a diff --git a/tools/bin/Virtual Machine Emulator.dat b/tools/bin/Virtual Machine Emulator.dat new file mode 100755 index 0000000..729384c --- /dev/null +++ b/tools/bin/Virtual Machine Emulator.dat @@ -0,0 +1 @@ +C:\Users\SQA-AGrudev\Desktop\Hangman diff --git a/tools/bin/classes/CPUEmulatorMain.class b/tools/bin/classes/CPUEmulatorMain.class new file mode 100755 index 0000000..2c5b68f Binary files /dev/null and b/tools/bin/classes/CPUEmulatorMain.class differ diff --git a/tools/bin/classes/HackAssemblerMain.class b/tools/bin/classes/HackAssemblerMain.class new file mode 100755 index 0000000..b912391 Binary files /dev/null and b/tools/bin/classes/HackAssemblerMain.class differ diff --git a/tools/bin/classes/HardwareSimulatorMain.class b/tools/bin/classes/HardwareSimulatorMain.class new file mode 100755 index 0000000..5786077 Binary files /dev/null and b/tools/bin/classes/HardwareSimulatorMain.class differ diff --git a/tools/bin/classes/TextComparer.class b/tools/bin/classes/TextComparer.class new file mode 100755 index 0000000..f2e076e Binary files /dev/null and b/tools/bin/classes/TextComparer.class differ diff --git a/tools/bin/classes/VMEmulatorMain.class b/tools/bin/classes/VMEmulatorMain.class new file mode 100755 index 0000000..aa6b7ff Binary files /dev/null and b/tools/bin/classes/VMEmulatorMain.class differ diff --git a/tools/bin/help/asmAbout.html b/tools/bin/help/asmAbout.html new file mode 100755 index 0000000..919e539 --- /dev/null +++ b/tools/bin/help/asmAbout.html @@ -0,0 +1,96 @@ + + + + + + + + +About Assembler + + + + + + + +

+ +

Assembler, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

+ +

 

+ +
+ + + + diff --git a/tools/bin/help/asmUsage.html b/tools/bin/help/asmUsage.html new file mode 100755 index 0000000..1e18db2 --- /dev/null +++ b/tools/bin/help/asmUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The Assembler Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/tools/bin/help/compiler.txt b/tools/bin/help/compiler.txt new file mode 100755 index 0000000..07bbba9 --- /dev/null +++ b/tools/bin/help/compiler.txt @@ -0,0 +1,9 @@ +Jack Compiler, Version 2.5 + +This program is part of www.nand2tetris.org +and the book "The Elements of Computing Systems" +by Nisan and Schocken, MIT Press. + +Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski + +Usage instruction and tips can be found in the relevant book chapters. diff --git a/tools/bin/help/cpuAbout.html b/tools/bin/help/cpuAbout.html new file mode 100755 index 0000000..f806d5e --- /dev/null +++ b/tools/bin/help/cpuAbout.html @@ -0,0 +1,96 @@ + + + + + + + + +About CPU Emulator + + + + + + + +
+ +

CPU Emulator, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

+ +

 

+ +
+ + + + diff --git a/tools/bin/help/cpuUsage.html b/tools/bin/help/cpuUsage.html new file mode 100755 index 0000000..7e69482 --- /dev/null +++ b/tools/bin/help/cpuUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The CPU Emulator Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/tools/bin/help/hwAbout.html b/tools/bin/help/hwAbout.html new file mode 100755 index 0000000..67ad89b --- /dev/null +++ b/tools/bin/help/hwAbout.html @@ -0,0 +1,96 @@ + + + + + + + + +About Hardware Simulator + + + + + + + +
+ +

Hardware Simulator, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

+ +

 

+ +
+ + + + diff --git a/tools/bin/help/hwUsage.html b/tools/bin/help/hwUsage.html new file mode 100755 index 0000000..4663f53 --- /dev/null +++ b/tools/bin/help/hwUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The Hardware Simulator Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/tools/bin/help/vmAbout.html b/tools/bin/help/vmAbout.html new file mode 100755 index 0000000..c5b296a --- /dev/null +++ b/tools/bin/help/vmAbout.html @@ -0,0 +1,110 @@ + + + + + + + + +About Virtual Machine Emulator + + + + + + + +
+ +

Virtual Machine Emulator, Version 2.5

+ +

 

+ +

This program is +part of www.nand2tetris.org

+ +

and +the book "The Elements of Computing Systems"

+ +

by +Nisan and Schocken, MIT Press.

+ +

 

+ +

Software Architects: Yaron Ukrainitz and Yannai A. +Gonczarowski

+ +

 

+ +
+ + + + diff --git a/tools/bin/help/vmUsage.html b/tools/bin/help/vmUsage.html new file mode 100755 index 0000000..611662b --- /dev/null +++ b/tools/bin/help/vmUsage.html @@ -0,0 +1,115 @@ + + + + + + + + +Usage instruction and tips can be found in: + + + + + + + +
+ +

Usage instruction and tips can be found in:

+ +

 

+ +

The VM Emulator Tutorial

+ +

 

+ +

Available in www.nand2tetris.org

+ +

 

+ +

And in relevant book chapters from

+ +

The Elements of Computing Systems,

+ +

by Noam Nisan and Shimon Schocken

+ +

MIT Press

+ +

 

+ +
+ + + + diff --git a/tools/bin/images/arrow2.gif b/tools/bin/images/arrow2.gif new file mode 100755 index 0000000..c744eab Binary files /dev/null and b/tools/bin/images/arrow2.gif differ diff --git a/tools/bin/images/calculator2.gif b/tools/bin/images/calculator2.gif new file mode 100755 index 0000000..834cb05 Binary files /dev/null and b/tools/bin/images/calculator2.gif differ diff --git a/tools/bin/images/cancel.gif b/tools/bin/images/cancel.gif new file mode 100755 index 0000000..a8509fa Binary files /dev/null and b/tools/bin/images/cancel.gif differ diff --git a/tools/bin/images/chip.gif b/tools/bin/images/chip.gif new file mode 100755 index 0000000..fbfbb02 Binary files /dev/null and b/tools/bin/images/chip.gif differ diff --git a/tools/bin/images/clock2.gif b/tools/bin/images/clock2.gif new file mode 100755 index 0000000..addcf78 Binary files /dev/null and b/tools/bin/images/clock2.gif differ diff --git a/tools/bin/images/equal.gif b/tools/bin/images/equal.gif new file mode 100755 index 0000000..3402556 Binary files /dev/null and b/tools/bin/images/equal.gif differ diff --git a/tools/bin/images/find.gif b/tools/bin/images/find.gif new file mode 100755 index 0000000..e3f4c9d Binary files /dev/null and b/tools/bin/images/find.gif differ diff --git a/tools/bin/images/hex.gif b/tools/bin/images/hex.gif new file mode 100755 index 0000000..68a851b Binary files /dev/null and b/tools/bin/images/hex.gif differ diff --git a/tools/bin/images/keyboard.gif b/tools/bin/images/keyboard.gif new file mode 100755 index 0000000..823aaf8 Binary files /dev/null and b/tools/bin/images/keyboard.gif differ diff --git a/tools/bin/images/ok.gif b/tools/bin/images/ok.gif new file mode 100755 index 0000000..fe6ed8d Binary files /dev/null and b/tools/bin/images/ok.gif differ diff --git a/tools/bin/images/ok2.gif b/tools/bin/images/ok2.gif new file mode 100755 index 0000000..083909b Binary files /dev/null and b/tools/bin/images/ok2.gif differ diff --git a/tools/bin/images/open.gif b/tools/bin/images/open.gif new file mode 100755 index 0000000..f69a024 Binary files /dev/null and b/tools/bin/images/open.gif differ diff --git a/tools/bin/images/open2.gif b/tools/bin/images/open2.gif new file mode 100755 index 0000000..2b94682 Binary files /dev/null and b/tools/bin/images/open2.gif differ diff --git a/tools/bin/images/opendoc.gif b/tools/bin/images/opendoc.gif new file mode 100755 index 0000000..e84f0d6 Binary files /dev/null and b/tools/bin/images/opendoc.gif differ diff --git a/tools/bin/images/redflag.gif b/tools/bin/images/redflag.gif new file mode 100755 index 0000000..1b1a6b1 Binary files /dev/null and b/tools/bin/images/redflag.gif differ diff --git a/tools/bin/images/save.gif b/tools/bin/images/save.gif new file mode 100755 index 0000000..7b5d5b9 Binary files /dev/null and b/tools/bin/images/save.gif differ diff --git a/tools/bin/images/scroll.gif b/tools/bin/images/scroll.gif new file mode 100755 index 0000000..e00a9a1 Binary files /dev/null and b/tools/bin/images/scroll.gif differ diff --git a/tools/bin/images/smallcancel.gif b/tools/bin/images/smallcancel.gif new file mode 100755 index 0000000..1f8cddc Binary files /dev/null and b/tools/bin/images/smallcancel.gif differ diff --git a/tools/bin/images/smallequal.gif b/tools/bin/images/smallequal.gif new file mode 100755 index 0000000..a1db606 Binary files /dev/null and b/tools/bin/images/smallequal.gif differ diff --git a/tools/bin/images/smallminus.gif b/tools/bin/images/smallminus.gif new file mode 100755 index 0000000..06492f5 Binary files /dev/null and b/tools/bin/images/smallminus.gif differ diff --git a/tools/bin/images/smallnew.gif b/tools/bin/images/smallnew.gif new file mode 100755 index 0000000..c3137e5 Binary files /dev/null and b/tools/bin/images/smallnew.gif differ diff --git a/tools/bin/images/smallok.gif b/tools/bin/images/smallok.gif new file mode 100755 index 0000000..9bef2b2 Binary files /dev/null and b/tools/bin/images/smallok.gif differ diff --git a/tools/bin/images/smallplus.gif b/tools/bin/images/smallplus.gif new file mode 100755 index 0000000..9030b0b Binary files /dev/null and b/tools/bin/images/smallplus.gif differ diff --git a/tools/bin/images/vcrfastforward.gif b/tools/bin/images/vcrfastforward.gif new file mode 100755 index 0000000..11c7235 Binary files /dev/null and b/tools/bin/images/vcrfastforward.gif differ diff --git a/tools/bin/images/vcrforward.gif b/tools/bin/images/vcrforward.gif new file mode 100755 index 0000000..b58d649 Binary files /dev/null and b/tools/bin/images/vcrforward.gif differ diff --git a/tools/bin/images/vcrrewind.gif b/tools/bin/images/vcrrewind.gif new file mode 100755 index 0000000..e55b4d6 Binary files /dev/null and b/tools/bin/images/vcrrewind.gif differ diff --git a/tools/bin/images/vcrstop.gif b/tools/bin/images/vcrstop.gif new file mode 100755 index 0000000..abe2082 Binary files /dev/null and b/tools/bin/images/vcrstop.gif differ diff --git a/tools/bin/lib/AssemblerGUI.jar b/tools/bin/lib/AssemblerGUI.jar new file mode 100755 index 0000000..c40d455 Binary files /dev/null and b/tools/bin/lib/AssemblerGUI.jar differ diff --git a/tools/bin/lib/Compilers.jar b/tools/bin/lib/Compilers.jar new file mode 100755 index 0000000..9a78b05 Binary files /dev/null and b/tools/bin/lib/Compilers.jar differ diff --git a/tools/bin/lib/Hack.jar b/tools/bin/lib/Hack.jar new file mode 100755 index 0000000..9d57398 Binary files /dev/null and b/tools/bin/lib/Hack.jar differ diff --git a/tools/bin/lib/HackGUI.jar b/tools/bin/lib/HackGUI.jar new file mode 100755 index 0000000..22d4ff3 Binary files /dev/null and b/tools/bin/lib/HackGUI.jar differ diff --git a/tools/bin/lib/Simulators.jar b/tools/bin/lib/Simulators.jar new file mode 100755 index 0000000..72b5db7 Binary files /dev/null and b/tools/bin/lib/Simulators.jar differ diff --git a/tools/bin/lib/SimulatorsGUI.jar b/tools/bin/lib/SimulatorsGUI.jar new file mode 100755 index 0000000..4d36e64 Binary files /dev/null and b/tools/bin/lib/SimulatorsGUI.jar differ diff --git a/tools/bin/lib/TranslatorsGUI.jar b/tools/bin/lib/TranslatorsGUI.jar new file mode 100755 index 0000000..f29f926 Binary files /dev/null and b/tools/bin/lib/TranslatorsGUI.jar differ diff --git a/tools/bin/scripts/defaultCPU.txt b/tools/bin/scripts/defaultCPU.txt new file mode 100755 index 0000000..43b2720 --- /dev/null +++ b/tools/bin/scripts/defaultCPU.txt @@ -0,0 +1,3 @@ +repeat { + ticktock; +} \ No newline at end of file diff --git a/tools/bin/scripts/defaultHW.txt b/tools/bin/scripts/defaultHW.txt new file mode 100755 index 0000000..bdb2261 --- /dev/null +++ b/tools/bin/scripts/defaultHW.txt @@ -0,0 +1,4 @@ +repeat { + tick, + tock; +} \ No newline at end of file diff --git a/tools/bin/scripts/defaultVM.txt b/tools/bin/scripts/defaultVM.txt new file mode 100755 index 0000000..dbc64c4 --- /dev/null +++ b/tools/bin/scripts/defaultVM.txt @@ -0,0 +1,3 @@ +repeat { + vmstep; +} \ No newline at end of file diff --git a/tools/builtInChips/ALU.class b/tools/builtInChips/ALU.class new file mode 100755 index 0000000..03f95dc Binary files /dev/null and b/tools/builtInChips/ALU.class differ diff --git a/tools/builtInChips/ALU.hdl b/tools/builtInChips/ALU.hdl new file mode 100755 index 0000000..e5fd1f0 --- /dev/null +++ b/tools/builtInChips/ALU.hdl @@ -0,0 +1,55 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/ALU.hdl + +/** + * The ALU. Computes one of the following functions: + * x+y, x-y, y–x, 0, 1, -1, x, y, -x, -y, !x, !y, + * x+1, y+1, x-1, y-1, x&y, x|y on two 16-bit inputs. + * Which function to compute is determined by 6 input bits + * denoted zx, nx, zy, ny, f, no. + * The computed function's value is called "out". + * In addition to computing out, the ALU computes two + * 1-bit outputs called zr and ng: + * if out == 0, zr = 1; otherwise zr = 0; + * If out < 0, ng = 1; otherwise ng = 0. + * The 6-bit combinations (zx,nx,zy,ny,f,no) and + * their effect are documented in the book. + */ + +// Implementation: the ALU manipulates the x and y +// inputs and then operates on the resulting values, +// as follows: +// if (zx == 1) sets x = 0 // 16-bit constant +// if (nx == 1) sets x = ~x // bitwise "not" +// if (zy == 1) sets y = 0 // 16-bit constant +// if (ny == 1) sets y = ~y // bitwise "not" +// if (f == 1) sets out = x + y // integer 2's-complement addition +// if (f == 0) sets out = x & y // bitwise And +// if (no == 1) sets out = ~out // bitwise Not +// if (out == 0) sets zr = 1 +// if (out < 0) sets ng = 1 + + +CHIP ALU { + + IN // 16-bit inputs: + x[16], y[16], + // Control bits: + zx, // Zero the x input + nx, // Negate the x input + zy, // Zero the y input + ny, // Negate the y input + f, // Function code: 1 for add, 0 for and + no; // Negate the out output + + OUT // 16-bit output + out[16], + + // ALU output flags + zr, // 1 if out=0, 0 otherwise + ng; // 1 if out<0, 0 otherwise + + BUILTIN ALU; +} diff --git a/tools/builtInChips/ARegister.class b/tools/builtInChips/ARegister.class new file mode 100755 index 0000000..ab9aadc Binary files /dev/null and b/tools/builtInChips/ARegister.class differ diff --git a/tools/builtInChips/ARegister.hdl b/tools/builtInChips/ARegister.hdl new file mode 100755 index 0000000..23aee73 --- /dev/null +++ b/tools/builtInChips/ARegister.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/ARegister.hdl + +/** + * A 16-Bit register called "A Register". + * If load[t-1]=1 then out[t] = in[t-1] + * else out does not change (out[t] = out[t-1]) + * + * This built-in chip implementation has the side effect of + * providing a GUI representation of a 16-bit register + * called "A register" (typically used to store an address). + */ + +CHIP ARegister { + + IN in[16], load; + OUT out[16]; + + BUILTIN ARegister; + CLOCKED in, load; +} + diff --git a/tools/builtInChips/Add16.class b/tools/builtInChips/Add16.class new file mode 100755 index 0000000..c3754ce Binary files /dev/null and b/tools/builtInChips/Add16.class differ diff --git a/tools/builtInChips/Add16.hdl b/tools/builtInChips/Add16.hdl new file mode 100755 index 0000000..a494af4 --- /dev/null +++ b/tools/builtInChips/Add16.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Add16.hdl + +/* + * Adds two 16-bit values. + * The most significant carry bit is ignored. + */ + +CHIP Add16 { + + IN a[16], b[16]; + OUT out[16]; + + BUILTIN Add16; +} + diff --git a/tools/builtInChips/And.class b/tools/builtInChips/And.class new file mode 100755 index 0000000..2c7492b Binary files /dev/null and b/tools/builtInChips/And.class differ diff --git a/tools/builtInChips/And.hdl b/tools/builtInChips/And.hdl new file mode 100755 index 0000000..d2c48b5 --- /dev/null +++ b/tools/builtInChips/And.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/And.hdl + +/** + * And gate: out = 1 if {a == 1 and b == 1}, 0 otherwise + */ + +CHIP And { + + IN a, b; + OUT out; + + BUILTIN And; +} diff --git a/tools/builtInChips/And16.hdl b/tools/builtInChips/And16.hdl new file mode 100755 index 0000000..4c71874 --- /dev/null +++ b/tools/builtInChips/And16.hdl @@ -0,0 +1,17 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/And16.hdl + +/** + * 16-bit-wise And gate: for i = 0..15: out[i] = a[i] and b[i] + */ + +CHIP And16 { + + IN a[16], b[16]; + OUT out[16]; + + BUILTIN And; +} + diff --git a/tools/builtInChips/Bit.class b/tools/builtInChips/Bit.class new file mode 100755 index 0000000..1e5a3c4 Binary files /dev/null and b/tools/builtInChips/Bit.class differ diff --git a/tools/builtInChips/Bit.hdl b/tools/builtInChips/Bit.hdl new file mode 100755 index 0000000..a0a76bb --- /dev/null +++ b/tools/builtInChips/Bit.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Bit.hdl + +/** + * 1-bit register. + * If load[t] == 1 then out[t+1] = in[t] + * else out[t+1] = out[t] (no change) + */ + +CHIP Bit { + + IN in, load; + OUT out; + + BUILTIN Bit; + CLOCKED in, load; +} diff --git a/tools/builtInChips/DFF.class b/tools/builtInChips/DFF.class new file mode 100755 index 0000000..49efcf1 Binary files /dev/null and b/tools/builtInChips/DFF.class differ diff --git a/tools/builtInChips/DFF.hdl b/tools/builtInChips/DFF.hdl new file mode 100755 index 0000000..c66b796 --- /dev/null +++ b/tools/builtInChips/DFF.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DFF.hdl + +/** + * Data Flip-flop: out(t) = in(t-1) + * where t is the current time unit, or clock cycle. + */ + +CHIP DFF { + + IN in; + OUT out; + + BUILTIN DFF; + CLOCKED in; +} diff --git a/tools/builtInChips/DMux.class b/tools/builtInChips/DMux.class new file mode 100755 index 0000000..8cf4e0b Binary files /dev/null and b/tools/builtInChips/DMux.class differ diff --git a/tools/builtInChips/DMux.hdl b/tools/builtInChips/DMux.hdl new file mode 100755 index 0000000..80153d7 --- /dev/null +++ b/tools/builtInChips/DMux.hdl @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DMux.hdl + +/** + * Dmultiplexor. + * {a,b} = {in,0} if sel == 0 + * {0,in} if sel == 1 + */ + + +CHIP DMux { + + IN in, sel; + OUT a, b; + + BUILTIN DMux; +} + diff --git a/tools/builtInChips/DMux4Way.class b/tools/builtInChips/DMux4Way.class new file mode 100755 index 0000000..ab72a17 Binary files /dev/null and b/tools/builtInChips/DMux4Way.class differ diff --git a/tools/builtInChips/DMux4Way.hdl b/tools/builtInChips/DMux4Way.hdl new file mode 100755 index 0000000..110bb4e --- /dev/null +++ b/tools/builtInChips/DMux4Way.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DMux4Way.hdl + +/** + * 4-way demultiplexor. + * {a,b,c,d} = {in,0,0,0} if sel == 00 + * {0,in,0,0} if sel == 01 + * {0,0,in,0} if sel == 10 + * {0,0,0,in} if sel == 11 + */ + + +CHIP DMux4Way { + + IN in, sel[2]; + OUT a, b, c, d; + + BUILTIN DMux4Way; +} + diff --git a/tools/builtInChips/DMux8Way.class b/tools/builtInChips/DMux8Way.class new file mode 100755 index 0000000..80e7437 Binary files /dev/null and b/tools/builtInChips/DMux8Way.class differ diff --git a/tools/builtInChips/DMux8Way.hdl b/tools/builtInChips/DMux8Way.hdl new file mode 100755 index 0000000..c5536b8 --- /dev/null +++ b/tools/builtInChips/DMux8Way.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/DMux8Way.hdl + +/** + * 8-way demultiplexor. + * {a,b,c,d,e,f,g,h} = {in,0,0,0,0,0,0,0} if sel == 000 + * {0,in,0,0,0,0,0,0} if sel == 001 + * etc. + * {0,0,0,0,0,0,0,in} if sel == 111 + */ + + +CHIP DMux8Way { + + IN in, sel[3]; + OUT a, b, c, d, e, f, g, h; + + BUILTIN DMux8Way; +} + diff --git a/tools/builtInChips/DRegister.class b/tools/builtInChips/DRegister.class new file mode 100755 index 0000000..74a713d Binary files /dev/null and b/tools/builtInChips/DRegister.class differ diff --git a/tools/builtInChips/DRegister.hdl b/tools/builtInChips/DRegister.hdl new file mode 100755 index 0000000..6c9a254 --- /dev/null +++ b/tools/builtInChips/DRegister.hdl @@ -0,0 +1,24 @@ +// This file is part of the materials accompanying the book +// "The Elements of Computing Systems" by Nisan and Schocken, +// MIT Press. Book site: www.idc.ac.il/tecs +// File name: tools/builtIn/DRegister.hdl + +/** + * A 16-Bit register called "D Register". + * If load[t-1]=1 then out[t] = in[t-1] + * else out does not change (out[t] = out[t-1]) + * + * This built-in chip implementation has the side effect of + * providing a GUI representation of a 16-bit register + * called "D register" (typically used to store data). + */ + +CHIP DRegister { + + IN in[16], load; + OUT out[16]; + + BUILTIN DRegister; + CLOCKED in, load; +} + diff --git a/tools/builtInChips/FullAdder.class b/tools/builtInChips/FullAdder.class new file mode 100755 index 0000000..2ed9ead Binary files /dev/null and b/tools/builtInChips/FullAdder.class differ diff --git a/tools/builtInChips/FullAdder.hdl b/tools/builtInChips/FullAdder.hdl new file mode 100755 index 0000000..a4caa56 --- /dev/null +++ b/tools/builtInChips/FullAdder.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/FullAdder.hdl + +/** + * Full adder. Computes sum, the least significant bit of + * a + b + c, and carry, the most significant bit of a + b + c. + */ + +CHIP FullAdder { + + IN a, b, c; + OUT sum, // LSB of a + b + c + carry; // MSB of a + b + c + + BUILTIN FullAdder; +} + diff --git a/tools/builtInChips/HalfAdder.class b/tools/builtInChips/HalfAdder.class new file mode 100755 index 0000000..e7741ed Binary files /dev/null and b/tools/builtInChips/HalfAdder.class differ diff --git a/tools/builtInChips/HalfAdder.hdl b/tools/builtInChips/HalfAdder.hdl new file mode 100755 index 0000000..1591b96 --- /dev/null +++ b/tools/builtInChips/HalfAdder.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/HalfAdder.hdl + +/** + * Half adder. Computes sum, the least significnat bit of a + b, + * and carry, the most significnat bit of a + b. + */ + +CHIP HalfAdder { + + IN a, b; + OUT sum, // LSB of a + b + carry; // MSB of a + b + + BUILTIN HalfAdder; +} diff --git a/tools/builtInChips/Inc16.class b/tools/builtInChips/Inc16.class new file mode 100755 index 0000000..b5b2aeb Binary files /dev/null and b/tools/builtInChips/Inc16.class differ diff --git a/tools/builtInChips/Inc16.hdl b/tools/builtInChips/Inc16.hdl new file mode 100755 index 0000000..9d2d49b --- /dev/null +++ b/tools/builtInChips/Inc16.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Inc16.hdl + +/** + * 16-bit incrementer. out = in + 1 (16-bit addition). + * Overflow is neither detected nor handled. + */ + +CHIP Inc16 { + + IN in[16]; + OUT out[16]; + + BUILTIN Inc16; +} + diff --git a/tools/builtInChips/Keyboard.class b/tools/builtInChips/Keyboard.class new file mode 100755 index 0000000..090b7cc Binary files /dev/null and b/tools/builtInChips/Keyboard.class differ diff --git a/tools/builtInChips/Keyboard.hdl b/tools/builtInChips/Keyboard.hdl new file mode 100755 index 0000000..26ca5ed --- /dev/null +++ b/tools/builtInChips/Keyboard.hdl @@ -0,0 +1,23 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Keyboard.hdl + +/** + * The keyboard (memory map). + * Outputs the code of the currently pressed key. + * + * The built-in chip implementation has two side effects supplied + * by the simulator. First, the keyboard memory map is continuously + * being refreshed from the physical keyboard unit. Second, it + * displays a keyboard icon and data entry GUI. + */ + +CHIP Keyboard { + + OUT out[16]; // The ASCII code of the pressed key, + // or 0 if no key is currently pressed, + // or one the special codes listed in Figure 5.5. + + BUILTIN Keyboard; +} diff --git a/tools/builtInChips/Mux.class b/tools/builtInChips/Mux.class new file mode 100755 index 0000000..75c6645 Binary files /dev/null and b/tools/builtInChips/Mux.class differ diff --git a/tools/builtInChips/Mux.hdl b/tools/builtInChips/Mux.hdl new file mode 100755 index 0000000..a0eefbc --- /dev/null +++ b/tools/builtInChips/Mux.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux.hdl + +/** + * Multiplexor. If sel == 1 then out = b else out = a. + */ + +CHIP Mux { + + IN a, b, sel; + OUT out; + + BUILTIN Mux; +} diff --git a/tools/builtInChips/Mux16.hdl b/tools/builtInChips/Mux16.hdl new file mode 100755 index 0000000..676d1f4 --- /dev/null +++ b/tools/builtInChips/Mux16.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux16.hdl + +/** + * 16 bit multiplexor. If sel == 1 then out = b else out = a. + */ + +CHIP Mux16 { + + IN a[16], b[16], sel; + OUT out[16]; + + BUILTIN Mux; +} diff --git a/tools/builtInChips/Mux4Way16.class b/tools/builtInChips/Mux4Way16.class new file mode 100755 index 0000000..b2e2ed7 Binary files /dev/null and b/tools/builtInChips/Mux4Way16.class differ diff --git a/tools/builtInChips/Mux4Way16.hdl b/tools/builtInChips/Mux4Way16.hdl new file mode 100755 index 0000000..9929e82 --- /dev/null +++ b/tools/builtInChips/Mux4Way16.hdl @@ -0,0 +1,21 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux4Way16.hdl + +/** + * 4-way 16-bit multiplexor. + * out = a if sel == 00 + * b if sel == 01 + * c if sel == 10 + * d if sel == 11 + */ + + +CHIP Mux4Way16 { + + IN a[16], b[16], c[16], d[16], sel[2]; + OUT out[16]; + + BUILTIN Mux4Way16; +} diff --git a/tools/builtInChips/Mux8Way16.class b/tools/builtInChips/Mux8Way16.class new file mode 100755 index 0000000..d8040ef Binary files /dev/null and b/tools/builtInChips/Mux8Way16.class differ diff --git a/tools/builtInChips/Mux8Way16.hdl b/tools/builtInChips/Mux8Way16.hdl new file mode 100755 index 0000000..dc16861 --- /dev/null +++ b/tools/builtInChips/Mux8Way16.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Mux8Way16.hdl + +/** + * 8-way 16-bit multiplexor. + * out = a if sel == 000 + * b if sel == 001 + * etc. + * h if sel == 111 + */ + + +CHIP Mux8Way16 { + + IN a[16], b[16], c[16], d[16], + e[16], f[16], g[16], h[16], + sel[3]; + + OUT out[16]; + + BUILTIN Mux8Way16; +} \ No newline at end of file diff --git a/tools/builtInChips/Nand.class b/tools/builtInChips/Nand.class new file mode 100755 index 0000000..4b429ba Binary files /dev/null and b/tools/builtInChips/Nand.class differ diff --git a/tools/builtInChips/Nand.hdl b/tools/builtInChips/Nand.hdl new file mode 100755 index 0000000..ae0204e --- /dev/null +++ b/tools/builtInChips/Nand.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Nand.hdl + +/** + * Nand gate: out = a Nand b. + */ + +CHIP Nand { + + IN a, b; + OUT out; + + BUILTIN Nand; +} diff --git a/tools/builtInChips/Not.class b/tools/builtInChips/Not.class new file mode 100755 index 0000000..4726b67 Binary files /dev/null and b/tools/builtInChips/Not.class differ diff --git a/tools/builtInChips/Not.hdl b/tools/builtInChips/Not.hdl new file mode 100755 index 0000000..5b9d897 --- /dev/null +++ b/tools/builtInChips/Not.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Not.hdl + +/** + * Not gate: out = not in + */ + +CHIP Not { + + IN in; + OUT out; + + BUILTIN Not; +} \ No newline at end of file diff --git a/tools/builtInChips/Not16.class b/tools/builtInChips/Not16.class new file mode 100755 index 0000000..ff3e68f Binary files /dev/null and b/tools/builtInChips/Not16.class differ diff --git a/tools/builtInChips/Not16.hdl b/tools/builtInChips/Not16.hdl new file mode 100755 index 0000000..c50dab9 --- /dev/null +++ b/tools/builtInChips/Not16.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Not16.hdl + +/** + * 16-bit Not gate: for i = 0..15: out[i] = not in[i] + */ + +CHIP Not16 { + + IN in[16]; + OUT out[16]; + + BUILTIN Not16; +} \ No newline at end of file diff --git a/tools/builtInChips/Or.class b/tools/builtInChips/Or.class new file mode 100755 index 0000000..a5b64f9 Binary files /dev/null and b/tools/builtInChips/Or.class differ diff --git a/tools/builtInChips/Or.hdl b/tools/builtInChips/Or.hdl new file mode 100755 index 0000000..4a3f14b --- /dev/null +++ b/tools/builtInChips/Or.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Or.hdl + +/** + * Or gate: out = 1 if {a == 1 or b == 1}, 0 otherwise + */ + +CHIP Or { + + IN a, b; + OUT out; + + BUILTIN Or; +} diff --git a/tools/builtInChips/Or16.hdl b/tools/builtInChips/Or16.hdl new file mode 100755 index 0000000..6c124e8 --- /dev/null +++ b/tools/builtInChips/Or16.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Or16.hdl + +/** + * 16-bit bitwise Or gate: for i = 0..15 out[i] = a[i] or b[i]. + */ + +CHIP Or16 { + + IN a[16], b[16]; + OUT out[16]; + + BUILTIN Or; +} diff --git a/tools/builtInChips/Or8Way.class b/tools/builtInChips/Or8Way.class new file mode 100755 index 0000000..104804b Binary files /dev/null and b/tools/builtInChips/Or8Way.class differ diff --git a/tools/builtInChips/Or8Way.hdl b/tools/builtInChips/Or8Way.hdl new file mode 100755 index 0000000..dccd61d --- /dev/null +++ b/tools/builtInChips/Or8Way.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Or8Way.hdl + +/** + * 8-way Or gate: out = in[0] or in[1] or ... or in[7]. + */ + +CHIP Or8Way { + + IN in[8]; + OUT out; + + BUILTIN Or8Way; +} diff --git a/tools/builtInChips/PC.class b/tools/builtInChips/PC.class new file mode 100755 index 0000000..1e6ada1 Binary files /dev/null and b/tools/builtInChips/PC.class differ diff --git a/tools/builtInChips/PC.hdl b/tools/builtInChips/PC.hdl new file mode 100755 index 0000000..f102d99 --- /dev/null +++ b/tools/builtInChips/PC.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/PC.hdl + +/** + * 16-bit counter with load and reset controls. + * + * If reset(t-1) then out(t) = 0 + * else if load(t-1) then out(t) = in(t-1) + * else if inc(t-1) then out(t) = out(t-1) + 1 (integer addition) + * else out(t) = out(t-1) + */ + +CHIP PC { + + IN in[16], load, inc, reset; + OUT out[16]; + + BUILTIN PC; + CLOCKED in, load, inc, reset; +} diff --git a/tools/builtInChips/RAM.class b/tools/builtInChips/RAM.class new file mode 100755 index 0000000..e17050f Binary files /dev/null and b/tools/builtInChips/RAM.class differ diff --git a/tools/builtInChips/RAM16K.class b/tools/builtInChips/RAM16K.class new file mode 100755 index 0000000..2f1e3fe Binary files /dev/null and b/tools/builtInChips/RAM16K.class differ diff --git a/tools/builtInChips/RAM16K.hdl b/tools/builtInChips/RAM16K.hdl new file mode 100755 index 0000000..7031bf9 --- /dev/null +++ b/tools/builtInChips/RAM16K.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM16K.hdl + +/** + * Memory of 16K registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM16K[address(t)](t) + * Write: If load(t-1) then RAM16K[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load=1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM16K { + + IN in[16], load, address[14]; + OUT out[16]; + + BUILTIN RAM16K; + CLOCKED in, load; +} diff --git a/tools/builtInChips/RAM4K.class b/tools/builtInChips/RAM4K.class new file mode 100755 index 0000000..164ebf8 Binary files /dev/null and b/tools/builtInChips/RAM4K.class differ diff --git a/tools/builtInChips/RAM4K.hdl b/tools/builtInChips/RAM4K.hdl new file mode 100755 index 0000000..8f1b211 --- /dev/null +++ b/tools/builtInChips/RAM4K.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM4K.hdl + +/** + * Memory of 4K registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM4K[address(t)](t) + * Write: If load(t-1) then RAM4K[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM4K { + + IN in[16], load, address[12]; + OUT out[16]; + + BUILTIN RAM4K; + CLOCKED in, load; +} diff --git a/tools/builtInChips/RAM512.class b/tools/builtInChips/RAM512.class new file mode 100755 index 0000000..69bff7a Binary files /dev/null and b/tools/builtInChips/RAM512.class differ diff --git a/tools/builtInChips/RAM512.hdl b/tools/builtInChips/RAM512.hdl new file mode 100755 index 0000000..2a2f433 --- /dev/null +++ b/tools/builtInChips/RAM512.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM512.hdl + +/** + * Memory of 512 registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM512[address(t)](t) + * Write: If load(t-1) then RAM512[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM512 { + + IN in[16], load, address[9]; + OUT out[16]; + + BUILTIN RAM512; + CLOCKED in, load; +} diff --git a/tools/builtInChips/RAM64.class b/tools/builtInChips/RAM64.class new file mode 100755 index 0000000..a1fe78a Binary files /dev/null and b/tools/builtInChips/RAM64.class differ diff --git a/tools/builtInChips/RAM64.hdl b/tools/builtInChips/RAM64.hdl new file mode 100755 index 0000000..6f32f47 --- /dev/null +++ b/tools/builtInChips/RAM64.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM64.hdl + +/** + * Memory of 64 registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM64[address(t)](t) + * Write: If load(t-1) then RAM64[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM64 { + + IN in[16], load, address[6]; + OUT out[16]; + + BUILTIN RAM64; + CLOCKED in, load; +} diff --git a/tools/builtInChips/RAM8.class b/tools/builtInChips/RAM8.class new file mode 100755 index 0000000..88f106e Binary files /dev/null and b/tools/builtInChips/RAM8.class differ diff --git a/tools/builtInChips/RAM8.hdl b/tools/builtInChips/RAM8.hdl new file mode 100755 index 0000000..c08d62c --- /dev/null +++ b/tools/builtInChips/RAM8.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/RAM8.hdl + +/** + * Memory of 8 registers, each 16-bit wide. + * The chip facilitates read and write operations, as follows: + * Read: out(t) = RAM8[address(t)](t) + * Write: If load(t-1) then RAM8[address(t-1)](t) = in(t-1) + * In words: the chip always outputs the value stored at the memory + * location specified by address. If load == 1, the in value is loaded + * into the memory location specified by address. This value becomes + * available through the out output starting from the next time step. + */ + +CHIP RAM8 { + + IN in[16], load, address[3]; + OUT out[16]; + + BUILTIN RAM8; + CLOCKED in, load; +} diff --git a/tools/builtInChips/ROM32K.class b/tools/builtInChips/ROM32K.class new file mode 100755 index 0000000..c4320d8 Binary files /dev/null and b/tools/builtInChips/ROM32K.class differ diff --git a/tools/builtInChips/ROM32K.hdl b/tools/builtInChips/ROM32K.hdl new file mode 100755 index 0000000..929f824 --- /dev/null +++ b/tools/builtInChips/ROM32K.hdl @@ -0,0 +1,30 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/ROM32K.hdl + +/** + * Read-Only memory (ROM) of 16K registers, each 16-bit wide. + * The chip is designed to facilitate data read, as follows: + * out(t) = ROM32K[address(t)](t) + * In words: the chip always outputs the value stored at the + * memory location specified by address. + * + * The built-in chip implementation has a GUI side-effect, + * showing an array-like component that displays the ROM's + * contents. The ROM32K chip is supposed to be pre-loaded with + * a machine language program. To that end, the built-in chip + * implementation also knows how to handle the "ROM32K load Xxx" + * script command, where Xxx is the name of a text file containing + * a program written in the Hack machine language. When the + * simulator encounters such a command in a test script, the code + * found in the file is loaded into the simulated ROM32K unit. + */ + +CHIP ROM32K { + + IN address[15]; + OUT out[16]; + + BUILTIN ROM32K; +} diff --git a/tools/builtInChips/Register.class b/tools/builtInChips/Register.class new file mode 100755 index 0000000..3958fcd Binary files /dev/null and b/tools/builtInChips/Register.class differ diff --git a/tools/builtInChips/Register.hdl b/tools/builtInChips/Register.hdl new file mode 100755 index 0000000..3b81e46 --- /dev/null +++ b/tools/builtInChips/Register.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Register.hdl + +/** + * 16-Bit register. + * If load[t-1]=1 then out[t] = in[t-1] + * else out does not change (out[t] = out[t-1]) + */ + +CHIP Register { + + IN in[16], load; + OUT out[16]; + + BUILTIN Register; + CLOCKED in, load; +} diff --git a/tools/builtInChips/RegisterWithGUI.class b/tools/builtInChips/RegisterWithGUI.class new file mode 100755 index 0000000..c80208c Binary files /dev/null and b/tools/builtInChips/RegisterWithGUI.class differ diff --git a/tools/builtInChips/Screen.class b/tools/builtInChips/Screen.class new file mode 100755 index 0000000..100ed03 Binary files /dev/null and b/tools/builtInChips/Screen.class differ diff --git a/tools/builtInChips/Screen.hdl b/tools/builtInChips/Screen.hdl new file mode 100755 index 0000000..5e7837b --- /dev/null +++ b/tools/builtInChips/Screen.hdl @@ -0,0 +1,35 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Screen.hdl + +/** + * The Screen (memory map). + * Functions exactly like a 16-bit 8K RAM: + * 1. out(t)=Screen[address(t)](t) + * 2. If load(t-1) then Screen[address(t-1)](t)=in(t-1) + * + * The built-in chip implementation has the side effect of continuously + * refreshing a visual 256 by 512 black-and-white screen, simulated + * by the simulator. Each row in the visual screen is represented + * by 32 consecutive 16-bit words, starting at the top left corner + * of the visual screen. Thus the pixel at row r from the top and + * column c from the left (0<=r<=255, 0<=c<=511) reflects the c%16 + * bit (counting from LSB to MSB) of the word found in + * Screen[r*32+c/16]. + */ + +CHIP Screen { + + IN in[16], // what to write + load, // write-enable bit + address[13]; // where to read/write + OUT out[16]; // Screen value at the given address + + BUILTIN Screen; + CLOCKED in, load; +} + + + + \ No newline at end of file diff --git a/tools/builtInChips/Xor.class b/tools/builtInChips/Xor.class new file mode 100755 index 0000000..d99ad18 Binary files /dev/null and b/tools/builtInChips/Xor.class differ diff --git a/tools/builtInChips/Xor.hdl b/tools/builtInChips/Xor.hdl new file mode 100755 index 0000000..8452d73 --- /dev/null +++ b/tools/builtInChips/Xor.hdl @@ -0,0 +1,16 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: tools/builtIn/Xor.hdl + +/** + * Exclusive-or gate: out = !(a == b). + */ + +CHIP Xor { + + IN a, b; + OUT out; + + BUILTIN Xor; +} diff --git a/tools/builtInVMCode/Array.class b/tools/builtInVMCode/Array.class new file mode 100755 index 0000000..c76b652 Binary files /dev/null and b/tools/builtInVMCode/Array.class differ diff --git a/tools/builtInVMCode/JackOSClass.class b/tools/builtInVMCode/JackOSClass.class new file mode 100755 index 0000000..25df72a Binary files /dev/null and b/tools/builtInVMCode/JackOSClass.class differ diff --git a/tools/builtInVMCode/Keyboard.class b/tools/builtInVMCode/Keyboard.class new file mode 100755 index 0000000..7366f75 Binary files /dev/null and b/tools/builtInVMCode/Keyboard.class differ diff --git a/tools/builtInVMCode/Math.class b/tools/builtInVMCode/Math.class new file mode 100755 index 0000000..71aef91 Binary files /dev/null and b/tools/builtInVMCode/Math.class differ diff --git a/tools/builtInVMCode/Memory.class b/tools/builtInVMCode/Memory.class new file mode 100755 index 0000000..e9bb7ad Binary files /dev/null and b/tools/builtInVMCode/Memory.class differ diff --git a/tools/builtInVMCode/Output.class b/tools/builtInVMCode/Output.class new file mode 100755 index 0000000..65b25b7 Binary files /dev/null and b/tools/builtInVMCode/Output.class differ diff --git a/tools/builtInVMCode/Screen.class b/tools/builtInVMCode/Screen.class new file mode 100755 index 0000000..8644e09 Binary files /dev/null and b/tools/builtInVMCode/Screen.class differ diff --git a/tools/builtInVMCode/String.class b/tools/builtInVMCode/String.class new file mode 100755 index 0000000..98c7f58 Binary files /dev/null and b/tools/builtInVMCode/String.class differ diff --git a/tools/builtInVMCode/Sys.class b/tools/builtInVMCode/Sys.class new file mode 100755 index 0000000..0c15f1b Binary files /dev/null and b/tools/builtInVMCode/Sys.class differ