There is a bug in the HL_Div_C routine that gives wrong results, for example 37901 / 149 should be 254 but the routine yields 34, fixed code below:
HL_Div_C:
;Inputs:
; HL is the numerator
; C is the denominator
;Outputs:
; A is the remainder
; B is 0
; C is not changed
; DE is not changed
; HL is the quotient
;
ld b,16
xor a
add hl,hl
rla
jr c,$+5 ; this line is missing
cp c
jr c,$+4
inc l
sub c
djnz $-9 ; this needs to be adjusted for the added code
ret




