Introduction
Open a File - F$OPEN and F$MOPEN
Close a File - F$CLOSE
Create a File - F$MAKE
Delete a File - F$DELETE
Rename a File - F$RENAME
Test of the Existance of a File - F$EXIST
Read a Block from a File - F$READ
Write a Block to a File - F$WRITE
:CP/M File Input/Output Routines
Th� followin� routine� ar� general-purpos� fil� I/� routine� �
whic� interfac� t� CP/� throug� th� Entr� Poin� a� locatio� 5� �
The� preserv� BC�� DE�� an� HL� an� the� retur� wit� th� standar� �
CP/� erro� code� fo� th� correspondin� routines.
Specifically, these routines are --
F$OPEN Open a file
F$MOPEN Open/Create a file
F$CLOSE Close a file
F$MAKE Create a file
F$DELETE Delete a file
F$RENAME Rename a file
F$EXIST Test of existance of a file
F$READ Read a block (128 bytes) from a file
F$WRITE Write a block (128 bytes) to a file
:Open a File
Routine Name: F$OPEN
Function�
Ope� th� fil� specifie� b� th� FC� pointe� t� b�� DE� �
I� fil� no� found�� F$OPE� return� wit� a� erro� cod� i� � (0FFH� �
an� Zer� Fla� Clea� (NZ).
Inputs: DE = pointer to FCB
Outputs: A = Error Code and PSW Flags Set (Zero Flag)
0 --> No Error
0FFH --> File not opened
Registers Affected: PSW
SYSLIB Routines Called: BDOS, CAPS, CIN, COUT, CRLF, PRINT
Special Error Conditions: -None-
Routine Name: F$MOPEN
Function�
Ope� th� fil� specifie� b� th� FC� pointe� t� b�� DE� �
I� fil� i� no� found�� F$MOPE� trie� t� creat� one�� I� return� �
th� erro� cod� o� 0FF� i� � i� ther� wa� no� enoug� roo� i� th� �
dis� director� t� creat� th� director� entry.
Inputs: DE = pointer to FCB
Outputs: A = Error Code and PSW Flags (Zero Flag) Set
0 --> No Error
0FFH --> File not opened
Registers Affected: PSW
SYSLIB Routines Called: BDOS, CAPS, CIN, COUT, CRLF, PRINT
Special Error Conditions: -None-
:Close a File
Routine Name: F$CLOSE
Function:
Close the file whose FCB is pointed to by DE.
Inputs: DE = pointer to FCB
Outputs: A = Error Code
0 --> No Error
0FFH --> Error in closing file
Registers Affected: PSW
SYSLIB Routines Called: BDOS
Special Error Conditions: -None-
:Create a File
Routine Name: F$MAKE
Function:
Create (Make) the file whose FCB is pointed to by DE.
Inputs: DE = pointer to FCB
Outputs: A = Error Code
0FFH --> No directory space available
Not 0FFH --> No Error; Value is byte address in
TBUFF (80H-0FFH) of directory entry
allocated to the FCB
Registers Affected: PSW
SYSLIB Routines Called: BDOS, F$DELETE
Special Error Conditions: -None-
:Delete a File
Routine Name: F$DELETE
Function�
Delet� th� fil� whos� FC� i� pointe� t� b� DE� I� fil� �
doe� no� exist�� nothin� happen� (n� erro� messag� o� cod� i� �
given).
Inputs: DE = pointer to FCB
Outputs: -None-
Registers Affected: PSW
SYSLIB Routines Called: BDOS
Special Error Conditions: -None-
:Rename a File
Routine Name: F$RENAME
Function�
F$RENAMРma� b� use� t� renam� � file�� O� entry�� D� �
pt� t� th� firs� twelv� byte� o� th� file'� FC� an� H� pt� t� th� �
firs� twelv� byte� o� th� FC� fo� th� ne� fil� (tha� is� onl� th� ��F� an� F� field� ar� significant�� s� th� res� o� a� FC� nee� no� �
b� presen� fo� thi� functio� t� work)�� F$RENAMРcontain� a� �
interna� FC� whic� i� structure� fro� th� tw� entrie� t� properl� �
rename the file.
Inputs: HL pts to 1st 12 bytes of new FCB
DE pts to 1st 12 bytes of old FCB
Outputs: Zero Flag Set (Z) means error (file not found)
Registers Affected: PSW
SYSLIB Routines Called: BDOS, FILLB, MOVEB
Specia� Erro� Conditions�� Fil� No� Foun� error�� indicate� �
by Z flag
:Test of Existance of a File
Routine Name: F$EXIST
Function�
F$EXIS� test� fo� th� presenc� o� th� fil� whos� FC� i� �
pte� t� b� D� i� th� curren� disk/use� area�� I� thi� fil� doe� �
no� exis� i� thi� area�� F$EXIS� return� wit� th� Zer� Fla� Se� �
(Z); if this file does exist, F$EXIST returns with NZ.
Inputs: DE pts to FCB of file to test for
Outputs: Zero Flag Set (Z) means file not found; NZ means
file found
Registers Affected: PSW
SYSLIB Routines Called: BDOS
Specia� Erro� Conditions� None
:Read a Block from a File
Routine Name: F$READ
Function�
Rea� nex� bloc� (12� bytes� fro� th� opene� fil� whos� �
FC� i� pointe� t� b� D� int� TBUF� (buffe� a� 80� - 0FFH).
Inputs: DE = pointer to FCB
Outputs: A = Error Code
0 --> No Error
1 --> Read past end of file
2 --> Reading unwritten data in random access
Registers Affected: PSW
SYSLIB Routines Called: BDOS
Special Error Conditions: -None-
:Write a Block to a File
Routine Name: F$WRITE
Function�
Writ� nex� bloc� (12� bytes� fro� TBUF� (buffe� a� 80� �
t� 0FFH� t� th� opene� fil� whos� FC� i� pointe� t� b� DE.
Inputs: DE = pointer to FCB
Outputs: A = Error Code
0 --> No Error
1 --> Error in extending file
2 --> End of disk data
0FFH --> No more directory space
Registers Affected: PSW
SYSLIB Routines Called: BDOS
Special Error Conditions: -None-