52h | MT$FADD | floating point addition |

Input | Floating-point registers contain the two numbers to be added. |

Output | Accumulator contains accumulator + operand. |

Description |
Does a floating-point add on the accumulator and operand registers. When adding two numbers of equal exponent, the register mantissas are added (or the smaller mantissa subtracted from the larger if the signs are not the same). The exponent is incremented by 1 if the result overflows, and decremented if underflow occurs in subtraction. If the exponents differ, the mantissa of the register with the smaller exponent is shifted to the right (downwards in memory) by n digits where n is the difference between the two exponents. The shifted mantissa is then added to or subtracted from the other. The larger exponent is taken as the exponent of the result after adjusting for over- or underflow as above. The alignment and addition/subtraction of mantissas are always done on the full 7 bytes of the register mantissas, ie. to 14 digit accuracy. If the result requires more than 12 digits of precision, the guard digits are used to round the least significant digit accordingly. See also: technical manual > utility system services > floating point numbers |

Example |
To add 1.0E+11 and 202.88, the following constants can be set up:
FP_CONST1: DB 0,0,0,0,0,10h ;mantissa DB 11 ;exponent DB 0 ;positive sign DUMMY_GUARD_BYTE: DB 0 FP_CONST2: DB 0,0,0,80h,28h,20h ;mantissa DB 2 ;exponent DB 0 ;signand the following code executed (taking advantage of the fact that the operand follows immediately after the accumulator in memory): LDD #MTT_AMAN+1 ;D -> byte above guard digit LDX #2*8+1 ;length to move STX UTW_S0 LDX #FP_CONST1 OS UT$CPYB ;copy constants into registers OS MT$FADDthen after the mantissas have been aligned they will contain the following: Mantissa Guard Digit Accumulator: 10 00 00 00 00 00 00 Operand: 00 00 00 00 02 02 88 Result after adding: 10 00 00 00 02 02 88Before returning this is rounded up and the guard digit cleared to give: 10 00 00 00 02 03 00 |

Errors | 253 - exponent overflow |