Advertisement
vladikcomper

Calculating a square root

Oct 20th, 2012
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ===============================================================
  2. ; ---------------------------------------------------------------
  3. ; Function to calculate a root
  4. ; (c) 2012, Vladikcomper
  5. ; ---------------------------------------------------------------
  6. ; INPUT:
  7. ;   d0.w    = Number
  8. ;
  9. ; OUTPUT:
  10. ;   d0.w    = Root of number
  11. ;
  12. ; USES:
  13. ;   d0, d1
  14. ;
  15. ; ---------------------------------------------------------------
  16.  
  17. CalcRoot:
  18.     moveq   #-1,d1
  19.  
  20. @0  addq.w  #2,d1
  21.     sub.w   d1,d0
  22.     bcc.s   @0
  23.  
  24.     subq.w  #1,d1
  25.     lsr.w   #1,d1
  26.     exg d1,d0
  27.     rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement