diff options
Diffstat (limited to 'projects/08/FunctionCalls/SimpleFunction')
-rw-r--r-- | projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm new file mode 100644 index 0000000..174d7c3 --- /dev/null +++ b/projects/08/FunctionCalls/SimpleFunction/SimpleFunction.asm @@ -0,0 +1,115 @@ +// function SimpleFunction.test 2 +(SimpleFunction.test) +@SP +A=M +M=0 +@SP +AM=M+1 +M=0 +@SP +M=M+1 +// push local 0 +@LCL +D=M +@0 +A=D+A +D=M +@SP +A=M +M=D +@SP +M=M+1 +// push local 1 +@LCL +D=M +@1 +A=D+A +D=M +@SP +A=M +M=D +@SP +M=M+1 +// add +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +// not +@SP +A=M-1 +M=!M +// push argument 0 +@ARG +D=M +@0 +A=D+A +D=M +@SP +A=M +M=D +@SP +M=M+1 +// add +@SP +AM=M-1 +D=M +A=A-1 +M=D+M +// push argument 1 +@ARG +D=M +@1 +A=D+A +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 +@ARG +A=M +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 |