×   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

AAE7 OPENUP

Submitted by Steve Fewell

Description:

Set A to #&C0. This is the OSFIND (&FFCE) option to open a file for update/random access.
Store A (the OSFIND option number) to the 6502 stack.

Call routine &AD36 to obtain the value after the OPENUP keyword (this should be the filename to open).
If the result of the expression value is not a String value then issue a 'Type mismatch' error.

Call routine &BE2B to store a carriage return character at the end of the SWA (as the OSFIND operation requires the
filename to be terminated by a '<cr>' character.

Set X to #&00 and Y to #&06, so that X & Y point to the filename (i.e. the SWA location - &0600).
Retrieve the OSFIND option from the 6502 stack.
Call the Operating System OSFIND routine to perform the file open operation and return the channel number that the file
was opened on in A.

Jump to routine &AE18 to set the IWA to the 8-bit value in A (i.e. the channel number of the opened file).
This causes this routine to return the channel number value - which is usually then assigned to a variable by the BASIC
program.


Disassembly for the OPENUP routine

AAE7   169 192 A9 C0 LDA#&C0
AAE9 H 072 48 PHA
AAEA 6 032 054 173 20 36 AD JSR &AD36 Get value / result of expression (if bracketed)
AAED   208 013 D0 0D BNE 13 --> &AAFC
AAEF + 032 043 190 20 2B BE JSR &BE2B Store #&0D (carriage return, '<cr>') at the end of the SWA value
AAF2   162 000 A2 00 LDX#&00
AAF4   160 006 A0 06 LDY#&06
AAF6 h 104 68 PLA
AAF7   032 206 255 20 CE FF JSR &FFCE   OSFIND
AAFA   128 198 80 C6 BRA -58 --> &AAC2 [JMP &AE18 Set IWA to the 8-bit value in A]
AAFC L 076 146 144 4C 92 90 JMP &9092 Type mismatch error

 


 Back to 8BS
Or