Two functions : the first is for unpacking the mantissas of two floating-point numbers, the second is for comparing two floating-point numbers.
Unpacks the mantissas of FACCUM and BCDE. This is simple enough - we just restore the missing most-significant bit, invariably a 1 (see tech note). Unfortunately, doing this loses the sign bits of both packed numbers.
To compensate for this, a combination of both signs is returned. Duing the function FACC's sign is negated and later xor'ed with BCDE's sign, and returned in bit 7 of A. The effect of this is when the function returns, A is +ve if the signs mismatched, or -ve if the signs matched. |
|
0A37 | 217101 | FUnpackMantissas | LXI H,FACCUM+2 | |
0A3A | 7E | MOV A,M | ||
0A3B | 07 | RLC | Move FACCUM's sign to bit 0. | |
0A3C | 37 | STC | Set MSB of FACCUM mantissa, | |
0A3D | 1F | RAR | FACCUM's sign is now in carry. | |
0A3E | 77 | MOV M,A | ||
0A3F | 3F | CMC | Negate FACCUM's sign. | |
0A40 | 1F | RAR | Bit 7 of A is now FACCUM's sign. | |
0A41 | 23 | INX H | Store negated FACCUM sign at FTEMP_SIGN. | |
0A42 | 23 | INX H | ||
0A43 | 77 | MOV M,A | ||
0A44 | 79 | MOV A,C | ||
0A45 | 07 | RLC | Set MSB of BCDE mantissa, | |
0A46 | 37 | STC | BCDE's sign is now in carry. | |
0A47 | 1F | RAR | ||
0A48 | 4F | MOV C,A | ||
0A49 | 1F | RAR | Bit 7 of A is now BCDE's sign | |
0A4A | AE | XRA M | XORed with FTEMP_SIGN. | |
0A4B | C9 | RET |
Compares FACCUM to BCDE, with the result being returned in A as follows :
FACCUM > BCDE, A = 0x01.
FACCUM < BCDE, A = 0xFF.
FACCUM = BCDE, A = 0.
If BCDE is zero, then we don't need to compare and can just return via FTestSign. | ||||
0A4C | 78 | FCompare | MOV A,B | |
0A4D | B7 | ORA A | ||
0A4E | CA2800 | JZ FTestSign | ||
Set return address to InvSignToInt | ||||
0A51 | 21DE09 | LXI H,InvSignToInt | ||
0A54 | E5 | PUSH H | ||
Test FACCUM's sign, and return with A=the inverse of BCDE's sign if FACCUM is zero. | ||||
0A55 | EF | RST FTestSign | ||
0A56 | 79 | MOV A,C | ||
0A57 | C8 | RZ | ||
0A58 | 217101 | LXI H,FACCUM+2 | ||
0A5B | AE | XRA M | ||
0A5C | 79 | MOV A,C | ||
0A5D | F8 | RM | ||
Call function to test for equality. If BCDE and FACCUM are equal, then this function will not return here, but to FCompare's caller. | ||||
0A5E | CD640A | CALL FIsEqual | ||
Not equal. We get the carry flag (indicating greater/lesser relationship) into bit 7 of A and then XOR that with ??? and return to 09DE. | ||||
0A61 | 1F | RAR | ||
0A62 | A9 | XRA C | ||
0A63 | C9 | RET | ||
Test for equality between BCDE and FACCUM. | ||||
0A64 | 23 | FIsEqual | INX H | |
0A65 | 78 | MOV A,B | ||
0A66 | BE | CMP M | ||
0A67 | C0 | RNZ | ||
0A68 | 2B | DCX H | ||
0A69 | 79 | MOV A,C | ||
0A6A | BE | CMP M | ||
0A6B | C0 | RNZ | ||
0A6C | 2B | DCX H | ||
0A6D | 7A | MOV A,D | ||
0A6E | BE | CMP M | ||
0A6F | C0 | RNZ | ||
0A70 | 2B | DCX H | ||
0A71 | 7B | MOV A,E | ||
0A72 | 96 | SUB M | ||
0A73 | C0 | RNZ | ||
Equality, ie BCDE==FACCUM. In this case we can lose the first two return addresses on the stack, and return the caller of FCompare. | ||||
0A74 | E1 | POP H | Lose 0A5E | |
0A75 | E1 | POP H | Lose 09DE | |
0A76 | C9 | RET | Return to caller |