aboutsummaryrefslogtreecommitdiff
path: root/projects/08/FunctionCalls
diff options
context:
space:
mode:
Diffstat (limited to 'projects/08/FunctionCalls')
-rw-r--r--projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm16
-rw-r--r--projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm11
-rw-r--r--projects/08/FunctionCalls/StaticsTest/StaticsTest.asm586
-rw-r--r--projects/08/FunctionCalls/StaticsTest/StaticsTest.out2
4 files changed, 606 insertions, 9 deletions
diff --git a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm
index 9d98a3f..a2ca368 100644
--- a/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm
+++ b/projects/08/FunctionCalls/FibonacciElement/FibonacciElement.asm
@@ -114,6 +114,11 @@ M=M+1
D=M
@R13
M=D
+@5
+A=D-A
+D=M
+@R14
+M=D
@SP
AM=M-1
D=M
@@ -144,8 +149,7 @@ AM=M-1
D=M
@LCL
M=D
-@R13
-A=M-1
+@R14
A=M
0;JMP
(Main.fibonacci$IF_FALSE)
@@ -318,6 +322,11 @@ M=M+1
D=M
@R13
M=D
+@5
+A=D-A
+D=M
+@R14
+M=D
@SP
AM=M-1
D=M
@@ -348,8 +357,7 @@ AM=M-1
D=M
@LCL
M=D
-@R13
-A=M-1
+@R14
A=M
0;JMP
(Sys.init)
diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm
index 7fe71a5..de3a0da 100644
--- a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm
+++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm
@@ -98,6 +98,11 @@ M=M+1
D=M
@R13
M=D
+@5
+A=D-A
+D=M
+@R14
+M=D
@SP
AM=M-1
D=M
@@ -128,10 +133,6 @@ AM=M-1
D=M
@LCL
M=D
-@R13
-A=M-1
+@R14
A=M
0;JMP
-(END)
-@END
-0;JMP \ No newline at end of file
diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm b/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm
new file mode 100644
index 0000000..2d6f2aa
--- /dev/null
+++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm
@@ -0,0 +1,586 @@
+@256
+D=A
+@SP
+M=D
+@RET0
+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
+@LCL
+M=D
+@5
+D=D-A
+@0
+D=D-A
+@ARG
+M=D
+@Sys.init
+0;JMP
+(RET0)
+(Class2.set)
+@ARG
+D=M
+@0
+D=A+D
+A=D
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@Class2.0
+M=D
+@ARG
+D=M
+@1
+D=A+D
+A=D
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@Class2.1
+M=D
+@0
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@LCL
+D=M
+@R13
+M=D
+@5
+A=D-A
+D=M
+@R14
+M=D
+@SP
+AM=M-1
+D=M
+@ARG
+A=M
+M=D
+@ARG
+D=M+1
+@SP
+M=D
+@R13
+AM=M-1
+D=M
+@THAT
+M=D
+@R13
+AM=M-1
+D=M
+@THIS
+M=D
+@R13
+AM=M-1
+D=M
+@ARG
+M=D
+@R13
+AM=M-1
+D=M
+@LCL
+M=D
+@R14
+A=M
+0;JMP
+(Class2.get)
+@Class2.0
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@Class2.1
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+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P
+(Class1.get)
+@Class1.0
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@Class1.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
+@LCL
+D=M
+@R13
+M=D
+@5
+A=D-A
+D=M
+@R14
+M=D
+@SP
+AM=M-1
+D=M
+@ARG
+A=M
+M=D
+@ARG
+D=M+1
+@SP
+M=D
+@R13
+AM=M-1
+D=M
+@THAT
+M=D
+@R13
+AM=M-1
+D=M
+@THIS
+M=D
+@R13
+AM=M-1
+D=M
+@ARG
+M=D
+@R13
+AM=M-1
+D=M
+@LCL
+M=D
+@R14
+A=M
+0;JMP
diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTest.out b/projects/08/FunctionCalls/StaticsTest/StaticsTest.out
new file mode 100644
index 0000000..309f058
--- /dev/null
+++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.out
@@ -0,0 +1,2 @@
+| RAM[0] |RAM[261]|RAM[262]|
+| 263 | -2 | 8 |