Apple DOS

Apple DOS

Apple computer running a Hello World program
Developer Apple Computer
Written in Assembly[1]
OS family Apple DOS
Working state Discontinued
Source model Closed source
Initial release Late 1978 (1978)
Latest release 3.3 / 1980 (last released bug fix in 1983)
Kernel type Monolithic kernel
License Apple Software License Agreement

Apple DOS is the family of disk operating systems for the Apple II series of microcomputers from late 1978 through early 1983. Apple DOS has three major releases: DOS 3.1, DOS 3.2, and DOS 3.3; each one of these three releases was followed by a second, minor "bug-fix" release, but only in the case of Apple DOS 3.2 did that minor release receive its own version number, Apple DOS 3.2.1. The best-known and most-used version is Apple DOS 3.3 in the 1980 and 1983 releases. Prior to the release of Apple DOS 3.1, Apple users had to rely on audio cassette tapes for data storage and retrieval, but that method was notoriously slow, inconvenient, and unreliable.

Version history

When Apple Computer introduced the Apple II in April 1977, the new computer had no disk drive or disk operating system (DOS). Although Apple co-founder Steve Wozniak designed the Disk II controller late that year, and believed that he could have written a DOS, fellow founder Steve Jobs decided to outsource the task. The company considered using Digital Research's CP/M, but Wozniak sought an operating system that was easier to use. On 10 April 1978 Apple signed a $13,000 contract with Shepardson Microsystems to write a DOS and deliver it within 35 days. Apple provided detailed specifications, and early Apple employee Randy Wigginton worked closely with Shepardson's Paul Laughton as the latter wrote the operating system with punched cards and a minicomputer.[2]

There was no Apple DOS 1 or 2, per se. Versions 0.1 through 2.8 were serially enumerated revisions during development, which might as well have been called builds 1 through 28. Apple DOS 3.0, a renamed issue of version 2.8, was never publicly released due to bugs. To the dismay of many programmers, Apple published no official documentation until release 3.2.[3][4]

Apple DOS 3.1 was publicly released in June 1978, slightly less than one year after the Apple II was introduced, becoming the first disk-based operating system for any Apple computer. A bug-fix release came later, addressing a problem with its MASTER CREATE utility, which is used to create Apple DOS master disks: The built-in INIT command creates disks that can be booted only on machines with at least the same amount of memory as the one that had created them. MASTER CREATE includes a self-relocating version of DOS that boots on Apples with any memory configuration.

Apple DOS 3.2 was released in 1979 to reflect major changes in computer booting methods that were built into the successor of the Apple II, the Apple II Plus. Instead of the original Integer BASIC, the Apple II Plus firmware includes the newer Applesoft II floating point BASIC. The new firmware also has an auto-start feature which automatically finds a disk controller and boots from it when the system is powered up  earning it the name Autostart ROM.

Apple DOS 3.3 was released in 1980. It improves various functions of release 3.2, while also allowing for large gains in available floppy disk storage; the newer P5A/P6A PROMs in the disk controller can read and write data at a higher density, so that instead of 13 sectors (3.25 KB), 16 sectors (4 KB) of data can be stored per disk track, increasing the capacity from 113.75 KB to 140 KB per disk side  16 KB of which is used by filesystem overhead and a copy of DOS, on a DOS 3.3-formatted disk, leaving 124 KB for user programs and data. DOS 3.3 is, however, not backwards compatible; it cannot read or write DOS 3.2 disks. To address this problem, Apple Computer released a utility called "MUFFIN" to migrate Apple DOS 3.2 files and programs to version 3.3 disks. Apple never offered a utility to copy the other way. To migrate Apple DOS 3.3 files back to version 3.2 disks, someone wrote a "NIFFUM" utility. There are also commercial utilities (such as Copy II Plus) that can copy files from and to either format (and eventually ProDOS as well). Release 3.3 also improves the ability to switch between Integer BASIC and Applesoft BASIC, if the computer has a language card (RAM expansion) or firmware card.

Technical details

Apple DOS 3.1 disks use 13 sectors of data per track, each sector being 256 B. It uses 35 tracks per disk side, and can access only one side of the floppy disk, unless the user flipped the disk over. This gives the user a total storage capacity of 113.75 KB per side, of which about 10 KB are used to store DOS itself and the disk directory, leaving about 100 KB for user programs.

