Difference between revisions of "GSREAD"

From BeebWiki
Jump to: navigation, search
m (1 revision)
(created)
Line 1: Line 1:
 
[[Category:MOS API]]
 
[[Category:MOS API]]
 +
Read character from string
 +
 +
==Specification==
 +
{| cellpadding="0" cellspacing="0"
 +
|  6502  || align="left" | '''On entry:''' || align="left" | '''On exit:'''
 +
|- align="center" valign="top"
 +
| C || align="left" | undefined || align="left" | 0=Character valid<br>1=End of string reached
 +
|- 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" | Next character of string; =&0D if end of string reached
 +
|- align="center" valign="top"
 +
| Y || align="left" | Offset of current character || align="left" | Offset of next character
 +
|}
 +
 +
Returns a character from a string found using [[GSINIT]].  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.
 +
 +
GSREAD parses the character sequence at the position given by (?&F2,?&F3)+Y and scans forward.
 +
 +
If the string began with <tt>"</tt> then a character is returned unless the closing <tt>"</tt> is reached; then C=1 and A=&0D is returned.  [[VDU 13|CR]] encountered before the closing <tt>"</tt> causes error &FD, '''Bad string'''.
 +
 +
Otherwise a character is returned unless CR or space (if C=0 to GSINIT), or CR only (if C=1 to GSINIT) is reached; then C=1 and A=&0D.
 +
 +
(?&F2,?&F3)+Y points to the next character unless C=1, in which case GSREAD skips any spaces following the end of the string.
 +
 +
;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: &FFC5 (I/O processor only)
 +
 +
[[User:Regregex|Regregex]] ([[User talk:Regregex|talk]]) 18:31, 11 January 2019 (CET)

Revision as of 18:31, 11 January 2019

Read character from string

Specification

 6502  On entry: On exit:
C undefined 0=Character valid
1=End of string reached
 ?&F2 LSB of start of array preserved
 ?&F3 MSB of start of array preserved
A undefined Next character of string; =&0D if end of string reached
Y Offset of current character Offset of next character

Returns a character from a string found using GSINIT. The string may be enclosed in double quotes (") 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.

GSREAD parses the character sequence at the position given by (?&F2,?&F3)+Y and scans forward.

If the string began with " then a character is returned unless the closing " is reached; then C=1 and A=&0D is returned. CR encountered before the closing " causes error &FD, Bad string.

Otherwise a character is returned unless CR or space (if C=0 to GSINIT), or CR only (if C=1 to GSINIT) is reached; then C=1 and A=&0D.

(?&F2,?&F3)+Y points to the next character unless C=1, in which case GSREAD skips any spaces following the end of the string.

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: &FFC5 (I/O processor only)

Regregex (talk) 18:31, 11 January 2019 (CET)