aboutsummaryrefslogtreecommitdiff
path: root/projects/08/ProgramFlow
diff options
context:
space:
mode:
Diffstat (limited to 'projects/08/ProgramFlow')
-rw-r--r--projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm16
-rw-r--r--projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries1.asm241
2 files changed, 247 insertions, 10 deletions
diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm
index 68a4c8e..3f06978 100644
--- a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm
+++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm
@@ -1,7 +1,3 @@
-@256
-D=A
-@SP
-M=D
@ARG
D=M
@1
@@ -97,7 +93,7 @@ D=M
@R13
A=M
M=D
-(MAIN_LOOP_START)
+($MAIN_LOOP_START)
@ARG
D=M
@0
@@ -112,11 +108,11 @@ M=M+1
@SP
AM=M-1
D=M
-@COMPUTE_ELEMENT
+@$COMPUTE_ELEMENT
D;JNE
-@END_PROGRAM
+@$END_PROGRAM
0;JMP
-(COMPUTE_ELEMENT)
+($COMPUTE_ELEMENT)
@THAT
D=M
@0
@@ -233,9 +229,9 @@ D=M
@R13
A=M
M=D
-@MAIN_LOOP_START
+@$MAIN_LOOP_START
0;JMP
-(END_PROGRAM)
+($END_PROGRAM)
(END)
@END
0;JMP \ No newline at end of file
diff --git a/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries1.asm b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries1.asm
new file mode 100644
index 0000000..68a4c8e
--- /dev/null
+++ b/projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries1.asm
@@ -0,0 +1,241 @@
+@256
+D=A
+@SP
+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
+@4
+M=D
+@0
+D=A
+@SP
+A=M
+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