TRS-80 DOS - LDOS 5.3.1 for the Model I - BOOT/SYS Disassembled

Page Customization

Introduction/Summary

LDOS 5.3.1 BOOT/SYS Disassembly - The Boot Sectors and the System Information Sector (Model I)

BOOT/SYS is the first file of every LDOS diskette: granule 0 of cylinder 0, sectors 0-4 (the manual's file list gives it 5 records). It is not a load module. Sector 0 is the boot sector the ROM runs, sector 1 is the boot sector for a boot through a disk driver, sector 2 is the system information sector, sector 3 is a copy of the granule allocation table and sector 4 is not used. FORMAT/CMD writes all of it; the manual says BOOT/SYS and DIR/SYS are never to be copied from one diskette to another.

The file on this page holds seven sectors: the five of BOOT/SYS and sectors 5 and 6 of cylinder 0, which lie outside it. Sector 6 holds the second part of the double density boot module SOLE/CMD writes; on this diskette nothing reads it.

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 reads sector 4 of the directory cylinder (the cylinder number is byte 2 of the sector, 4202H), checks that the directory record of SYS0/SYS there is in use, works out where the file's first extent starts, reads it sector by sector into a buffer at 5100H-51FFH, copies each load block to its address and jumps to the transfer address, 4E00H. A free directory record displays No System, a sector that cannot be read in two tries displays Disk Error; both wait for a line from the keyboard and stop the computer until RESET is pressed.

Sectors 0 and 1 are shown at 4200H-42FFH, where they run; sectors 2-5 at 4200H-42FFH too, the buffer SYS0/SYS reads the system information sector into; sector 6 at 52F8H-53F7H, where its code would run. Rows of sectors 1-6 carry ids that name the sector (s1-4224H, for example).

How Sector 0 Reads a Sector

Sector 0 works the floppy disk controller through its memory mapped registers, polling the status:

StepWhat the code does
Select01H to the drive select latch 37E1H before the directory read and before every sector of SYS0/SYS (4211H, 427EH)
SeekSector to 37EEH, cylinder to the data register 37EFH, command 1BH to 37ECH; bits 1-0 of the command are the bootstrap step rate FORMAT/CMD puts there (42B4H)
ReadCommand 88H, then each byte is taken from 37EFH when the status shows DATA REQUEST, until BUSY goes off (42C5H)
CheckStatus AND 1CH (record not found, CRC error, lost data); on an error Force Interrupt D0H and one more try (42DCH, 42ACH)

The main register set does the loading (Register Pair HL = the load address, Register B = the bytes left in the record); the alternate set does the reading (Register Pair DE' = cylinder and sector, Register Pair BC' = the buffer pointer). A granule is 5 sectors and a cylinder 10.

The Seven Sectors

SectorContents
0The boot sector the ROM runs, 4200H. Byte 2 is the directory cylinder (11H), the operand at 42BCH carries the bootstrap step rate.
1The boot sector for a boot through a disk driver, 4200H: entered with Index Register IY pointing at drive 0's drive code table, it reads through the driver (function 09H) and works out the geometry from the drive code table and the allocation table. Byte 2 is the directory cylinder, the operand at 4210H the bootstrap step rate.
2The system information sector, 4200H: the configuration file flag, the days in each month, two blocks of eight drive code tables (one for a boot through a driver, one for a boot by sector 0), the date and time prompt switches and the names of the days and months. SYS0/SYS reads it into 4200H at every boot.
3A copy of the granule allocation table, 4200H, as FORMAT/CMD wrote it: 35 cylinders of 2 granules, the diskette name LDOS531 and the date 07/14/91.
4Not used, 4200H: 00H.
5Outside BOOT/SYS, 4200H: bytes left from SYS7/SYS and 6CH.
6Outside BOOT/SYS, 52F8H: the second part of SOLE/CMD's double density boot module (a load block for 52FCH-53D0H and the transfer address 5312H).

SYS0/SYS's reset tells the two boots apart by Index Register IY (0000H after sector 0) and sets bit 0 of 442FH after a boot through a driver; that bit picks the block of drive code tables in sector 2 and the operand it takes the bootstrap step rate from (42BCH for sector 0, 4210H for sector 1).

Variables

Memory Outside BOOT/SYS

Address
Size
Contents
37E1H
1 byte
Drive Select Latch
Written with 01H (drive 0) by sector 0 at 4213H and 4280H; each write restarts the drive motor time-out.
37ECH
1 byte
Controller Command and Status
Commands 1BH (Seek), 88H (Read Sector) and D0H (Force Interrupt) 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).
37EEH
1 byte
Controller Sector Register
The sector to read, stored with the cylinder by LD (37EEH),DE at 42B4H.
37EFH
1 byte
Controller Data Register
The cylinder for the seek (42B4H), then each byte of the sector as it is read (42D7H).
41D4H-41DFH
12 bytes
Stack (Sector 0)
Below 41E0H, set at 4204H: return addresses and the pushes of Register Pairs BC, DE and HL during a read. At the jump to SYS0/SYS, 41DEH-41DFH hold 77H 42H.
4152H-415FH
14 bytes
Stack (Sector 1)
Below 4160H, set at 4203H: return addresses, the buffer address, the sectors per cylinder and the pushes of the disk driver.
4200H-42FFH
256 bytes
Boot Sector
The sector the boot runs from. SYS0/SYS reads the system information sector (sector 2) into the same place.
5100H-51FFH
256 bytes
Sector Buffer
The directory sector of SYS0/SYS (5100H attribute byte, 5116H-5117H first extent), the allocation table (51CDH, sectors 1 and 6) and then each sector of SYS0/SYS.
4700H-4709H
10 bytes
Drive 0 Drive Code Table
In SYS0/SYS. Sector 6 copies the driver's drive code table here (53A2H-53A8H); SYS0/SYS's reset copies it from Index Register IY after a boot by sector 1.
442FH
1 byte
Boot Flag
In SYS0/SYS. Bit 0 is set by its reset after a boot through a disk driver (Index Register IY not 0000H).

BOOT/SYS Data and Changed Operands

Address
Size
Contents
4202H
1 byte
Directory Cylinder (Sectors 0 and 1)
Byte 2 of the boot sector, the operand of CP 11H: 11H. Read at 4216H (sector 0) and 4229H (sector 1); SYS0/SYS copies it to 4709H.
42BCH
1 byte
Seek Command (Sector 0)
1BH; bits 1-0 are the bootstrap step rate (3). FORMAT/CMD writes it; SYS0/SYS's reset copies the two bits to 4703H.
4210H
1 byte
Bootstrap Step Rate (Sector 1)
The operand of OR 00H at 420FH: 00H on this diskette. FORMAT/CMD writes it; SYS0/SYS's reset copies it to 4703H after a driver boot.
42ABH
1 byte
Sectors per Cylinder (Sector 1)
The operand of SUB 00H at 42AAH, stored at 423AH.
53BFH
1 byte
Sectors per Cylinder (Sector 6)
The operand of SUB 00H at 53BEH, stored at 5339H.
42E4H-42FFH
28 bytes
Sector 0 Texts
Clear screen (42E4H), No System (42E7H), Disk Error (42F3H), each ended by 03H.
42E6H-42FEH
25 bytes
Sector 1 Texts
No System (42E6H), Disk Error (42F2H), each ended by 03H.

System Information Sector (Sector 2, at 4200H)

Address
Size
Contents
4200H
1 byte
Mark
53H.
4201H
1 byte
Configuration File Flag
C9H no CONFIG/SYS; 00H load it. SYS0/SYS replaces it with 00H after reading it.
4202H-420DH
12 bytes
Days in Each Month
January to December; 4203H is set to 28 or 29 by the date prompt.
4220H-426FH
80 bytes
Drive Code Tables, Driver Boot
Drives 0-7, 10 bytes each: JP 308AH, two 5 inch and two 8 inch drives present.
4270H-42BFH
80 bytes
Drive Code Tables, Sector 0 Boot
Drives 0-7: JP 45FBH (SYS0/SYS's floppy driver), drives 0-3 present, 35 cylinders of 10 sectors.
42C0H
1 byte
Set by BACKUP/CMD
FFH.
42C2H
1 byte
Date Prompt Switch
00H ask Date?; other values do not.
42C3H
1 byte
Time Prompt Switch
00H ask Time?; other values do not.
42C7H-42DBH
21 bytes
Day Names
Sun to Sat.
42DCH-42FFH
36 bytes
Month Names
Jan to Dec.

Outside Routines

AddressContents
0033HROM: display the character in Register A (42A4H, 42C2H in sector 1).
0040HROM: wait for a line from the keyboard into the buffer at Register Pair HL (429AH, 42B9H in sector 1).
01C9HROM: clear the screen (4207H in sector 1).
4E00HSYS0/SYS: its reset code, the transfer address of SYS0/SYS on this diskette.

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 finds SYS0/SYS through its directory record (sector 4 of the directory cylinder), reads its first extent sector by sector into the buffer at 5100H-51FFH, copies each load block to its address and jumps to the transfer address (4E00H on this diskette). It works the floppy disk controller directly through its memory mapped registers at 37ECH-37EFH. On entry the ROM has selected drive 0, the stack is the ROM's and interrupts may be on.

4200
NOP 00
No operation. Byte 0 of the boot sector is 00H. Execution passes to 4201H.
4201
CP 11H FE 11
Compare Register A against 11H. The flags are never tested: the instruction only steps over byte 2 of the sector (4202H), which is data: 11H, the cylinder that holds the directory (17). FORMAT/CMD stores the directory cylinder of the new diskette there; the LD A,(4202H) at 4216H below reads it, and SYS0/SYS's reset (4E76H) copies it to 4709H, the directory cylinder byte (+09H) of drive 0's drive code table.
4203
DI F3
Disable interrupts. No clock interrupt (through the RST 38H vector at 4012H) may run while SYS0/SYS loads over the ROM's vectors and work area in 4000H-41FFH; interrupts stay off until SYS0/SYS's reset turns them on (its 4E84H).
4204
LD SP,41E0H 31 E0 41
Load the Stack Pointer with 41E0H. The stack holds return addresses and the pushes of Register Pairs BC, DE and HL of the routines below, at most 12 bytes (41D4H-41DFH) during a sector read from the byte fetch. SYS0/SYS's last load record puts 00H 00H at 41DEH-41DFH; the CALLs that follow store their return addresses over them, so at the jump to SYS0/SYS they hold 77H 42H, the return address 4277H of the CALL at 4274H.
4207
LD IY,0000H FD 21 00 00
Load Index Register IY with 0000H. SYS0/SYS's reset (4E4FH-4E54H) tests IY: 0000H tells it that this sector, the boot sector the ROM runs, loaded it, so it takes the step rate from 42BCH below and does not set bit 0 of 442FH, the flag of a boot through a disk driver.
420B
LD HL,42E4H 21 E4 42
Point Register Pair HL to 42E4H, the text 1CH 1FH 03H: cursor to the top left, clear to the end of the screen, end of text.
420E
GOSUB to 429EH to display the text at Register Pair HL (42E4H) through the ROM: the screen is cleared.
4211
LD A,01H 3E 01
Load Register A with 01H, the select bit of drive 0.
4213
LD (37E1H),A 32 E1 37
Store Register A (01H) to the drive select latch at 37E1H: drive 0 is selected and its motor runs.
4216
LD A,(4202H) 3A 02 42
Fetch the directory cylinder from 4202H (byte 2 of this sector, 11H on this diskette) into Register A.
4219
LD D,A 57
Copy Register A (the directory cylinder) into Register D, the cylinder for the sector read at 42ACH.
421A
LD E,04H 1E 04
Load Register E with 04H: sector 4 of the directory cylinder, whose first directory record (bytes 00H-1FH) is the record of SYS0/SYS. Sectors 0 and 1 of the directory cylinder hold the granule allocation table and the hash index table; the first records of sectors 2 and 3 are BOOT/SYS and DIR/SYS.
421C
LD BC,5100H 01 00 51
Point Register Pair BC to 5100H, the 256 byte buffer the sector is read into.
421F
GOSUB to 42ACH to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H). On return the Z FLAG is set if the read succeeded (in one of two tries) and Register Pair HL holds 5100H.
4222
If the NZ FLAG is set (the directory sector could not be read), JUMP to 4294H to display Disk Error and stop.
4224
LD A,(5100H) 3A 00 51
Fetch byte 00H of the directory record from 5100H into Register A: the attribute byte of SYS0/SYS's directory record.
4227
AND 10H E6 10
Mask Register A to bit 4, the bit that marks a directory record in use. The Z FLAG is set when the record is free, that is when the diskette has no SYS0/SYS.
4229
LD HL,42E7H 21 E7 42
Point Register Pair HL to 42E7H, the text No System, in case the record is free. LD does not change the flags of the AND above.
422C
If the Z FLAG is set (bit 4 of the attribute byte in Register A is 0: no SYS0/SYS on the diskette), JUMP to 4297H to display No System at Register Pair HL and stop.

422EH - Locate SYS0/SYS on the Diskette

Byte 16H of the directory record is the cylinder of the file's first extent and byte 17H holds its first granule (bits 7-5) and the number of granules less one (bits 4-0). This code works the first granule into a sector number, 5 sectors to a granule, and sets up the alternate register set, which does all the reading from here on: Register Pair DE' holds the cylinder and sector of the next sector to read and Register Pair BC' the pointer into the buffer. Only the first extent is used, read as consecutive sectors.

422E
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 routine at 4279H uses.
422F
LD HL,(5116H) 2A 16 51
Fetch the first extent of SYS0/SYS from 5116H-5117H into Register Pair HL: Register L = byte 16H (the cylinder) and Register H = byte 17H (the first granule in bits 7-5, the number of granules less one in bits 4-0).
4232
LD D,L 55
Copy Register L (the cylinder of the first extent) into Register D, the cylinder of the first sector to read.
4233
LD A,H 7C
Copy Register H (byte 17H: first granule in bits 7-5) into Register A.
4234
RLCA 07
Rotate Register A left one bit (bit 7 goes to bit 0): first of three rotations that bring the first granule from bits 7-5 down to bits 2-0.
4235
RLCA 07
Rotate Register A left one bit again: second of three rotations that bring the first granule from bits 7-5 down to bits 2-0.
4236
RLCA 07
Rotate Register A left one bit again: bits 7-5 of byte 17H are now bits 2-0 of Register A.
4237
AND 07H E6 07
Mask Register A to bits 2-0: Register A now holds the number of the first granule on the cylinder (0 or 1 on a single density cylinder of 10 sectors).
4239
LD H,A 67
Copy Register A (the granule number) into Register H, to be added once more below.
423A
RLCA 07
Rotate Register A left one bit: Register A = granule x 2 (bits 2-0 hold at most 7, so no bit is lost).
423B
RLCA 07
Rotate Register A left one bit again: Register A = granule x 4.
423C
ADD A,H 84
Add Register H (the granule number) to Register A: Register A = granule x 5, the first sector of the granule (5 sectors to a granule: sector 0 or 5).
423D
LD E,A 5F
Copy Register A (the first sector of the file) into Register E. Register Pair DE (alternate set) now holds the cylinder and sector where SYS0/SYS begins.
423E
LD BC,51FFH 01 FF 51
Load Register Pair BC with 51FFH, one byte before the buffer at 5100H. The byte fetch at 4279H increments only Register C, so its first call turns 51FFH into 5100H with the Z FLAG set, and that makes it read the first sector of SYS0/SYS before it takes a byte.
4241
EXX D9
Exchange Register Pairs BC, DE and HL back with the alternate set. The alternate set now holds the read position (DE' cylinder and sector, BC' buffer pointer); the main set is free for the loader.

4242H - Load SYS0/SYS Record by Record

SYS0/SYS is a load module: records of a type byte, a length byte and the data. Type 01H is a load block (two address bytes, then the length less 2 data bytes; a length of 02H gives 256), type 02H is the transfer address, and every other type is passed over by its length. The bytes come one at a time from the buffer through 4279H, which reads the next sector when the buffer is used up.

4242
GOSUB to 4279H to fetch the next byte of SYS0/SYS into Register A: the record type.
4245
DEC A 3D
DECrement Register A (the record type) by 1. The Z FLAG is set when the type was 01H, a load block.
4246
If the NZ FLAG is set (the type in Register A was not 01H), JUMP to 425FH to check for the transfer address record or pass over the record.
4248
GOSUB to 4279H to fetch the next byte into Register A: the record's length byte (the number of bytes after it).
424B
LD B,A 47
Copy Register A (the record length) into Register B, the count of bytes of this record still to be read.
424C
GOSUB to 4279H to fetch the next byte into Register A: the low byte of the load address.
424F
LD L,A 6F
Copy Register A (the low byte of the load address) into Register L.
4250
DEC B 05
DECrement Register B (the bytes left in the record) by 1 for the low address byte just read.
4251
GOSUB to 4279H to fetch the next byte into Register A: the high byte of the load address.
4254
LD H,A 67
Copy Register A (the high byte of the load address) into Register H. Register Pair HL now holds the address where this block's data goes.
4255
DEC B 05
DECrement Register B by 1 for the high address byte. Register B now holds the number of data bytes (a length byte of 02H gives 00H, which the DJNZ below counts as 256).
4256
GOSUB to 4279H to fetch the next data byte of the block into Register A. 425BH loops back here.
4259
LD (HL),A 77
Store Register A (the data byte) at the load address in Register Pair HL.
425A
INC HL 23
INCrement Register Pair HL, the load address, to the next byte.
425B
DECrement Register B (the data bytes left) and LOOP BACK to 4256H until the block is copied.
425D
JUMP back to 4242H for the next record: the load block in Register Pair HL's range is copied.
425F
DEC A 3D
DECrement Register A again: the type in Register A is now the record type less 2. The Z FLAG is set when the type was 02H, the transfer address.
4260
If the Z FLAG is set (the type in Register A was 02H), JUMP to 426DH to take the transfer address and run SYS0/SYS.
4262
Any other type (00H, 03H and up) is passed over. GOSUB to 4279H to fetch the record's length byte into Register A.
4265
LD B,A 47
Copy Register A (the record length) into Register B, the number of bytes to pass over. A length of 00H passes over 256 bytes.
4266
GOSUB to 4279H to fetch the next byte of the record into Register A, which is not used. 4269H loops back here.
4269
DECrement Register B (the bytes left to pass over) and LOOP BACK to 4266H until the record is passed over.
426B
JUMP back to 4242H for the next record: the passed over record changed nothing in memory.
426D
Type 02H, the transfer address. GOSUB to 4279H to fetch the record's length byte into Register A (02H); it is not used.
4270
GOSUB to 4279H to fetch the next byte into Register A: the low byte of the transfer address.
4273
LD L,A 6F
Copy Register A (the low byte of the transfer address) into Register L.
4274
GOSUB to 4279H to fetch the next byte into Register A: the high byte of the transfer address.
4277
LD H,A 67
Copy Register A (the high byte of the transfer address) into Register H. Register Pair HL now holds the transfer address of SYS0/SYS (4E00H on this diskette).
4278
JP (HL) E9
JUMP to the address in Register Pair HL: SYS0/SYS's reset code. Index Register IY still holds 0000H (4207H), interrupts are off and the Stack Pointer is 41E0H; SYS0/SYS sets its own stack at once.

4279H - Fetch the Next Byte of SYS0/SYS

Returns the next byte of the file in Register A. Works in the alternate register set: Register Pair BC' points into the buffer at 5100H and Register Pair DE' holds the cylinder and sector of the next sector to read. When Register C' wraps to 00H the buffer is used up and the next sector is read into it first. The main registers of the caller are not changed.

4279
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: Register Pair BC now points into the buffer and Register Pair DE holds the next cylinder and sector.
427A
INC C 0C
INCrement Register C, the low byte of the buffer pointer in Register Pair BC. The Z FLAG is set when it wraps from FFH to 00H: the 256 bytes of the buffer have all been used (or this is the first call, with Register Pair BC = 51FFH).
427B
If the NZ FLAG is set (Register C did not wrap, so the buffer at Register Pair BC still holds unread bytes), JUMP to 4291H to fetch the byte.
427D
PUSH BC C5
Save Register Pair BC (the buffer pointer, now 5100H) to the stack. The read below changes Register Pair BC.
427E
LD A,01H 3E 01
Load Register A with 01H, the select bit of drive 0.
4280
LD (37E1H),A 32 E1 37
Store Register A (01H) to the drive select latch at 37E1H again before every sector: selecting the drive restarts its motor time-out, so the motor keeps running while SYS0/SYS loads.
4283
GOSUB to 42ACH to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H). The Z FLAG is set on return if the read succeeded.
4286
If the NZ FLAG is set (the sector could not be read in two tries), JUMP to 4294H to display Disk Error and stop.
4288
POP BC C1
Restore Register Pair BC (the buffer pointer, 5100H) from the stack.
4289
INC E 1C
INCrement Register E, the sector number, to the next sector.
428A
LD A,E 7B
Copy Register E (the next sector number) into Register A.
428B
SUB 0AH D6 0A
SUBtract 0AH (10, the number of sectors on a single density cylinder) from Register A (the next sector number). The Z FLAG is set when Register E has passed the last sector, 9.
428D
If the NZ FLAG is set (the next sector in Register E is still on this cylinder), JUMP to 4291H to fetch the byte.
428F
LD E,A 5F
Copy Register A (00H) into Register E: sector 0 of the next cylinder.
4290
INC D 14
INCrement Register D, the cylinder number, to the next cylinder.
4291
LD A,(BC) 0A
Fetch the byte at Register Pair BC (the buffer pointer) into Register A: the next byte of SYS0/SYS.
4292
EXX D9
Exchange Register Pairs BC, DE and HL back with the alternate set: the read position is kept in the alternate set and the caller's Register Pairs BC, DE and HL come back.
4293
RET C9
RETurn to the caller with the byte in Register A.

4294H - Display an Error and Stop

Disk Error is shown when a sector cannot be read, No System (entered at 4297H with Register Pair HL = 42E7H) when the directory record of SYS0/SYS is free. Both wait for a line from the keyboard and then stop the computer; only RESET restarts it.

4294
LD HL,42F3H 21 F3 42
Point Register Pair HL to 42F3H, the text Disk Error.
4297
GOSUB to 429EH to display the text at Register Pair HL (42F3H Disk Error, or 42E7H No System from 422CH). Register Pair HL comes back unchanged.
429A
GOSUB to the ROM's line input at 0040H. It waits for keys and stores them over the message text at Register Pair HL, at most Register B characters (51H or 52H, the high byte the sector read left in the buffer pointer), until ENTER or BREAK. Nothing uses the line: it only waits for the operator.
429D
HALT 76
Stop the processor. Interrupts are off (4203H), so only the RESET button (a non maskable interrupt) starts the computer again.

