Submitted by Steve Fewell
Routine: CheckNum&ConvFloat
Name: Check Number and Convert to Integer if Number is Floating-Point
Starting Address: &96BE
Entry criteria: The Accumulator specifies which type of value has just
been processed.
Exit: If the value was Floating-Point, then the FWA's
value will be converted to Integer and stored in the IWA.
Description:
Transfers the current Variable Type [stored in A] to Y in order to update the
status flags.
If the current Variable Type = 0 (String) then a Type Mismatch error is given.
If the current Variable Type = positive (i.e. &40, Integer) then nothing to do as the number is already integer, so exit with the IWA's value intact.
Otherwise, the current Variable Type must be negative (i.e. &FF, Floating-Point), so the number is floating-point. So we need to convert the number into an Integer and return it in the IWA.
The Convert Float to Integer routine is used to return a Two's-complement Integer value in the FWA Mantissa (stored Most significant byte first, least significant byte last). Now, store the Integer Number in the IWA - stored the right way around (least significant byte first, and Most significant byte last), and exit.
Disassembly for the Check Number and Convert to Integer if Float routine
96BE | 168 | A8 | TAY | |
96BF | 240 022 | F0 16 | BEQ 22 --> &96D7 | |
96C1 | 016 019 | 10 13 | BPL 19 --> &96D6 | |
96C3 | B | 032 066 130 | 20 42 82 | JSR &8242 Convert Float to Integer |
96C6 | 1 | 165 049 | A5 31 | LDA &31 |
96C8 | - | 133 045 | 85 2D | STA &2D |
96CA | 2 | 165 050 | A5 32 | LDA &32 |
96CC | , | 133 044 | 85 2C | STA &2C |
96CE | 3 | 165 051 | A5 33 | LDA &33 |
96D0 | + | 133 043 | 85 2B | STA &2B |
96D2 | 4 | 165 052 | A5 34 | LDA &34 |
96D4 | * | 133 042 | 85 2A | STA &2A |
96D6 | ` | 096 | 60 | RTS |
96D7 | L | 076 146 144 | 4C 92 90 | JMP &9092 Type Mismatch error 6 |