This is the Commodore DOS reference I actually use. Not exhaustive — that’s what the official 1541 manuals are for — just the commands that come up over and over again when you’re working with a 1541 from a C64 BASIC prompt.
All the examples below assume the drive is device 8 on the IEC bus. If your drive is set to device 9, substitute 9 wherever you see 8.
Loading and saving
LOAD "TEST",8 : REM load the file TEST from disk
LOAD "$",8 : REM load the directory
SAVE "TEST",8 : REM save the current program as TEST
SAVE "@0:TEST",8 : REM save and overwrite an existing TEST
The @0: prefix on SAVE is the
overwrite-if-exists modifier. Without it, the
drive refuses to write over an existing file.
The 0 is the drive number — always 0 on a
1541, which is single-drive.
Gotcha: LOAD "$",8 reads the directory
into BASIC’s program memory, which means it
overwrites whatever program you have in there.
If you typed something you wanted to keep, save
it first. After the directory loads, LIST to
see it, then NEW (or just power-cycle) before
you keep coding — the directory listing isn’t a
runnable program and you don’t want it
underfoot.
The command channel
Anything that isn’t a load or save goes through the command channel, file 15. Open it once, send commands, close it when you’re done.
OPEN 15,8,15
PRINT#15, "command goes here"
CLOSE 15
The three arguments to OPEN are:
- 15 — the file number you’ll use locally (any number, but 15 is the convention)
- 8 — the device number on the IEC bus
- 15 — the secondary address, which is the drive’s command channel
You can also pass a one-shot command as an
optional fourth argument:
OPEN 15,8,15,"command".
Format a new disk
OPEN 15,8,15
PRINT#15, "NEW0:MYDISK,ID"
CLOSE 15
NEW— the format command0— the drive number (always 0 on a 1541)MYDISK— the disk name (16 characters max)ID— a two-character ID written to every sector
Delete a file
OPEN 15,8,15
PRINT#15, "SCRATCH0:FILENAME"
CLOSE 15
SCRATCH— the delete command0— the drive numberFILENAME— the file to delete
Reset the drive after a command failure
OPEN 15,8,15
PRINT#15, "INITIALIZE"
CLOSE 15
INITIALIZE resets the drive after a failed
command. If the drive is sitting on a flashing
red error LED, this is the first thing to try —
the drive holds the error state until you read
the error channel or initialize it.
Read the error channel
Same command-channel file (15), but read it instead of write to it. The drive replies with four fields: error code, error message, track, sector.
OPEN 15,8,15
INPUT#15, A, B$, C, D
PRINT A; B$; C; D
CLOSE 15
After a clean operation you’ll get
00 OK 00 00. After a failure you’ll get the
specific code and message, plus the track and
sector where it happened (zeros if not
applicable). Reading the error channel also
clears the error LED — same effect as
INITIALIZE for that purpose, so on a flashing
1541 you can either reset it or just read the
error and learn what went wrong at the same
time.
Common error codes
The handful you’ll actually see day-to-day on a 1541:
- 00 OK — no error.
- 21 READ ERROR — no sync mark on the track. Usually a bad disk, sometimes a head-alignment problem.
- 22 READ ERROR — data block not present where the directory says it should be.
- 23 READ ERROR — checksum error in a data block. The block is there but corrupted.
- 26 WRITE PROTECT ON — the write-protect notch is covered (or there’s no notch). Cover it with tape and try again.
- 29 DISK ID MISMATCH — you swapped disks
without an
INITIALIZE. SendINITIALIZEand it clears. - 62 FILE NOT FOUND — the filename you asked for isn’t on the disk.
- 63 FILE EXISTS — you tried to
SAVEwithout the@0:overwrite prefix and there’s already a file by that name. - 73 CBM DOS V2.6 1541 — the power-up banner, not an error. If you see this on any other operation, you’ve got a 1571 / 1581 / second drive answering with its own banner.
- 74 DRIVE NOT READY — no disk in the drive, or the disk isn’t seated.
A complete list lives in the 1541 User’s Guide appendix and in the service manuals.
Change the device number temporarily
The 1541’s device number is set in hardware by solder pads on the controller board, but you can override it in software. Send a memory-write to the drive’s zero page:
OPEN 15,8,15
PRINT#15, "M-W"+CHR$(119)+CHR$(0)+CHR$(2)+CHR$(N+32)+CHR$(N+64)
CLOSE 15
Where N is the desired device number (8, 9,
10, or 11). For example, N=9 sends bytes 41
and 73.
What this does: the two bytes at zero-page
addresses 119 ($77) and 120 ($78)
hold the LISTEN and TALK addresses the drive
responds to on the IEC bus, which default to
device+32 and device+64. Overwriting them
with N+32 and N+64 makes the drive answer
to a different IEC address, so to the rest of
the bus it looks like a different device number.
The change lives in the drive’s RAM only. Power the drive off and the hardware-set number takes over again — meaning you have to re-run the one-liner on every cold boot. That’s why nobody really used this as the actual answer for running two drives on the same chain; the trace-cut hardware mod was the practical standard.