429EH - Display a Text

Displays the bytes at Register Pair HL through the ROM until the end byte 03H. Register Pair HL is kept.

429E
PUSH HL E5
Save Register Pair HL (the start of the text) to the stack, so the caller gets it back at 42AAH.
429F
LD A,(HL) 7E
Fetch the next character of the text at Register Pair HL into Register A. 42A8H loops back here.
42A0
CP 03H FE 03
Compare Register A (the character) against 03H, the end of text byte. The Z FLAG is set at the end.
42A2
If the Z FLAG is set (Register A holds 03H, the end of the text), JUMP to 42AAH to return.
42A4
GOSUB to the ROM's display routine at 0033H to display the character in Register A. The ROM acts on the control codes: 1CH moves the cursor to the top left, 1FH clears to the end of the screen, 17H switches to 32 characters per line, and C0H-FFH display (code less C0H) spaces (E8H: 40 spaces).
42A7
INC HL 23
INCrement Register Pair HL to the next character of the text.
42A8
LOOP BACK to 429FH for the next character of the text at Register Pair HL.
42AA
POP HL E1
Restore Register Pair HL (the start of the text) from the stack.
42AB
RET C9
RETurn to the caller with Register Pair HL pointing at the start of the text again.

42ACH - Read a Sector, Two Tries

Reads cylinder Register D, sector Register E of drive 0 into the buffer at Register Pair BC. The first try is the CALL 42B4H; when it fails, the code falls into 42B4H for a second try, which returns straight to the caller. On return the Z FLAG is set if the sector was read, and Register Pair HL holds the buffer address.

42AC
PUSH BC C5
Save Register Pair BC (the buffer address) to the stack: the read at 42B4H advances Register Pair BC through the buffer.
42AD
GOSUB to 42B4H for the first try at reading cylinder Register D, sector Register E into the buffer at Register Pair BC. The Z FLAG is set on return if it succeeded.
42B0
POP HL E1
Restore the buffer address saved at 42ACH from the stack into Register Pair HL. POP does not change the flags.
42B1
RET Z C8
If the Z FLAG is set (the first try read the sector), RETurn to the caller with Register Pair HL = the buffer address.
42B2
LD B,H 44
Copy Register H (the high byte of the buffer address) into Register B for the second try.
42B3
LD C,L 4D
Copy Register L (the low byte of the buffer address) into Register C. Register Pair BC again holds the buffer address, and the code falls into 42B4H for the second and last try, which returns to this routine's caller.
42B4
LD (37EEH),DE ED 53 EE 37
Store Register Pair DE to 37EEH-37EFH: Register E (the sector) goes to the controller's sector register at 37EEH and Register D (the cylinder) to its data register at 37EFH, where the seek command takes the cylinder to move to. The track register (37EDH) is not written: it holds the cylinder the head is on (0 after the ROM's restore, then the last cylinder sought).
42B8
LD HL,37ECH 21 EC 37
Point Register Pair HL to 37ECH, the controller's command register (written) and status register (read).
42BB
LD (HL),1BH 36 1B
Store 1BH to the command register at Register Pair HL (37ECH): Seek to the cylinder in the data register. FORMAT/CMD writes the bootstrap step rate into bits 1-0 of this command byte (42BCH), and SYS0/SYS's reset (4E66H-4E75H) copies those two bits into drive 0's drive code table at 4703H.
1771 FDC Command: 1BH (00011011)Function Description
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0Summary of Bits
00011011Command=Seek (bits 7-4 = 0001)
h = 1: head load and settle delay
V = 0: no verify
r1 r0 = 11: 40 ms stepping rate
42BD
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (the Stack Pointer is not changed): first of four exchanges that only pass time (the four take 76 cycles) so the controller has set its busy bit before the status is read. Register Pair HL is unchanged after the even number of exchanges.
42BE
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (the Stack Pointer is not changed) again: second of the four delay exchanges.
42BF
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (the Stack Pointer is not changed) again: third of the four delay exchanges.
42C0
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (the Stack Pointer is not changed) again: fourth delay exchange. Register Pair HL holds 37ECH again.
42C1
LD A,(HL) 7E
Fetch the controller's status from 37ECH (Register Pair HL) into Register A. 42C3H loops back here.
42C2
RRCA 0F
Rotate Register A right one bit: bit 0 of the status, BUSY, goes into the CARRY FLAG.
42C3
If the CARRY FLAG is set (the controller is still busy with the seek), LOOP BACK to 42C1H to read the status again.
42C5
LD (HL),88H 36 88
Store 88H to the command register at Register Pair HL (37ECH): Read Sector, the sector in the sector register on the cylinder just reached.
1771 FDC Command: 88H (10001000)Function Description
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0Summary of Bits
10001000Command=Read Sector (bits 7-5 = 100)
m = 0: one sector
b = 1: IBM sector length
E = 0: no head load delay
42C7
PUSH DE D5
Save Register Pair DE (the cylinder and sector) to the stack, since Register Pair DE is needed for the data register address.
42C8
LD DE,37EFH 11 EF 37
Point Register Pair DE to 37EFH, the controller's data register, where each byte of the sector arrives.
42CB
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (the Stack Pointer is not changed): first of two exchanges that only pass time while the controller starts the read. Register Pair HL is unchanged after both.
42CC
EX (SP),HL E3
Exchange Register Pair HL with the word at the top of the stack (the Stack Pointer is not changed) again: Register Pair HL holds 37ECH (the status register) again.
42CD
JUMP to 42DAH, which goes on to the status test at 42D2H.
42CF
RRCA 0F
Rotate Register A (the status, with DATA REQUEST clear) right one bit: bit 0, BUSY, goes into the CARRY FLAG.
42D0
If the NO CARRY FLAG is set (the controller is no longer busy: the sector is finished), JUMP to 42DCH to check the result.
42D2
LD A,(HL) 7E
Fetch the controller's status from 37ECH (Register Pair HL) into Register A. 42DAH and 42D5H come back here.
42D3
BIT 1,A CB 4F
Test bit 1 of Register A (the status): DATA REQUEST, a byte waiting in the data register. The Z FLAG is set when no byte is waiting.
42D5
If the Z FLAG is set (no byte in the data register yet), JUMP to 42CFH to check whether the controller has finished.
42D7
LD A,(DE) 1A
Fetch the byte from the controller's data register at Register Pair DE (37EFH) into Register A. Reading it clears DATA REQUEST.
42D8
LD (BC),A 02
Store Register A (the byte of the sector) into the buffer at Register Pair BC.
42D9
INC BC 03
INCrement Register Pair BC to the next byte of the buffer.
42DA
JUMP to 42D2H to wait for the next byte or the end of the read.
42DC
LD A,(HL) 7E
Fetch the controller's final status from 37ECH (Register Pair HL) into Register A.
42DD
AND 1CH E6 1C
Mask Register A to bits 4-2 of the status: RECORD NOT FOUND (bit 4), CRC ERROR (bit 3) and LOST DATA (bit 2). The Z FLAG is set when none of them is on: the sector was read.
42DF
POP DE D1
Restore Register Pair DE (the cylinder and sector) from the stack. POP does not change the flags.
42E0
RET Z C8
If the Z FLAG is set (no error bit in Register A), RETurn: the sector is in the buffer.
42E1
LD (HL),D0H 36 D0
Store D0H to the command register at Register Pair HL (37ECH): Force Interrupt ends whatever the controller is doing after the failed read. The NZ FLAG from the AND at 42DDH is still set for the caller.
1771 FDC Command: D0H (11010000)Function Description
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0Summary of Bits
11010000Command=Force Interrupt (bits 7-4 = 1101)
I3-I0 = 0000: end the command, no interrupt
42E3
RET C9
RETurn to the caller with the NZ FLAG set: the read failed.

42E4H - Sector 0: Texts

The three texts this sector displays through 429EH, each ended by 03H.

42E4-42E6
DEFB 1CH, 1FH, 03H 1C 1F 03
The text displayed by 420EH at the start: 1CH moves the cursor to the top left, 1FH clears to the end of the screen, 03H ends the text.
42E7-42E8
DEFB 17H, E8H 17 E8
Start of the No System text (422CH): 17H switches the screen to 32 characters per line, E8H displays 40 spaces (E8H less C0H), which puts the message on the second line, 8 columns in.
42E9-42F1
DEFM "No System" 4E 6F 20 53 79 73 74 65 6D
The message displayed when the directory record of SYS0/SYS is not in use (4224H-422CH).
42F2
DEFB 03H 03
End of the No System text: 429EH stops at this byte and does not display it.
42F3-42F4
DEFB 17H, E8H 17 E8
Start of the Disk Error text (4294H): 17H switches the screen to 32 characters per line, E8H displays 40 spaces, which puts the message on the second line, 8 columns in.
42F5-42FE
DEFM "Disk Error" 44 69 73 6B 20 45 72 72 6F 72
The message displayed when a sector cannot be read in two tries (4222H, 4286H).
42FF
DEFB 03H 03
End of the Disk Error text, and the last byte of sector 0.

Sector 1: The Boot Sector for a Driver Boot

Sector 1 also runs at 4200H-42FFH. It is the boot sector for a computer whose own boot code reads the diskette through a disk driver and enters this sector with Index Register IY pointing at drive 0's 10 byte drive code table, whose first three bytes are a JP to the driver. Every read goes through that driver (JP (IY) at 42D5H): function 09H (read a sector) with Register C = drive, Register D = cylinder, Register E = sector and Register Pair HL = the buffer, the same registers SYS0/SYS's own read primitive at 4777H passes. SYS0/SYS's reset (4E4FH-4E61H) sees that Index Register IY is not 0000H, copies the 10 bytes at IY to drive 0's drive code table at 4700H and sets bit 0 of 442FH, which makes it take the drive tables of drives 1-7 from the block at 4220H-426FH of the system information sector (sector 2) instead of the block at 4270H-42BFH. The entries of that block jump to 308AH, outside the LDOS files, and describe two 5 inch and two 8 inch drives, the default configuration the manual gives for the Lobo LX-80 interface; MISOSYS documents bit 0 of 442FH as the flag of a boot from that interface. FORMAT/CMD writes this sector from its image at 6C00H, with the directory cylinder at 4202H and the bootstrap step rate at 4210H.

