labels.icasm 779 B

1234567891011121314
  1. ld @regA, 0 // jz, seq register
  2. ld @regB, 0 // storage space
  3. ld @counter, 10 // loop counter
  4. ld @lower, 0 // lower number
  5. ld @higher, 1 // higher number
  6. Fibonacci:
  7. add @higher, 0, @regB // Move higher number to a storage point
  8. add @higher, @lower, @higher // Add higher and lower number, and store in higher number slot
  9. out @higher // Output the current highest number
  10. add @regB, 0, @lower // Move stored number to lower number slot
  11. add @counter, -1, @counter // Subtract 1 from the loop counter
  12. seq @counter, 0, @regA // Check if the loop counter is 0
  13. jz @regA, Fibonacci // Loop the function if not
  14. hlt // Otherwise, exit