Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- div_32_32_to_5bit:
- inc hl
- inc hl
- inc hl
- inc de
- inc de
- inc de
- ld a,(de)
- or (hl)
- jr nz,begin_div
- dec hl
- dec de
- ld a,(de)
- or (hl)
- jr nz,begin_div
- dec hl
- dec de
- ld a,(de)
- or (hl)
- jr nz,begin_div
- ;only 8 bits of each left
- ld c,(hl)
- ld a,(de)
- ld d,a
- jr C_Div_D
- begin_div:
- ld b,(hl)
- dec hl
- ld c,(hl)
- ex de,hl
- ld d,(hl)
- dec hl
- ld e,(hl)
- ex de,hl
- ;now we need to shift these left until bit 7 is set
- jr div32_adjust_loop_begin
- div32_adjust_loop:
- add hl,hl
- sla c
- rl b
- div32_adjust_loop_begin:
- ld a,h
- or b
- jp p,div32_adjust_loop
- ld c,b
- ld d,h
- C_Div_D:
- ld b,5
- xor a
- sla c
- rla
- sla c
- rla
- sla c
- rla
- C_Div_D_loop:
- sla c
- rla
- cp d
- jr c,+_
- inc c
- sub d
- _:
- djnz C_Div_D_loop
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement