The FMS Open routine, DFMOPN, is called directly by CIO via the FMS Device Vector Table, DFMSDH at $7CB.
The DFMOPN routine is the FMS file open routine.
|Address — $8AB
|Entry Registers —
||A = Don’t Care
|X = IOCB number times 16.
|Y = Don’t Care.
|Exit Registers —
||A = Unknown.
|X = Unknown.
|Y = Unknown.
1) Initialize for this operation by calling SETUP.DFOIN
2) Decode the filename via FNDCODE.
3) Examine the open code in ICAUX1 for the open-for-directory-read command. If this is a directory read command, go to LISTDIR.
4) If not a directory read, then search the directory for the first match on the file name and save the resulting search condition on the stack.
5) Determine the exact type of Open operation to he performed by examining the IOCB ACUXI field. If INPUT, go to DFOIN. If Output, go to DFOUT. If Update, go to DFOUPD. If Append, go to DFOAPN. If none of the above, exit via the ERDVDC (device command error) exit.
DFOIN ($8D8) is entered when opening a file for Input. The routine pops the stack to determine if the directory search for the file name was successful. If the file name was found in the directory, then go to DFOUI. If the search was not successful, then exit to ERFNF (file not found).
DFOUPD ($8DD) is entered when opening a file for Update (Input and Output). The routine pops the stack to determine if the file name was found in the directory. If the file was not found, then exit to ERFNF (file not found). If the file was found, insure that the file is not Locked by calling TSTLOCK. If the file is unlocked, then continue at DFOUI.
DFOUI ($8E3) is entered to finish opening a file for Input or Update. The read setup routine, DFRDSU, is called. FMS then exits via the GREAT exit.
DFDRDSU ($9AE) is entered to set up a data file for reading. It begins by calling SETFCB to set some standard file information into the FCB. It continues by setting up the FCB with various other parameters to read the first data sector in the file. This sector is read via the RDNSO routine. When the sector has been read into the sector buffer, the code returns to the caller.
DFOAPN ($BEC) is entered to open a file for Append.
1) Pop the stack to determine if the file has been found in the directory. If the file was not found exit via ERFNF.DFOOUT
2) If the file was created by DOS 1, then exit via ERAPO.
3) Insure the file is not locked by calling TSTLOCK.
4) Insure the diskette is not write protected by calling OPVTOC.
5) Allocate a new sector for the start of the Append chain by calling GETSECTOR.
6) Save the sector number of the sector obtained in FCBSSN so that it will be available when the file is closed.
7) Continue opening the file as it it were being opened for Output at DHFOX2.
The DFOOUT ($911) routine is entered when opening a file for Output.
1) Pop the stack to determine if the file was found in the directory.DHFOX2
2) If the file was found, then delete it via the XDELO ($C53) routine.
3) If the file was not found, then make a new entry in the directory via the code at DFOXI ($91D).
4) Allocate a data sector for the file via the GETSECTOR routine.
5) Put the necessary information about the file into the directory and write the directory sector hack to the disk.
6) Continue at DHFOX2.
DHFOX2 ($97C) is entered to finish the Open process for files that are being opened for Output or Append.
1) Finish initializing the FCB via SETFCB.SETFCB
2) If the TSTDOS routine determines that the file name being opened is DOS.SYS, then write out DOS via the WRTDOS routine.
3) Exit via GREAT.
The SETFCB ($995) routine is used in the various Open file routines to place certain common data into the FCB.
Return to Table of Contents | Previous Chapter | Next Chapter