Commodore DOS

from Wikipedia, the free encyclopedia

Commodore DOS ( D isk O perating S ystem) is a floppy - operating system of the company Commodore , which was used in the floppy disk drives the Commodore 8-bit number, z. B. CBM 3040, CBM 4040 , CBM 8050 , CBM 8250, VC1540 , VC1541 , VC1570 / 71 , VC1581 , SFD1001 , SFD1002 .

CBM DOS versions

There are at least seven versions of Commodore DOS. The following list contains the version numbers and the associated drives. Unless otherwise noted, drives are 5¼-inch. The "lp" code denotes "low profile" drives. Drives with model numbers beginning with 15 are connected using the IEEE 488 serial bus protocol ( IEC bus ) (TALK / LISTEN). All others use the parallel IEEE-488.

Disk drive hardware

For a detailed explanation of the hardware, see the separate article CBM floppy disk drives .

In typical computer systems of that time, and in principle until today, floppy disk drives were connected almost directly via the processor bus. Either a simple controller chip or the software of the operating system took care of the coding of the data . The file system was also managed by the computer's operating system.

With the computers of the Commodore 8-bit series, a different approach was chosen. In order to minimize the costs for the computer, which was initially often used without a floppy disk drive, and to keep the connection of drives as flexible as possible, the computer only had very simple and general, character-oriented (not block-oriented) software and hardware - Interfaces to external devices. The complete logic for encoding / decoding sectors as well as the file system and DOS command logic was implemented in the floppy disk drive.

Commodore 8-bit floppy disk drive units were therefore independent computers with one or two processors that were independent of the actual computer. One unit had one or more drives ( Drives ). Several units could be connected to one computer. The operating system that was used in these drives was Commodore DOS. In contrast to the DOS versions from most other companies at the time, it was not stored on a floppy disk, but in ROM chips ( firmware ) inside the drive. This results in a faster system start (the DOS is ready for use within 1 to 2 seconds when switched on), lower costs (ROM memory was significantly cheaper at that time than the same amount of RAM memory) but also less flexibility (newer DOS versions with Error corrections or additional functions can only be used by converting the drive, while other systems only required the exchange of a data carrier).

The original models for the Commodore PET series had two symmetrical CPUs, 2 KB RAM and 16 KB ROM. CPU 1 implemented the logic to read and write sectors, while CPU 2 took care of the file system logic as well as communicating with the computer. The communication between the two processors took place via the main memory: CPU 2 wrote command tuples (action, drive, track, sector, memory address) in a defined memory area, which CPU 1 read out, executed and overwritten the command tuple with the result code. The two CPUs could use the same memory at the same time by making use of a special feature of the 6502 processors - they only access the system bus in one of the two halves of each clock cycle . The CPUs were now interconnected in such a way that CPU 1 used the bus in the first half of the clock and CPU 2 in the second half of the clock, exactly as the processor and the video chip shared the bus in the Commodore computers.

In principle, all of this information also applies to the CBM 9060 and CBM 9090 hard disks .

Later devices only had one drive and the second CPU was saved for cost reasons. The individual CPU took on both tasks, but the original conception of the system remained unchanged: The tasks of CPU 2 (file system) ran as the main program, while the tasks of CPU 1 (hardware control) were performed in an interrupt routine.

Features of Commodore DOS

Actions such as formatting floppy disks, renaming, deleting or copying files are carried out by Commodore DOS and run entirely in the drive unit. The DOS offers a flat file system (for details see under SFD100x ) without subdirectories and with a limited number of entries, i.e. files, per data carrier (floppy disk or hard disk). The maximum number of entries varies with the capacity of the respective data carrier, from a 170 KB floppy disk to a 4.5 MB hard disk drive.

Supported file types

Each file has an identifier in the table of contents that assigns it to one of the following file types :

  • Sequential file (SEQ) - for unstructured data to be read in a continuous stream, the length is in the table of contents, each data block has the block number of the following block for this file on the floppy disk in the first two bytes, so that only 254 useful bytes are stored per block are.
  • Program File (PRG) - structured like a sequential file; contains the load address in the computer's main memory in the first two useful bytes and then the binary memory content as it was copied from this memory area or is to be written back into it.
  • Relative file (REL) - direct access file that allows the diskette blocks it occupies to access specific locations within the file directly via separately stored pointers ("pointers", in one or more sequentially linked data blocks) without the entire content having to read through beforehand. With most other operating systems this is possible for all files, Commodore DOS saves a little memory space by not creating the necessary structures for non-relative file types.
  • User file (USR) - structured like a sequential file; does not have to comply with any other rules.

