EasyManua.ls Logo

Dick Smith VZ200 - Page 19

Default Icon
34 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
D. COMPARE SYMBOL (EXAMINE STRING) -- RST 08H
A routine which is called using the RST 08H instruction can be
used to compare a character in a string pointed to by the HL
register, with the value in the location following the RST 08
instruction itself. If there is a match, control is returned to
the instruction 2 bytes after the RST 08, with the HL register
incremented by one and the next character of the string in the
A register. This allows repeated calling to check for an
expected sequence of characters. Note that if a match is NOT
found, the RST 08 routine does not return from where it was
called, but jumps instead to the BASIC interpreter's input
phase after printing the SYNTAX ERROR message. Here is how the
routine is used to check that the string pointed to by the HL
register is 'A=B=C':
RST 08H
DEFB 41H
RST 08H
DEFB 3DH
RST 08H
DEFB 42H
RST 08H
DEFB 3DH
RST 08H
DEFB 43H
;test for 'A'
;hex value of A for comparison
;must have found, so try for '='
;hex value of
1
=
1
;OK so far, try for 'B'
;now look for second '='
;finally check for 'C'
;must have been OK, so proceed
E. LOAD & CHECK NEXT CHARACTER IN STRING -- RST 10H
The RST 10H instruction may be used to call a routine which
loads the A register with the next character of a string
pointed to by the HL register, and clears the CARRY flag if the
character is alphabetic, or sets the flag if it is
alphanumeric. Blanks and control codes 09H and OBH are skipped
automatically. The HL register is incremented before each
character is loaded, therefore on the first call the HL
register should be set to point to the address BEFORE the
location of the first string character to be tested. The string
must be terminated by a null byte.
Here is an example of this routine in use. Note that if it is
used immediately after the RST 08H instruction as shown, the HL
register will automatically be incremented to point to the next
character in the string:
RST 08H
DEFB 3DH
RST 10H
JR NC, VAR
• •
;test for '='
;fetch & check next char
;will go to VAR if alpha
;continues if numeral
- 18 -