aboutsummaryrefslogtreecommitdiff
path: root/projects/07/MemoryAccess/PointerTest
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2017-11-29 12:30:41 +0100
committerYuchen Pei <me@ypei.me>2017-11-29 12:30:41 +0100
commita000308104aab27c2dde9a306f1bc654b2db4806 (patch)
treeaecc628e14c1628b5714281437aba18680cdc27b /projects/07/MemoryAccess/PointerTest
first commit
Diffstat (limited to 'projects/07/MemoryAccess/PointerTest')
-rw-r--r--projects/07/MemoryAccess/PointerTest/PointerTest.cmp2
-rw-r--r--projects/07/MemoryAccess/PointerTest/PointerTest.tst20
-rw-r--r--projects/07/MemoryAccess/PointerTest/PointerTest.vm22
-rw-r--r--projects/07/MemoryAccess/PointerTest/PointerTestVME.tst20
4 files changed, 64 insertions, 0 deletions
diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.cmp b/projects/07/MemoryAccess/PointerTest/PointerTest.cmp
new file mode 100644
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 100644
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 100644
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 100644
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;