Appendix
I
Blocking and Deblocking
Algorithms
Upon
each call
to
the BIOS
WRITE
entry
point,
the
CP/M-86
BDOS includes
information
that
allows effective sector blocking
and
deblocking where the host disk
subsystem has a sector size which is a multiple
of
the basic 128-byte unit. This
appendix presents a general-purpose algorithm
that
is
included in the CBIOS
and
that
uses the BDOS information to perform the operations automatically.
Upon
each call
to
WRITE,
the BDOS provides the following information in register
CL:
0=
normal sector write
1
= write
to
directory sector
2
= write
to
the first sector
of
a new
data
block
Condition
0 occurs whenever the next write
operation
is
into a previously written
area,
such as a
random
mode
record
update,
when the write
is
to
other
than
the first
sector
of
an
unallocated block,
or
when the write
is
not
into
the
directory area.
Condition
1 occurs when a write
into
the directory
area
is
performed.
Condition
2
occurs when the first record (only)
of
a newly allocated
data
block
is
written.
In
most
cases, application
programs
read
or
write mUltiple 128-byte sectors in sequence,
and
thus there
is
little overhead involved in either
operation
when blocking
and
deblock-
ing records since pre-read operations can be avoided when writing records.
This appendix briefly describes the blocking
and
deblocking algorithm (the file
is
included
on
your
CP/M-86
system diskette). Generally, the algorithms
map
all
CP
1M
sector read
operations
onto
the host disk
through
an
intermediate buffer
which is the size
of
the
host
disk sector.
Throughout
the
program,
values
and
variables which relate
to
the
CP
1M
sector involved in a seek operation are prefixed
by
"sek", while those related
to
the host disk system are prefixed by "hst".
1-1