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

 6502  Z80  6809  PDP11  80x86  31016  ARM On entry: On exit:
A A AR0ALR1R0function code  object type or preserved if function unsupported
XYHLXR1BX control block  preserved, control block updated
ctrl+&00 R2R1pointer to filename  preserved
ctrl!&02 R3R2Load Address  Load Address
ctrl!&06 R4R3Execution Address  Execution Address
ctrl!&0A R5R4Start Address  Length
ctrl!&0E R6R5End Address or Attributes Attributes

Function  
&FC  Write file system information
&FD  Read file system information
&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 3  Locked
      bit 6  Executable by others  bit 2  Executable by owner
      bit 5  Writable by others  bit 1  Writeable by owner
      bit 4  Readable by others  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

    &FC Write file system information.
    &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:  
  • &FFDD, vectors via &FFDE
  • 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