Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;===============================================================
- DE_Div_BC:
- ;===============================================================
- ;Performs DE/BC
- ;Speed: 1365-2b cycles (b is the number of bits set in the result)
- ;Size: 25 bytes
- ;Inputs:
- ; HL is the numerator
- ; BC is the denominator
- ;Outputs:
- ; DE is the quotient
- ; HL is the remainder
- ; BC is not changed
- ; A is 0
- ; z flag is set
- ;===============================================================
- ld a,16
- ld hl,0
- jp $+6 ;change to jr $+5 to save a byte at the cost of 2 extra cycles
- DivLoop1:
- add hl,bc
- dec a
- ret z
- sla e
- rl d
- adc hl,hl
- sbc hl,bc
- jr nc,DivLoop1
- inc e
- jp DivLoop1+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement