Submitted by Steve Fewell
Routine:splus
Name: SWA = SWA + string expression
Starting Address: &9E22
Entry criteria: SWA contains a string value. The BASIC Text pointer
points to the second string to concatenate to the end of the SWA.
Exit: The SWA contains the concatenated strings.
Description:
Frstly, push the existing string value in the SWA to the Stack.
Call &A012 to get the result of expression (as there are no higher priority
operators for strings above '+', then the highest level of the expression handler can
be used [A012].
Y=A [to set flags]
If the second value is not a string then generate a Type Mismatch error.
Store X (type of variable?) on stack.
Add the new string's length to the length of the first string (on Stack). If the
result is > 255 then generate a String Too Long error.
X = resulting length (length of new concatenated string).
Store length of new string on Stack.
Y = Length of secong string.
Move each character of the second string (last character first) to the end of the�
SWA value, so that the last character of the second string is stored in the SWA
at the new string length position, and the first character of the second string
is stored in the SWA at the position of the first string length + 1.
Now the second string is in the appropriate place, we just need to put the first
string back in to the SWA (starting at position &600), to do this we simply
Pop the SWA String value from the Stack. [Note: This won't overwrite any of the 2nd String, as
only the length of the first value is extracted].
Pop the new string length from the Stack, and store it in &36, so that the correct
new length of the SWA is specified.
Pop X from the stack (to restore the variable type information?).
exit with A = 00 (as result is a String).
9E22 | Q | 032 081 188 | 20 51 BC | JSR &BC51 Push SWA to Stack |
9E25 | 032 018 160 | 20 12 A0 | JSR &A012 Get result of expression | |
9E28 | 168 | A8 | TAY | |
9E29 | f | 208 102 | D0 66 | BNE 102 --> &9E91 [JMP &9092 Type Mismatch error] |
9E2B | 024 | 18 | CLC | |
9E2C | 218 | DA | PHX | |
9E2D | 178 004 | B2 04 | LDA (&04) | |
9E2F | e6 | 101 054 | 65 36 | ADC &36 |
9E31 | 176 221 | B0 DD | BCS -35 --> &9E10 String Too Long error | |
9E33 | 170 | AA | TAX | |
9E34 | H | 072 | 48 | PHA |
9E35 | 6 | 164 054 | A4 36 | LDY &36 |
9E37 | 185 255 005 | B9 FF 05 | LDA &05FF,Y | |
9E3A | 157 255 005 | 9D FF 05 | STA &05FF,X | |
9E3D | 202 | CA | DEX | |
9E3E | 136 | 88 | DEY | |
9E3F | 208 246 | D0 F6 | BNE -10 --> &9E37 | |
9E41 | 032 210 188 | 20 D2 BC | JSR &BCD2 Pop String from Stack | |
9E44 | h | 104 | 68 | PLA |
9E45 | 6 | 133 054 | 85 36 | STA &36 |
9E47 | 250 | FA | PLX | |
9E48 | 169 000 | A9 00 | LDA#&00 | |
9E4A | 128 003 | 80 03 | BRA 3 --> &9E4F Process any more +'s |