The table of contents itself is stored in a similar way to a sequential file, but does not appear in the table of contents (not even as a “.” As in Unix or MS-DOS ). When it is read out, it is formatted like a non-executable BASIC program and loaded like such into the main memory and can be viewed there with the LIST command of the basic interpreter (attempting to start this pseudo-program with the RUN command leads to on the other hand to an error message). Since it is loaded like a BASIC program, it also overwrites any BASIC program that may have been there before, which must then be reloaded. Only in version 4 of Commodore BASIC there are separate commands for viewing the table of contents without overwriting a BASIC program in the main memory.

Command transfer

Each drive can maintain 15 virtual channels or files (0-14) through the interface to the computer; H. the computer can hold up to 15 files open for reading or writing on a drive. (The actual number of open files is in practice limited by the RAM of the drive, usually 3–4 files and the command channel can be kept open, with relative files counting twice.)

On the other hand, the computer works with its own virtual channels, identified by their number and assigned to the devices when they are opened; When the channel is opened, the device (e.g. floppy disk drive) is also informed which virtual channel it should use for this connection. The numbers are any “names” that can be used to address real buffers in the computer and the devices.

Channel 15 ("command channel") has a special meaning for a floppy disk drive: commands from the computer to Commodore DOS and status messages run in the other direction via it. On the computer side, however, the command channel is treated exactly like a normal file.

Channel 0 is intended for read operations and channel 1 for write operations (especially loading and saving programs) so that the type of access no longer has to be specified when using these channels.

Receiving and sending of data and commands

The data exchange between the computer and the drive is made possible via the aforementioned virtual channels ("secondary addresses") in the drive. With Commodore computers (e.g. C64 ) there are analogue virtual channels ("file numbers") also on the computer side, managed by routines in the ROM-based operating system ( Kernal ). These are called up by the BASIC interpreter when certain BASIC commands are entered or directly by programs, especially assembler programs. The computer's virtual channel numbers ("file numbers") are never communicated to the drive, but only used within the computer itself. The drives identify files only via the "secondary addresses".

The following examples illustrate how DOS is addressed from the BASIC level and how user-friendliness depends on the implementation of the latter. In this context, “device” explicitly means a Commodore floppy disk station and is used to distinguish between a “drive” and a “drive”, since some stations consist of two drives.

Example 1: renaming a file

OPEN 1,10,15: PRINT # 1, "R: NEUNAME = ALTNAME": CLOSE 1
or abbreviated OPEN 1,10,15, "R: NEUNAME = ALTNAME": CLOSE 1

The OPEN command opens the virtual channel ("file number") 1 on the computer side, assigns it to device 10 on the serial bus and sends this device the information to use the virtual channel ("secondary address") with number 15 (ie a buffer area) to reserve and call him “15”); Based on this number 15, the device knows that this channel does not send data for a file , but rather DOS commands that it should execute. The second command sends the command "R" (can also be written in RENAME) to channel 1 with the new and old file names. The third command closes the virtual channel.

Example 2: Opening a file and writing a text into it

OPEN 1,8,13, "0: TESTFILE, S, W"
or OPEN 1,8,1, "0: TESTDATEI, S"
or DOPEN # 1, "TESTFATEI, W"

PRINT # 1, "WIKIPEDIA, THE FREE ENCYCLOPAEDIA"
CLOSE 1

The first OPEN command opens virtual channel ("file number") 1 on the computer side and assigns it to device 8. This device is first informed that a file is to be opened, which from now on can be addressed via the number ("secondary address") 13. Since this is a real file, it is on a specific data carrier and has a name. "0" denotes the number of the drive in which the data carrier is located, the first drive of a device with two drives (the second drive would be called "1"). The characters between the colon and the comma are interpreted as the name of the file. This is followed by "S" to indicate that it should be a file of the type SEQ (sequential read / write), and "W" for WRITE (write access). Other access modes are "R" (Read) and "M" (Modify). The character string between the quotation marks is sent unchanged by the computer to the diskette station and only there the individual components (drive number, name, file type, access mode) are interpreted.

The command below fulfills exactly the same function, but since the drive-side virtual channel number 1 is used and this is reserved for write operations by default, the entry for write access is omitted. The next command requires BASIC 4.0 or higher and fulfills the same purpose without the user having to worry about further parameters - the device number, the drive-side channel number ("secondary address"), the file type and the drive number are automatically added by the BASIC interpreter before sending the command to the drive.

