OSFILE - Operations on whole files and directories
BBC->FAQ->API->OSFILE Search

6502 A80 ARM PDP11 32016 80x86 On entry: On exit:
AAR0R0R1ALfunction code object type or preserved if function unsupported
XYHL R1 BXcontrol block preserved, control block updated
  R1 R2 pointer to filename preserved
  R2 R3 Load Address Load Address
  R3 R4 Execution Address Execution Address
  R4 R5 Start Address Length
  R5 R6 End Address or Attributes Attributes
Control block:
&00 Address of filename
&02 Load Address
&06 Execution Address
&0A Length, or start address for SAVE and CREATE
&0E Attributes, or end address for SAVE and CREATE

Function  
&FD  Read file system information (System Internal Name)
&FE  Verify file
&FF  Load file
0 Save file
1 Write load, exec, attrs
2 Write load address
3 Write execution address
4 Write attributes
5 Read object information
6 Delete object
7 Create empty file
8 Create a directory

Object types returned in A are:
&FF Execute-only file
&00 Object not found
&01 File found
&02 Directory found
&03 Image file found (file accessible as a directory)
&04 Unresolved symbolic link found
Note: The Tube protocol masks off bit 7 of the return value from OSFILE, so A=&FF is returned as A=&7F.

File attributes. These are held in four bytes as follows:
Byte &0E  bit 7  Private
  bit 6  Executable by others
  bit 5  Writable by others
  bit 4  Readable by others
  bit 3  Locked
  bit 2  Executable only by owner
  bit 1  Writable by owner
  bit 0  Readable by owner
Byte &0F  bits 0-4  Date: day of month
  bits 5-7  Date: year since 1981, bits 4-6
Byte &10  bits 0-3  Date: month of year
  bits 4-7  Date: year since 1981, bits 0-3
Byte &11  bits 0-7  Undefined (returned as zero)
See also File Access

Functions

&FD Read file system information. The attributes field is returned holding the sector start address.
&FE Verifies a file. The control block is as for A=&FF, LOAD. If the verification is successful, A is returned holding &01 and the control block holds the file information, as with function call &05. If the verification fails, A is returned holding &00 and the load address is returned holding the address where the verification failed. If the file does not exist or is a directory or does not have read access, then an error is generated.
&FF Loads a file into memory. If the low byte of the execution address is zero, the file's own load address is used, otherwise the supplied address is used to load to. If the filename does not exist, or is a directory, or an execute-only file, or does not have read access, then an error is generated.
&00Saves a file. If a file already exists with the same name, it is overwritten, with the file access and the case of the name staying the same. If the file is locked, or a directory exists with the same name, or the file is open, then an error is generated.
&01Write an object's reload address, execution address and attributes.
&02Write an object's reload address.
&03Write an object's execution address.
&04Write an object's attributes.
&05Read object's catalogue information into the control block.
&06Delete object. If the object does not exist, A returned as &00. If the object is locked, or is not owned, or is a directory that is not empty, or is open, then an error is generated.
&07Create an empty file of defined length. Block as for SAVE. The supplied start address is usually passed as &0 and the end address as the required length. No data is transfered, and the file does not necessarily contain zeros. Some file systems may deliberately overwrite any existing data in the file. If a file already exists with the same name, it is overwritten, with the file access and the case of the name staying the same. If the file is locked, or a directory exists with the same name, or the file is open, then an error is generated.
&08Create a directory. The length field is passed holding a suggested minimum number of entries required, or zero for a default number. If a directory already exists, there is no error. The created directory is locked. If a file already exists, an error is generated.

Calling from BBC BASIC

  • LOAD fn$  
  • calls OSFILE &FF
  • CHAIN fn$  
  • calls OSFILE &FF
  • SAVE fn$  
  • calls OSFILE &00

    Entry points

  • BBC BASIC Entry Address: 
  • &FFDD
  • 6502 Entry Address:  
  • &FFDD, vectors via &0212
  • Z80 Entry Address:  
  • &FFDD, vectors via &FFDE
  • 6809 Entry Address:  
  • 80x86 Entry Address:  
  • INT &45, vectors via 0000:0114
  • 32000 Entry Address:  
  • SVC &0A
  • PDP-11 Entry Address:  
  • EMT 7, vector &07
  • ARM Entry Address:  
  • SWI "OS_File", vector &08


    This page last updated 11-Aug-2006