Advertisement
sci4me

Relay CPU Fibonacci

Oct 18th, 2016
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. jmp start
  2.  
  3. .resb 1024
  4. stack: .resb 1
  5.  
  6.  
  7. .macro call 1
  8. push a
  9. push b
  10. push c
  11. push d
  12. jsr %1
  13. .endmacro
  14.  
  15. .macro ret 0
  16. rts
  17. pop d
  18. pop c
  19. pop b
  20. pop a
  21. .endmacro
  22.  
  23.  
  24. fib: ldi c #1
  25. xor a
  26. brz one
  27. ldi c #2
  28. xor a
  29. brz one
  30.  
  31. ldi c #-1
  32. add a
  33. ldi c #-2
  34. add d
  35.  
  36. mov a b
  37. call fib
  38. push a
  39. mov d b
  40. call fib
  41. mov a c
  42. pop b
  43. add a
  44.  
  45. ret
  46.  
  47. one: ldi a #1
  48. ret
  49.  
  50.  
  51. start: ldsp stack
  52.  
  53. ldi b #8
  54. call fib
  55. hlt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement