Advertisement
Zeda

RoundHL_Div_C

Jan 4th, 2012
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RoundHL_Div_C:
  2. ;Inputs:
  3. ;     HL is the numerator
  4. ;     C is the denominator
  5. ;Outputs:
  6. ;     A is twice the remainder of the unrounded value
  7. ;     B is 0
  8. ;     C is not changed
  9. ;     DE is not changed
  10. ;     HL is the rounded quotient
  11. ;     c flag set means no rounding was performed
  12. ;            reset means the value was rounded
  13. ;
  14.        ld b,16
  15.        xor a
  16.          add hl,hl
  17.          rla
  18.          cp c
  19.          jr c,$+4
  20.            inc l
  21.            sub c
  22.          djnz $-7
  23.        add a,a
  24.        cp c
  25.        jr c,$+3
  26.          inc hl
  27.        ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement