Prev: 12187 Up: Map Next: 12253
12218: 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 12218 PUSH HL HL is preserved.
12219 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.
12220 LD C,(HL) M1 to C.
12221 INC HL Next.
12222 LD B,(HL) M2 to B.
12223 LD (HL),A Copy the sign of the result to bit 7 of (HL).
12224 INC HL Next.
12225 LD A,C M1 to A.
12226 LD C,(HL) M3 to C.
12227 PUSH BC Save M2 and M3 on the machine stack.
12228 INC HL Next.
12229 LD C,(HL) M4 to C.
12230 INC HL Next.
12231 LD B,(HL) M5 to B.
12232 EX DE,HL HL now points to N1.
12233 LD D,A M1 to D.
12234 LD E,(HL) N1 to E.
12235 PUSH DE Save M1 and N1 on the machine stack.
12236 INC HL Next.
12237 LD D,(HL) N2 to D.
12238 INC HL Next.
12239 LD E,(HL) N3 to E.
12240 PUSH DE Save N2 and N3 on the machine stack.
12241 EXX Get the exchange registers.
12242 POP DE N2 to D' and N3 to E'.
12243 POP HL M1 to H' and N1 to L'.
12244 POP BC M2 to B' and M3 to C'.
12245 EXX Get the original set of registers.
12246 INC HL Next.
12247 LD D,(HL) N4 to D.
12248 INC HL Next.
12249 LD E,(HL) N5 to E.
12250 POP AF Restore the original AF.
12251 POP HL Restore the original HL.
12252 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.
Prev: 12187 Up: Map Next: 12253