!lm11
!rm76
Commented Listing of DOS 3.2.1 Format

Here is the second installment of DOS disassembly, covering the area from $BEA0 through $BFFF.  If you read the listing in last month's AAL carefully, you probably noted that it ended with the label definition "FORMAT", but no code followed.  Well, here it is!

FORMAT turns a blank diskette into one with address headers recorded on every track.  Otherwise, the disk is empty.  No directory is written into track $11 yet, nor is any DOS recorded yet in tracks 0, 1, and 2.  When you use the INIT command, the first step exectured is to format the disk; after formatting, a DOS image and empty directory are written; then your HELLO program is SAVEd.

By the way, there are a lot of differences between DOS 3.2.1 and DOS 3.3 FORMAT routines.  Later in this issue of AAL you will find a commented listing of the DOS 3.3 version.  If you compare the two, you will find at least these major differences:

!lm16
1.  DOS 3.2.1 formats 13 sectors per track, DOS 3.3 formats 16 sectors per track.
2.  DOS 3.2.1 writes an address header followed by a long series of $FF bytes where the data should be;  DOS 3.3 writes an address header followed by a standard data block (the data is all $00 bytes).
3.  DOS 3.2.1 writes an address header starting with $D5AAB5; DOS 3.3 writes an address header starting with $D5AA96.
4.  DOS 3.2.1 verifies correct format by trying to read sector 0 immediately after formatting the last sector; no other verification is made.  DOS 3.3 tries to read EVERY sector just formatted; it does a complete check of the track.
5.  DOS 3.2.1 writes the sectors in the order 0, 10, 7, 4, 1, 11, 8, 5, 2, 12, 9, 6, 3; DOS 3.3 writes them in sequential order 0, 1, 2, ... , 15.

!lm11
The Apple Disk Interface depends on critical software timing to operate correctly.  You will find many strange sequences of code (such as PHA, PLA, NOP, PHA, PLA between $BF47 and $BF4B) which are for timing purposes.  If you are interested in counting cycles, the timing for each opcode-address mode combination are listed in the Quick Reference Card that came with your S-C ASSEMBLER II Version 4.0.


Commented Listing of DOS 3.3 Format

As promised three or four pages ago, here is my rendition of the DOS 3.3 Format routine.
