×   Main Menu ALL The 8BS News Manuals (New menu) Links Worth a Look Tools Disc and Basic Webring Site Map 8BS Guestbook Old Guest Book Me The Barnsley Rovers   
8-Bit Software

The BBC and Master Computer Public Domain Library

ACF8 Extract next field

Submitted by Steve Fewell

Description:

This routine gets the next field from an input (or data) line. The field value is returned as a string in the SWA

First, get the next non-space character and set Y to point to this character.
If the character is a double quote ("), then we have found a String value, so call routine AD19 to extract the String,
place the value of the String (without the surrounding quotes) in the SWA and update BASIC Text Pointer B Offset to
point to after the String value.

Keep getting the next character from BASIC Text Pointer B (Starting at Y) and store the character in the next free
SWA location (starting at &0600 - uses X as an index), until the character is a carriage return <cr>, or a comma ','.

Decrement Y and X (so that they point to the <cr> or ',' character), store X in &36 (the length of the field
excluding the <cr> or ',' character), and store Y in &1B (so that PTR B points to the <cr> or ',' character).

Set A to 00 (as return type is a String), and exit.


Disassembly for the Extract next field routine

ACF8   032 213 142 20 D5 8E JSR &8ED5 Get next non-space character (PTR B)
ACFB " 201 034 C9 22 CMP#&22
ACFD   240 026 F0 1A BEQ 26 --> &AD19 Extract String
ACFF   162 000 A2 00 LDX#&00
AD01   177 025 B1 19 LDA (&19),Y
AD03   157 000 006 9D 00 06 STA &0600,X
AD06   200 C8 INY
AD07   232 E8 INX
AD08   201 013 C9 0D CMP#&0D
AD0A   240 004 F0 04 BEQ 4 --> &AD10
AD0C , 201 044 C9 2C CMP#&2C
AD0E   208 241 D0 F1 BNE -15 --> &AD01
AD10   136 88 DEY
AD11   202 CA DEX
AD12 6 134 054 86 36 STX &36
AD14   132 027 84 1B STY &1B
AD16   169 000 A9 00 LDA#&00
AD18 ` 096 60 RTS

 


 Back to 8BS
Or