Submitted by Steve Fewell
Starting Address: &9B1C (or 9B1E if &0A doesn't need incrementing)
Entry criteria: &0A and &0B (the PTR A) point to the position on the program line where a Line Number
Exit: The IWA contains the detokenised value of the Line Number.
Carry Flag = 1 if a line number was found (and its value is in the IWA).
Carry Flag = 0 if a tokenised line number was not found.
Y contains the offset of the next character after the line number (or the next non-space character if no Line Number was
If called from &9B1C, increment the PTR A Offset.
Get the next non-space character from Basic text Pointer A (including the offset (&0A)).
If the next character is not #&8D (Line Number token) then goto &9B44 (exit with Carry = 0 ) as there is no
Line Number to detokenise.
Get the next (1st) character from PTR A (the character after the &8D token).
Multiply the ASCII code by 4 (to clear the lower 2-bits, ready to be merged with the next byte).
Store the result in X, to backup current value of the first ASCII code.
AND the ASCII code by #&C0 (1100 0000) to clear all but the top 2 bits.
EOR the ASCII code with the next (2nd) character from PTR A.
Store the result (of the merged first and second bytes) in &2A.
A = X (i.e. the backup value of the Line Number's first ASCII code).
Multiply A by 4 (to clear the top 2-bits).
EOR A with the next (3rd) character from PTR A.
Store the result in &2B.
So, basically, the detokenised line number LSB is the 2nd byte of the line number EORed with bytes 4 and 5 (positioned
in bytes 6 and 7 of the byte) of the 1st byte; and the detokenised line number MSB is the 3rd byte of the
line number EORed with bytes 2 and 3 (positioned in bytes 6 and 7 of the byte) of the 1st byte.
Update PTR A offset to point to the next character after the line number.
Set carry and exit.
|9B1C||230 010||E6 0A||INC &0A|
|9B1E||164 010||A4 0A||LDY &0A|
|9B20||177 011||B1 0B||LDA (&0B),Y|
|9B22||201 032||C9 20||CMP#&20|
|9B24||240 246||F0 F6||BEQ -10 --> &9B1C|
|9B26||201 141||C9 8D||CMP#&8D|
|9B28||208 026||D0 1A||BNE 26 --> &9B44|
|9B2B||177 011||B1 0B||LDA (&0B),Y|
|9B30||)||041 192||29 C0||AND#&C0|
|9B33||Q||081 011||51 0B||EOR (&0B),Y|
|9B35||*||133 042||85 2A||STA &2A|
|9B3B||Q||081 011||51 0B||EOR (&0B),Y|
|9B3D||+||133 043||85 2B||STA &2B|
|9B40||132 010||84 0A||STY &0A|