labels.icasm 658 B

12345678910111213
  1. ld 0d19, 0 // jpt, jpf, eq, lt register
  2. ld 0d20, 10 // loop counter
  3. ld 0d30, 0 // lower number
  4. ld 0d31, 1 // higher number
  5. ld 0d33, 0 // storage space
  6. Fibonacci:
  7. add 0d31, 0, 0d33 // Move higher number to a storage point
  8. add 0d31, 0d30, 0d31 // Add higher and lower number, and store in higher number slot
  9. add 0d33, 0, 0d30 // Move stored number to lower number slot
  10. add 0d20, -1, 0d20 // Subtract 1 from the loop counter
  11. eq 0d20, 0, 0d19 // Check if the loop counter is 0
  12. jpf 0d19, Fibonacci + 1 // Loop the function if not
  13. hlt // Otherwise, exit