Prev: 2DC1 Up: Map Next: 2DE3
2DD5: THE 'FLOATING-POINT TO A' SUBROUTINE
Used by the routines at TWO_PARAM, FIND_INT1, STK_TO_A, CD_PRMS1, DEC_TO_FP, PRINT_FP, chrs and exp.
The routine at LOG_2_A continues here.
This short but vital subroutine is called at least 8 times for various purposes. It uses FP_TO_BC to get the 'last value' into the A register where this is possible. It therefore tests whether the modulus of the number rounds to more than 255 and if it does the subroutine returns with the carry flag set. Otherwise it returns with the modulus of the number, rounded to the nearest integer, in the A register, and the zero flag set to imply that the number was positive, or reset to imply that it was negative.
Output
A Last value from the calculator stack
F Carry flag set on overflow
F Zero flag set if the value is positive, reset if negative
FP_TO_A 2DD5 CALL FP_TO_BC Compress the 'last value' into BC.
2DD8 RET C Return if out of range already.
2DD9 PUSH AF Save the result and the flags.
2DDA DEC B Again it will be out of range if the B register does not hold zero.
2DDB INC B
2DDC JR Z,FP_A_END Jump if in range.
2DDE POP AF Fetch the result and the flags.
2DDF SCF Signal the result is out of range.
2DE0 RET Finished - unsuccessful.
FP_A_END 2DE1 POP AF Fetch the result and the flags.
2DE2 RET Finished - successful.
Prev: 2DC1 Up: Map Next: 2DE3