<s>
Commodore	B-Device
DOS	I-Device
,	O
also	O
known	O
as	O
CBM	B-Device
DOS	I-Device
,	O
is	O
the	O
disk	B-Operating_System
operating	I-Operating_System
system	I-Operating_System
used	O
with	O
Commodore	O
's	O
8-bit	O
computers	O
.	O
</s>
<s>
Unlike	O
most	O
other	O
DOSes	O
,	O
which	O
are	O
loaded	O
from	O
disk	O
into	O
the	O
computer	O
's	O
own	O
RAM	B-Architecture
and	O
executed	O
there	O
,	O
CBM	B-Device
DOS	I-Device
is	O
executed	O
internally	O
in	O
the	O
drive	O
:	O
the	O
DOS	B-Operating_System
resides	O
in	O
ROM	B-Device
chips	I-Device
inside	O
the	O
drive	O
,	O
and	O
is	O
run	O
there	O
by	O
one	O
or	O
more	O
dedicated	O
MOS	B-General_Concept
6502	I-General_Concept
family	O
CPUs	B-General_Concept
.	O
</s>
<s>
Thus	O
,	O
data	O
transfer	O
between	O
Commodore	O
8-bit	O
computers	O
and	O
their	O
disk	O
drives	O
more	O
closely	O
resembles	O
a	O
local	B-General_Concept
area	I-General_Concept
network	I-General_Concept
connection	O
than	O
typical	O
disk/host	O
transfers	O
.	O
</s>
<s>
At	O
least	O
seven	O
distinctly	O
numbered	O
versions	O
of	O
Commodore	B-Device
DOS	I-Device
are	O
known	O
to	O
exist	O
;	O
the	O
following	O
list	O
gives	O
the	O
version	O
numbers	O
and	O
related	O
disk	O
drives	O
.	O
</s>
<s>
Drives	O
whose	O
model	O
number	O
starts	O
with	O
15	O
connect	O
via	O
Commodore	O
's	O
unique	O
serial	O
IEEE-488	O
bus	O
(	O
IEC	B-Protocol
Bus	I-Protocol
)	O
serial	O
(	O
TALK/LISTEN	O
)	O
protocols	O
;	O
all	O
others	O
use	O
the	O
parallel	O
IEEE-488	O
.	O
</s>
<s>
Version	O
2.6	O
was	O
by	O
far	O
the	O
most	O
commonly	O
used	O
and	O
widely	O
known	O
DOS	B-Operating_System
version	O
,	O
due	O
to	O
its	O
use	O
in	O
the	O
1541	B-Device
as	O
part	O
of	O
C64	O
systems	O
.	O
</s>
<s>
Note	O
:	O
The	O
revised	O
firmware	O
for	O
the	O
1571	B-Device
which	O
fixed	O
the	O
relative	O
file	O
bug	O
was	O
also	O
identified	O
as	O
V3.0	O
.	O
</s>
<s>
The	O
1541	B-Device
Commodore	O
floppy	O
disk	O
can	O
contain	O
up	O
to	O
144	O
files	O
in	O
a	O
flat	O
namespace	O
(	O
no	O
subdirectories	B-Application
)	O
;	O
the	O
directory	B-Application
is	O
stored	O
on	O
reserved	O
track	O
18	O
,	O
which	O
is	O
located	O
halfway	O
from	O
the	O
hub	O
to	O
the	O
edge	O
of	O
a	O
35-track	O
single-sided	O
disk	O
.	O
</s>
<s>
A	O
file	O
name	O
may	O
be	O
up	O
to	O
16	O
bytes	O
in	O
length	O
and	O
is	O
theoretically	O
unique	O
;	O
by	O
using	O
direct	O
access	O
methods	O
on	O
the	O
directory	B-Application
structure	O
,	O
it	O
is	O
possible	O
to	O
rename	O
a	O
file	O
to	O
that	O
of	O
anotheralthough	O
accessing	O
such	O
files	O
may	O
be	O
difficult	O
or	O
impossible	O
.	O
</s>
<s>
One	O
popular	O
trick	O
,	O
used	O
,	O
for	O
example	O
,	O
by	O
The	B-Device
Final	I-Device
Cartridge	I-Device
III	I-Device
,	O
was	O
to	O
add	O
files	O
named	O
"	O
----------------	O
"	O
of	O
type	O
DEL	O
<	O
to	O
the	O
directory	B-Application
,	O
and	O
files	O
could	O
then	O
be	O
rearranged	O
around	O
those	O
lines	O
to	O
form	O
groups	O
.	O
</s>
<s>
Many	O
game	O
developers	O
,	O
warez	B-Application
group	O
members	O
,	O
and	O
demoscene	O
hackers	O
used	O
some	O
more	O
clever	O
custom	O
directory	B-Application
entries	O
as	O
well	O
.	O
</s>
<s>
File	O
names	O
may	O
contain	O
a	O
shifted	O
space	O
character	O
( $A0	O
)	O
,	O
and	O
if	O
the	O
directory	B-Application
listing	O
is	O
being	O
viewed	O
from	O
BASIC	B-Language
,	O
the	O
portion	O
of	O
the	O
file	O
name	O
beyond	O
the	O
$A0	O
character	O
will	O
appear	O
to	O
have	O
been	O
separated	O
from	O
the	O
first	O
part	O
of	O
the	O
file	O
name	O
by	O
a	O
quotation	O
mark	O
,	O
causing	O
BASIC	B-Language
to	O
not	O
consider	O
it	O
to	O
be	O
part	O
of	O
the	O
full	O
file	O
name	O
.	O
</s>
<s>
This	O
feature	O
can	O
be	O
used	O
to	O
create	O
directory	B-Application
entries	O
such	O
as	O
,	O
which	O
will	O
then	O
appear	O
in	O
the	O
directory	B-Application
listing	O
as	O
,	O
for	O
example	O
,	O
.	O
</s>
<s>
When	O
the	O
user	O
moves	O
the	O
cursor	O
to	O
the	O
beginning	O
of	O
the	O
line	O
,	O
types	O
the	O
word	O
LOAD	O
over	O
the	O
file	O
size	O
,	O
and	O
presses	O
,	O
BASIC	B-Language
interprets	O
that	O
as	O
,	O
causing	O
the	O
program	O
to	O
be	O
loaded	O
into	O
memory	O
.	O
</s>
<s>
A	O
null	O
byte	O
embedded	O
in	O
a	O
file	O
name	O
will	O
interrupt	O
the	O
listing	O
after	O
loading	O
by	O
BASIC	B-Language
.	O
</s>
<s>
If	O
there	O
are	O
three	O
null	O
bytes	O
,	O
that	O
makes	O
it	O
difficult	O
to	O
list	O
through	O
BASIC	B-Language
.	O
</s>
<s>
Many	O
machine	O
language	O
programmers	O
would	O
experiment	O
with	O
null	O
bytes	O
in	O
an	O
attempt	O
to	O
make	O
it	O
harder	O
for	O
BASIC	B-Language
programmers	O
to	O
access	O
their	O
code	O
and	O
tamper	O
with	O
it	O
.	O
</s>
<s>
In	O
BASIC	B-Language
,	O
the	O
directory	B-Application
can	O
be	O
accessed	O
as	O
a	O
non-executable	O
pseudo-BASIC	O
program	O
with	O
(	O
or	O
in	O
the	O
case	O
of	O
a	O
dual	O
drive	O
)	O
followed	O
by	O
LIST	O
.	O
</s>
<s>
The	O
first	O
line	O
has	O
a	O
line	O
number	O
of	O
0	O
or	O
1	O
(	O
indicating	O
the	O
drive	O
number	O
)	O
,	O
showing	O
in	O
reverse	O
video	O
the	O
name	O
and	O
ID	O
of	O
the	O
disk	O
and	O
a	O
shorthand	O
code	O
for	O
the	O
DOS	B-Operating_System
version	O
with	O
which	O
it	O
was	O
created	O
(	O
codes	O
vary	O
only	O
as	O
far	O
as	O
the	O
DOS	B-Operating_System
versions	O
use	O
incompatible	O
disk	O
formats	O
:	O
"	O
2A	O
"	O
is	O
used	O
by	O
most	O
5.25-inch	O
DOS	B-Operating_System
versions	O
,	O
"	O
3D	O
"	O
by	O
the	O
3.5-inch	O
1581	O
)	O
.	O
</s>
<s>
On	O
the	O
Commodore	O
64	O
,	O
entering	O
will	O
flood	O
the	O
screen	O
with	O
garbage	O
instead	O
of	O
loading	O
the	O
directory	B-Application
into	O
BASIC	B-Language
RAM	B-Architecture
.	O
</s>
<s>
This	O
is	O
because	O
the	O
drive	O
assigns	O
the	O
directory	B-Application
a	O
load	O
address	O
of	O
$0401	O
(	O
1025	O
)	O
,	O
which	O
is	O
equivalent	O
to	O
the	O
start	O
of	O
BASIC	B-Language
for	O
the	O
Commodore	B-Device
PET	I-Device
,	O
but	O
corresponds	O
to	O
the	O
default	O
screen	O
memory	O
in	O
the	O
C64	O
(	O
starting	O
with	O
the	O
second	O
character	O
on	O
the	O
first	O
line	O
of	O
the	O
screen	O
)	O
.	O
</s>
<s>
Viewing	O
the	O
directory	B-Application
with	O
a	O
command	O
overwrites	O
the	O
BASIC	B-Language
program	O
in	O
memory	O
.	O
</s>
<s>
The	O
DOS	B-Operating_System
Wedge	I-Operating_System
and	O
various	O
third-party	O
cartridges	O
and	O
extenders	O
such	O
as	O
Epyx	B-Application
Fast	I-Application
Load	I-Application
,	O
Action	B-Device
Replay	I-Device
,	O
and	O
The	B-Device
Final	I-Device
Cartridge	I-Device
III	I-Device
allow	O
viewing	O
of	O
the	O
disk	O
directory	B-Application
using	O
special	O
commands	O
that	O
load	O
the	O
directory	B-Application
into	O
screen	O
memory	O
without	O
destroying	O
the	O
current	O
BASIC	B-Language
program	O
.	O
</s>
<s>
Some	O
versions	O
of	O
Commodore	B-Language
BASIC	I-Language
include	O
a	O
DIRECTORY	B-Application
or	O
CATALOG	O
command	O
that	O
performs	O
the	O
same	O
function	O
.	O
</s>
<s>
A	O
sequential	B-General_Concept
file	O
is	O
a	O
data	O
file	O
that	O
can	O
be	O
linearly	O
read	O
from	O
start	O
to	O
finish	O
.	O
</s>
<s>
A	O
sequential	B-General_Concept
file	O
is	O
analogous	O
to	O
a	O
flat	B-Application
file	I-Application
in	O
Linux	B-Application
or	O
UNIX	B-Application
,	O
in	O
that	O
it	O
has	O
no	O
specialized	O
internal	O
structure	O
.	O
</s>
<s>
It	O
is	O
not	O
possible	O
to	O
position	O
to	O
any	O
arbitrary	O
location	O
in	O
a	O
sequential	B-General_Concept
file	O
,	O
as	O
there	O
is	O
no	O
analog	O
of	O
the	O
lseek	B-Application
kernel	O
call	O
found	O
in	O
UNIX-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
.	O
</s>
<s>
The	O
first	O
two	O
bytes	O
of	O
the	O
PRG	O
are	O
read	O
by	O
the	O
kernal	B-Operating_System
"	O
load	O
file	O
"	O
routine	O
and	O
used	O
to	O
determine	O
the	O
load	O
address	O
(	O
they	O
are	O
stored	O
in	O
a	O
little	O
endian	O
format	O
)	O
.	O
</s>
<s>
A	O
relative	O
file	O
is	O
a	O
variation	O
of	O
the	O
sequential	B-General_Concept
file	O
type	O
,	O
in	O
which	O
an	O
indexing	O
mechanism	O
referred	O
to	O
as	O
side-sectors	O
is	O
present	O
to	O
permit	O
record-oriented	O
access	O
.	O
</s>
<s>
Records	O
may	O
be	O
a	O
maximum	O
of	O
254	O
bytes	O
in	O
size	O
and	O
are	O
addressed	O
by	O
a	O
one-based	O
cardinal	O
number	O
,	O
permitting	O
true	O
random	B-General_Concept
access	I-General_Concept
to	O
any	O
part	O
of	O
the	O
file	O
.	O
</s>
<s>
A	O
user-specified	O
file	O
has	O
an	O
internal	O
structure	O
that	O
is	O
identical	O
to	O
that	O
of	O
a	O
sequential	B-General_Concept
file	O
.	O
</s>
<s>
Commodore	O
's	O
original	O
purpose	O
for	O
this	O
file	O
type	O
was	O
the	O
facilitation	O
of	O
DOS	B-Operating_System
development	O
,	O
as	O
the	O
file	O
content	O
could	O
be	O
copied	O
into	O
a	O
drive	O
buffer	O
for	O
execution	O
by	O
the	O
drive	O
's	O
microprocessor	O
.	O
</s>
<s>
Some	O
applications	O
that	O
use	O
non-standard	O
low-level	O
disk	B-Device
structures	I-Device
save	O
data	O
in	O
USR	O
format	O
,	O
which	O
came	O
to	O
be	O
considered	O
a	O
sort	O
of	O
"	O
leave	O
me	O
alone	O
,	O
do	O
n't	O
try	O
to	O
copy	O
or	O
delete	O
"	O
indication	O
to	O
the	O
user	O
.	O
</s>
<s>
Most	O
notably	O
,	O
GEOS	B-Device
 '	O
"	O
VLIR	O
"	O
files	O
show	O
up	O
as	O
USR	O
files	O
.	O
</s>
<s>
An	O
undocumented	O
internally	O
used	O
file	O
type	O
similar	O
in	O
structure	O
to	O
a	O
sequential	B-General_Concept
file	O
.	O
</s>
<s>
Creation	O
of	O
this	O
file	O
type	O
must	O
be	O
accomplished	O
by	O
direct	O
manipulation	O
of	O
the	O
disk	O
directory	B-Application
.	O
</s>
<s>
The	O
presence	O
of	O
an	O
asterisk	O
( *	O
)	O
prepended	O
to	O
the	O
file	O
type	O
in	O
a	O
directory	B-Application
listing	O
(	O
for	O
example	O
,	O
*	O
SEQ	O
)	O
indicates	O
that	O
the	O
file	O
was	O
not	O
properly	O
closed	O
after	O
writing	O
.	O
</s>
<s>
When	O
the	O
drive	O
is	O
commanded	O
to	O
close	O
a	O
file	O
that	O
has	O
been	O
opened	O
for	O
writing	O
,	O
the	O
associated	O
buffer	O
is	O
flushed	O
to	O
the	O
disk	O
and	O
the	O
block	B-Application
availability	I-Application
map	I-Application
(	O
BAM	B-Application
)	O
is	O
updated	O
to	O
accurately	O
reflect	O
which	O
blocks	O
have	O
been	O
used	O
.	O
</s>
<s>
If	O
a	O
program	O
crash	O
or	O
other	O
problem	O
(	O
such	O
as	O
the	O
user	O
removing	O
the	O
disk	O
while	O
a	O
file	O
is	O
open	O
)	O
results	O
in	O
an	O
"	O
orphan	O
file	O
"	O
,	O
also	O
referred	O
to	O
as	O
a	O
"	O
poison	O
"	O
or	O
"	O
splat	O
"	O
file	O
,	O
buffers	O
are	O
not	O
flushed	O
and	O
the	O
BAM	B-Application
will	O
not	O
accurately	O
reflect	O
disk	O
usage	O
,	O
putting	O
the	O
disk	O
at	O
risk	O
of	O
corruption	O
.	O
</s>
<s>
A	O
poison	O
file	O
generally	O
cannot	O
be	O
accessed	O
(	O
but	O
can	O
be	O
opened	O
in	O
"	O
modify	O
"	O
mode	O
)	O
,	O
and	O
an	O
attempt	O
to	O
use	O
the	O
DOS	B-Operating_System
scratch	O
command	O
to	O
delete	O
the	O
file	O
may	O
cause	O
filesystem	O
corruption	O
,	O
such	O
as	O
crosslinking	O
.	O
</s>
<s>
The	O
only	O
practical	O
method	O
of	O
removing	O
one	O
of	O
these	O
files	O
is	O
by	O
opening	O
the	O
file	O
in	O
"	O
modify	O
"	O
mode	O
(	O
and	O
fixing	O
it	O
)	O
,	O
or	O
by	O
validating	O
the	O
disk	O
(	O
see	O
the	O
DOS	B-Operating_System
validate	O
command	O
below	O
)	O
,	O
the	O
latter	O
which	O
rebuilds	O
the	O
BAM	B-Application
and	O
removes	O
poison	O
file	O
references	O
from	O
the	O
directory	B-Application
.	O
</s>
<s>
*	O
DEL	O
is	O
a	O
special	O
type	O
written	O
into	O
the	O
on-disk	O
directory	B-Application
entry	O
of	O
files	O
that	O
have	O
been	O
deleted	O
.	O
</s>
<s>
Such	O
files	O
are	O
not	O
shown	O
in	O
a	O
normal	O
directory	B-Application
listing	O
,	O
and	O
their	O
data	O
blocks	O
and	O
directory	B-Application
entries	O
will	O
be	O
reused	O
by	O
files	O
that	O
are	O
subsequently	O
created	O
.	O
</s>
<s>
Some	O
utility	O
programs	O
allow	O
the	O
"	O
un-deletion	O
"	O
of	O
such	O
files	O
if	O
their	O
data	O
blocks	O
and	O
directory	B-Application
entries	O
haven	O
not	O
yet	O
been	O
overwritten	O
by	O
other	O
files	O
.	O
</s>
<s>
DEL	O
files	O
are	O
commonly	O
used	O
to	O
insert	O
banners	O
or	O
comment	O
sections	O
into	O
a	O
directory	B-Application
listing	O
.	O
</s>
<s>
There	O
is	O
no	O
Commodore	B-Device
DOS	I-Device
command	O
that	O
can	O
explicitly	O
set	O
or	O
clear	O
this	O
status	O
,	O
but	O
many	O
third-party	O
utilities	O
were	O
written	O
to	O
allow	O
this	O
to	O
be	O
done	O
.	O
</s>
<s>
These	O
utilities	O
generally	O
read	O
the	O
directory	B-Application
using	O
direct-access	O
commands	O
,	O
perform	O
the	O
necessary	O
modifications	O
to	O
the	O
raw	O
data	O
,	O
and	O
then	O
write	O
the	O
changes	O
back	O
to	O
the	O
disk	O
.	O
</s>
<s>
The	O
kernal	B-Operating_System
ROM	B-Device
in	O
the	O
computer	O
contains	O
the	O
necessary	O
primitive	O
routines	O
needed	O
to	O
access	O
files	O
,	O
and	O
the	O
BASIC	B-Language
ROM	I-Language
contains	O
a	O
higher	O
level	O
abstraction	O
for	O
file	O
access	O
using	O
BASIC	B-Language
syntax	O
.	O
</s>
<s>
The	O
components	O
that	O
concern	O
the	O
DOS	B-Operating_System
itself	O
are	O
file	O
name	O
parsing	O
and	O
the	O
secondary	O
address	O
.	O
</s>
<s>
This	O
section	O
will	O
give	O
an	O
overview	O
of	O
the	O
necessary	O
BASIC	B-Language
commands	O
for	O
the	O
sake	O
of	O
completeness	O
.	O
</s>
<s>
Since	O
the	O
DOS	B-Operating_System
is	O
actually	O
running	O
in	O
the	O
drive	O
's	O
controller	O
,	O
the	O
file	O
opening	O
sequence	O
must	O
pass	O
enough	O
information	O
to	O
the	O
drive	O
to	O
assure	O
unambiguous	O
interpretation	O
.	O
</s>
<s>
A	O
typical	O
statement	O
in	O
BASIC	B-Language
to	O
write	O
to	O
a	O
sequential	B-General_Concept
file	O
would	O
be	O
as	O
follows	O
:	O
</s>
<s>
This	O
parameter	O
,	O
the	O
file	O
number	O
,	O
logically	O
identifies	O
the	O
opened	O
file	O
within	O
the	O
computer	O
's	O
operating	O
system	O
and	O
is	O
analogous	O
to	O
a	O
file	B-Application
descriptor	I-Application
in	O
UNIX-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
.	O
</s>
<s>
In	O
assembly	B-Language
language	I-Language
programs	O
,	O
this	O
value	O
is	O
often	O
referred	O
to	O
as	O
LA	O
(	O
logical	O
address	O
)	O
,	O
the	O
abbreviation	O
coming	O
from	O
the	O
mnemonic	O
that	O
refers	O
to	O
the	O
memory	O
location	O
where	O
the	O
file	O
number	O
is	O
stored	O
.	O
</s>
<s>
Devices	O
0	O
through	O
3	O
address	O
the	O
keyboard	O
,	O
tape	O
cassette	O
,	O
RS-232	O
interface	O
,	O
and	O
video	O
display	O
,	O
respectively	O
,	O
all	O
of	O
which	O
are	O
directly	O
controlled	O
by	O
the	O
kernal	B-Operating_System
ROM	B-Device
.	O
</s>
<s>
In	O
assembly	B-Language
language	I-Language
programs	O
,	O
this	O
value	O
is	O
often	O
referred	O
to	O
as	O
FA	O
or	O
PA	O
(	O
physical	O
address	O
)	O
,	O
again	O
from	O
the	O
mnemonic	O
for	O
the	O
memory	O
location	O
where	O
the	O
device	O
number	O
is	O
stored	O
.	O
</s>
<s>
In	O
assembly	B-Language
language	I-Language
programs	O
,	O
this	O
value	O
is	O
often	O
referred	O
to	O
as	O
SA	O
(	O
secondary	O
address	O
)	O
.	O
</s>
<s>
In	O
the	O
case	O
of	O
a	O
disk	O
drive	O
unit	O
,	O
the	O
formal	O
command	O
string	O
structure	O
consists	O
of	O
the	O
drive	O
mechanism	O
number	O
(	O
0	O
:	O
,	O
not	O
to	O
be	O
confused	O
with	O
the	O
device	O
number	O
)	O
,	O
filename	O
(	O
ADDRESSBOOK	O
)	O
,	O
file	O
type	O
(	O
S	O
,	O
sequential	B-General_Concept
in	O
this	O
example	O
)	O
and	O
access	O
mode	O
(	O
W	O
,	O
opened	O
for	O
writing	O
in	O
this	O
example	O
)	O
.	O
</s>
<s>
The	O
drive	O
number	O
identifies	O
a	O
drive	O
mechanism	O
attached	O
to	O
a	O
disk	O
unit	O
's	O
controller	O
and	O
is	O
analogous	O
to	O
a	O
logical	O
unit	O
number	O
in	O
a	O
SCSI	B-Architecture
controller	O
that	O
is	O
capable	O
of	O
controlling	O
multiple	O
mechanisms	O
(	O
e.g.	O
,	O
the	O
OMTI	O
SASI	B-Architecture
controllers	O
that	O
were	O
developed	O
to	O
work	O
with	O
ST-412/ST	O
-506	O
hard	B-Device
drives	I-Device
in	O
the	O
1980s	O
)	O
.	O
</s>
<s>
It	O
is	O
fairly	O
common	O
practice	O
to	O
omit	O
the	O
drive	O
number	O
when	O
communicating	O
with	O
a	O
single	O
drive	O
floppy	O
unit	O
,	O
as	O
0	O
:	O
is	O
the	O
default	O
in	O
such	O
units	O
,	O
but	O
since	O
omitting	O
the	O
number	O
can	O
trigger	O
a	O
few	O
obscure	O
bugs	O
in	O
the	O
DOS	B-Operating_System
it	O
is	O
not	O
a	O
recommended	O
practice	O
(	O
a	O
colon	O
alone	O
is	O
equivalent	O
to	O
0	O
:	O
and	O
is	O
enough	O
to	O
avoid	O
those	O
bugs	O
)	O
.	O
</s>
<s>
An	O
exception	O
to	O
this	O
convention	O
is	O
with	O
the	O
Lt	B-Device
.	I-Device
Kernal	I-Device
hard	B-Device
disk	I-Device
subsystem	O
,	O
in	O
which	O
the	O
drive	O
number	O
refers	O
to	O
"	O
logical	O
units	O
"	O
(	O
virtual	B-Application
drives	I-Application
created	O
on	O
a	O
single	O
physical	O
drive	O
)	O
,	O
which	O
made	O
syntax	O
such	O
as	O
4	O
:	O
or	O
10	O
:	O
necessary	O
if	O
a	O
file	O
to	O
be	O
opened	O
was	O
not	O
on	O
logical	O
unit	O
zero	O
(	O
equivalent	O
to	O
drive	O
mechanism	O
zero	O
in	O
a	O
dual	O
floppy	O
unit	O
)	O
.	O
</s>
<s>
File	O
name	O
specifiers	O
can	O
also	O
be	O
used	O
here	O
,	O
for	O
example	O
,	O
saves	O
the	O
BASIC	B-Language
program	O
to	O
a	O
PRG	O
(	O
program	O
)	O
file	O
and	O
saves	O
the	O
BASIC	B-Language
program	O
to	O
a	O
sequential	B-General_Concept
file	O
.	O
</s>
<s>
)	O
,	O
the	O
file	O
is	O
saved/loaded	O
from	O
the	O
BASIC	B-Language
memory	O
area	O
(	O
which	O
,	O
on	O
the	O
C64	O
,	O
starts	O
by	O
default	O
at	O
$0801	O
)	O
.	O
</s>
<s>
Load	O
relocation	O
was	O
first	O
introduced	O
on	O
the	O
VIC-20	B-Device
because	O
this	O
machine	O
could	O
start	O
BASIC	B-Language
RAM	B-Architecture
in	O
several	O
different	O
locations	O
,	O
depending	O
on	O
the	O
memory	O
expansion	O
that	O
was	O
installed	O
.	O
</s>
<s>
The	O
older	O
Commodore	B-Device
PET	I-Device
series	O
did	O
not	O
support	O
relocation	O
,	O
so	O
and	O
would	O
have	O
the	O
same	O
effect	O
:	O
the	O
file	O
would	O
be	O
loaded	O
into	O
the	O
same	O
memory	O
region	O
from	O
which	O
it	O
was	O
saved	O
.	O
</s>
<s>
Since	O
the	O
PET	O
cannot	O
relocate	O
files	O
,	O
BASIC	B-Language
programs	O
written	O
on	O
later	O
Commodore	O
machines	O
must	O
be	O
modified	O
by	O
using	O
a	O
sector	O
editor	O
to	O
change	O
the	O
header	O
bytes	O
.	O
</s>
<s>
It	O
is	O
also	O
possible	O
to	O
use	O
the	O
PET	O
's	O
built-in	O
machine	O
language	O
monitor	O
to	O
change	O
the	O
link	O
address	O
for	O
the	O
BASIC	B-Language
program	O
after	O
loading	O
it	O
.	O
</s>
<s>
The	O
directories	B-Application
of	O
disks	O
in	O
two-drive	O
units	O
are	O
accessed	O
as	O
and	O
.	O
</s>
<s>
"	O
0	O
:	O
$	O
"	O
and	O
"	O
1	O
:	O
$	O
"	O
do	O
not	O
access	O
the	O
directory	B-Application
but	O
actual	O
files	O
on	O
one	O
drive	O
or	O
the	O
other	O
that	O
just	O
happen	O
to	O
be	O
named	O
"	O
$	O
"	O
.	O
</s>
<s>
Partial	O
directories	B-Application
can	O
be	O
loaded	O
by	O
adding	O
a	O
colon	O
and	O
a	O
template	O
:	O
for	O
example	O
,	O
would	O
load	O
a	O
partial	O
directory	B-Application
that	O
shows	O
only	O
the	O
files	O
whose	O
name	O
starts	O
with	O
the	O
letter	O
K	O
and	O
which	O
are	O
of	O
type	O
PRG	O
;	O
all	O
such	O
partial	O
directories	B-Application
still	O
contain	O
the	O
initial	O
disk	O
name	O
line	O
and	O
the	O
final	O
"	O
BLOCKS	O
FREE	O
"	O
line	O
.	O
</s>
<s>
Commodore	B-Device
DOS	I-Device
also	O
offers	O
a	O
"	O
Save-with-Replace	O
"	O
command	O
,	O
which	O
allows	O
a	O
file	O
to	O
be	O
saved	O
over	O
an	O
existing	O
file	O
without	O
the	O
need	O
to	O
first	O
SCRATCH	O
the	O
existing	O
file	O
.	O
</s>
<s>
For	O
years	O
rumors	O
spread	O
,	O
beginning	O
with	O
the	O
4040	B-Device
drive	O
,	O
of	O
a	O
bug	O
in	O
the	O
command	O
's	O
implementation	O
.	O
</s>
<s>
Affected	O
devices	O
included	O
the	O
single-drive	O
1541	B-Device
and	O
dual-drive	O
4040	B-Device
;	O
the	O
8050	B-Device
and	O
8250	B-Device
did	O
not	O
exhibit	O
the	O
issue	O
.	O
</s>
<s>
The	O
bug	O
stemmed	O
from	O
the	O
fact	O
that	O
the	O
affected	O
DOS	B-Operating_System
implementations	O
were	O
modified	O
versions	O
of	O
the	O
DOS	B-Operating_System
contained	O
in	O
earlier	O
Commodore	B-Device
PET	I-Device
dual	O
drives	O
such	O
as	O
the	O
8050	B-Device
.	O
</s>
<s>
In	O
September	O
1986	O
,	O
Philip	O
A	O
.	O
Slaymaker	O
published	O
an	O
article	O
describing	O
in	O
great	O
detail	O
the	O
cause	O
of	O
the	O
bug	O
and	O
providing	O
patches	O
to	O
the	O
1541	B-Device
drive	O
ROMs	O
;	O
readers	O
with	O
an	O
EPROM	B-General_Concept
burner	O
could	O
produce	O
their	O
own	O
patched	O
ROMs	O
which	O
could	O
be	O
swapped	O
into	O
the	O
drive	O
.	O
</s>
<s>
Commodore	O
was	O
made	O
aware	O
of	O
Slaymaker	O
's	O
findings	O
,	O
and	O
while	O
they	O
never	O
issued	O
an	O
official	O
update	O
for	O
the	O
original	O
1541	B-Device
's	O
ROMs	O
,	O
they	O
did	O
fix	O
the	O
bug	O
in	O
Revision	O
5	O
of	O
the	O
1571	B-Device
ROMs	O
,	O
and	O
also	O
in	O
the	O
ROMs	O
for	O
the	O
1541-c	O
and	O
1541-II	O
drives	O
.	O
</s>
<s>
Although	O
not	O
supported	O
by	O
Commodore	O
,	O
it	O
is	O
known	O
that	O
the	O
1541-II	O
firmware	O
(	O
but	O
not	O
that	O
of	O
the	O
1541-c	O
)	O
can	O
also	O
be	O
used	O
in	O
an	O
original	O
1541	B-Device
drive	O
by	O
using	O
EPROMs	B-General_Concept
,	O
which	O
will	O
fix	O
the	O
bug	O
for	O
that	O
drive	O
as	O
well	O
.	O
</s>
<s>
As	O
previously	O
noted	O
,	O
the	O
Commodore	B-Device
DOS	I-Device
itself	O
is	O
accessed	O
via	O
the	O
"	O
command	O
channel	O
"	O
,	O
using	O
syntax	O
like	O
that	O
used	O
to	O
access	O
files	O
.	O
</s>
<s>
Issuing	O
commands	O
to	O
the	O
DOS	B-Operating_System
and	O
retrieving	O
status	O
and	O
error	O
messages	O
generated	O
in	O
response	O
to	O
commands	O
is	O
accomplished	O
by	O
opening	O
a	O
file	O
to	O
the	O
device	O
using	O
15	O
as	O
the	O
secondary	O
address	O
,	O
for	O
example	O
:	O
</s>
<s>
Commodore	B-Language
BASIC	I-Language
versions	O
4.0	O
and	O
later	O
provide	O
a	O
pseudo-variable	O
referred	O
to	O
as	O
DS$	O
that	O
may	O
be	O
used	O
to	O
retrieve	O
drive	O
status	O
in	O
lieu	O
of	O
the	O
above	O
code	O
.	O
</s>
<s>
This	O
reserved	O
variable	O
is	O
not	O
available	O
on	O
earlier	O
versions	O
of	O
BASIC	B-Language
,	O
so	O
the	O
command	O
channel	O
must	O
be	O
manually	O
read	O
as	O
demonstrated	O
above	O
.	O
</s>
<s>
Note	O
that	O
immediately	O
after	O
power-on	O
or	O
reset	O
,	O
the	O
DOS	B-Operating_System
revision	O
will	O
be	O
returned	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
1541	B-Device
will	O
return	O
.	O
</s>
<s>
Command	O
Description	O
BASIC	B-Language
1.x	O
and	O
2.x	O
Implementation	O
DOS	B-Operating_System
Wedge	I-Operating_System
Implementation	O
BASIC	B-Language
3.0	O
+	O
Implementation	O
New	O
Format	O
a	O
disk	O
,	O
preparing	O
it	O
for	O
use	O
and	O
deleting	O
any	O
data	O
contained	O
on	O
it	O
.	O
</s>
<s>
Note	O
that	O
the	O
new	O
name	O
comes	O
first	O
(	O
except	O
in	O
the	O
BASIC	B-Language
3.0	O
+	O
code	O
)	O
!	O
</s>
<s>
OPEN	O
15	O
,	O
8	O
,	O
15	O
,	O
"	O
R0:new	O
name	O
=	O
old	O
name	O
"	O
:CLOSE	O
15	O
@R0	O
:new	O
name	O
=	O
old	O
name	O
RENAME	O
"	O
old	O
name	O
"	O
TO	O
"	O
new	O
name	O
"	O
Initialize	O
Reset	O
the	O
drive	O
and	O
read	O
the	O
disk	O
BAM	B-Application
into	O
its	O
internal	O
memory	O
.	O
</s>
<s>
@I0	O
:	O
DCLEAR	O
(	O
BASIC	B-Language
7.0	I-Language
+	O
only	O
)	O
Validate	O
Reconcile	O
the	O
BAM	B-Application
with	O
the	O
disk	O
directory	B-Application
,	O
allocate	O
all	O
used	O
blocks	O
and	O
free	O
all	O
blocks	O
not	O
being	O
used	O
by	O
files	O
,	O
and	O
delete	O
all	O
unclosed	O
files	O
from	O
the	O
directory	B-Application
.	O
</s>
<s>
Comparable	O
to	O
CHKDSK/ScanDisk	O
tools	O
of	O
Microsoft	O
operating	O
systems	O
.	O
</s>
<s>
Note	O
that	O
the	O
new	O
name	O
comes	O
first	O
(	O
except	O
in	O
the	O
BASIC	B-Language
3.0	O
+	O
code	O
)	O
!	O
</s>
<s>
drive	O
number	O
comes	O
first	O
,	O
then	O
the	O
source	O
drive	O
number	O
(	O
except	O
in	O
the	O
BASIC	B-Language
3.0	O
+	O
code	O
)	O
.	O
</s>
<s>
Some	O
of	O
the	O
theoretically	O
user-definable	O
functions	O
were	O
rededicated	O
for	O
accessing	O
new	O
functionality	O
in	O
DOS	B-Operating_System
versions	O
after	O
1.0	O
.	O
</s>
