OSARGS - Attributes of open object or file system
BBC->FAQ->API->OSARGS Search

 6502  Z80  6809  PDP11  80x86  32016  ARM On entry: On exit:
A A AR0ALR1R0function code  preserved if function unsupported
Y E R1AHR2R1file handle or 0  preserved
X points to four-byte data word in zero page  preserved, data word updated
HLXR2BX points to four-byte data word  preserved, data word updated
R3R2four-byte data word  any returned four-byte data word
If the data word is not used, then it is ignored and so X/HL/R2/BX/R3 may be left set to anything on entry.

Function handle<>0 handle=0
&80 Return file handle internal info   
&FD Write context  Return version and capabilities
&FE Read context  Return last drive used
&FF Ensure open file to media  Ensure all open files to media
0 Read PTR  Read filing system number
1 Write PTR  Read address of command tail
2 Read EXT  Read NFS version
3 Write EXT  Read libfs number
4 Read size allocated to open file  Return disk space used
5 Read EOF  Return disk free space
6 Ensure file size of open file   
7 Convert file handle to filename   
8 Inform change in image filestamp   

Functions, handle<>0

0Reads the sequential pointer of the open object.
1Writes the sequential pointer of the open file. If PTR is moved past the end of an output file, the file is extended with zeroes and zero returned in A. If PTR is moved past the end of an input file, an error is generated. The EOF-error-flag is cleared. The PTR of an open directory cannot be written.
2Reads the extent of the open object.
3Writes the extent of the open file. If the length of the file is reduced, the end disappears. If the length is increased, the file is extended as with function &01 and zero is returned in A. The EOF-error-flag is cleared. The EXT of an open directory cannot be written.
4Reads the space allocated to the open object. This will be at least the current extent of the object, and determines how many more bytes can be written to the object before the object has to be extended or the write fails with a "Can't extend" error.
5Reads the EOF for the open file. If PTR=EXT then &FFFFFFFF is returned, otherwise 0 is returned.
6Ensures the open file is allocated the specified amount of space. Returns the actual amount of space allocated.
7Convert file handle to filename. The data word points to a buffer to return the filename in.
8Inform underlying filing system of new image stamp in data word.
&80Return handle internal information. Returns four bytes of data:
byte 0 = handle in internal format
byte 1-2 = fileserver station number
byte 3 = handle information:    
  • b0: sequence number    
  • b1: known to be a directory    
  • b2: thought to be the URD    
  • b3: thought to be the CSD    
  • b4: thought to be the LIB    
  • b5: current context    
  • b6: EOF flag, next BGET will generate an error    
  • b7: writable
    internal_handle=FNargs(128,handle,2^(handle-32))AND255
  • &FD HADFS: Write filing system context.
  • 25: Currently Selected Directory
  • 26: Currently Selected Library
  • 27: User Root Directory
  • 28: USERNUM/OPTFLG/ENABLE
  • 29: Current directory in memory
  • &FD HADFS: Read filing system context.
  • 25: Currently Selected Directory
  • 26: Currently Selected Library
  • 27: User Root Directory
  • 28: USERNUM/OPTFLG/ENABLE
  • 29: Current directory in memory
  • &FE RISC OS: Returns the filing system information word in the data word and the stream information for the handle in R0.
  • b0
  • b1
  • b2
  • b3: Interactive stream
  • b4: Unbuffered stream that directly supports OSGBPB
  • b5: Object is a directory
  • b6: Object is readable
  • b7: Object is writable
  • b8: Object has been written to
  • b9: EOF flag, next BGET will generate an error
  • b10: Stream is unbuffered
  • b11: Stream is unopened, no other bits have any significance
  • b12: Stream is critical
  • b13: Data lost on this stream
  • b14: Image file busy
  • b15
  • &FF Ensures any buffered data for the open file is written to the media.
      
      

    Functions, handle=0

    0Returns currently selected filing system number in A.
    1Returns address in I/O memory of command line tail.
    2Returns A=2 if early bug-ridden NFS or call is unsupported. Returns A=1 for NFS 3.60+, A=0 for ANFS 4.00+.
    3Returns libfs filing system number in A.
    4Returns used space on the device with the currently selected directory on.
    5Returns free space on the device with the currently selected directory on.
    &FDReturns version number*10 in BCD in A and filing system capability flags in the data word.
    &FEReturns the last drive accessed in A.
    &FFEnsures any buffered data for all open files is written to the media.


    Calling from BBC BASIC

  • ptr=PTR#ch  
  • calls OSARGS 0,ch
  • PTR#chn=ptr  
  • calls OSARGS 1,ch
  • ptr=EXT#ch  
  • calls OSARGS 2,ch
  • EXT#ch=ptr  
  • calls OSARGS 3,ch
  • =EOF#ch nbsp;
  • calls OSBYTE 127,ch on 8-bit systems, which vectors via FSCV. Otherwise, =EOF#ch calls OSARGS 5,ch.

    Special handles

    The Z88 allows:
  • =EOF#-1  
  • returns -1 for expanded, 0 for unexpanded
  • =EXT#-1  
  • returns the amount of free system memory
  • =PTR#-1  
  • returns the number of file handles still available in b16-b31 and the ROM version in b0-b15

    Entry points

  • BBC BASIC Entry Address: 
  • &FFDA
  • 6502 Entry Address:  
  • &FFDA, vectors via &0214
  • Z80 Entry Address:  
  • &FFDA, vectors via &FFDB
  • 6809 Entry Address:  
  • &FFDA, vectors via &FFDB
  • 80x86 Entry Address:  
  • INT &44, vectors via 0000:0110
  • 32000 Entry Address:  
  • SVC &0C
  • PDP-11 Entry Address:  
  • EMT 8, vector &08
  • ARM Entry Address:  
  • SWI "OS_Args", vector &09

    Implementation

    CFS

    Not implemented, simply returns with an RTS instruction {check Master}.

    ROMFS

    Not implemented, simply returns with an RTS instruction {check Master}.

    DFS

    Acorn DFS 0.xx and 1.xx implements &FF to &02. DFS 2.xx and later also implement &03.

    HDFS

    Andrew Duggan's Hierarchial DFS implements OSARGS &03,Y as 'Read allocated space' instead of 'Write extent'.

    Watford DFS

    Implements &FE to &02. OSARGS &FE preserves A, so zero page has to be examined to see if the call has been acted on with code such as: drive%=FNargs(&FE,-1)AND&FF. drive% will be &FF if not supported, or the drive number if it is.

    NFS, ANFS

    NFS 3.34 returns the command line address incorrectly. It points to the first non-'*' character of the command, not the first character of the parameters. NFS 3.60 and later return the command line address correctly. OSARGS 2,0 returns A<>2 to indicate this.
    NFS before 3.60 returns A=2, NFS 3.60+ returns A=1, ANFS 4.00+ returns A=0.

    ADFS

    HADFS

    Implements &FD to &06.



    This page last updated 11-Aug-2006