×   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

9BA6 Check for End of Statement

Submitted by Steve Fewell

Name: Check for End of Statement
Starting Address: &9BA6
Entry criteria: &0A, &0B and &0C point to the input line.
Exit: Syntax Error if unexpected input is found at end of a statement.


This routine is called before a command (e.g. CLS) is executed to check that the BASIC
Statement line is terminated correctly, and contains no errors. If all is ok then
the routine returns sucessfully and the command is performed.
If errors are found on the input line, then a Syntax Error is generated.

The routine does the following:
Set Y to the offset which contains the next character to check. This will be &0A for the BASIC Text pointer A offset,
or, to &1B for the BASIC text pointer B offset (if called from routine &9B96).
Get next character on the line (at the offset position), skiping any spaces found.
If the next character is ':' or '<return>' or 'ELSE' (token &8B) then the
line has been terminated correctly, so update the pointer (&B, &C) and set the pointer offset
to 1. Test whether an error has occurred, if no error then return (otherwise goto 9B7D to issue an 'Escape' error).

If the next character on the line is anything else then generate a Syntax Error.

Disassembly for the Check for End of Statement routine

9BA6   164 010 A4 0A LDY &0A
9BA8   136 88 DEY
9BA9   200 C8 INY
9BAA   177 011 B1 0B LDA (&0B),Y
9BAC   201 032 C9 20 CMP#&20
9BAE   240 249 F0 F9 BEQ -7 --> &9BA9
9BB0 : 201 058 C9 3A CMP#&3A
9BB2   240 008 F0 08 BEQ 8 --> &9BBC
9BB4   201 013 C9 0D CMP#&0D
9BB6   240 004 F0 04 BEQ 4 --> &9BBC
9BB8   201 139 C9 8B CMP#&8B
9BBA   208 173 D0 AD BNE -83 --> &9B69 'Syntax error'
9BBC   024 18 CLC
9BBD   152 98 TYA
9BBE e 101 011 65 0B ADC &0B
9BC0   133 011 85 0B STA &0B
9BC2   144 002 90 02 BCC 2 --> &9BC6 Set PTR A Offset to 1 & Check for Escape error condition
9BC4   230 012 E6 0C INC &0C
9BC6   160 001 A0 01 LDY#&01
9BC8   132 010 84 0A STY &0A
9BCA $ 036 255 24 FF BIT &FF
9BCC 0 048 175 30 AF BMI -81 --> &9B7D Escape error
9BCE ` 096 60 RTS

Disassembly for the Check for End of Statement (PTR B) routine

9B96   164 027 A4 1B LDY &1B
9B98   128 014 80 0E BRA 14 --> &9BA8


 Back to 8BS