8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


BASIC IV ROM Routines
Page Last Altered:


9C6A Check for End of Statement

Submitted by Steve Fewell

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

Description:

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 &9C5A).
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 9C41 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

9C6A

 

164 010

A4 0A

LDY &0A

9C6C

 

136

88

DEY

9C6D

 

200

C8

INY

9C6E

 

177 011

B1 0B

"LDA (&0B),Y"

9C70

 

201 032

C9 20

CMP#&20

9C72

 

240 249

F0 F9

BEQ -7 --> &9C6D

9C74

:

201 058

C9 3A

CMP#&3A

9C76

 

240 008

F0 08

BEQ 8 --> &9C80

9C78

 

201 013

C9 0D

CMP#&0D

9C7A

 

240 004

F0 04

BEQ 4 --> &9C80

9C7C

 

201 139

C9 8B

CMP#&8B

9C7E

 

208 173

D0 AD

BNE -83 --> &9C2D 'Syntax error'

9C80

 

24

18

CLC

9C81

 

152

98

TYA

9C82

e

101 011

65 0B

ADC &0B

9C84

 

133 011

85 0B

STA &0B

9C86

 

144 002

90 02

BCC 2 --> &9C8A Set PTR A Offset to 1 & Check for Escape error condition

9C88

 

230 012

E6 0C

INC &0C

9C8A

 

160 001

A0 01

LDY#&01

9C8C

 

132 010

84 0A

STY &0A

9C8E

$

036 255

24 FF

BIT &FF

9C90

0

048 175

30 AF

BMI -81 --> &9C41 Escape error

9C92

`

96

60

RTS


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

9C5A   164 027 A4 1B LDY &1B
9C5C   128 014 80 0E BRA 14 --> &9C6C Check end of Statement

 


 Back to 8BS
Or