diff --git a/.gitignore b/projects/.gitignore
similarity index 100%
rename from .gitignore
rename to projects/.gitignore
diff --git a/tools/OS/Memory.vm b/tools/OS/Memory.vm
index 28fe8a5..51a3660 100644
--- a/tools/OS/Memory.vm
+++ b/tools/OS/Memory.vm
@@ -37,9 +37,9 @@ push temp 0
pop that 0
push constant 0
return
-function Memory.alloc 1
+function Memory.alloc 2
push argument 0
-push constant 1
+push constant 0
lt
if-goto IF_TRUE0
goto IF_FALSE0
@@ -48,9 +48,21 @@ 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
@@ -58,6 +70,7 @@ pop pointer 1
push that 0
push argument 0
lt
+and
not
if-goto WHILE_END0
push constant 1
@@ -65,7 +78,91 @@ 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
@@ -73,13 +170,13 @@ push argument 0
add
push constant 16379
gt
-if-goto IF_TRUE1
-goto IF_FALSE1
-label IF_TRUE1
+if-goto IF_TRUE4
+goto IF_FALSE4
+label IF_TRUE4
push constant 6
call Sys.error 1
pop temp 0
-label IF_FALSE1
+label IF_FALSE4
push constant 0
push local 0
add
@@ -89,9 +186,9 @@ push argument 0
push constant 2
add
gt
-if-goto IF_TRUE2
-goto IF_FALSE2
-label IF_TRUE2
+if-goto IF_TRUE5
+goto IF_FALSE5
+label IF_TRUE5
push argument 0
push constant 2
add
@@ -119,9 +216,9 @@ push local 0
push constant 2
add
eq
-if-goto IF_TRUE3
-goto IF_FALSE3
-label IF_TRUE3
+if-goto IF_TRUE6
+goto IF_FALSE6
+label IF_TRUE6
push argument 0
push constant 3
add
@@ -136,8 +233,8 @@ pop temp 0
pop pointer 1
push temp 0
pop that 0
-goto IF_END3
-label IF_FALSE3
+goto IF_END6
+label IF_FALSE6
push argument 0
push constant 3
add
@@ -152,7 +249,7 @@ pop temp 0
pop pointer 1
push temp 0
pop that 0
-label IF_END3
+label IF_END6
push constant 1
push local 0
add
@@ -165,7 +262,7 @@ pop temp 0
pop pointer 1
push temp 0
pop that 0
-label IF_FALSE2
+label IF_FALSE5
push constant 0
push local 0
add
diff --git a/tools/OS/Sys.vm b/tools/OS/Sys.vm
index df9209c..ae9261e 100644
--- a/tools/OS/Sys.vm
+++ b/tools/OS/Sys.vm
@@ -65,15 +65,14 @@ label WHILE_END0
push constant 0
return
function Sys.error 0
-push constant 3
-call String.new 1
push constant 69
-call String.appendChar 2
+call Output.printChar 1
+pop temp 0
push constant 82
-call String.appendChar 2
+call Output.printChar 1
+pop temp 0
push constant 82
-call String.appendChar 2
-call Output.printString 1
+call Output.printChar 1
pop temp 0
push argument 0
call Output.printInt 1
diff --git a/tools/bin/classes/CPUEmulatorMain.class b/tools/bin/classes/CPUEmulatorMain.class
new file mode 100644
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 100644
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 100644
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 100644
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 100644
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 100644
index 0000000..3bc11c8
--- /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 100644
index 0000000..daeb6e8
--- /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 100644
index 0000000..2152f03
--- /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 100644
index 0000000..ff70ba5
--- /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 100644
index 0000000..e6e0a43
--- /dev/null
+++ b/tools/bin/help/cpuUsage.html
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
+
+Usage instruction and tips can be found in:
+
+
+
+
+
+
+
+