summaryrefslogtreecommitdiff
path: root/projects/08/FunctionCalls/StaticsTest
diff options
context:
space:
mode:
Diffstat (limited to 'projects/08/FunctionCalls/StaticsTest')
-rw-r--r--projects/08/FunctionCalls/StaticsTest/StaticsTest.asm539
1 files changed, 539 insertions, 0 deletions
diff --git a/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm b/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm
new file mode 100644
index 0000000..df3fe36
--- /dev/null
+++ b/projects/08/FunctionCalls/StaticsTest/StaticsTest.asm
@@ -0,0 +1,539 @@
+@256
+D=A
+@SP
+M=D
+@StaticsTest$ret_init
+D=A
+@SP
+A=M
+M=D
+@LCL
+D=M
+@SP
+AM=M+1
+M=D
+@ARG
+D=M
+@SP
+AM=M+1
+M=D
+@THIS
+D=M
+@SP
+AM=M+1
+M=D
+@THAT
+D=M
+@SP
+AM=M+1
+M=D
+@SP
+MD=M+1
+@LCL
+M=D
+@5
+D=D-A
+@ARG
+M=D
+@Sys.init
+0;JMP
+(StaticsTest$ret_init)
+// function Class2.set 0
+(Class2.set)
+// push argument 0
+@ARG
+D=M
+@0
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// pop static 0
+@SP
+AM=M-1
+D=M
+@Class2.0
+M=D
+// push argument 1
+@ARG
+D=M
+@1
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// pop static 1
+@SP
+AM=M-1
+D=M
+@Class2.1
+M=D
+// push constant 0
+@0
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// return
+@LCL
+D=M
+@5
+A=D-A
+D=M
+@R13
+M=D
+@SP
+A=M-1
+D=M
+@ARG
+A=M
+M=D
+@ARG
+D=M+1
+@SP
+M=D
+@LCL
+AM=M-1
+D=M
+@THAT
+M=D
+@LCL
+AM=M-1
+D=M
+@THIS
+M=D
+@LCL
+AM=M-1
+D=M
+@ARG
+M=D
+@LCL
+AM=M-1
+D=M
+@LCL
+M=D
+@R13
+A=M
+0;JMP
+// function Class2.get 0
+(Class2.get)
+// push static 0
+@Class2.0
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// push static 1
+@Class2.1
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// sub
+@SP
+AM=M-1
+D=M
+A=A-1
+M=M-D
+// return
+@LCL
+D=M
+@5
+A=D-A
+D=M
+@R13
+M=D
+@SP
+A=M-1
+D=M
+@ARG
+A=M
+M=D
+@ARG
+D=M+1
+@SP
+M=D
+@LCL
+AM=M-1
+D=M
+@THAT
+M=D
+@LCL
+AM=M-1
+D=M
+@THIS
+M=D
+@LCL
+AM=M-1
+D=M
+@ARG
+M=D
+@LCL
+AM=M-1
+D=M
+@LCL
+M=D
+@R13
+A=M
+0;JMP
+// function Sys.init 0
+(Sys.init)
+// push constant 6
+@6
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// push constant 8
+@8
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// call Class1.set 2
+@Sys$ret.0
+D=A
+@SP
+A=M
+M=D
+@LCL
+D=M
+@SP
+AM=M+1
+M=D
+@ARG
+D=M
+@SP
+AM=M+1
+M=D
+@THIS
+D=M
+@SP
+AM=M+1
+M=D
+@THAT
+D=M
+@SP
+AM=M+1
+M=D
+@SP
+MD=M+1
+@LCL
+M=D
+@7
+D=D-A
+@ARG
+M=D
+@Class1.set
+0;JMP
+(Sys$ret.0)
+// pop temp 0
+@SP
+AM=M-1
+D=M
+@5
+M=D
+// push constant 23
+@23
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// push constant 15
+@15
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// call Class2.set 2
+@Sys$ret.1
+D=A
+@SP
+A=M
+M=D
+@LCL
+D=M
+@SP
+AM=M+1
+M=D
+@ARG
+D=M
+@SP
+AM=M+1
+M=D
+@THIS
+D=M
+@SP
+AM=M+1
+M=D
+@THAT
+D=M
+@SP
+AM=M+1
+M=D
+@SP
+MD=M+1
+@LCL
+M=D
+@7
+D=D-A
+@ARG
+M=D
+@Class2.set
+0;JMP
+(Sys$ret.1)
+// pop temp 0
+@SP
+AM=M-1
+D=M
+@5
+M=D
+// call Class1.get 0
+@Sys$ret.2
+D=A
+@SP
+A=M
+M=D
+@LCL
+D=M
+@SP
+AM=M+1
+M=D
+@ARG
+D=M
+@SP
+AM=M+1
+M=D
+@THIS
+D=M
+@SP
+AM=M+1
+M=D
+@THAT
+D=M
+@SP
+AM=M+1
+M=D
+@SP
+MD=M+1
+@LCL
+M=D
+@5
+D=D-A
+@ARG
+M=D
+@Class1.get
+0;JMP
+(Sys$ret.2)
+// call Class2.get 0
+@Sys$ret.3
+D=A
+@SP
+A=M
+M=D
+@LCL
+D=M
+@SP
+AM=M+1
+M=D
+@ARG
+D=M
+@SP
+AM=M+1
+M=D
+@THIS
+D=M
+@SP
+AM=M+1
+M=D
+@THAT
+D=M
+@SP
+AM=M+1
+M=D
+@SP
+MD=M+1
+@LCL
+M=D
+@5
+D=D-A
+@ARG
+M=D
+@Class2.get
+0;JMP
+(Sys$ret.3)
+// label WHILE
+(Sys$WHILE)
+// goto WHILE
+@Sys$WHILE
+0;JMP
+// function Class1.set 0
+(Class1.set)
+// push argument 0
+@ARG
+D=M
+@0
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// pop static 0
+@SP
+AM=M-1
+D=M
+@Class1.0
+M=D
+// push argument 1
+@ARG
+D=M
+@1
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// pop static 1
+@SP
+AM=M-1
+D=M
+@Class1.1
+M=D
+// push constant 0
+@0
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// return
+@LCL
+D=M
+@5
+A=D-A
+D=M
+@R13
+M=D
+@SP
+A=M-1
+D=M
+@ARG
+A=M
+M=D
+@ARG
+D=M+1
+@SP
+M=D
+@LCL
+AM=M-1
+D=M
+@THAT
+M=D
+@LCL
+AM=M-1
+D=M
+@THIS
+M=D
+@LCL
+AM=M-1
+D=M
+@ARG
+M=D
+@LCL
+AM=M-1
+D=M
+@LCL
+M=D
+@R13
+A=M
+0;JMP
+// function Class1.get 0
+(Class1.get)
+// push static 0
+@Class1.0
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// push static 1
+@Class1.1
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+// sub
+@SP
+AM=M-1
+D=M
+A=A-1
+M=M-D
+// return
+@LCL
+D=M
+@5
+A=D-A
+D=M
+@R13
+M=D
+@SP
+A=M-1
+D=M
+@ARG
+A=M
+M=D
+@ARG
+D=M+1
+@SP
+M=D
+@LCL
+AM=M-1
+D=M
+@THAT
+M=D
+@LCL
+AM=M-1
+D=M
+@THIS
+M=D
+@LCL
+AM=M-1
+D=M
+@ARG
+M=D
+@LCL
+AM=M-1
+D=M
+@LCL
+M=D
+@R13
+A=M
+0;JMP