Chapter Nine

FMS
CLOSE
ROUTINES


The FMS close routine is called directly by CIO via the FMS Device Vector Table, DFMSDH at $7CB.

DFMCLS
Address $B15 
Entry Registers  
A = Don't Care.
X = IOCB number times 16.
Y = Don't Care.
Exit Registers    
A = Unknown.
X = Unknown.
Y = Unknown.

Functions:

1) Initialize via call to SETUP.
2) If the file was not opened for some form of output (Output, Update or Append) then clear the FCB open flag, FCBOTC and exit via FGREAT.
3) If the FCBFLG indicates that the file has not acquired sectors, then continue at CLUPDT to close the Update file.
4) Write the last data sector via WRTLSEC.
5) Read the file's directory sector into the directory buffer via the RRDIR routine.
6) Get the sector count from the directory.
7) If the file was opened for Output (i.e. it is not open for Append), then continue at CLOUT.
8) Read all the data sector of the file until the end-of-file sector is found.
9) Place the sector address of the start of the Append chain into the link sector field of the (old) end-of-file sector.
10) Continue at CLOUT.
CLOUT
The CLOUT ($B50) routine is entered to finish closing a file that had been opened for Output or Append.
1) The sector count field of the directory is updated.
2) The open for output flag is turned off.
3) The file in use flag is set.
4) The directory sector is written back to the disk by the DRTDIR routine.
5) The VTOC sector is written back to the disk by the WRTVTOC routine.
6) The FCB open code flag, FCBOTC, is cleared to zero.
7) Exit via FGREAT.
CLUPDT
The CLUPDT ($B75) is called to finish the closing of a file that had been opened for Update.
1) If the current sector in the sector buffer has been modified then write it back to the disk via the WRCSIO routine.
2) Clear the FCB open flag, FCBOTC, to zero.
3) Exit via FGREAT.

Return to Table of Contents | Previous Chapter | Next Chapter