DOSPLUS 3.5 for the Model I - BOOT/SYS Disassembled
Page Customization
Page Index
BOOT/SYS
Other Navigation
Introduction/Summary
DOSPLUS 3.5 BOOT/SYS Disassembly - The Boot Sector and the Boot Settings Sector (Model I)
BOOT/SYS is the first file of every DOSPLUS 3.5 diskette: granule 0 of cylinder 0, sectors 0-4 (its directory entry, the first entry of directory sector 2, gives 5 sectors in one granule). It is not a load module. Sector 0 is the boot sector the ROM runs, sector 1 is a byte for byte copy of it, sector 2 holds this diskette's copy of the perishable part of its drive control table (DCT) and the boot settings the SYSTEM command keeps, and sectors 3 and 4 are 00H. Byte 2 of sector 0 holds the directory cylinder, 11H (cylinder 17).
When the computer is reset with a diskette in drive 0, the ROM reads cylinder 0, sector 0 into 4200H-42FFH and jumps to 4200H. The boot sector clears the screen, reads sector 2 into 5200H, and switches a double density adapter to double density when the diskette's flags say so (bit 7 of 5203H; clear on this diskette). It then reads sector 4 of the directory cylinder (byte 0AH of sector 2) into 5300H, checks that its first entry is an active system file, works out from the entry's first segment descriptor where SYS0/SYS starts, and reads SYS0/SYS sector by sector into 5300H-53FFH, copying each load block to its address. The transfer record sends it to SYS0/SYS at 4E00H, with Index Register IX still pointing to the settings at 5200H. A sector that cannot be read in two tries, or a wrong directory entry, displays ERROR! and stops the computer until RESET is pressed.
Sector 0 is shown at 4200H-42FFH, where it runs, and sector 2 at 5200H-52FFH, where the boot sector reads it; sectors 1, 3 and 4 are shown at their file offsets (0100H-01FFH, 0300H-04FFH).
How Sector 0 Reads a Sector
Sector 0 works the floppy disk controller through its memory mapped registers, polling the status:
| Step | What the code does |
|---|---|
| Select | 01H (drive 0, side 0) or 09H (drive 0, side 1) to the drive select latch 37E1H before every read (42B9H); the byte fetch sets or clears bit 3 of the operand at 42BAH (4294H, 429DH) |
| Seek | Sector to 37EEH, cylinder to the data register 37EFH, command 13H to 37ECH, then a wait for BUSY to go off (42BEH) |
| Read | Command 88H, then each byte is taken from 37EFH while DATA REQUEST is set, until BUSY goes off (42D5H) |
| Check | Status AND 9CH (not ready, record not found, CRC error, lost data); a failed first try is followed by one more (42B2H) |
The main register set does the loading (Register H = the record type, Register B = the bytes left in the record, Register Pair HL = the load address); the alternate set does the reading (Register D' = cylinder, Register B' = sector within the cylinder, Register Pair HL' = the buffer pointer). The side is chosen from the sector number against the sectors per track, the next cylinder from the sectors per cylinder, both taken from sector 2.
The Five Sectors
| Sector | Contents |
|---|---|
| 0 | The boot sector the ROM runs, 4200H. Byte 2 is the directory cylinder (11H). |
| 1 | A copy of sector 0, 0100H, not read during the boot. |
| 2 | The drive control table copy and the boot settings, 5200H: density and directory protection flags, surfaces, sectors per track, directory length, sectors per granule, granules per cylinder, sectors per cylinder, directory cylinder and cylinder count (bytes 03H-0BH); the time, date and logo switches and the alternate driver flag (byte 10H); the alternate driver address, the cursor blink, the cursor character, the caps switch, the default step rate and a port and value to output at boot (bytes 11H-18H). |
| 3 | 00H, 0300H: the manual gives sectors 3 and up to an alternate system driver; this diskette has none. |
| 4 | 00H, 0400H. |
Variables
Memory Outside BOOT/SYS
| Address Size | Contents |
|---|---|
| 37E1H 1 byte | Drive Select Latch Written with 01H (drive 0, side 0) or 09H (drive 0, side 1) at 42BBH before each sector read. |
| 37ECH 1 byte | Controller Command and Status FFH (double density adapter on, only for a double density diskette, 421CH), D0H (Force Interrupt, 4222H), 13H (Seek, 42CAH) and 88H (Read Sector, 42D5H) are written here; reading gives the status (bit 0 BUSY, bit 1 DATA REQUEST, bit 2 LOST DATA, bit 3 CRC ERROR, bit 4 RECORD NOT FOUND, bit 7 NOT READY). |
| 37EDH 1 byte | Controller Track Register Set to 00H at 4222H for a double density diskette. |
| 37EEH 1 byte | Controller Sector Register The sector to read, stored with the cylinder by LD (37EEH),DE at 42BEH. |
| 37EFH 1 byte | Controller Data Register The cylinder for the seek (42BEH), then each byte of the sector as it is read (42E2H). |
| 4200H-42FFH 256 bytes | Boot Sector Sector 0, where the ROM puts it and runs it. |
| 5200H-52FFH 256 bytes | Sector 2 Buffer Sector 2 of BOOT/SYS, read at 420CH; Index Register IX points here for the rest of the boot and SYS0/SYS's start-up reads its fields here. |
| 5300H-53FFH 256 bytes | Sector Buffer The directory sector with SYS0/SYS's entry (5300H flags, 5316H-5317H first segment descriptor), then each sector of SYS0/SYS. |
BOOT/SYS Data and Changed Operands
| Address Size | Contents |
|---|---|
| 4202H 1 byte | Directory Cylinder Byte 2 of the boot sector, the operand of CP 11H: 11H. The boot sector itself takes the directory cylinder from 520AH. |
| 42BAH 1 byte | Drive Select Value The operand of LD A,01H at 42B9H: 01H for side 0, 09H for side 1 (bit 3 reset at 4294H, set at 429DH). |
| 42F9H-42FEH 6 bytes | Error Text ERROR!, displayed by 427EH. |
Sector 2 (at 5200H)
| Address Size | Contents |
|---|---|
| 5200H-5202H 3 bytes | Mark DCT. |
| 5203H 1 byte | Diskette Flags 40H: bit 7 double density (tested at 4214H), bit 6 protected directory. |
| 5204H 1 byte | Surfaces 01H. |
| 5205H 1 byte | Sectors per Track 0AH, read at 4298H. |
| 5206H 1 byte | Directory Length 0AH sectors. |
| 5207H 1 byte | Sectors per Granule 05H, read at 4246H. |
| 5208H 1 byte | Granules per Cylinder 02H. |
| 5209H 1 byte | Sectors per Cylinder 0AH, read at 42A8H. |
| 520AH 1 byte | Directory Cylinder 11H, read at 4226H. |
| 520BH 1 byte | Cylinder Count 23H (35). |
| 5210H 1 byte | Boot Flags 0EH: bit 3 ask the time, bit 2 ask the date, bit 1 display the logo, bit 0 jump to an alternate system driver (read by SYS0/SYS). |
| 5211H-5212H 2 bytes | Alternate System Driver Address 0000H. |
| 5213H 1 byte | Cursor Blink 00H, a steady cursor. |
| 5214H 1 byte | Cursor Character 5FH. |
| 5215H 1 byte | Caps Switch FFH, capitals. |
| 5216H 1 byte | Default Step Rate 03H. |
| 5217H-5218H 2 bytes | Boot Port and Value Port 00H, value 00H. |
Outside Routines
| Address | Contents |
|---|---|
| 0033H | ROM: display the character in Register A (4285H). |
| 01C9H | ROM: clear the screen (4203H). |
| 4E00H | SYS0/SYS: its start-up, the transfer address of SYS0/SYS on this diskette (reached by JP (HL) at 4266H). |
Disassembly
4200H - Sector 0: Boot Sector Entry
When the computer is reset with a diskette in drive 0, the ROM reads cylinder 0, sector 0 (single density) into 4200H-42FFH and jumps to 4200H. This sector reads sector 2 of BOOT/SYS (the drive control table copy and the boot settings) into 5200H, finds the directory entry of SYS0/SYS (the first entry of sector 4 of the directory cylinder) and loads SYS0/SYS from its first segment, record by record, until the transfer record sends it to SYS0/SYS. It works the floppy disk controller directly through its memory mapped registers at 37ECH-37EFH and uses the stack the ROM left (the ROM's boot loads the Stack Pointer with 407DH).
4226H - Find SYS0/SYS in the Directory
The directory cylinder is byte 0AH of sector 2. Sector 4 of that cylinder holds the directory entry of SYS0/SYS in its first 32 bytes; the entry is read into 5300H and must describe an active system file.
4237H - Work Out Where SYS0/SYS Starts
The first segment descriptor of the entry (5316H-5317H) gives the cylinder and the granule SYS0/SYS starts at. The alternate register set becomes the reading context: Register D' the cylinder, Register B' the sector within the cylinder, Register Pair HL' the pointer into the buffer at 5300H.
4250H - Load SYS0/SYS Record by Record
SYS0/SYS is a load module: each record is a type byte, a length byte and that many bytes. Type 01H is a load block (address, then the data), type 02H the transfer address; any other type is passed over. The main register set does the loading: Register H the record type, Register B the bytes left in the record, Register Pair HL the load address.
4267H - Pass Over a Record
A record of any type other than 01H or 02H: the byte at Register L has already been taken, Register B counts the bytes left.
426FH - Copy a Load Block
Type 01H: the low byte of the load address is in Register L; the high byte follows, then the data.
427EH - Display ERROR! and Stop
Reached when a sector cannot be read in two tries or the directory entry of SYS0/SYS is not an active system file.
428CH - Fetch the Next Byte of SYS0/SYS
Returns the next byte of the file in Register A, reading the next sector into 5300H-53FFH when the buffer is used up. The reading context is in the alternate registers: Register Pair HL' the buffer pointer, Register B' the sector within the cylinder, Register D' the cylinder; Index Register IX points to sector 2 at 5200H.
42BAH is the operand of LD A,01H at 42B9H; bit 3 of the value written to 37E1H selects side 1 on a two sided drive.
The operand of LD A,01H at 42B9H.
42B2H - Read a Sector, Two Tries
Reads cylinder Register D, sector Register E into the buffer at Register Pair HL. Register Pairs BC, DE and HL are kept. On return the Z FLAG is set if the read succeeded and Register A holds the status masked with 9CH.
The operand at 42BAH is changed by RES 3,(HL) at 4294H and SET 3,(HL) at 429DH.
42F9H - Sector 0 Data
The text of the error display and the last byte of the sector.
Sector 1: A Copy of Sector 0
File offsets 0100H-01FFH, cylinder 0, sector 1. Byte for byte the same 256 bytes as sector 0. The ROM reads only sector 0 and this boot sector reads sectors 2 and 4 of the directory cylinder and SYS0/SYS, so nothing during the boot reads sector 1.
Sector 2: Drive Control Table Copy and Boot Settings (at 5200H)
File offsets 0200H-02FFH, cylinder 0, sector 2. Read into 5200H-52FFH by the boot sector (4206H-420CH), which keeps Index Register IX at 5200H; SYS0/SYS's start-up reads the same buffer. Bytes 03H-0BH are this diskette's copy of the perishable part of its drive control table (DCT+0BH to DCT+13H); bytes 10H-18H are the boot settings the SYSTEM command keeps.
Sector 3: Not Used on This Diskette
File offsets 0300H-03FFH, cylinder 0, sector 3. The manual gives sectors 3 and up of BOOT/SYS to an alternate system driver; bit 0 of byte 10H of sector 2 is clear, and the boot sector never reads this sector.
Sector 4: Not Used on This Diskette
File offsets 0400H-04FFH, cylinder 0, sector 4, the last sector of BOOT/SYS (one granule of five sectors). The boot sector never reads it.