12345678910111213 |
- ld 0d19, 0 // jpt, jpf, eq, lt register
- ld 0d20, 10 // loop counter
- ld 0d30, 0 // lower number
- ld 0d31, 1 // higher number
- ld 0d33, 0 // storage space
- Fibonacci:
- add 0d31, 0, 0d33 // Move higher number to a storage point
- add 0d31, 0d30, 0d31 // Add higher and lower number, and store in higher number slot
- add 0d33, 0, 0d30 // Move stored number to lower number slot
- add 0d20, -1, 0d20 // Subtract 1 from the loop counter
- eq 0d20, 0, 0d19 // Check if the loop counter is 0
- jpf 0d19, Fibonacci + 1 // Loop the function if not
- hlt // Otherwise, exit
|