Advertisement
Zeda

C_div_B unrolled

Feb 4th, 2015
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a_div_b:
  2.     ld c,a
  3. c_div_b:
  4. ;Inputs:
  5. ;     C is the numerator
  6. ;     B is the denominator (less than 128)
  7. ;Outputs:
  8. ;     A is the quotient
  9. ;     C is -1/2 the quotient
  10. ;     B,D,E,H,L are not changed
  11. ;242cc to 250cc
  12. ;61 bytes
  13.      xor a
  14.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  15.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  16.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  17.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  18.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  19.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  20.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  21.      rl c \ rla \ cp b \ jr c,$+3 \ sub b
  22.      ld a,c \ rla \ cpl
  23.      ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement