EasyManua.ls Logo

NEC CP/M-86 - Page 58

NEC CP/M-86
280 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Basic Disk Operating System (BDOS) Functions
4-24
READ
RANDOM
ENTRY
CL:
2lH
DX: FCB
Offset
RETURN
FUNCTION
33
AL:
Return
Code
READ
RANDOM
The
Read
Random
function reads a record
at
a
particular
record number. The
record
number
is
selected by the 24-bit value constructed from the three-byte field
(rO,
rl,
r2) in the FCB at byte positions 33, 34,
and
35.
The
sequence
of
24 bits is
stored
with least significant byte first
(rO),
middle byte next
(rl),
and
high byte last
(r2).
CPIM
does
not
reference byte r2, except in computing the size
of
a file
(function 35). Byte r2 must be zero, however, since a non-zero value indicates
overflow
past
the end
of
file.
The
rO,
rl
byte
pair
is
treated
as a double-byte,
or
"word" value, which contains the
number
of
the record
to
read. This value ranges from 0 to 65535, providing access
to
any
particular
record
of
any
size file. In
order
to
access a file using the Read
Random
function, the base extent (extent 0) must first be opened. Although the base
extent
mayor
may
not
contain allocated
data,
this ensures
that
the
FCB
is
properly
initialized for subsequent
random
access operations. The selected record
number
is
then
stored into the
random
record field
(rO,
r 1),
and
the BDOS is called
to
read the
record. Register
AL
returns either
an
error
code (see Table 4-4)
or
the value 00
indicating the operation was successful.
In
the latter case, the buffer
at
the
current
DMA
address contains the randomly accessed record. Unlike the sequential read
operation, the
Random
Read function does not advance the record number. Thus,
subsequent
random
read operations continue
to
read the same record.
Each
random
read operation automatically sets the logical extent
and
current
record values. Thus, the file
can
be sequentially read
or
written starting from the
current
randomly
accessed position. Note, however,
that
as a
program
switches
from
random
mode
to
sequential, the last randomly read record is reread. Similarly,
the last record
is
rewritten as a
program
switches from a
random
to
sequential write
operation.
To
obtain
the effect
of
a sequential
1/0
operation, advance the
random
record position following each
random
read
or
write.

Table of Contents

Related product manuals