Advertisement
sci4me

spu0 gcd

Jun 12th, 2015
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. gcd:
  2. ldi r3 0
  3. beq r0 r3 gcd_zero
  4. gcd_loop:
  5. beq r1 r3 gcd_end
  6. bgt r0 r1 gcd_a_greater_than_b
  7. sub r1 r0
  8. jmp gcd_loop
  9. gcd_a_greater_than_b:
  10. sub r0 r1
  11. jmp gcd_loop
  12. gcd_zero:
  13. mov r2 r1
  14. rts
  15. gcd_end:
  16. mov r2 r0
  17. ldi r0 0
  18. ldi r1 0
  19. rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement