Advertisement
Runer112

Div32By16

Jul 10th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. Div32By16:
  2. ; IN: ACIX=dividend, DE=divisor
  3. ; OUT: ACIX=quotient, DE=divisor, HL=remainder, B=0
  4. ld hl,0
  5. ld b,32
  6. Div32By16_Loop:
  7. add ix,ix
  8. rl c
  9. rla
  10. adc hl,hl
  11. jr c,Div32By16_Overflow
  12. sbc hl,de
  13. jr nc,Div32By16_SetBit
  14. add hl,de
  15. djnz Div32By16_Loop
  16. ret
  17. Div32By16_Overflow:
  18. or a
  19. sbc hl,de
  20. Div32By16_SetBit:
  21. .db $DD,$2C ; inc ixl, change to inc ix to avoid undocumented
  22. djnz Div32By16_Loop
  23. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement