Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HL_Div_C:
- ;Inputs:
- ; HL is the numerator
- ; C is the denominator
- ;Outputs:
- ; HL is quotient
- ; A is the remainder
- ; B is 0
- ; C is unchanged
- ;
- ;8+466+{-5+9{0,4+{0,3}}, 261+16{0,3}}
- ;min: 469
- ;max: 783
- ;avg: 626.375
- bit 7,c
- jr nz,HL_Div_C_ge_128
- HL_Div_C_lt_128:
- ;720+16{0,3}
- ;min: 720
- ;max: 768
- ;avg: 744
- xor a
- ld b,16
- HL_Div_C_loop:
- add hl,hl
- rla
- cp c
- jr c,$+4
- inc l
- sub c
- djnz HL_Div_C_loop
- ret
- HL_Div_C_ge_128:
- ;449+9{0,4+{0,3}}
- ;min: 449
- ;max: 512
- ;avg: 473.75
- ld a,h
- ld h,l
- ld l,0
- ld b,9
- jr $+6
- HL_Div_C_ge_128_loop:
- add hl,hl
- rla
- jr c,$+5
- cp c
- jr c,$+4
- inc l
- sub c
- djnz HL_Div_C_ge_128_loop
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement