Prev: 11682 Up: Map Next: 11733
11713: THE 'LOG(2↑A)' SUBROUTINE
Used by the routine at PRINT_FP.
This subroutine calculates the approximate number of digits before the decimal in x, the number to be printed, or, if there are no digits before the decimal, then the approximate number of leading zeros after the decimal. It is entered with the A register containing e', the true exponent of x, or e'-2, and calculates z=log to the base 10 of (2↑A). It then sets A equal to ABS INT (z+0.5), as required, using FP_TO_A for this purpose.
Input
A e' (true exponent) or e'-2
Output
A INT log (2↑A)
LOG_2_A 11713 LD D,A The integer A is stacked, either as 00 00 A 00 00 (for positive A) or as 00 FF A FF 00 (for negative A).
11714 RLA
11715 SBC A,A
11716 LD E,A These bytes are first loaded into A, E, D, C, B and then STK_STORE is called to put the number on the calculator stack.
11717 LD C,A
11718 XOR A
11719 LD B,A
11720 CALL STK_STORE
11723 RST 40 The calculator is used.
11724 DEFB 52 stk_data: log 2 to the base 10 is now stacked
11725 DEFB 239,26,32,154,133
11730 DEFB 4 multiply: A*log 2 i.e. log (2↑A)
11731 DEFB 39 int: INT log (2↑A)
11732 DEFB 56 end_calc
The subroutine continues into FP_TO_A to complete the calculation.
Prev: 11682 Up: Map Next: 11733