Memory Read; Memory Write - Commodore 1541 User Manual

Hide thumbs Also See for 1541:
Table of Contents

Advertisement

Other Resources:
More detailed
information
about Commodore disk drives
can
be
found
in
these
books:
Inside Commodore DOS, by Imrners & Neufeld
(Datamost, cl984)
The Anatomy of the 1541 Disk Drive, by Englisch & Szczepanowski
(Abacus, cl984)
Programming the PET/CBM, by West
(Level
Limited,
c
1982)
The PET Personal Computer Guide, by Osborne & Strasmas
(Osborne/McGraw-Hill, c
1982)
MEMORY-READ
The disk contains l 6K of ROM
(Read-Only
Memory), as well as 2K of RAM
(Read-
Write Memory)
.
You
can get
direct
access
to
any
location within these, or to the
buffers
that the DOS has
set
up in RAM, by using memory
commands.
Memory-Read
allows
you
to
select
which byte or bytes to read from disk memory into the
computer.
The
Memory-
Read
command is
the
equivalent of
the Ba
ic
Peek() function, but reads the
disk's
memory instead of the
computer's
memory.
Note:
Unlike
other
disk
commands
,
those in this chapter
cannot
be
spelled out in
full.
Thus, M-R is
correct,
but MEMORY-READ is not
a
permitted
alternate
wording
.
FORMAT FOR THE MEMORY-READ COMMAND:
PRINT# 15,
"M-R
"CHR$(
<address)CHR$(>address)CHR$(
#
of
bytes)
where
"<address" is
the low
order
par\,
and ">address"
is the high
order
part
of the
address in disk memory to be read
.
If the
optional "#of
bytes"
is specified, it
selects
'how many memory locations will be read in, from 1-255
.
Otherwise, I character
will be
read
.
If desired,
a colon (:)
may follow M-R inside the quotation marks
.
ALTERNATE FORMAT:
PRINT# I 5,
"M-R: "CHR$( <address)CHR$(>address)CHR$(
#
of bytes)
'The
next byte read using the Get#
statement
through channel #15
(the error
channel), will be from that address in the disk controller's memory, and
success~ve
bytes
will be from successive memory locatjons
.
Any
lnput#
from the error channel will give peculiar results when you're uiing
this
command.
This can be cleared up by sending any other command to the disk,
except
another memory command.
74
AMPLES
:
To
see
how many tries the disk
will
make to
read a particular sector, and whether
k
" one-half
track
to each side will be attempted if a read fails
,
and whether
..
see
s
.
s"
to track
one and
back
will be attempted before declanng
the
sector unreadable
,
"bUmP
.
·
·
·
f
d'
k
can-use the
following
lines. They
will
read
a
special.
variable
m
the
zer? page o
is
:mory,
called
REYCNT
.
It
is
located
at $6A
hexadecimal
($6A
hexadecimal
= 6 x 16
+JO=
106)
.
110
OPEN
15,8, 15
ilO
PRINT#l5
, "M-R"CHR$(106)CHR$(0)
Open
command channel
Same as G =
PEEK(
I 06)
130
GET#l5
,G$:LF G$=
''''THEN G$=CHR$(0)
140
G
=
ASC(G$)
!So
B
=G
AND 128:B$=
"ON"
:IF B THEN B$=
"OFF" Check
bit
7
!60
S
=
G AND 64:S$
= "ON":IF
S
THEN
S$
=
"OFF" Check bit 6
t70 T
=
G AND
31
:PRINT
"#OF
TRIES IS";T
Check bits 0-5
!80
PRINT
"BUMPS
ARE"
;B$
and give results
t90
PRINT
"SEEKS
ARE" ;S$
ZQOCLOSE 15
Tidy up
after
210END
Here's a more
general
purpose program that reads
one or
more locations
anywhere in disk
memory:
110OPENI5
,8,15
120
INPUT"#
OF BYTES TO READ
(O= END)";NL
130
IF
NL<I THEN CLOSE 15:END
140
IF
NL>255 THEN 120
150
INPUT"STARTING
AT ADDRESS";AD
160
AH
=
INT(AD/256) :AL
=
AD-AH*256
170 PRINT#15
,"M-R"CHR$(AL)CHR$(AH)
CHR$(NL)
180
FOR I= I TO NL
190: GET#
15,A$:1F A$="" THEN A$= CHR$(0)
200 :
PRINT
ASC(A$);
210
NEXT
I
220 PRINT
230GOTO 120
MEMORY-WRITE
Open
command channel
Enter number
of
bytes
wanted
unless done
or way
out of
line
Enter
starting address
Convert
it into
disk
form
Actual Memory-Read
Loop til have
all
the data
printing it
as
we
go
Forever
The
Memory-Write command is the equivalent of the Basic Poke
command'.
but has
its
effect
in
disk memory instead of within the computer. M-W allows you to wnte up
to
l4
bytes
at a time into disk memory. The Memory-Execute and
some
User commands
can
be
Used
to
run any programs written this way.
75

Advertisement

Table of Contents
loading

Table of Contents