Compared to modern operating systems, Apple DOS is quite primitive. The first layer of the operating system is called the RWTS, which stands for "read/write track sector". This layer consists of subroutines for track seeking, sector reading and writing, and disk formatting. An API called the File Manager was built on top of this, and implements functions to open, close, read, write, delete, lock (i.e. write-protect), unlock (i.e. write-enable), and rename files, and to verify a file's structural integrity. There is also a catalog function, for listing files on the diskette, and an "init" function, which formats a disk for use with DOS, storing a startup program (usually called HELLO) that is auto-started when this disk is booted from. On top of the File Manager API, the main DOS routines are implemented which hook into the machine's BASIC interpreter and intercept all disk commands. It provides BLOAD, BSAVE, and BRUN for storing, loading, and running binary executables. LOAD, RUN, and SAVE are provided for BASIC programs, and an EXEC was provided for running text-based batch files consisting of BASIC and DOS commands. Finally, four types of files exist, identified by letters in a catalog listing.

Apple DOS File Formats:

There are four additional file types; "R", "S", and an additional "A" and "B", none of which are fully supported. DOS recognizes these types for catalog listings only, and there are no direct ways to manipulate these types of files. The "R" type found some use for relocatable binary executable files. A few programs support the "S" type as data files.

Relocatable software

Most 8-bit Apple II machine language programs do not concern themselves with code relocation since the Apple II usually does not run multiple programs at the same time like more modern computers. Programs are generally written to always expect to find their machine code at the same memory location every time. Fully relocatable code is more complicated and difficult to implement on the 8-bit 6502 CPU.

Apple DOS, however, needs to accommodate varying amounts of memory installed in an Apple II  from 16 KB up to 48 KB. This DOS loads itself into the highest point possible to free up the lower memory locations for BASIC programs and graphics capabilities. In machines with 48 KB or more memory, it occupies the region from $960016 to $BFFF16 (enough space for three file buffers plus 10 KB of software), but can load into a lower memory area if less system memory is available. (In comparison, ProDOS always loads into language card RAM, thus requiring at least a 64 KB machine.)

A call vector table in the region of $03D0–03FF16 allows programs to find DOS wherever it is loaded in the system memory. For example, if the DOS hooked into the BASIC CLI stops functioning, it can be reinitialized by calling location $03D016 (97610)  hence the traditional "3D0G" ("3D0 go") command to return to BASIC from the System Monitor.

Boot loader

The process of loading Apple DOS involves a series of very tiny programs, each of which carries the loading process forward a few steps before passing control to the next program in the chain.

Integer BASIC and Applesoft floating point BASIC support

The Apple II started out using a simple BASIC interpreter, known originally as Apple BASIC and later as Integer BASIC. It can only handle integer numbers ranging from −32,768 to +32,767 (16-bit binary values) and only has built-in support for low-resolution graphics. But it was the first version of BASIC available for the Apple II and is what the earliest BASIC programs use.

Only months after the Apple II's release, Apple commissioned Microsoft to develop a much more capable BASIC interpreter known as Applesoft BASIC,[5] capable of handling floating-point real numbers with up to nine digits of precision and base-10 exponents from -38 to +38, and with support for high-resolution graphics. While more capable, Applesoft BASIC cannot run Integer BASIC programs, causing some users to resist upgrading to it.

DOS 3.3 was released when Applesoft BASIC was standard in ROM on the Apple II Plus, so Apple designed it to support switching back and forth between the two BASIC interpreters. The DOS 3.3 System Master disk contains Integer BASIC and Applesoft BASIC on disk as binary files which can be loaded into RAM, allowing whichever language was not resident in ROM to be used on any machine with enough RAM. The user can switch between either BASIC by typing either FP or INT at the BASIC prompt. DOS automatically chooses the needed language when running a saved program. Applesoft programs are saved as type-A files, while Integer BASIC programs are saved as type-I files.

Decline of Apple DOS

After 1980, Apple DOS entered into a state of stagnation, along with all other Apple II products, as Apple concentrated its efforts on the ill-fated Apple III computer and its SOS operating system. After the Apple III had been abandoned by the company, two more versions of Apple DOS, both still called DOS 3.3 but with some bug fixes and better support for the new Apple IIe model, were released in early and mid-1983.

Without third-party patches, Apple DOS can only read floppy disks running in a 5.25-inch Disk II drive and cannot access any other media, such as hard disk drives, virtual RAM drives, or 3.5-inch floppy disk drives. The structure of Apple DOS disks (particularly the free sector map, which was restricted to part of a single sector) is such that it is not possible to have more than 400 KB available at a time per drive without a major rewrite of almost all sections of the code; this is the main reason Apple abandoned this iteration of DOS in 1983, when Apple DOS was entirely replaced by ProDOS.