4200
NOP 00
No operation. Byte 0 of the sector is 00H, as in sector 0. Execution passes to 4201H.
4201
CP 11H FE 11
Compare Register A against 11H. The flags are never tested: the instruction only steps over byte 2 of the sector (4202H), which is data: 11H, the directory cylinder (17), which FORMAT/CMD stores here (its 62DEH). 4229H below reads it, and SYS0/SYS's reset (4E76H) copies it to 4709H, the directory cylinder byte of drive 0's drive code table.
4203
LD SP,4160H 31 60 41
Load the Stack Pointer with 4160H. The stack holds the return addresses, the buffer address and the sectors per cylinder pushed below, and whatever the disk driver pushes, growing down from 4160H.
4206
DI F3
Disable interrupts while SYS0/SYS loads over the vectors and work area in 4000H-41FFH. SYS0/SYS's reset turns them on (its 4E84H).
4207
GOSUB to the ROM's clear screen routine at 01C9H: the screen is cleared and the cursor goes to the top left.
420A
LD A,(IY+03H) FD 7E 03
Fetch byte +03H of drive 0's drive code table at Index Register IY into Register A: the drive's flags, with the step rate in bits 1-0.
420D
AND FCH E6 FC
Mask Register A to bits 7-2 (AND FCH): the step rate bits 1-0 are cleared.
420F
OR 00H F6 00
OR Register A with 00H, the bootstrap step rate. FORMAT/CMD writes the rate (0-3) into the operand byte at 4210H (its 62E5H-62ECH through the pointer at 6902H); on this diskette it is 00H. SYS0/SYS's reset (4E63H-4E75H) copies bits 1-0 of 4210H into drive 0's drive code table at 4703H.
4211
LD (IY+03H),A FD 77 03
Store Register A (the flags with the bootstrap step rate) back into byte +03H of the drive code table at Index Register IY, so every seek of the boot uses that rate.
4214
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 hold the highest sector number on a track and bits 7-5 the number of heads less one.
4217
LD D,A 57
Copy Register A (byte +07H) into Register D, kept for the head count below.
4218
AND 1FH E6 1F
Mask Register A to bits 4-0: Register A now holds the highest sector number on a track.
421A
LD E,A 5F
Copy Register A (the highest sector number) into Register E.
421B
INC E 1C
INCrement Register E: Register E now holds the number of sectors on a track (sectors are numbered from 0).
421C
XOR D AA
Exclusive OR Register A (the highest sector number, bits 4-0 of byte +07H) with Register D (all of byte +07H): only bits 7-5 of byte +07H are left in Register A, the number of heads less one.
421D
RLCA 07
Rotate Register A left one bit: first of three rotations that bring bits 7-5 down to bits 2-0.
421E
RLCA 07
Rotate Register A left one bit again: second of three rotations.
421F
RLCA 07
Rotate Register A left one bit again: Register A now holds the number of heads less one in bits 2-0.
4220
INC A 3C
INCrement Register A: Register A now holds the number of heads.
4221
GOSUB to 42D7H to multiply Register A (the number of heads) by Register E (the sectors on a track). Register A comes back holding the number of sectors on a cylinder.
4224
LD BC,5100H 01 00 51
Point Register Pair BC to 5100H, the 256 byte buffer for every sector read.
4227
PUSH BC C5
Save Register Pair BC (the buffer address 5100H) to the stack, for the directory read at 423FH-4244H.
4228
PUSH AF F5
Save Register Pair AF (Register A = the sectors on a cylinder) to the stack across the read below.
4229
LD A,(4202H) 3A 02 42
Fetch the directory cylinder from 4202H (byte 2 of this sector) into Register A.
422C
LD D,A 57
Copy Register A (the directory cylinder) into Register D, the cylinder to read.
422D
LD E,C 59
Copy Register C (00H, the low byte of 5100H) into Register E: sector 0 of the directory cylinder, the granule allocation table.
422E
GOSUB to 42C9H to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H) through the disk driver. The result is not tested: the allocation table is only used for one bit below.
4231
POP AF F1
Restore Register Pair AF from the stack: Register A = the sectors on a cylinder again.
4232
LD HL,51CDH 21 CD 51
Point Register Pair HL to 51CDH, byte CDH of the allocation table just read: the high byte of the diskette's configuration word.
4235
BIT 5,(HL) CB 6E
Test bit 5 of the configuration byte at Register Pair HL (51CDH): set when the diskette was formatted with two sides (FORMAT/CMD takes it from bit 5 of byte +04H of the drive code table, its 6318H). The Z FLAG is set for one side.
4237
If the Z FLAG is set (the diskette has one side), JUMP to 423AH, keeping the sectors on a cylinder in Register A as they are.
4239
ADD A,A 87
Double Register A (ADD A,A): a diskette with two sides has twice the sectors on a cylinder.
423A
LD (42ABH),A 32 AB 42
Store Register A (the sectors on a cylinder) into the operand byte 42ABH of the SUB at 42AAH, where the byte fetch decides when to move to the next cylinder.
423D
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. Register D still holds the directory cylinder.
423F
POP BC C1
Restore Register Pair BC from the stack: the buffer address 5100H saved at 4227H.
4240
PUSH BC C5
Save Register Pair BC (5100H) to the stack again, to come back as Register Pair HL at 4244H.
4241
GOSUB to 42C9H to read the directory sector (cylinder Register D, sector Register E = 04H) into the buffer at Register Pair BC (5100H). The result is not tested; a sector that could not be read leaves the buffer as it was.
4244
POP HL E1
Restore the buffer address from the stack into Register Pair HL: Register Pair HL = 5100H, byte 00H of SYS0/SYS's directory record.
4245
BIT 4,(HL) CB 66
Test bit 4 of the attribute byte at Register Pair HL (5100H): set when the directory record is in use. The Z FLAG is set when the record is free, that is when the diskette has no SYS0/SYS.
4247
LD HL,42E6H 21 E6 42
Point Register Pair HL to 42E6H, the text No System, in case the record is free. LD does not change the flags.
424A
If the Z FLAG is set (the record of SYS0/SYS is free), JUMP to 42B6H to display No System at Register Pair HL and stop.

424CH - Locate SYS0/SYS (Sector 1)

The first extent of SYS0/SYS (bytes 16H-17H of its directory record) gives the cylinder and the first granule. Here the sectors per granule come from the drive code table (bits 4-0 of byte +08H, plus 1), and the granule number is multiplied by them through 42D7H. The read position is set up in the alternate register set, as in sector 0.

424C
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 429DH uses.
424D
LD HL,(5116H) 2A 16 51
Fetch the first extent of SYS0/SYS from 5116H-5117H into Register Pair HL: Register L = byte 16H (the cylinder) and Register H = byte 17H (the first granule in bits 7-5, the number of granules less one in bits 4-0).
4250
LD A,H 7C
Copy Register H (byte 17H of the directory record: first granule in bits 7-5) into Register A.
4251
RLCA 07
Rotate Register A left one bit: first of three rotations that bring the first granule from bits 7-5 down to bits 2-0.
4252
RLCA 07
Rotate Register A left one bit again: second of three rotations.
4253
RLCA 07
Rotate Register A left one bit again: bits 7-5 of byte 17H are now bits 2-0 of Register A.
4254
AND 07H E6 07
Mask Register A to bits 2-0: Register A now holds the number of the first granule on the cylinder.
4256
LD E,A 5F
Copy Register A (the granule number) into Register E, the multiplier for 42D7H.
4257
LD A,(IY+08H) FD 7E 08
Fetch byte +08H of the drive code table at Index Register IY into Register A: bits 4-0 hold the sectors in a granule less one.
425A
AND 1FH E6 1F
Mask Register A to bits 4-0: the sectors in a granule less one.
425C
INC A 3C
INCrement Register A: Register A now holds the number of sectors in a granule.
425D
GOSUB to 42D7H to multiply Register A (the sectors in a granule) by Register E (the granule number). Register A comes back holding the first sector of the file on its cylinder.
4260
LD E,A 5F
Copy Register A (the first sector of SYS0/SYS) into Register E.
4261
LD D,L 55
Copy Register L (the cylinder of the first extent) into Register D. Register Pair DE (alternate set) now holds the cylinder and sector where SYS0/SYS begins.
4262
LD BC,51FFH 01 FF 51
Load Register Pair BC with 51FFH, one byte before the buffer at 5100H, so that the first call of the byte fetch (INC C at 429EH gives 00H) reads the first sector before it takes a byte.
4265
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 for the loader.

4266H - Load SYS0/SYS Record by Record (Sector 1)

The same loader as sector 0 (4242H): type 01H records are copied to their load address, type 02H gives the transfer address, any other type is passed over by its length. The bytes come from 429DH.

4266
GOSUB to 429DH to fetch the next byte of SYS0/SYS into Register A: the record type.
4269
DEC A 3D
DECrement Register A (the record type) by 1. The Z FLAG is set when the type was 01H, a load block.
426A
If the NZ FLAG is set (the type in Register A was not 01H), JUMP to 4283H to check for the transfer address record or pass over the record.
426C
GOSUB to 429DH to fetch the next byte into Register A: the record's length byte.
426F
LD B,A 47
Copy Register A (the record length) into Register B, the count of bytes of this record still to be read.
4270
GOSUB to 429DH to fetch the next byte into Register A: the low byte of the load address.
4273
LD L,A 6F
Copy Register A (the low byte of the load address) into Register L.
4274
DEC B 05
DECrement Register B (the bytes left in the record) by 1 for the low address byte.
4275
GOSUB to 429DH to fetch the next byte into Register A: the high byte of the load address.
4278
LD H,A 67
Copy Register A (the high byte of the load address) into Register H. Register Pair HL now holds the address where this block's data goes.
4279
DEC B 05
DECrement Register B by 1 for the high address byte. Register B now holds the number of data bytes (00H counts as 256 in the DJNZ below).
427A
GOSUB to 429DH to fetch the next data byte into Register A. 427FH loops back here.
427D
LD (HL),A 77
Store Register A (the data byte) at the load address in Register Pair HL.
427E
INC HL 23
INCrement Register Pair HL, the load address, to the next byte.
427F
DECrement Register B (the data bytes left) and LOOP BACK to 427AH until the block is copied.
4281
JUMP back to 4266H for the next record: the load block in Register Pair HL's range is copied.
4283
DEC A 3D
DECrement Register A again: the type in Register A is now the record type less 2. The Z FLAG is set when the type was 02H, the transfer address.
4284
If the Z FLAG is set (the type in Register A was 02H), JUMP to 4291H to take the transfer address and run SYS0/SYS.
4286
Any other type is passed over. GOSUB to 429DH to fetch the record's length byte into Register A.
4289
LD B,A 47
Copy Register A (the record length) into Register B, the number of bytes to pass over (00H passes over 256).
428A
GOSUB to 429DH to fetch the next byte of the record into Register A, which is not used. 428DH loops back here.
428D
DECrement Register B (the bytes left to pass over) and LOOP BACK to 428AH until the record is passed over.
428F
JUMP back to 4266H for the next record: the passed over record changed nothing in memory.
4291
Type 02H. GOSUB to 429DH to fetch the record's length byte into Register A (02H); it is not used.
4294
GOSUB to 429DH to fetch the next byte into Register A: the low byte of the transfer address.
4297
LD L,A 6F
Copy Register A (the low byte of the transfer address) into Register L.
4298
GOSUB to 429DH to fetch the next byte into Register A: the high byte of the transfer address.
429B
LD H,A 67
Copy Register A (the high byte of the transfer address) into Register H. Register Pair HL now holds the transfer address of SYS0/SYS (4E00H on this diskette).
429C
JP (HL) E9
JUMP to the address in Register Pair HL: SYS0/SYS's reset code, with Index Register IY still pointing at the drive code table the driver boot gave, which tells the reset that this sector loaded it.

429DH - Fetch the Next Byte (Sector 1)

Returns the next byte of SYS0/SYS in Register A, working in the alternate register set (Register Pair BC' = buffer pointer, Register Pair DE' = next cylinder and sector). When Register C' wraps to 00H the next sector is read through the driver; the sector number wraps at the sectors per cylinder stored at 42ABH.

