9646 TRACE
Submitted by Steve Fewell
Description:
Call routine &9B1E to check if there is a tokenised Line Number following the TRACE Keyword. If a Line Number is
found then detokenise the Line Number and set the IWA to the Line Number value.
-
If the carry flag is not set, then a Line Number was not found and A contains the character after the TRACE Keyword, so:
- * If A is the 'ON-Token' [#&EE] then jump to the TRACE ON routine at &9667
- * If A is the 'OFF-Token' [#&87] then jump to the TRACE OFF routine at &9670
- * Otherwise, the TRACE Line Number must be a variable/expression, so call routine &926F to evaluate
- the variable/expression, convert the result to Integer and store the result in the IWA
Call routine &9BA6 to check that the statement terminates correctly with a ':', '<cr>' or 'ELSE-token' character,
issuing 'Syntax error' if it doesn't.
Set the TRACE Line Number (locations &21-&22) to the 16-bit Line Number from the IWA (locations &2A-&2B).
Set the TRACE flag (location &20) to #&FF to indicate that TRACEing is currently activated.
Jump to &9005 to continue executing the next statement of the Program.
[&9667] TRACE ON routine
Increment the BASIC Text Pointer A offset (&0A) to skip over the ON-Token.
Call routine &9BA6 to check that the statement terminates correctly with a ':', '<cr>' or 'ELSE-token' character,
issuing 'Syntax error' if it doesn't.
Set A to #&FF.
-
Jump to &965F to:
- * Set the TRACE Line Number MSB (location &22) to A (#&FF) to indicate that there is no maximum
- TRACE Line Number.
- * Set the TRACE flag (location &20) to #&FF to indicate that TRACEing is currently activated.
- * Jump to &9005 to continue executing the next statement of the Program.
[&9670] TRACE OFF routine
Increment the BASIC Text Pointer A offset (&0A) to skip over the OFF-Token.
Call routine &9BA6 to check that the statement terminates correctly with a ':', '<cr>' or 'ELSE-token' character,
issuing 'Syntax error' if it doesn't.
Set A to #&00.
-
Jump to &9663 to:
- * Set the TRACE flag (location &20) to A (#&00) to indicate that TRACEing is NOT currently activated.
- * Jump to &9005 to continue executing the next statement of the Program.
Disassembly for the TRACE routine
9646 |
|
032 030 155 |
20 1E 9B |
JSR &9B1E Detokenise the Line Number at PTR A & Set IWA to the Line Number value |
9649 |
|
176 011 |
B0 0B |
BCS 11 --> &9656 |
964B |
|
201 238 |
C9 EE |
CMP#&EE |
964D |
|
240 024 |
F0 18 |
BEQ 24 --> &9667 TRACE ON |
964F |
|
201 135 |
C9 87 |
CMP#&87 |
9651 |
|
240 029 |
F0 1D |
BEQ 29 --> &9670 TRACE OFF |
9653 |
o |
032 111 146 |
20 6F 92 |
JSR &926F Evaluate Expression at BASIC Text pointer A convert result to integer |
9656 |
|
032 166 155 |
20 A6 9B |
JSR &9BA6 Check end of Statement |
9659 |
* |
165 042 |
A5 2A |
LDA &2A |
965B |
! |
133 033 |
85 21 |
STA &21 |
965D |
+ |
165 043 |
A5 2B |
LDA &2B |
965F |
" |
133 034 |
85 22 |
STA &22 |
9661 |
|
169 255 |
A9 FF |
LDA#&FF |
9663 |
|
133 032 |
85 20 |
STA &20 |
9665 |
|
128 212 |
80 D4 |
BRA -44 --> &963B [JMP &9005] Process the next statement |
9667 |
|
230 010 |
E6 0A |
INC &0A |
9669 |
|
032 166 155 |
20 A6 9B |
JSR &9BA6 Check end of Statement |
966C |
|
169 255 |
A9 FF |
LDA#&FF |
966E |
|
208 239 |
D0 EF |
BNE -17 --> &965F |
9670 |
|
230 010 |
E6 0A |
INC &0A |
9672 |
|
032 166 155 |
20 A6 9B |
JSR &9BA6 Check end of Statement |
9675 |
|
169 000 |
A9 00 |
LDA#&00 |
9677 |
|
128 234 |
80 EA |
BRA -22 --> &9663 |
Or