Difference between revisions of "GSINIT"

From BeebWiki
Jump to: navigation, search
m (1 revision)
(skeleton)
Line 1: Line 1:
 
[[Category:MOS API]]
 
[[Category:MOS API]]
 +
Initialize to read a string
 +
 +
==Specification==
 +
{| cellpadding="0" cellspacing="0"
 +
|  6502  || align="left" | '''On entry:''' || align="left" | '''On exit:'''
 +
|- align="center" valign="top"
 +
| Z || align="left" | undefined || align="left" | 0=String is non-empty or quoted<br>1=String is empty and unquoted
 +
|- align="center" valign="top"
 +
| C || align="left" | 0=String terminates at second <tt>"</tt>, otherwise at first CR or space<br>1=String terminates at second <tt>"</tt">, otherwise at first CR || align="left" | undefined
 +
|- align="center" valign="top"
 +
| ?&F2 || align="left" | LSB of start of array || align="left" | preserved
 +
|- align="center" valign="top"
 +
| ?&F3 || align="left" | MSB of start of array || align="left" | preserved
 +
|- align="center" valign="top"
 +
| A || align="left" | undefined || align="left" | First character of string; =&0D if string empty
 +
|- align="center" valign="top"
 +
| Y || align="left" | Offset to start scan || align="left" | Offset of first character of string
 +
|}
 +
 +
Prepares [[GSREAD]] to read a string from a character array. The string may be enclosed in double quotes (<tt>"</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 [[VDU 13|CR]] is found.
 +
 +
If the string begins with <tt>"</tt> then &22 is returned in A and (?&F2,?&F3)+Y points to the character after the <tt>"</tt>. The carry flag input to GSINIT has no effect; GSREAD will return characters until the closing <tt>"</tt> is reached.  A missing closing <tt>"</tt> 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.  GSINIT will return characters until CR or space (if C=0 to GSINIT), or CR only (if C=1 to GSINIT) is reached.
 +
 +
It is safe to call GSREAD at least once following GSINIT.
 +
 +
;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)
 +
 +
[[User:Regregex|Regregex]] ([[User talk:Regregex|talk]]) 17:53, 11 January 2019 (CET)

Revision as of 17:53, 11 January 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
C 0=String terminates at second ", otherwise at first CR or space
1=String terminates at second "</tt">, otherwise at first CR
undefined
 ?&F2 LSB of start of array preserved
 ?&F3 MSB of start of array preserved
A undefined First character of string; =&0D if string empty
Y Offset to start scan Offset of first character of string

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. A missing 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. GSINIT will return characters until CR or space (if C=0 to GSINIT), or CR only (if C=1 to GSINIT) is reached.

It is safe to call GSREAD at least once following GSINIT.

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)