aboutsummaryrefslogtreecommitdiff
path: root/projects/07/MemoryAccess
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2018-01-03 11:49:20 +0100
committerYuchen Pei <me@ypei.me>2018-01-03 11:49:20 +0100
commit040cf91851036a0216e7b5faea1f74ecd674db50 (patch)
tree0bb654c38f734cae0aafbbfa8dacf673d270b48b /projects/07/MemoryAccess
parent98111ae037b165ca8deb2d0b73d3194a1e71d45c (diff)
Finished Project 7
Diffstat (limited to 'projects/07/MemoryAccess')
-rw-r--r--projects/07/MemoryAccess/BasicTest/BasicTest.asm250
-rw-r--r--projects/07/MemoryAccess/BasicTest/BasicTest.out2
-rw-r--r--projects/07/MemoryAccess/BasicTest/delme.asm26
-rw-r--r--projects/07/MemoryAccess/BasicTest/delme.vm8
-rw-r--r--projects/07/MemoryAccess/PointerTest/PointerTest.asm138
-rw-r--r--projects/07/MemoryAccess/PointerTest/PointerTest.out2
-rw-r--r--projects/07/MemoryAccess/StaticTest/StaticTest.asm86
-rw-r--r--projects/07/MemoryAccess/StaticTest/StaticTest.out2
8 files changed, 514 insertions, 0 deletions
diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.asm b/projects/07/MemoryAccess/BasicTest/BasicTest.asm
new file mode 100644
index 0000000..d978f07
--- /dev/null
+++ b/projects/07/MemoryAccess/BasicTest/BasicTest.asm
@@ -0,0 +1,250 @@
+@256
+D=A
+@SP
+M=D
+@10
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@LCL
+D=M
+@0
+D=A+D
+@R13
+M=D
+@SP
+AM=M-1
+D=M
+@R13
+A=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
+@ARG
+D=M
+@2
+D=A+D
+@R13
+M=D
+@SP
+AM=M-1
+D=M
+@R13
+A=M
+M=D
+@ARG
+D=M
+@1
+D=A+D
+@R13
+M=D
+@SP
+AM=M-1
+D=M
+@R13
+A=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=M+1
+(END)
+@END
+0;JMP \ No newline at end of file
diff --git a/projects/07/MemoryAccess/BasicTest/BasicTest.out b/projects/07/MemoryAccess/BasicTest/BasicTest.out
new file mode 100644
index 0000000..85c19a7
--- /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/delme.asm b/projects/07/MemoryAccess/BasicTest/delme.asm
new file mode 100644
index 0000000..6392181
--- /dev/null
+++ b/projects/07/MemoryAccess/BasicTest/delme.asm
@@ -0,0 +1,26 @@
+@256
+D=A
+@SP
+M=D
+@10
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@LCL
+D=M
+@0
+D=A+D
+@R13
+M=D
+@SP
+AM=M-1
+D=M
+@R13
+A=M
+M=D
+(END)
+@END
+0;JMP \ No newline at end of file
diff --git a/projects/07/MemoryAccess/BasicTest/delme.vm b/projects/07/MemoryAccess/BasicTest/delme.vm
new file mode 100644
index 0000000..d1ae195
--- /dev/null
+++ b/projects/07/MemoryAccess/BasicTest/delme.vm
@@ -0,0 +1,8 @@
+// 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
diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.asm b/projects/07/MemoryAccess/PointerTest/PointerTest.asm
new file mode 100644
index 0000000..67125df
--- /dev/null
+++ b/projects/07/MemoryAccess/PointerTest/PointerTest.asm
@@ -0,0 +1,138 @@
+@256
+D=A
+@SP
+M=D
+@3030
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@3
+M=D
+@3040
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@4
+M=D
+@32
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@THIS
+D=M
+@2
+D=A+D
+@R13
+M=D
+@SP
+AM=M-1
+D=M
+@R13
+A=M
+M=D
+@46
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@THAT
+D=M
+@6
+D=A+D
+@R13
+M=D
+@SP
+AM=M-1
+D=M
+@R13
+A=M
+M=D
+@3
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@4
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@SP
+AM=M-1
+D=M+D
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@THIS
+D=M
+@2
+D=A+D
+A=D
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@SP
+AM=M-1
+D=M-D
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@THAT
+D=M
+@6
+D=A+D
+A=D
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@SP
+AM=M-1
+D=M+D
+@SP
+A=M
+M=D
+@SP
+M=M+1
+(END)
+@END
+0;JMP \ No newline at end of file
diff --git a/projects/07/MemoryAccess/PointerTest/PointerTest.out b/projects/07/MemoryAccess/PointerTest/PointerTest.out
new file mode 100644
index 0000000..5d62de8
--- /dev/null
+++ b/projects/07/MemoryAccess/PointerTest/PointerTest.out
@@ -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/StaticTest/StaticTest.asm b/projects/07/MemoryAccess/StaticTest/StaticTest.asm
new file mode 100644
index 0000000..8cd989d
--- /dev/null
+++ b/projects/07/MemoryAccess/StaticTest/StaticTest.asm
@@ -0,0 +1,86 @@
+@256
+D=A
+@SP
+M=D
+@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
+AM=M-1
+D=M
+@StaticTest.8
+M=D
+@SP
+AM=M-1
+D=M
+@StaticTest.3
+M=D
+@SP
+AM=M-1
+D=M
+@StaticTest.1
+M=D
+@StaticTest.3
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@StaticTest.1
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@SP
+AM=M-1
+D=M-D
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@StaticTest.8
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@SP
+AM=M-1
+D=M+D
+@SP
+A=M
+M=D
+@SP
+M=M+1
+(END)
+@END
+0;JMP \ No newline at end of file
diff --git a/projects/07/MemoryAccess/StaticTest/StaticTest.out b/projects/07/MemoryAccess/StaticTest/StaticTest.out
new file mode 100644
index 0000000..2bc908b
--- /dev/null
+++ b/projects/07/MemoryAccess/StaticTest/StaticTest.out
@@ -0,0 +1,2 @@
+|RAM[256]|
+| 1110 |