|
@@ -1,13 +1,14 @@
|
|
|
-ld @regA, 0 // jz, seq, lt register
|
|
|
+ld @regA, 0 // jz, seq register
|
|
|
+ld @regB, 0 // storage space
|
|
|
ld @counter, 10 // loop counter
|
|
|
ld @lower, 0 // lower number
|
|
|
ld @higher, 1 // higher number
|
|
|
-ld @regB, 0 // storage space
|
|
|
Fibonacci:
|
|
|
add @higher, 0, @regB // Move higher number to a storage point
|
|
|
add @higher, @lower, @higher // Add higher and lower number, and store in higher number slot
|
|
|
+out @higher // Output the current highest number
|
|
|
add @regB, 0, @lower // Move stored number to lower number slot
|
|
|
add @counter, -1, @counter // Subtract 1 from the loop counter
|
|
|
seq @counter, 0, @regA // Check if the loop counter is 0
|
|
|
-jz @regA, Fibonacci + 1 // Loop the function if not
|
|
|
+jz @regA, Fibonacci // Loop the function if not
|
|
|
hlt // Otherwise, exit
|