Commodore 1541 User Manual
Annonce
Annonce
A Friendly Introduction to Your 1541 Disk Drive
t commodore
COMPUTER
USER'S GUIDE STATEMENT
"This equipment generates and uses radio frequency energy. If it is
not properly installed and used in strict accordance with the manufac
turer's instructions, this equipment may interfere with radio and tele vision reception. This machine has been tested and found to comply with the limits for a Class B computing device peripheral in accord ance with the specifications in Subpart J of Part 15 of FCC Rules, which are designed to provide reasonable protection against such interference in a residential installation. If you suspect interference,
you can test this equipment by turning it off and on. If you determine
that there is interference with radio or television reception, try one
or more of the following measures to correct it:
• reorient the receiving antenna
• move the equipment away from the receiver
• change the relative positions of the equipment and the receiver
• plug the equipment into a different outlet so that the equipment
and the receiver are on different branch circuits.
If necessary, consult your Commodore dealer or an experienced radio/ television technician for additional suggestions. You may also wish to
consult the following booklet, which was prepared by the Federal
Communications Commission:
"How to Identify and Resolve Radio-TV Interference Problems".
This booklet is available from the U.S. Government Printing Office,
Washington, D.C. 20402, Stock No. 004000-00345-4.
COMMQDORI
1541
DISK DRIVE
A Friendly Introduction to Your 1541 Disk Drive
f:commodare v COMPUTER
The information in ihis manual has been reviewed and is believed to be entirely reliable. No responsibility, however, is assumed for inaccuracies. The material in (his manual is for information purposes only, and is subject to change without notice.
tjyCommodore Business Machines Electronics Ltd., September 1982
"All rights reserved."
Table of Contents
1.
GENERAL DESCRIPTION
2.
UNPACKING AND CONNECTING
Contents of Box
Connection of Cables
Powering On
*'
Insertion of Diskette
■ Using with VIC 20 or Commodore 64
3.
©SING PROGRAMS
Loading Pre-packaged Software
LOAD
Directory of Disk
Pattern Matching & Wild Cards
SAVE
SAVE and replace
VERIFY
DOS Support Program
4.
DISK COMMANDS
OPEN AND PRINT #
NEW
COPY
RENAME
SCRATCH
INITIALIZE
VALIDATE
DUPLICATE
Reading the Error Channel
CLOSE
5.
SEQUENTIAL FILES
OPEN
PRINT # and INPUT #
GET #
Reading Ihe Directory
6.
RANDOM FILES
Opening a channel for random access dala
BLOCK-READ
BLOCK-WRITE
BLOCK-ALLOCATE
BLOCK-FREE
BUFFtlR-POINTER
USER1 and USER2
•
20
20
21
U
M
16
17
n
!7
18
18
19
14
«
I5
16
M
2'
29
3°
30
31
33
3*
Pa8«
•
*
4
'
"
7
7
11
"
IZ
I2
n
13
8
8
8
7.
RELATIVE FILES
Creating a relative file.
Using relative files
Create a relative tile
,
Sum man -
Modifying the program.......
,
,
,
8.
PROGRAMMING THE DISK CONTROLLER
BLOCK-EXECUTE
MEMORY-REAP
MEMORY-WRITE
MEMORY-EXECUTE
USER Commands
,
<
,
„..„
,
^
.....«^!
'
45
\[ 4S
45
46
."!!!,"!!!!.'."!"! 46
ti 47
36
35
_ -jg
43
43
... 44
9.
CHANGING THE DISK DEVICE NUMBER
Software Method ,
Hardware Method ,
10.
ASSEMBLY LANGUAGE AND THE 1541
Appendices
A. Disk Command Siunmun
B. Error Messages , ,
C. Demonstration Disk Programs
D.
Disk Formate Tables
,
,
,
,„
,
, t nmt
48
,.48
4«;
50
51
52
57
64
1.
GENERAL DESCRIPTION
INTRODUCTION
Welcome to the fastest, easiest, and most efficient filing system available for your
Commodore 64 or VIC 20 computer, your 154] DISK DRIVE. This manual has been designed io show you how to get the most from your drive, whether you're a beginner or an advanced professional.
If you are a beginner, the first few chapters will help you through the basics of disk drive installation and operation. As your skill and programming knowledge im proves, you will find more uses for your disk drive and the more advanced chapters of this manual will become much more valuable.
If you're a professional, this reference guide wiil show you how to put the 1541 through its paces Id perform just about all the disk drive jobs you can think of.
No matter what level of expertise you haveh your 1541 disk drive will dramatically improve the overall capabilities of your computer system.
Before you get to the details of 1541 operation, you should be aware of a few im portant points. This manual is a REFERENCE GUIDE, which means that unless the information you seek directly pertains lo the disk or disk drive you will have to use your Commodore 64 or VIC 20 User's Guides and Programmer's Reference Guides to find programming information. In addition, even though we give you step-by-step in structions for each operation, you should become familiar with BASIC and the in structions (called commands) that help you operate your disks and drives. However, if you just want to use your disk drive unit lo load and save prepackaged software, we've included an easy and brief section on doing just that.
Now , . , let's get on with the general information.
The commands for the disk drive come in several levels of sophistication. Starting in chapter three, you can learn how the command that allow you to SAVE and LOAD programs with (he disk work. Chapter four teaches you how commands are sent to the disk, and introduces the disk maintenance commands.
Chapter five tells you how to work with SEQuential data flies. These are very similar to their counterparts on tape (but much faster). Chapter six introduces the com mands that allow you to work with random filcsj lo access any piece of data on the disk, and how you organize the diskette into tracks and blocks. Chapter seven describes The special relative files. RELaiive Files are the best method of storing data bases, especially when they are used along with sequential files.
Chapter eight describes methods for programming the disk controller circuits at the machine language level. And the final chapter shows you how to change the disk device number, by cutting a line inside the drive unit or through software.
Remember, you don't really need to learn everything in this book all at once. The first four chapters are enough to get you going, and tne next couple are enough for most operations. Getting ta know your disk drive will reward you in many ways — speed of operation, reliability, and much more flexibility in your data processing capabilities.
SPECIFICATIONS
This disk drive allows you to store up to 144 different programs and/or data files on a single mini-floppy diskette, for a maximum of over 174,000 byics worth of infor mation storage.
Included in the drive is circuitry for both the disk controller and a complete disk operating system, a total of 16K of ROM and 2K of RAM memory. This circuitry makes your Commodore 1541 disk drive an "intelligent" device. This means it does its own processing without talcing any memory away from your Commodore 54 or VIC 20 computer. The disk uses a "pipeline" software system. The "pipeline" makes the disk able to process commands while the computer is performing other jobs. This dramatically improves the overall throughput (input and outpu*) of the system.
Diskettes that you create in this disk drive arc read and write compatible with
Commodore 4040 and 2031 disk drives, Therefore, diskettes can be used inter changeably on any of these systems. In addition, this drive can read programs created on the older Commodore 2040 drives.
The 1541 disk drive contains a dual "serial bus" interface. This bus was specially created by Commodore. The signals of this bus resemble the parallel IEEE-488 inter face used on Commodore PET computers, except that only one wire is used to com municate data instead of eight. The two ports at the rear of the drive allows more than one device to share the serial bus at the same time. This is accomplished by "daisychaining" the devices together, each plugged into the next. Up to five disk drives and one printer can share the bus simultaneously.
Figure 1.1 Specifications VIC 1540/1541 Single Drive Floppy Disk
STORAGE
Total capacity
Sequential
Relative
Directory entries
Sectors per track
Bytes per sector
Tracks
Blocks
IC\:
6502
6522 (2)
Buffer
2114(4)
PHYSICAL;
Dimensions
Height
Width
Depth
Electrical:
Power Requirements
Voltage
Frequency
Power
MEDIA:
Diskettes
174848 bytes per diskette
168656 bytes per diskette
167132 bytes per diskette
65535 records per file
144 per diskette
17(0 21
256
35
683 (664 blocks free) microprocessor
I/O, internal timers
2K RAM
97 mm
200 mm
374 mm
100, 120, 220, or 240 VAC
50 or 60 Hertz
25 Watts
Standard mini 5V4", single sided, single density
2.
UNPACKING AND CONNECTING
CONTENTS OF BOX
Included with the 154] disk drive unii, you should find a gray power cable, black serial bus cable, this manual, and a demonstration diskette. The power cable has a con nection for the back of ihc disk drive on one end, and for a grounded (three-prong) electrical outlet on the other. The serial bus cable is exactly the same on both ends. H has a 6-pin DIN plug which attaches to the VIC 20, Commodore 64 or another disk drive.
Please, don't hook up anything until you've completed the following section!
iFigl.A
£i commodore 1541
1
DRIVE JNDICATER (RED LED)
LIGHT: ACTIVE
FLASH: ERROR
POWER INDICATER
Fig !. Front Panel ]green LED) LIGHT: POWERQN
} Fig 13
DRIVE INDICATOR (RED LED) LIGHT: ACTIVE
FLASH ERROR
POWER JNDICATEP
(GREEN LED) LIGHT: POWER ON
Fig 2. Back Panel
POWER SWITCH SERIAL BUS
FUSE/HOLDER
CONNECTION OF CABLES
Your first step is to take the power cable and insert it into the back of the disk drive (see figure 2). It won't go in if you try to put it in upside down. Once it's in the drive, plug the other end into the electrical outlet. IF the disk drive makes any sound at this time, please turn il off using the switch on (he back! Don't plug any other cables into Ihe disk drive if Ihe power is on.
Next, take the serial bus cable and attach il to either one of the serial bus sockets in Ihe rear of the drive. Turn off ihe computer, and plug the other end of the cable into the back of the computer. That's all there is to it!
If you have a printer, or any additional disk drives, attach the cables into the se cond serial bus port (see figure 3). For directions on using multiple drives at one time, read chapter 9. If you are a first-time user with more than one drive, start working with only one drive until you're comfortable with the unit.
Fig 3. Floppy Disk Hookup
POWERING ON
When you have all the devices hooked together, it's time to start turning on the power. II Is important Ihnl you turn on the devices in the correct order. The computer should always be turned on last. As long as the computer is the last one to be turned on, everything will be OK.
First, make sure that you've removed all diskettes from the disk drives before powering on.
After all the other devices have been turned on, only then is it safe to turn on the computer. All the other devices will go through their starting sequences. The printer's motor goes on, with the print head moving halfway across the line and back again. The
1541 disk drive will have its green light on, and then the red drive/error light will blink, while your TV screen forms the starting picture.
Once the red drive/error light has stopped flashing on the drive, it is safe to begin working with it.
WRITE
PROTECT
NOTCH
WHEN COVERED, DISKETTE
CONTENTS CANNOT BE
ALTERED
Fig.4. Position for Diskette Insertion
INSERTION OF DISKETTE
There is different way to open and close the drive door, and insertion/
removal the diskette.
TYPE1: figure l.A
,.._,.•
To open the door on the drive, simply press the door catch lightly, anil LSie
door will pop open. If there is a diskette in ihc drive, it is ejected by a small
spring. Take the diskette to be inserted, and place it in the drive face-up with the large opening going in first and write-protect notch to the left (covered with tape in the demonstration disk) (sec figure 4).
Press it in gently, and when the diskette is in all the way, you will feel a click and the diskette will not spring out. Close the drive door by pulling downward until the latch clicks into place. Now you are ready to begin working with the diskette.
TYPE2: figure 1,B
To open the door on the drive, simply turn the door Sever counter-clockwise.
Take the diskette to be inserted, and place it in the drive face-up with the large opening going in first and write-protect notch to the Seft (covered with tape in the demonstration disk) {see figure 4).
Close the drive door by turning clockwise direction unti! the latch clicks into place. Now you are ready to begin working with the disk.
Remember to always remove the diskette before the drive is turned off or on.
Never remove the diskette when the red drive light in on! Data can be destroyed by the
drive at this time!
USING WITH A VIC 20 OR COMMODORE 64
The 1541 Disk Drive can work with either the VIC 20 or Commodore 64 com
puters. However, each computer has different requirements for speed of incoming
data. Therefore, there is a software switch for selecting which computer's speed to use.
The drive starts out ready for a Commodore 64. To switch to VIC 20 speed, the follow ing comand must be sent after the drive is started (power-on or through software):
OPEN 15, 8. 15, -UI-": CLOSE 15
To return the disk drive to Commodore 64 speed, use this command:
OPEN 15, 8, 15, "U1+": CLOSE 15
More about using this type of command is in chapter 4, wiih a detailed explana tion of the U (user) commands in chapter 8.
3.
USING PROGRAMS
LOADING PREPACKAGED PROGRAMS
For those of you interested in using only prepackaged programs available on car tridges, cassette, or disk, here's all you have lo do:
Using your disk drive, carefully insert the preprogrammed disk so that the label on the disk is facing up and is closest to you. Look for a little nolch on the disk (it might be covered with a little piece of tape). If you're inserting the disk properly, the notch will be on the left side. Once the disk is inside, close [he protective gate by pushing in on the level. Now type LOAD'TROGRAM NAME", 8 and hit the
The disk will make noise and your screen will say:
SEARCHING FOR PROGRAM NAME
LOADING
READY
When the word READY appears, just type RUN, and your prepaekaged software is ready to use.
LOAD
The BASIC commands used with programs on the disk drive are the same as the commands used on the Commodore DATASSETTE™ recorder. There are a few extra commands available for use with disks, however.
First of all, the program name must be given with each command. On a
DATASSETTE™, you could omit the program name in order to just LOAD the first program there. On disk, since there are many different programs thai are equally ac cessible, the program name must be used to tell the disk drive what to do. In addition, the disk drive's device number must be specified. If no device number is listed, the computer assumes the program is on tape.
FORMAT FOR THE LOAD COMMAND:
LOAD nameS,device#, commands
The program name is a string, that is, either a name in quotes or the contents of a given string variable. Some valid names are: "HELLO", "PROGRAM ffl", AS,
NAMES.
The device*/ is preset on the circuit board to be #8. If you have more than one drive, sec chapter 9 on how to change the device number. This book assumes that you're using device number 8 for the disk drive.
The commands is optional. If not given, or zero, the program is LOADed nor mally, that is, beginning at the start of your available memory for BASIC programs. If the number is 1, the program will be LOADed at exactly the same memory locations from which it came. In the case of computers with different memory configurations, like VICs with 5K, 8K, or more memory, the start of BASIC memory is in different places. The command/* 0 permits BASIC programs to LOAD normally. CommandW 1 is used mainly for machine language, character sets, and other memory dependent functions.
EXAMPLES
LOAD "TEST", 8
LOAD "Program # 1", 8
LOAD AS. J , K
LOAD "Mach Lang", 8. 1
NOTE: You can use variables to represent device numbers, commands, and strings, as long as you've previously defined them in your program.
DIRECTORY OF DISKETTE
The DATASSETTE™ tape deck is a sequential device. It can only read from the ■ beginning of the tape to the end, without skipping around the tape and without the capability of going backward or recording over old data.
Your disk drive is a random access device. The read/write head of the disk can go to any spot on the disk and access a single block of data which holds up to 256 bytes of information. There are a total of 683 blocks on a single diskette.
Fortunately, you don't really have to worry about individual blocks of data.
There is a program in the disk drive called the Disk Operating System, or the DOS.
This program keeps track of the blocks for you. It organizes them into a Block
Availability Map. or BAM, and a directory.
The Block Availability Map is simply a checklist of all 683 blocks on the disk. It is stored in the middle of the diskette, halfway between the center hub and the outer rim.
Every time a program is SAVEd or a data Tile is CLOSEd, the BAM is updated with the list of blocks used up.
The directory is a list of all programs and other files stored on the disk. It is physically located right next to the BAM. There are 144 entries available in the direc tory, consisting of information like file name and type, a list of blocks used, and the starting block. The directory is automatically updated every time a program is SAVEd
or a file is OPENed for writing. BEWARE; the BAM isn't updated until the file is
CLOSEd, even though the directory changes right away. If a file isn't CLOSEd pro perly, all data in thai file will probably be lost.
The directory can be LOADed into your memory just like a BASIC program.
Place the diskette in the drive, and type the following command:
LOAD "$", 8
The computer responds with:
SEARCHING FQRS
FOUND S
LOADING
READY.
Now the directory is in your computer's memory. Type LIST, and you'll see die directory displayed on the screen. To print the directory on your printer, type the following command line (in this example your printer is plugged in as device? 4):
OPEN 4, 4: CMD 4: LIST
NOTE: When using CMD, the Tile must be closed using the command PRINTS
4: CLOSE 4. See the VIC 1525/1515 printer manual for detailed explanation.
To read the directory without LOADing it into your memory, see the section later in this chapter on the DOS Support Program. In addition, to examine the directory from inside a BASIC program t see the section in chapter 5 that deals with the GET# statement.
10
PATTERN MATCHING AND WILD CARDS
When using the tape deck, you can LOAD any program starting with certain let ters just by leaving off any following letters. Thus, the command LOAD "T" will find the first program on the tape beginning with the letter T. And LOAD "HELLO" will find the first program beginning with the letters HELLO, like "HELLO THERE.1'
When using the disk, this option is called pattern matching, and there is a special character in the file name used to designate this. The asterisk {*) character following any program name tells the drive you want to find any program start ing with that name.
FORMAT FOR PATTERN MATCHING:
LOAD nameS +
Can Be A String
Variable Or The
Name Inside Quotes
In other words, if you want to LOAD the first program on Che disk starting with the letter T, use the command LOAD "t*", 8,
If only the "• is used for the name, the lasl program accessed on the disk is the one LOADed. If no program has yet been LOADed, the first one listed in the directory is the one used.
You are probably familiar with the concept of wild cards in poker where one card can replace any other card needed. On your 1541, the question mark (?) can be used as a wild card on the disk. The program name on the disk is compared la the name in the
LOAD command, but any characters where there is a question mark in the name aren't checked.
For instance, when the command LOAD "TINT", 8 is given, programs that match include TINT, TENT, etc.
When LOADing the directory of the disk, pattern matching and wild cards can be used GO check for a list of specific programs. If you gave the command LOAD
"SO:TEST", only the program TEST would appear in the directory {if present on the disk). The command LOAD "S0:T*" would give you a directory- of all programs beginning with the letter T. And LOAD "SOiTIST" would give you all the programs with 4-letter names having the first letter of T and the third and fourth letters ST.
LOAD "$0:T?ST*" would give names of any length with the correct first, third, and fourth letters.
II
SAVE
To SAVE a program to the diskette, all that is needed is to add the device number after the program name. Just like the SAVE command for the tape deck, the device number can be followed by a command number, to prevent the automatic re-location on LOADing (sec the section on the LOAD command, above).
FORMAT FOR THE SAVE COMMAND:
SAVE namel, device*, command//
See the LOAD command (page 10) for an explanation of the parameters device^ and command^.
When you tell the disk drive 10 SAVE a program, the DOS must take several steps. First, it looks at the directory to see if a program with thai name already exists.
Next it checks to see that there is a directory entry available for the name. Then it checks [he BAM to see if there are enough blocks in which to store the program. If everything is OK up to this point, the program is stored. If not, the error light wilJ flash.
SAVE AND REPLACE
If a program already exists on the disk, it is often necessary to make a change and re-SAVE it onto the disk. In this case, it would be inconvenient to have 10 erase the old version of the program and then SAVE it.
If the first characters of the program name are the M@" sign followed by a 0 and a colon (:), the DOS knows to replace any old program that has thai name with the program that is now in the computer's memory, The drive checks the directory to find the old program, then it marks thai entry as deleted, and it next creates a new entry with the same name. Finally, the program is stored normally.
FORMAT FOR SAVE WITH REPLACE:
SAVE "@0:" + nameS, device*, command*
For example, if a file was called TEST, the SAVE and replace command would be
SAVE "@0: TEST'\8. If the name is in AS, the command is SAVE AS + "@0:
TEST", 8.
The reason for the 0: is to keep compatibility with other Commodore disk drive units which have more than one drive built in. In that case, the number 0 or 1 is used to specify which drive is being used.
VERIFY
The VERIFY command works to check the program currently in memory against the program on disk. You must include a device# with the VERIFY command. The computer does a byte-by-byte comparison of the program, including line links — which may be different for different memory configurations. For instance, if a pro gram was SAVEd to disk from a 5K VIC 20, and re-LOADed on an 8K machine, it wouldn't VERIFY properly because the links point to different memory locations.
FORMAT FOR VERIFY COMMAND:
VERIFY namcS, device*
DOS SUPPORT PROGRAM
On your demonstration disk, there may be a program called DOS SUPPORT.
This program, also called a wedge, allows you to use many disk commands more easily
(different wedges are used for the VIC 20 and the Commodore 64). Just LOAD the program and RUN it. It automatically sets itseif up and erases itself when it's finished.
You'll have a few hundred less bytes to work with when this program is running, but you'll also have a handy way to send the disk commands.
As a result of the DOS Support, the "/" key now takes the place of the LOAD command. Just hit the slash followed by the program name, and the program is
LOADed. When you use this method, you don't need to use the LOAD command or the comma 8.
The "@" and " > " keys are used to send commands to the disk drive. If you type @$ (or > $), the directory- of the disk is displayed on the screen, without
LOADing into your memory! These keys also take the place of the PRINTS (see chapter 4) to send commands listed in the next chapter.
To read the error channel of the disk (when the red error light is blinking), just hit either the <£ or the > and hit RETURN Key. Trie complete error message is dis played to you: message number, text, and track and block numbers.
13
4* DISK COMMANDS
OPEtV AND PRINT #
Up 'til now, you have explored the simple ways of dealing with the disk drive. In order to communicate with the disk drive more fully, you have to touch on the OPEN and PRINTS statements in BASIC (more details of these commands arc available in yaur VIC 20 or Commodore 64 User's Guide or Programmer's Reference Guide). You may be familiar with their use with data files on cassette tape, where the OPEN statement creates the file and the PRINTS* statement Fills the file with data. They can be used the same way with the disk, as you will see in the next chapter. But ihey can also be used to set up a command channel. The command channel lets you exchange infor mation between the computer and the disk drive.
FORMAT FOR THE OPEN STATEMENT:
OPEN filc#r device*, channel*, (cxtS
The filetf can be any number from 1 to 255. This numbe: is used throughout the program to identify which Tile is being accessed. Bui numbers greater than 127 should be avoided, because they cause the PRINT# statement to generaie a linefeed after the return character. These numbers are rcaJiy meant to be used with non-standard printers.
The device*/ of the disk is usually 8.
The channel* can be any number from 2 to 15. These refer to a channel used to communicate with the disk, and channels numbered 0 and 1 are reserved for the operating system to use for LOADing and SAVEing. Channels 2 through 14 can be used for data to files, and 15 is the command channel.
The textS is a string that is PRINTed to the file, as if with a PRINTS statement.
This is handy for sending a single command to the channel,
EXAMPLES OF OPEN STATEMENTS:
OPEN 15, 8, 15
OPEN 2, 8.2
OPEN A, B, C, Z$
COMMAND CHANNEI
^ --_-^ ^—^—^s
COMMANDJ(texlS)
The PRINTS command works exactly like a PRINT statement, except that the data goes to a device other than the screen, in this case to the disk drive. When used with a data channel, the PRINT# sends information into a buffer in the disk drive, which LOADS it onto the diskette. When PRJNT# is used with the command channel, it sends commands to the disk drive.
FORMAT FOR SENDING DISK COMMANDS;
OPEN 15, 8, 15, commands or
PRINTS 15, commands
NEW
This command is necessary when using a diskette for the first time. The NEW command erases the entire diskette, it puts timing and block markers on die diskette and creates the directory and BAM. The NEW command can also be used to dear out the directory of an already-formatted diskette. This is faster than re-formatting the whole disk.
FORMAT FOR THE NEW COMMAND TO FORMAT DISK:
PRINT#15> "NEWinamcid" or abbreviated as
PRINT#15, "N:namcjd"
FORMAT FOR THE NEW COMMAND TO CLEAR DIRECTORY:
PR1NT#I5, llN:name"
The name goes in the directory as the name of the entire disk. This only appears when the directory is listed, The ID code is any 2 characters, and they are placed nol only on the directory but on every block throughout the diskette. That way, if you carelessly replace diskettes while writing data, the drive will know by checking the ID thai something is wrong.
J5
COPY
This command allows you to make a copy of any program or file on the disk drive. It won't copy from one drive 10 a different one {except in the case of dual drives like the 4040), but it can duplicate a program under another name on [he drive.
FORMAT FOR THE COPY COMMAND:
PRINTS 15. ■'COPY:newfile= oldfile" or abbreviated as
PRINTS 15, "C:newfile = oldfile" disk.
The COPY command can also be used lo combine two through four files on the
FORMAT FOR COPY TO COMBINE FILES:
PRINTS 15, "C:newfile = oldfilel, oldfile2, oldfi!e3, oldfile4"
EXAMPLES OF COPY COMMAND:
PRINTS 15. ■■OBACKUP^ ORIGINAL"
PRINTS 15. "C:MASTERFILE= NAME, ADDRESS, PHONES"
RENAME
This command allows you to change the name of a file once it is in ihe disk direc tory. This is a fast operation, since only the name in the directory must be changed.
FORMAT FOR RENAME COMMAND:
PRINTS 15, ■■RENAME:newname= jldnamc" or abbreviated as
PRINTS 15, "R:newname = o!dname"
EXAMPLE OF RENAME COMMAND:
PRINTS15, ■■R:MYRA = MYRON"
The RENAME command will not work on any files that are currently OPEN.
.(■
SCRATCH
This command allows you to erase unwanted Tiles and programs from the disk, which then makes the blocks available for new information. You can erase programs one at a time or in groups by using pattern matching and or wild cards.
FORMAT FOR SCRATCH COMMAND
PRINTS 15, "SCRATCH:name" or abbreviated as
PRINTS 15, "Siname"
If you check the error channel after a scratch operation (see below), the number usually reserved for the track number now tells you how many files were scratched. For example, if your directory contains the programs KNOW and GNAW, and you use the command PRINTS 15, "S:?N?W". you will scratch both programs. If the directory contains TEST, TRAIN. TRUCK, and TAIL, and you command the disk to PRINTS
15, "S:"!"•", you will erase all four of these programs.
INITIALIZE
At times, an error condition on the disk will prevent you from performing some operation you want to do. The INITIALIZE command returns the disk drive to the same state as when powered up. You must be careful to re-match the drive to the com puter (see chapter 2).
FORMAT FOR INITIALIZE COMMAND:
PRINTS 15, "INITIALIZE" or abbreviated as
PRINT*/ 15, "I"
VALIDATE
After a diskette has been in use for some time, the directory can become disorganized. When programs have been repeatedly SAVEd and SCRATCHed, they may leave numerous small gaps on the disk, a block here and a few blocks there. These blocks never gel used because they are too small to be useful. The VALIDATE com mand will go in and re-organize your diskette so that you can get the most from the available space.
Also, there may be data files that were OPENed but never properly CLOSEd.
This command will collect all blocks taken by such Tiles and make them available to the drive, since the files are unusable at that point.
r
There is a danger in using this command. When using random files (see chapter 6), blocks allocated will be de-allocated by this command. Therefore, this command should never be used with a diskette that uses random files,
FORMAT FOR VALIDATE COMMAND:
PRINTJU5, "VALIDATE" or abbreviated as
PRINT# 15. "V"
DUPLICATE
This command is a hangover from the operating systems that were contained on the dual drives like the 4040. Jt was used 10 copy entire diskettes from Dne drive to another, but has no function on a single disk drive.
READING THE ERROR CHANNEL
Without Ihe DOS Support Program, there is no way 10 read 1 he disk error channel without a program, since you need to use the INPUTS command which won*t work outside a program. Here is a simple BASIC routine to read the error channel:
10 OPEN 15,8, 15
20 INPUTS 15. AS, BS, CS> DS
30 PRINT AS. BS, C$, DS
Whenever you perform an INPUTS operation from the command channel, you read up to 4 variables that describe the error condition. The first, third, and fourlh variables come in as numbers, and cart be INPUT into numeric variables if you like.
The first variable describes the error#S. where 0 is no error. The second variable is the error description. The third variable is ihe track number on which the error occurred, and the fourth and final is the block number inside that track. (A block is also known as a sector)
Errors on track 18 have to do with the BAM and directory. Tor example, a READ
ERROR on track 18 block 0 may indicate that the disk was never formatted.
CLOSE it is extremely important that you properly CLOSE files once you are finished using them. Closing the file causes the DOS to properly allocate blocks in the BAM and to finish the entry in the directory. If you don't CLOSE ihe file, all your data will be lost!
FORMAT FOR CLOSE STATEMENT:
CLOSE file*
You should also be careful not to CLOSE ihe error channel (channel* 15) before
CLOSEing your data channels. The error channel should be OPENed first and
CLOSEd last of all your files! That will keep your programs out of trouble.
If you close the error channel while other files are OPEN, the disk drive will
CLOSE them for you, but BASIC will still think they are open (unless you CLOSE them properly), and let you to try to write to them.
NOTE: If your BASIC program leads you into an error condition, all Tiles are
CLOSEd in BASIC, without CLOSEing them on your disk drive! This is a very dangerous condition. You should immediately type the statement OPEN 15, 8, 15,
"I". This will re-initialize your drive and make all your files safe,
19
5.
OPEN
SEQUENTIAL FILES
SEQuential files are limited by their sequential nature, which means they must be read from beginning to end. Data is transferred byte by byte, through a buffer, onto the magnetic media. To the disk drive all files are created equal. That is, SEQuential files, program files, and user files aJl work (he same on the disk. Only program Tiles can be LOADed, but that's really the only difference. Even the directory works like this, except that It is read-only. The onJy difference is with relative files.
FORMAT FOR OPENING A SEQUENTIAL FILE:
OPEN fileff, device*, channel, "0:name,type,directionIN
The file number is the same as in all your other applications of the OPEN state ment, and it is used throughout the program to refer to this particular file. The devicetf is usually 8. The channel^ is a data channel, number 2 through 14. It is convenient to use the same number for both the channel and filetf, to keep th.m straight. The name is the file name (no wild cards or pattern matching if you're creating a write file). The type can be any of the ones from the chart below, at least the first letter of each lypc.
The direction must be READ or WRITE, or at least the first letter of each.
FILE TYPE
PRG
SEQ
USR
REL
MEANING
Program
Sequential
User
Relative
EXAMPLES OF OPENING SEQUENTIAL FILES:
OPEN 2t 8, 2. "0:DATA. S, W"
OPEN 8, 8. 8. "0:Program, PN R"
OPEN A, B, C, "0;" + AS + "Ut W" tf the file already exists, you can use the replace option in the OPEN statement, similar to the SAVE-and-replace described in chapter 3, Simply add the @0: before the file's name in the OPEN statement.
EXAMPLE OF SEQUENTIAL FILE WITH REPLACE OPTION:
OPEN 2, 8, 2, "@0:DATA,S,W"
The 0: should always precede the name of the file or the drive will only allow you to use 2 of the available buffers.
20
PRINT#and INPUT*
The PRINT# command works exactly like the PRINT statement, except that out put is re-directed to the disk drive. The reason for the special emphasis on the word ex actly is thai all the formatting capabilities of the PRINT statement, as applies to punc tuation and data types, applies here too. It just means that you have to be careful when putting data into your files.
FORMAT FOR WRITING TO FILE WITH PRINTS:
PRINTS file*, data list
The filefl is the one from the OPEN statement when the file was created.
The data list is the same as the regular PRINT statement — a list of variables and/or text inside quote marks. However, you must be especially careful when writing data so that it is as easy as possible to read the data back again.
When using the PRINTS statement, if you use commas (,) to separate items on the line, the items will be separated by some blank spaces, as if it were being formatted for the screen. Semicolons (;) don't result in any extra spaces.
In order to more fully understand what's happening, here is a diagram of a se quential file created by the statement OPEN 5, 8, 5, "O:TEST,S,W": char tor
1
7 8 10 It 12 13 !4
15 ...
The eof stands for the end-of-file marker. String data entering the file goes in byte by byte, including spaces.
For instance, let's set up some variables with the statement AS= "HELLO";
BS= "ALL":C$= "BYE". Here isapicture of a file after the statement PRINTS 5,
A$; B$; CS: diar
H
1
El
2
L
3
L
4
0 i
A B
'I
Y
10
H CR
12 eof
13
CR stands for the CHRS code of 13, the carriage return, which is PRINTed at the end of every PRINT or PRINTS statement unless there is a comma or semicolon at the end of the line.
NOTE: Do not leave a space between PRINT and S, and do not try to abbreviate the command as ?#. See the appendixes in the user manual for the correct abbreviation.
FORMAT FOR INPUTS STATEMENT:
INPUTS file*, variable list
2:
When using the INPUT*/ to read in data, the disk drive can't tell that it's not supposed 10 be one long string. You need something in the file 10 act as a separator.
Characters to use as separators include the CR, a comma or a semicolon. The CR can be added easily by just using one variable per line on the PRINT/* statement, and the system puls one there automatically. The statement PRINTS 5, AS: PRINTS 5, BS:
PRINT# 5, CS puts a CR after every variable being written, providing the proper separation for a statement like INPUT05, AS, B$, CS. Or else a line like
Z$= ",":PRINTS 5, AS Z$ BS Z$ CS will do ihe job as well, and in less space. The file after that line looks like this: char 1
M E
2
L
3
L
A
0
S 6 ;
\ L
H
L
1 ID
B
11
V
12
E
1)
TR
14 r.ll
15
Putting commas between variables resulls in lots of extra space on the disk being used. A statement like PRINTS 5, AS, BS makes a file that looks like: char 1
II fc L j
L
4
0 s 6 7 8 ') 10 11
A
12
1
13
1
14 rp
:j
You can see that much of the space in the file is wasted.
The moral of all this is: take care when using PRINTS so your data will be in order for reading back in.
Numeric data written in the file takes the form of a string, as if the STRS function had been performed on it before writing it out. The first character will be a blank space if the number is positive, and a minus sign (-) if the number is negative. Then comes ihe number, and the last character is the cursor right character. This format provides enough information for the INPUTS statement lo read them in as separate numbers if several are written with no other special separators. It is somewhat wasteful of space, since there can be two unused characters if the numbers arc positive.
Here is a picture of the file after the statement PRINT** 5, 1; 3; 5; 7 is performed:
10 M
CK
I 1 of
Appendix B contains a program demonstrating the use of a sequential disk file.
22
GET*
The GET# retrieves data from the disk, one character at a time.
FORMAT FOR THE GET* STATEMENT:
GETS fileS, variable list
Data comes in byte by byte, including the CR, comma, and other separating characters. It is much safer to use string variables when using the GET* statement. You will get a BASIC error message if string data is received where a number was requested,
but not vice-versa.
EXAMPLES OF GETS STATEMENT:
GETS 5, AS
GETS A, BS, C$, D$
^
GET#5, A
—-^-^^--^-^-^-^-^-^-^
_( You can get more than 1 character at a time )
The GET# statement is extremely useful when examining files with unknown con tents like a file that may have been damaged by an experimental program. It is safer than'lNPUTS because there is a limit to the number of characters allowed between separators of INPUT variables." With GET#, you receive every character, and you can
examine separators as well as other data.
Here is a sample program that will allow you to examine any file on the disk;
10 INPUT "FILE NAME";FS
20 INPUT "FILE TYPE";TS
30 TS = LEFTS {T$,l> _ ,„
40 IFTS<>"S" THEN IFTS<>"P" THEN IF TS<>"U"THEN20
45 OPEN15,8,i5
50 OPENS^,'^:11
60 GOSUB200
70 GETS5.AS
80 IFST = 0THEN90
85 IF ST = 64 THEN CLOSE5,15:END_
87 PRINT ST:STOP
90 PRINT ASC(AS + CHR$(0)
IN CASE A
NULL CHARACTER
IS RtAD
100 GOTO70
200 INPUTS15,A$,BS,C$,DS
210 IFVAL(A$)>OTHEN PRINTA$,B$,C$,D$:STOP
220 RETURN
23
READING THE DIRECTORY
The directory of the diskette may be read just like a sequential file. Just use S for the file name, and OPEN 5, 8, 5, "S". Now the GETS statement works to examine the directory- The format here is identical to the format of a program file: the file sizes are the line numbers, and names are stored as characters within quote marks.
Here's a program thai lets you read the directory of the diskette:
10
20
30
OPEN1,8,2,"S"
FORX=]TOI41:GET#1.AS:NEXT<
TS(O)="DEL":T$(l)="SEQ11:TS(2) = "PRG":TJ(3) = "l
T$(4)="REL"
J= 17:GOSUB500*
N$ = BS
( DISK NAME'
SET LENGTH OF ID STKINd
SET LENGTH OF OPERATING SYSTEM STRING
130 GET#1,AS
140 NEXT
160 PRINT CHRS (147) "DISK NAME:"N$,"ID:"I$."OS:"O$
161 PRINT "LENGTH","TYPE","NAME"
165 FOR P=1TO8
170
180
190
IF TS - ■'" THEN TS = CHRS(128)
J=15«
SLT LENGTH OF FILE NAMfc
200 GOSUB500
210 N$ = BS
220 GET#1,AS,AS,AS,A$,A$,A$,AS,A$,AS,C$,H$"
225 L = ASC(LS + CHR$(O)) + 256'ASC(H$ + CHR$(O)):IF L = (
LOW & HIGH BYTES
OF FILE LENGTH
227 IFSTTHENCLOSEhEND
230 PRINT L,TS(ASC(T$)-128),NS
250 IFP<8THEN GET#1,A$,AS
260 NEXT P:GOTOI65
500 B$=""
510 FOR L = 0TOJ
520 GET#1,AS
530 IF AS<>CHRS(96)THENIFAS<>CHRS(160)THENBS=B$ + AS
540 NEXT
STRING
BUILDING
ROUTINE
550 RETURN
24
Table
5.J: 1540/1541 BAM FORMAT
0,1
Track 18, Sector 0.
BYTE CONTENTS
18,01
2 65
3 0
4—143
DEFINITION
Track and sector of first directory block.
ASCII character A indicating 4040 format.
Null flag for future DOS use.
Bit map of available blocks for tracks 1-35.
•1 = available block
0 = block not available
{each bit represents one block)
Table 5.2:
1540/1541 DIRECTORY HEADER
Track 18, Sector 0.
BYTE CONTENTS
144—161
162—163
164
165,166
160
50,65
166—167
171—255
160
0
DEFINITION
Disk name padded with shifted spaces.
Disk ID.
Shifted space.
ASCII representation for 2A which is DOS version and formal type-
Shifted spaces.
Nulls, not used.
Note: ASCII characters may appear in locations 180 thru 191 on some diskettes.
Table 5 J: DIRECTORY FORMAT
Track 18, Sector 1 for 1540/154 J
BYTE
0,1
2—31
34—63
66—95
98—127
130—159
162—191
194—223
226—255
DEFINITION
Track and sector af next directory block.
•File entry 1
•File cnlry 2
•File entry 3
•File entry 4
*File entry 5
•File entry 6
•File entry 7
•File entry 8
0
BYTE
1,2
3—IS
19,20
21
22—25
26h27
28,29
■STRUCTURE OF SINGLE DIRECTORY ENTRY
CONTENTS
128+type
DEFINITION
File type OR'ed with 580 (hexadecimal) io indicate properly closed file.
TYPES: 0 - DELeied
1 = SEQential
2 = PROGram
3 - USER
4 = RELative
Track and sector of 1st data block.
File name padded with shifted spaces.
Relative file only; track and sector for first side sector block.
Relative Hie only: Record size.
Unused.
Track and sector of replacement flic when OPEN® is in effect.
Number of blocks in file: low byte, high byte.
BYTE
0,1
2—256
Table 5.4: SEQUENTIAL FORMAT
DEFINITION
Track and sector of next sequential data block.
254 bytes of data with carriage returns as record terminators.
BYTE
0,1
2—256
Table 5.5: PROGRAM FILE FORMAT
DEFINITION
Track and sector of next block in program file.
254 bytes of program info stored in CBM memory format (with key words tokenized). End of Tile is marked by three zero bytes.
27
6.
RANDOM FILES
Sequential files are Tine when you're just working with a continuous stream of data, but some jobs require more ihan that. For example, with a large mailing list, you would not want to have to scan through the entire list to Find a person's record. For this you need some kind of random access method, some way to get to any record in side a Tile without having to read through the entire file first.
There arc actually two different types of random access files an the Commodore disk drive. The relative files discussed in the next chapter are more convenient for data handling operations, although the random files in this chapter have uses of their own, especially when working with machine language.
Random files on the Commodore disk drive reach the individual 256-byic blocks of data stored on the disk. As was mentioned in the first chapter, there are a total of
6S3 blocks on the diskette, of which 664 are free on a blank diskette.
The diskette is divided into tracks, which are laid out as concentric circles on the surface of the diskette. There are 35 different tracks, starting with track 1 at the outside, of the diskette to track 3 5 at the center, Track 18 is used for the directory, and ihe DOS fills up the diskette from the center outward.
Each track is subdivided into blocks. Because there is more room on the outer tracks, theie are more blocks there. The outer tracks contain 21 blocks each, white the inner ones only have 17 blocks each. The table below shows the number of blocks per track.
TRACK NUMBER
1 SO 17
18 to 24
25 to 30
31 to 35
Table 6.1: Track and Block Format
BLOCK RANGE
0to20
Ota 18
Oto 17
Oto 16
TOTAL BLOCK
2]
19
IS
17
The DOS contains commands for reading and writing directly lo any track and block on the diskette. There are also commands for checking to see which blocks are available, and for marking off used blocks.
These commands arc transmitted through the command channel (channel^ ]5), and tell the disk what to do with the data. The data must be read later through one of the open data channels.
OPENING A DATA CHANNEL FOR RANDOM ACCESS
When working with random access files, you need to have 2 channels open to the disk: one for the commands, and the other for the data. The command channel is
OPENed to channel 15, just Uke other disk commands you've encountered so far. The data channel for random access files is OPENed by selecting the pound sign (#) as the
file name.
FORMAT FOR OPEN STATEMENT FOR RANDOM ACCESS DATA:
OPEN fileS, device*, channel*. "#" or optionally
OPEN file#, devke#, channel*, "#buffer#"
EXAMPLES OF OPENING RANDOM ACCESS DATA CHANNEL:
OPEN 5, 8, 5, "#"
OPEN A, B, C, "#2"
^(dON'T CARE WHICH BUFFER
_^/F
BLOCK-READ
FORMAT FOR BLOCK-READ COMMAND:
PRINTSfiktf, "BLOCK-READ:" channel; drive; track; block or abbreviated as
PRINT#file#, "B-R:" channel; drive; track; block
This command will move one block of data from the diskette into the selected channel. Once this operation has been performed, the INPUTS and GET# statements can read the information.
SAMPLE PROGRAM TO READ BLOCK 2 FROM TRACK 18: (stores contents in
BS)
DRIVE
10 OPEN15.8.15
\
20 OPEN5,8,5,"r \b/jS^
30 PRINT#15."B-R:"5;O;18;2
>—ZLs-S /~^~^ f BLOCK J
V^v_—-
40 BS-""
50 FOR L = 0TO255
60 GET«,AS
70 IF ST = 0 THENBS - BS + AS:NEXTL
SO PRINT "FINISHED"
90 CLOSES:CLOSE 15 \COLLECT ENTIRE
BLOCK:BYTE
BY BYTE
BLOCK-WRITE
The BLOCK-WRITE command is the exact opposite of the BLOCK-READ com mand. First you must fill up a data buffer with your information, then you write that buffer to the correct location on the disk.
FORMAT FOR BLOCK-WRITE COMMAND:
PRlNTfffUe*. "BLOCK-WRITE:" channel; drive; track; block or abbreviated as
PRINTtffile, "B-W:*r channel; drive; track; block
When the data is being put into the buffer, 0 pointer in the DOS keeps track of how many characters there are. When you perform the BLOCK-WRITE operation, that pointer is recorded on the disk. That is the reason for the ST check in line 70 of the program above: the ST will become non-zero when you try to read past the end-of-file marker within the record,
SAMPLE PROGRAM TO WRITE DATA ON TRACK 1. SECTOR 1:
10
20
30
40
50
60
70
OPEN15,
OPEN5.8
8.15
FORL1TO50
PRINTS ."TEST"
NEXT
PRINTtfl5,"B-W;"5;O;l;l
CLOSES; CLOSE15
[ OPEN A
> ACCESS
V^A A.
RANDOM
CHANNEL
BLOCK ALLOCATE
In order to safely use random files along with regular files, your programs must check the BAM to find available blocks, and change the BAM to reflect that you've used them. Once you update the BAM, your random files will be safe — at least unless you perform the VALIDATE command (see chapter 3).
FORMAT FOR THE BLOCK-ALLOCATE COMMAND:
PRINTtffileS, "BLOCK-ALLOCATE:" drive; track; block
How do you know which blocks are available to use? If you try a block that isn't available, the DOS will set the error message to number 65, NO BLOCK, and set the track and block numbers to the next available track and block number. Therefore, any time you atlempl to write a block to the disk, you must first try to allocate that block.
If that block isn't available, read the next block available from the error channel and
[hen allocate that block.
EXAMPLE OF PROCEDURE TO ALLOCATE BLOCK:
10 OPEN15TS.15
30 PRINTS,"DATA"
40 T=1:B=1
SO PRINTtfl5P"B-A:"(fcT:B
60 INPUTtflS.A.BS^.D
70 IF A-65 THEN T= C:B = D:GOTO50
80 PRINT tfl5,"B-W:"5;QJ;l
90 CLOSE5:CLOSEI5
BLOCK-FREE
The BLOCK-FREE command is the opposite of BLOCK-ALLOCATE, in that it frees a block that you don't want to use anymore for use by the system. It is vaguely similar to the SCRATCH command for files, since it doesn't really erase any data from the disk — just frees the entry, in this case just in the BAM.
FORMAT FOR BLOCK-FREE COMMAND;
PRlNT#file0, "BLOCK-FREE:" drive; track; block or abbreviated as
, "B-F:" drive; track; block
USING RANDOM FILES
The only problem with what yc-u've learned about random files so far is that you have no way of keeping track of which blocks on the disk you used, After all, you can't tell one used block on the BAM from another. You can't tell whether it contains your random file, just part of a program, or even sequential or relative files.
To keep track, the most common method is to build up a sequential file to go with each random file. Use this file to keep just a list of record, track, and block locations.
This means that there are I channels open ro the disk for each random file: one for the command channel, one for the random data, and the other for the sequential data.
This also means that there arc 2 buffers that you're filling up at ihe same time!
3J
SAMPLE PROGRAM WRITING 10 RANDOM-ACCESS BLOCKS WITH SE
QUENTIAL FILE:
10 OPEN15,8,15
20 OPEN5,8,5,"#"
30 OPEN4,8,4,"@0:KEYS,S,W"
40 A$= "RECORD CONTENTS ff"
50 FORR=1TO10
70 PRINT#5,A$","R
90 T= 1:B= 1-
100 PRlNTfll5,"B-A;"0;T;B
110 INPUT#15,A,B$,C,D-
120 IF A = 65THENT = C:B = D:GOTO100
130 PR1NT#15."B-W:"5;O;T;B
140 PRINT#4,T","B
150 NEXT R
160 CLOSE4:CLOSE5:CLOSE15
FIND NEXT
AVAILABLE
TRACK &
BLOCK
SAMPLE PROGRAM READING BACK 10 RANDOM-ACCESS BLOCKS WITH
SEQUENTIAL FILE:
10 OPEN15,8,15
20 OPEN5,8,5,"#"
30 OPEN4,8,4,"KEYS,S.R"
40 FOR R=lTO10
50 1NPUT#4,T,B
60 PRINT#I5,"B- R:"5;0;T;B
80 !NPUTfl5,AS,X
CHECKS TO
MAKE SURE
DATA IS OK
90 IF A$<>"RECORD CONTENTS #
100 PRINTASiR
110 PRINT#l5,"B-F:"0;T;B.
120 NEXT R
130 CLOSE4:CLOSE5
140 PRINT/J15,"SO:KEYS"
150 CLOSE15
OR XOR THEN STOP
(■■KEESTHIS
TRACK & BLOCK
FOR LATER USE
BUFFER-POINTER
The buffer pointer keeps track of where the lasi piece of data was written. It also is the pointer for where the nex* piece of data is to be read. By changing the buffer pointer's location within the buffer, you can get random access to the individual bytes within a block. This way, you can subdivide each block into records.
For example, let's lake a hypothetical mailing list. The information such as name, address, etc., will take up a total of 64 characters maximum. We could divide each block of the random access file into 4 separate records, and by knowing the track, sec tor, and record numbers, we can access that individual record.
FORMAT FOR BUFFER-POINTER COMMAND:
PRINTtffileS, "BUFFER-POINTER:" channel; location or abbreviated as
PRlNTtffilefl, "B-P:" channel; location
EXAMPLE OF SETTING POINTER TO 64TH CHARACTER OF BUFFER:
PRINTS 15, "B-P:" 5; 64
Here are versions of ihe random access writing and reading programs shown above, modified to work with records within blocks:
SAMPLE PROGRAM WRITING 10 RANDOM-ACCESS BLOCKS WITH 4
RECORDS EACH:
10 OPEN15.S.15
20 OPEN5,8,5,"#"
30 OPEN4,8>4,"@0:KEYSlSlW1t
40 AS-"RECORD CONTENTS//"
50 FORR=1T010
60 FORL=tTO4
70 PR[NT#151"B-P:"S;(L-l)*64-f-
80 PRENT#5,A$
90 NEXT L
100 T=L:B=1
110 PRINTS! 5
120 lNPUTfll5,A,l
130 IF A-65THEN T=C:B=D:GOT(
140 PRINTS! 5,"B-W:"5;O;T;B
150 PRLNT#4,TC7'B
160 NEXTR
170 CLOSE4:CLOSE5:CLOSE15
^^-^-^-^
/ set POSITIONS
s\ TO I, 65r 129, 1W }
FIND
AVAILABLE
TRACK &
BLOCK
33
SAMPLE PROGRAM READING BACK 10 RANDOM-ACCESS BLOCKS WITH
4 RECORDS EACH:
10 OPEN15,8,I5
20 OPEN5,8,5,"#"
30 OPEN4,8,4,"KEYS,S,R"
40 FOR R=lTO10
50 INPUT#4,T,B
60 PR1NT#I5,"B-R:"5;O;T;B
70 FORL=1TO4
80 PRINT#15,"B- P:"5;(L- 1)'64+ 1
85 INPUT#5,AJ,X
90 IF A$o"RECORD CONTENTS*" OR X<> L THEN STOP
95 PRINT R;AS;L
100 NEXT L
110 PR1NT/M5,"B-F:"O;T;B
120 NEXT R
130 CLOSE4:CLOSE5
140 PRINT#15,"S0:KEYS"
150 CLOSE15
USER1 and USER2
The USER commands are generally designed to work wiih machine language (see chapter 8 for more on this). The USER1 and USER2 commands are special versions of the BLOCK-READ and BLOCK-WRITE commands, but... with an important dif ference: the way USER! and USER2 work with the buffer-pointer.
The BLOCK-READ command reads up to 256 characters, but stops reading when the buffer-pointer stored with the block says that block is finished. The USER1 com mand performs the BLOCK-READ operation, but first forces the pointer to 255 in order to read the entire block of data from the disk.
FORMAT FOR USER1 COMMAND
PRINT#file#, "Ul:" channel; drive; track; block or
PRINT#file#, "UA:" channel; drive; (rack; block
There is no difference between the Ul and UA designations for this command.
34
The BLOCK-WRITE command writes the contents of the buffer to the block on the disk along with the value of the buffer-pointer. The USER2 command writes the buffer without disturbing the buffer-pointer value already stored on that block of the diskette. This is useful when a block is to be read in with BLOCK-READ, updated ihrough the BUFFER-POINTER and PRINTS statements, and then written back to the diskette with USER2.
FORMAT FOR USER2 COMMAND:
PRlNT#file#, "U2:" channel; drive; track; block
Or
PRINT#filefl, -UB:" channel; drive; track; block
For a more complex sample program, see Appendix C.
35
7.
RELATIVE FILES
RELaiive Tiles allow you to easily zero in on exactly the piece of data thai you want from the file, ll [s more convenient for data handling because it allows you to structure your files inio records, and into fields within those records.
The DOS keeps track of the tracks and blocks used, and even allows records to overlap from one block to Ihc next. 31 is able 10 do this because it establishes side sec tors, a series of pointers for the beginning of each record. Each side sector can point to up to 120 records, and there may be 6 side sectors in a file. There can be up to 720 records in a file, and each record can be up to 254 characters, so the file couid be as large as (he entire diskette.
CREATING A RELATIVE FILE
When a RELaiive file is first to be used, the OPEN statement will create that file; after that, that same file will be used. The replace option (with the @ sign) does not erase and re-creale the file. The file can be expanded, read, and written into.
FORMAT FOR THE OPEN STATEMENT TO CREATE RELATIVE FILE:
OPEN file#t device*, channel*, "name,L," + CHRS(record length)
EXAMPLES OF OPEN STATEMENT CREATING RELATIVE FILES;
OPEN 2, 8, 2, "FILE.L," + CHRS(IOO)
OPENF, 8, F, A$+",L,"
OPEN A, B, C, "TEST,L/' + CHRS{33)
36
Table 7.1: RELATIVE FILE FORMAT r>ATA m.ncK
BYTE
0,1
2—256
DEFINITION
TnrV ™H hlnrl- nf npxr daia block.
254 bytes of data. Empty records contain FF (all binary ones) in the first byte followed by 00 (binary all zeros) to the end of the record.
Partially filled records are padded with nulls (00).
SIDE SECTOR BLOCK
BYTE
0,1
2
3
4,5
6,7
8,9
10,11
12,13
14,15
16-256
DEFINITION
Track and block of next side sector block.
Side sector number. (0-5)
Record length.
Track and block of first side sector (number 0)
Track and block of second side sector (number 1)
Track and block of third side sector (number 2)
Track and block of fourth side seclor (number 3)
Track and block of fifth side sector (number 4)
Track and block of sixth side sector (number 5)
Track and block pointers to 120 data blocks.
Upon execution, the DOS first checks to see if the file exists. If it does, then nothing happens. The only way to erase an old relative file is by using the SCRATCH
command (see chapter 4), but nol by using the replace option.
USING RELATIVE FILES
In order to OPEN a relative file once it exists, the format is simpler.
FORMAT FOR OPENING AN EXISTING RELATIVE FILE:
OPEN file#, device^, channels, "name"
In this case, the DOS automatically knows that it is a relative file. This syntax, and the one shown in the above section, boih allow eilher reading or writing to the file.
In order to read or write, you must, before any operation, position the file pointer to the correct record position.
FORMAT FOR POSITION COMMAND:
PRINTSfileS, "P" CHRS{channel» + 96) CHRS(rec#lo) CHR$(rec#hi)
CHR$(position)
ECAMPLES OF POSITION COMMAND:
PRINTSI5, "P" CHR$(2'+96VCHRS(]) CHR$(O)
PRINTSI5, "P" CHR$(CH + 96))CHR$(R1) CHRS(R2)
tg—^
*r ~^^ i^~l Position ^
PR1NTS15, "P" CHRS(4+96) CHRS(Rl) CHRS(R2) CHRS(P) (within Record
The 2-byte format for the record number is needed because one byte can only hold
256 different numbers, and we can have over 700 records in the file. The rccfl lo con tains the least significant part of the address, and the recS hi is the most significant part. This could be translated to the actual record number by the formula
REC# = REC HI • 256 + REC LO.
If the record number is known, the high and low bytes can be determined as follows:
RECfl HI = INT{REC#/256)
REC# LO=REC#-REC# HI'256
EXAMPLE:
PR1NTS15, "P" CHRS(4 + 96) CHR$(R1) CHR$(R2) CHR$(0)
If REC# = 54O: R2= INT(54O/256) . . . so R2 = 2
R1 = 54O-R2'256 . . . so R]=28
38
Let's assume we have a mailing list. The list consists of 8 pieces of data, according to this chart:
Field Name first name last name address line 1 address line 2 city state zip code phone number
Le
20
12
2
9
10
12
15
20
TOTAL 100
This is how the record length is determined. We would probably want to allow an extra character in length for each field, to allow for separations; otherwise the INPUTS command would pick up a much longer piece of the file than needed, just like in se quential files. Therefore, we'll set up a file with a length of 108 characters per record.
In the first record, we'll put the number 1, representing the largest records used so far.
Here is the program as described so far:
5 X = 0
10 OPENl.8,15
20 OPEN2,8,3,"0:MA1L1NG LIST,L, " + CHRS(108)
30 GOSUB900
40 PR1NT#1,"P"CHRS(3 + 96)CHR$(1)CHRS(O)CHRJ(1)
50 GOSUB900
60 1FE = 50THENPRINT#2,1:GOT040
70 1NPUTS2.X
75 PRINT X
300 STOP:CLOSE1;CLOSE2;END_
900 INPUT#1,E,BS,C,D'
910 IF (E = 50) OR (E<20) THEN RETURN
920 PRINT E;BS;C;D:STOP:RETURN
Error #50 which is checked in line 60 of the program is Ihe RECORD NOT PRE
SENT error, which means that the record hadn't been created yet. Writing into the record will solve the problem. This error condition must be watched carefully within your programs.
39
So far, all it does is create the file and the first record, but doesn't actually put any data in it. Below is a greatly expanded version of ihe program, to actually allow you to work with a mailing list where the records arc coded by numbers.
■I OPEN
RELATIVE
FILE CALLED
V'MAILINO LIST"
10 OPEN1,8,15:OPEN2,8,3,"0:MAILING LIST.L, " + CHR$(10i
20 PRINT#l."P"CHR$(3 + 96)CHRS(l)CHR$(0)CHRS(l):INPUTfl2,XS:
X=VAL(XS): X = 0THEN X = 2
30 INPUT "READ,WRITE,OR END";JS:IF JS = "E'THEN CLOSE2'
CLOSE I: END
40 IFJ$ = "W"THEN200
50 PR1NT:INPUT "RECORD #";R:IF R<0 OR R>X THEN 50*^
CrEAD ROUTINE
60 IF R<2THEN 30
70 Rl = R:R2 = 0:IF Rl>256 THEN R2= INT (R1/256):R1 =R1 - 256-R2
80 RESTORE:DATAI,FIRST NAME.14.LAST NAME,30,ADDRESSl 51
ADDRESS2
90 DATA72,CITY,85,STATE,88,ZIP,98,PHONE#
100 FOR L=1TO8:READ A,AS:PRINT#l,"P"CHR$(3 + 96) (R1)CHR$(R2)
HR$(A):GOSUB900
110 ON A/50 GOTO50
115 INPUTfl2,ZS:PRINT AS,ZS:NEXT:GOTO50
s-s\r
( WRITE routine
200 PRINT:INPUT "RECORD #";R:IF R<0 OR R>500 THEN 200-1
210 IF R<2THEN 30
215 IFR>KTHEN R = X + I:PRINT:PR1NT "RECORD/T;R
220 Rl = R:R2 = 0:IFR>255THEN R2= INT (R1/256):RI = R1-256-R2
230 RESTORE:FOR L= IT08:READ A.AS^RlNTfll.-'P-'CHRSg + gfi)
CHR$(R1)CHR5(R2)CHR$(A)
232 GOSUB900
235 PRINT A$;:1NPUT Z$:IF LEN(ZS)>A(L) THEN Z$ = LEFT$(Z$,A(L))
240 IjRINT#2,ZS:GOSUB900:NEXTiIF R>X THEN X = ]
245 PRINT#l,"P"CHR$(3 + 96)CHRS(l)CHR$(0)CHR$(l)
250 PRINT#2,X:GOSUB900:GOTO200
900 INPUT#l,A,BS,C,D:IFA<20THEN RETURN
910 IF AO50THEN PRINT A;B$,C;D:STOP:RETURN
920 IF JS="R" THEN PRINT BS
930 RETURN
ERROR CHFXKING
SUBROUTINE
This program asks for record numbers when retrieving records. It won't let you retrieve from beyond the end of the file, and if you try to write beyond the end it forces you to write on the next higher record.
A more advanced version than this would keep track of the items by "keys", to index the records. For example, you would probably want to search for a record by name, or print out labels by zip code. For this you would need a separate list of keys and record numbers, probably stored in sequential files.
40
When working with a new relative file that will soon be very large, it will save much lime to create a record at the projected end of the Tile. In other words, if you ex pert the file to be 1000 records long, create a record* 1000 as soon as the file is created.
This will force the DOS lo create all intermediate records, making later use of those records much faster.
EXAMPLE OF CREATING LARGE FILE:
OPEN 1.8, 15: OPEN 2, 8, 2, ■■fl:REL,L," +CHRS(60)
PRINTS. "P" CHRS(2 + 96) CHR$(0) CHRS(4) CHR$(l)
PRINTS, "END"
CLOSE 2: CLOSE 1
40
50
60
63
65
67
70
75
76
77
78
80
82
85
90
100
105
106
110
115
130
160
PROGRAM AND EXPLANATION
9
11
20
30
1
2
3
4
5
6
8
REM RELATIVE FILE PROGRAM
DIM AS (5):DIM CS{5) :PRiNT" □ "
PRINT "HIT Fl TO CONSTRUCT A RELATIVE FILE"
PRINT "HIT F3 TO READ A RELATIVE FILE"
PRINT "HIT F5 TO READ THE ERROR CHANNEL":GOSUB 5000
INPUT"ENTER RELATIVE FILE NAME";Z3
OPEN2.8,2,Z$+",L," + CHR$<50) :REM CREATE THE RELATIVE FILE
OPENl.8,15
GOSUB 1000
FOR 1 = 1 TO 5
PRINTS,■■P"CHRS(2 + 96)CHR$(l)CHRS{0)CHRS(i):REM POSITION THE
RECORD POINTER
PRINT "ENTER A NAME"
INPUT A$(I)
PRINT#2,A$,(I)
INPUT "ENTER ADDITIONAL INFO";CS(I)
PRINT#l,"P"CHRS(2 + 96)CHRS(I)CHRS(0)CHRS(25) :REM POSITION
POINTER TO 25TH CHARACTER
PRINT #2,CS(I)
NEXT I
PRINT"DO YOU WISH TO REPLACE A RECORD":INPUT DS
1FD$ = "N"THEN8O
GOSUB 8000
GO TO 75
PRINT"THE RELATIVE FILE IS CONSTRUCTED"
FOR DE = 1 TO 2500:NEXT DE:GOSUB 6000
CLOSE 2
END:STOP
INPUT "ENTER DESIRED FILE TO READ";Z$
OPEN 2,8,2,ZS:OPEN 1,8,15
PRINT "READING "ZS
FORI=1TO5
REMFORI = 5TO1 STEP-1
PRIN™,"P"CHRS(2 + 96)CHR$(I)CHR$(O)CHR$(1)
INPUT#2,AS(I)
41
170
175
177
179
180
PRINT "RECORD0(1T')-t',AS(l)
K = 6-l
PRINTS,"P"CHR$(2 + 96)CHRS(I}CHR$(O>CHR5(25)
1NPUT#2,C$(I):PSINT"ADDITIONAL INFO:";C$(I)
NEXT I
181
182
183
184
PRINT "DO YOU WISH TO REPLACE A RECORD'MNPUT DS
IFDS="N"THEN 1S5
GOSUB 8000
GO TO 181
185
186
GOSUB 1000
J-I+l
190 PRINT "END OF READ";FOR DE= ] TO 1500;NEXT DE:GOSUB
1000
6000:CLOSE2:CLOSE1:END
INPUT#1,A,B$VC,D,:1FA < 20 THEN RETURN
1001 IFAO5GTHEN PRINT A,B$.C,D :STOP:RETURN
1999 END
2000
2001
OPEN 15,8,15
1NPU™5.A,BJ,C\D
2002 PRINT A3S,C,D
2003 CLOSE 15:END
5000 GET SS:IF SS= ""THEN 5000 :REM SCAN KEYBOARD FOR
5001
FUNCTION KEY CHRS CODES
IF SS = CHR$(133) THEN 6:REM ASSIGN Fl FUNCTION KEY
5002 IFSS = CHRJ(134) THEN 100:REM ASSIGN F3 FUNCTION KEY
5003 IF S$ = CHRS{D5) THEN 2000: REM ASSIGN F5 FUNCTION KEY
5004 RETURN
6000 PRINT "OHIT F7: FOR HARD COPY OR C TO CONTINUE"
6001 GET PS:1FP$< >CHRS(136) AND PS- "C" THEN RETURN
6002 FOR DE=1 TO 500:NEXT DE:IF PS = ""OR PS<>CHR$(136) THEN
6000
6003 OPEN 4,4 :CMD4
6004
6005
PRINT#4,"THE "ZS" FILE CONSISTS OF:"
FOR I = 1 TO 5
6010 PRIN™/'RECORD#M;I
6012 PRINT#4,"ADDITIONAL
6015 NEXT I
6020 CLOSE4:RETURN
7000 REM TO READ IN RECORDS IN REVERSE ORDER REMOVE THE
REM IN LINE #115 AND
7002 REM PUT A REM BEFORE LINE#110
7005 REM TO READ THE 1ST FIELD OF THE 1ST RECORD AND THE 2ND
FIELD OF THE LAST
7007 REM REPLACE THE CHRS(I> IN LINE 177 WITH CHRS(K)
8000 PRINT"WHICH RECORD ft DO YOU WANT REPLACED'MNPUT J
8001 1NPUT"ENTER NEW RECORD";AS(I)
S002
PRINT#1."P"CHRS(2 + 96)CHRS(])CHRS<O)CHRS(1):REM POSITION FILE
POINTER
8003 PRlNT#2hAS(I)
8004 INPUT-'ENTER NEW RECORD (FIELD 2r';CS(I)
42
8005
8007
8009
8010
PRINT#l,"P1'CHRS<2 + 96>CHRS(I)CHRS(0)CHR$<25) :REM POSITION FILE
POINTER
PRINT#2,CS(I)
PR1NT"RECORD#";1;"HAS BEEN REPLACED"
RETURN
CREATE A RELATIVE FILE
The program below, creates a relative file with 2 fields. The first field starts in position 1 of the record and the second field starts in position 25.
LINE 8: Create the file. Make room for records of 50 characters with the CHR$(50).
Use the Z$ as a file, input variable in LINE 6, you can then press the fl function key to create a file.
LINE 30: Point to the first character position of a file. P tells the disk drive to point to the position in the record that corresponds to the optionaJ, CHR$(1).
NOTE: If the CHRS is not specified, character position defaults to ].
LINE 65: Point to the twenty-fifth character position of a file. P tells the disk drive to point to the position in the record that corresponds to the CHR$(25).
NOTE: The POSITION command docs NOT write anything to, or read anything from the file. It just points to the position specified in the record.
WRITE TO A RELATIVE FILE
LINE 60: Use the PRINTS statement after ihe POSITION command to move to character position I, as specified in LINE 30 — CHR$(1).
READ FROM A RELATIVE FILE
LINE 130: Specify the character position using the POSITION command. Then follow it with LINE 160, the INPUT/* statement.
SUMMARY
In this program, you press the fl key and a RELative file is created on disk. You can type RUN and press the D key to READ the previous RELative file. If an error condition exists (flashing red light on the disk drive) you can hit the RUN/STOP key, type RUN and press the f5 key. This reads the ERROR CHANNEL from the drive, shows the enor number and message, as well as the track and sector of the error. It then resets the drive for use. Later on the program asks if the file should be printed. To print the file, press the 17 key when prompted, or press C to continue.
43
REMEMBER:
1) Before a file can be written 10, or read from, a POSITION command must be ex ecuted.
2) You must always use PRINT #1 with the POSITION command. This puts your daia under command channel control.
3) The FIRST character string code in ihe POSITION command must correspond 10 the THIRD number (channel ~) in ihe OPEN statement. Except OPEN 1, 8, 15
(see lines 8 and 30 of above program).
A) For convenience, use the FOR . . . NEXT loop variable in ihe SECOND character siring, CHRS(i), of the POSITION command where I equals ihe record number
(see lines 20 and 30 of above program).
MODIFYING THE PROGRAM
1) You can add mare POSITION commands to make more fields wiihin each record.
Remember to include the character position number as the last CHRS, when ad ding fields,
2) To change the length of each record, change the value of CHR£(50) in LINE 8.
3) The number of records in ihe file is determined by the POSITION command. The current example can process 5 records; the FOR . . . NEXT loop variable is 1 io5.
The program can process 720 records, but in order to use more than 512 records, the number 2 must be in the THIRD CHRSf ) of the POSITION command. For more than 256, use [he number I, For up to 256 records, simply use the FOR - ■ .
NEXT loop variable. EXAMPLE: FOR I = I TO 256 may access 256 records.
44
8.
PROGRAMMING THE DISK CONTROLLER
The expert programmer can actually design routines that reside and operate on the disk controller. DOS routines can be added that come from The diskette. Routines can be added much the same way as the DOS Support Program is "wedged" into your memory.
BLOCK-EXECUTE
This command will load a block from the diskette containing a machine language routine, and begin executing it at local ion 0 in the buffer until a RTS (ReTurn from
Subroutine) command is encountered.
FORMAT FOR BLOCK-EXECUTE:
PRINTflfiletf, "B-E:" channel- drive; track; block
MEMORY-READ
There is !6K of ROM in the disk drive as well as 2K of RAM. You can get direct access to these, or to the buffers that the DOS has set up in the RAM, by using the
MEMORY commands. MEMORY-READ allows you to select which byte to read, through (he error channel.
FORMAT FOR MEMORY-READ:
, H1M-R" CHRSflow byte of address) CHR5(high byte)
(no abbreviation!)
The next byte read using the GETtf statement through channels 15, the error channel, will be from that address in the disk controller's memory, and successive bytes will be From successive memory locations,
Any INPUTS to the error channel will give peculiar results when you're using this command. This can be cleared up by any other command to the disk (aside from a memory command).
25
30
40
PROGRAM TO READ THE DISK CONTROLLER'S MEMORY:
10
20
OPEN15,8,15
INPUT"LOCATION PLEASE";A
FOR L=lTO50
Al = INT(A/256): A2= A - A 1*256
PRINT#15,4'M-R"CHRS(A2)CHRS(A1) jyJ
60
70 so
90
100
]10
OtlffljfAl
PRINT ASC(A$ + CHRS(0));
A=A+ 1
—
NEXT
INPUT "CONT1NUE";AJ
IF LEFTS(AIJ) = "Y>r THEN 25
GOTO20
45
_^^ /GET CHARACTERS
~\ FROM ERROR
\ CHANNEL }
MEMORY-WRITE
The MEMORY-WRITE command allows you to write up to 34 bytes at a lime in to the disk controller's memory. The MEMORY-EXECUTE and USER commands can be used to run this code.
FORMAT FOR MEMORY-WRITE:
PRINT<*file#, "M-W" CHRS(low address byte) CHRSfhigh address byte)
CHR$(#-of-characlcrs) byte data
PROGRAM TO WRITE AN "RTS" TO DISK:
10 OPEN8,8,15,"I"-
20 PRINT#8."M - W"CHRS(0)CHR$(3>CHR$(l)CHRS<96)
30 PRINT#8."M - E"CHRS(0)CHRS(3)
40 CLOSES
MEMORY-EXECUTE
Any routine in Ihe DOS memory, RAM or ROM, can be executed with the
MEMORY-EXECUTE command.
FORMAT FOR MEMORY-EXECUTE:
PRlNT#fi!e#, "M-E" CHRS(low address byte) CHRS(high byte)
See line 30 above for an example.
46
USER COMMANDS
Aside from the USER] and USER2 commands discussed in chapter 6, and the
UI +■ and UI - commands in chapter 2, the USER commands are jumps to a table of locations in the disk drive's RAM memory-
USER COMMAND
Ul orUA
U2 or UB
U3 or UC
U4 or UD
U5 or UE
U6 or UF
U7 or UG
USorUH
U9 or UI
U; or UJ
UI+
UI-
FUNCTION
BLOCK-READ without changing buffer-pointer
BLOCK-WRITE without changing buffer-pointer jump to 50500 jump to SO5O3 jump to $0506
HEXADECIMAL LOCATIONS) jump to S05O9 jump to S050C jumptoS050F jump to SFFFA power-up vector set Commodore 64 speed set VIC 20 speed
By loading these locations with another jump command, lite JMP $0520, you can create longer routines thai operate in the disk's memory along with an easy-to-use jump table — even from BASIC!
EXAMPLES OF USER COMMANDS:
PRINT* 15, "U3"
PRINT* 15, "U^+CHRStfO + Q)
PRINT* 15, "Ul"
9.
CHANGING THE DISK DRIVE DEVICE NUMBER
SOFTWARE METHOD
The device number is selected by the drive by looking at a hardware jumper on the board and writing the number based on thai jumper in a section of its RAM. Once operation is underway, it is easy to write over the previous device number with a new one.
FORMAT FOR CHANGING DEVICE NUMBER:
PRINTflfileS, "M-W:" CHRS(119) CHRS(O) CHRS(2) CHR$(address + 32)
CHR$(address + 64)
EXAMPLE OF CHANGING DEVICE NUMBER (FROM 8 TO 9):
10 OPEN 15, 8, 15
20 PRINTS 15, "M-W" CHR${i!9) CHR$(0) CHRS(2) CHRS(9 + 32>
CHRS(9 + 64)
If you have more than one drive, it's sensible to change [headdress through hard ware (see below). If you must, the procedure is easy. Just plug in the drives one at a time, and change their number to the desired new values. That way you won't have any conflicts.
48
HARDWARE METHOD
It's an easy job to permanently change llic device number of your drive for use in multiple drive systems. The tools needed are a phillips-head screwdriver and a knife.
STEPS TO CHANGING DEVICE NUMBER ON HARDWARE:
1.
2.
3.
4.
5.
Disconnect all cables from drive, including power.
Turn drive upside down on a flat, steady surface.
Remove 4 screws holding drive box together.
Carefully turn drive right side up, and remove case top.
Remove 2 screws on side of metal housing.
6.
Remove housing.
7.
Locate device number jumpers. If facing the front of the drive, it's on the
8.
9.
left edge in the middle of the board.
Cut either or both of jumpers I and 2 for Model 1541.
Cut cither or both of jumpers A and B for Model 1541CR.
(see chan below)
Replace housing and 2 screws, and case top and 4 screws.
10.
Re-connect cables and power up.
DEVICES
8
9
10
11
JUMPER VI
DON'T CUT
CUT
DON'T CUT
CUT
JUMPER B/2
DON'T CUT
DON'T CUT
CUT
CUT
10.
ASSEMBLY LANGUAGE AND THE 1541
If you want to use your 1541 disk drive to manipulate data directly from assembly language you can use the information presented below.
Here is a list of subroutines that provide the start of memory locations in each of the Kernal routines. These routines are used in conjunction with the assembly language command JSR 10 jump to thai subroutine location in memory:
SUBROUTINE
SETLFS = SFFBA
SETNAM = SFFBD
OPEN = SFFCO
CLOSK
CHKIN
CT.RCII
= SFFC3
= SFFC6
- SFFCC
BASIN
BSOUT
= SFFCF
= SFFD2
; set logical, physical &. secondary addresses
; save length & address of filename
; open a logical tile
; close a logical file
; open a channel far input
; dear all channels
; get a byte from a file
; output a character to the screen
For a more complete description as to what each routine does and what parameters are passed lo and from cadi routine, see your Commodore 64 or V1C-20
Programmer's Reference Guide.
Now, for a practical application of the subroutines listed above, here is a sample program using (hose routines to read a sequential file on a disk. Assume that you have stored the filename "TEST" at SC0O0.
INIT
LDA #$04
LDX #$00
LDV #$C0
JSR SETNAM
LDA #503
LDX #$08
LDY #500
JSR SETLFS
JSR OPEN
LDX #$03
JSR CHKIN your program info
JSR BASIN
BEQ END
JSR BSOUT
JMP jour prog, info
END
LDA #503
JSR CLOSE
JSR CLRCH
RTS
; initialise:
; filename length
; low byte of filename address
; high byte of filename address
; save length & address of filename
; logical address
; device number
; secondary address (0 = read seq. file)
; set logical, physical & secondary addresses
; open logical file
; sei x-rcgislcr to logical address
; open input channel
; get data and print it one byte at a time
; get one byte
; if 0 then end of file or error
; output character to the screen
; loop
; set accumulator to logical address
; close Hie
; clear channels and reset defaults
; end of assembly language program
SO
APPENDIX A: DISK COMMAND SUMMARY
Genera] Formal: PRlNT#file#, command
COMMAND
NEW
COPY
RENAME
SCRATCH
INITIALIZE
VALIDATE
DUPLICATE
BLOCK-READ
BLOCK-WRITE
BLOCK-ALLOCATE
BLOCK-FREE
BUFFER-POINTER
USER1 and USER2
POSITION
BLOCK-EXECUTE
MEMORY-READ
MEMORY-WRITE
MEMORY-EXECUTE
USER Commands
"N
"C:new file= :orginal file
"R:new name = old name
"Sifile name
"I
"V noi for single drives
"B-R:"' channel; drive; [rack; block
"B-W:" channel; drive; irack; block
"B-A:" drive; track; block
"B-F:" drive; track; block
"B-P:"' channel; position
"Un:" channel; drive; track; block
"P" CHRS(channel#) CHRS(rec#lo) CHRS(rec#hi)
CHRS( position)
"B-E:" channel; drive; track; block
"M-R" CHR$(address lo) CHR$(addrcss hi)
"M-W" Cl!R$(addrc5s lo) CHR$(address hi)
CHRS(Schars) "data"
"M-E" CHRS(address lo) CHRS( address hi)
"Un"
APPENDIX B: SUMMARY OF CBM FLOPPY ERROR MESSAGES
64
65
66
67
70
71
72
73
74
30
31
32
33
34
39
50
51
52
60
61
62
63
0
21
22
23
24
25
1
2-19
20
26
27
28
29
OK, no error exists.
Files scratched response. Not an error condition.
Unused error messages: should be ignored.
Block header not found on disk.
Sync character not found.
Data block not present.
Checksum error in data.
Byte decoding error.
Write-verify error.
Attempt to write with write protect on.
Checksum error in header,
Data extends into next block.
Disk id mismatch.
General syntax error
Invalid command.
Long 11. . .
Invalid filename.
No file given.
Command file not found.
Record not present.
Overflow in record.
File too large.
File open For write.
File not open.
File not found.
File exists.
File type mismatch.
No block.
Illegal Irack or sector.
Illegal system track or sector.
No channels available,
Directory error.
Disk full or directory full.
Power up message, or wrile attempt with DOS Mumatch-
Drive not ready.
DESCRIPTION OF DOS ERROR MESSAGES
NOTE: Error message numbers less lhan 20 should be ignored with the exception of 01 which gives information about the number of Tiles scratched with the SCRATCH com
mand.
20READ ERROR (block header not found)
The disk controUer is unable to locate the header of the requested data block.
Caused by an illegal block number, or the header has been destroyed.
21: READ ERROR (no sync character)
The disk controller is unable to detect a sync mark on the desired track. Caused
by misalignment of the read/writer head, no diskette is present, or unformatted or improperly seated diskette. Can also indicate a hardware failure.
22: READ ERROR (data block not present)
The disk controUer has been requested to read or verify a data block that was
not properly written. This error message occurs in conjunction with the BLOCK
commands and indicates an illegal track and/or block request.
23: READ ERROR (checksum error in data block)
This error message indicates that there is an error in one or more of the data bytes. The data has been read into the DOS memory, but the checksum over the
data is in error. This message may also indicate grounding problems.
24READ ERROR (byte decoding error)
The data or header as been read into the DOS memory, but a hardware error has been created due to an invalid bit pattern in the data byte. This message may also
indicate grounding problems.
25: WRITE ERROR (write-verify error)
This message is generated if the controller detects a mismatch between the writ ten dala and the data in the DOS memory.
26: WRITE PROTECT ON
This message is generated when the controller has been requested to write a dala
block while the write protect switch is depressed. Typically, this is caused by us ing a diskette with a write a protect tab over the notch.
27READ ERROR (checksum error in header)
The controller has detected an error in the header of the requested data block.
The block has not been read into the DOS memory. This message may also in
dicate grounding problems.
28: WRITE ERROR (long data block)
The controller attempts to detect the sync mark of the next header after writing a
data block. If the sync mark does not appear within a pre-delermined time, the
error message is generated. The error is caused by a bad diskette format (the data extends into the next block), or by hardware failure.
S3
29:
30:
31:
DISK ID MISMATCH
This message is generated when the controller has been requested to access a diskette which has not been initialized. The message can also occur if a diskette has a bad header.
SYNTAX ERROR (general syntax)
The DOS cannot interpret the command sent 10 the command channel. Typical ly, this is caused by an illegal number of 111c names, or patterns are illegally used.
For example, two file names may appear on the left side of the COPY com mand.
SYNTAX ERROR (invalid command)
The DOS does not recognize the command. The command must start in the first position,
32:
33:
34:
39:
SYNTAX ERROR (invalid file name)
Pattern matching is invalidly used in the OPEN or SAVE command.
SYNTAX ERROR (no file given) the IIJe name was left out of a command or the DOS does not recogniic it as such. Typically, a colon <:) has been left out of the command.
SYNTAX ERROR (invalid command)
This error may result if the command sent to command channel (secondary ad dress 15) is unrecognised by the DOS.
50:
51:
RECORD NOT PRESENT
Result of disk reading past the last record through INPUTtf, or GET0 com mands. This message will also occur after positioning la a record beyond end of file in a relative file. If the intent is to expand the file by adding the new record
(with a PRINTS command), :he error message may be ignored. INPUT or GET should not be attempted after this eiTor is detected without first reposiiioning.
OVERFLOW IN RECORD
PRINTS statement exceeds record boundary. Information is cut off. Since the carriage return is seni as a record terminator is counted in the record size. This message will occur if [he total characters in the record (including the final car riage return) exceeds the defined size.
52:
60:
SYNTAX ERROR (invalid command)
The command sent is longer than 58 characters.
FILE TOO LARGE
Record position within a relative fite indicates that disk overflow will result.
WRITE FILE OPEN
This message is generated when a write file that has not been closed i$ being opened for reading.
61:
62:
FILE NOT OPEN
This message is generated when a file is being accessed that has not been opened in ihc DOS. Sometimes, in this case, a message is not generated; the request is simply ignored.
FILE NOT FOUND
The requested file does not exist on the indicated drive.
63:
64:
65;
66:
67:
FILE TYPE MISMATCH
The file type does not match the Tile type in ihe directory eniry for ihe requested
file.
NO BLOCK
This message occurs in conjunction with the B-A command. It indicates that the block to be allocated has been previously allocated. The parameters indicate Ihe track and secior available with the next highest number. If the parameters are zero (0), then all blocks higher in number are in uje.
ILLEGAL TRACK AND SECTOR
The DOS has attempted to access a track or block which does not exist in Ihe format being used. This may indicate a problem reading the pointer to the next block.
ILLEGAL SYSTEM T OR S
This special error message indicates an illegal system track or block.
70: NO CHANNEL (available)
The requested channel is not available, or all channels arc in use. A maximum of five sequential Tiles may be opened at one time to the DOS. Direct access chan nels may have six opened Tiles.
71:
72:
FILE EXISTS
The file name of ihe Tile being created already exists on the diskette.
DIRECTORY ERROR
The BAM docs not match the internal count. There is a problem in the BAM allocation or Ihe HAM has been overwritten in DOS memory. To correct this problem, reinitialize the diskette to restore ihe BAM in memory. Some active files may be terminated by ihe corrective action. NOTE: BAM = Block
Availability Map
DISK FULL
Eilher the blocks on ihe diskette are used or the directory is at its entry limit.
DISK FULL is seni when two blocks are available on the 1541 to allow the cur rent Tile to be closed.
55
73:
74:
DOS MISMATCH (73, CBM DOS V2.6 1541)
DOS 1 and 2 are read compatible but not write compatible. Disks may be inter changeably read with either DOS, but a disk formatted on one version cannot be written upon with the other version because the format is different. This error is displayed whenever an attempt is made io write upon a disk which has been for matted in a non-compatible format. {A utility routine is available to assist in converting from one formal to another.) This message may also appear after power up.
DRIVE NOT READY
An attempt has been made to access ihe 1541 Single Drive Floppy Disk without any diskettes present in either drive.
56
APPENDIX C: Demonstration Disk Programs
1.
DIR •■ ■
4 0PEM2 S.15
5 pfimttt goto
I Li 0PEN1 .3D. "19"
£0 GET! I Fit EJ
GETil .i=i*. 3* c=e if h*ou" then
:?»': ■ them
?3 C-ET«l-£l tF STO0 THEN
[00 IF &fOCMFT.*O-4J THEN W
110 ..E'»l ?J IF B*00R*<3OTHEN PPJHTB*
:;■■ GET*1 BS TF PI^CHPJ- ?2 - THEM 1^'?
IIS PRINT Tfl?-|8>i CT="
[4? C*-C54-B* GETK1.BS IF B*O"
ISO PRINT"B"LEFT*fC* 3)
:-?9 GET Tt EF T*O"" THEIi GOSUE
170 IF ST=0 THEM 30
PMNT" BLOCrS FREE"
IF Tt= nthen CUDSEt
GET TJ IF T*=" l-OTCIIO
9 Cl=1MI PRIMT">"
I5E7B*
PRIHTB*!
IF E*-CHP»-:i3/ THEM
: ;j=C*~** GOTO -101 :
*i IF B
3029 PPIHT-B" inPiP.? FFIKT 'P-pIPECTOPV
1B310 FPItlT "Sp-DIS* COTtflflMD"
10020 &PINT "O-SUIT FPOOPflri"
OETFI* if f\*^<t>" them is i83ee [F ft*-"-" cjr nt»">- of h4=i-i them
19310 IF Ht-"G" THEM fflli
10320 IF R»n"5" THEM
10?:^ GOTO 10100
tilr
7 MBfA
60
01 en
OZI
201
Oil o^i
J3J iiKinidJ iittiNisd
SZOX&'ltlOd tz>SNi
,,ei.
,.*,.■S*S'3M3dO
= itn,
INldd
,-irJi-s.u3
'ai:b'£*..
b/tf,,=*nij w/M B/N tt/H «u/H i-t-z
■+(I^*dl£j*lH0ld.LL+,lMldd t£-..
1X3N eg?
d
1K3H
,,wit*siiiL:,.ir<idd ees utv
Q&S u_i'
UP:1 hJcT d]
1X3N
.1.11
+«.iiudd
BL-lHIdd
O«'b/SHJ
■ hJHi fxN'jidiJJd
H3HliT-SflHU0E t-Z'fl"&OrajWliliad:H3Hi8T«Sam«'2CLd;i
'(fb'Z-*nHJ*aiHlHiarfH3Hie£"SttH0L;t-Lidri
IdilUHEdd »fiH f-'£'
I'
-,t
'
>frVZ'*n rdio :.
■ v:
6990X09
0990100
' AVldSlQ S1?!
9it
0t£
ItC
BSI
S?J
di dl
HiJ-3-J
..IHiad
t-ii'
1£"
^S^ t'i^ t-,.;
=*iS
'S'SIH3dD ii 3HJ.
***+n.«*l***w3d
MBIO
*+
01 3H1
4********
J0S
13= uydSDdd
Jl dDd I .;bt=
B
....=Jif
.XMiadH3Hl..S»-*ri
*a+L.l,,'£1 ulHIddH3Hl,d,.-ill
Ul
KZH3KL
JjriSO^
1NUXSH0O
055 di di
,,d.,=lll
,,^-.^*lf H3H1
H3H1
31A£t o du HSIiI d3JJi"i esttip stp
Ft*
*PV fir evt-
Epp sit-
^ ixsn
:j^*h-*^
<I>*U'5*i3a wraa di
DON aod
<*Od dOd
,..=*y a^ad 9 iarj e^i
^-i
1=^
I
0=1 i dub
0-.H
di insoo oi o±
Qi
,i:..=ra dl
£>I
£s e di
,.s..-*n c&i t*r-M
N3H1 j*ihjOshph:£ n3Hi
....='.[.i*U
U ec-r ansoD esi
<'I
*3+*£-*s h3hi
M3H1
*y ffftSGQ ansco
******4
♦
Jl-eu n3hi.,h.,-*z ee-r
OSS
1X3N dl
<aod
F6 ib tiS
JI dOd
(Il«U'Sli3S
1-jI
Q-r 01
<lt^O
I
^H'l
0-1 ox
1S3H ii dl
2>1
£1 no,1
*Z dl .(J.-tZ inyn l>*tl
JI3H1
02S ixaw
06SN3H1 ansoo.<•ij*Hj^sy=n ae^ ji
■ciyai
I.H
CMb
■3>HtJ .-■„ f(3 dI:S3'13'*W3 B-H3 t'3i yj^ e +w3-d dJ dl
3
*u3d
*w3d ji dl
9C3 uyt
MS
Bsa ties wit
++♦♦*+♦+♦+♦#♦♦*+*******»»#»#t*uad
S3l>\*O.OSU
-."L^Mj^jiy
,.U..-S"
..A..<:*Z d31DydyHi
«sia
.isiii
bias
M3H1 dO oi
.t>;Hj*aiu*ib=*id aiAa
,.JJ
M3M1
H3H1
1 » oi
Sb^
^3h
S,.dCilJ3S
.=tj ..
6Sl«*3>3Sfe!
♦
H3Hi
Ndniaa lu i+ ■ 1
N-drtL3d.iiLm
HdlU3d m3hi,.m,,=*z eta;
4. CHECK DISK
1 FEM CHECK BISK — VER 1.4
2 PN»B=REM FLOPPY DEVICE NUfiBER
5 Bifrr<iee>-pirisci80>-«EM brd truck, sector
10 PRINT" CHECK DISC
12 PRINT"
20 If*-"0"
3Q 0PEN15 DH. 15
33 PPIItTltl?. "V"B*
4? HK-RHD<T]
SP PRINT: PRIHT*2*fl*;
M PPINT*15- "E-fli-DI-T.^S
IBS IHPUT#15,EM,En*.ET.ES
ireT-0THEN29B-pEM END
134 H?=HB+l PPIhtT" CHECKEB BLGCKS'NB
135 PRINT-1 TRACK IMWT" SECTOR
143 tHPUT#15.EN*EH»,ES»CT
159 IF EN-DTHEHe3
1(58 F<J5»T:SCJ>"S J"J*I
155 PRINT"MHPfiD BLOCK III" , T. S" "
170
212 CLOSE2
315 IFJ=OTH£NPRIHT"mi»MHO BflP BLOCKS t "
^17 OPEN2.DH3. "#ri
21P PftINT"1WBFi:D FLOCKS". "TPflCK" , "^
235 PPIHT#15.r'E-P
24e print. .■m>,sa>
2^0 NEHT
2^S PP-INT1 'VJ"BflD BLOCKS HHVE BEEN FtLLOCfiTED"
27" CL05E2 END
?J5? IriPMTttl^.EN^EMJ.ET, ES
?ie tF EN=0 THEM RETURN
S2O PRINT "HMERROR H"EM, EI«; ET; E5"11
930
5.
PERFORMANCE TEST
PEM PERFORMANCE TEST
1020 REM
1030 RF.fi
1040
VtC-2?i RMD rOMMCDOPE 64
SIMPLE FLOPPY DISK DRIVE
1050 OPEN L8.-150PEm5.6- 13
1PS0 LT-33
Mrtft PPIHT"
11 If PRfMT
> 1 ?fl PPIHT
H^ft FPTMT"
1 t Jtt PFINT
PEPFCPMRNCE TEST
INSERT
115"? PPIIJT1
U££ PPTPJT
I17fl PFlNTpl
PPTUT
PRINT"
DISKETTE 11J WIVE"
PRESS ^ETUPH*'
WHEN PEflLiVB"
FOP i=.3 TO 9B-0ET R* NEXT
? GET fl* IF fWOCHS1*'1 ?• THE*I
1 "P
'-M9-TES7
137? Cl*=" DISK MEM CWNRHII "+CHP*M3'»
128Q C?j=-n WRIT FIBDUT RO 5ECCWB9"
1336 DC*=Clf+Ci* CiOSUP 1?J0
130? IF TKHTTHEN1370
I^io PftlHT-iEVSTEM 15"
1320 PPIfJT"W MOT RESPONDING"
15?3 FPitrr- rnppErTL',' TO
1343 eOSLf
1378
1^0 PPHtT"
1393 TT=^1
MECHRHICRL TESTU"
140fi OPEN M3.2.H9 TEST FILES.U"
1415 CC*='OFEH WRITE FILE'
1-420 CH=2 O;**"UPIT£ DRTR'1
1430 rCl^'CLOSE "+CC*
1440 OPEN 2-9.2- "8 : TEST FILE'S^11
OOSUB 1S43
MJSUB 1936
OTSUD 1840
1450 CCI-'-DFEH REPO FILE1 GOSUB 1840
1470 PPIHT*1.-SOFTEST FILE"
1413? CC*«"?CRPTCH FILEM" TT-1
1430
G05UE
152B OPEN 4-S.4,"#"
153^ HNK=<r1*PHI!l<rTI)1ES54+miK^fit-tB253 PRIMTtl. "B-P1
1^40 IJNt^ FOR 1 = ] TO 233:HN**NN
1339 PRINT* 4.MN±: l^fpi PRIIJ7* 1 ■ "U2 : "-4 ; 3;LT:0
15?Q CC»-"WRITE TPfiCK"+LTi GOSUB 1843
1559 CC*=rlUffITE TRRCK 1"
PPIHTttl . "L.ll : " \A O:LT:B
TRflCKrl+LT*
:6CHUB
■ OGSUB
1653 i?C*-1R£ftt' Tf^RCK 1" GOSUB 1B40
62
l£70 PPtHT"1l UHTT HRS PRS5EC"
16m PRINT" PEPFOPMflMCE TEST'"
\&X* PPtUT"*] PULL TJlSkTTTE FRCTI"
173S PPIHT-'H URl'/E BEFORE TURNING"
ITli? PP1NT1
172B EUP
POWER OFF."
1740
I7T0 PPINT" BCOtlTlHUE CV/H>?"J
1760 FOP 1-0 TQ 50-GET P>*
177C GET fli IF A*=llI< THEN J
1760 PRINT R*"lfl" t75?l JF fl*f"H" THEN END ieeo ir *«-"v" then petmph
." ",.r'j*l\ i Af.\l\ ** /
1S70 IF EN<2 THEN l?i3O PRINT "W UHir tS FfllLING11
,p^p PPiMT"*] PERFORMANCE TEST1 rhi'TI* GOSUE 1750 TI**TM*
FHR IH0P1? TO ?"PC PRINT#CH,I :»EXT
GO5UB1630 i?ee n.osE ch return
15*7a
?p t n Pijp I w 10^0 TO £O0B
J^Sfl INPUT* TH, ,T
2fl»? IF J<> I THEN PPlHT'SPEPD EPRDP' ■'■ COSUB
-: ,-iT TH PFTUFN
APPENDIX D: DISK FORMATS
NOTE
Nol lo scsde
/
SYNC ID 1 id: THAI K 11 LOCK
CHECK
SUM
GAP 1 SYNC 11!
d
POINTERS TOLINK
TOGF.THF.H All. BLOCKS
WITHIN A KILI
2i4 BY1ES
Ol I1ATA
CHECK
SUM
N
\
1540/1541 Format: Expanded View of a Single Secior
64
Track number
1 to 17
18 ro24
25 to 30
31 10 35
BLOCK DISTRIBUTION BY TRACK
Block Range
Oto 20
Oto 18
Oio 17
Oto 16
Total
21
19
18
17
1540/1541 BAM FORMAT
Track 18, Sector 0.
BYTE
0,1
2
3
4—143
CONTENTS
18,0]
65
DEFINITION
Track and block of first directory block.
ASCII character A indicating 4040 format.
0 Null flag for future DOS use.
Bit map of available blocks for tracks 1—35.
* ] = available block
0 = block not available
(each bit represents one block)
1540/1541 DIRECTORY HEADER
Track 18, Sector 0.
BYTE
144—161
162—163
Itvl
165-166
166—167
177—255
CONTENTS
160
50,65
DEFINITION
Disk name padded with shifted spaces.
Disk ID.
Shifted space.
160
ASCII representation for 2A which is DOS version and format type.
Shifted spaces.
0 Nulls, not used.
Note: ASCII characters may appear in Locations 180 thru 191 on Kome diskettes.
BYTE
0—1
2—256
SEQUENTIAL FORMAT
DEFINITION
Track and block of next sequential daia block.
265 bytes of data with carriage Feturn as record terminators.
BYTE
0,1
2—256
PROGRAM FILE FORMAT
DEFINITION
Track and block of next block in program file.
265 bytes of program info stored in CBM memory format (with key words tokenized}. End of file is marked by three zero bytes.
BYTE
0-1
2-31
34—63
66-95
98—127
130—159
162—191
194—123
226-255
DIRECTORY FORMAT
Track 18. Block 1 for 1540/1541
DEFINITION
Trad [ and block of next directory block.
*File entry 1
•File entry 2
•File entry 3
•File
•File entry 4 entry 5
*File entry
6
* File entry 7
♦File entry 8
•STRUCTURE OF SINGLE DIRECTORY ENTRY
1-2
3—18
19—20
21
22—25
26-27
28—29
0
BYTE CONTENTS
128 + type
DEFINITION
File type OR'ed with S80 to indicate properly closed file.
TYPES: 0 = DELeted
1 - SEQentiaL
2 = PROGram
3 = USER
4 = RELative
Track and block of 1st data block.
File name padded with shifted spaces.
Relative file only: track and block for first side sector block.
Relative file only: Record size.
Unused.
Track and block of replacement Tile when OPEN@ b in effect.
Number of blocks in file: low byte, high byte.
fi7
RELATIVE FILE FORMAT
DATA BLOCK
BYTE
0,1
2—256
DEFINITION
Track and block of next data block.
254 bytes of data. Empty records contain FF (all binary ones) in the firsi byte followed by 00 (binary all ^eros) to ihe end of the record.
Partially filled records are padded wilh nulls (00).
SIDE SECTOR BLOCK
BYTE
0—1
2
4-5
6—7
8-9
10—11
12—13
14—15
16—256
DEFINITION
Track and block of next side sector block.
Side sector number (0-5)
Record length
Track and block of first side seclor (number 0)
Track and block of second side sector (number ])
Track mid block of third side sector (number 2)
Track and block of fourth side seclor (number 3)
Track and block of fifth side sector (number 4)
Track ;ind block of sixth side sector (number 5)
Track and block pointers to 120 daia blocks
INDEX
A
Assembly Language, 50
B
BLOCK-ALLOCATE, 30-31, 51
Block Availability Map (BAM), 940, 25, 28. 30-31, 64-68
BLOCK-EXECUTE, 45, 51
BLOCK FREE, 31, 51
BLOCK-READ, 28-29, 3102, 34-35, 51
Blocks, 3. 34-35, 64-6S
BLOCK-WRITE, 3Q, 32, 34-35. 51
Buffer, 3, 33
BUFFER-POINTER, 33-34, 51
C
CLOSE, 19
COPY, 16. 5]
D
Data Channel, 29
DemonstraliDii Disk Programs, 57-63
Device Number, 20, 48-49
Directory, 9-10, 24-27. 66-67
Disk Controller, 45-47
Disk Operating System (DOS), 10-11, 13,25-28.31.33.53-56
DOS Support Program, 13, 18
Drive Speeds, 7
DUPLICATE, 18, 5!
E
End-ol-file(EOF),2]
Error Channel, is, 43-45
Error Messages. 52-56
F
FORMAT (see NEW)
G
CETtf, 23
I
INITIALIZE, 17,46,51
INPUT*, 18,21-22,44
L
LOAD, 1, 8-15. 19
69
M
Mailing List Program, 39-40
MEMORY-EXECUTE, 46, 5]
MEMORY-READ, 45, 51
MEMORY-WRITE, 46, 51
N
NEW, 15,51
O
Open, 14-15, 20
P
Pattern Matching, 11
POSITION, 38-43, 51
PRINTS, 14-15, 21
Program Files (PRO), 20, 26, 56
R
Random Files, 3, 28-33
Relative Files (REL), 1, 3, 5, 20, 33-44, 68
RENAME, 16, 51
S
SAVE, 1, 12, 17
SCRATCH, 17, 51
Sectors, 3, 64-6S
Sequcniial Files (SEQ), 1, 3, 5, 20-23, 26-27, 31-32, 44, 66
Serial Bus interface, 2, 6-7
Side Sector, 36-37
Specifications, 2-3
T
Tracks, 5, 2S, 33, 64-68
U
USER, 47, 51
User Files (USR), 20, 26, 34-35
V
VALIDATE, 17, 51
VERIFY, 13, 51
W
Wedge, 7
Wild Cards, 11
COMMODORE SALES CENTERS
Commodore Business Machines, Inc.
1200 Wilson Drive
West Chester, PA 19380, U.S.A.
Commodore Business Machines Limited
3370 Pharmacy Avenue, Agincourt
Ontario, M1W2K4, Canada
Commodore Business Machines {UK) Ltd.
1, Hunters Road, Weldon
Corby, Nortbants, NN17 1QX, England
Commodore Bueromaschinen GmbH l]0 HOX 710126, Lyonersuasse 38
6000 Frankfjll 71, West Germany
Commodore Italians 5.P.A.
Vici Friitelli Gracchi 48
20092 Cinisello Balsamo, MilanD, Italy
Commodore Business Machines Pty Ltd.
b 0rioi i Ru;iiJ
Lane Cove, NSW 2066, Australia
Commodore Computer B.V.
KabelwegSB
1014 BC AMSTERDAM, Netherlands
Commodore AG(Scheweii)
Aeschenvofstadi 57
Ch-^OIQ Basfil, Switzerland
Commodore Computer NV-SA
Europalaan 7^
I^OST-STEVENS-WOLUWE, BeJgium
Commodore Data AS
Bjerrevej67
^, Denmark
MODEL am 1OO1
1 Megabyte double sided, floppy disk drive.
Uses double density, double sided diskettes.
IEEE interface.
MODEL EO31LP
Media compatible with 1541 and 4O4O diskettes.
170 K of memory per single side disk.
Rugged and stylish housing.
IEEE interface.
Pk JTERS
MODEL MPS-BO1
High quality dot matrix printing.
BO column printing.
Prints 5O characters per second.
Serial port interface.
..
MODEL MCS-8O1
Seven color, dot matrix printing.
Up to BO columns printed per page.
Prints 3B characters per second.
Perfect for everything from personal letters to Important business reports.
Sen si port interface.
MODEL 15ZB
BO column, dot matrix printing.
Prints SO characters per second.
Durability at an affordable price.
Senal Port interface.
I1 /Ir.'i , ■ j .- PLOTTER
MODEL 1S2O
Four cole, printer/plotter for ell graphic needs.
Print bar graphs...create pie charts. ..plot time graphs.
High quality printing in a vanety of styles and sizes.
Great for graphic artists.
Mk< •>'•< ■;■■ VriiS
VICMODEM
Timely financial information, news and reference libraries are as near as your phone.
An affordable introduction to the growing world of phone /computer services.
Communicate with a wide variety of computer users who already own a modern.
AUTOMODEM
The convenience of automatic ansenng and dialing.
The resource power of telecomputing services.
Turn your phone into e telecomputing information network.
commodore
COMPUTER
Printed in Japan P/N !540031-02 (!)
Download
Annonce