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:


BEAE CLOSE

Submitted by Steve Fewell

Description:

Call routine &BA3E to copy BASIC Text pointer A address to BASIC text pointer B, Check that the next character is '#'
('Missing #' error if not), set Y to the number after the '#' (the file channel number).

Call &9B96 to check for the end of statement (at BASIC Text Pointer B). If the next character after the CLOSE
parameter value is not ':', '<cr>' or 'ELSE-token' then issue 'Syntax error', as the statement was not terminated
correctly.

Set Y to the value of location &2A (i.e. the LSB byte of the channel number). Note: if Y is zero then all open files
will be closed.
Set A to zero (indicating to the OSFIND routine that we are closing a file).
Call the Operating system OSFIND routine (&FFCE) to carry out the file operation.
Jump to &9005 to execute the next BASIC statement in the program/command line.


Disassembly for the CLOSE routine

BEAE > 032 062 186 20 3E BA JSR &BA3E Copy PTR A to PTR B, check for '#', get file channel number & store it in Y
BEB1   032 150 155 20 96 9B JSR &9B96 Check for end of Statement (PTR B)
BEB4 * 164 042 A4 2A LDY &2A
BEB6   169 000 A9 00 LDA#&00
BEB8   032 206 255 20 CE FF JSR &FFCE   OSFIND (Open or close a file)
BEBB   128 238 80 EE BRA -18 --> &BEAB   [JMP &9005 Execute next statement]

 


 Back to 8BS
Or