7.2. Exchanging tokens
Note: a "token"
means any keyword
call (command, function) of
"Dictionary" BASIC, which is considered by the program
(Both computer and interpreter) in the form of some code.
Length: 46
Number of variables: 2
Checksum: 5000
Purpose: The change any occurrence of a given token in a
BASIC program on another token (For example, all operators PRINT
may be changed at LPRINT).
Variables:
Name: chr old
Length: 1
Cell: 23296
Comment: The code replaces the token.
Name: chr new
Length: 1
Cell: 23297
Comment: The code is a replacement token.
Calling the program:
RANDOMIZE USR address
Error checking: If BEYSIKprogrammy not in memory or a
of the two specified tokens has
code is less than 32, then the procedure returns to BASIC.
Comment: This procedure
very quickly, but the longer
BASIC program, the slower
it works.
LISTING machine code
Assembly label number to VVODA147.
LD BC, (23296) 237 75 0 91
LD A, 31 62 31
CP B 184
RET NC 208
CP C 185
RET NC 208
LD HL, (23635) 42 83 92
NXT_CH INC HL 35
INC HL 35
INC HL 35
CHECK LD DE, (23,627) two hundred thirty-seven 91 75 92
AND A 167
SBC HL, DE 237 82
RET NC 208
ADD HL, DE 25
INC HL 35
LD A, (HL) 126
INC HL 35
CP 13254 1913
JR Z, NXT_CH 40237
CP 14254 1914
JR NZ, COMP 32 3
INC HL 35
JR NEXT_CHR 24230
CONP DEC HL 1943
CP C 185
JR NZ, CHECK 32229
LD (HL), B 112
JR CHECK 24226
2
How it works:
In the registers B and C are loaded
old and new tokens, respectively. If any of the tokens
has a code less than 32, then
the program returns to BASIC.
In a pair of HL recorded address of the start-BASIC program.
A pair of registers, and then increases compared with the
address field variables. If HL is not less
than the start address of the variables, the program returns to
BASIC.
Pair HL is increased, pointing to the next character. Code
this character is loaded into the accumulator and HL increases
again. If the value in the accumulator is equal to 13 or 14
(ENTER or NUMBER), routine returns to NXT_CH, and HL increased,
pointing to the next symbol. If the battery does not contain 13
or 14, the stored value is compared with the chr old. If a
couple is found, this symbol replaced by chr new.
Then return to the test
(CHECK) at the end of the processed
program.