User`s guide

Other
Resources:
More detailed information about Commodore disk drives can be found in these
books:
Inside Commodore
DOS, by lmmers & Neufeld (Datamost,
cl984)
The Anatomy
of
the 1541 Disk Drive, by Englisch & Szczepanowski
(Abacus, c1984)
Programming the PET/CBM, by West (Level Limited,
cl982)
The
PET Personal Computer Guide, by Osborne & Strasmas
(Osborne/McGraw-Hill, c 1982)
MEMORY -READ
The disk contains 16K
of
ROM (Read-Only Memory), as well as 2K
of
RAM (Rea
d-
Write Memory). You can get direct
acce~s
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
Memo
ry-
Read command
is
the equivalent
of
the Basic 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)Cj-IR$(>address)CHR$(#
of
bytes)
where
"<address"
is
the low order
par\
and "
">address"
is
the high order part
of
th
e
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#
15,
"M-R:
"CHR$(
<address)CHR$(>address)CHR$(#
of
bytes)
· The next byte read using the
Get#
statement through channel
#15
(the err
or
channel), will be from that address in the disk controller's memory, and successive byt
es
will be from successive memory locations.
Any
Input#
from the error channel will give peculiar results when you're Uiing
th
is
command. This can be cleared up by sending any other command to the disk, except
another memory command.
74
E)(
AMPLES:
To see how many tries the disk will make to read a particular sector, and whether
••seeks" one-half track to each side will be attempted if a read fails, and whether
"
bu
mps"
to track
one
and back will be attempted before declaring the sector unreadable,
we
can· use the following lines. They will read a special variable
in
the zero page
of
disk
mem
ory, called REYCNT. It
is
located
at
$6A hexadecimal ($6A hexadecimal = 6 x
16
+
10
= 106).
11
00
PEN 15,8,15
120
P
RINT#
15
, " M-R
"CHR$(
I06)CHR$(0)
130
GET#l5,G$:IF
G$=
' '
''THEN
G$
=CHR$(0)
J40
G = ASC(G$)
Open
command channel
Sarne as G =
PEEK(l06)
150
B
=G
AND
128
:
B$=
"ON"
:IF B THEN
8$=
"OFF"
Check bit 7
160
s = G AND 64:S$
=.'ON'.
:IF s
THEN
S$
=.'OFF'
. Check bit 6
170
T=G
AND
31
:PRINT
"#OF
TRIES
IS";T
Check bits 0-5
180
PRINT
"BUMPS
ARE";B$
and give results
190
PRINT
"SEEKS
ARE";S$
200
CLOSE
15
Tidy up after
210
END
Here
's
a more general purpose program that reads one
or
more locations anywhere in disk
mem
ory:
110O
PENl5,8,15
120
INPUT"#
OF
BYTES
TO
READ
(O=END)";NL
130
IF
NL<l
THEN
CLOSE
15:END
140
IF
NL>255
THEN
120
150
I
NPUT"STARTING
AT
ADDRESS";AD
160
AH = INT(AD/256):AL = AD-AH*256
170
PR
INT#l5,
"M-R"CHR$(AL)CHR$(AH)
CHR$(NL)
180
FOR
I=
I
TO
NL
190
: G
ET#l5,A$:IF
A$=""
THEN
A$=CHR$(0)
200
: PRINT ASC(A$);
2IO
NEXT I
220
PRINT
230GO
TO
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 write up to
34
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