346
Using
Peripheral
Devices
40
Take
only
the
leftmost
34
bytes.
N
is
the
length.
50
Write
this
information
into
the
1541's
RAM
beginning
at
$0500.
60
Execute
a
memory
read
to
put
the
contents
of
locations
$0500-$0510
of
the
154l's
RAM
into
the
buffer.
70
I
counts
the
bytes
read.
80
Get
a
byte
from
the buffer
through
the
command
channel.
90
Print
out
the
character.
100
Go
on
to
the
next
byte.
110
Close
the
command
channel.
Memory
Execute
(M-E)
This
command
transfers
program
control
of
the
1541
processor
to
the
designated
address
in
the
154l's
memory.
This
execution
continues
until
an
RTS
instruction
is
encountered.
It
is
important
to
understand
that
a
subroutine
executed
in
this
way
is
addressing
only
memory
in
the
1541;
it
is
independent
of
the
Plus/4.
The
syntax
is
PRINT#flieiiumber//M-E:'/CHR$(Jad)CHRl|(iiadd)
where
filenumber
is
the
logical
file
number
of
the
command
channel,
laddis
the
low
byte
of
the
address
to
begin
executing,
and
hadd
is
the
high
byte
of
the
address
to
begin
executing.
Example:
This
example
writes
a
short
machine-language
subroutine
into
a
buffer
in
the
1541.
This
subroutine
counts
the
number
of
active
buffers
and
stores
it
in
the
1541
's
RAM
for
retrieval.
The
number
of
active
buffers
found
can
be
changed
by
opening
some
direct-access
channels
just
before
running
the
program.
10
0PEN15,8,15
SO
IFDSO0THENPRINTDS$:G0T090
30
B$=////:F0RI=0T016:READIT:B$=B$+CHR$(]Sr):]SrEXT
40
PRI]SrT#15//M-W"CHR$(0)CHR$(5)CHR$(17)Bl|l;
50
PRINT#15//M-E//CHR$(0)CHR$(5)
60
PRINT#15//M-R//CHR$(S7)CHR$(0)
70
GET#15,A$
80
PRUTT^ITOMBER
OP
BUFFERS
=
*;ASC(A$)
90
CLOSE15
100
DATA
160,0,16S,6,181,167,S01,S55,S40,l,S00,g0S,16,S46,132,
27,96