8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

8CEB Replace untokenised ASCII value with a 1-byte token

Submitted by Steve Fewell

Routine:ASCIItoToken
Name: Replace untokenised ASCII value with a 1-byte token
Starting Address: &8CEB
Entry criteria: &37 and &38 point to the start of the ASCII Keyword in the program text.
A contains the token value to replace the ASCII text with.
Y contains the offset to the end character of the Keyword.
Exit: Y = offset pointer to the end of the program command line.

Description:

Store A (the token value) as the first byte of the ASCII Keyword (the location pointed to by (&37, &38)).
Set (&39, &3A) to point to (&37, &38) + Y.
So that (&37, &38) point to the start of the Keyword and (&39, &3A) point to the end of the Keyword.
Copy each character from ((&39, &3A) + 1) to ((&37, &38) + 1) until a <cr> (carriage return character)
is encountered. After a <cr> has been copied, the routine ends, as the rest of the program line has been moved sucessfully
to be positioned directly after the token.


Disassembly for the 'Replace untokenised ASCII value with a 1-byte token' routine

8CEB 7 146 055 92 37 STA (&37)
8CED   024 18 CLC
8CEE   152 98 TYA
8CEF e7 101 055 65 37 ADC &37
8CF1 9 133 057 85 39 STA &39
8CF3   160 000 A0 00 LDY#&00
8CF5   152 98 TYA
8CF6 e8 101 056 65 38 ADC &38
8CF8 : 133 058 85 3A STA &3A
8CFA   200 C8 INY
8CFB 9 177 057 B1 39 LDA (&39),Y
8CFD 7 145 055 91 37 STA (&37),Y
8CFF   201 013 C9 0D CMP#&0D
8D01   208 247 D0 F7 BNE -9 --> &8CFA
8D03 ` 096 60 RTS

 


 Back to 8BS
Or