summaryrefslogtreecommitdiff
path: root/projects/07/StackArithmetic
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-08-22 17:04:49 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-08-22 17:04:49 +0800
commit21c58570d3897f1f480b6cf6c572c350e7a0dd95 (patch)
treeeed5ff515d322439ab843e009b00faed0e30e9c8 /projects/07/StackArithmetic
parent10c9f64f592198d78aad11ebc676629d92ca6576 (diff)
Output assembly files in project 07
Diffstat (limited to 'projects/07/StackArithmetic')
-rw-r--r--projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm19
-rw-r--r--projects/07/StackArithmetic/StackTest/StackTest.asm295
2 files changed, 314 insertions, 0 deletions
diff --git a/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm
new file mode 100644
index 0000000..71d9d8d
--- /dev/null
+++ b/projects/07/StackArithmetic/SimpleAdd/SimpleAdd.asm
@@ -0,0 +1,19 @@
+@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
+AM=M-1
+D=M
+A=A-1
+M=D+M
diff --git a/projects/07/StackArithmetic/StackTest/StackTest.asm b/projects/07/StackArithmetic/StackTest/StackTest.asm
new file mode 100644
index 0000000..b0d944a
--- /dev/null
+++ b/projects/07/StackArithmetic/StackTest/StackTest.asm
@@ -0,0 +1,295 @@
+@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
+AM=M-1
+D=M
+A=A-1
+D=M-D
+M=0
+@END_EQ_0
+D;JNE
+@SP
+A=M-1
+M=-1
+(END_EQ_0)
+@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
+AM=M-1
+D=M
+A=A-1
+D=M-D
+M=0
+@END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