| Routines

2FBA: THE 'FETCH TWO NUMBERS' SUBROUTINE

Used by the routines at PRINT_FP, addition, multiply and division. This subroutine is called by addition, multiply and division to get two numbers from the calculator stack and put them into the registers, including the exchange registers. On entry to the subroutine the HL register pair points to the first byte of the first number (M) and the DE register pair points to the first byte of the second number (N). When the subroutine is called from multiply or division the sign of the result is saved in the second byte of the first number.
Input
A | Bit 7 holds the sign bit of the result (when called from multiply or division)
DE | Address of the first byte of N
HL | Address of the first byte of M
Output
H'B'C'CB | The five bytes of M
L'D'E'DE | The five bytes of N
FETCH_TWO | 2FBA | PUSH HL | HL is preserved.
| 2FBB | PUSH AF | AF is preserved.
Call the five bytes of the first number M1, M2, M3, M4 and M5, and the five bytes of the second number N1, N2, N3, N4 and N5.
| 2FBC | LD C,(HL) | M1 to C.
| 2FBD | INC HL | Next.
| 2FBE | LD B,(HL) | M2 to B.
| 2FBF | LD (HL),A | Copy the sign of the result to bit 7 of (HL).
| 2FC0 | INC HL | Next.
| 2FC1 | LD A,C | M1 to A.
| 2FC2 | LD C,(HL) | M3 to C.
| 2FC3 | PUSH BC | Save M2 and M3 on the machine stack.
| 2FC4 | INC HL | Next.
| 2FC5 | LD C,(HL) | M4 to C.
| 2FC6 | INC HL | Next.
| 2FC7 | LD B,(HL) | M5 to B.
| 2FC8 | EX DE,HL | HL now points to N1.
| 2FC9 | LD D,A | M1 to D.
| 2FCA | LD E,(HL) | N1 to E.
| 2FCB | PUSH DE | Save M1 and N1 on the machine stack.
| 2FCC | INC HL | Next.
| 2FCD | LD D,(HL) | N2 to D.
| 2FCE | INC HL | Next.
| 2FCF | LD E,(HL) | N3 to E.
| 2FD0 | PUSH DE | Save N2 and N3 on the machine stack.
| 2FD1 | EXX | Get the exchange registers.
| 2FD2 | POP DE | N2 to D' and N3 to E'.
| 2FD3 | POP HL | M1 to H' and N1 to L'.
| 2FD4 | POP BC | M2 to B' and M3 to C'.
| 2FD5 | EXX | Get the original set of registers.
| 2FD6 | INC HL | Next.
| 2FD7 | LD D,(HL) | N4 to D.
| 2FD8 | INC HL | Next.
| 2FD9 | LD E,(HL) | N5 to E.
| 2FDA | POP AF | Restore the original AF.
| 2FDB | POP HL | Restore the original HL.
| 2FDC | RET | Finished.
Summary: M1 - M5 are in H', B', C', C, B. N1 - N5 are in L', D', E', D, E. HL points to the first byte of the first number.