Difference between revisions of "GSINIT"

From BeebWiki
Jump to: navigation, search
m (grammar)
(X preserved)
Line 8: Line 8:
 
| Z || align="left" | undefined || align="left" | 0=String is non-empty or quoted<br>1=String is empty and unquoted
 
| Z || align="left" | undefined || align="left" | 0=String is non-empty or quoted<br>1=String is empty and unquoted
 
|- align="center" valign="top"
 
|- align="center" valign="top"
| C || align="left" | 0=String terminates at closing <tt>"</tt>, otherwise at CR or space<br>1=String terminates at closing <tt>"</tt">, otherwise at CR || align="left" | undefined
+
| Cy || align="left" | 0=String terminates at closing <tt>"</tt>, otherwise at CR or space<br>1=String terminates at closing <tt>"</tt">, otherwise at CR || align="left" | undefined
 
|- align="center" valign="top"
 
|- align="center" valign="top"
 
| A || align="left" | undefined || align="left" | First character of string; =&0D if string empty and unquoted
 
| A || align="left" | undefined || align="left" | First character of string; =&0D if string empty and unquoted
 +
|- align="center" valign="top"
 +
| X || align="left" | undefined || align="left" | preserved
 
|- align="center" valign="top"
 
|- align="center" valign="top"
 
| Y || align="left" | Offset of first character to scan || align="left" | Offset of first character of string
 
| Y || align="left" | Offset of first character to scan || align="left" | Offset of first character of string
Line 27: Line 29:
 
Otherwise (?&F2,?&F3)+Y points to the first non-space character, which is returned in A.  Z is set if this is CR, indicating an empty, unquoted string.  GSREAD will return characters until CR, or also space if GSINIT was called with C=0, is reached.
 
Otherwise (?&F2,?&F3)+Y points to the first non-space character, which is returned in A.  Z is set if this is CR, indicating an empty, unquoted string.  GSREAD will return characters until CR, or also space if GSINIT was called with C=0, is reached.
  
It is safe to call GSREAD at least once following GSINIT.
+
It is safe to call GSREAD at least once following GSINIT, and repeatedly on reaching CR.
  
 
;Note
 
;Note

Revision as of 15:09, 3 February 2019

Initialize to read a string

Specification

 6502  On entry: On exit:
Z undefined 0=String is non-empty or quoted
1=String is empty and unquoted
Cy 0=String terminates at closing ", otherwise at CR or space
1=String terminates at closing "</tt">, otherwise at CR
undefined
A undefined First character of string; =&0D if string empty and unquoted
X undefined preserved
Y Offset of first character to scan Offset of first character of string
 ?&F2 LSB of start of array preserved
 ?&F3 MSB of start of array preserved

Prepares GSREAD to read a string from a character array. The string may be enclosed in double quotes (<tt>") in which case spaces in the string are preserved. The string may also contain control codes and high-order characters encoded with an escape sequence.

GSINIT starts at the position given by (?&F2,?&F3)+Y and scans forward, incrementing Y until a character other than space or CR is found.

If the string begins with " then &22 is returned in A and (?&F2,?&F3)+Y points to the character after the ". The carry flag input to GSINIT has no effect; GSREAD will return characters until the closing " is reached. CR encountered before the closing " causes error &FD, Bad string.

Otherwise (?&F2,?&F3)+Y points to the first non-space character, which is returned in A. Z is set if this is CR, indicating an empty, unquoted string. GSREAD will return characters until CR, or also space if GSINIT was called with C=0, is reached.

It is safe to call GSREAD at least once following GSINIT, and repeatedly on reaching CR.

Note

The character returned by GSINIT is not necessarily the character returned by the first call to GSREAD.

Calling from BBC BASIC

Entry points

  • 6502 Entry Address: &FFC2 (I/O processor only)

Regregex (talk) 17:53, 11 January 2019 (CET)