ProDOS retains the 16-sector low-level format of DOS 3.3 for 5.25 inch disks, but introduces a new high-level format that is suitable for devices of up to 32 MB; this makes it suitable for hard disks from that era and 3.5-inch floppies. All the Apple computers from the II Plus onward can run both DOS 3.3 and ProDOS, the Plus requiring a "Language Card" memory expansion to use ProDOS; the e and later models have built-in Language Card hardware, and so can run ProDOS straight. ProDOS includes software to copy files from Apple DOS disks. However, many people who had no need for the improvements of ProDOS (and who did not like its much higher memory footprint) continued using Apple DOS or one of its clones long after 1983. The Apple convention of storing a bootable OS on every single floppy disk means that commercial software can be used no matter what OS the user owns. A program called DOS.MASTER enables users to have multiple virtual DOS 3.3 partitions on a larger ProDOS volume, which allows the use of many floppy-based DOS programs with a hard disk.

Apple stopped authorizing user groups to distribute DOS 3.3 many years ago, but granted one company, Syndicomm, an exclusive license to resell DOS 3.3.[6]

Performance improvements and other versions

DOS's RWTS routine can read or write a track in two revolutions with proper interleaving. A sector of the spinning disk passes under the read/write head while the RWTS routine is decoding the just-read sector (or encoding the next one to be written), and if this missed sector is the next one needed, DOS needs to wait nearly an entire revolution of the disk for the sector to come around again. This is called "blowing a rev" and is a well-understood performance bottleneck in disk systems. To avoid this, the sectors on a DOS disk are arranged on the in an interleaved order:[7]

0 7 14 6 13 5 12 4 11 3 10 2 9 1 8 15

Later, ProDOS arranged the sectors in this order:[7]

0 8 1 9 2 10 3 11 4 12 5 13 6 14 7 15

When reading and decoding sector 0, then sector 8 passes by, so that sector 1, the next sector likely to be needed, will be available without waiting. When reading sector 7, two unneeded sectors, 15 and 0, pass by before sector 8 is available, and when reading sector 15, the drive will always have to wait an extra revolution for sector 0 on the same track. However, the sector 0 actually needed in most cases will be on the next-higher track, and that track can be arranged relative to the last one to allow the needed time to decode the just-read sector and move the head before sector 0 comes around. On average, a full track can be read in two revolutions of the disk.

Unfortunately, the early DOS File Manager subverted this efficiency by copying bytes read from or written to a file one at a time between a disk buffer and main memory, requiring more time and resulting in DOS constantly blowing revs when reading or writing files.[8] Programs became available early on to format disks with modified sector interleaves; these disks give DOS more time between sectors to copy the data, ameliorating the problem.

Later, programmers outside Apple rewrote the File Manager routines to avoid making the extra copy for most sectors of a file; RWTS was instructed to read or write sectors directly to or from main memory rather than from a disk buffer whenever a full sector was to be transferred. An early "patch" to provide this functionality was published in Call-A.P.P.L.E.. Speedups in the LOAD command of three to five times were typical.

This functionality soon appeared in commercial products, such as Pronto-DOS, Diversi-DOS, Hyper-DOS, and David-DOS, along with additional features, but it was never used in an official Apple DOS release. Similar functionality was, however, employed by Apple's successor operating system, ProDOS. The Apple IIGS-specific operating system, GS/OS, would eventually employ an even more efficient "scatter read" technique that would read any sector that happened to be passing under the read head if it was needed for the file being read.

Release of the source code

In 2013, more than 35 years after the Apple II debuted, the original Apple DOS source code was released by the Computer History Museum at its website.[9] Paul Laughton, the creator of the code, has donated it.[10]

References

  1. Apple II DOS - Source Code
  2. Terdiman, Daniel (2013-04-03). "The untold story behind Apple's $13,000 operating system". CNET. Retrieved April 4, 2013.
  3. "Apple Computer". Laughton.com. Retrieved 2013-06-14.
  4. "Apple II History » 14-DOS". Apple2history.org. Retrieved 2013-06-14.
  5. Steven Weyhrich. "Apple II History Chapter 16". Archived from the original on 29 January 2009. Retrieved 2009-01-26.
  6. Dean Esmay. "Even Apple Used Pirate Tools". Archived from the original on 25 July 2011. Retrieved 2011-08-11.
  7. 1 2 "About the archive formats". Retrieved 26 April 2012.
  8. DOS 3.3, ProDOS & Beyond v1.3 bullet 07 Jul 01
  9. Shustek, Len (2013-11-12). "Apple II DOS source code". computerhistory.org. Retrieved 2013-11-30.
  10. "Apple II's 35-year-old operating system is now open to the public". November 13, 2013.
Notes

External links

This article is issued from Wikipedia - version of the 9/28/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.