Chapter 8 Peripheral Devices 277
by the system, you may use that memory freely. One method
is
to specify
which buffers you want when you open a disk channel and write your
routines in one or two of the buffers that are not in use.
The information that follows
is
not intended for beginning pro-
grammers. The use of the MEMORY-READ, MEMORY-WRITE, and
MEMORY-EXECUTE commands requires a thorough understanding
of
machine language programming and the Disk Operating System.
MEMORY-WRITE
To store
data
into the disk drive memory, you will need
to
use the
MEMORY-WRITE command. Like POKE in BASIC, this instruction
puts whatever data you specify into any memory location you want. Take
the example of a POKE statement.
POKE
768J
255
There
is
only one byte transferred with each POKE statement. The
MEMORY-WRITE command allows you to transfer up to
34
bytes with a
single statement. To perform the same operation using MEMORY-WRITE
you would need
to
convert the decimal memory location into a hexadecimal
number;
300
is
the hexadecimal equivalent
of
decimal 768. Since you can
transfer only one byte at a time with a POKE command, BASIC always
knows how many bytes to expect. With the MEM
OR
Y -WRITE command,
you will need
to
indicate how many bytes are going
to
be transferred. In this
case, only one byte
is
going to
be
transferred, so the command will
be
quite
short.
There are some special constraints that must
be
used with these instruc-
tions since they are actually just extensions of machine code.
1.
The memory address must be entered as two bytes, low byte first,
then high byte.
2.
All of the data must
be
transferred
as
character strings (CHR$).
3.
The
6502
understands only binary data. The instruction allows you
to enter numbers in hexadecimal; but BASIC doesn't use that
notation.
For
instance,
65536 decimal =
FFFF
hexadecimal
This
is
two hexadecimal bytes
(FF
and FF). To represent them
in this mode, take the two bytes and convert each to its decimal