429D
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: Register Pair BC now points into the buffer and Register Pair DE holds the next cylinder and sector.
429E
INC C 0C
INCrement Register C, the low byte of the buffer pointer in Register Pair BC. The Z FLAG is set when it wraps to 00H: the buffer at 5100H is used up (or this is the first call).
429F
If the NZ FLAG is set (Register C did not wrap, so unread bytes remain at Register Pair BC), JUMP to 42B0H to fetch the byte.
42A1
PUSH BC C5
Save Register Pair BC (the buffer pointer, now 5100H) to the stack across the read.
42A2
GOSUB to 42C9H to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H) through the disk driver. The Z FLAG is set on return if the driver read it.
42A5
If the NZ FLAG is set (the driver reported an error), JUMP to 42B3H to display Disk Error and stop.
42A7
POP BC C1
Restore Register Pair BC (the buffer pointer, 5100H) from the stack.
42A8
INC E 1C
INCrement Register E, the sector number, to the next sector.
42A9
LD A,E 7B
Copy Register E (the next sector number) into Register A.
42AA
SUB 00H D6 00
SUBtract the sectors per cylinder from Register A (the next sector number). The operand byte 42ABH is 00H in the file; 423AH stores the sectors per cylinder there before the first read. The Z FLAG is set when Register E has passed the last sector of the cylinder.
42AC
If the NZ FLAG is set (the next sector in Register E is still on this cylinder), JUMP to 42B0H to fetch the byte.
42AE
LD E,A 5F
Copy Register A (00H) into Register E: sector 0 of the next cylinder.
42AF
INC D 14
INCrement Register D, the cylinder number, to the next cylinder.
42B0
LD A,(BC) 0A
Fetch the byte at Register Pair BC (the buffer pointer) into Register A: the next byte of SYS0/SYS.
42B1
EXX D9
Exchange Register Pairs BC, DE and HL back with the alternate set: the read position stays in the alternate set and the caller's registers come back.
42B2
RET C9
RETurn to the caller with the byte in Register A.

42B3H - Display an Error and Stop (Sector 1)

Disk Error when the driver cannot read a sector of SYS0/SYS; No System (entered at 42B6H with Register Pair HL = 42E6H) when its directory record is free. Then the computer waits for a line from the keyboard and stops.

42B3
LD HL,42F2H 21 F2 42
Point Register Pair HL to 42F2H, the text Disk Error.
42B6
GOSUB to 42BDH to display the text at Register Pair HL (42F2H Disk Error, or 42E6H No System from 424AH). Register Pair HL comes back pointing at the text's end byte 03H.
42B9
GOSUB to the ROM's line input at 0040H: it waits for keys and stores them from Register Pair HL (the end of the message) on, at most Register B characters (the count the disk driver left in Register B), until ENTER or BREAK. Nothing uses the line.
42BC
HALT 76
Stop the processor. Interrupts are off (4206H), so only RESET starts the computer again.

42BDH - Display a Text (Sector 1)

Displays the bytes at Register Pair HL through the ROM until the end byte 03H; Register Pair HL is left pointing at the 03H.

42BD
LD A,(HL) 7E
Fetch the next character of the text at Register Pair HL into Register A. 42C6H loops back here.
42BE
CP 03H FE 03
Compare Register A (the character) against 03H, the end of text byte. The Z FLAG is set at the end.
42C0
If the Z FLAG is set (Register A holds 03H), JUMP to 42C8H to return.
42C2
GOSUB to the ROM's display routine at 0033H to display the character in Register A (17H switches to 32 characters per line, E8H displays 40 spaces).
42C5
INC HL 23
INCrement Register Pair HL to the next character of the text.
42C6
LOOP BACK to 42BDH for the next character of the text at Register Pair HL.
42C8
RET C9
RETurn to the caller with Register Pair HL pointing at the end byte 03H.

42C9H - Read a Sector Through the Driver

Reads cylinder Register D, sector Register E of drive 0 into the buffer at Register Pair BC by calling the disk driver through the drive code table at Index Register IY with function 09H. The driver's Z FLAG (set = read) and Register A (the error) come back to the caller; Register Pair HL is kept.

42C9
PUSH HL E5
Save Register Pair HL to the stack: the driver takes the buffer address in Register Pair HL.
42CA
LD H,B 60
Copy Register B (the high byte of the buffer address) into Register H.
42CB
LD L,C 69
Copy Register C (the low byte of the buffer address) into Register L. Register Pair HL now holds the buffer address for the driver.
42CC
LD B,09H 06 09
Load Register B with 09H, the driver function: read a sector (the function SYS0/SYS's read primitive at 4777H passes).
42CE
LD C,00H 0E 00
Load Register C with 00H, the drive number: drive 0.
42D0
GOSUB to 42D5H, which jumps through the drive code table at Index Register IY into the disk driver. The driver returns here with the Z FLAG set if the sector was read.
42D3
POP HL E1
Restore Register Pair HL from the stack. POP does not change the flags the driver returned.
42D4
RET C9
RETurn to the caller with the driver's flags.
42D5
JP (IY) FD E9
JUMP to the address in Index Register IY: byte +00H of the drive code table, which holds a JP to the disk driver (C3H and the driver's address). The driver's RET goes back to 42D3H.

42D7H - Multiply Two Bytes

Returns in Register A the low 8 bits of Register A times Register E, by shift and add. Register D is left holding the first factor and Register E is shifted to 00H; Register Pair BC is kept.

42D7
PUSH BC C5
Save Register Pair BC to the stack: Register B is the bit counter below.
42D8
LD D,A 57
Copy Register A (the first factor) into Register D, the value added for each set bit of Register E.
42D9
XOR A AF
Set Register A to 00H (XOR A), the product so far.
42DA
LD B,08H 06 08
Load Register B with 08H, one pass for each bit of Register E.
42DC
ADD A,A 87
Double Register A (the product so far, ADD A,A). 42E2H loops back here.
42DD
SLA E CB 23
Shift Register E (the second factor) left one bit: its bit 7 goes into the CARRY FLAG.
42DF
If the NO CARRY FLAG is set (that bit of Register E was 0), JUMP to 42E2H without adding.
42E1
ADD A,D 82
ADD Register D (the first factor) to Register A (the product so far).
42E2
DECrement Register B (the bits left) and LOOP BACK to 42DCH until all 8 bits of Register E are done. Register A holds the product.
42E4
POP BC C1
Restore Register Pair BC (saved at 42D7H; Register B was the bit counter) from the stack.
42E5
RET C9
RETurn to the caller with the product in Register A.

42E6H - Sector 1: Texts

The two messages of this sector, each ended by 03H, and the last byte of the sector.

42E6-42E7
DEFB 17H, E8H 17 E8
Start of the No System text (424AH): 17H switches the screen to 32 characters per line, E8H displays 40 spaces (E8H less C0H), which puts the message on the second line, 8 columns in.
42E8-42F0
DEFM "No System" 4E 6F 20 53 79 73 74 65 6D
The message displayed when the directory record of SYS0/SYS is not in use (4245H-424AH).
42F1
DEFB 03H 03
End of the No System text: 42BDH stops at this byte and does not display it.
42F2-42F3
DEFB 17H, E8H 17 E8
Start of the Disk Error text (42B3H): 32 characters per line, then 40 spaces.
42F4-42FD
DEFM "Disk Error" 44 69 73 6B 20 45 72 72 6F 72
The message displayed when the driver cannot read a sector of SYS0/SYS (42A5H).
42FE
DEFB 03H 03
End of the Disk Error text: 42BDH stops at this byte and does not display it.
42FF
DEFB FFH FF
The last byte of sector 1, FFH. No code of this sector uses it.

Sector 2: The System Information Sector (Data)

Sector 2 of cylinder 0 holds the system information of the diskette. SYS0/SYS's reset reads it into 4200H-42FFH (its 4E85H-4E8CH: cylinder 0, sector 2, through the read primitive at 4777H) and uses it there, so the rows show each byte at that address. SYS7/SYS (SYSTEM, its 5A61H and 5A6EH) reads and rewrites it to keep the DATE, TIME, BSTEP, DRIVE and SYSGEN settings; BACKUP/CMD copies it to the destination diskette with byte 01H set to C9H (its 6689H-66A2H). FORMAT/CMD writes a new diskette's sector 2 as 53H followed by 255 bytes of 00H (its 634BH-6361H); this diskette carries the settings of its master.

4200
DEFB 53H 53
Byte 00H: 53H ("S"), the mark of a system information sector. FORMAT/CMD writes it (634EH-6356H); DATECONV/CMD accepts the sector only when this byte is 53H or 63H (its 5264H-526BH).
4201
DEFB C9H C9
Byte 01H: the configuration file flag. C9H means no CONFIG/SYS file is to be loaded; SYS7/SYS stores 00H here when SYSTEM (SYSGEN) builds the file and C9H when SYSGEN=OFF deletes it (its 52D3H, 534BH), and BACKUP/CMD stores C9H on every copy. SYS0/SYS's reset reads it (4E90H-4E95H), keeps it on the stack for the configuration step at 5022H and stores 00H in its place, so that the month table below starts with a 0 when it adds up the days of the year (4F0FH-4F19H).
4202-420D
DEFB 1FH, 1CH, 1FH, 1EH, 1FH, 1EH, 1FH, 1FH, 1EH, 1FH, 1EH, 1FH 1F 1C 1F 1E 1F 1E 1F 1F 1E 1F 1E 1F
Bytes 02H-0DH: the number of days in each month, January to December: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31. SYS0/SYS's reset checks the day typed at the date prompt against it (4EDFH-4EE9H), stores 1CH (28) or 1DH (29) into the February byte at 4203H for the year typed (4EC4H-4ED6H, 4EFEH-4F05H) and adds up the months before the current one to get the day of the year (4F0FH-4F19H).
420E-421F
DEFB 00H x 18 00 x 18
Bytes 0EH-1FH: 18 bytes of 00H. SYS0/SYS's reset does not read them.
4220-4229
DEFB C3H, 8AH, 30H, 03H, 41H, 00H, 22H, 09H, 24H, 11H C3 8A 30 03 41 00 22 09 24 11
Bytes 20H-29H, the first block of drive code tables (drives 0-7, 10 bytes each), the one used after a boot through a disk driver (bit 0 of 442FH set: SYS0/SYS's 4FC5H-4FD6H, SYS7/SYS's 53CDH-53D3H and 5951H-5957H). Drive 0: +00H = C3H 8AH 30H, JP 308AH (C3H marks the drive as present); +03H = 03H, step rate 3 in bits 1-0, a 5 inch drive (bit 5 clear); +04H = 41H, bit 6 set (the controller can work in double density) and select line 1 in bits 3-0; +05H = 00H, the cylinder the head is on; +06H = 22H, highest cylinder 34 (35 cylinders); +07H = 09H, highest sector 9 (10 sectors), one head; +08H = 24H, 2 granules a track (bits 7-5 plus 1) of 5 sectors (bits 4-0 plus 1); +09H = 11H, directory cylinder 17. SYS0/SYS's reset copies only drives 1-7; SYSTEM (BSTEP) stores the bootstrap step rate in bits 1-0 of this entry's +03H (4223H, SYS7/SYS 53CBH-53D9H).
422A-4233
DEFB C3H, 8AH, 30H, 03H, 42H, FFH, 22H, 09H, 24H, 11H C3 8A 30 03 42 FF 22 09 24 11
Bytes 2AH-33H, first block, drive 1: JP 308AH (present); +03H = 03H, step rate 3, 5 inch; +04H = 42H, double density capable, select line 2; +05H = FFH, head position not known; +06H = 22H, 35 cylinders; +07H = 09H, 10 sectors, one head; +08H = 24H, 2 granules of 5 sectors a track; +09H = 11H, directory cylinder 17. SYS0/SYS's reset copies this entry and the next six (drives 1-7, 70 bytes) to 470AH-474FH when bit 0 of 442FH is set.
4234-423D
DEFB C3H, 8AH, 30H, 22H, 41H, FFH, 4CH, 0FH, 27H, 26H C3 8A 30 22 41 FF 4C 0F 27 26
Bytes 34H-3DH, first block, drive 2: JP 308AH (present); +03H = 22H, step rate 2, bit 5 set: an 8 inch drive; +04H = 41H, double density capable, select line 1; +05H = FFH, head position not known; +06H = 4CH, highest cylinder 76 (77 cylinders); +07H = 0FH, highest sector 15 (16 sectors), one head; +08H = 27H, 2 granules of 8 sectors a track; +09H = 26H, directory cylinder 38.
423E-4247
DEFB C3H, 8AH, 30H, 22H, 42H, FFH, 4CH, 0FH, 27H, 26H C3 8A 30 22 42 FF 4C 0F 27 26
Bytes 3EH-47H, first block, drive 3: JP 308AH (present); +03H = 22H, step rate 2, 8 inch; +04H = 42H, double density capable, select line 2; +05H = FFH, head position not known; +06H = 4CH, 77 cylinders; +07H = 0FH, 16 sectors, one head; +08H = 27H, 2 granules of 8 sectors a track; +09H = 26H, directory cylinder 38.
4248-4251
DEFB C9H, 8AH, 30H, 03H, 44H, FFH, 22H, 09H, 24H, 11H C9 8A 30 03 44 FF 22 09 24 11
Bytes 48H-51H, first block, drive 4: +00H = C9H, a RET in place of the JP: the drive is disabled, and a call to it returns at once; +01H-+02H keep the address 308AH; +03H = 03H, step rate 3, 5 inch; +04H = 44H, double density capable, select line 4; +05H = FFH; +06H = 22H, 35 cylinders; +07H = 09H, 10 sectors; +08H = 24H, 2 granules of 5 sectors; +09H = 11H, directory cylinder 17.
4252-425B
DEFB C3H, 8AH, 30H, 03H, 48H, FFH, 22H, 09H, 24H, 11H C3 8A 30 03 48 FF 22 09 24 11
Bytes 52H-5BH, first block, drive 5: JP 308AH (present); +03H = 03H, step rate 3, 5 inch; +04H = 48H, double density capable, select line 8; +05H = FFH; +06H = 22H, 35 cylinders; +07H = 09H, 10 sectors; +08H = 24H, 2 granules of 5 sectors; +09H = 11H, directory cylinder 17.
425C-4265
DEFB C3H, 8AH, 30H, 22H, 44H, FFH, 4CH, 0FH, 27H, 26H C3 8A 30 22 44 FF 4C 0F 27 26
Bytes 5CH-65H, first block, drive 6: JP 308AH (present); +03H = 22H, step rate 2, 8 inch; +04H = 44H, double density capable, select line 4; +05H = FFH; +06H = 4CH, 77 cylinders; +07H = 0FH, 16 sectors; +08H = 27H, 2 granules of 8 sectors; +09H = 26H, directory cylinder 38.
4266-426F
DEFB C3H, 8AH, 30H, 22H, 48H, FFH, 4CH, 0FH, 27H, 26H C3 8A 30 22 48 FF 4C 0F 27 26
Bytes 66H-6FH, first block, drive 7: JP 308AH (present); +03H = 22H, step rate 2, 8 inch; +04H = 48H, double density capable, select line 8; +05H = FFH; +06H = 4CH, 77 cylinders; +07H = 0FH, 16 sectors; +08H = 27H, 2 granules of 8 sectors; +09H = 26H, directory cylinder 38. The first block ends here.
4270-4279
DEFB C3H, FBH, 45H, 83H, 01H, 00H, 22H, 09H, 24H, 11H C3 FB 45 83 01 00 22 09 24 11
Bytes 70H-79H, the second block of drive code tables (drives 0-7), the one used after a boot by sector 0 (bit 0 of 442FH clear). Drive 0: +00H = C3H FBH 45H, JP 45FBH, SYS0/SYS's floppy disk driver (present); +03H = 83H, step rate 3 in bits 1-0 and bit 7 set, the software write protect (SYS0/SYS's write path refuses a write with error 0FH when it is set, its 468DH-4693H); +04H = 01H, select line 1 (drive 0 of the expansion interface); +05H = 00H, head on cylinder 0; +06H = 22H, 35 cylinders; +07H = 09H, 10 sectors, one head; +08H = 24H, 2 granules of 5 sectors; +09H = 11H, directory cylinder 17. SYS0/SYS's reset copies only drives 1-7; SYSTEM (BSTEP) stores the bootstrap step rate in bits 1-0 of this entry's +03H (4273H).
427A-4283
DEFB C3H, FBH, 45H, 03H, 02H, FFH, 22H, 09H, 24H, 11H C3 FB 45 03 02 FF 22 09 24 11
Bytes 7AH-83H, second block, drive 1: JP 45FBH (present); +03H = 03H, step rate 3, 5 inch; +04H = 02H, select line 2; +05H = FFH, head position not known; +06H = 22H, 35 cylinders; +07H = 09H, 10 sectors; +08H = 24H, 2 granules of 5 sectors; +09H = 11H, directory cylinder 17. SYS0/SYS's reset copies this entry and the next six (drives 1-7, 70 bytes) to 470AH-474FH when bit 0 of 442FH is clear (4FC5H-4FD6H).
4284-428D
DEFB C3H, FBH, 45H, 03H, 04H, FFH, 22H, 09H, 24H, 11H C3 FB 45 03 04 FF 22 09 24 11
Bytes 84H-8DH, second block, drive 2: JP 45FBH (present); +03H = 03H, step rate 3, 5 inch; +04H = 04H, select line 4; +05H = FFH; +06H = 22H, 35 cylinders; +07H = 09H, 10 sectors; +08H = 24H, 2 granules of 5 sectors; +09H = 11H, directory cylinder 17.
428E-4297
DEFB C3H, FBH, 45H, 03H, 08H, FFH, 22H, 09H, 24H, 11H C3 FB 45 03 08 FF 22 09 24 11
Bytes 8EH-97H, second block, drive 3: JP 45FBH (present); +03H = 03H, step rate 3, 5 inch; +04H = 08H, select line 8; +05H = FFH; +06H = 22H, 35 cylinders; +07H = 09H, 10 sectors; +08H = 24H, 2 granules of 5 sectors; +09H = 11H, directory cylinder 17.
4298-42A1
DEFB C9H, FBH, 45H, 83H, 01H, 00H, 22H, 09H, 24H, 11H C9 FB 45 83 01 00 22 09 24 11
Bytes 98H-A1H, second block, drive 4: +00H = C9H, disabled (a call returns at once); +01H-+02H keep 45FBH; the other bytes repeat drive 0's entry (+03H = 83H, +04H = 01H, +05H = 00H, 35 cylinders of 10 sectors, directory cylinder 17).
42A2-42AB
DEFB C9H, FBH, 45H, 03H, 02H, FFH, 22H, 09H, 24H, 11H C9 FB 45 03 02 FF 22 09 24 11
Bytes A2H-ABH, second block, drive 5: +00H = C9H, disabled; the other bytes repeat drive 1's entry (select line 2, 35 cylinders of 10 sectors, directory cylinder 17).
42AC-42B5
DEFB C9H, FBH, 45H, 03H, 04H, FFH, 22H, 09H, 24H, 11H C9 FB 45 03 04 FF 22 09 24 11
Bytes ACH-B5H, second block, drive 6: +00H = C9H, disabled; the other bytes repeat drive 2's entry (select line 4, 35 cylinders of 10 sectors, directory cylinder 17).
42B6-42BF
DEFB C9H, FBH, 45H, 03H, 08H, FFH, 22H, 09H, 24H, 11H C9 FB 45 03 08 FF 22 09 24 11
Bytes B6H-BFH, second block, drive 7: +00H = C9H, disabled; the other bytes repeat drive 3's entry (select line 8, 35 cylinders of 10 sectors, directory cylinder 17). The second block ends here.
42C0
DEFB FFH FF
Byte C0H: FFH. BACKUP/CMD stores FFH here when it writes the system information sector of a destination diskette (its 63C9H-63CBH); SYS0/SYS's reset does not read it.
42C1
DEFB 00H 00
Byte C1H: 00H. SYS0/SYS's reset does not read it.
42C2
DEFB 00H 00
Byte C2H: the date prompt switch. 00H: SYS0/SYS's reset asks Date? at every boot (4E96H-4E9AH); any other value skips the prompt. SYSTEM (DATE=ON/OFF) stores 00H or FFH here (SYS7/SYS 5380H).
42C3
DEFB 00H 00
Byte C3H: the time prompt switch. 00H: SYS0/SYS's reset asks Time? (4F89H-4F8DH); any other value skips the prompt. SYSTEM (TIME=ON/OFF) stores 00H or FFH here (SYS7/SYS 5397H).
42C4-42C6
DEFB 00H x 3 00 x 3
Bytes C4H-C6H: 00H. SYS0/SYS's reset does not read them.
42C7-42DB
DEFM "SunMonTueWedThuFriSat" 53 75 6E 4D 6F 6E 54 75 65 57 65 64 54 68 75 46 72 69 53 61 74
Bytes C7H-DBH: the three letter names of the days of the week, Sunday first. SYS0/SYS's reset displays the day of the boot date from here (4F56H-4F59H through 5084H, which steps 3 bytes for each day).
42DC-42FF
DEFM "JanFebMarAprMayJunJulAugSepOctNovDec" 4A 61 6E 46 65 62 4D 61 72 41 70 72 4D 61 79 4A 75 6E 4A 75 6C 41 75 67 53 65 70 4F 63 74 4E 6F 76 44 65 63
Bytes DCH-FFH: the three letter names of the months, January first. SYS0/SYS's reset displays the month of the boot date from here (4F63H-4F65H through 5084H).

Sector 3: The Copy of the Granule Allocation Table (Data)

FORMAT/CMD writes its finished image of the granule allocation table (its 6A00H-6AFFH) to sector 3 of cylinder 0 as well as to sector 0 of the directory cylinder (its 6338H-6348H); BACKUP/CMD copies it to the destination (its 6698H-66A2H, 66C7H-66D1H). The rows show each byte at 4200H plus its offset, the place the allocation table takes in the buffer at 4200H. This copy shows the diskette as FORMAT/CMD left it: 35 cylinders of 2 granules, with only BOOT/SYS and the directory cylinder in use.

4200
DEFB FDH FD
Byte 00H: the allocation byte of cylinder 0. One bit per granule, set = in use: FDH (1111 1101) has bit 0 set (granule 0, sectors 0-4, BOOT/SYS) and bit 1 clear (granule 1, sectors 5-9, free); bits 7-2 are set because a cylinder of this diskette has only 2 granules.
4201-4210
DEFB FCH x 16 FC x 16
Bytes 01H-10H: the allocation bytes of cylinders 1-16, each FCH: granules 0 and 1 free, bits 7-2 set for the granules a cylinder does not have.
4211
DEFB FFH FF
Byte 11H: the allocation byte of cylinder 17, the directory cylinder: FFH, both granules in use.
4212-4222
DEFB FCH x 17 FC x 17
Bytes 12H-22H: the allocation bytes of cylinders 18-34, each FCH: both granules free.
4223-425F
DEFB FFH x 61 FF x 61
Bytes 23H-5FH: FFH for cylinders 35-95, which this diskette does not have, so no granule there is ever free.
4260-4282
DEFB FCH x 35 FC x 35
Bytes 60H-82H: the lock out table, one byte for each of cylinders 0-34 with a bit set for each granule that cannot be used. FCH: both granules of every cylinder usable (FORMAT/CMD found no bad cylinder).
4283-42CA
DEFB FFH x 72 FF x 72
Bytes 83H-CAH: FFH for the cylinders the diskette does not have (lock out bytes 23H-5FH of the table) and for bytes C0H-CAH.
42CB
DEFB 53H 53
Byte CBH: 53H ("S"), the byte FORMAT/CMD's image carries here (its 6ACBH).
42CC
DEFB 00H 00
Byte CCH: the low byte of the configuration word, the number of cylinders less 35 (FORMAT/CMD 6310H-6315H): 00H, 35 cylinders.
42CD
DEFB 89H 89
Byte CDH: the high byte of the configuration word, 89H (1000 1001). FORMAT/CMD builds it at 6318H-6335H: bit 7 and bit 3 always set (bit 3 marks the date format of this release in the directory), bit 6 clear (single density), bit 5 clear (one side), bit 4 clear (cylinder 0 has the same density as the rest), bits 2-0 = 1: 2 granules a cylinder, less one.
42CE-42CF
DEFW 42E0H E0 42
Bytes CEH-CFH: the hash of the diskette's master password, 42E0H, the hash of PASSWORD, the default FORMAT/CMD offers (its 764CH).
42D0-42D7
DEFM "LDOS531 " 4C 44 4F 53 35 33 31 20
Bytes D0H-D7H: the diskette name, LDOS531 and one space. SYS0/SYS's reset displays the name of the diskette in drive 0 from these bytes of the allocation table on the directory cylinder, which has the same layout as this copy (4FF0H-4FF8H).
42D8-42DF
DEFM "07/14/91" 30 37 2F 31 34 2F 39 31
Bytes D8H-DFH: the date the diskette was formatted, 07/14/91. SYS0/SYS's reset displays these bytes of the allocation table on the directory cylinder next to the name (4FFAH-4FFEH).
42E0
DEFB 0DH 0D
Byte E0H: the first byte of the AUTO command field: 0DH, no AUTO command. SYS0/SYS's reset tests this byte of the allocation table on drive 0's directory cylinder (5000H-5003H for a leading 2AH, 501FH-5020H for 0DH).
42E1-42FF
DEFB 20H x 31 20 x 31
Bytes E1H-FFH: 31 spaces, the rest of the AUTO command field.

Sector 4: Not Used (Data)

Sector 4 of cylinder 0 is the last sector of BOOT/SYS (the manual's file list gives BOOT/SYS 5 records). No code reads it at boot; BACKUP/CMD copies it to the destination together with sectors 2 and 3 (its 66A5H-66B5H, 66D4H). On this diskette it is all 00H.

4200-42FF
DEFB 00H x 256 00 x 256
Bytes 00H-FFH of sector 4: 256 bytes of 00H, which nothing reads at boot.

Sector 5: Outside BOOT/SYS (Data)

The file holds two more sectors than BOOT/SYS's five: sectors 5 and 6 of cylinder 0, granule 1, which the allocation table copy in sector 3 shows as free. No code on this diskette reads them. Sector 5 holds the last 23 bytes of SYS7/SYS (its file offsets 3200H-3216H), 12 more bytes and 221 bytes of 6CH.

4200-4216
DEFB 54H, 53H, 20H, 20H, 20H, 8FH, 54H, 44H, 45H, 46H, 41H, 55H, 4CH, 52H, 52H, 00H, 04H, 01H, 00H, 02H, 02H, 00H, 00H 54 53 20 20 20 8F 54 44 45 46 41 55 4C 52 52 00 04 01 00 02 02 00 00
Bytes 00H-16H: the same 23 bytes as the end of SYS7/SYS (file offsets 3200H-3216H). They are not used here.
4217-4222
DEFB 20H, 20H, 52H, 52H, 00H, 04H, 01H, 00H, 02H, 02H, 00H, 00H 20 20 52 52 00 04 01 00 02 02 00 00
Bytes 17H-22H: 12 bytes that repeat the last 12 bytes before them with 20H 20H in place of 55H 4CH. They are not used.
4223-42FF
DEFB 6CH x 221 6C x 221
Bytes 23H-FFH: 221 bytes of 6CH. They are not used.

Sector 6: Second Part of a SOLE/CMD Boot Module (Outside BOOT/SYS, Dead Code on This Diskette)

SOLE/CMD makes a diskette boot in double density by writing a load module to sectors 5 and 6 of cylinder 0 (its 527FH-52BBH) and patching sector 0 to load it (52BEH-52D8H: Index Register IY = 421CH and the code at 4216H). Sector 6 on this diskette holds the second part of that module, byte for byte as SOLE/CMD writes it: a load block of 213 bytes for 52FCH-53D0H and the transfer address 5312H. Sector 0 is not patched and sector 5 does not hold the first part, so nothing reads this sector. The rows show the code at the addresses it would run at, 52F8H plus the offset in the sector. The module's first part (in SOLE/CMD's image at 5500H-55FBH, which it would load to 5200H-52FBH) is the double density read driver the code below calls through Index Register IY, and the routines at 52BFH and 52D1H.

52F8-52FB
DEFB 01H, D7H, FCH, 52H 01 D7 FC 52
Bytes 00H-03H of sector 6: a load record header: type 01H, length D7H (215: the address and 213 data bytes), load address 52FCH. SOLE/CMD builds it at 52A5H-52B3H.
52FC
DEFB 03H 03
Byte 04H (52FCH): 03H, the displacement byte of a JR Z,5300H at 52FBH in the module's first part, which skips the LD HL,4511H below when the drive is set to single density.
52FD
LD HL,4511H 21 11 45
Load Register Pair HL with 4511H, the geometry of a double density cylinder: Register L = 11H for byte +07H of the drive code table (highest sector 17, 18 sectors) and Register H = 45H for byte +08H (3 granules a track of 6 sectors). The code before it, in the first part, toggles bit 6 of byte +03H (the density) and loads 2409H, the single density geometry.
5300
LD (IY+07H),L FD 75 07
Store Register L (the highest sector number) into byte +07H of the drive code table at Index Register IY.
5303
LD (IY+08H),H FD 74 08
Store Register H (the granules a track and the sectors in a granule) into byte +08H of the drive code table at Index Register IY.
5306
POP HL E1
Restore Register Pair HL from the stack: the value the first part of the routine saved before it used Register Pair HL.
5307
CALL 52D1H CD D1 52
GOSUB to 52D1H, in the first part of the module (SOLE/CMD's image 55D1H): it stores 80H (double density) or A0H (single density) to 37EEH, from bit 6 of byte +03H of the drive code table.
530A
LD (IY+05H),00H FD 36 05 00
Store 00H into byte +05H of the drive code table at Index Register IY: the head is about to be on cylinder 0.
530E
LD B,08H 06 08
Load Register B with 08H, the controller command Restore (to cylinder 0) without its step rate bits.
5310
JR 52BFH 18 AD
JUMP to 52BFH in the first part of the module (SOLE/CMD's image 55BFH), which selects the drive, ORs the step rate from byte +03H of the drive code table into Register B (08H) and writes the command to 37ECH.

5312H - The Module's Loader (Transfer Address, Dead Code on This Diskette)

The transfer address of the module: the loader that finds SYS0/SYS through the directory and loads it record by record, reading every sector through the double density driver at Index Register IY. It reuses the messages of sector 0 (4229H, 4294H), which stays at 4200H.

5312
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 hold the highest sector number on a track and bits 7-5 the number of heads less one.
5315
LD D,A 57
Copy Register A (byte +07H) into Register D, kept for the head count.
5316
AND 1FH E6 1F
Mask Register A to bits 4-0: the highest sector number on a track.
5318
LD E,A 5F
Copy Register A (the highest sector number) into Register E.
5319
INC E 1C
INCrement Register E: Register E now holds the number of sectors on a track.
531A
XOR D AA
Exclusive OR Register A (bits 4-0 of byte +07H) with Register D (all of byte +07H): Register A keeps only bits 7-5, the number of heads less one.
531B
RLCA 07
Rotate Register A left one bit: first of three rotations that bring bits 7-5 down to bits 2-0.
531C
RLCA 07
Rotate Register A left one bit again: second of three rotations.
531D
RLCA 07
Rotate Register A left one bit again: Register A now holds the number of heads less one.
531E
INC A 3C
INCrement Register A: Register A now holds the number of heads.
531F
LD B,A 47
Copy Register A (the number of heads) into Register B, the count of additions below.
5320
XOR A AF
Set Register A to 00H (XOR A), the sum the loop below builds up.
5321
ADD A,E 83
ADD Register E (the sectors on a track) to Register A. 5322H loops back here.
5322
DECrement Register B (the heads left) and LOOP BACK to 5321H: Register A ends as the sectors on a cylinder (heads times sectors on a track).
5324
LD BC,5100H 01 00 51
Point Register Pair BC to 5100H, the buffer for every sector read.
5327
PUSH BC C5
Save Register Pair BC (the buffer address 5100H) to the stack.
5328
PUSH AF F5
Save Register Pair AF (Register A = the sectors on a cylinder) to the stack across the read below.
5329
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.
532C
LD E,C 59
Copy Register C (00H, the low byte of 5100H) into Register E: sector 0, the granule allocation table.
532D
GOSUB to 53C7H to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H) through the driver. The result is not tested.
5330
POP AF F1
Restore Register Pair AF from the stack: Register A = the sectors on a cylinder again.
5331
LD HL,51CDH 21 CD 51
Point Register Pair HL to 51CDH, byte CDH of the allocation table just read: the high byte of the configuration word.
5334
BIT 5,(HL) CB 6E
Test bit 5 of the configuration byte at Register Pair HL (51CDH): set when the diskette has two sides. The Z FLAG is set for one side.
5336
If the Z FLAG is set (one side), JUMP to 5339H with the sectors on a cylinder in Register A as they are.
5338
ADD A,A 87
Double Register A (ADD A,A): a diskette with two sides has twice the sectors on a cylinder.
5339
LD (53BFH),A 32 BF 53
Store Register A (the sectors on a cylinder) into the operand byte 53BFH of the SUB at 53BEH in the byte fetch.
533C
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. Register D still holds the directory cylinder.
533E
POP BC C1
Restore Register Pair BC from the stack: the buffer address 5100H.
533F
PUSH BC C5
Save Register Pair BC (5100H) to the stack again, to come back as Register Pair HL at 5343H.
5340
GOSUB to 53C7H to read the directory sector (cylinder Register D, sector Register E = 04H) into the buffer at Register Pair BC (5100H). The result is not tested.
5343
POP HL E1
Restore the buffer address from the stack into Register Pair HL: Register Pair HL = 5100H, byte 00H of SYS0/SYS's directory record.
5344
BIT 4,(HL) CB 66
Test bit 4 of the attribute byte at Register Pair HL (5100H): set when the record is in use. The Z FLAG is set when the diskette has no SYS0/SYS.
5346
If the Z FLAG is set (the record of SYS0/SYS is free), JUMP to 4229H in sector 0, which loads Register Pair HL with 42E7H and, the Z FLAG still being set, displays No System and stops.
5349
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set. The read position is set up in the alternate set, which only the byte fetch at 53B0H uses.
534A
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 (bits 7-5) and the number of granules less one (bits 4-0).
534D
LD A,H 7C
Copy Register H (byte 17H of the directory record: first granule in bits 7-5) into Register A.
534E
RLCA 07
Rotate Register A left one bit: first of three rotations that bring the first granule from bits 7-5 down to bits 2-0.
534F
RLCA 07
Rotate Register A left one bit again: second of three rotations.
5350
RLCA 07
Rotate Register A left one bit again: bits 7-5 of byte 17H are now bits 2-0 of Register A.
5351
AND 07H E6 07
Mask Register A to bits 2-0: the number of the first granule on the cylinder.
5353
LD E,A 5F
Copy Register A (the granule number) into Register E.
5354
LD A,(IY+08H) FD 7E 08
Fetch byte +08H of the drive code table at Index Register IY into Register A: bits 4-0 hold the sectors in a granule less one.
5357
AND 1FH E6 1F
Mask Register A to bits 4-0: the sectors in a granule less one.
5359
INC A 3C
INCrement Register A: Register A now holds the sectors in a granule.
535A
LD D,A 57
Copy Register A (the sectors in a granule) into Register D, the value added in the loop below.
535B
INC E 1C
INCrement Register E (the granule number): the loop below adds Register D once more than the granule number.
535C
NEG ED 44
Negate Register A: Register A = minus the sectors in a granule, so that one of the additions below is cancelled.
535E
ADD A,D 82
ADD Register D (the sectors in a granule) to Register A. 5360H loops back here.
535F
DEC E 1D
DECrement Register E, the number of additions still to make.
5360
If the NZ FLAG is set (Register E has not reached 0), LOOP BACK to 535EH. Register A ends as the granule number times the sectors in a granule: the first sector of SYS0/SYS on its cylinder.
5362
LD E,A 5F
Copy Register A (the first sector of SYS0/SYS) into Register E.
5363
LD D,L 55
Copy Register L (the cylinder of the first extent) into Register D. Register Pair DE (alternate set) holds the cylinder and sector where SYS0/SYS begins.
5364
LD BC,51FFH 01 FF 51
Load Register Pair BC with 51FFH, one byte before the buffer at 5100H, so that the first byte fetch reads the first sector.
5367
EXX D9
Exchange Register Pairs BC, DE and HL back with the alternate set. The alternate set holds the read position.
5368
GOSUB to 53B0H to fetch the next byte of SYS0/SYS into Register A: the record type. 5383H and 5391H loop back here.
536B
DEC A 3D
DECrement Register A (the record type) by 1. The Z FLAG is set when the type was 01H, a load block.
536C
If the NZ FLAG is set (the type in Register A was not 01H), JUMP to 5385H.
536E
GOSUB to 53B0H to fetch the record's length byte into Register A.
5371
LD B,A 47
Copy Register A (the record length) into Register B, the bytes of this record still to be read.
5372
GOSUB to 53B0H to fetch the low byte of the load address into Register A.
5375
LD L,A 6F
Copy Register A (the low byte of the load address) into Register L.
5376
DEC B 05
DECrement Register B (the bytes left in the record) by 1 for the low address byte.
5377
GOSUB to 53B0H to fetch the high byte of the load address into Register A.
537A
LD H,A 67
Copy Register A (the high byte of the load address) into Register H. Register Pair HL holds the load address.
537B
DEC B 05
DECrement Register B by 1 for the high address byte: Register B holds the number of data bytes (00H counts as 256).
537C
GOSUB to 53B0H to fetch the next data byte into Register A. 5381H loops back here.
537F
LD (HL),A 77
Store Register A (the data byte) at the load address in Register Pair HL.
5380
INC HL 23
INCrement Register Pair HL, the load address, to the next byte.
5381
DECrement Register B (the data bytes left) and LOOP BACK to 537CH until the block is copied.
5383
JUMP back to 5368H for the next record: the load block in Register Pair HL's range is copied.
5385
DEC A 3D
DECrement Register A again: the record type less 2. The Z FLAG is set when the type was 02H, the transfer address.
5386
If the Z FLAG is set (the type in Register A was 02H), JUMP to 5393H to take the transfer address.
5388
Any other type is passed over. GOSUB to 53B0H to fetch the record's length byte into Register A.
538B
LD B,A 47
Copy Register A (the record length) into Register B, the bytes to pass over (00H passes over 256).
538C
GOSUB to 53B0H to fetch the next byte of the record into Register A, which is not used. 538FH loops back here.
538F
DECrement Register B (the bytes left to pass over) and LOOP BACK to 538CH.
5391
JUMP back to 5368H for the next record: the passed over record changed nothing in memory.
5393
Type 02H. GOSUB to 53B0H to fetch the record's length byte into Register A; it is not used.
5396
GOSUB to 53B0H to fetch the low byte of the transfer address into Register A.
5399
LD L,A 6F
Copy Register A (the low byte of the transfer address) into Register L.
539A
GOSUB to 53B0H to fetch the high byte of the transfer address into Register A.
539D
LD H,A 67
Copy Register A (the high byte of the transfer address) into Register H. Register Pair HL holds the transfer address of SYS0/SYS.
539E
PUSH HL E5
Save Register Pair HL (the transfer address) to the stack while Register Pair HL is used for the copy below.
539F
PUSH IY FD E5
Save Index Register IY (the address of the drive code table the driver used) to the stack.
53A1
POP HL E1
Restore it into Register Pair HL: Register Pair HL = the address of that drive code table, the source of the copy.
53A2
LD DE,4700H 11 00 47
Point Register Pair DE to 4700H, drive 0's drive code table in SYS0/SYS, the destination of the copy.
53A5
LD BC,000AH 01 0A 00
Load Register Pair BC with 000AH, the 10 bytes of a drive code table.
53A8
LDIR ED B0
Copy the 10 bytes from Register Pair HL (the driver's drive code table) to Register Pair DE (4700H), counting Register Pair BC down to 0: drive 0's table now jumps to the double density driver.
53AA
POP HL E1
Restore Register Pair HL from the stack: the transfer address of SYS0/SYS.
53AB
LD IY,0000H FD 21 00 00
Load Index Register IY with 0000H, so that SYS0/SYS's reset (4E4FH-4E54H) treats the boot as one by sector 0 and keeps the drive code table just copied.
53AF
JP (HL) E9
JUMP to the address in Register Pair HL: SYS0/SYS's reset code.

53B0H - The Module's Byte Fetch (Dead Code on This Diskette)

Returns the next byte of SYS0/SYS in Register A, working in the alternate register set (Register Pair BC' = buffer pointer, Register Pair DE' = next cylinder and sector), as sector 1 does at 429DH.

53B0
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set: Register Pair BC points into the buffer and Register Pair DE holds the next cylinder and sector.
53B1
INC C 0C
INCrement Register C, the low byte of the buffer pointer in Register Pair BC. The Z FLAG is set when it wraps to 00H: the buffer is used up.
53B2
If the NZ FLAG is set (unread bytes remain at Register Pair BC), JUMP to 53C4H to fetch the byte.
53B4
PUSH BC C5
Save Register Pair BC (the buffer pointer, now 5100H) to the stack across the read.
53B5
GOSUB to 53C7H to read cylinder Register D, sector Register E into the buffer at Register Pair BC (5100H). The Z FLAG is set on return if it was read.
53B8
If the NZ FLAG is set (the read failed), JUMP to 4294H in sector 0 to display Disk Error and stop.
53BB
POP BC C1
Restore Register Pair BC (the buffer pointer, 5100H) from the stack.
53BC
INC E 1C
INCrement Register E, the sector number, to the next sector.
53BD
LD A,E 7B
Copy Register E (the next sector number) into Register A.
53BE
SUB 00H D6 00
SUBtract the sectors per cylinder from Register A (the next sector number). The operand byte 53BFH is 00H in the sector; 5339H stores the sectors per cylinder there. The Z FLAG is set when Register E has passed the last sector of the cylinder.
53C0
If the NZ FLAG is set (the next sector in Register E is still on this cylinder), JUMP to 53C4H.
53C2
LD E,A 5F
Copy Register A (00H) into Register E: sector 0 of the next cylinder.
53C3
INC D 14
INCrement Register D, the cylinder number, to the next cylinder.
53C4
LD A,(BC) 0A
Fetch the byte at Register Pair BC (the buffer pointer) into Register A: the next byte of SYS0/SYS.
53C5
EXX D9
Exchange Register Pairs BC, DE and HL back with the alternate set.
53C6
RET C9
RETurn to the caller with the byte in Register A.

53C7H - The Module's Sector Read Through the Driver (Dead Code on This Diskette)

Calls the driver at Index Register IY with the buffer address in Register Pair HL, cylinder Register D and sector Register E. No function code or drive number is loaded: the double density driver of this module only reads (SOLE/CMD's image at 5500H sets its own Register Pair BC: 5 tries, command 88H).

53C7
PUSH HL E5
Save Register Pair HL to the stack: the driver takes the buffer address in Register Pair HL.
53C8
LD H,B 60
Copy Register B (the high byte of the buffer address) into Register H.
53C9
LD L,C 69
Copy Register C (the low byte of the buffer address) into Register L. Register Pair HL holds the buffer address for the driver.
53CA
GOSUB to 53CFH, which jumps through the drive code table at Index Register IY into the driver. The driver returns here with the Z FLAG set if the sector was read.
53CD
POP HL E1
Restore Register Pair HL from the stack. POP does not change the flags.
53CE
RET C9
RETurn to the caller with the driver's flags.
53CF
JP (IY) FD E9
JUMP to the address in Index Register IY: the drive code table whose first bytes are a JP to the double density driver (SOLE/CMD's patched sector 0 sets IY to 421CH, where it stores such a table).
53D1-53D4
DEFB 02H, 02H, 12H, 53H 02 02 12 53
Bytes D9H-DCH of sector 6: the transfer address record of the module: type 02H, length 02H, address 5312H, the loader above.
53D5-53E5
DEFB 00H, 80H, 20H, 00H, 00H, 42H, 00H, 01H, 09H, 0BH, 00H, 00H, 00H, 04H, 00H, 15H, 20H 00 80 20 00 00 42 00 01 09 0B 00 00 00 04 00 15 20
Bytes DDH-EDH of sector 6: bytes after the end of the module, which no loader reads. SOLE/CMD's image ends with the transfer record (its 56D1H-56D4H), so these are what its buffer held beyond the image.
53E6-53F5
DEFB FFH x 16 FF x 16
Bytes EEH-FDH of sector 6: 16 bytes of FFH after the end of the module, not read.
53F6-53F7
DEFB 6DH, B6H 6D B6
Bytes FEH-FFH of sector 6: the last two bytes, after the end of the module, not read.