Submitted by Steve Fewell
Description:
If the Integer power (A) is negative then decrement if and EOR it with #&FF to
reverse the two's complement and obtain the absolute value of the power. Then call
the Floating-Point Reciple routine (&A5E9) to set FWA = 1/FWA. Now the FWA can be raised
to the positive power value to give the required result.
If the Integer power is 0, then set FWA = 1.0 and exit.
Store the FWA to Temporary Floating-Point variable location &046C.
If the power = 1 then exit (the FWA already contains the result, as raising to the power
of 1 just returns the same value).
Reduce the power value by 1.
Keep multiplying the FWA by the original copy of the FWA (&046C) (FWA = &046C * FWA)
and reducing the power value until the power value is zero.
Exit, as the FWA now contains the correct result of FWA^A.
Note: It's strange that there is no quicker way to perform this calculation!
A5BE | 170 | AA | TAX | |
A5BF | 016 008 | 10 08 | BPL 8 --> &A5C9 | |
A5C1 | : | 058 | 3A | DEC A |
A5C2 | I | 073 255 | 49 FF | EOR#&FF |
A5C4 | H | 072 | 48 | PHA |
A5C5 | 032 233 165 | 20 E9 A5 | JSR &A5E9 Floating-Point Reciple (FWA=1/FWA) | |
A5C8 | 250 | FA | PLX | |
A5C9 | 240 013 | F0 0D | BEQ 13 --> &A5D8 Set FWA = 1.0 | |
A5CB | 032 017 165 | 20 11 A5 | JSR &A511 Store FWA to &046C & set argp=&046C | |
A5CE | 202 | CA | DEX | |
A5CF | 240 006 | F0 06 | BEQ 6 --> &A5D7 | |
A5D1 | 032 166 166 | 20 A6 A6 | JSR &A6A6 Floating-Point multiplication (FWA=argp*FWA) | |
A5D4 | 202 | CA | DEX | |
A5D5 | 208 250 | D0 FA | BNE -6 --> &A5D1 | |
A5D7 | ` | 096 | 60 | RTS |
A5D8 | 169 128 | A9 80 | LDA#&80 | |
A5DA | 1 | 133 049 | 85 31 | STA &31 |
A5DC | 026 | 1A | INC A | |
A5DD | 0 | 133 048 | 85 30 | STA &30 |
A5DF | L | 076 184 166 | 4C B8 A6 | JMP &A6B8 Clear FWA (except Exp/Mantissa1) |