All of these commands also enter the computer-side virtual channel number ("file number"), the device number, and the drive-side channel number ("secondary address") in an internal table in the computer's memory, so that further commands that refer to the same file , only the file number has to be specified.

The next command sends the text to the virtual channel (buffer in the RAM of the drive). Using the specified file number, the computer finds the device number and secondary address previously specified in the internal table; this and the specified text are transmitted to the diskette station. The last command closes the channel, whereby the device number and secondary address are again looked up in the internal table and transmitted to the diskette station, followed by an end-of-file marker. Only when the buffer overflows or the CLOSE command causes the text to be written to the diskette. At the same time, CLOSE releases the buffer in the drive for other purposes and removes the entry for the device number and secondary address from the mentioned computer-side table. Any further access to this file is only possible after a new OPEN or DOPEN command.

While this procedure, with one level each of virtual channels on the computer and drive side for programs, offers options for device-independent access (addressing drives in the same way as printers, modems, datasets , keyboard, screen, etc.), it is unwieldy for simple drive operations . Commodore therefore integrated commands in later versions of BASIC for easier access to disk contents:

Example 3: Renaming a file in BASIC 4.0 or 7.0 (e.g. C128)

RENAME " old " TO " new "

Technically speaking, this command works like example 1 (except that it addresses device 8 instead of 10).

BASIC extensions for CBM computers also often integrate a command (usually "@") which enables commands to be sent directly on the command channel of a drive without the user having to worry about the level of files and channels:

Example 4: Renaming a file with DOS-Wedge or e.g. B. JiffyDOS

@R: new = old

In particular, querying the command channel from the computer is made much easier because this is how DOS reports to the computer:

Example 5: Querying the status of the device with DOS-Wedge or e.g. B. JiffyDOS

@

Output z. E.g .: 00, OK, 00, 00

Commodore floppy disk units report their status in the above. Form as a CBM-ASCII string to the computer. The first number indicates the number of the event that has occurred (generally an error, but also, for example, the selection of a partition with the 1581), 0 means none here. A comma is followed by the error in plain text (but less differentiated than the number, so read errors are reported as "READ ERROR" for various reasons and must be narrowed down more precisely using their number), then two numbers that are usually (but not for all messages ) Specify the track and sector of the event. From BASIC 4.0 the status can also be called up as a text string using the system variable DS $ (for "Disk Status") and the event number using DS .

Commands

The following incomplete list shows some important Commodore DOS commands, also to illustrate the sometimes quite elaborate nature of the commands. The commands can also be sent with the full names also listed, since the first character is used to distinguish them, i. A. be shortened.

Most commands can use the wildcards ? and * process. Depending on the command, either the first or all suitable files are used. The file name $ (dollar sign) is reserved for the directory of a disk which a non-executable form, but LIST-baren Commodore BASIC -Programms is returned.

The specification of a drive number, which is possible in many commands, is not mandatory, drive 0 is the default value. With some commands, however, obscure problems can arise if no drive number is given; therefore it has become common practice to always include these in the command, even for devices with only one drive. The BASIC commands of the higher BASIC versions from 4.0 onwards do this automatically.

Most commands with numeric parameters expect these as decimal numbers from ASCII digits (sequences of hex codes $ 30 to $ 39 for the digits 0 to 9). The POSITION command and the MEMORY commands, however, expect their parameters in binary format (hex codes $ 00 to $ FF for the values ​​0 to 255).

  • N [d] : name, id - NEW: Formatting a floppy disk in drive d (0 or 1) of the device. name is the disk name that will appear later in the header of the table of contents, id is a two-character code that is written in the header of each data block on the disk; based on this, the drive can recognize when the diskette has been changed, of course only if the same ID is not used for different diskettes. Specification of a drive other than 0 is of course only possible for devices with two drives, e.g. B. "N1: name, id " - Formats the disk in drive 1 (second drive).
  • N [d] : name - NEW: Deletion of the table of contents of an already formatted floppy disk without reformatting; the ID does not change. All file names and any references to the location of the files are deleted and all blocks of data are freed, but the actual file data is not deleted.
  • V [d] - VALIDATE: Checking the file system and correcting incorrect entries, correcting the free storage space; comparable to the CHKDSK or ScanDisk from MS Windows
  • I [d] - INIT, INITIALIZE: Initializing the disk (updating the B lock A viability M ap for short BAM) in the drive cache, may be necessary after changing the disk if the IDs of the disks do not differ)
  • R [d] : new = old - RENAME: Rename a file; note that the new name comes first, unlike most other operating system rename commands
  • C [d] : new = old - COPY: copy a file on the same disk. Here, too, the new name comes first.
  • C [x] : re = [y]: old - COPY: copy a file from drive y (0 or 1) on drive x (1 or 0), if necessary, under the new name again ; only possible within devices with two drives
  • S [d] : name - SCRATCH: delete one or more files
  • D: [x] = [y] - DUPLICATE: Copy an entire floppy disk from drive y (0 or 1) to drive x (1 or 0); only possible within devices with two drives; note that the destination drive is shown first, unlike the duplicate commands of most other operating systems
  • P, channel number position - POSITION: Searching for a specific position in a file (only possible with relative files). The channel number means the secondary address described above.
  • BR channel track sector - BLOCK-READ (mandatory abbreviation): Reading of a sector and transmission of the content to the specified logical channel (= secondary address). Due to complaints about the for real block-by-block access, e.g. for copying a floppy disk in devices with only one drive or direct manipulation of the file system, the command does not work properly (the first byte of the block determines the number of bytes read) by the following "Intuitively" functioning variant added:
  • U1 channel track sector - replacement for block read, always reads the whole block, also writable as "UA"
  • BW channel track sector - BLOCK-WRITE (mandatory abbreviation): Writing a sector, the first byte determines the number of bytes to be written
  • U2 channel track sector - replacement for block write, always writes the whole block, also writable as "UB"

