Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- div24:
- ;DE/BC, assumes DE<BC
- ;180F+13R+10W+2+24{1,F}+{0,F+3+{0,3F}}
- push bc ;save for later
- ;First, we are going to shift BC right
- xor a
- sbc hl,hl
- add hl,sp
- push bc
- dec hl
- ld a,(hl)
- cpl
- rra ;c flag is reset from the add hl,sp
- ld (hl),a
- pop bc
- rr b
- rr c
- ld a,b
- cpl
- ld b,a
- ld a,c
- cpl
- ld c,a
- inc bc
- ex de,hl
- add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- push af
- dec sp
- pop de
- inc sp
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- ld d,a
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl \ add hl,bc \ jr c,$+4 \ sbc hl,bc
- rla \ add hl,hl
- ld e,a
- pop bc
- bit 0,c
- ret z
- ;HL is the remainder
- ;r-Q*E = HL-DE
- sbc hl,de
- ret nc
- add hl,bc
- dec de
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement