Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;===============================================================
- BC_Div_DE_round:
- ;===============================================================
- ;Performs BC/DE, rounded
- ;Speed: 1226+10a+6b cycles, 1320cc worst case
- ;Size: 32 bytes
- ;Inputs:
- ; BC is the numerator
- ; DE is the denominator
- ;Outputs:
- ; BC is the quotient
- ; DE is divided by 2 (truncated)
- ; A reflects the low bits of the quotient
- ;Destroys: HL
- ;===============================================================
- ld a,b
- ld hl,0
- ld b,16
- rl c
- rla
- adc hl,hl
- sbc hl,de
- jr nc,$+3
- add hl,de
- ccf
- djnz $-11
- rl c
- rla
- ld b,a
- srl d
- rr e
- sbc hl,de
- ret c
- inc bc
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement