TRS-80 DOS - LDOS 5.3.1 for the Model I - SOLE/CMD Disassembled

Page Customization

Introduction/Summary

LDOS 5.3.1 SOLE/CMD Disassembly - Making a Double Density System Diskette Boot (Model I)

The ROM of the Model I boots from a diskette whose cylinder 0 is single density: it reads sector 0 of cylinder 0 into 4200H and runs it. FORMAT/CMD with the DDEN and SYSTEM parameters makes a diskette that is double density except for a single density cylinder 0; once the system files are on it, SOLE/CMD puts on it a boot module with a double density driver, so that the diskette boots and loads SYS0/SYS from its double density cylinders. The manual gives the command as SOLE [:d], with drive 0 when :d is left out; the code of this file requires the colon and the digit and stops with Drive spec required! without them (5200H).

The file is a load module of 1181 bytes: a record of type 1FH with the text Copyright 1991 MISOSYS, Inc., All rights reserved, five load blocks for 5200H-547CH and 5500H-56D4H (1106 bytes) and the transfer address record for 5200H.

What SOLE Checks

The drive comes from the command line (5200H). Its drive code table must not have bit 3 or bit 5 of byte +03H set (an 8 inch drive has bit 5): else Drive must be 5" floppy!. @CKDRV must find the drive ready (else error 20H, Illegal drive number) and the diskette not write protected (else Drive is write protected!). @CKDRV also sets bit 7 of byte +04H of the table from the diskette's allocation table when cylinder 0 is single density and the rest double density; without it SOLE stops with Track 0 is not single density!. The messages are displayed by @LOGOT and the program ends at @ABORT; a disk error ends through @ERROR with the short message (533CH).

What SOLE Writes

Cylinder 0Contents
Sector 554FCH-55FBH: the load record header 01H FEH 00H 52H and the 252 bytes 5500H-55FBH, which load at 5200H-52FBH (5273H).
Sector 655F8H-56F7H: the header 01H D7H FCH 52H, the 213 bytes 55FCH-56D0H, which load at 52FCH-53D0H, the transfer record for 5312H (56D1H) and 35 bytes of memory after the file.
Sector 0, the boot sectorRead, changed and written back (52BEH): its LD IY,0000H at 4207H loads 421CH instead, and 4216H-4225H become LD DE,0005H / JP 423EH and a drive code table for the boot, the table of the drive given with its driver address set to 5200H and byte +04H set to drive 0 (525AH).
The allocation tableThe byte of cylinder 0 is set to FFH: granule 1 (sectors 5-9) is in use (542CH).
Directory sector 2The directory record of BOOT/SYS gets an ending record number of 7 instead of 5 and one more granule in its first extent, so sectors 5 and 6 belong to BOOT/SYS. When the ending record number is already 7 the record is left alone (52DBH).

The BOOT/SYS page shows sector 6 of the LDOS 5.3.1 system diskette: it is byte for byte the sector 6 SOLE writes. On that diskette sector 0 is not changed and sector 5 holds other bytes, so nothing reads it there.

How the Diskette Boots

The ROM reads the boot sector into 4200H and runs it in single density. With SOLE's changes it loads Index Register IY with 421CH and, at 4216H, jumps into its own loader at 423EH with cylinder 0, sector 5: the loader takes sectors 5 and 6 as a load module, puts the boot module at 5200H-53D0H and jumps to its transfer address, 5312H. The boot module (5612H, running at 5312H) reads the allocation table and the directory record of SYS0/SYS from the directory cylinder through its own driver at 5200H, works out the first sector of SYS0/SYS from its first extent, and loads SYS0/SYS record by record. Then it copies the drive code table at 421CH to drive 0's table at 4700H, sets Index Register IY to 0000H and jumps to the transfer address of SYS0/SYS. The results of the reads of the allocation table and the directory sector are not tested; a failed read of SYS0/SYS goes to the boot sector's Disk Error (4294H), a free directory record to its No System (4229H).

The driver at 5200H (5500H) reads one sector, whatever function it is given: it seeks the cylinder with the side chosen from the sector number (a sector at or above the sectors of a track is on side 1, bit 4 of byte +03H of the drive code table, bit 3 of the drive select latch at 37E1H), issues Read Sector with interrupts off, takes the bytes with a poll of the data request written out five times, and tries up to 5 times. Lost data is tried again without counting; on RECORD NOT FOUND the density is changed (55EDH): bit 6 of byte +03H is flipped, bytes +07H and +08H get the layout of the other density (09H 24H single, 11H 45H double) and the head is restored to cylinder 0. It returns the Z FLAG, or the NZ FLAG with error 03H-07H (5560H).

The Two Double Density Adapters

The density of the controller is set one of two ways, as FDUBL/CMD sets it for its TANDY and PERCOM parameters. The Tandy adapter takes it from a write of 80H (double) or A0H (single) to the sector register at 37EEH (55D1H); the Percom doubler from a command of FFH (double) or FEH (single) to the command register at 37ECH, followed by a Force Interrupt, D0H (55DDH). SOLE finds which by byte 9 of the driver named by the drive code table of the drive given: the double density driver that FDUBL/CMD installs has a header of 9 bytes, followed by CDH in its Tandy form and by C3H in its Percom form. For any byte but CDH, SOLE changes the boot module's two calls of 52D1H to 52DDH (5242H).

About This Page

Every byte of the file is shown at its file address, with DEFS rows for the bytes SOLE uses beyond its loaded bytes. The boot module, 5500H-56D0H, runs 0300H lower, at 5200H-53D0H; its headings give the run address, and its calls and jumps are linked to the row of this page that holds the target (run address + 0300H), not to SOLE's own rows at those addresses. Rows 5477H-547CH run in the boot sector at 4216H-421BH.

Memory Map

Load Blocks in File Order

The five load blocks of the file in the order LDOS loads them, after the copyright record. The transfer address is 5200H. 547DH-54FFH are not loaded.

AddressContents
5200H-52FFH256 bytes
5300H-53FFH256 bytes
5400H-547CH125 bytes
5500H-55FFH256 bytes
5600H-56D4H213 bytes

Sections of the Disassembly

AddressContents
5200HEntry: the Drive Specification and the Checks
5242HChoose the Density Routine of the Boot Module
525AHMake the Drive Code Table of the Boot
5273HWrite the Boot Module to Sectors 5 and 6
52BEHPatch the Boot Sector
52DBHGive Sectors 5 and 6 to BOOT/SYS
5305HThe End
5311HThe Disk Calls with the Drive Given
532CHVerify a Directory Sector
533CHThe Errors
5356HThe Texts
542CHMark Cylinder 0 in Use in the Allocation Table
543AHText No Code Uses
5445HThe Closing Message
5477HThe Boot Sector's New Instructions at 4216H
5500HBoot Module: the Driver, Read a Sector (Runs at 5200H)
5569HSelect the Drive and the Side (Runs at 5269H)
5589HWait While the Controller Is Busy (Runs at 5289H)
5596HSeek the Cylinder and Choose the Side (Runs at 5296H)
55D1HDensity for the Tandy Adapter (Runs at 52D1H)
55DDHDensity for the Percom Doubler (Runs at 52DDH)
55EDHChange the Density (Runs at 52EDH)
5612HBoot Module: the Loader (Runs at 5312H)
5668HLoader: the Records (Runs at 5368H)
56B0HLoader: Fetch the Next Byte (Runs at 53B0H)
56C7HRead a Sector through the Drive Code Table (Runs at 53C7H)
56D1HThe Transfer Record of the Boot Module

The Boot Module: File and Run Addresses

In the FileRuns AtContents
5500H-55FBH5200H-52FBHSector 5: the driver (5200H), the status to error number (5260H), select (5269H), wait (5289H), seek (5296H), issue a command (52C8H), the density routines (52D1H, 52DDH) and the start of the density change (52EDH).
55FCH-56D0H52FCH-53D0HSector 6: the rest of the density change, the loader (5312H, the transfer address), the records (5368H), the byte fetch (53B0H) and the sector read through the drive code table (53C7H, 53CFH).
56D1H-56D4HThe transfer record of the module: 02H 02H 12H 53H, start at 5312H.

Memory SOLE/CMD Uses

AddressContents
0060HROM: the delay, Register Pair BC counted down (the boot module, for the motor).
37E1HThe drive select latch: bits 3-0 the select line, bit 3 also the side (the boot module).
37ECH-37EFHThe floppy disk controller: command and status, track, sector, data registers (the boot module).
402DH, 4030H, 4409H@EXIT, @ABORT and @ERROR, the ends of the program.
4200H-42FFHAt boot: the boot sector, whose No System (4229H), Disk Error (4294H) and loader (423EH) the boot module and the changed sector use.
4467H, 447BH@DSPLY and @LOGOT, the banner and the messages.
44B8H@CKDRV, the check of the drive.
4700H-474FHDCT$, the drive code tables (GETDCT 478FH); at boot the module copies its table to 4700H-4709H.
4763H, 4768H, 4772H, 4777HWRSECT, WRPROT, VERSEC and RDSECT, the disk primitives SOLE calls through 5311H-5329H.
4B45HRDSSEC, the read of a directory sector.
5100H-51FFHAt boot: the buffer of the module's loader (allocation table, directory sector 4, the sectors of SYS0/SYS).
5700H-57FFHSOLE's buffer for the boot sector, the allocation table and directory sector 2.

Variables

The entry points of SOLE/CMD, then the data of the file and the bytes beyond it that SOLE uses, the operands it changes, and the cells outside the file that it uses, by address.

Entry Points

AddressRuns AtContents
5200HThe start of SOLE/CMD, the transfer address of the file.
5311HWrite a sector of the drive given (WRSECT); 5318H with the deleted data mark (WRPROT), 531FH read (RDSECT), 5326H verify (VERSEC).
532CHVerify a directory sector: the Z FLAG when it reads back with the deleted data mark.
533CHA disk error as a short message through @ERROR; 5341H, 5345H, 5349H, 534DH the four messages through @LOGOT.
542CHMark cylinder 0 in use in the allocation table.
5500H5200HThe boot module's driver: read a sector.
5569H5269HSelect the drive and the side.
5589H5289HWait while the controller is busy.
5596H5296HSeek and choose the side; 55C8H (52C8H) issues a command.
55D1H52D1HThe density for the Tandy adapter.
55DDH52DDHThe density for the Percom doubler.
55EDH52EDHChange the density.
5612H5312HThe boot module's loader, its transfer address.
56B0H53B0HFetch the next byte of SYS0/SYS.
56C7H53C7HRead a sector through the drive code table.

Data in the File and Beyond It

Address
Size
Contents
5356H-538CH
55 bytes
DEFM "SOLE - Version 5.3.1 - Double Density BOOTing - Phase 2"
5356H-538CH: the first line of the banner, displayed by 5204H.
538DH-538DH
1 byte
DEFB 0AH
538DH: 0AH, a line feed: the copyright goes on the next line in the same text.
538EH-53C2H
53 bytes
DEFM "Copyright (C) 1991 MISOSYS, Inc., All rights reserved"
538EH-53C2H: the second line of the banner, the copyright.
53C3H-53C4H
2 bytes
DEFB 0AH, 0DH
53C3H-53C4H: a line feed, then 0DH, the end of the banner.
53C5H-53D9H
21 bytes
DEFM "Drive spec required!" / DEFB 0DH
53C5H-53D9H: the message of 534DH, for a command line without :d, ended by 0DH.
53DAH-53F8H
31 bytes
DEFM "Track 0 is not single density!" / DEFB 0DH
53DAH-53F8H: the message of 5341H, for a diskette not formatted with a single density cylinder 0 and double density elsewhere.
53F9H-5412H
26 bytes
DEFM "Drive is write protected!" / DEFB 0DH
53F9H-5412H: the message of 5345H, for a write protected diskette.
5413H-542BH
25 bytes
DEFM "Drive must be 5" / DEFB 22H / DEFM " floppy!" / DEFB 0DH
5413H-542BH: the message of 5349H, Drive must be 5" floppy!, for a drive whose code table has bit 3 or bit 5 of +03H set.
543AH-5444H
11 bytes
DEFM " complete. "
543AH-5444H: the text complete. with a space before and after it. No code of the file reads it.
5445H-5476H
50 bytes
DEFM "Your double density SYSTEM diskette can now BOOT." / DEFB 0DH
5445H-5476H: the closing message, ended by 0DH.
547DH-5486H
10 bytes
DEFS 10
547DH-5486H: not in the file. The copy of the drive code table made at 525AH-5270H: +00H C3H, +01H-+02H 5200H (5282H), +03H as the drive's, +04H with bits 6, 4 and 0 set (526AH), +05H 00H (5270H), +06H-+09H as the drive's. It goes into the boot sector at 421CH-4225H.
5487H-54FBH
117 bytes
DEFS 117
5487H-54FBH: not in the file and not used by SOLE.
54FCH-54FFH
4 bytes
DEFS 4
54FCH-54FFH: not in the file. The header of sector 5's load record, built by 5286H-5290H: 01H (a load block), FEH (the length), 00H 52H (load at 5200H). Written with 5500H-55FBH as sector 5.
56D1H-56D4H
4 bytes
DEFB 02H, 02H / DEFW 5312H
56D1H-56D4H: record type 02H (the transfer address), length 02H, then 5312H, the run address of the loader (5612H in the file). The boot sector's loader jumps there.
56D5H-56F7H
35 bytes
DEFS 35
56D5H-56F7H: not in the file. The rest of the 256 bytes written as sector 6 (55F8H-56F7H): whatever memory holds there. The boot module does not use them.
5700H-57FFH
256 bytes
DEFS 256
5700H-57FFH: not in the file. The buffer of the boot sector (5273H-52D5H), then of the allocation table and of directory sector 2 (52DBH-5302H).

Operands and Bytes Changed While It Runs

Address
Size
Contents
5327H
1 byte
The operand of LD A,00H at 5326H: the drive given (521BH), read by 5311H, 5318H and 531FH.
5504H-5505H
2 bytes
The operand of CALL 52D1H at 5503H in the boot module: 52DDH when 5254H finds no CDH at byte 9 of the drive's driver.
5608H-5609H
2 bytes
The operand of CALL 52D1H at 5607H in the boot module: 52DDH the same way (5257H).
5590H
1 byte
The operand of LD A,01H at 558FH (run 528FH): the drive select latch value, stored as 5290H by 5579H (run 5279H); 01H in the file.
56BFH
1 byte
The operand of SUB 00H at 56BEH (run 53BEH): the sectors of a cylinder, stored as 53BFH by 5639H (run 5339H) at boot.
55F8H-55FBH
4 bytes
The last 4 bytes of sector 5's part of the module; after sector 5 is written, 52A5H-52B3H put the header 01H D7H FCH 52H of sector 6 over them.

Cells Outside the File That SOLE/CMD Uses

Address
Size
Contents
37E1H
1 byte
The drive select latch: bits 3-0 the select line, bit 3 also side 1 (from bit 4 of +03H of the drive code table).
37ECH
1 byte
The controller's command (write) and status (read): bit 0 BUSY, bit 1 DATA REQUEST, bit 2 LOST DATA, bit 3 CRC ERROR, bit 4 RECORD NOT FOUND, bits 6-5 the record type, bit 7 NOT READY. Commands used: 18H Seek, 08H Restore, 88H Read Sector, D0H Force Interrupt, and FEH or FFH for the Percom doubler's density.
37EDH
1 byte
The controller's track register: the cylinder the head is on.
37EEH
1 byte
The controller's sector register: the sector, or 80H or A0H for the Tandy adapter's density.
37EFH
1 byte
The controller's data register: the cylinder of a Seek, then each byte read.
4207H-420AH
4 bytes
The boot sector's LD IY,0000H, whose operand (4209H-420AH) SOLE sets to 421CH.
4216H-421BH
6 bytes
In the boot sector after SOLE: LD DE,0005H / JP 423EH (5477H).
421CH-4225H
10 bytes
In the boot sector after SOLE: the drive code table of the boot, Index Register IY while the module runs.
4700H-4709H
10 bytes
Drive 0's drive code table: the module copies the table at 421CH here before it starts SYS0/SYS.
5100H-51FFH
256 bytes
At boot: the allocation table (51CDH, bit 5 two sides), then directory sector 4 (5100H the attribute byte, 5116H-5117H the first extent of SYS0/SYS), then each sector of SYS0/SYS.
IY +01H-+09HThe drive code table: +01H-+02H the driver, +03H bit 3 and bit 5 (SOLE refuses the drive), bit 4 the side, bit 6 double density, bits 1-0 the step rate; +04H bit 7 cylinder 0 single density, bits 3-0 the select line; +05H the cylinder the head is on; +07H and +08H the layout; +09H the directory cylinder.

Disassembly

5200H - Entry: the Drive Specification and the Checks

LDOS Ready loads SOLE/CMD at 5200H-547CH and 5500H-56D4H and jumps to 5200H, the transfer address, with Register Pair HL pointing at the rest of the command line. SOLE shows its banner, takes the drive from the command line (a colon and a digit 0-7 must follow the spaces), and refuses the drive unless it is a 5 inch floppy drive that is ready, holds a diskette that is not write protected and whose cylinder 0 is single density while the rest of the diskette is double density (bit 7 of byte +04H of the drive code table, which @CKDRV sets from the allocation table).

5200
PUSH HL E5
Save Register Pair HL, the pointer LDOS Ready gives the program to the rest of the command line after the word SOLE, to the stack while the banner is shown.
5201
LD HL,5356H 21 56 53
Point Register Pair HL to 5356H, the banner text: the name and version of SOLE and the copyright, two lines ended by 0DH.
5204
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (5356H) up to its 0DH.
5207
POP HL E1
Restore Register Pair HL from the stack: the pointer to the rest of the command line.
5208
LD A,(HL) 7E
Fetch the next character of the command line at Register Pair HL into Register A.
5209
INC HL 23
INCrement Register Pair HL past that character, to the one after it.
520A
CP 20H FE 20
Compare Register A (the character) against 20H, a space.
520C
If the Z FLAG is set (Register A was a space), JUMP back to 5208H to take the next character: spaces before the drive are skipped.
520E
CP 3AH FE 3A
Compare Register A (the first character that is not a space) against 3AH, a colon.
5210
If the NZ FLAG is set (no colon: the drive is not given), JUMP to 534DH to display Drive spec required! and end at @ABORT. The drive cannot be left out.
5213
LD A,(HL) 7E
Fetch the character after the colon at Register Pair HL into Register A: the drive digit.
5214
SUB 30H D6 30
SUBtract 30H from Register A, the character 0: Register A = the drive number when the character was a digit.
5216
CP 08H FE 08
Compare Register A (the drive number) against 08H: the CARRY FLAG is set for drives 0-7.
5218
If the NC FLAG is set (Register A is 8 or more, or the character was below 0), JUMP to 534DH to display Drive spec required! and end.
521B
LD (5327H),A 32 27 53
Store Register A (the drive number, 0-7) at 5327H, the operand of LD A,00H at 5326H, from which every disk call of SOLE (5311H-5329H) takes the drive.
521E
LD C,A 4F
Copy Register A (the drive number) into Register C, the drive for GETDCT and @CKDRV.
521F
GOSUB to 478FH, GETDCT, to point Index Register IY at the drive code table of drive Register C (4700H + drive x 10).
5222
BIT 3,(IY+03H) FD CB 03 5E
Test bit 3 of byte +03H of the drive code table at Index Register IY. SOLE refuses a drive whose table has this bit set.
5226
If the NZ FLAG is set (bit 3 of +03H is set), JUMP to 5349H to display Drive must be 5" floppy! and end.
5229
BIT 5,(IY+03H) FD CB 03 6E
Test bit 5 of byte +03H of the drive code table at Index Register IY, set for an 8 inch drive.
522D
If the NZ FLAG is set (an 8 inch drive), JUMP to 5349H to display Drive must be 5" floppy! and end.
5230
GOSUB to 44B8H, @CKDRV, to check drive Register C: it must be present, its diskette must turn and its allocation table must read. @CKDRV brings bytes +04H and +06H of the drive code table into line with the diskette and returns the Z FLAG when the drive is ready, with the CARRY FLAG when the diskette is write protected.
5233
LD A,20H 3E 20
Load Register A with 20H, error 32, Illegal drive number, for the case below. LD does not change the flags of @CKDRV.
5235
If the NZ FLAG is set (@CKDRV found the drive not ready), JUMP to 533CH to give error 20H in Register A as a short message and end.
5238
If the CARRY FLAG is set (the diskette is write protected), JUMP to 5345H to display Drive is write protected! and end.
523B
BIT 7,(IY+04H) FD CB 04 7E
Test bit 7 of byte +04H of the drive code table at Index Register IY: set by @CKDRV when bit 4 of the configuration byte of the diskette's allocation table says that cylinder 0 is single density while the rest of the diskette is double density.
523F
If the Z FLAG is set (the diskette is not formatted that way), JUMP to 5341H to display Track 0 is not single density! and end.

5242H - Choose the Density Routine of the Boot Module

The boot module must set the density of the controller the way the double density adapter of this computer wants it. SOLE looks at the driver the drive code table names (bytes +01H-+02H) and takes byte 9 of it. The double density driver of LDOS that FDUBL/CMD installs starts with a header of 9 bytes; in the module built for the Tandy adapter the byte after the header is CDH, in the module built for the Percom doubler it is C3H. When the byte is CDH the boot module keeps its routine at 52D1H (55D1H in the file), which sets the density through the controller's sector register; otherwise both calls of that routine are changed to 52DDH (55DDH in the file), which sets it through the command register.

5242
LD L,(IY+01H) FD 6E 01
Fetch byte +01H of the drive code table at Index Register IY into Register L: the low byte of the address of the drive's driver.
5245
LD H,(IY+02H) FD 66 02
Fetch byte +02H of the drive code table at Index Register IY into Register H: Register Pair HL = the address of the drive's driver.
5248
LD DE,0009H 11 09 00
Load Register Pair DE with 0009H, the offset of the first byte after the driver's header of 9 bytes.
524B
ADD HL,DE 19
ADD Register Pair DE (0009H) to Register Pair HL (the driver): Register Pair HL = the address of byte 9 of the driver.
524C
LD A,(HL) 7E
Fetch byte 9 of the driver at Register Pair HL into Register A.
524D
CP CDH FE CD
Compare Register A (byte 9 of the driver) against CDH, the first byte of a CALL, which the Tandy adapter's module has there.
524F
If the Z FLAG is set (CDH), JUMP to 525AH: the boot module keeps its calls of 52D1H, the routine for the Tandy adapter.
5251
LD HL,52DDH 21 DD 52
Load Register Pair HL with 52DDH, the run address of the boot module's density routine for the Percom doubler (55DDH in the file).
5254
LD (5504H),HL 22 04 55
Store Register Pair HL (52DDH) at 5504H-5505H, the operand of the CALL 52D1H at 5503H in the boot module, which now calls 52DDH.
5257
LD (5608H),HL 22 08 56
Store Register Pair HL (52DDH) at 5608H-5609H, the operand of the CALL 52D1H at 5607H in the boot module, which now calls 52DDH.

525AH - Make the Drive Code Table of the Boot

The boot module needs a drive code table for drive 0 that names its own driver. SOLE copies the 10 bytes of the table of the drive given to 547DH-5486H, just after the end of its loaded bytes, and changes them: byte +01H-+02H becomes 5200H (the module's driver), byte +04H keeps bits 7-4 and gets bits 6, 4 and 0 set (OR 51H): bit 7 cylinder 0 single density and bit 5 two sides as the drive's, bit 6 the controller can do double density, bit 4 no index test, and select line 0, and byte +05H, the cylinder under the head, becomes 00H. 5477H-5486H, 16 bytes, later go into the boot sector at 4216H-4225H.

525A
PUSH IY FD E5
Save Index Register IY (the drive code table of the drive given) to the stack.
525C
POP HL E1
Restore the value into Register Pair HL: Register Pair HL = the drive code table, the source of the copy.
525D
LD DE,547DH 11 7D 54
Point Register Pair DE to 547DH, the 10 bytes after the end of SOLE's first load block (547CH), where the copy goes.
5260
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, the 10 bytes of a drive code table.
5263
LDIR ED B0
Copy the 10 bytes from Register Pair HL (the drive code table) to Register Pair DE (547DH-5486H), counting Register Pair BC down to zero.
5265
LD A,(5481H) 3A 81 54
Fetch byte +04H of the copy at 5481H into Register A: bit 7 cylinder 0 single density, bit 6 the controller can do double density, bit 5 two sides, bit 4 no index test, bits 3-0 the select line.
5268
AND F0H E6 F0
Keep bits 7-4 of Register A (AND F0H): the select line bits 3-0 are cleared.
526A
OR 51H F6 51
OR Register A with 51H: bit 6 (the controller can do double density), bit 4 and bit 0 (the select line of drive 0) are set. The diskette will boot as drive 0.
526C
LD (5481H),A 32 81 54
Store Register A (the new byte +04H) back at 5481H, byte +04H of the copy.
526F
XOR A AF
Clear Register A to 00H (XOR A), the value for byte +05H of the copy.
5270
LD (5482H),A 32 82 54
Store Register A (00H) at 5482H, byte +05H of the copy: the head is taken to be on cylinder 0.

5273H - Write the Boot Module to Sectors 5 and 6

SOLE reads the boot sector (cylinder 0, sector 0) of the diskette into 5700H, sets the copy's driver address to 5200H, and writes the boot module as a load module of two sectors. Sector 5 is 54FCH-55FBH: the load record header 01H FEH 00H 52H (load 252 bytes at 5200H) built at 54FCH-54FFH, then the 252 bytes 5500H-55FBH. Sector 6 is 55F8H-56F7H: the header 01H D7H FCH 52H (load 213 bytes at 52FCH) built over 55F8H-55FBH once sector 5 is written, the 213 bytes 55FCH-56D0H, the transfer record 02H 02H 12H 53H at 56D1H-56D4H (start at 5312H) and the 35 bytes 56D5H-56F7H that follow SOLE's file in memory. The module runs 0300H lower than SOLE keeps it: 5500H-56D0H run at 5200H-53D0H.

5273
LD HL,5700H 21 00 57
Point Register Pair HL to 5700H, the buffer for the boot sector.
5276
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D = cylinder 0, Register E = sector 0, the boot sector.
5279
GOSUB to 531FH to read cylinder Register D, sector Register E of the drive given into the buffer at Register Pair HL (RDSECT): the Z FLAG on success, else the error number in Register A.
527C
If the NZ FLAG is set (the boot sector could not be read), JUMP to 533CH to give the error in Register A as a short message and end.
527F
LD HL,5200H 21 00 52
Load Register Pair HL with 5200H, the run address of the boot module's driver (5500H in the file).
5282
LD (547EH),HL 22 7E 54
Store Register Pair HL (5200H) at 547EH-547FH, bytes +01H-+02H of the copy of the drive code table: its JP goes to the module's driver.
5285
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = 5200H, the load address of sector 5's record.
5286
LD HL,54FFH 21 FF 54
Point Register Pair HL to 54FFH, the last byte of the record header before 5500H.
5289
LD (HL),D 72
Store Register D (52H, the high byte of the load address) at Register Pair HL, 54FFH.
528A
DEC HL 2B
DECrement Register Pair HL to 54FEH, the low byte of the load address.
528B
LD (HL),E 73
Store Register E (00H, the low byte of the load address) at Register Pair HL, 54FEH.
528C
DEC HL 2B
DECrement Register Pair HL to 54FDH, the length byte of the record.
528D
LD (HL),FEH 36 FE
Store FEH at Register Pair HL (54FDH): the record's length byte, the load address and 252 bytes.
528F
DEC HL 2B
DECrement Register Pair HL to 54FCH, the type byte of the record.
5290
LD (HL),01H 36 01
Store 01H at Register Pair HL (54FCH): the record type, a load block.
5292
PUSH DE D5
Save Register Pair DE (5200H, the load address of sector 5's record) to the stack.
5293
LD DE,0005H 11 05 00
Load Register Pair DE with 0005H: Register D = cylinder 0, Register E = sector 5.
5296
GOSUB to 5311H to write the sector at Register Pair HL (54FCH-55FBH) to cylinder Register D, sector Register E of the drive given (WRSECT): the Z FLAG on success.
5299
POP DE D1
Restore Register Pair DE (5200H) from the stack.
529A
If the NZ FLAG is set (the write failed), JUMP to 533CH to give the error in Register A as a short message and end.
529D
INC H 24
INCrement Register H: Register Pair HL = 55FCH, the first byte of sector 6's part of the module.
529E
PUSH HL E5
Save Register Pair HL (55FCH, the start of sector 6's part) to the stack.
529F
LD HL,00FCH 21 FC 00
Load Register Pair HL with 00FCH, the 252 bytes of sector 5's record.
52A2
ADD HL,DE 19
ADD Register Pair DE (5200H) to Register Pair HL (00FCH): Register Pair HL = 52FCH, the load address of sector 6's record.
52A3
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = 52FCH.
52A4
POP HL E1
Restore Register Pair HL (55FCH) from the stack.
52A5
DEC HL 2B
DECrement Register Pair HL to 55FBH, the last byte of the header that goes before 55FCH.
52A6
LD (HL),D 72
Store Register D (52H, the high byte of 52FCH) at Register Pair HL, 55FBH. Sector 5 is already written, so these 4 bytes of the module (55F8H-55FBH) are no longer needed in memory.
52A7
DEC HL 2B
DECrement Register Pair HL to 55FAH, the low byte of the load address.
52A8
LD (HL),E 73
Store Register E (FCH, the low byte of 52FCH) at Register Pair HL, 55FAH.
52A9
DEC HL 2B
DECrement Register Pair HL to 55F9H, the length byte of the record.
52AA
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = 55F9H, Register Pair HL = 52FCH.
52AB
LD HL,00D5H 21 D5 00
Load Register Pair HL with 00D5H, the 213 bytes 55FCH-56D0H of sector 6's record.
52AE
INC HL 23
INCrement Register Pair HL to 00D6H, counting the low byte of the load address.
52AF
INC HL 23
INCrement Register Pair HL to 00D7H, the length byte: the 2 bytes of the load address and the 213 bytes.
52B0
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = 55F9H, Register E = D7H.
52B1
LD (HL),E 73
Store Register E (D7H, the length byte) at Register Pair HL, 55F9H.
52B2
DEC HL 2B
DECrement Register Pair HL to 55F8H, the type byte of sector 6's record.
52B3
LD (HL),01H 36 01
Store 01H at Register Pair HL (55F8H): the record type, a load block. Register Pair HL = 55F8H, the start of sector 6.
52B5
LD DE,0006H 11 06 00
Load Register Pair DE with 0006H: Register D = cylinder 0, Register E = sector 6.
52B8
GOSUB to 5311H to write the sector at Register Pair HL (55F8H-56F7H) to cylinder Register D, sector Register E (WRSECT): the Z FLAG on success.
52BB
If the NZ FLAG is set (the write failed), JUMP to 533CH to give the error in Register A as a short message and end.

52BEH - Patch the Boot Sector

The boot sector read at 5273H (now at 5700H) is changed in two places and written back. Its LD IY,0000H at 4207H becomes LD IY,421CH (5709H-570AH, the operand), and 4216H-4225H (5716H-5725H) become LD DE,0005H / JP 423EH and the new drive code table. When the ROM runs the boot sector, it starts its loader at 423EH with cylinder 0 sector 5 instead of reading the directory record of SYS0/SYS, so it loads the boot module and starts it at 5312H with Index Register IY at the table at 421CH.

52BE
LD HL,421CH 21 1C 42
Load Register Pair HL with 421CH, the address in the boot sector of the new drive code table.
52C1
LD (5709H),HL 22 09 57
Store Register Pair HL (421CH) at 5709H-570AH, the operand of the boot sector's LD IY,0000H at 4207H (byte 09H of the sector): the boot sector will load Index Register IY with 421CH.
52C4
LD HL,5477H 21 77 54
Point Register Pair HL to 5477H, the 16 bytes LD DE,0005H / JP 423EH (5477H-547CH) and the drive code table (547DH-5486H).
52C7
LD DE,5716H 11 16 57
Point Register Pair DE to 5716H, byte 16H of the boot sector in the buffer, which runs at 4216H.
52CA
LD BC,0010H 01 10 00
Load Register Pair BC with 0010H, the 16 bytes to copy.
52CD
LDIR ED B0
Copy the 16 bytes from Register Pair HL (5477H) to Register Pair DE (5716H-5725H, the boot sector's 4216H-4225H), counting Register Pair BC down to zero.
52CF
LD HL,5700H 21 00 57
Point Register Pair HL to 5700H, the changed boot sector.
52D2
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D = cylinder 0, Register E = sector 0.
52D5
GOSUB to 5311H to write the sector at Register Pair HL (5700H) to cylinder Register D, sector Register E (WRSECT): the Z FLAG on success.
52D8
If the NZ FLAG is set (the write failed), JUMP to 533CH to give the error in Register A as a short message and end.

52DBH - Give Sectors 5 and 6 to BOOT/SYS

Sectors 5-9 of cylinder 0 are granule 1 of cylinder 0. SOLE marks both granules of cylinder 0 in use in the allocation table (542CH), then in the directory record of BOOT/SYS (the first record of directory sector 2) raises the ending record number from 5 to 7 and the granules of the first extent by one, so that sectors 5 and 6 belong to BOOT/SYS. When the ending record number is already 7, SOLE was run on the diskette before and the record is left as it is.

52DB
LD HL,5700H 21 00 57
Point Register Pair HL to 5700H, the buffer for the allocation table and the directory sector.
52DE
GOSUB to 542CH to read the allocation table of the drive given into the buffer at Register Pair HL, set the byte of cylinder 0 to FFH and write it back: the Z FLAG on success. Register D comes back as the directory cylinder.
52E1
LD E,02H 1E 02
Load Register E with 02H, sector 2 of the directory cylinder: the first sector of directory records, whose first record (5700H-571FH) is the record of BOOT/SYS.
52E3
If the Z FLAG is set (the allocation table was written), GOSUB to 4B45H, RDSSEC, to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL: the Z FLAG when the sector carries the deleted data mark of a directory sector.
52E6
If the NZ FLAG is set (a read or write failed, or the sector is not a directory sector), JUMP to 533CH to give the error number in Register A as a short message and end (after a failed RDSSEC, Register A holds the read's error number less 6).
52E9
LD A,(5714H) 3A 14 57
Fetch byte +14H of the record of BOOT/SYS at 5714H into Register A: the low byte of the ending record number of the file (05H, sectors 0-4 of cylinder 0).
52EC
CP 07H FE 07
Compare Register A (the ending record number) against 07H.
52EE
If the Z FLAG is set (07H: SOLE was run on this diskette before), JUMP to 5305H to display the closing message.
52F0
INC A 3C
INCrement Register A (the ending record number).
52F1
INC A 3C
INCrement Register A again: two more records, the sectors 5 and 6 of the boot module.
52F2
LD (5714H),A 32 14 57
Store Register A (the new ending record number) at 5714H, byte +14H of the record of BOOT/SYS.
52F5
LD A,(5717H) 3A 17 57
Fetch byte +17H of the record at 5717H into Register A: the granule byte of the first extent (bits 7-5 the first granule, bits 4-0 the granules less one).
52F8
INC A 3C
INCrement Register A: one granule more, granule 1 of cylinder 0 (sectors 5-9).
52F9
LD (5717H),A 32 17 57
Store Register A (the new granule byte) at 5717H.
52FC
GOSUB to 5318H to write the directory sector at Register Pair HL (5700H) back to cylinder Register D, sector Register E with the deleted data mark (WRPROT): the Z FLAG on success.
52FF
If the Z FLAG is set (written), GOSUB to 532CH to verify the sector: the Z FLAG when it reads back as a directory sector.
5302
If the NZ FLAG is set (the write or the verify failed), JUMP to 533CH to give the error in Register A as a short message and end.

5305H - The End

The closing message, and the end of the program through @EXIT.

5305
LD HL,5445H 21 45 54
Point Register Pair HL to 5445H, the text Your double density SYSTEM diskette can now BOOT. ended by 0DH.
5308
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (5445H).
530B
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the return code of the program: no error.
530E
JUMP to 402DH, @EXIT, back to LDOS Ready with Register Pair HL = 0000H.

5311H - The Disk Calls with the Drive Given

Each entry loads Register C with the drive taken from the command line and jumps to a disk primitive of SYS0/SYS, which calls the drive's driver through its drive code table with Register D = the cylinder, Register E = the sector and Register Pair HL = the buffer. The drive number is kept in the operand of LD A,00H at 5326H (stored by 521BH).

5311
LD A,(5327H) 3A 27 53
Fetch the drive number from 5327H (the operand of LD A,00H at 5326H) into Register A.
5314
LD C,A 4F
Copy Register A (the drive number) into Register C, the drive for the disk primitive.
5315
JUMP to 4763H, WRSECT: write the sector at Register Pair HL to cylinder Register D, sector Register E of drive Register C. It returns to SOLE's caller with the Z FLAG on success, else the error number in Register A.
5318
LD A,(5327H) 3A 27 53
Fetch the drive number from 5327H (the operand of LD A,00H at 5326H) into Register A.
531B
LD C,A 4F
Copy Register A (the drive number) into Register C, the drive for the disk primitive.
531C
JUMP to 4768H, WRPROT: write the sector at Register Pair HL with the deleted data mark of a directory sector to cylinder Register D, sector Register E of drive Register C; the Z FLAG on success.
531F
LD A,(5327H) 3A 27 53
Fetch the drive number from 5327H (the operand of LD A,00H at 5326H) into Register A.
5322
LD C,A 4F
Copy Register A (the drive number) into Register C, the drive for the disk primitive.
5323
JUMP to 4777H, RDSECT: read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL; the Z FLAG on success, else the error number in Register A.
5326
LD A,00H 3E 00
Load Register A with the drive number: the operand 5327H is 00H in the file and holds the drive after 521BH.
5328
LD C,A 4F
Copy Register A (the drive number) into Register C, the drive for the disk primitive.
5329
JUMP to 4772H, VERSEC: read cylinder Register D, sector Register E of drive Register C without storing the bytes. A sector with the deleted data mark returns error 06H in Register A with the NZ FLAG.

532CH - Verify a Directory Sector

A directory sector must read back with the deleted data mark: VERSEC then returns error 06H, which counts as success here (the Z FLAG and Register A = 00H). Any other error comes back with the NZ FLAG and its number in Register A. A sector that reads back without the mark gives the NZ FLAG with Register A = 00H.

532C
GOSUB to 5326H to verify cylinder Register D, sector Register E of the drive given (VERSEC).
532F
If the Z FLAG is set (the sector read back with a normal data mark), JUMP to 5337H to return the NZ FLAG.
5331
SUB 06H D6 06
SUBtract 06H from Register A (the error number of VERSEC): 00H with the Z FLAG for error 06H, the deleted data mark.
5333
RET Z C8
RETurn with the Z FLAG and Register A = 00H if the sector read back as a directory sector.
5334
ADD A,06H C6 06
ADD 06H to Register A: Register A = the error number of VERSEC again, with the NZ FLAG (it is not 00H).
5336
RET C9
RETurn with the NZ FLAG and the error number in Register A.
5337
OR 01H F6 01
OR Register A (00H, from VERSEC) with 01H: the NZ FLAG is set.
5339
LD A,00H 3E 00
Load Register A with 00H, error 0: the caller ends at 533CH with the short message of error 0. LD does not change the NZ FLAG.
533B
RET C9
RETurn with the NZ FLAG and Register A = 00H.

533CH - The Errors

533CH gives a disk error through @ERROR as a short message and ends the program. 5341H-534DH are four entries into one display: each is the LD HL of a message, and the entries before it skip it as the operand of LD IX (the bytes DD 21). The message is displayed and logged by @LOGOT and the program ends at @ABORT.

533C
OR 40H F6 40
OR Register A (the error number) with 40H: bit 6 asks @ERROR for the short message, the text alone; bit 7 stays clear, so the program ends at @ABORT after it.
533E
JUMP to 4409H, @ERROR, to display the message of the error number in Register A and end at @ABORT (4030H).
5341
LD HL,53DAH 21 DA 53
Point Register Pair HL to 53DAH, the text Track 0 is not single density! (from 523FH).
5344
LD IX,53F9H DD 21 F9 53
Load Index Register IX with 53F9H. Entered at 5344H the instruction only steps over the bytes 21H F9H 53H; entered at 5345H (from 5238H) they are LD HL,53F9H.
5348
LD IX,5413H DD 21 13 54
Load Index Register IX with 5413H. Entered at 5348H the instruction only steps over the bytes 21H 13H 54H; entered at 5349H (from 5226H and 522DH) they are LD HL,5413H.
534C
LD IX,53C5H DD 21 C5 53
Load Index Register IX with 53C5H. Entered at 534CH the instruction only steps over the bytes 21H C5H 53H; entered at 534DH (from 5210H and 5218H) they are LD HL,53C5H.
5350
GOSUB to 447BH, @LOGOT, to display the message at Register Pair HL and send it to the job log. Register Pair HL = 53DAH, 53F9H, 5413H or 53C5H by the entry taken.
5353
JUMP to 4030H, @ABORT: back to LDOS Ready after an error.

5356H - The Texts

The banner and the four messages of 5341H-534DH. 0AH moves the cursor to the next line without ending the text; 0DH ends it.

5356-538C
DEFM "SOLE - Version 5.3.1 - Double Density BOOTing - Phase 2" 53 4F 4C 45 20 2D 20 56 65 72 73 69 6F 6E 20 35 2E 33 2E 31 20 2D 20 44 6F 75 62 6C 65 20 44 65 6E 73 69 74 79 20 42 4F 4F 54 69 6E 67 20 2D 20 50 68 61 73 65 20 32
5356H-538CH: the first line of the banner, displayed by 5204H.
538D
DEFB 0AH 0A
538DH: 0AH, a line feed: the copyright goes on the next line in the same text.
538E-53C2
DEFM "Copyright (C) 1991 MISOSYS, Inc., All rights reserved" 43 6F 70 79 72 69 67 68 74 20 28 43 29 20 31 39 39 31 20 4D 49 53 4F 53 59 53 2C 20 49 6E 63 2E 2C 20 41 6C 6C 20 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64
538EH-53C2H: the second line of the banner, the copyright.
53C3-53C4
DEFB 0AH, 0DH 0A 0D
53C3H-53C4H: a line feed, then 0DH, the end of the banner.
53C5-53D9
DEFM "Drive spec required!" / DEFB 0DH 44 72 69 76 65 20 73 70 65 63 20 72 65 71 75 69 72 65 64 21 0D
53C5H-53D9H: the message of 534DH, for a command line without :d, ended by 0DH.
53DA-53F8
DEFM "Track 0 is not single density!" / DEFB 0DH 54 72 61 63 6B 20 30 20 69 73 20 6E 6F 74 20 73 69 6E 67 6C 65 20 64 65 6E 73 69 74 79 21 0D
53DAH-53F8H: the message of 5341H, for a diskette not formatted with a single density cylinder 0 and double density elsewhere.
53F9-5412
DEFM "Drive is write protected!" / DEFB 0DH 44 72 69 76 65 20 69 73 20 77 72 69 74 65 20 70 72 6F 74 65 63 74 65 64 21 0D
53F9H-5412H: the message of 5345H, for a write protected diskette.
5413-542B
DEFM "Drive must be 5" / DEFB 22H / DEFM " floppy!" / DEFB 0DH 44 72 69 76 65 20 6D 75 73 74 20 62 65 20 35 22 20 66 6C 6F 70 70 79 21 0D
5413H-542BH: the message of 5349H, Drive must be 5" floppy!, for a drive whose code table has bit 3 or bit 5 of +03H set.

542CH - Mark Cylinder 0 in Use in the Allocation Table

Reads the granule allocation table (sector 0 of the directory cylinder) of the drive given into the buffer at Register Pair HL (5700H) and sets its first byte, the byte of cylinder 0, to FFH: both granules of cylinder 0 are in use, so no file can be given granule 1 (sectors 5-9), where the boot module now is. Then the table is written back as a directory sector.

542C
LD D,(IY+09H) FD 56 09
Fetch byte +09H of the drive code table at Index Register IY into Register D: the directory cylinder.
542F
LD E,00H 1E 00
Load Register E with 00H, sector 0 of the directory cylinder: the granule allocation table.
5431
GOSUB to 4B45H, RDSSEC, to read cylinder Register D, sector Register E of drive Register C into the buffer at Register Pair HL (5700H): the Z FLAG and Register A = 00H when it is a directory sector, else the NZ FLAG with the read's error number less 6 in Register A.
5434
LD (HL),FFH 36 FF
Store FFH at Register Pair HL (5700H), byte 00H of the allocation table, the byte of cylinder 0: both of its granules are in use. LD does not change the flags of RDSSEC.
5436
If the Z FLAG is set (the table was read), GOSUB to 5318H to write it back to cylinder Register D, sector Register E with the deleted data mark (WRPROT).
5439
RET C9
RETurn with the Z FLAG on success, else the NZ FLAG and an error number in Register A.

543AH - Text No Code Uses

Eleven bytes of text between the routine and the closing message. No instruction of SOLE/CMD addresses them.

543A-5444
DEFM " complete. " 20 63 6F 6D 70 6C 65 74 65 2E 20
543AH-5444H: the text complete. with a space before and after it. No code of the file reads it.

5445H - The Closing Message

Displayed by 5305H when the boot module is written.

5445-5476
DEFM "Your double density SYSTEM diskette can now BOOT." / DEFB 0DH 59 6F 75 72 20 64 6F 75 62 6C 65 20 64 65 6E 73 69 74 79 20 53 59 53 54 45 4D 20 64 69 73 6B 65 74 74 65 20 63 61 6E 20 6E 6F 77 20 42 4F 4F 54 2E 0D
5445H-5476H: the closing message, ended by 0DH.

5477H - The Boot Sector's New Instructions at 4216H

Six bytes that 52CDH copies, with the drive code table after them, over 4216H-4225H of the boot sector (5716H-5725H in the buffer). They are not run at 5477H: in the boot sector at 4216H they load Register Pair DE with cylinder 0, sector 5 and jump to the boot sector's loader at 423EH, which then loads sectors 5 and 6 instead of SYS0/SYS.

5477
LD DE,0005H 11 05 00
Load Register Pair DE with 0005H: Register D = cylinder 0, Register E = sector 5. Run at 4216H in the boot sector, this is where its loader starts to read.
547A
JUMP to 423EH, the boot sector's loader (run at 4219H): it moves Register Pair DE into the alternate set, reads the sectors from there on and loads their records.
547D-5486
DEFS 10
547DH-5486H: not in the file. The copy of the drive code table made at 525AH-5270H: +00H C3H, +01H-+02H 5200H (5282H), +03H as the drive's, +04H with bits 6, 4 and 0 set (526AH), +05H 00H (5270H), +06H-+09H as the drive's. It goes into the boot sector at 421CH-4225H.
5487-54FB
DEFS 117
5487H-54FBH: not in the file and not used by SOLE.
54FC-54FF
DEFS 4
54FCH-54FFH: not in the file. The header of sector 5's load record, built by 5286H-5290H: 01H (a load block), FEH (the length), 00H 52H (load at 5200H). Written with 5500H-55FBH as sector 5.

5500H - Boot Module: the Driver, Read a Sector (Runs at 5200H)

The boot module is 5500H-56D0H in the file and runs 0300H lower, at 5200H-53D0H: the boot sector loads 5500H-55FBH from sector 5 to 5200H-52FBH and 55FCH-56D0H from sector 6 to 52FCH-53D0H. Its addresses are run addresses; each row names the run address and the row of this page that holds it (run address + 0300H). The driver at 5200H is what the drive code table of the boot names (+01H-+02H = 5200H). It has one function, whatever Register B holds: read cylinder Register D, sector Register E into the buffer at Register Pair HL, with up to 5 tries, the side chosen from the sector number, and the density changed on a record not found. It returns the Z FLAG with Register A = 00H, or the NZ FLAG with an error number in Register A (5260H).

5500
GOSUB to 5289H (5589H on this page) to wait until the controller is not busy.
5503
GOSUB to 52D1H (55D1H on this page) to set the density of the controller from bit 6 of byte +03H of the drive code table. SOLE changes the operand to 52DDH (55DDH on this page) at 5254H for the Percom doubler.
5506
LD BC,0588H 01 88 05
Load Register Pair BC with 0588H: Register B = 5, the tries, Register C = 88H, the controller command Read Sector.
5509
PUSH BC C5
Save Register Pair BC (Register B = the tries left, Register C = the command) to the stack. Run address 5209H; 554DH and 555CH come back here for another try.
550A
GOSUB to 5296H (5596H on this page) to seek cylinder Register D and give the controller sector Register E, with the side chosen from it.
550D
PUSH DE D5
Save Register Pair DE (the cylinder and the sector) to the stack.
550E
PUSH HL E5
Save Register Pair HL (the buffer) to the stack.
550F
LD HL,37EDH 21 ED 37
Point Register Pair HL to 37EDH, the controller's track register.
5512
GOSUB to 5289H (5589H on this page) to wait until the controller is not busy: the seek is done.
5515
LD (HL),D 72
Store Register D (the cylinder) in the track register at Register Pair HL (37EDH).
5516
DEC HL 2B
DECrement Register Pair HL to 37ECH, the controller's command and status register.
5517
LD DE,37EFH 11 EF 37
Point Register Pair DE to 37EFH, the controller's data register.
551A
DI F3
Disable interrupts: nothing may delay the loop that takes the bytes from the data register.
551B
LD A,C 79
Copy Register C (88H, Read Sector) into Register A.
551C
GOSUB to 52C8H (55C8H on this page) to issue the command in Register A to the controller and wait a moment.
551F
POP BC C1
Restore Register Pair BC from the stack: the buffer, saved as Register Pair HL at 550EH.
5520
PUSH BC C5
Save Register Pair BC (the buffer) to the stack again, for the restore at 5547H.
5521
LD A,(HL) 7E
Fetch the controller's status at Register Pair HL (37ECH) into Register A. Run address 5221H; 5524H comes back here.
5522
AND 03H E6 03
Keep bits 1-0 of Register A (AND 03H): bit 0 BUSY, bit 1 DATA REQUEST. The PARITY flag is odd when exactly one of them is set.
5524
If the parity of Register A is odd (busy and no byte yet), JUMP back to 5221H (5521H on this page) to read the status again. Both bits set (a byte waiting) or neither (the command ended) go on.
5527
LD A,(DE) 1A
Fetch the byte from the data register at Register Pair DE (37EFH) into Register A. Run address 5227H; the polls below come back here.
5528
LD (BC),A 02
Store Register A (the byte) in the buffer at Register Pair BC.
5529
INC BC 03
INCrement Register Pair BC to the next byte of the buffer.
552A
BIT 1,(HL) CB 4E
Test bit 1 (DATA REQUEST) of the status at Register Pair HL (37ECH). The test is written five times so that a byte is taken within a few microseconds at double density.
552C
If the NZ FLAG is set (a byte is waiting), JUMP to 5227H (5527H on this page) to take it.
552F
BIT 1,(HL) CB 4E
Test bit 1 (DATA REQUEST) of the status at Register Pair HL (37ECH) again.
5531
If the NZ FLAG is set (a byte is waiting), JUMP to 5227H (5527H on this page) to take it.
5534
BIT 1,(HL) CB 4E
Test bit 1 (DATA REQUEST) of the status at Register Pair HL (37ECH) again.
5536
If the NZ FLAG is set (a byte is waiting), JUMP back to 5527H to take it.
5538
BIT 1,(HL) CB 4E
Test bit 1 (DATA REQUEST) of the status at Register Pair HL (37ECH) again.
553A
If the NZ FLAG is set (a byte is waiting), JUMP back to 5527H to take it.
553C
BIT 1,(HL) CB 4E
Test bit 1 (DATA REQUEST) of the status at Register Pair HL (37ECH) a fifth time.
553E
If the NZ FLAG is set (a byte is waiting), JUMP back to 5527H to take it.
5540
BIT 0,(HL) CB 46
Test bit 0 (BUSY) of the status at Register Pair HL (37ECH).
5542
If the NZ FLAG is set (the command still runs), JUMP back to 552AH to poll for the next byte.
5544
LD A,(HL) 7E
Fetch the controller's final status at Register Pair HL (37ECH) into Register A.
5545
AND 7CH E6 7C
Keep bits 6-2 of Register A (AND 7CH): bit 2 LOST DATA, bit 3 CRC ERROR, bit 4 RECORD NOT FOUND, bits 6-5 the record type (the data mark). The Z FLAG is set when none is set.
5547
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
5548
POP DE D1
Restore Register Pair DE (the cylinder and the sector) from the stack.
5549
POP BC C1
Restore Register Pair BC (Register B = the tries left, Register C = the command) from the stack.
554A
RET Z C8
RETurn with the Z FLAG and Register A = 00H if the sector was read without an error bit.
554B
BIT 2,A CB 57
Test bit 2 of Register A, LOST DATA: a byte came before the last one was taken.
554D
If the NZ FLAG is set (a byte was lost), JUMP back to 5509H to read the sector again without counting a try.
554F
PUSH AF F5
Save Register Pair AF (the error bits in Register A) to the stack.
5550
AND 18H E6 18
Keep bits 4-3 of Register A (AND 18H): RECORD NOT FOUND and CRC ERROR.
5552
If the Z FLAG is set (neither: a data mark bit), JUMP to 555FH, into the instruction at 555EH, where the byte F1H is POP AF: no more tries.
5554
BIT 4,A CB 67
Test bit 4 of Register A, RECORD NOT FOUND: no sector with that number and cylinder was found.
5556
PUSH BC C5
Save Register Pair BC (the tries and the command) to the stack.
5557
If the NZ FLAG is set (record not found), GOSUB to 52EDH (55EDH on this page) to change to the other density and restore the head to cylinder 0.
555A
POP BC C1
Restore Register Pair BC (Register B = the tries left, Register C = the command) from the stack.
555B
POP AF F1
Restore Register Pair AF (the error bits) from the stack.
555C
DECrement Register B (the tries left) and, if it is not 0, JUMP back to 5509H for another try.
555E
LD B,F1H 06 F1
Load Register B with F1H. Register B is not used after it: the instruction steps over the byte F1H, which 5552H enters as POP AF.
5560
LD B,A 47
Copy Register A (the error bits) into Register B. Run address 5260H: turn the lowest error bit into an error number.
5561
LD A,01H 3E 01
Load Register A with 01H, the error number for bit 0.
5563
RRC B CB 08
Rotate Register B right one bit (RRC B): the bit going out goes into the CARRY FLAG.
5565
RET C D8
RETurn with the NZ FLAG and the error number in Register A when the bit rotated out was set: 03H for LOST DATA, 04H for CRC ERROR, 05H for RECORD NOT FOUND, 06H and 07H for the data mark bits 5 and 6, the error numbers of a read.
5566
INC A 3C
INCrement Register A, the error number of the next bit.
5567
JUMP back to 5563H to rotate out the next bit of Register B.

5569H - Select the Drive and the Side (Runs at 5269H)

Waits until the controller is not busy, then writes the drive's select line and the side bit to the drive select latch: bit 3 of the latch is bit 4 of byte +03H of the drive code table, set for side 1. The value is also kept at 5290H (5590H on this page), which 5289H writes while it waits. When the controller reported NOT READY (the motor was off) it waits about a second for the motor.

5569
GOSUB to 5289H (5589H on this page) to wait until the controller is not busy: Register A = the status, bit 0 clear.
556C
RLCA 07
Rotate Register A left one bit: bit 7 of the status, NOT READY, goes into the CARRY FLAG.
556D
PUSH AF F5
Save Register Pair AF (the CARRY FLAG = not ready) to the stack.
556E
LD A,(IY+03H) FD 7E 03
Fetch byte +03H of the drive code table at Index Register IY into Register A.
5571
AND 10H E6 10
Keep bit 4 of Register A (AND 10H), the side: set for side 1.
5573
RRCA 0F
Rotate Register A right one bit: the side bit moves to bit 3, the side bit of the drive select latch.
5574
OR (IY+04H) FD B6 04
OR Register A with byte +04H of the drive code table at Index Register IY: bits 3-0 are the drive's select line.
5577
AND 0FH E6 0F
Keep bits 3-0 of Register A (AND 0FH): the select line and the side bit.
5579
LD (5290H),A 32 90 52
Store Register A (the latch value) at 5290H, the operand of LD A,01H at 528FH (5590H on this page), so that the wait at 5289H selects the same drive and side.
557C
LD (37E1H),A 32 E1 37
Store Register A (the latch value) in the drive select latch at 37E1H: the drive is selected, its motor runs, and the side is chosen.
557F
POP AF F1
Restore Register Pair AF (the CARRY FLAG = not ready) from the stack.
5580
RET NC D0
RETurn if the NC FLAG is set (the drive was ready).
5581
PUSH BC C5
Save Register Pair BC (the caller's command and count) to the stack.
5582
LD B,FFH 06 FF
Load Register B with FFH: Register Pair BC = FFxxH (Register C as it is), the count of the delay.
5584
GOSUB to the ROM's delay at 0060H, which counts Register Pair BC down to zero: about a second for the motor to come up to speed.
5587
POP BC C1
Restore Register Pair BC (the caller's command and count) from the stack.
5588
RET C9
RETurn to the caller with the drive selected and its motor up to speed.

5589H - Wait While the Controller Is Busy (Runs at 5289H)

Returns when bit 0 (BUSY) of the controller's status is clear, with the status in Register A. While it waits it writes the latch value kept at 5290H (5590H on this page) to the drive select latch, which keeps the drive selected and its motor running.

5589
LD A,(37ECH) 3A EC 37
Fetch the controller's status at 37ECH into Register A. Run address 5289H.
558C
BIT 0,A CB 47
Test bit 0 of Register A, BUSY: set while a command runs.
558E
RET Z C8
RETurn with the status in Register A if the Z FLAG is set (not busy).
558F
LD A,01H 3E 01
Load Register A with the latch value: the operand 5590H (run address 5290H) is 01H in the file, drive 0 on side 0, and the store at 5279H (5579H on this page) keeps it current.
5591
LD (37E1H),A 32 E1 37
Store Register A (the latch value) in the drive select latch at 37E1H: the drive stays selected and its motor running.
5594
JUMP back to 5589H to read the controller's status again.

5596H - Seek the Cylinder and Choose the Side (Runs at 5296H)

Register D = the cylinder, Register E = the sector counted through both sides of the cylinder. A sector at or above the sectors on a track (byte +07H, bits 4-0, plus 1) is on side 1: bit 4 of byte +03H is set and the count of a track is taken off. The sector goes to the controller's sector register and the cylinder to its data register and to byte +05H of the drive code table, and a Seek is issued with the drive's step rate. Register Pair DE comes back unchanged. 52C8H (55C8H on this page) is the end of it, used to issue any command.

5596
GOSUB to 5289H (5589H on this page) to wait until the controller is not busy. Run address 5296H.
5599
LD A,(IY+05H) FD 7E 05
Fetch byte +05H of the drive code table at Index Register IY into Register A: the cylinder the head is on.
559C
LD (37EDH),A 32 ED 37
Store Register A (the cylinder the head is on) in the controller's track register at 37EDH, the start of the seek.
559F
LD A,(IY+07H) FD 7E 07
Fetch byte +07H of the drive code table at Index Register IY into Register A: bits 4-0 the highest sector on a track.
55A2
AND 1FH E6 1F
Keep bits 4-0 of Register A (AND 1FH): the highest sector on a track.
55A4
INC A 3C
INCrement Register A: the sectors on a track.
55A5
RES 4,(IY+03H) FD CB 03 A6
Reset bit 4 of byte +03H of the drive code table at Index Register IY: side 0 to begin with.
55A9
SUB E 93
SUBtract Register E (the sector) from Register A (the sectors on a track).
55AA
NEG ED 44
Negate Register A: Register A = the sector less the sectors on a track, negative (the SIGN FLAG set) when the sector is on side 0.
55AC
PUSH DE D5
Save Register Pair DE (the cylinder and the sector as given) to the stack.
55AD
If the SIGN FLAG is set (the sector is on side 0), JUMP to 52B5H (55B5H on this page) with Register E as it is.
55B0
SET 4,(IY+03H) FD CB 03 E6
Set bit 4 of byte +03H of the drive code table at Index Register IY: side 1.
55B4
LD E,A 5F
Copy Register A (the sector less the sectors on a track) into Register E: the sector on side 1.
55B5
LD (37EEH),DE ED 53 EE 37
Store Register Pair DE in the controller at 37EEH-37EFH: Register E (the sector) in the sector register, Register D (the cylinder) in the data register, where the Seek command takes it from. Run address 52B5H.
55B9
POP DE D1
Restore Register Pair DE (the cylinder and the sector as given) from the stack.
55BA
LD (IY+05H),D FD 72 05
Store Register D (the cylinder) in byte +05H of the drive code table at Index Register IY: the head will be there.
55BD
LD B,18H 06 18
Load Register B with 18H, the controller command Seek with the head loaded.
55BF
GOSUB to 5269H (5569H on this page) to select the drive and the side, waiting for the motor if needed. Run address 52BFH; the density change at 55EDH (run address 52EDH) comes here with Register B = 08H.
55C2
LD A,(IY+03H) FD 7E 03
Fetch byte +03H of the drive code table at Index Register IY into Register A.
55C5
AND 03H E6 03
Keep bits 1-0 of Register A (AND 03H): the drive's step rate.
55C7
OR B B0
OR Register B (the command, 18H Seek or 08H Restore) into Register A: the command with the drive's step rate.
55C8
LD (37ECH),A 32 EC 37
Store Register A (the command) in the controller's command register at 37ECH. Run address 52C8H, the entry 551CH uses to issue Read Sector.
55CB
LD B,08H 06 08
Load Register B with 08H, the count of a short wait.
55CD
DECrement Register B and, if it is not 0, JUMP to 55CDH, the same instruction: the controller needs a moment before its BUSY bit can be read.
55CF
XOR A AF
Clear Register A to 00H (XOR A), with the Z FLAG.
55D0
RET C9
RETurn to the caller with Register A = 00H and the Z FLAG.

55D1H - Density for the Tandy Adapter (Runs at 52D1H)

The Tandy double density adapter takes its settings from writes to the controller's sector register with bits 7-5 set: 80H selects double density, A0H single density. The density is bit 6 of byte +03H of the drive code table. This is the routine the driver calls unless SOLE changed its two calls to 52DDH.

55D1
LD A,(IY+03H) FD 7E 03
Fetch byte +03H of the drive code table at Index Register IY into Register A. Run address 52D1H.
55D4
AND 40H E6 40
Keep bit 6 of Register A (AND 40H): set for double density.
55D6
RRCA 0F
Rotate Register A right one bit: 20H for double density, 00H for single.
55D7
XOR A0H EE A0
Exclusive OR Register A with A0H: 80H for double density, A0H for single density.
55D9
LD (37EEH),A 32 EE 37
Store Register A (80H or A0H) in the controller's sector register at 37EEH: the adapter sets the density.
55DC
RET C9
RETurn to the caller with the density set for the Tandy adapter.

55DDH - Density for the Percom Doubler (Runs at 52DDH)

The Percom doubler takes the density from a command written to the controller's command register: FEH selects single density, FFH double density. A Force Interrupt (D0H) then ends that command. 5254H and 5257H make the driver call this routine instead of 52D1H when byte 9 of the drive's driver is not CDH.

55DD
LD A,(IY+03H) FD 7E 03
Fetch byte +03H of the drive code table at Index Register IY into Register A. Run address 52DDH.
55E0
RLCA 07
Rotate Register A left one bit: bit 6 (double density) moves to bit 7.
55E1
RLCA 07
Rotate Register A left one bit again: the density bit is now bit 0.
55E2
OR FEH F6 FE
OR Register A with FEH: FFH for double density, FEH for single density.
55E4
LD (37ECH),A 32 EC 37
Store Register A (FEH or FFH) in the controller's command register at 37ECH: the doubler sets the density.
55E7
LD A,D0H 3E D0
Load Register A with D0H, the controller command Force Interrupt.
55E9
LD (37ECH),A 32 EC 37
Store Register A (D0H) in the command register at 37ECH, which ends the command written before.
55EC
RET C9
RETurn to the caller with the density set for the Percom doubler.

55EDH - Change the Density (Runs at 52EDH)

Called by the driver when the controller reports RECORD NOT FOUND: the diskette may be in the other density. Bit 6 of byte +03H of the drive code table is flipped, bytes +07H and +08H get the layout of that density (single density 09H 24H: 10 sectors on a track, 5 to a granule, 2 granules on a track; double density 11H 45H: 18 sectors, 6 to a granule, 3 granules on a track), the controller is set to the density, and the head is restored to cylinder 0 (byte +05H = 00H) so that the next seek starts from a known cylinder. The routine is split between the sectors: 55EDH-55FBH run at 52EDH-52FBH from sector 5, 55FCH-5611H at 52FCH-5311H from sector 6.

55ED
PUSH HL E5
Save Register Pair HL (the buffer) to the stack. Run address 52EDH.
55EE
LD A,(IY+03H) FD 7E 03
Fetch byte +03H of the drive code table at Index Register IY into Register A.
55F1
XOR 40H EE 40
Exclusive OR Register A with 40H: bit 6, the density, is flipped.
55F3
LD (IY+03H),A FD 77 03
Store Register A (byte +03H with the other density) back in byte +03H at Index Register IY.
55F6
LD HL,2409H 21 09 24
Load Register Pair HL with 2409H, the layout of single density: Register L = 09H for +07H, Register H = 24H for +08H.
55F9
BIT 6,A CB 77
Test bit 6 of Register A (the new byte +03H): set for double density.
55FB
If the Z FLAG is set (single density), JUMP to 5600H with the single density layout in Register Pair HL. The byte 28H is the last of sector 5, its displacement 03H the first of sector 6.
55FD
LD HL,4511H 21 11 45
Load Register Pair HL with 4511H, the layout of double density: Register L = 11H for +07H, Register H = 45H for +08H.
5600
LD (IY+07H),L FD 75 07
Store Register L in byte +07H of the drive code table at Index Register IY: bits 4-0 the highest sector on a track (09H or 11H).
5603
LD (IY+08H),H FD 74 08
Store Register H in byte +08H at Index Register IY: bits 4-0 the sectors in a granule less one, bits 7-5 the granules on a track less one (24H or 45H).
5606
POP HL E1
Restore Register Pair HL (the buffer) from the stack.
5607
GOSUB to 52D1H (55D1H on this page) to set the controller to the new density. SOLE changes the operand to 52DDH (55DDH on this page) at 5257H for the Percom doubler.
560A
LD (IY+05H),00H FD 36 05 00
Store 00H in byte +05H of the drive code table at Index Register IY: the head will be on cylinder 0.
560E
LD B,08H 06 08
Load Register B with 08H, the controller command Restore with the head loaded.
5610
JUMP back to 55BFH (run address 52BFH) to select the drive and issue the Restore with the drive's step rate; its RET returns to the driver at 555AH.

5612H - Boot Module: the Loader (Runs at 5312H)

The start of the boot module: the boot sector's loader jumps here (the transfer address 5312H) with Index Register IY at the drive code table at 421CH in the boot sector, the ROM's single density work done. It reads the allocation table and the directory record of SYS0/SYS from the directory cylinder through the module's driver, and loads SYS0/SYS from its first extent as a load module, sector by sector through the buffer at 5100H. Before it jumps to SYS0/SYS it copies its drive code table to drive 0's table at 4700H and sets Index Register IY to 0000H.

5612
LD A,(IY+07H) FD 7E 07
Fetch byte +07H of the drive code table at Index Register IY into Register A. Run address 5312H.
5615
LD D,A 57
Copy Register A (byte +07H) into Register D, kept for the head count.
5616
AND 1FH E6 1F
Keep bits 4-0 of Register A (AND 1FH): the highest sector on a track.
5618
LD E,A 5F
Copy Register A (the highest sector) into Register E.
5619
INC E 1C
INCrement Register E: the sectors on a track.
561A
XOR D AA
Exclusive OR Register A (bits 4-0 of byte +07H) with Register D (all of it): only bits 7-5 are left, the heads less one.
561B
RLCA 07
Rotate Register A left one bit: the first of three rotations that bring bits 7-5 down to bits 2-0.
561C
RLCA 07
Rotate Register A left one bit again, the second of the three rotations.
561D
RLCA 07
Rotate Register A left one bit again: Register A = the heads less one.
561E
INC A 3C
INCrement Register A (the heads less one): Register A = the heads.
561F
LD B,A 47
Copy Register A (the heads) into Register B, the count of the additions.
5620
XOR A AF
Clear Register A to 00H (XOR A), the start of the sum.
5621
ADD A,E 83
ADD Register E (the sectors on a track) to Register A.
5622
DECrement Register B and, if it is not 0, JUMP back to 5621H: Register A = the sectors on a track x the heads.
5624
LD BC,5100H 01 00 51
Load Register Pair BC with 5100H, the buffer of the sectors.
5627
PUSH BC C5
Save Register Pair BC (5100H, the buffer) to the stack.
5628
PUSH AF F5
Save Register Pair AF (the sectors of a cylinder on one side in Register A) to the stack.
5629
LD D,(IY+09H) FD 56 09
Fetch byte +09H of the drive code table at Index Register IY into Register D: the directory cylinder.
562C
LD E,C 59
Copy Register C (00H) into Register E: sector 0 of the directory cylinder, the granule allocation table.
562D
GOSUB to 53C7H (56C7H on this page) to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H). The result is not tested.
5630
POP AF F1
Restore Register Pair AF (the sectors of a cylinder in Register A) from the stack.
5631
LD HL,51CDH 21 CD 51
Point Register Pair HL to 51CDH, byte CDH of the allocation table: the configuration of the diskette.
5634
BIT 5,(HL) CB 6E
Test bit 5 of the configuration byte at Register Pair HL: set for a diskette with two sides.
5636
If the Z FLAG is set (one side), JUMP to 5639H.
5638
ADD A,A 87
ADD Register A to itself: the sectors of a cylinder on both sides.
5639
LD (53BFH),A 32 BF 53
Store Register A (the sectors of a cylinder) at 53BFH, the operand of SUB 00H at 53BEH (56BFH on this page), the count at which the byte fetch steps to the next cylinder.
563C
LD E,04H 1E 04
Load Register E with 04H, sector 4 of the directory cylinder, whose first record is the directory record of SYS0/SYS.
563E
POP BC C1
Restore Register Pair BC (5100H) from the stack.
563F
PUSH BC C5
Save Register Pair BC (5100H) to the stack again.
5640
GOSUB to 53C7H (56C7H on this page) to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H). The result is not tested.
5643
POP HL E1
Restore Register Pair HL from the stack: 5100H, the attribute byte of the directory record of SYS0/SYS.
5644
BIT 4,(HL) CB 66
Test bit 4 of the attribute byte at Register Pair HL: set when the record is in use.
5646
If the Z FLAG is set (no SYS0/SYS), JUMP to 4229H in the boot sector, still at 4200H, to display No System and stop.
5649
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: the values worked out below go into the alternate set, which only the byte fetch at 53B0H uses.
564A
LD HL,(5116H) 2A 16 51
Fetch the first extent of SYS0/SYS from 5116H-5117H into Register Pair HL: Register L = the cylinder, Register H = the first granule in bits 7-5 and the granules less one in bits 4-0.
564D
LD A,H 7C
Copy Register H (the granule byte) into Register A.
564E
RLCA 07
Rotate Register A left one bit: the first of three rotations that bring bits 7-5 down to bits 2-0.
564F
RLCA 07
Rotate Register A left one bit again, the second of the three rotations.
5650
RLCA 07
Rotate Register A left one bit again: bits 7-5 of the granule byte are now bits 2-0.
5651
AND 07H E6 07
Keep bits 2-0 of Register A (AND 07H): the first granule of the extent.
5653
LD E,A 5F
Copy Register A (the first granule) into Register E.
5654
LD A,(IY+08H) FD 7E 08
Fetch byte +08H of the drive code table at Index Register IY into Register A.
5657
AND 1FH E6 1F
Keep bits 4-0 of Register A (AND 1FH): the sectors in a granule less one.
5659
INC A 3C
INCrement Register A: the sectors in a granule.
565A
LD D,A 57
Copy Register A (the sectors in a granule) into Register D.
565B
INC E 1C
INCrement Register E (the first granule): the count of the additions below is one more than the granule.
565C
NEG ED 44
Negate Register A: Register A = minus the sectors in a granule, so that the first addition gives 0.
565E
ADD A,D 82
ADD Register D (the sectors in a granule) to Register A.
565F
DEC E 1D
DECrement Register E, the count of the additions still to make.
5660
If the NZ FLAG is set, JUMP back to 565EH: Register A = the first granule x the sectors in a granule, the first sector of SYS0/SYS on its cylinder.
5662
LD E,A 5F
Copy Register A (the first sector) into Register E.
5663
LD D,L 55
Copy Register L (the cylinder of the extent) into Register D: Register Pair DE (alternate set) = the cylinder and sector to read first.
5664
LD BC,51FFH 01 FF 51
Load Register Pair BC with 51FFH, one byte before the buffer: the first byte fetch turns Register C to 00H and reads the first sector.
5667
EXX D9
Exchange Register Pairs BC, DE and HL back with the alternate set: the alternate set holds the read position, the main set is free.

5668H - Loader: the Records (Runs at 5368H)

Takes the records of SYS0/SYS through the byte fetch: type 01H, a load block (length, address, bytes); type 02H, the transfer address; any other type is passed over by its length. A length byte counts the address too, so a load block has length less 2 bytes; 02H gives 256.

5668
GOSUB to 53B0H (56B0H on this page) to fetch the next byte into Register A: the record type. Run address 5368H.
566B
DEC A 3D
DECrement Register A (the record type): the Z FLAG for 01H.
566C
If the NZ FLAG is set (not a load block), JUMP to 5685H.
566E
GOSUB to 53B0H (56B0H on this page) to fetch the length byte into Register A.
5671
LD B,A 47
Copy Register A (the length) into Register B.
5672
GOSUB to 53B0H (56B0H on this page) to fetch the low byte of the load address into Register A.
5675
LD L,A 6F
Copy Register A (the low byte of the load address) into Register L.
5676
DEC B 05
DECrement Register B (the length) for the byte of the address.
5677
GOSUB to 53B0H (56B0H on this page) to fetch the high byte of the load address into Register A.
567A
LD H,A 67
Copy Register A into Register H: Register Pair HL = the load address.
567B
DEC B 05
DECrement Register B for the second byte of the address: Register B = the bytes to load (00H counts 256).
567C
GOSUB to 53B0H (56B0H on this page) to fetch the next byte of the block into Register A.
567F
LD (HL),A 77
Store Register A (the byte) at Register Pair HL.
5680
INC HL 23
INCrement Register Pair HL to the next load address.
5681
DECrement Register B and, if it is not 0, JUMP back to 567CH for the next byte.
5683
JUMP back to 5668H for the next record of SYS0/SYS.
5685
DEC A 3D
DECrement Register A again: the Z FLAG for type 02H.
5686
If the Z FLAG is set (the transfer address), JUMP to 5693H.
5688
GOSUB to 53B0H (56B0H on this page) to fetch the length byte of the record into Register A.
568B
LD B,A 47
Copy Register A (the length) into Register B, the bytes to pass over.
568C
GOSUB to 53B0H (56B0H on this page) to fetch a byte of the record into Register A, which is not kept.
568F
DECrement Register B and, if it is not 0, JUMP back to 568CH.
5691
JUMP back to 5668H for the next record of SYS0/SYS.
5693
GOSUB to 53B0H (56B0H on this page) to fetch the length byte of the transfer record into Register A, not used.
5696
GOSUB to 53B0H (56B0H on this page) to fetch the low byte of the transfer address into Register A.
5699
LD L,A 6F
Copy Register A (the low byte of the transfer address) into Register L.
569A
GOSUB to 53B0H (56B0H on this page) to fetch the high byte of the transfer address into Register A.
569D
LD H,A 67
Copy Register A into Register H: Register Pair HL = the transfer address of SYS0/SYS.
569E
PUSH HL E5
Save Register Pair HL (the transfer address) to the stack.
569F
PUSH IY FD E5
Save Index Register IY (the drive code table at 421CH) to the stack.
56A1
POP HL E1
Restore the value into Register Pair HL: the source of the copy.
56A2
LD DE,4700H 11 00 47
Point Register Pair DE to 4700H, the drive code table of drive 0.
56A5
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, the 10 bytes of a drive code table.
56A8
LDIR ED B0
Copy the 10 bytes from Register Pair HL (the table at 421CH) to Register Pair DE (4700H-4709H), counting Register Pair BC down to zero: drive 0's table names the module's driver at 5200H.
56AA
POP HL E1
Restore Register Pair HL (the transfer address of SYS0/SYS) from the stack.
56AB
LD IY,0000H FD 21 00 00
Load Index Register IY with 0000H: SYS0/SYS's reset takes this as a boot by the boot sector the ROM runs and keeps drive 0's table at 4700H.
56AF
JP (HL) E9
JUMP to Register Pair HL, the transfer address of SYS0/SYS.

56B0H - Loader: Fetch the Next Byte (Runs at 53B0H)

Returns the next byte of SYS0/SYS in Register A. The read position is in the alternate set: Register Pair BC' the pointer into the buffer at 5100H, Register Pair DE' the cylinder and sector of the next sector. When the buffer is used up the next sector is read; after the last sector of a cylinder (the count stored at 53BFH) the sector goes back to 0 and the cylinder up by one.

56B0
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: Register Pair BC = the buffer pointer, Register Pair DE = the next cylinder and sector. Run address 53B0H.
56B1
INC C 0C
INCrement Register C, the low byte of the buffer pointer: 00H with the Z FLAG when the buffer is used up.
56B2
If the NZ FLAG is set (bytes are left in the buffer), JUMP to 56C4H to take the byte.
56B4
PUSH BC C5
Save Register Pair BC (5100H, the buffer) to the stack.
56B5
GOSUB to 53C7H (56C7H on this page) to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H).
56B8
If the NZ FLAG is set (the sector could not be read), JUMP to 4294H in the boot sector, still at 4200H, to display Disk Error and stop.
56BB
POP BC C1
Restore Register Pair BC (5100H) from the stack.
56BC
INC E 1C
INCrement Register E, the sector to read next.
56BD
LD A,E 7B
Copy Register E (the next sector) into Register A.
56BE
SUB 00H D6 00
SUBtract the sectors of a cylinder from Register A: the operand 53BFH (56BFH on this page) is 00H in the file and holds the count stored at 5339H (5639H on this page). The Z FLAG when the cylinder is done.
56C0
If the NZ FLAG is set (sectors are left on the cylinder), JUMP to 56C4H.
56C2
LD E,A 5F
Copy Register A (00H) into Register E: sector 0 of the next cylinder.
56C3
INC D 14
INCrement Register D, the cylinder of the next sector to read.
56C4
LD A,(BC) 0A
Fetch the byte at Register Pair BC (the buffer pointer) into Register A.
56C5
EXX D9
Exchange Register Pairs BC, DE and HL back with the alternate set: the read position is kept there.
56C6
RET C9
RETurn with the byte in Register A; the alternate set keeps the read position.

56C7H - Read a Sector through the Drive Code Table (Runs at 53C7H)

Reads cylinder Register D, sector Register E into the buffer at Register Pair BC by calling the driver through the drive code table at Index Register IY (421CH, whose JP goes to 5200H). Register Pair HL is kept.

56C7
PUSH HL E5
Save Register Pair HL to the stack. Run address 53C7H.
56C8
LD H,B 60
Copy Register B (the high byte of the buffer) into Register H.
56C9
LD L,C 69
Copy Register C (the low byte of the buffer) into Register L: Register Pair HL = the buffer, as the driver takes it.
56CA
GOSUB to 53CFH (56CFH on this page), which jumps to the drive code table at Index Register IY, and so to the driver at 5200H (5500H on this page): the Z FLAG on success.
56CD
POP HL E1
Restore Register Pair HL (the caller's value) from the stack.
56CE
RET C9
RETurn with the driver's result in Register A and the flags.
56CF
JP (IY) FD E9
JUMP to the drive code table at Index Register IY: its bytes +00H-+02H are JP 5200H. Run address 53CFH.

56D1H - The Transfer Record of the Boot Module

Four bytes at the end of sector 6's load record: they are data, the record that tells the boot sector's loader where to start the module.

56D1-56D4
DEFB 02H, 02H / DEFW 5312H 02 02 12 53
56D1H-56D4H: record type 02H (the transfer address), length 02H, then 5312H, the run address of the loader (5612H in the file). The boot sector's loader jumps there.
56D5-56F7
DEFS 35
56D5H-56F7H: not in the file. The rest of the 256 bytes written as sector 6 (55F8H-56F7H): whatever memory holds there. The boot module does not use them.
5700-57FF
DEFS 256
5700H-57FFH: not in the file. The buffer of the boot sector (5273H-52D5H), then of the allocation table and of directory sector 2 (52DBH-5302H).