APPENDIX IV

ACCESSING THE RaFS FROM MACHINE CODE

Section 43 of the BBC User Guide between pages 442 and 466 contains most of the information you will need in order to be able to use the RaFS in assembler. In addition any information contained within your DFS manual should also be read. All of these OS routines operate exactly as detailed in these manuals, but to clarify matters the information given here should be of some help. There are however, some: differences that are peculiar to the RaFS and these are detailed in this appendix.

OSFIND

Entry address: &FFCE Indirection vector: &21C

Exactly as given in the BBC User Guide. On exit Y will contain a channel number if the file has been succcesfully opened, or 0 if it was unable to open the file. However, the RaFS requires that Y is assigned a unique filing handle for the read and write operations. Details are given under USBPUT, OSBGET and OSGBPB.

OSARGS

Entry address: &FFDA Indirection vector: &214

Exactly as given in the BBC User Guide. The RaFS has however been officially allocated its own unique filing system identification number, which is 12. Therefore, with A=0 and Y=0, use of OSARGS will return in A the number 12 if the RaFS is active. At the same time it also places the Rom number in zero page location &F5.

If Y is non-zero the value of A determines the action to be taken on the file whose handle (see OSBPUT, GSBGET and OSBPB) is in Y. The BBC User Guide however is not very clear on this, so the following should help.

A=0 Read sequential pointer = Read PTR#
(BASIC; A%=PTR#<channel>)
A=1 Write sequential pointer = Write PTR#
(BASIC; PTR#<channel>=A%)
A=2 Read sequential file length = Read EXT#
(BASIC; A% = EXT#<channel>)

In all other respects OSARGS is implemented exactly as in the BBC User Guide.

OSFILE

Entry address. &FFDD Indirection vector: &212

Exactly as in the BBC User Guide. However, to clarify the action taken according to the value of A consider the following:

A=0

SAVE, *SAVE

A=1

Write the catalogue information for the named file.

A=2

Write load address only = *RELOAD

A=3

Write execution address only = *REXEC

A=4

Write attributes only = *ACCESS

A=5

Read named file's catalogue information, place file type in A.

A=7

Delete the named file = *DELETE

A-&FF

LOAD, *LOAD

OSBGET

Entry address: &FFD7 Indirection vector: &216

Exactly as per the BBC User Guide except that the channel number allocated via OSFIND should be safely stored away somewhere in memory and the value of Y should be set to &4E (decimal 78). If this is not done the 'Channel' error will occur. The value of Y (&4E) is a unique filing handle allocated to the RaFS for read operations.

OSBPUT

Entry address: &FFD4 Indirection vector: &218

As above, but now the required filing handle is &4F (decimal 79). This is the filing handle allocated to the RaFS for all write operations.

OSGBPB

Entry address: &FFD1 Indirection vector: &21A

This facility is not implemented in the cassette filing system, but will be known to disc users. For the benefit of both the following should be of some use.

OSGBPB stands for OS Get Byte Put Byte, and is a general random access command. It allows files to be OPENed for both reading and writing. The BASIC 2 keyword OPENUP performs the same task. The routine will read or write a byte (or group of bytes) to or from a specified and previously opened file. The option to read or write depends on the value of A and the filing

handle used. The length of the data to be passed and its locution are specified in a control block located somewhere in memory.

On entry X (lo-byte) and Y (hi-byte) point to this control block which is set up as follows.

Offset

 

XY+0

 
 

Filing handle

XY+1

 
 

Pointer to data (address)

XY+5

 
 

Number of bytes to be passed

XY+9

 
 

Byte offset in file (if used)

XY+13

 

The value of A determines the operation to be performed.

A=1

PUT byte(s) using byte offset.

A=2

PUT byte(s) ignoring byte offset.

A=3

GET byte(s) using byte offset.

A=4

GET byte(s) ignoring byte offset.

A=8

Read files names.

With A=1 or A=2 the filing handle at XY+0 should be &4F, and with A=3 or A=4 this should be &4E.

On exit C clear signifies a successful transfer. C set indicates the the end of file was reached before the transfer had been completed. In this case the number of bytes and the byte offset (if used) are altered to indicate just how much data has been passed, and the new pointer value is the old value plus the number of bytes passed.

OSFSC

Entry address: See below Indirection vector: &21E

This routine is not detailed in either the BBC User or Disc system guides. There is no actual entry address for use with this routine which is known as the File system control entry routine, and is responsible for a host of filing system commands.

As there is no direct entry address a subroutine should be used to call the routine, this means that once it has completed its designated task it will return in an orderly fashion. To do this proceed as follows:

LDA#<value>:JSR fsc:......rest of program
.fsc JMP(&21E)

In this way the return from the routine will be to the point following the JSR fsc instruction.

The value of A again determines the action to be carried out.

A=0

*OPT X = 1st parameter, Y=2nd parameter.

A=1

EOF# Y=filing handle.

A=2

*RUN, CHAIN X and Y point to filename in Ram.

A=3

As above.

A=4

As above.

A=5

*CAT

A=6

CLOSE spool, exec files.

A=7

Returns X=&4E , Y=&4F

A=8

*ENABLE

A=8 does not apply to the RaFS, but may be of some use to disc users.