DEHL_Div_C.z80 310 B

1234567891011121314151617181920212223242526
  1. DEHL_Div_C:
  2. ex de,hl
  3. push de
  4. jr $+4
  5. HLIX_Div_C:
  6. ;HLIX/C, C<=128 (yes, 128 is allowed)
  7. ;26 bytes
  8. push ix
  9. call HL_Div_C_limited
  10. ex (sp),hl
  11. call HL_Div_C_limited+1
  12. ex (sp),hl
  13. pop ix
  14. ret
  15. HL_Div_C_limited:
  16. xor a
  17. ld b,16
  18. _:
  19. add hl,hl
  20. rla
  21. cp c
  22. jr c,$+4
  23. sub c
  24. inc l
  25. djnz -_
  26. ret