summaryrefslogtreecommitdiff
path: root/projects/08/ProgramFlow/FibonacciSeries
diff options
context:
space:
mode:
Diffstat (limited to 'projects/08/ProgramFlow/FibonacciSeries')
-rw-r--r--projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm214
1 files changed, 214 insertions, 0 deletions
diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm
new file mode 100644
index 0000000..e84fad0
--- /dev/null
+++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm
@@ -0,0 +1,214 @@
+@ARG
+D=M
+@1
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@THAT
+M=D
+@0
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@0
+D=A
+@THAT
+M=M+D
+@SP
+AM=M-1
+D=M
+@THAT
+A=M
+M=D
+@0
+D=A
+@THAT
+M=M-D
+@1
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@1
+D=A
+@THAT
+M=M+D
+@SP
+AM=M-1
+D=M
+@THAT
+A=M
+M=D
+@1
+D=A
+@THAT
+M=M-D
+@ARG
+D=M
+@0
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@2
+D=A
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+A=A-1
+M=M-D
+@0
+D=A
+@ARG
+M=M+D
+@SP
+AM=M-1
+D=M
+@ARG
+A=M
+M=D
+@0
+D=A
+@ARG
+M=M-D
+(MAIN_LOOP_START)
+@ARG
+D=M
+@0
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@SP
+AM=M-1
+D=M
+@COMPUTE_ELEMENT
+D;JNE
+@END_PROGRAM
+0;JMP
+(COMPUTE_ELEMENT)
+@THAT
+D=M
+@0
+A=D+A
+D=M
+@SP
+A=M
+M=D
+@SP
+M=M+1
+@TH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