If the second letter in "BR" and "BW" is capitalized or replaced by a corresponding graphic character (bit 7 is set in the code of the set CBM-ASCII character set), there is no check for permissible values ​​for tracks and sectors, for example areas outside to manipulate the normal floppy disk format.

  • U3-U8 - User commands: Jump to your own software in the drive RAM through jump table, can also be written as "UC" - "UH"
  • U9 - Resetting the device to the waiting state and initializing the floppy disk (reset), also "UI"
  • U: - Resetting the device to the power-on state and initializing the disk ("hard" reset), also "UJ"
  • U0> PETSCII character no. X - Assigning a new device number x to the drive (only 157x and newer)
  • MW AdrL AdrH Number of data bytes - MEMORY-WRITE (abbreviation mandatory): Writing to the RAM of the floppy disk drive
  • MR AdrL AdrH number - MEMORY-READ (abbreviation mandatory): Read from the RAM of the floppy disk drive
  • ME AdrL AdrH - MEMORY-EXECUTE (abbreviation mandatory): Starting a machine program in the RAM of the floppy disk drive

With the memory and U commands you can transfer your own software to the floppy disk drive, let it run there and finally read out the results stored in the RAM. Applications for this:

  • You can optimize data access, as a practical example, time-critical searches in a database were carried out entirely within the floppy disk drive.
  • You can speed up the transfer between the floppy disk drive and the computer by replacing the very suboptimal transfer routines with more optimized variants. This was mainly used for the serial CBM bus between the C64 and its drives.
  • The floppy disk station can be used as a slave computer that takes on partial tasks in multiprocessing , so that overall more data throughput is achieved. Example: fractal calculation ( Mandelbrot set ) or the first stage of a database search for a university library catalog. The very limited RAM memory of most drives (mostly 2 kilobytes) made this only possible to a limited extent, only the 1581 had enough RAM with 8 kilobytes for somewhat more complex calculations.
  • A more complex copy protection can be built into programs by writing a program to the drive that can read non-standard data structures from a floppy disk that are unreadable with normal copying programs.
  • You can also bypass copy protection procedures by allowing software in the drive to access the data stream on the floppy disk surface directly and pass it on to the computer for analysis without modification.

These possibilities for direct access to the internal information of the drive were often useful in practice, but prevented a meaningful upgrade path without complex and expensive measures to maintain compatibility; the 1571 drive already contained several components that only served to maintain compatibility with the predecessor model 1541 on this deep level. Today's ( hard disk ) drives no longer offer such possibilities , although they also have a high level of intelligence in their firmware and a lot of internal RAM.

Use of the drives on third-party computers

Due to the plain text character of the commands, it was also relatively easy to operate Commodore drives (at least those with the standardized parallel IEEE-488 bus) on IEEE-488 bus-capable computers from other manufacturers (e.g. Tektronix). The commands could easily be formulated in their own BASIC dialect as output instructions and sent to the devices. Knowledge of the structure of this data was only required for the interpretation of the returned results (e.g. directory listing in the form of a pseudo-Commodore BASIC program).

Individual evidence

  1. Table of contents of a floppy disk , description on c64-wiki.de
  2. Block Availability Map , description on c64-wiki.de