Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;===============================================================
- BC_Div_DE:
- ;===============================================================
- ;Performs BC/DE
- ;Speed: 1150+6b cycles when DE<256 (1/256 of the time)
- ; 688+6b cycles when DE>=256 (255/256 of the time)
- ; Avg = 716.88671875cc
- ;Size: 35 bytes
- ;Inputs:
- ; BC is the numerator
- ; DE is the denominator
- ;Outputs:
- ; BC is the quotient
- ; HL is the remainder
- ; DE is not changed
- ; A is 0
- ; z flag is set
- ; c flag is reset
- ;===============================================================
- ld hl,0
- ld a,b
- ld b,16
- inc d
- dec d
- jr z,loop
- ld l,a
- ld a,c
- ld b,8
- loop:
- rl c
- rla
- adc hl,hl
- sbc hl,de
- jr nc,$+3
- add hl,de
- djnz loop
- rl c
- rla
- cpl
- ld b,a
- ld a,c
- cpl
- ld c,a
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement