Prev: 2DE3 Up: Map Next: 2F9B
2F8B: THE 'CA=10*A+C' SUBROUTINE
This subroutine is called by PRINT_FP to multiply each byte of D'E'DE by 10 and return the integer part of the result in the C register. On entry, the A register contains the byte to be multiplied by 10 and the C register contains the carry over from the previous byte. On return, the A register contains the resulting byte and the C register the carry forward to the next byte.
Input
A First number (M)
C Second number (N)
Output
A LSB of 10*M+N
C MSB of 10*M+N
CA_10A_C 2F8B PUSH DE Save whichever DE pair is in use.
2F8C LD L,A Copy the multiplicand from A to HL.
2F8D LD H,$00
2F8F LD E,L Copy it to DE too.
2F90 LD D,H
2F91 ADD HL,HL Double HL.
2F92 ADD HL,HL Double it again.
2F93 ADD HL,DE Add in DE to give HL=5*A.
2F94 ADD HL,HL Double again: now HL=10*A.
2F95 LD E,C Copy C to DE (D is zero) for addition.
2F96 ADD HL,DE Now HL=10*A+C.
2F97 LD C,H H is copied to C.
2F98 LD A,L L is copied to A, completing the task.
2F99 POP DE The DE register pair is restored.
2F9A RET Finished.
Prev: 2DE3 Up: Map Next: 2F9B