0810
C1
FAdd
POP B
Get lhs in BCDE.
0811
D1
POP D
Special cases for when lhs or rhs are zero.
0812
78
MOV A,B
If lhs==0 then we don't need
0813
B7
ORA A
to do anything and can just
0814
C8
RZ
exit.
0815
3A7201
LDA
FACCUM+3
If rhs==0 then exit via a copy
0818
B7
ORA A
of lhs to FACCUM.
Get exponents' difference into A.
081C
90
SUB B
A=rhs.exponent-lhs.exponent.
081D
D22C08
JNC 082C
If rhs' exponent >= lhs'exponent, jump ahead.
Swap lhs and rhs if lhs exponent was more than rhs exponent.
0820
2F
CMA
Two's complement the exponent
0821
3C
INR A
difference, so it's correct.
0822
EB
XCHG
0823
CD020A
CALL
FPush
Push old rhs
0826
EB
XCHG
082A
C1
POP B
lhs = old rhs.
082B
D1
POP D
Unpack the mantissas. This loses the signs of both numbers, but we do get back their relationship : the call to FUnpackMantissas leaves A +ve if the signs mismatched, or -ve if the signs were equal.
082C
F5
PUSH PSW
Preserve exponent diff
0830
67
MOV H,A
H=sign relationship
0831
F1
POP PSW
A=exponent diff.
Align lhs with rhs.
0832
CDC908
CALL
FMantissaRtMult
Shift lhs mantissa right by (exponent diff) places.
Decide whether to add or subtract the mantissas. We subtract if the signs were mismatched.
0835
B4
ORA H
A=0 after last call, so this tests
0836
216F01
LXI H,
FACCUM
the sign relationship.
Add the mantissas.
083F
D27E08
JNC
FRoundUp
Jump ahead if that didn't overflow.
0842
23
INX H
Flip the sign in FTEMP_SIGN.
0843
34
INR M
0844
CAA408
JZ
Overflow
Error out if exponent overflowed.
Subtract lhs mantissa from rhs mantissa.
084D
AF
FSubMantissas
XRA A
B=0-B
084E
90
SUB B
084F
47
MOV B,A
0850
7E
MOV A,M
E=(FACCUM)-E
0851
9B
SBB E
0852
5F
MOV E,A
0853
23
INX H
0854
7E
MOV A,M
D=(FACCUM+1)-D
0855
9A
SBB D
0856
57
MOV D,A
0857
23
INX H
0858
7E
MOV A,M
C=(FACCUM+2)-C
0859
99
SBB C
085A
4F
MOV C,A
Fall into FNormalise
[Index] [Previous] [Next]