Prev: A469 Up: Map Next: A480
A476: Divide By Repeated Subtraction
Used by the routines at ShiftTextPointer and PrintOneDecimalDigit.
Counts how many times DE can be subtracted from HL. Returns the count in A and the remainder in HL.
DivideBySubtraction A476 LD A,$FF Start the count at FF so the first pass makes it zero.
DivideBySubtraction_0 A478 INC A Count in A how many times DE can be subtracted from HL, and repeat until HL goes below DE.
A479 AND A
A47A SBC HL,DE
A47C JR NC,DivideBySubtraction_0
A47E ADD HL,DE Add DE back to leave the remainder in HL.
A47F RET Return.
Prev: A469 Up: Map Next: A480