daily pastebin goal
26%
SHARE
TWEET

div24 (eZ80)

Zeda Jan 14th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. div24:
  2. ;DE/BC, assumes DE<BC
  3. ;180F+13R+10W+2+24{1,F}+{0,F+3+{0,3F}}
  4.   push bc   ;save for later
  5. ;First, we are going to shift BC right
  6.   xor a
  7.   sbc hl,hl
  8.   add hl,sp
  9.   push bc
  10.   dec hl
  11.   ld a,(hl)
  12.   cpl
  13.   rra   ;c flag is reset from the add hl,sp
  14.   ld (hl),a
  15.   pop bc
  16.   rr b
  17.   rr c
  18.   ld a,b
  19.   cpl
  20.   ld b,a
  21.   ld a,c
  22.   cpl
  23.   ld c,a
  24.   inc bc
  25.   ex de,hl
  26.   add hl,bc \ jr c,$+4 \ sbc hl,bc
  27.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  28.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  29.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  30.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  31.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  32.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  33.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  34.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  35.   push af
  36.   dec sp
  37.   pop de
  38.   inc sp
  39.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  40.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  41.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  42.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  43.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  44.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  45.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  46.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  47.   ld d,a
  48.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  49.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  50.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  51.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  52.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  53.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  54.   rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
  55.   rla \ add hl,hl
  56.   ld e,a
  57.   pop bc
  58.   bit 0,c
  59.   ret z
  60. ;HL is the remainder
  61. ;r-Q*E = HL-DE
  62.   sbc hl,de
  63.   ret nc
  64.   add hl,bc
  65.   dec de
  66.   ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top