Submitted by Steve Fewell
Description:
Check the value type (in A).
If the value is a string then issue a Type Mismatch error, as you cannot subtract
Strings in BASIC.
If variable type is negative then the first value is a Float, so jump to &9EE7, which
does the following:
* Push FWA to Stack
* Get the second value from the expression handler (level 5)
* If second value is a String then generate a Type Mismatch error.
* If second value is an Integer then convert it to a Float
* Pop the first Float value from Stack to argp (&4A, &4B)
* Call the Floating-Point Subtraction routine to subtract the 2nd value from the 1st (&A68A)
* Jump to 9E4F (Expression handler level 4) to check for further + or - operators.
Otherwise, the value is Integer, so push the first value to the Stack and call the
Expression Handler level 5 routine (&9FC4) to get the second value to add.
If the second value is a string then generate a Type Mismatch error.
If the second value is a Float then jump to &9EFF to do the following:
* Pop the first value (the Integer) from the Stack
* Push the second value (the Float) to the Stack
* Convert the Integer to a Float (and put it in the FWA).
* Pop the second Float value from Stack to argp (&4A, &4B)
* Call the Floating-Point Subtraction routine to subtract the 1st value from the 2nd (&ACC7)
* If the FWA is not zero, then reverse the sign of the FWA (as the subtraction was performed
the opposite way than it should have been.
* Jump to 9E4F (Expression handler level 4) to check for further + or - operators.
Otherwise, both values are Integers, so carry out the Integer Addition routine. This
routine automatically jumps back to 9E4F on completion, to check for further + or - operators.
9EBD | 168 | A8 | TAY | |
9EBE | 240 209 | F0 D1 | BEQ -47 --> &9E91 [JMP &9092 - Type Mismatch error] | |
9EC0 | 0% | 048 037 | 30 25 | BMI 37 --> &9EE7 |
9EC2 | 032 196 159 | 20 C4 9F | JSR &9FC4 Push Integer to stack & Expression handler level 5 | |
9EC5 | 168 | A8 | TAY | |
9EC6 | 240 201 | F0 C9 | BEQ -55 --> &9E91 [JMP &9092 - Type Mismatch error] | |
9EC8 | 05 | 048 053 | 30 35 | BMI 53 --> &9EFF |
9ECA | iminus start: |
9EE7 | 032 250 187 | 20 FA BB | JSR &BBFA Push FWA to Stack | |
9EEA | 032 199 159 | 20 C7 9F | JSR &9FC7 Expression Handler level 5 (*,/,MOD,DIV) | |
9EED | 168 | A8 | TAY | |
9EEE | 240 161 | F0 A1 | BEQ -95 --> &9E91 [JMP &9092 - Type Mismatch error] | |
9EF0 | ' | 134 039 | 86 27 | STX &27 |
9EF2 | 0 | 048 003 | 30 03 | BMI 3 --> &9EF7 |
9EF4 | 032 133 129 | 20 85 81 | JSR &8185 Convert Integer to Float | |
9EF7 | 032 232 187 | 20 E8 BB | JSR &BBE8 Pop Float to argp | |
9EFA | 032 138 166 | 20 8A A6 | JSR &A68A Floating-Point Subtraction | |
9EFD | 128 171 | 80 AB | BRA -85 --> &9EAA | |
9EFF | ' | 134 039 | 86 27 | STX &27 |
9F01 | 032 230 188 | 20 E6 BC | JSR &BCE6 Pop Integer from Stack | |
9F04 | 032 250 187 | 20 FA BB | JSR &BBFA Push FWA to Stack | |
9F07 | 032 133 129 | 20 85 81 | JSR &8185 Convert Integer to Float | |
9F0A | 032 232 187 | 20 E8 BB | JSR &BBE8 Pop Float to argp | |
9F0D | 032 199 172 | 20 C7 AC | JSR &ACC7 Floating-Point Subtraction with reverse sign of result | |
9F10 | 128 152 | 80 98 | BRA -104 --> &9EAA |
ACC7 | 032 138 166 | 20 8A A6 | JSR &A68A Floating-Point Subtraction | |
ACCA | 1 | 165 049 | A5 31 | LDA &31 |
ACCC | 240 006 | F0 06 | BEQ 6 --> &ACD4 | |
ACCE | . | 165 046 | A5 2E | LDA &2E |
ACD0 | I | 073 128 | 49 80 | EOR#&80 |
ACD2 | . | 133 046 | 85 2E | STA &2E |
ACD4 | 169 255 | A9 FF | LDA#&FF | |
ACD6 | ` | 096 | 60 | RTS |