Chapter
1
I
System Calls
Open
Open
a
File
Function Call
3DH
Opens
a
file. The following values are allowed for the
ac-
cess code:
0
-
The file is opened for reading.
1
-
The file is opened for writing.
2
-
The
file
is
opened for both reading and writing.
The readiwrite pointer
is
set at the
first
byte of the file
and the record size of the file
is
1
byte. The returned
file handle
must be used for subsequent
IiO
to the file.
Entry Conditions:
AH
=
3DH
DS:DX
=
pointer to
ASCIIZ
pathname
for file to open
AL
=
access
code
(0
=
read,
1
=
write,
2
=
read
and
Exit Conditions:
Carry set:
Carry not set:
Error
Returns:
AX
=
12
write)
AX
=
error
code
AX
=
file
handle
number
Invalid access. The access specified in AL was not in
the range 0-2.
File not found. The path specified was invalid or not
found.
Access denied. The user attempted to open
a
directory
or volume
ID,
or open
a
read-only file for writing.
Too many open files. There were no free handles
available in the current process
or
the internal sys-
tem tables were full.
AX
=
2
AX
=
5
AX
=
4
108