8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

A861 Evaluate continued-fraction expansions Series

Submitted by Steve Fewell

Routine:EvaluateSeries
Name: Evaluate continued-fraction expansions Series
Starting Address: &A861
Entry criteria: The FWA contains the value to apply the Number Series to.
Y contains the number of cycles to evaluate.
X contains the LSB address of the first Floating-Point constant (in the FP constant table: &BF24)
to use in the series calculation. This value and subsequent values will be used.
A contains the LSB address of the Floating-Point constant value to set the FWA to
if the number in the FWA is too small to evaluate.
Exit: The FWA contains the result of the calculation.

Description:

Set &47 to the number of cycles that we need to evaluate (Y).
Set &4C to the LSB address of the first Floating-Point constant to use (X).
All Floating-Point constant values used are located in the Floating-Point constant table.

If the exponent of the FWA is less than &40, then the value is too small to evaluate, so set
the FWA to the default value specified (The Floating-Point constant located at &BF00 + A)
and exit. Note: This will also trap a 0.0 value, and thus avoid a Division by zero error when
the reciple value is calculated.

Obtain the reciple of the FWA value (FWA = 1/FWA).
Store the reciple value in the temporary Floating-Point variable located at &046C.

Set argp to the address of the first Floating-Point constant in the series calculation:
that is &BF00 + the LSB value in &4C.
Add the first Floating-Point constant value to the Reciple value in the FWA (FWA=argp+FWA).

For each cycle do the following: [i.e. if the cycle (&47) is 2 then repeat twice]
  * Update argp to point to the address of the next Floating-Point constant (i.e. add
    5 to the LSB address and update &4C to the new LSB address. The MSB
    address is always #&BF). Divide this Floating-Point constant value by
    the FWA (FWA = argp/FWA).
  * Update argp to point to the address of the next Floating-Point constant (i.e. add
    5 to the LSB address and update &4C to the new LSB address. The MSB
    address is always #&BF). Add this Floating-Point constant value to
    the FWA (FWA = argp+FWA).
  * Add the Temporary Floating-Point variable at &046C (the reciple of the original
    value) to the FWA (FWA = argp + FWA).
  * Decrement the cycle number (&47).

Lastly perform a division and addition calculation with the next two floating-point
constants, as follows:
Update argp to point to the address of the next Floating-Point constant (i.e. add 5 to
the LSB address and update &4C to the new LSB address. The MSB address is always #&BF).
Divide this Floating-Point constant value by the FWA (FWA = argp/FWA).
Update argp to point to the address of the next Floating-Point constant (i.e. add 5 to
the LSB address and update &4C to the new LSB address. The MSB address is always #&BF).
Add this Floating-Point constant value to the FWA (FWA = argp+FWA).

The FWA now contains the required result.


Disassembly for the Evaluate continued-fraction expansions series routine

A861 G 132 071 84 47 STY &47
A863 L 134 076 86 4C STX &4C
A865 0 166 048 A6 30 LDX &30
A867 @ 224 064 E0 40 CPX#&40
A869 + 144 043 90 2B BCC 43 --> &A896 Set FWA = Default value
A86B   032 233 165 20 E9 A5 JSR &A5E9 Floating-Point Reciple (FWA=1/FWA)
A86E   032 017 165 20 11 A5 JSR &A511 Store FWA to Temp address &046C
A871 L 165 076 A5 4C LDA &4C
A873   032 139 165 20 8B A5 JSR &A58B Set argp to &BF00 + A
A876   032 141 166 20 8D A6 JSR &A68D Floating-Point Addition
A879   032 134 168 20 86 A8 JSR &A886
A87C   032 146 165 20 92 A5 JSR &A592 Set argp to &046C
A87F   032 141 166 20 8D A6 JSR &A68D Floating-Point Addition
A882 G 198 071 C6 47 DEC &47
A884   208 243 D0 F3 BNE -13 --> &A879
A886   169 191 A9 BF LDA#&BF
A888 K 133 075 85 4B STA &4B
A88A   032 127 165 20 7F A5 JSR &A57F Set &4C to address of next FP constant
A88D   032 238 165 20 EE A5 JSR &A5EE Floating-Point Division
A890   032 127 165 20 7F A5 JSR &A57F Set &4C to address of next FP constant
A893 L 076 141 166 4C 8D A6 JMP &A68D Floating-Point Addition
A896   032 139 165 20 8B A5 JSR &A58B Set argp to &BF00 + A
A899 LA 076 065 165 4C 41 A5 JMP &A541 Load FWA with Floating-Point variable

A57F - Update &4C to point to the LSB address of the next FP variable
A57F   024 18 CLC
A580 L 165 076 A5 4C LDA &4C
A582 i 105 005 69 05 ADC#&05
A584 L 133 076 85 4C STA &4C
A586 J 133 074 85 4A STA &4A
A588 ` 096 60 RTS

A592 - Set argp to &046C
A592 l 169 108 A9 6C LDA#&6C
A594 J 133 074 85 4A STA &4A
A596   169 004 A9 04 LDA#&04
A598 K 133 075 85 4B STA &4B
A59A ` 096 60 RTS

 


 Back to 8BS
Or