DOSPLUS 3.5 for the Model III - FORMAT/CMD Disassembled

Page Customization

Introduction/Summary

DOSPLUS 3.5 FORMAT/CMD Disassembly - The Floppy Formatter (Model III)

FORMAT/CMD is DOSPLUS's formatter of floppy diskettes, run from the DOS command level as FORMAT :d (NAME="name",DATE="date",PW="password",CYLS=n,SIDES=n,DEN="S" or "D",USE="Y"); its heading reads FORMAT - DOSPLUS Floppy formatter - 3.50. It is a load module of 10 blocks, 2474 bytes, at 5200H-5BA9H with the transfer address 5200H, after the two comment records (the name FORMAT and the copyright notice). The Model I and Model III files have the same length and differ in 45 bytes: the addresses in SYS0/SYS (DATE$, LOW$, HMEM$, SFLAG1$, DCTTBL, DISKIO%, LOCDCT%, the multiply and divide), the prompt Insert SYSTEM disk, which ends (ENTER) on the Model I and [ENTER] on the Model III, and the density taken for ENTER alone, single on the Model I and double on the Model III (5387H-53A5H). This page is the Model III one.

FORMAT makes a data diskette: it writes no boot code and no system files, only an empty directory with the entries of BOOT/SYS and DIR/SYS. It refuses a rigid drive (Drive NOT SUPPORTED!, 5293H). The track routines are the ones BACKUP/CMD uses (54F8H): the same interleave, skew and format descriptions.

The Parts of FORMAT/CMD

AddressContents
5200H-52B4HThe heading, the buffer, EVAL@, the drive, the empty GAT (5200H).
52B5H-5333HThe name, the date and the master password (52B5H).
5334H-53ACHThe cylinders, the sides and the density (5334H).
53ADH-53F1HThe drive and a diskette that holds data (53ADH).
53F2H-547CHFormat and verify (53F2H).
547DH-55B5HThe system information: the boot sectors and the directory (547DH).
55B6H-55DFHThe errors (55B6H).
55E0H-5720HA cylinder, a track, a group, a granule's verify, the geometry, the format (55E0H, 55F4H, 56B9H, 56C3H, 56E0H, 5709H).
5721H-5845HPrompts, the password code, numbers, digits, bits, texts and the system disk prompt (5721H, 575EH, 578DH, 57BFH, 5804H).
5846H-5BA9HThe directory entries, the formats and geometries, the texts, the evaluation block (5847H, 5887H, 590FH, 5B61H).

How FORMAT Works

The buffer starts at 5D00H, or at the page above LOW$ (42A7H) when that is higher, and needs 2AF6H bytes below HMEM$ (4411H) for the image of a track (else No available memory!). EVAL@ takes the drive and the parameters (524DH); EVAL@ stores each string's address, or each number, straight into the operand of an LD HL instruction (52B6H, 52D9H, 531CH, 5335H, 535EH, 5383H, 53CAH). Whatever the command line does not give is asked for: Target drivespec ? (a drive name of DCTTBL), Diskette name ? (ENTER alone gives DATA), Format date ? (only when no system date is set; ENTER alone gives 00/00/00), Master password ? (ENTER alone gives eight spaces), Number of cylinders (35-96) ? (ENTER alone gives 40), Number of sides ? (1), Single or double density ? (double density (D)). BREAK at any prompt ends FORMAT with EXIT@.

The format code (5BAEH: bit 0 double density, bit 1 an 8 inch drive, bit 2 two sides) picks the drive's geometry from the table at 58BFH (56E0H): 10 sectors a track in single density and 18 in double on a 5 inch drive (16 and 30 on an 8 inch drive). A diskette whose GAT can be read holds data: FORMAT then asks Diskette contains data, use or not ? (or takes USE=), and anything but N formats it. Every cylinder is formatted, every granule verified (DVERF) from the last cylinder down, and a granule that does not verify is locked out (53F2H). Then (547DH) the boot granule is allocated (a flawed one ends FORMAT), the directory cylinder is chosen near the middle, cylinder 0's sectors 0 and 1 get 00H, FEH and the directory cylinder (the byte the DOS's logging reads), and the directory is written with the directory's data address mark: the GAT, the HIT, the entries of BOOT/SYS and DIR/SYS and empty sectors. The prompt Insert SYSTEM disk [ENTER] is flashed at the end only when drive 0 was formatted (5804H).

Findings

FORMAT does not test EVAL@'s return code; the string parameters (USE, DATE, PW, NAME, DEN) need quotation marks and the numbers (CYLS, SIDES) must not have them (5B61H). At Diskette contains data, use or not ? the answers Y, U and F all format the diskette; only N keeps it (53DEH). The count of cylinders is taken from 20 to 96, not 35 to 96 as the prompt says, so +CCH of the GAT (the count less 35) can be below zero (534DH). The directory cylinder is searched from the middle outwards, one above, one below and so on, but the search gives up as soon as one side reaches cylinder 0 or the last cylinder, even if the other side still has a free one (5492H). The page made at 5511H-5530H (the letters DCT and the drive's geometry, as in BOOT/SYS's sector 2) is never written: the HIT is made over it at 553FH. Sector 0 of cylinder 0 holds no boot code, so the diskette cannot boot. FORMAT sets bit 0 of the drive control table's type byte (DCT+00H) for the new geometry (56E2H). An error before the drive is known leaves the prompt for the system disk to a byte the file does not load (5804H).

Differences from the Manual

The manual (Utilities, FORMAT, pages 3-27 to 3-29) agrees with the parameters, their types and abbreviations (D, P, N, C, S, DE, U) and the prompts. Its defaults differ: no name (the bytes give DATA), the date 01/01/80 (00/00/00 when no system date is set and ENTER is pressed), and a count of cylinders of 40 in its table but 35 on the Model I and 40 on the Model III in its text (the bytes give 40 on both). It says to answer Y to proceed or N to abort; U and F also proceed. It says Insert SYSTEM disk is flashed when the format is complete; the bytes show it only when drive 0 was formatted, and not while a DO file runs.

Variables

FORMAT/CMD Variables

Address
Size
Contents
5846H
1 byte
Flash state
1EH while the prompt is shown, 00H while the line is clear (5846H).
5847H-5886H
64 bytes
Directory entries
BOOT/SYS and DIR/SYS (5847H).
5B61H-5BA9H
73 bytes
Evaluation block
The block of EVAL@ and its seven parameters (5B61H).
5BAAH
1 byte
Drive
The drive to format (5BAAH).
5BABH-5BAEH
4 bytes
Format
The cylinders, the empty cylinder byte, the directory's last granule, the format code (5BABH).
5BAFH-5BB0H
2 bytes
Buffer
The start of the buffer (5BAFH).
5BB1H-5BD1H
33 bytes
Field and reply
The field block of EVAL@ and the replies (5BB1H).
5BDAH-5BF9H
32 bytes
Sector order
The sector order of a track being formatted (5BDAH).
5C00H-5CFFH
256 bytes
New GAT
The GAT of the new diskette (5C00H).

Memory Outside FORMAT/CMD

Address
Size
Contents
421AH-421CH
3 bytes
DATE$
The system date: year, day, month (52DFH).
42A7H-42A8H
2 bytes
LOW$
The lowest address free for programs (5207H).
4411H-4412H
2 bytes
HMEM$
The highest address free for programs (5224H).
4297H
1 byte
SFLAG1$
Bit 5, a DO file runs (5809H).
44E8H
32 bytes
DCTTBL
The drive names (526DH).
5D00H on
to HMEM$
Buffer
The image of a track and the sectors written (5219H).

Outside Routines

AddressContents
4479HSYS0/SYS: EVAL@ (524DH).
4488HSYS0/SYS: DISKIO% (53B3H and others).
44A3HSYS0/SYS: LOCDCT% (5299H).
4491HSYS0/SYS: 8 bit multiply (560AH, 56CAH).
4494HSYS0/SYS: 8 bit divide (54C5H, 5612H).
402DHSYS0/SYS: EXIT@ (55B3H).
4030HSYS0/SYS: ABORT@ (55DDH).
0033HROM: display a character (57E5H, 5728H, 5834H).
0040HROM: line input (5731H).
002BHROM: scan the keyboard (5827H).

Disassembly

5200H - FORMAT

FORMAT/CMD's transfer address, entered from the DOS command level with Register Pair HL at the command line after the word FORMAT: FORMAT :d (NAME="name",DATE="date",PW="password",CYLS=n,SIDES=n,DEN="S" or "D",USE="Y"). FORMAT shows its heading, sets its buffer above 5D00H, takes the drive, the diskette name, the date, the master password, the counts of cylinders and sides and the density from the command line or the prompts, checks the drive, asks before formatting a diskette that holds data, formats and verifies every cylinder (flawed granules locked out), and writes the system information: cylinder 0's sectors 0 and 1, and on a directory cylinder near the middle the GAT, the HIT, the entries of BOOT/SYS and DIR/SYS and empty directory sectors. It ends with EXIT@ (after the prompt for the system disk when drive 0 was formatted), or with an error message and ABORT@.

5200
PUSH HL E5
Save Register Pair HL, the command line pointer after FORMAT, to the top of the stack for EVAL@ below.
5201
LD HL,590FH 21 0F 59
Point Register Pair HL to 590FH, FORMAT's heading (FORMAT - DOSPLUS Floppy formatter - 3.50) and copyright line.
5204
GOSUB to 57DFH to show the text at Register Pair HL up to its ending 03H; Register A returns 03H.
5207
LD HL,(42A7H) 2A A7 42
Load Register Pair HL with LOW$ from 42A7H-42A8H, the lowest address free for programs.
520A
LD BC,5D00H 01 00 5D
Load Register Pair BC with 5D00H, the lowest address FORMAT ever uses for its buffer.
520D
OR A B7
OR Register A against itself, to clear the C FLAG for the SBC below.
520E
SBC HL,BC ED 42
SUBtract Register Pair BC (5D00H) from Register Pair HL (LOW$) with the C FLAG: the C FLAG when LOW$ is below 5D00H.
5210
If the C FLAG is set (LOW$ below 5D00H), JUMP to 5219H with Register Pair BC = 5D00H as the buffer.
5212
LD BC,(42A7H) ED 4B A7 42
Load Register Pair BC with LOW$ from 42A7H-42A8H again, for a buffer above a program in low memory.
5216
LD C,00H 0E 00
Load Register C with 00H, the start of the page that holds LOW$.
5218
INC B 04
INCrement Register B by 1: Register Pair BC is the start of the page above LOW$.
5219
LD (5BAFH),BC ED 43 AF 5B
Store Register Pair BC, the start of the buffer, into 5BAFH-5BB0H, where the track image and the sectors are made.
521D
LD HL,2AF6H 21 F6 2A
Load Register Pair HL with 2AF6H, the room the buffer needs at least (the image of a whole track).
5220
ADD HL,BC 09
ADD Register Pair BC (the buffer) to Register Pair HL: the end of that room, with the C FLAG past FFFFH.
5221
If the C FLAG is set (past the top of memory), JUMP to 55D4H for the message No available memory!.
5224
LD BC,(4411H) ED 4B 11 44
Load Register Pair BC with HMEM$ from 4411H-4412H, the highest address free for programs.
5228
SBC HL,BC ED 42
SUBtract Register Pair BC (HMEM$) from Register Pair HL (the end of the room) with the C FLAG, which is clear here.
522A
If the NC FLAG is set (the room reaches HMEM$), JUMP to 55D4H for the message No available memory!.
522D
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, to clear the values of the seven parameters below.
5230
LD (5BAAH),A 32 AA 5B
Store Register A (03H, from 57DFH) into 5BAAH, the drive, until the drive is known: no prompt for the system disk yet.
5233
LD (53CAH),HL 22 CA 53
Store Register Pair HL (0000H) into 53CAH-53CBH, the operand of LD HL at 53C9H: no USE string yet.
5236
LD (52D9H),HL 22 D9 52
Store Register Pair HL (0000H) into 52D9H-52DAH, the operand of LD HL at 52D8H: no DATE string yet.
5239
LD (531CH),HL 22 1C 53
Store Register Pair HL (0000H) into 531CH-531DH, the operand of LD HL at 531BH: no PW string yet.
523C
LD (52B6H),HL 22 B6 52
Store Register Pair HL (0000H) into 52B6H-52B7H, the operand of LD HL at 52B5H: no NAME string yet.
523F
LD (5383H),HL 22 83 53
Store Register Pair HL (0000H) into 5383H-5384H, the operand of LD HL at 5382H: no DEN string yet.
5242
LD (5335H),HL 22 35 53
Store Register Pair HL (0000H) into 5335H-5336H, the operand of LD HL at 5334H: no CYLS number yet.
5245
LD (535EH),HL 22 5E 53
Store Register Pair HL (0000H) into 535EH-535FH, the operand of LD HL at 535DH: no SIDES number yet.
5248
POP HL E1
Restore Register Pair HL, the command line pointer, from the top of the stack.
5249
LD IX,5B61H DD 21 61 5B
Point Index Register IX to 5B61H, FORMAT's evaluation block for EVAL@ (one field and seven parameters).
524D
GOSUB to 4479H, EVAL@, to take the drive and the parameters of the command line; its return code is not tested.
5250
LD A,(IX+00H) DD 7E 00
Load Register A with the flags of the evaluation block from Index Register IX+00H.
5253
AND 07H E6 07
AND Register A with 07H to keep bits 0-2: a field was given (all three fields share the block at 5BB1H).
5255
If the Z FLAG is set (no field on the command line), JUMP to 5262H to prompt for the drive.
5257
LD A,(5BB1H) 3A B1 5B
Load Register A with the flag byte of the field from 5BB1H: bit 7 a device or drive, bit 3 a drive.
525A
LD C,A 4F
Copy Register A, the field's flags, into Register C to keep them.
525B
AND C8H E6 C8
AND Register A with C8H to keep bit 7 (a device or drive), bit 6 (a name) and bit 3 (a drive).
525D
CP 88H FE 88
Compare Register A against 88H: the Z FLAG for a drive alone (bits 7 and 3, no name).
525F
LD A,C 79
Load Register A with Register C, the field's flags, whose bits 0-2 are the drive number.
5260
If the Z FLAG is set (the field is a drive), JUMP to 5293H to keep its number.
5262
LD B,02H 06 02
Load Register B with 02H, the most characters the reply to the prompt may have.
5264
LD HL,596AH 21 6A 59
Point Register Pair HL to 596AH, the prompt Target drivespec ?, followed by its count of spaces.
5267
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply into 5BB1H.
526A
GOSUB to 573AH to pad the reply at Register Pair HL (5BB1H) with spaces to 8 characters.
526D
LD IX,44E8H DD 21 E8 44
Point Index Register IX to 44E8H, DCTTBL, the table of the drives (a DCT address and a two character name).
5271
LD DE,0004H 11 04 00
Load Register Pair DE with 0004H, the length of an entry of DCTTBL.
5274
LD B,08H 06 08
Load Register B with 08H, the count of entries.
5276
LD A,(HL) 7E
Load Register A with the first character of the reply at Register Pair HL.
5277
GOSUB to 57FBH to make the character in Register A upper case.
527A
CP (IX+02H) DD BE 02
Compare Register A against the first character of the name at Index Register IX+02H.
527D
If the NZ FLAG is set (no match), JUMP to 528AH for the next entry.
527F
INC HL 23
INCrement Register Pair HL by 1, to the second character of the reply.
5280
LD A,(HL) 7E
Load Register A with the second character at Register Pair HL.
5281
GOSUB to 57FBH to make the character in Register A upper case.
5284
DEC HL 2B
DECrement Register Pair HL by 1, back to the first character of the reply.
5285
CP (IX+03H) DD BE 03
Compare Register A against the second character of the name at Index Register IX+03H.
5288
If the Z FLAG is set (the name matches), JUMP to 5290H.
528A
ADD IX,DE DD 19
ADD Register Pair DE (0004H) to Index Register IX, to the next entry of DCTTBL.
528C
DECrement Register B and, while it is not zero, JUMP to 5276H for the next entry (DJNZ).
528E
JUMP to 5262H to ask again: no drive has the name of the reply.
5290
LD A,08H 3E 08
Load Register A with 08H, the count of entries of DCTTBL.
5292
SUB B 90
SUBtract Register B (the entries left) from Register A: the drive number.
5293
AND 07H E6 07
AND Register A with 07H, to keep the drive number 0-7.
5295
LD (5BAAH),A 32 AA 5B
Store Register A, the drive to format, into 5BAAH.
5298
LD C,A 4F
Copy Register A, the drive to format, into Register C for LOCDCT%.
5299
GOSUB to 44A3H, LOCDCT%: Index Register IY = the drive control table of drive Register C.
529C
BIT 5,(IY+03H) FD CB 03 6E
Test bit 5 of DCT+03H at Index Register IY+03H, set for a rigid drive.
52A0
If the NZ FLAG is set (a rigid drive), JUMP to 55CFH for the message Drive NOT SUPPORTED!.
52A3
LD A,(IY+03H) FD 7E 03
Load Register A with the flags DCT+03H from Index Register IY+03H, bit 7 an 8 inch drive.
52A6
RLCA 07
Rotate Register A left (RLCA): the 8 inch bit to bit 0.
52A7
RLCA 07
Rotate Register A left (RLCA) again: the 8 inch bit to bit 1.
52A8
AND 02H E6 02
AND Register A with 02H, to keep the 8 inch bit of the format code.
52AA
LD (5BAEH),A 32 AE 5B
Store Register A into 5BAEH, the format code so far (bit 1 8 inch).
52AD
LD HL,5C00H 21 00 5C
Point Register Pair HL to 5C00H, the buffer of the new GAT.
52B0
LD (HL),FFH 36 FF
Store FFH at Register Pair HL: every byte of the new GAT starts as FFH.
52B2
INC L 2C
INCrement Register L by 1, to the next byte of the GAT.
52B3
If the NZ FLAG is set (not past the end of the page), JUMP to 52B0H.

52B5H - The Name, the Date and the Password

The diskette name (NAME=, else the prompt Diskette name ?, ENTER alone giving DATA) goes to +D0H of the GAT; the date (DATE=, else the system date DATE$ as MM/DD/YY, else the prompt Format date ?, ENTER alone giving 00/00/00) to +D8H; the master password (PW=, else the prompt Master password ?, ENTER alone giving 8 spaces) is hashed (575EH) into +CEH-+CFH. Each is up to 8 characters padded with spaces.

52B5
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the NAME string: 0000H unless EVAL@ stored the address here (52B6H).
52B8
LD A,H 7C
Load Register A with Register H, the high byte of the NAME string's address.
52B9
OR L B5
OR Register A with Register L: the Z FLAG when no NAME string was given.
52BA
If the NZ FLAG is set (a NAME string), JUMP to 52CDH to take up to 8 characters of it.
52BC
LD B,08H 06 08
Load Register B with 08H, the most characters the reply to the prompt may have.
52BE
LD HL,597EH 21 7E 59
Point Register Pair HL to 597EH, the prompt Diskette name ?, followed by its count of spaces.
52C1
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply; Register A its first character.
52C4
CP 0DH FE 0D
Compare Register A against 0DH: the Z FLAG when the reply is ENTER alone.
52C6
If the NZ FLAG is set (a name was typed), JUMP to 52CDH to take it.
52C8
LD B,04H 06 04
Load Register B with 04H, the length of the name DATA (not used by 573AH, which stops at the 00H after it).
52CA
LD HL,5B5DH 21 5D 5B
Point Register Pair HL to 5B5DH, the default name DATA, ended by the 00H at 5B61H.
52CD
GOSUB to 573AH to copy up to 8 characters from Register Pair HL to 5BB1H, padded with spaces; Register Pair HL = 5BB1H.
52D0
LD DE,5CD0H 11 D0 5C
Point Register Pair DE to 5CD0H, +D0H of the new GAT, the diskette name.
52D3
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the length of the name.
52D6
LDIR ED B0
Copy the name from Register Pair HL to Register Pair DE (LDIR, Register Pair BC the count).
52D8
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the DATE string: 0000H unless EVAL@ stored the address here (52D9H).
52DB
LD A,H 7C
Load Register A with Register H, the high byte of the DATE string's address.
52DC
OR L B5
OR Register A with Register L: the Z FLAG when no DATE string was given.
52DD
If the NZ FLAG is set (a DATE string), JUMP to 5310H to take up to 8 characters of it.
52DF
LD A,(421CH) 3A 1C 42
Load Register A with the month of DATE$ from 421CH.
52E2
OR A B7
OR Register A against itself: the Z FLAG for month 0, no system date.
52E3
If the Z FLAG is set (no system date), JUMP to 5304H for the prompt Format date ?.
52E5
LD HL,5BB1H 21 B1 5B
Point Register Pair HL to 5BB1H, the work area where the date is made as MM/DD/YY.
52E8
PUSH HL E5
Save Register Pair HL, the start of the date, to the top of the stack.
52E9
LD A,(421CH) 3A 1C 42
Load Register A with the month of DATE$ from 421CH.
52EC
GOSUB to 57ADH to store Register A as two decimal digits at Register Pair HL.
52EF
LD (HL),2FH 36 2F
Store 2FH, a slash, at Register Pair HL, after the month.
52F1
INC HL 23
INCrement Register Pair HL by 1, to the place of the day.
52F2
LD A,(421BH) 3A 1B 42
Load Register A with the day of DATE$ from 421BH.
52F5
GOSUB to 57ADH to store Register A as two decimal digits at Register Pair HL.
52F8
LD (HL),2FH 36 2F
Store 2FH, a slash, at Register Pair HL, after the day.
52FA
INC HL 23
INCrement Register Pair HL by 1, to the place of the year.
52FB
LD A,(421AH) 3A 1A 42
Load Register A with the year (mod 100) of DATE$ from 421AH.
52FE
GOSUB to 57ADH to store Register A as two decimal digits at Register Pair HL.
5301
POP HL E1
Restore Register Pair HL, the start of the date at 5BB1H, from the top of the stack.
5302
JUMP to 5310H to pad the date to 8 characters and keep it.
5304
LD B,08H 06 08
Load Register B with 08H, the most characters the reply to the date prompt may have.
5306
LD HL,598FH 21 8F 59
Point Register Pair HL to 598FH, the prompt Format date ?, followed by its count of spaces.
5309
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply; Register A its first character.
530C
CP 0DH FE 0D
Compare Register A against 0DH: the Z FLAG when the reply is ENTER alone.
530E
If the Z FLAG is set (no date given), JUMP to 52E5H to make the date from DATE$, which is 00/00/00.
5310
GOSUB to 573AH to copy up to 8 characters from Register Pair HL to 5BB1H, padded with spaces; Register Pair HL = 5BB1H.
5313
LD DE,5CD8H 11 D8 5C
Point Register Pair DE to 5CD8H, +D8H of the new GAT, the diskette date.
5316
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the length of the date.
5319
LDIR ED B0
Copy the date from Register Pair HL to Register Pair DE (LDIR, Register Pair BC the count).
531B
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the PW string: 0000H unless EVAL@ stored the address here (531CH).
531E
LD A,H 7C
Load Register A with Register H, the high byte of the PW string's address.
531F
OR L B5
OR Register A with Register L: the Z FLAG when no PW string was given.
5320
If the NZ FLAG is set (a PW string), JUMP to 532AH to take up to 8 characters of it.
5322
LD B,08H 06 08
Load Register B with 08H, the most characters the reply to the prompt may have.
5324
LD HL,599EH 21 9E 59
Point Register Pair HL to 599EH, the prompt Master password ?, followed by its count of spaces.
5327
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply into 5BB1H.
532A
GOSUB to 573AH to copy up to 8 characters from Register Pair HL to 5BB1H, padded with spaces; Register Pair HL = 5BB1H.
532D
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE points to the password at 5BB1H.
532E
GOSUB to 575EH to hash the 8 characters at Register Pair DE into the password code in Register Pair HL.
5331
LD (5CCEH),HL 22 CE 5C
Store Register Pair HL, the master password code, into 5CCEH-5CCFH, +CEH of the new GAT.

5334H - The Cylinders, the Sides and the Density

CYLS= (a number), else the prompt Number of cylinders (35-96) ?, ENTER alone giving 40; a value below 20 or above 96 is asked for again. SIDES=, else Number of sides ?, ENTER alone giving 1; only 1 or 2 is taken. DEN="S" or "D", else Single or double density ?, ENTER alone giving single density on the Model I and double density on the Model III. The count of cylinders goes to 5BABH and, less 35, to +CCH of the GAT; the sides and the density complete the format code 5BAEH.

5334
LD HL,0000H 21 00 00
Load Register Pair HL with the CYLS number: 0000H unless EVAL@ stored the value here (5335H).
5337
LD A,H 7C
Load Register A with Register H, the high byte of the CYLS number.
5338
OR A B7
OR Register A against itself: the NZ FLAG for a number above 255.
5339
If the NZ FLAG is set (too large), JUMP to 533EH for the prompt.
533B
OR L B5
OR Register A (00H) with Register L: Register A the CYLS number, the Z FLAG when none was given.
533C
If the NZ FLAG is set (a CYLS number), JUMP to 534DH to check it.
533E
LD B,02H 06 02
Load Register B with 02H, the most digits the reply to the prompt may have.
5340
LD HL,59B1H 21 B1 59
Point Register Pair HL to 59B1H, the prompt Number of cylinders (35-96) ?, followed by its count of spaces.
5343
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply; Register A its first character.
5346
CP 0DH FE 0D
Compare Register A against 0DH: the Z FLAG when the reply is ENTER alone.
5348
LD A,28H 3E 28
Load Register A with 28H (40), the count of cylinders for ENTER alone, without changing the flags.
534A
If the NZ FLAG is set (digits were typed), GOSUB to 578DH to read the decimal number at Register Pair HL into Register A.
534D
CP 14H FE 14
Compare Register A against 14H (20), the smallest count taken: the C FLAG below it.
534F
If the C FLAG is set (fewer than 20 cylinders), JUMP to 533EH to ask again.
5351
CP 61H FE 61
Compare Register A against 61H (97): the NC FLAG for 97 cylinders or more.
5353
If the NC FLAG is set (too many cylinders), JUMP to 533EH to ask again.
5355
LD (5BABH),A 32 AB 5B
Store Register A, the count of cylinders, into 5BABH.
5358
SUB 23H D6 23
SUBtract 23H (35) from Register A: the cylinder count less 35, as the GAT keeps it.
535A
LD (5CCCH),A 32 CC 5C
Store Register A into 5CCCH, +CCH of the new GAT.
535D
LD HL,0000H 21 00 00
Load Register Pair HL with the SIDES number: 0000H unless EVAL@ stored the value here (535EH).
5360
LD A,H 7C
Load Register A with Register H, the high byte of the SIDES number.
5361
OR A B7
OR Register A against itself: the NZ FLAG for a number above 255.
5362
If the NZ FLAG is set (too large), JUMP to 5367H for the prompt.
5364
OR L B5
OR Register A (00H) with Register L: Register A the SIDES number, the Z FLAG when none was given.
5365
If the NZ FLAG is set (a SIDES number), JUMP to 5376H to check it.
5367
LD B,02H 06 02
Load Register B with 02H, the most digits the reply to the prompt may have.
5369
LD HL,59D0H 21 D0 59
Point Register Pair HL to 59D0H, the prompt Number of sides ?, followed by its count of spaces.
536C
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply; Register A its first character.
536F
CP 0DH FE 0D
Compare Register A against 0DH: the Z FLAG when the reply is ENTER alone.
5371
LD A,01H 3E 01
Load Register A with 01H, one side for ENTER alone, without changing the flags.
5373
If the NZ FLAG is set (digits were typed), GOSUB to 578DH to read the decimal number at Register Pair HL into Register A.
5376
DEC A 3D
DECrement Register A by 1: 00H for one side, 01H for two.
5377
CP 02H FE 02
Compare Register A against 02H: the NC FLAG for anything but one or two sides.
5379
If the NC FLAG is set (not 1 or 2), JUMP to 5367H to ask again.
537B
LD HL,5BAEH 21 AE 5B
Point Register Pair HL to 5BAEH, the format code.
537E
RLCA 07
Rotate Register A left (RLCA): the sides bit to bit 1.
537F
RLCA 07
Rotate Register A left (RLCA) again: the sides bit to bit 2.
5380
OR (HL) B6
OR Register A with the format code at Register Pair HL.
5381
LD (HL),A 77
Store Register A, the format code with bit 2 for two sides, at Register Pair HL.
5382
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the DEN string: 0000H unless EVAL@ stored the address here (5383H).
5385
LD A,H 7C
Load Register A with Register H, the high byte of the DEN string's address.
5386
OR L B5
OR Register A with Register L: the Z FLAG when no DEN string was given.
5387
LD C,01H 0E 01
Load Register C with 01H, double density, the density for no answer, without changing the flags.
5389
If the NZ FLAG is set (a DEN string), JUMP to 5399H to take its first character.
538B
LD B,02H 06 02
Load Register B with 02H, the most characters the reply to the prompt may have.
538D
LD HL,59E3H 21 E3 59
Point Register Pair HL to 59E3H, the prompt Single or double density ?, followed by its count of spaces.
5390
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply; Register A its first character.
5393
CP 0DH FE 0D
Compare Register A against 0DH: the Z FLAG when the reply is ENTER alone.
5395
LD C,01H 0E 01
Load Register C with 01H, double density for ENTER alone, without changing the flags.
5397
If the Z FLAG is set (ENTER alone), JUMP to 53A7H with the density in Register C.
5399
LD A,(HL) 7E
Load Register A with the first character of the answer at Register Pair HL.
539A
GOSUB to 57FBH to make the character in Register A upper case.
539D
CP 44H FE 44
Compare Register A against 44H, a D: double density.
539F
If the Z FLAG is set (D, with Register C = 01H), JUMP to 53A7H.
53A1
CP 53H FE 53
Compare Register A against 53H, an S: single density.
53A3
If the NZ FLAG is set (neither D nor S), JUMP to 538BH to ask again.
53A5
LD C,00H 0E 00
Load Register C with 00H, single density, bit 0 of the format code clear.
53A7
LD HL,5BAEH 21 AE 5B
Point Register Pair HL to 5BAEH, the format code.
53AA
LD A,C 79
Load Register A with Register C, the density bit.
53AB
OR (HL) B6
OR Register A with the format code at Register Pair HL.
53AC
LD (HL),A 77
Store Register A, the whole format code (bit 0 density, bit 1 8 inch, bit 2 two sides), at Register Pair HL.

53ADH - The Drive and Its Diskette

DCHECK of the drive (not ready or write protected ends FORMAT). A diskette whose GAT can be read (SREAD of directory sector 0) holds data: then USE= (its first character) or the prompt Diskette contains data, use or not ? decides: N ends FORMAT; Y, U and F all go on to format it.

53AD
LD HL,5BAAH 21 AA 5B
Point Register Pair HL to 5BAAH, the drive to format.
53B0
LD C,(HL) 4E
Load Register C with the drive at Register Pair HL.
53B1
LD A,00H 3E 00
Load Register A with 00H, the function DCHECK of DISKIO%: is the drive Register C ready.
53B3
GOSUB to 4488H, DISKIO%, to check drive Register C: the C FLAG for write protect.
53B6
If the NZ FLAG is set (the drive is not ready), JUMP to 55B6H for the message Disk drive NOT READY!.
53B9
If the C FLAG is set (the diskette is write protected), JUMP to 55BBH for the message WRITE PROTECTED disk!.
53BC
LD HL,(5BAFH) 2A AF 5B
Load Register Pair HL with the start of the buffer from 5BAFH-5BB0H.
53BF
LD E,00H 1E 00
Load Register E with 00H, sector 0 of the directory cylinder, the GAT.
53C1
LD B,E 43
Load Register B with Register E (00H); SREAD does not use Register B.
53C2
LD A,06H 3E 06
Load Register A with 06H, the function SREAD of DISKIO%: read a sector of the directory cylinder.
53C4
GOSUB to 4488H, DISKIO%, to read the GAT of drive Register C to Register Pair HL.
53C7
If the NZ FLAG is set (no GAT can be read: no data), JUMP to 53F2H to format without asking.
53C9
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the USE string: 0000H unless EVAL@ stored the address here (53CAH).
53CC
LD A,H 7C
Load Register A with Register H, the high byte of the USE string's address.
53CD
OR L B5
OR Register A with Register L: the Z FLAG when no USE string was given.
53CE
If the Z FLAG is set (no USE string), JUMP to 53D6H for the prompt.
53D0
GOSUB to 573AH to copy the USE string from Register Pair HL to 5BB1H; Register Pair HL = 5BB1H.
53D3
LD A,(HL) 7E
Load Register A with the first character of the USE string at Register Pair HL.
53D4
JUMP to 53DEH to take the first character of the USE string as the answer.
53D6
LD B,03H 06 03
Load Register B with 03H, the most characters the reply to the prompt may have.
53D8
LD HL,59FFH 21 FF 59
Point Register Pair HL to 59FFH, the prompt Diskette contains data, use or not ?, followed by its count of spaces.
53DB
GOSUB to 5721H to show the prompt at Register Pair HL and take the reply; Register A its first character.
53DE
GOSUB to 57FBH to make the letter in Register A upper case.
53E1
CP 4EH FE 4E
Compare Register A against 4EH, an N: do not format the diskette.
53E3
If the Z FLAG is set (N), JUMP to 55B0H to end FORMAT without formatting.
53E6
CP 55H FE 55
Compare Register A against 55H, a U: format the diskette all the same.
53E8
If the Z FLAG is set (U), JUMP to 53F2H to format the diskette.
53EA
CP 59H FE 59
Compare Register A against 59H, a Y: format the diskette all the same.
53EC
If the Z FLAG is set (Y), JUMP to 53F2H to format the diskette.
53EE
CP 46H FE 46
Compare Register A against 46H, an F: format the diskette.
53F0
If the NZ FLAG is set (any other answer), JUMP to 53D6H to ask again.

53F2H - Format and Verify

Gives the drive the geometry of the format code (56E0H), makes the empty GAT (the empty cylinder byte 5BACH in the allocation and lock out tables for each cylinder, the version 35H at +CBH, the flags at +CDH with bit 5 for two sides, no AUTO command at +E0H), formats every cylinder (55E0H), then verifies every granule from the last cylinder down (56C3H, DVERF): a granule that cannot be verified is shown as GRAN FLAWED! Locked out! and set in both tables.

53F2
LD HL,5BAAH 21 AA 5B
Point Register Pair HL to 5BAAH, the drive to format.
53F5
LD C,(HL) 4E
Load Register C with the drive at Register Pair HL.
53F6
GOSUB to 56E0H to give drive Register C the geometry of the format code; Index Register IY is its DCT.
53F9
LD E,(IY+10H) FD 5E 10
Load Register E with the granules per cylinder from Index Register IY+10H.
53FC
LD A,FFH 3E FF
Load Register A with FFH, every granule bit set.
53FE
DEC E 1D
DECrement Register E by 1, to the last granule of a cylinder.
53FF
GOSUB to 57CFH to reset bit Register E of Register A: a granule the cylinder has.
5402
DEC E 1D
DECrement Register E by 1, to the granule before it.
5403
If the P FLAG is set (Register E not below 0), JUMP to 53FFH.
5406
LD (5BACH),A 32 AC 5B
Store Register A into 5BACH, the GAT byte of an empty cylinder (FCH for two granules a cylinder).
5409
LD HL,5BABH 21 AB 5B
Point Register Pair HL to 5BABH, the count of cylinders.
540C
LD B,(HL) 46
Load Register B with the count of cylinders at Register Pair HL.
540D
PUSH BC C5
Save Register Pair BC, the count in Register B, to the top of the stack.
540E
LD HL,5C00H 21 00 5C
Point Register Pair HL to 5C00H, the allocation table of the new GAT.
5411
LD (HL),A 77
Store Register A, the empty cylinder byte, at Register Pair HL.
5412
INC L 2C
INCrement Register L by 1, to the next cylinder.
5413
DECrement Register B and, while it is not zero, JUMP to 5411H (DJNZ).
5415
POP BC C1
Restore Register Pair BC, the count of cylinders in Register B, from the top of the stack.
5416
LD L,60H 2E 60
Load Register L with 60H: Register Pair HL = 5C60H, the lock out table of the new GAT.
5418
LD (HL),A 77
Store Register A, the empty cylinder byte, at Register Pair HL.
5419
INC L 2C
INCrement Register L by 1, to the next cylinder.
541A
DECrement Register B and, while it is not zero, JUMP to 5418H (DJNZ).
541C
LD L,CBH 2E CB
Load Register L with CBH: Register Pair HL = 5CCBH, +CBH of the new GAT.
541E
LD (HL),35H 36 35
Store 35H at Register Pair HL, the version of DOSPLUS that formatted the diskette (3.5).
5420
LD L,CDH 2E CD
Load Register L with CDH: Register Pair HL = 5CCDH, +CDH of the new GAT, the diskette's flags.
5422
LD A,(IY+0CH) FD 7E 0C
Load Register A with the count of surfaces from Index Register IY+0CH.
5425
DEC A 3D
DECrement Register A by 1: 01H for two sides.
5426
RRCA 0F
Rotate Register A right (RRCA): towards bit 5.
5427
RRCA 0F
Rotate Register A right (RRCA) again: the sides bit one place lower.
5428
RRCA 0F
Rotate Register A right (RRCA) again: 20H for two sides.
5429
LD (HL),A 77
Store Register A at Register Pair HL: bit 5 of +CDH set for a diskette with two sides.
542A
LD L,E0H 2E E0
Load Register L with E0H: Register Pair HL = 5CE0H, +E0H of the new GAT, the AUTO command.
542C
LD (HL),0DH 36 0D
Store 0DH at Register Pair HL: a carriage return first, no AUTO command.
542E
LD D,00H 16 00
Load Register D with 00H, the first cylinder to format.
5430
LD HL,5A25H 21 25 5A
Point Register Pair HL to 5A25H, the text FORMATTING that starts the line of the pass.
5433
GOSUB to 57EBH to show the text at Register Pair HL and then Cylinder with the cylinder Register D.
5436
GOSUB to 55E0H to format cylinder Register D of drive Register C, every side.
5439
If the NZ FLAG is set (a format error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
543C
INC D 14
INCrement Register D by 1, to the next cylinder.
543D
LD A,(5BABH) 3A AB 5B
Load Register A with the count of cylinders from 5BABH.
5440
DEC A 3D
DECrement Register A by 1, to the last cylinder.
5441
CP D BA
Compare Register A against Register D: the NC FLAG while Register D is not past the last.
5442
If the NC FLAG is set (more cylinders), JUMP to 5430H.
5444
LD D,A 57
Load Register D with Register A, the last cylinder: the verify goes from there down.
5445
LD L,A 6F
Load Register L with Register A, the last cylinder.
5446
LD H,5CH 26 5C
Load Register H with 5CH: Register Pair HL is the GAT byte of the last cylinder.
5448
PUSH HL E5
Save Register Pair HL to the top of the stack.
5449
POP IX DD E1
Restore Index Register IX from the top of the stack: Index Register IX = the GAT byte of the cylinder.
544B
LD HL,5A32H 21 32 5A
Point Register Pair HL to 5A32H, the text VERIFYING that starts the line of the pass.
544E
GOSUB to 57EBH to show the text at Register Pair HL and then Cylinder with the cylinder Register D.
5451
LD E,00H 1E 00
Load Register E with 00H, the first granule of the cylinder.
5453
GOSUB to 56C3H to verify every sector of granule Register E of cylinder Register D.
5456
If the Z FLAG is set (the granule verifies), JUMP to 5470H.
5458
LD HL,5B3EH 21 3E 5B
Point Register Pair HL to 5B3EH, the message GRAN FLAWED! Locked out!.
545B
GOSUB to 57DFH to show the message at Register Pair HL.
545E
LD HL,5A32H 21 32 5A
Point Register Pair HL to 5A32H, the text VERIFYING, to start the line again.
5461
GOSUB to 57EBH to show the text at Register Pair HL and then Cylinder with the cylinder Register D.
5464
LD A,(IX+00H) DD 7E 00
Load Register A with the GAT byte of the cylinder from Index Register IX+00H.
5467
GOSUB to 57BFH to set bit Register E of Register A: granule Register E is in use.
546A
LD (IX+00H),A DD 77 00
Store Register A into the allocation table at Index Register IX+00H.
546D
LD (IX+60H),A DD 77 60
Store Register A into the lock out table at Index Register IX+60H: the granule is locked out.
5470
LD A,(IY+10H) FD 7E 10
Load Register A with the granules per cylinder from Index Register IY+10H.
5473
INC E 1C
INCrement Register E by 1, to the next granule.
5474
CP E BB
Compare Register A against Register E: the Z FLAG after the last granule of the cylinder.
5475
If the NZ FLAG is set (more granules), JUMP to 5453H.
5477
DEC D 15
DECrement Register D by 1, to the cylinder below.
5478
DEC IX DD 2B
DECrement Index Register IX by 1, to that cylinder's GAT byte.
547A
If the P FLAG is set (Register D not below 0), JUMP to 544BH for the next cylinder.

547DH - The System Information

Shows Writing system information. The boot granule (granule 0 of cylinder 0) must not be flawed and is allocated. The directory cylinder is the free cylinder nearest the middle: from half the count of cylinders it tries one above, one below, two above and so on, and gives up (NO TRACK available for directory!) as soon as one side reaches cylinder 0 or the last cylinder, even if the other side still has a free cylinder. Its granules for the directory (enough for DCT+0EH sectors) are allocated. Then: cylinder 0's sectors 0 and 1 (00H, FEH, the directory cylinder, then 00H), the GAT (directory sector 0) and the HIT (sector 1, with the hash codes A2H and C4H of BOOT/SYS and DIR/SYS), the entries of BOOT/SYS (sector 2) and DIR/SYS (sector 3), and the other directory sectors filled with 00H, each directory sector with the directory's data address mark (DWRITA).

547D
LD HL,5A4CH 21 4C 5A
Point Register Pair HL to 5A4CH, the text Writing system information.
5480
GOSUB to 57DFH to show the text at Register Pair HL.
5483
LD IX,5C00H DD 21 00 5C
Point Index Register IX to 5C00H, the new GAT: cylinder 0.
5487
BIT 0,(IX+60H) DD CB 60 46
Test bit 0 of the lock out byte of cylinder 0 at Index Register IX+60H: granule 0, the boot.
548B
If the NZ FLAG is set (the boot granule is flawed), JUMP to 55C5H for the message BOOT FLAWED! routine aborted!.
548E
SET 0,(IX+00H) DD CB 00 C6
Set bit 0 of the allocation byte of cylinder 0 at Index Register IX+00H: the boot granule is in use.
5492
LD B,00H 06 00
Load Register B with 00H, the distance of the next try from the middle.
5494
LD A,(5BABH) 3A AB 5B
Load Register A with the count of cylinders from 5BABH.
5497
SRA A CB 2F
Shift Register A right arithmetically (SRA): half the count of cylinders, the middle.
5499
LD E,A 5F
Copy Register A, the middle cylinder, into Register E.
549A
LD D,5CH 16 5C
Load Register D with 5CH: Register Pair DE is the GAT byte of cylinder Register E.
549C
LD A,(5BACH) 3A AC 5B
Load Register A with the empty cylinder byte from 5BACH.
549F
LD L,A 6F
Copy Register A, the empty cylinder byte, into Register L for the compare.
54A0
LD A,(DE) 1A
Load Register A with the GAT byte of the cylinder at Register Pair DE.
54A1
CP L BD
Compare Register A against Register L: the Z FLAG for a cylinder with no granule in use or locked out.
54A2
If the Z FLAG is set (a free cylinder), JUMP to 54BDH for the directory there.
54A4
INC B 04
INCrement Register B by 1, the next distance.
54A5
LD A,B 78
Load Register A with Register B, the distance.
54A6
SRL A CB 3F
Shift Register A right (SRL): the C FLAG for an odd distance.
54A8
LD A,E 7B
Load Register A with Register E, the cylinder just tried, without changing the flags.
54A9
If the NC FLAG is set (an even distance), JUMP to 54B6H to go down.
54AB
ADD A,B 80
ADD Register B (the distance) to Register A: the next cylinder up.
54AC
LD E,A 5F
Copy Register A into Register E, the cylinder to try.
54AD
LD A,(5BABH) 3A AB 5B
Load Register A with the count of cylinders from 5BABH.
54B0
CP E BB
Compare Register A against Register E: the Z FLAG when the try is past the last cylinder.
54B1
If the NZ FLAG is set (still on the diskette), JUMP to 54A0H to try it.
54B3
JUMP to 55C0H for the message NO TRACK available for directory!.
54B6
SUB B 90
SUBtract Register B (the distance) from Register A: the next cylinder down.
54B7
LD E,A 5F
Copy Register A into Register E, the cylinder to try.
54B8
If the NZ FLAG is set (not cylinder 0), JUMP to 54A0H to try it.
54BA
JUMP to 55C0H for the message NO TRACK available for directory!.
54BD
PUSH DE D5
Save Register Pair DE, the GAT byte of the directory cylinder, to the top of the stack.
54BE
LD B,E 43
Load Register B with Register E, the directory cylinder.
54BF
LD E,(IY+0EH) FD 5E 0E
Load Register E with the directory length in sectors from Index Register IY+0EH.
54C2
LD A,(IY+0FH) FD 7E 0F
Load Register A with the sectors per granule from Index Register IY+0FH.
54C5
GOSUB to 4494H, SYS0/SYS's 8 bit divide: Register A = Register E divided by Register A, Register E = the remainder.
54C8
INC E 1C
INCrement Register E by 1, to test the remainder below.
54C9
DEC E 1D
DECrement Register E by 1: the Z FLAG when the directory fills whole granules.
54CA
If the NZ FLAG is set (a part granule more), JUMP to 54CDH with Register A the granules less 1.
54CC
DEC A 3D
DECrement Register A by 1: the number of the directory's last granule.
54CD
LD (5BADH),A 32 AD 5B
Store Register A, the last granule of the directory, into 5BADH (for DIR/SYS's entry).
54D0
LD E,A 5F
Copy Register A, the last granule, into Register E.
54D1
LD A,00H 3E 00
Load Register A with 00H, no granule bit yet.
54D3
GOSUB to 57BFH to set bit Register E of Register A: a granule of the directory.
54D6
DEC E 1D
DECrement Register E by 1, to the granule before it.
54D7
If the P FLAG is set (Register E not below 0), JUMP to 54D3H.
54DA
POP DE D1
Restore Register Pair DE, the GAT byte of the directory cylinder, from the top of the stack.
54DB
OR L B5
OR Register A with Register L, the empty cylinder byte: the bits of granules the cylinder does not have.
54DC
LD (DE),A 12
Store Register A, the directory cylinder's allocation, at Register Pair DE in the new GAT.
54DD
LD HL,(5BAFH) 2A AF 5B
Load Register Pair HL with the start of the buffer from 5BAFH-5BB0H.
54E0
LD (HL),00H 36 00
Store 00H at Register Pair HL, the first byte of cylinder 0's sector 0.
54E2
INC L 2C
INCrement Register L by 1, to the second byte.
54E3
LD (HL),FEH 36 FE
Store FEH at Register Pair HL, the second byte of the sector.
54E5
INC L 2C
INCrement Register L by 1, to the third byte.
54E6
LD (HL),B 70
Store Register B, the directory cylinder, at Register Pair HL: the byte the DOS's logging reads at +02H.
54E7
INC L 2C
INCrement Register L by 1, to the rest of the sector.
54E8
LD (HL),00H 36 00
Store 00H at Register Pair HL, the rest of the boot sector.
54EA
INC L 2C
INCrement Register L by 1, to the next byte of the sector.
54EB
If the NZ FLAG is set (not past the end of the page), JUMP to 54E8H.
54ED
PUSH BC C5
Save Register Pair BC, the directory cylinder in Register B and the drive in Register C, to the top of the stack.
54EE
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H: Register D cylinder 0, Register E sector 0.
54F1
LD HL,(5BAFH) 2A AF 5B
Load Register Pair HL with the start of the buffer from 5BAFH-5BB0H.
54F4
LD A,05H 3E 05
Load Register A with 05H, the function DWRITE of DISKIO%: write a sector.
54F6
GOSUB to 4488H, DISKIO%, to write sector Register E of cylinder Register D of drive Register C from Register Pair HL.
54F9
If the NZ FLAG is set (a write error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
54FC
LD E,01H 1E 01
Load Register E with 01H, sector 1 of cylinder 0.
54FE
LD A,05H 3E 05
Load Register A with 05H, the function DWRITE of DISKIO%: write a sector.
5500
GOSUB to 4488H, DISKIO%, to write the same bytes to sector Register E of cylinder Register D, drive Register C.
5503
If the NZ FLAG is set (a write error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
5506
POP AF F1
Restore Register Pair AF from the top of the stack: Register A = the directory cylinder (pushed as Register B).
5507
PUSH AF F5
Save Register Pair AF to the top of the stack again, for the writes of the directory.
5508
LD (IY+12H),A FD 77 12
Store Register A, the directory cylinder, into DCT+12H at Index Register IY+12H.
550B
LD A,(5BABH) 3A AB 5B
Load Register A with the count of cylinders from 5BABH.
550E
LD (IY+13H),A FD 77 13
Store Register A, the count of cylinders, into DCT+13H at Index Register IY+13H.
5511
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX), to keep them.
5512
LD HL,5B5AH 21 5A 5B
Point Register Pair HL to 5B5AH, the three letters DCT.
5515
LD DE,(5BAFH) ED 5B AF 5B
Load Register Pair DE with the start of the buffer from 5BAFH-5BB0H.
5519
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the length of DCT.
551C
LDIR ED B0
Copy the letters DCT from Register Pair HL to Register Pair DE (LDIR, Register Pair BC the count).
551E
PUSH IY FD E5
Save Index Register IY, the drive control table, to the top of the stack.
5520
PUSH DE D5
Save Register Pair DE, the buffer after DCT, to the top of the stack.
5521
LD DE,000BH 11 0B 00
Load Register Pair DE with 000BH, the offset of the drive control table's perishable bytes.
5524
ADD IY,DE FD 19
ADD Register Pair DE to Index Register IY: DCT+0BH.
5526
PUSH IY FD E5
Save Index Register IY (DCT+0BH) to the top of the stack.
5528
POP HL E1
Restore Register Pair HL from the top of the stack: Register Pair HL = DCT+0BH.
5529
POP DE D1
Restore Register Pair DE, the buffer after DCT, from the top of the stack.
552A
LD C,09H 0E 09
Load Register C with 09H: Register Pair BC = 0009H (Register B is 00H after the LDIR), the bytes DCT+0BH-DCT+13H.
552C
LDIR ED B0
Copy the nine bytes from Register Pair HL to Register Pair DE (LDIR, Register Pair BC the count), as in BOOT/SYS's sector 2.
552E
POP IY FD E1
Restore Index Register IY, the drive control table, from the top of the stack.
5530
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the drive is back; the page made here is not written.
5531
POP DE D1
Restore Register Pair DE from the top of the stack: Register D = the directory cylinder.
5532
LD HL,5C00H 21 00 5C
Point Register Pair HL to 5C00H, the new GAT.
5535
LD E,00H 1E 00
Load Register E with 00H, sector 0 of the directory cylinder.
5537
LD A,08H 3E 08
Load Register A with 08H, the function DWRITA of DISKIO%: write with the directory's data address mark.
5539
GOSUB to 4488H, DISKIO%, to write the GAT to sector Register E of cylinder Register D, drive Register C, from Register Pair HL.
553C
If the NZ FLAG is set (a write error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
553F
LD HL,(5BAFH) 2A AF 5B
Load Register Pair HL with the start of the buffer from 5BAFH-5BB0H, for the HIT (over the page just made).
5542
LD (HL),A2H 36 A2
Store A2H at Register Pair HL, the hash code of BOOT/SYS, in the HIT's first slot.
5544
INC L 2C
INCrement Register L by 1, to the second slot.
5545
LD (HL),C4H 36 C4
Store C4H at Register Pair HL, the hash code of DIR/SYS, in the HIT's second slot.
5547
INC L 2C
INCrement Register L by 1, to the rest of the HIT.
5548
LD (HL),00H 36 00
Store 00H at Register Pair HL: a free slot of the HIT.
554A
INC L 2C
INCrement Register L by 1, to the next slot of the HIT.
554B
If the NZ FLAG is set (not past the end of the page), JUMP to 5548H.
554D
LD E,01H 1E 01
Load Register E with 01H, sector 1 of the directory cylinder, the HIT.
554F
LD A,08H 3E 08
Load Register A with 08H, the function DWRITA of DISKIO%: write with the directory's data address mark.
5551
GOSUB to 4488H, DISKIO%, to write the HIT to sector Register E of cylinder Register D, drive Register C, from Register Pair HL.
5554
If the NZ FLAG is set (a write error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
5557
LD A,(IY+0FH) FD 7E 0F
Load Register A with the sectors per granule from Index Register IY+0FH: the size of BOOT/SYS.
555A
LD (585BH),A 32 5B 58
Store Register A into 585BH, the count of sectors of BOOT/SYS's entry (+14H).
555D
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX), to keep them.
555E
LD HL,5847H 21 47 58
Point Register Pair HL to 5847H, the directory entry of BOOT/SYS.
5561
LD DE,(5BAFH) ED 5B AF 5B
Load Register Pair DE with the start of the buffer from 5BAFH-5BB0H.
5565
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of an entry.
5568
LDIR ED B0
Copy the entry from Register Pair HL to Register Pair DE (LDIR, Register Pair BC the count): the first entry of sector 2.
556A
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the drive and the cylinder are back.
556B
LD E,02H 1E 02
Load Register E with 02H, sector 2 of the directory cylinder, the first sector of entries.
556D
LD A,08H 3E 08
Load Register A with 08H, the function DWRITA of DISKIO%: write with the directory's data address mark.
556F
GOSUB to 4488H, DISKIO%, to write sector Register E of cylinder Register D, drive Register C, from Register Pair HL.
5572
If the NZ FLAG is set (a write error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
5574
LD A,D 7A
Load Register A with Register D, the directory cylinder.
5575
LD (587DH),A 32 7D 58
Store Register A into 587DH, the cylinder of DIR/SYS's extent (+16H of its entry).
5578
LD A,(5BADH) 3A AD 5B
Load Register A with the directory's last granule from 5BADH.
557B
LD (587EH),A 32 7E 58
Store Register A into 587EH, +17H of DIR/SYS's entry: starting granule 0 and the count of granules less 1.
557E
LD A,(IY+0EH) FD 7E 0E
Load Register A with the directory length in sectors from Index Register IY+0EH.
5581
LD (587BH),A 32 7B 58
Store Register A into 587BH, the count of sectors of DIR/SYS's entry (+14H).
5584
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX), to keep them.
5585
LD HL,5867H 21 67 58
Point Register Pair HL to 5867H, the directory entry of DIR/SYS.
5588
LD DE,(5BAFH) ED 5B AF 5B
Load Register Pair DE with the start of the buffer from 5BAFH-5BB0H.
558C
LD BC,0020H 01 20 00
Load Register Pair BC with 0020H, the 32 bytes of an entry.
558F
LDIR ED B0
Copy the entry from Register Pair HL to Register Pair DE (LDIR, Register Pair BC the count): the first entry of sector 3.
5591
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the drive and the cylinder are back.
5592
LD E,03H 1E 03
Load Register E with 03H, sector 3 of the directory cylinder.
5594
LD A,08H 3E 08
Load Register A with 08H, the function DWRITA of DISKIO%: write with the directory's data address mark.
5596
GOSUB to 4488H, DISKIO%, to write sector Register E of cylinder Register D, drive Register C, from Register Pair HL.
5599
If the NZ FLAG is set (a write error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
559B
LD (HL),00H 36 00
Store 00H at Register Pair HL, the buffer: the other directory sectors are empty.
559D
INC L 2C
INCrement Register L by 1, to the next byte of the page.
559E
If the NZ FLAG is set (not past the end of the page), JUMP to 559BH.
55A0
LD A,(IY+0EH) FD 7E 0E
Load Register A with the directory length in sectors from Index Register IY+0EH.
55A3
INC E 1C
INCrement Register E by 1, to the next sector of the directory.
55A4
CP E BB
Compare Register A against Register E: the Z FLAG past the last sector of the directory.
55A5
If the Z FLAG is set (the directory is written), JUMP to 55B0H to end.
55A7
LD A,08H 3E 08
Load Register A with 08H, the function DWRITA of DISKIO%: write with the directory's data address mark.
55A9
GOSUB to 4488H, DISKIO%, to write the empty sector Register E of cylinder Register D, drive Register C.
55AC
If the NZ FLAG is set (a write error), JUMP to 55CAH for the message I/O ERROR! routine aborted!.
55AE
JUMP to 55A0H for the next sector of the directory.
55B0
GOSUB to 5804H to flash the prompt for the system disk when drive 0 was formatted.
55B3
JUMP to 402DH, EXIT@, back to the DOS: the diskette is formatted.

55B6H - The Errors

Each entry points Register Pair HL to its message and goes to 55D7H, which shows it, flashes the prompt for the system disk when drive 0 is the drive (5804H), and leaves by ABORT@. Every error of the format and of the writes is I/O ERROR! routine aborted!.

55B6
LD HL,5A9AH 21 9A 5A
Point Register Pair HL to 5A9AH, the message Disk drive NOT READY!.
55B9
JUMP to 55D7H to show the message, prompt for the system disk and abort.
55BB
LD HL,5AB1H 21 B1 5A
Point Register Pair HL to 5AB1H, the message WRITE PROTECTED disk!.
55BE
JUMP to 55D7H to show the message, prompt for the system disk and abort.
55C0
LD HL,5AC8H 21 C8 5A
Point Register Pair HL to 5AC8H, the message NO TRACK available for directory!.
55C3
JUMP to 55D7H to show the message, prompt for the system disk and abort.
55C5
LD HL,5AEBH 21 EB 5A
Point Register Pair HL to 5AEBH, the message BOOT FLAWED! routine aborted!.
55C8
JUMP to 55D7H to show the message, prompt for the system disk and abort.
55CA
LD HL,5B20H 21 20 5B
Point Register Pair HL to 5B20H, the message I/O ERROR! routine aborted!.
55CD
JUMP to 55D7H to show the message, prompt for the system disk and abort.
55CF
LD HL,5B0AH 21 0A 5B
Point Register Pair HL to 5B0AH, the message Drive NOT SUPPORTED!, for a rigid drive.
55D2
JUMP to 55D7H to show the message, prompt for the system disk and abort.
55D4
LD HL,5A84H 21 84 5A
Point Register Pair HL to 5A84H, the message No available memory!.
55D7
GOSUB to 57DFH to show the message at Register Pair HL up to its ending 03H.
55DA
GOSUB to 5804H to flash the prompt for the system disk when drive 0 is the drive.
55DD
JUMP to 4030H, ABORT@, back to the DOS with the abort.

55E0H - Format a Cylinder

Formats cylinder Register D of drive Register C: side 0, then side 1 for a diskette with two sides (Register E = the sectors per track, the first sector of side 1).

55E0
PUSH BC C5
Save Register Pair BC, the drive in Register C, to the top of the stack.
55E1
LD E,00H 1E 00
Load Register E with 00H, side 0 (the first sector of side 0).
55E3
GOSUB to 55F4H to format side 0 of cylinder Register D.
55E6
If the NZ FLAG is set (a format error), JUMP to 55F2H.
55E8
LD A,(IY+0CH) FD 7E 0C
Load Register A with the count of surfaces from Index Register IY+0CH.
55EB
DEC A 3D
DECrement Register A by 1: the NZ FLAG for a diskette with two sides.
55EC
LD E,(IY+0DH) FD 5E 0D
Load Register E with the sectors per track from Index Register IY+0DH, the first sector number of side 1.
55EF
If the NZ FLAG is set (two sides), GOSUB to 55F4H to format side 1 of cylinder Register D.
55F2
POP BC C1
Restore Register Pair BC, the drive in Register C, from the top of the stack.
55F3
RET C9
RETurn to the caller with the Z FLAG, or the NZ FLAG and Register A the error code.

55F4H - Make and Write a Track

Builds the image of one track in the buffer at (5BAFH) and writes it with DFORMT (function 09H), as BACKUP/CMD does: the interleave from 5709H (2 in single density, 3 in double) laid out from a place that moves by twice the interleave on each track, into the sector order at 5BDAH; the image from the format description (pairs of a count and a byte, 56B9H), each sector with its ID field (FEH, cylinder, side, sector, length code 01H, F7H for the CRC) and 256 data bytes of 6CH after FBH.

55F4
PUSH BC C5
Save Register Pair BC, the drive in Register C, to the top of the stack.
55F5
PUSH DE D5
Save Register Pair DE, the cylinder and the side's first sector, to the top of the stack.
55F6
LD B,D 42
Load Register B with Register D, the cylinder: the track number for one side.
55F7
LD A,(IY+0CH) FD 7E 0C
Load Register A with the count of surfaces from Index Register IY+0CH.
55FA
DEC A 3D
DECrement Register A by 1: the Z FLAG for a diskette with one side.
55FB
If the Z FLAG is set (one side), JUMP to 5604H with Register B the cylinder.
55FD
SLA B CB 20
Shift Register B left by one bit (SLA): twice the cylinder, the track number of side 0.
55FF
INC E 1C
INCrement Register E by 1, to test it for zero below without changing it.
5600
DEC E 1D
DECrement Register E by 1: the Z FLAG for side 0 (Register E = 00H).
5601
If the Z FLAG is set (side 0), JUMP to 5604H.
5603
INC B 04
INCrement Register B by 1: the track number of side 1.
5604
GOSUB to 5709H for the format of the track: Register A the interleave, Register Pair HL the format description.
5607
LD E,B 58
Copy Register B, the track number, into Register E for the multiply.
5608
LD B,A 47
Copy Register A, the interleave, into Register B.
5609
ADD A,A 87
ADD Register A to itself: twice the interleave.
560A
GOSUB to 4491H, SYS0/SYS's 8 bit multiply: Register A = Register A times Register E, twice the interleave times the track.
560D
LD E,A 5F
Copy Register A into Register E for the divide.
560E
LD C,(IY+0DH) FD 4E 0D
Load Register C with the sectors per track from Index Register IY+0DH.
5611
LD A,C 79
Copy Register C, the sectors per track, into Register A, the divisor.
5612
GOSUB to 4494H, SYS0/SYS's 8 bit divide: Register E = Register E divided by Register A, the remainder: the skew.
5615
LD A,E 7B
Load Register A with Register E, the starting place of the first sector on this track.
5616
LD D,B 50
Load Register D with Register B, the interleave, the step between sectors.
5617
LD HL,5BDAH 21 DA 5B
Point Register Pair HL to 5BDAH, the table of the sector order (one byte a place).
561A
LD B,C 41
Load Register B with Register C, the sectors per track, the count of places to clear.
561B
LD (HL),FFH 36 FF
Store FFH at Register Pair HL: the place is free.
561D
INC HL 23
INCrement Register Pair HL by 1, to the next place.
561E
DECrement Register B and, while it is not zero, JUMP to 561BH (DJNZ).
5620
LD E,00H 1E 00
Load Register E with 00H, the first sector number to place.
5622
LD B,C 41
Load Register B with Register C, the count of sectors to place.
5623
CP C B9
Compare Register A, the place, against Register C, the sectors per track: the C FLAG when it is on the track.
5624
If the C FLAG is set (on the track), JUMP to 5627H.
5626
SUB C 91
SUBtract Register C (the sectors per track) from Register A, to wrap the place round.
5627
PUSH DE D5
Save Register Pair DE, the sector number and the interleave, to the top of the stack.
5628
LD HL,5BDAH 21 DA 5B
Point Register Pair HL to 5BDAH, the table of the sector order.
562B
LD E,A 5F
Copy Register A, the place on the track, into Register E for the offset.
562C
LD D,00H 16 00
Load Register D with 00H: Register Pair DE is the place.
562E
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the byte of the place in the table.
562F
POP DE D1
Restore Register Pair DE, the sector number and the interleave, from the top of the stack.
5630
BIT 7,(HL) CB 7E
Test bit 7 of the place at Register Pair HL: set while the place is free (FFH).
5632
If the NZ FLAG is set (the place is free), JUMP to 5637H.
5634
INC A 3C
INCrement Register A by 1, to try the next place.
5635
JUMP to 5623H to wrap and test the next place on the track.
5637
LD (HL),E 73
Store Register E, the sector number, at the place at Register Pair HL.
5638
INC E 1C
INCrement Register E by 1, to the next sector number.
5639
ADD A,D 82
ADD Register D (the interleave) to Register A: the place of the next sector.
563A
DECrement Register B and, while it is not zero, JUMP to 5623H for the next sector (DJNZ).
563C
POP DE D1
Restore Register Pair DE, the cylinder and the side's first sector, from the top of the stack.
563D
POP BC C1
Restore Register Pair BC, the drive in Register C, from the top of the stack.
563E
PUSH BC C5
Save Register Pair BC, the drive, to the top of the stack again.
563F
PUSH DE D5
Save Register Pair DE, the cylinder and the side, to the top of the stack again.
5640
LD A,E 7B
Load Register A with Register E, the side's first sector: 00H for side 0.
5641
OR A B7
OR Register A against itself: the Z FLAG for side 0.
5642
If the Z FLAG is set (side 0), JUMP to 5646H with Register A = 00H.
5644
LD A,01H 3E 01
Load Register A with 01H, side 1, for the ID fields.
5646
LD (5678H),A 32 78 56
Store Register A, the side, into 5678H, the operand of LD (HL) at 5677H: the side byte of every ID field.
5649
LD A,D 7A
Load Register A with Register D, the cylinder.
564A
LD (5675H),A 32 75 56
Store Register A, the cylinder, into 5675H, the operand of LD (HL) at 5674H: the cylinder byte of every ID field.
564D
GOSUB to 5709H for the format description in Register Pair HL.
5650
LD C,(IY+0DH) FD 4E 0D
Load Register C with the sectors per track from Index Register IY+0DH, the count of sectors to make.
5653
LD DE,5BDAH 11 DA 5B
Point Register Pair DE to 5BDAH, the table of the sector order.
5656
PUSH DE D5
Save Register Pair DE, the place in the sector order, to the top of the stack.
5657
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE the format description.
5658
LD HL,(5BAFH) 2A AF 5B
Load Register Pair HL with the start of the buffer from 5BAFH-5BB0H, where the track image is made.
565B
GOSUB to 56B9H to store the first group of the description at Register Pair DE into the image at Register Pair HL.
565E
GOSUB to 56B9H to store the next group (the index address mark FCH).
5661
GOSUB to 56B9H to store the next group, the gap after the index address mark.
5664
LD (5669H),DE ED 53 69 56
Store Register Pair DE, the description of a sector, into 5669H-566AH, the operand of LD DE at 5668H.
5668
LD DE,0000H 11 00 00
Point Register Pair DE to the description of a sector (the operand at 5669H, set at 5664H; 0000H as loaded).
566B
GOSUB to 56B9H to store the first group of the gap before the ID field.
566E
GOSUB to 56B9H to store the second group of the gap before the ID field.
5671
LD (HL),FEH 36 FE
Store FEH at Register Pair HL, the ID address mark.
5673
INC HL 23
INCrement Register Pair HL by 1, to the cylinder byte.
5674
LD (HL),00H 36 00
Store the cylinder at Register Pair HL (00H as loaded; the operand 5675H is set at 564AH).
5676
INC HL 23
INCrement Register Pair HL by 1, to the side byte.
5677
LD (HL),00H 36 00
Store the side at Register Pair HL (00H as loaded; the operand 5678H is set at 5646H).
5679
INC HL 23
INCrement Register Pair HL by 1, to the sector byte.
567A
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL the place in the sector order.
567B
LD A,(HL) 7E
Load Register A with the sector number at Register Pair HL, the next one in the sector order.
567C
INC HL 23
INCrement Register Pair HL by 1, to the next place in the sector order.
567D
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (the Stack Pointer's word): Register Pair HL the image again.
567E
LD (HL),A 77
Store Register A, the sector number, at Register Pair HL.
567F
INC HL 23
INCrement Register Pair HL by 1, to the length byte.
5680
LD (HL),01H 36 01
Store 01H at Register Pair HL, the length code of a 256 byte sector.
5682
INC HL 23
INCrement Register Pair HL by 1, past the length byte.
5683
LD (HL),F7H 36 F7
Store F7H at Register Pair HL, the controller's code to write the two CRC bytes of the ID field.
5685
INC HL 23
INCrement Register Pair HL by 1, past the CRC code.
5686
GOSUB to 56B9H to store the first group of the gap after the ID field.
5689
GOSUB to 56B9H to store the second group of the gap after the ID field.
568C
GOSUB to 56B9H to store the third group of the gap after the ID field.
568F
LD B,80H 06 80
Load Register B with 80H, the count of the data loop: 128 passes of two bytes.
5691
LD (HL),FBH 36 FB
Store FBH at Register Pair HL, the data address mark.
5693
INC HL 23
INCrement Register Pair HL by 1, to the data of the sector.
5694
LD (HL),6CH 36 6C
Store 6CH at Register Pair HL, the byte a new sector is filled with.
5696
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the data.
5697
LD (HL),6CH 36 6C
Store 6CH at Register Pair HL, the second byte of the pass.
5699
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the data.
569A
DECrement Register B and, while it is not zero, JUMP to 5694H (DJNZ).
569C
LD (HL),F7H 36 F7
Store F7H at Register Pair HL, the controller's code to write the two CRC bytes of the data field.
569E
INC HL 23
INCrement Register Pair HL by 1, past the CRC code.
569F
GOSUB to 56B9H to store the gap after the data field.
56A2
DEC C 0D
DECrement Register C by 1, the count of sectors still to make.
56A3
If the NZ FLAG is set (more sectors), JUMP to 5668H for the next sector.
56A5
GOSUB to 56B9H to store the first group of the gap at the end of the track.
56A8
GOSUB to 56B9H to store the second group of the gap at the end of the track.
56AB
POP DE D1
Restore Register Pair DE from the top of the stack, to drop the place in the sector order.
56AC
POP DE D1
Restore Register Pair DE, the cylinder and the side's first sector, from the top of the stack.
56AD
POP BC C1
Restore Register Pair BC, the drive in Register C, from the top of the stack.
56AE
LD HL,(5BAFH) 2A AF 5B
Load Register Pair HL with the start of the buffer from 5BAFH-5BB0H, the track image.
56B1
LD B,00H 06 00
Load Register B with 00H before the call; DFORMT does not take a value in Register B.
56B3
LD A,09H 3E 09
Load Register A with 09H, the function DFORMT of DISKIO%: write a track.
56B5
GOSUB to 4488H, DISKIO%, to write the track image at Register Pair HL to cylinder Register D, side Register E, drive Register C.
56B8
RET C9
RETurn to the caller with the Z FLAG, or the NZ FLAG and Register A the error code.

56B9H - Store a Group

Takes a count and a byte from Register Pair DE (a count of 00H is 256) and stores the byte that many times at Register Pair HL; both pointers are left after them.

56B9
LD A,(DE) 1A
Load Register A with the count of the group at Register Pair DE.
56BA
INC DE 13
INCrement Register Pair DE by 1, to the byte of the group.
56BB
LD B,A 47
Copy Register A, the count of the group, into Register B for the DJNZ.
56BC
LD A,(DE) 1A
Load Register A with the byte of the group at Register Pair DE.
56BD
INC DE 13
INCrement Register Pair DE by 1, to the next group.
56BE
LD (HL),A 77
Store Register A, the byte, at Register Pair HL in the track image.
56BF
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the image.
56C0
DECrement Register B and, while it is not zero, JUMP to 56BEH (DJNZ).
56C2
RET C9
RETurn to the caller with Register Pairs DE and HL after the group.

56C3H - Verify a Granule

DVERF (function 04H) of every sector of granule Register E of cylinder Register D: the sectors are checked by the controller and not read into memory. Returns the Z FLAG, or the NZ FLAG and Register A the error code; Register Pairs BC and DE are kept.

56C3
PUSH BC C5
Save Register Pair BC, the drive in Register C, to the top of the stack.
56C4
PUSH DE D5
Save Register Pair DE, the cylinder and the granule, to the top of the stack.
56C5
LD B,(IY+0FH) FD 46 0F
Load Register B with the sectors per granule from Index Register IY+0FH, the count of sectors.
56C8
LD A,B 78
Copy Register B, the sectors per granule, into Register A for the multiply.
56C9
PUSH DE D5
Save Register Pair DE, the cylinder in Register D, to the top of the stack.
56CA
GOSUB to 4491H, SYS0/SYS's 8 bit multiply: Register A = Register A times Register E, the granule's first sector.
56CD
POP DE D1
Restore Register Pair DE, the cylinder and the granule, from the top of the stack.
56CE
LD E,A 5F
Copy Register A, the first sector of the granule, into Register E.
56CF
LD HL,(5BAFH) 2A AF 5B
Load Register Pair HL with the start of the buffer from 5BAFH-5BB0H, for DISKIO%.
56D2
LD A,04H 3E 04
Load Register A with 04H, the function DVERF of DISKIO%: verify a sector.
56D4
GOSUB to 4488H, DISKIO%, to verify sector Register E of cylinder Register D of drive Register C.
56D7
If the NZ FLAG is set (the sector does not verify), JUMP to 56DDH with Register A the error code.
56D9
INC E 1C
INCrement Register E by 1, to the next sector.
56DA
DECrement Register B and, while it is not zero, JUMP to 56CFH for the next sector (DJNZ).
56DC
XOR A AF
Load Register A with 00H by XORing it with itself, and set the Z FLAG: the granule verifies.
56DD
POP DE D1
Restore Register Pair DE, the cylinder and the granule, from the top of the stack.
56DE
POP BC C1
Restore Register Pair BC, the drive, from the top of the stack.
56DF
RET C9
RETurn to the caller with the Z FLAG, or the NZ FLAG and Register A the error code.

56E0H - Give the Drive Its Geometry

Sets bit 0 of DCT+00H and copies the nine bytes DCT+0BH-DCT+13H for the format code 5BAEH (0-7) from the table at 58BFH (10 bytes an entry) into the drive control table at Index Register IY (set by LOCDCT% at 5299H). Register Pairs BC and DE are kept.

56E0
PUSH BC C5
Save Register Pair BC, the drive, to the top of the stack.
56E1
PUSH DE D5
Save Register Pair DE to the top of the stack.
56E2
SET 0,(IY+00H) FD CB 00 C6
Set bit 0 of DCT+00H, the drive's type byte, at Index Register IY+00H.
56E6
LD A,(5BAEH) 3A AE 5B
Load Register A with the format code from 5BAEH, 0-7.
56E9
LD E,A 5F
Copy Register A, the format code, into Register E.
56EA
ADD A,A 87
ADD Register A to itself: twice the format code.
56EB
ADD A,A 87
ADD Register A to itself: four times the format code.
56EC
ADD A,E 83
ADD Register E to Register A: five times the format code.
56ED
ADD A,A 87
ADD Register A to itself: ten times the format code, the offset of its entry.
56EE
LD E,A 5F
Copy Register A, the offset, into Register E.
56EF
LD D,00H 16 00
Load Register D with 00H: Register Pair DE is the offset.
56F1
LD HL,58BFH 21 BF 58
Point Register Pair HL to 58BFH, the table of the geometries.
56F4
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the entry of the format code.
56F5
PUSH IY FD E5
Save Index Register IY, the drive control table, to the top of the stack.
56F7
LD DE,000BH 11 0B 00
Load Register Pair DE with 000BH, the offset of the drive control table's perishable bytes.
56FA
ADD IY,DE FD 19
ADD Register Pair DE to Index Register IY: DCT+0BH.
56FC
PUSH IY FD E5
Save Index Register IY (DCT+0BH) to the top of the stack.
56FE
POP DE D1
Restore Register Pair DE from the top of the stack: Register Pair DE = DCT+0BH.
56FF
LD BC,0009H 01 09 00
Load Register Pair BC with 0009H, the nine bytes DCT+0BH-DCT+13H.
5702
LDIR ED B0
Copy the nine bytes from Register Pair HL to Register Pair DE (LDIR, Register Pair BC the count).
5704
POP IY FD E1
Restore Index Register IY, the drive control table, from the top of the stack.
5706
POP DE D1
Restore Register Pair DE from the top of the stack.
5707
POP BC C1
Restore Register Pair BC, the drive, from the top of the stack.
5708
RET C9
RETurn to the caller with the drive's geometry set.

5709H - The Format of a Track

Returns Register A = the interleave and Register Pair HL = the format description, from the entry of the format code's bits 0-1 (density and 8 inch) in the table at 5887H; Register Pair DE is kept.

5709
PUSH DE D5
Save Register Pair DE to the top of the stack.
570A
LD A,(5BAEH) 3A AE 5B
Load Register A with the format code from 5BAEH.
570D
AND 03H E6 03
AND Register A with 03H to keep bit 0 (double density) and bit 1 (8 inch): the entry 0-3.
570F
LD E,A 5F
Copy Register A, the entry 0-3 of the table, into Register E.
5710
ADD A,A 87
ADD Register A to itself: twice the entry, on the way to three times.
5711
ADD A,E 83
ADD Register E to Register A: three times the entry, the offset in the table.
5712
LD E,A 5F
Copy Register A, the offset, into Register E.
5713
LD D,00H 16 00
Load Register D with 00H: Register Pair DE is the offset.
5715
LD HL,5887H 21 87 58
Point Register Pair HL to 5887H, the table of the formats, 3 bytes an entry.
5718
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the entry of the format.
5719
LD A,(HL) 7E
Load Register A with the interleave at Register Pair HL.
571A
INC HL 23
INCrement Register Pair HL by 1, to the address of the description.
571B
LD E,(HL) 5E
Load Register E with the low byte of the description's address at Register Pair HL.
571C
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
571D
LD D,(HL) 56
Load Register D with the high byte of the description's address at Register Pair HL.
571E
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL the format description.
571F
POP DE D1
Restore Register Pair DE from the top of the stack.
5720
RET C9
RETurn to the caller with Register A the interleave and Register Pair HL the description.

5721H - A Prompt and Its Reply

Shows the text at Register Pair HL up to its 03H, then as many spaces as the byte after the 03H gives, and takes a reply of up to Register B characters into 5BB1H with the ROM's line input (0040H). BREAK ends FORMAT at 55B0H, with EXIT@. Returns Register Pair HL = 5BB1H and Register A = the first character of the reply.

5721
PUSH DE D5
Save Register Pair DE to the top of the stack.
5722
GOSUB to 57DFH to show the prompt at Register Pair HL; Register Pair HL returns past its 03H.
5725
LD C,(HL) 4E
Load Register C with the count of spaces at Register Pair HL, the byte after the 03H.
5726
LD A,20H 3E 20
Load Register A with 20H, a space, to show before the reply.
5728
GOSUB to 0033H, the ROM's display of the character in Register A.
572B
DEC C 0D
DECrement Register C by 1, the count of spaces still to show.
572C
If the NZ FLAG is set (more spaces), JUMP to 5726H.
572E
LD HL,5BB1H 21 B1 5B
Point Register Pair HL to 5BB1H, the buffer for the reply.
5731
GOSUB to 0040H, the ROM's line input of up to Register B characters to Register Pair HL; the C FLAG for BREAK.
5734
POP DE D1
Restore Register Pair DE from the top of the stack.
5735
If the C FLAG is set (BREAK), JUMP to 55B0H to end FORMAT without formatting.
5738
LD A,(HL) 7E
Load Register A with the first character of the reply at Register Pair HL.
5739
RET C9
RETurn to the caller with Register A the first character and Register Pair HL = 5BB1H.

573AH - Copy Up to 8 Characters

Copies the text at Register Pair HL to 5BB1H, at most 8 characters, ending at a control character or at a double or single quotation mark (the end of a string given to a parameter), and fills the rest of the 8 with spaces. Returns Register Pair HL = 5BB1H.

573A
LD DE,5BB1H 11 B1 5B
Point Register Pair DE to 5BB1H, the place of the copy.
573D
PUSH DE D5
Save Register Pair DE, the start of the copy, to the top of the stack.
573E
LD C,08H 0E 08
Load Register C with 08H, the most characters to copy.
5740
LD A,(HL) 7E
Load Register A with the next character at Register Pair HL.
5741
LD (DE),A 12
Store Register A at Register Pair DE in the copy.
5742
CP 20H FE 20
Compare Register A against 20H, a space: the C FLAG for a control character.
5744
If the C FLAG is set (a control character), JUMP to 5755H to fill the rest with spaces.
5746
CP 22H FE 22
Compare Register A against 22H, a double quotation mark.
5748
If the Z FLAG is set (the end of a string), JUMP to 5755H to fill the rest with spaces.
574A
CP 27H FE 27
Compare Register A against 27H, a single quotation mark.
574C
If the Z FLAG is set (the end of a string), JUMP to 5755H to fill the rest with spaces.
574E
INC HL 23
INCrement Register Pair HL by 1, to the next character of the text.
574F
INC DE 13
INCrement Register Pair DE by 1, to the next place of the copy.
5750
DEC C 0D
DECrement Register C by 1, the count of characters still allowed.
5751
If the NZ FLAG is set (fewer than 8 copied), JUMP to 5740H.
5753
POP HL E1
Restore Register Pair HL, the start of the copy (5BB1H), from the top of the stack.
5754
RET C9
RETurn to the caller with Register Pair HL = 5BB1H.
5755
LD A,20H 3E 20
Load Register A with 20H, a space, to fill the rest of the copy.
5757
LD (DE),A 12
Store Register A, the space, at Register Pair DE.
5758
INC DE 13
INCrement Register Pair DE by 1, to the next place of the copy.
5759
DEC C 0D
DECrement Register C by 1, the count of places still to fill.
575A
If the NZ FLAG is set (more places), JUMP to 5757H.
575C
POP HL E1
Restore Register Pair HL, the start of the copy (5BB1H), from the top of the stack.
575D
RET C9
RETurn to the caller with Register Pair HL = 5BB1H.

575EH - The Password Code

Hashes the 8 characters at Register Pair DE (made upper case, taken from the last to the first) into the 16 bit password code in Register Pair HL, starting from FFFFH: for each character the code is mixed by shifts and XORs with the character, the same code the DOS compares with a file's or a diskette's password.

575E
LD HL,FFFFH 21 FF FF
Load Register Pair HL with FFFFH, the starting value of the code.
5761
LD B,08H 06 08
Load Register B with 08H, the count of characters.
5763
LD A,E 7B
Load Register A with Register E, the low byte of the password's address.
5764
ADD A,07H C6 07
ADD 07H to Register A: the low byte of the address of the last character.
5766
LD E,A 5F
Copy Register A, the low byte, into Register E: Register Pair DE the last character.
5767
If the NC FLAG is set (no carry), JUMP to 576AH.
5769
INC D 14
INCrement Register D by 1, for the carry: Register Pair DE points to the last character.
576A
LD A,(DE) 1A
Load Register A with the character at Register Pair DE.
576B
GOSUB to 57FBH to make the character in Register A upper case.
576E
PUSH DE D5
Save Register Pair DE, the place of the character, to the top of the stack.
576F
LD D,A 57
Load Register D with Register A, the character.
5770
LD E,H 5C
Load Register E with Register H, the high byte of the code.
5771
LD A,L 7D
Load Register A with Register L, the low byte of the code.
5772
AND 07H E6 07
AND Register A with 07H to keep its bits 0-2.
5774
RRCA 0F
Rotate Register A right (RRCA): towards bits 5-7.
5775
RRCA 0F
Rotate Register A right (RRCA) again: the bits one place lower.
5776
RRCA 0F
Rotate Register A right (RRCA) again: bits 0-2 of the low byte in bits 5-7.
5777
XOR L AD
XOR Register A with Register L, the low byte of the code.
5778
LD L,A 6F
Copy Register A, the mixed low byte, into Register L.
5779
LD H,00H 26 00
Load Register H with 00H: Register Pair HL is that byte.
577B
ADD HL,HL 29
ADD Register Pair HL to itself: the byte shifted left by 1.
577C
ADD HL,HL 29
ADD Register Pair HL to itself: shifted left by 2.
577D
ADD HL,HL 29
ADD Register Pair HL to itself: shifted left by 3.
577E
ADD HL,HL 29
ADD Register Pair HL to itself: shifted left by 4.
577F
XOR H AC
XOR Register A with Register H, the bits shifted out of the byte.
5780
XOR D AA
XOR Register A with Register D, the character.
5781
LD D,A 57
Copy Register A into Register D, the new high byte of the code.
5782
LD A,L 7D
Load Register A with Register L, the byte shifted left by 4.
5783
ADD HL,HL 29
ADD Register Pair HL to itself: shifted left by 5.
5784
XOR H AC
XOR Register A with Register H, the bits shifted out.
5785
XOR E AB
XOR Register A with Register E, the old high byte of the code.
5786
LD E,A 5F
Copy Register A into Register E, the new low byte of the code.
5787
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair HL the new code.
5788
POP DE D1
Restore Register Pair DE, the place of the character, from the top of the stack.
5789
DEC DE 1B
DECrement Register Pair DE by 1, to the character before it.
578A
DECrement Register B and, while it is not zero, JUMP to 576AH for the next character (DJNZ).
578C
RET C9
RETurn to the caller with Register Pair HL the password code.

578DH - A Decimal Number

Reads the decimal digits at Register Pair HL into Register Pair DE and returns Register A = its low byte at the first control character. Any other character ends the reading at once with Register A = that character less 30H, which the caller's range test then refuses (or not, for a value it happens to allow).

578D
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the number so far.
5790
LD A,(HL) 7E
Load Register A with the next character at Register Pair HL.
5791
CP 20H FE 20
Compare Register A against 20H, a space: the NC FLAG for a character that is not a control character.
5793
If the NC FLAG is set (not a control character), JUMP to 5797H to take it as a digit.
5795
LD A,E 7B
Load Register A with Register E, the low byte of the number.
5796
RET C9
RETurn to the caller with Register A the number.
5797
SUB 30H D6 30
SUBtract 30H from Register A: the value of a digit.
5799
RET C D8
If the C FLAG is set (below the digit 0), RETurn to the caller with Register A the character less 30H.
579A
CP 0AH FE 0A
Compare Register A against 0AH: the NC FLAG for a character above the digit 9.
579C
RET NC D0
If the NC FLAG is set (not a digit), RETurn to the caller with Register A the character less 30H.
579D
PUSH HL E5
Save Register Pair HL, the place in the text, to the top of the stack.
579E
LD H,D 62
Load Register H with Register D, the high byte of the number.
579F
LD L,E 6B
Load Register L with Register E: Register Pair HL is the number.
57A0
ADD HL,HL 29
ADD Register Pair HL to itself: twice the number.
57A1
ADD HL,HL 29
ADD Register Pair HL to itself: four times the number.
57A2
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: five times the number.
57A3
ADD HL,HL 29
ADD Register Pair HL to itself: ten times the number.
57A4
LD D,00H 16 00
Load Register D with 00H, the high byte for the digit below.
57A6
LD E,A 5F
Copy Register A, the digit, into Register E: Register Pair DE is the digit.
57A7
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the number times 10 plus the digit.
57A8
EX DE,HL EB
EXchange Register Pairs DE and HL: Register Pair DE is the number.
57A9
POP HL E1
Restore Register Pair HL, the place in the text, from the top of the stack.
57AA
INC HL 23
INCrement Register Pair HL by 1, to the next character.
57AB
JUMP to 5790H for the next character of the number.

57ADH - Two Decimal Digits

Stores Register A (0-99) at Register Pair HL as two ASCII digits, the tens first; Register Pair HL is left after them and Register Pair DE is kept.

57AD
PUSH DE D5
Save Register Pair DE to the top of the stack.
57AE
LD E,30H 1E 30
Load Register E with 30H, the ASCII digit 0, the tens.
57B0
SUB 0AH D6 0A
SUBtract 0AH (10) from Register A, one ten at a time.
57B2
If the C FLAG is set (below 0), JUMP to 57B7H.
57B4
INC E 1C
INCrement Register E by 1, the next tens digit.
57B5
JUMP to 57B0H to take off the next ten from Register A.
57B7
ADD A,3AH C6 3A
ADD 3AH to Register A: the units as an ASCII digit (10 too many were taken off).
57B9
LD (HL),E 73
Store Register E, the tens digit, at Register Pair HL.
57BA
INC HL 23
INCrement Register Pair HL by 1, to the place of the units.
57BB
LD (HL),A 77
Store Register A, the units digit, at Register Pair HL.
57BC
INC HL 23
INCrement Register Pair HL by 1, past the two digits.
57BD
POP DE D1
Restore Register Pair DE from the top of the stack.
57BE
RET C9
RETurn to the caller with Register Pair HL after the digits.

57BFH - Set or Reset Bit E

57BFH sets bit Register E (0-7) of Register A and 57CFH resets it: each stores the bit number into the second byte of its SET or RES instruction (57CDH, 57DDH) and then runs it.

57BF
PUSH AF F5
Save Register Pair AF, the byte, to the top of the stack.
57C0
LD A,E 7B
Load Register A with Register E, the bit number.
57C1
AND 07H E6 07
AND Register A with 07H, to keep the bit number 0-7.
57C3
RLCA 07
Rotate Register A left (RLCA): the bit number towards bits 3-5.
57C4
RLCA 07
Rotate Register A left (RLCA) again: the bit number one place higher.
57C5
RLCA 07
Rotate Register A left (RLCA) again: the bit number in bits 3-5.
57C6
OR C7H F6 C7
OR Register A with C7H: the second byte of SET n,A.
57C8
LD (57CDH),A 32 CD 57
Store Register A into 57CDH, the second byte of the SET instruction at 57CCH.
57CB
POP AF F1
Restore Register Pair AF, the byte, from the top of the stack.
57CC
SET 0,A CB C7
Set the bit of Register A that 57C8H stored (SET 0,A as loaded): bit Register E.
57CE
RET C9
RETurn to the caller with Register A the byte with the bit set.
57CF
PUSH AF F5
Save Register Pair AF, the byte, to the top of the stack.
57D0
LD A,E 7B
Load Register A with Register E, the bit number.
57D1
AND 07H E6 07
AND Register A with 07H, to keep the bit number 0-7.
57D3
RLCA 07
Rotate Register A left (RLCA): the bit number towards bits 3-5.
57D4
RLCA 07
Rotate Register A left (RLCA) again: the bit number one place higher.
57D5
RLCA 07
Rotate Register A left (RLCA) again: the bit number in bits 3-5.
57D6
OR 87H F6 87
OR Register A with 87H: the second byte of RES n,A.
57D8
LD (57DDH),A 32 DD 57
Store Register A into 57DDH, the second byte of the RES instruction at 57DCH.
57DB
POP AF F1
Restore Register Pair AF, the byte, from the top of the stack.
57DC
RES 0,A CB 87
Reset the bit of Register A that 57D8H stored (RES 0,A as loaded): bit Register E.
57DE
RET C9
RETurn to the caller with Register A the byte with the bit reset.

57DFH - Show a Text

Shows the characters at Register Pair HL with the ROM's 0033H until the 03H that ends the text. Returns Register Pair HL past the 03H and Register A = 03H; Register Pair DE is kept.

57DF
LD A,(HL) 7E
Load Register A with the next character at Register Pair HL.
57E0
INC HL 23
INCrement Register Pair HL by 1, past the character.
57E1
CP 03H FE 03
Compare Register A against 03H, the end of the text.
57E3
RET Z C8
If the Z FLAG is set (the end), RETurn to the caller.
57E4
PUSH DE D5
Save Register Pair DE to the top of the stack.
57E5
GOSUB to 0033H, the ROM's display of the character in Register A.
57E8
POP DE D1
Restore Register Pair DE from the top of the stack.
57E9
JUMP to 57DFH for the next character of the text at Register Pair HL.

57EBH - Show a Pass and the Cylinder

Shows the text of the pass at Register Pair HL (a carriage return and a cursor up start it, so the line is written over), then Cylinder and the cylinder Register D in two decimal digits (stored over the 00 at 5A49H).

57EB
GOSUB to 57DFH to show the text of the pass at Register Pair HL.
57EE
LD A,D 7A
Load Register A with Register D, the cylinder.
57EF
LD HL,5A49H 21 49 5A
Point Register Pair HL to 5A49H, the two digits of the cylinder in the text Cylinder 00.
57F2
GOSUB to 57ADH to store Register A as two decimal digits at Register Pair HL.
57F5
LD HL,5A3FH 21 3F 5A
Point Register Pair HL to 5A3FH, the text Cylinder with the cylinder's digits.
57F8
JUMP to 57DFH to show the text at Register Pair HL and return.

57FBH - Upper Case

Makes a lower case letter in Register A upper case; any other character is left as it is.

57FB
CP 61H FE 61
Compare Register A against 61H, a lower case a: the C FLAG below it.
57FD
RET C D8
If the C FLAG is set (not a lower case letter), RETurn to the caller.
57FE
CP 7BH FE 7B
Compare Register A against 7BH, the character after a lower case z.
5800
RET NC D0
If the NC FLAG is set (above z), RETurn to the caller.
5801
AND 5FH E6 5F
AND Register A with 5FH, to make the letter upper case.
5803
RET C9
RETurn to the caller with Register A the upper case letter.

5804H - The Prompt for the System Disk

Only when the drive (5BAAH) is drive 0 and no DO file runs (bit 5 of SFLAG1$): flashes Insert SYSTEM disk [ENTER] until a key is pressed, 500 scans of the keyboard with the text shown and 500 with the line cleared. 5BAAH holds 03H from 5230H until the drive is known; for No available memory!, found before that, it is a byte the file does not load.

5804
LD A,(5BAAH) 3A AA 5B
Load Register A with the drive from 5BAAH, to test for drive 0.
5807
OR A B7
OR Register A against itself: the Z FLAG for drive 0.
5808
RET NZ C0
If the NZ FLAG is set (not drive 0), RETurn to the caller without a prompt.
5809
LD A,(4297H) 3A 97 42
Load Register A with SFLAG1$ from 4297H, the system flags.
580C
AND 20H E6 20
AND Register A with 20H to keep bit 5, a DO file is running.
580E
RET NZ C0
If the NZ FLAG is set (a DO file runs), RETurn to the caller without waiting.
580F
LD HL,5A69H 21 69 5A
Point Register Pair HL to 5A69H, the prompt Insert SYSTEM disk [ENTER].
5812
LD BC,01F4H 01 F4 01
Load Register Pair BC with 01F4H, the 500 scans of the keyboard of each half of the flash.
5815
PUSH HL E5
Save Register Pair HL, the prompt, to the top of the stack.
5816
LD A,(5846H) 3A 46 58
Load Register A with the flash state from 5846H: 1EH while the prompt is shown.
5819
XOR 1EH EE 1E
XOR Register A with 1EH: 00H with the Z FLAG when the prompt is shown, else 1EH.
581B
PUSH AF F5
Save Register Pair AF, the new state, to the top of the stack.
581C
If the Z FLAG is set (the prompt is shown), GOSUB to 5834H to clear the line.
581F
POP AF F1
Restore Register Pair AF, the new state, from the top of the stack.
5820
LD (5846H),A 32 46 58
Store Register A, the new flash state (00H or 1EH), into 5846H.
5823
If the NZ FLAG is set (the line was clear), GOSUB to 57DFH to show the prompt at Register Pair HL.
5826
POP HL E1
Restore Register Pair HL, the prompt, from the top of the stack.
5827
GOSUB to 002BH, the ROM's scan of the keyboard: Register A the key, or 00H.
582A
OR A B7
OR Register A against itself: the NZ FLAG when a key is pressed.
582B
If the NZ FLAG is set (a key), JUMP to 5834H to clear the line and return.
582D
DEC BC 0B
DECrement Register Pair BC by 1, the count of scans.
582E
LD A,B 78
Load Register A with Register B, the high byte of the count.
582F
OR C B1
OR Register A with Register C: the Z FLAG when the count is out.
5830
If the NZ FLAG is set (more scans), JUMP to 5827H.
5832
JUMP to 5812H for the next half of the flash of the prompt.

5834H - Clear the Line

Shows a carriage return, a cursor up (1BH) and an erase to the end of the line (1EH): the line of the cursor is cleared and the cursor is at its start. Sets the flash state 5846H to 1EH.

5834
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, to the start of a new line.
5836
GOSUB to 0033H, the ROM's display of the character in Register A.
5839
LD A,1BH 3E 1B
Load Register A with 1BH, the cursor up a line, back to the line of the prompt.
583B
GOSUB to 0033H, the ROM's display of the character in Register A.
583E
LD A,1EH 3E 1E
Load Register A with 1EH, the erase to the end of the line.
5840
LD (5846H),A 32 46 58
Store Register A (1EH) into 5846H, the flash state, as if the prompt were shown.
5843
JUMP to 0033H, the ROM's display of the character in Register A, which returns to the caller.
5846
DEFB 1EH 1E
The flash state of 5804H: 1EH while the prompt is shown (and as loaded), 00H while the line is clear.

5847H - The Directory Entries

Data: the two 32 byte directory entries FORMAT writes, BOOT/SYS's in directory sector 2 and DIR/SYS's in sector 3 (5557H-5581H fill in the counts and DIR/SYS's extent).

5847
DEFB 5FH 5F
BOOT/SYS +00H, the flags: bit 6 a system file, bit 4 active, bit 3 invisible, protection level 7.
5848-584B
DEFB 00H,00H,00H,00H 00 00 00 00
BOOT/SYS +01H-+04H: no date, the end of file byte 00H, the record length 00H (256).
584C-5856
DEFM "BOOT SYS" 42 4F 4F 54 20 20 20 20 53 59 53
BOOT/SYS +05H-+0FH: the name padded to 8 characters and the extension.
5857-5858
DEFW 23DDH DD 23
BOOT/SYS +10H: a password code, 23DDH (the bytes DDH 23H).
5859-585A
DEFW 23DDH DD 23
BOOT/SYS +12H: the other password code, 23DDH.
585B-585C
DEFW 0000H 00 00
BOOT/SYS +14H: the count of sectors, set to the sectors per granule at 555AH.
585D-585E
DEFB 00H,00H 00 00
BOOT/SYS +16H: the extent, cylinder 0 from granule 0, one granule.
585F-5866
DEFB FFH,FFH,FFH,FFH,FFH,FFH,FFH,FFH FF FF FF FF FF FF FF FF
BOOT/SYS +18H-+1FH: no more extents and the end of the entry.
5867
DEFB 5DH 5D
DIR/SYS +00H, the flags: bit 6 a system file, bit 4 active, bit 3 invisible, protection level 5.
5868-586B
DEFB 00H,00H,00H,00H 00 00 00 00
DIR/SYS +01H-+04H: no date, the end of file byte 00H, the record length 00H (256).
586C-5876
DEFM "DIR SYS" 44 49 52 20 20 20 20 20 53 59 53
DIR/SYS +05H-+0FH: the name padded to 8 characters and the extension.
5877-5878
DEFW 23DDH DD 23
DIR/SYS +10H: a password code, 23DDH (the bytes DDH 23H).
5879-587A
DEFW 4296H 96 42
DIR/SYS +12H: the other password code, 4296H.
587B-587C
DEFW 0000H 00 00
DIR/SYS +14H: the count of sectors, set to the directory length at 5581H.
587D-587E
DEFB 00H,00H 00 00
DIR/SYS +16H: the extent, set to the directory cylinder (5575H) and the granules less 1 (557BH).
587F-5886
DEFB FFH,FFH,FFH,FFH,FFH,FFH,FFH,FFH FF FF FF FF FF FF FF FF
DIR/SYS +18H-+1FH: no more extents and the end of the entry.

5887H - The Formats and the Geometries

Data: the table of 5709H (an interleave and the address of a format description for each value of the format code's bits 0-1), the two format descriptions (pairs of a count and a byte for 56B9H, a count of 00H being 256), and the table of 56E0H: for each format code 0-7 the ten bytes DCT+0BH-DCT+14H (density, surfaces, sectors a track, directory length, sectors a granule, granules a cylinder, sectors a cylinder, then FFH), of which nine are copied.

5887
DEFB 02H 02
Entry 0, single density 5 inch: the interleave 2.
5888-5889
DEFW 5893H 93 58
Entry 0: the single density format description at 5893H.
588A
DEFB 03H 03
Entry 1, double density 5 inch: the interleave 3.
588B-588C
DEFW 58A9H A9 58
Entry 1: the double density format description at 58A9H.
588D
DEFB 03H 03
Entry 2, single density 8 inch: the interleave 3.
588E-588F
DEFW 5893H 93 58
Entry 2: the single density format description at 5893H.
5890
DEFB 03H 03
Entry 3, double density 8 inch: the interleave 3.
5891-5892
DEFW 58A9H A9 58
Entry 3: the double density format description at 58A9H.
5893-5894
DEFB 0BH,FFH 0B FF
Single density: 11 bytes of FFH at the start of the track.
5895-5896
DEFB 01H,FCH 01 FC
Single density: one byte FCH, the controller writes it as the index address mark.
5897-5898
DEFB 14H,FFH 14 FF
Single density: 20 bytes of FFH after the index address mark.
5899-589A
DEFB 03H,00H 03 00
Single density, each sector (5669H): 3 bytes of 00H before the ID field.
589B-589C
DEFB 03H,00H 03 00
Single density: 3 more bytes of 00H before the ID field.
589D-589E
DEFB 0BH,FFH 0B FF
Single density: 11 bytes of FFH after the ID field.
589F-58A0
DEFB 03H,00H 03 00
Single density: 3 bytes of 00H before the data field.
58A1-58A2
DEFB 03H,00H 03 00
Single density: 3 more bytes of 00H before the data field.
58A3-58A4
DEFB 0BH,FFH 0B FF
Single density: 11 bytes of FFH after the data field.
58A5-58A6
DEFB 00H,FFH 00 FF
Single density: 256 bytes of FFH at the end of the track.
58A7-58A8
DEFB 00H,FFH 00 FF
Single density: 256 more bytes of FFH at the end of the track.
58A9-58AA
DEFB 16H,4EH 16 4E
Double density: 22 bytes of 4EH at the start of the track.
58AB-58AC
DEFB 01H,FCH 01 FC
Double density: one byte FCH, the controller writes it as the index address mark.
58AD-58AE
DEFB 28H,4EH 28 4E
Double density: 40 bytes of 4EH after the index address mark.
58AF-58B0
DEFB 08H,00H 08 00
Double density, each sector (5669H): 8 bytes of 00H before the ID field.
58B1-58B2
DEFB 03H,F5H 03 F5
Double density: 3 bytes of F5H, the controller's code for the A1H sync bytes.
58B3-58B4
DEFB 16H,4EH 16 4E
Double density: 22 bytes of 4EH after the ID field.
58B5-58B6
DEFB 0CH,00H 0C 00
Double density: 12 bytes of 00H before the data field.
58B7-58B8
DEFB 03H,F5H 03 F5
Double density: 3 bytes of F5H, the A1H sync bytes of the data field.
58B9-58BA
DEFB 18H,4EH 18 4E
Double density: 24 bytes of 4EH after the data field.
58BB-58BC
DEFB 00H,4EH 00 4E
Double density: 256 bytes of 4EH at the end of the track.
58BD-58BE
DEFB 00H,4EH 00 4E
Double density: 256 more bytes of 4EH at the end of the track.
58BF-58C8
DEFB 40H,01H,0AH,0AH,05H,02H,0AH,FFH,FFH,FFH 40 01 0A 0A 05 02 0A FF FF FF
Code 0, single density 5 inch, one side: 10 sectors a track, a directory of 10 sectors, 5 a granule, 2 granules a cylinder.
58C9-58D2
DEFB C0H,01H,12H,12H,06H,03H,12H,FFH,FFH,FFH C0 01 12 12 06 03 12 FF FF FF
Code 1, double density 5 inch, one side: 18 sectors a track, a directory of 18 sectors, 6 a granule, 3 granules a cylinder.
58D3-58DC
DEFB 40H,01H,10H,10H,04H,04H,10H,FFH,FFH,FFH 40 01 10 10 04 04 10 FF FF FF
Code 2, single density 8 inch, one side: 16 sectors a track, a directory of 16 sectors, 4 a granule, 4 granules a cylinder.
58DD-58E6
DEFB C0H,01H,1EH,1EH,05H,06H,1EH,FFH,FFH,FFH C0 01 1E 1E 05 06 1E FF FF FF
Code 3, double density 8 inch, one side: 30 sectors a track, a directory of 30 sectors, 5 a granule, 6 granules a cylinder.
58E7-58F0
DEFB 40H,02H,0AH,0AH,05H,04H,14H,FFH,FFH,FFH 40 02 0A 0A 05 04 14 FF FF FF
Code 4, single density 5 inch, two sides: 10 sectors a track, 20 a cylinder, 5 a granule, 4 granules a cylinder.
58F1-58FA
DEFB C0H,02H,12H,12H,06H,06H,24H,FFH,FFH,FFH C0 02 12 12 06 06 24 FF FF FF
Code 5, double density 5 inch, two sides: 18 sectors a track, 36 a cylinder, 6 a granule, 6 granules a cylinder.
58FB-5904
DEFB 40H,02H,10H,10H,08H,04H,20H,FFH,FFH,FFH 40 02 10 10 08 04 20 FF FF FF
Code 6, single density 8 inch, two sides: 16 sectors a track, 32 a cylinder, 8 a granule, 4 granules a cylinder.
5905-590E
DEFB C0H,02H,1EH,1EH,0AH,06H,3CH,FFH,FFH,FFH C0 02 1E 1E 0A 06 3C FF FF FF
Code 7, double density 8 inch, two sides: 30 sectors a track, 60 a cylinder, 10 a granule, 6 granules a cylinder.

590FH - The Texts

Data: the heading, the prompts (each followed by its 03H and the count of spaces 5721H shows after it), the texts of the passes and the messages, each ended by 03H for 57DFH.

590F-5936
DEFM "FORMAT - DOSPLUS Floppy formatter - 3.50" 46 4F 52 4D 41 54 20 2D 20 44 4F 53 50 4C 55 53 20 46 6C 6F 70 70 79 20 66 6F 72 6D 61 74 74 65 72 20 2D 20 33 2E 35 30
The heading shown at the start (5201H), version 3.50 (no patch in this file).
5937
DEFB 0DH 0D
The carriage return that ends the heading's first line.
5938-5966
DEFM "(c) Copyright 1983, Micro-Systems Software Inc." 28 63 29 20 43 6F 70 79 72 69 67 68 74 20 31 39 38 33 2C 20 4D 69 63 72 6F 2D 53 79 73 74 65 6D 73 20 53 6F 66 74 77 61 72 65 20 49 6E 63 2E
The copyright line of the heading, the second line shown at the start.
5967-5969
DEFB 0DH,0DH,03H 0D 0D 03
Two carriage returns (an empty line after the heading) and the 03H that ends it.
596A-597B
DEFM "Target drivespec ?" 54 61 72 67 65 74 20 64 72 69 76 65 73 70 65 63 20 3F
The prompt for the drive to format (5264H), when the command line has none.
597C-597D
DEFB 03H,0CH 03 0C
The 03H that ends the prompt, and 12 spaces before the reply.
597E-598C
DEFM "Diskette name ?" 44 69 73 6B 65 74 74 65 20 6E 61 6D 65 20 3F
The prompt for the diskette name (52BEH), when NAME is not given.
598D-598E
DEFB 03H,0FH 03 0F
The 03H that ends the prompt, and 15 spaces before the reply.
598F-599B
DEFM "Format date ?" 46 6F 72 6D 61 74 20 64 61 74 65 20 3F
The prompt for the date (5306H), when DATE is not given and no system date is set.
599C-599D
DEFB 03H,11H 03 11
The 03H that ends the prompt, and 17 spaces before the reply.
599E-59AE
DEFM "Master password ?" 4D 61 73 74 65 72 20 70 61 73 73 77 6F 72 64 20 3F
The prompt for the master password (5324H), when PW is not given.
59AF-59B0
DEFB 03H,0DH 03 0D
The 03H that ends the prompt, and 13 spaces before the reply.
59B1-59CD
DEFM "Number of cylinders (35-96) ?" 4E 75 6D 62 65 72 20 6F 66 20 63 79 6C 69 6E 64 65 72 73 20 28 33 35 2D 39 36 29 20 3F
The prompt for the count of cylinders (5340H); 20 to 96 are taken.
59CE-59CF
DEFB 03H,01H 03 01
The 03H that ends the prompt, and 1 space before the reply.
59D0-59E0
DEFM "Number of sides ?" 4E 75 6D 62 65 72 20 6F 66 20 73 69 64 65 73 20 3F
The prompt for the count of sides (5369H), when SIDES is not given.
59E1-59E2
DEFB 03H,0DH 03 0D
The 03H that ends the prompt, and 13 spaces before the reply.
59E3-59FC
DEFM "Single or double density ?" 53 69 6E 67 6C 65 20 6F 72 20 64 6F 75 62 6C 65 20 64 65 6E 73 69 74 79 20 3F
The prompt for the density (538DH), when DEN is not given.
59FD-59FE
DEFB 03H,04H 03 04
The 03H that ends the prompt, and 4 spaces before the reply.
59FF-5A22
DEFM "Diskette contains data, use or not ?" 44 69 73 6B 65 74 74 65 20 63 6F 6E 74 61 69 6E 73 20 64 61 74 61 2C 20 75 73 65 20 6F 72 20 6E 6F 74 20 3F
The prompt for a diskette whose GAT can be read (53D8H).
5A23-5A24
DEFB 03H,01H 03 01
The 03H that ends the prompt, and 1 space before the reply.
5A25-5A26
DEFB 0DH,1BH 0D 1B
A carriage return and a cursor up: the line of the pass is written over.
5A27-5A30
DEFM "FORMATTING" 46 4F 52 4D 41 54 54 49 4E 47
The text of the format pass (5430H), 10 characters like the others.
5A31
DEFB 03H 03
The 03H that ends the text FORMATTING for 57DFH.
5A32-5A33
DEFB 0DH,1BH 0D 1B
A carriage return and a cursor up: the line of the pass is written over.
5A34-5A3D
DEFM "VERIFYING " 56 45 52 49 46 59 49 4E 47 20
The text of the verify pass (544BH), padded with a space to 10 characters.
5A3E
DEFB 03H 03
The 03H that ends the text VERIFYING for 57DFH.
5A3F-5A4A
DEFM " Cylinder 00" 20 43 79 6C 69 6E 64 65 72 20 30 30
The cylinder after the text of a pass (57F5H); its two digits 5A49H-5A4AH are set by 57F2H.
5A4B
DEFB 03H 03
The 03H that ends the text Cylinder and its two digits.
5A4C
DEFB 0DH 0D
The carriage return that starts the text Writing system information.
5A4D-5A66
DEFM "Writing system information" 57 72 69 74 69 6E 67 20 73 79 73 74 65 6D 20 69 6E 66 6F 72 6D 61 74 69 6F 6E
The text shown before the boot sectors and the directory are written (547DH).
5A67-5A68
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the text.
5A69-5A82
DEFM "Insert SYSTEM disk [ENTER]" 49 6E 73 65 72 74 20 53 59 53 54 45 4D 20 64 69 73 6B 20 5B 45 4E 54 45 52 5D
The prompt for the system disk at the end when drive 0 was formatted (580FH).
5A83
DEFB 03H 03
The 03H that ends the prompt for the system disk.
5A84-5A97
DEFM "No available memory!" 4E 6F 20 61 76 61 69 6C 61 62 6C 65 20 6D 65 6D 6F 72 79 21
The message of a buffer that does not fit below HMEM$ (55D4H).
5A98-5A99
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5A9A-5AAE
DEFM "Disk drive NOT READY!" 44 69 73 6B 20 64 72 69 76 65 20 4E 4F 54 20 52 45 41 44 59 21
The message of a drive that DCHECK finds not ready (55B6H).
5AAF-5AB0
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5AB1-5AC5
DEFM "WRITE PROTECTED disk!" 57 52 49 54 45 20 50 52 4F 54 45 43 54 45 44 20 64 69 73 6B 21
The message of a write protected diskette (55BBH).
5AC6-5AC7
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5AC8-5AE8
DEFM "NO TRACK available for directory!" 4E 4F 20 54 52 41 43 4B 20 61 76 61 69 6C 61 62 6C 65 20 66 6F 72 20 64 69 72 65 63 74 6F 72 79 21
The message when no free cylinder is found for the directory (55C0H).
5AE9-5AEA
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5AEB-5B07
DEFM "BOOT FLAWED! routine aborted!" 42 4F 4F 54 20 46 4C 41 57 45 44 21 20 72 6F 75 74 69 6E 65 20 61 62 6F 72 74 65 64 21
The message of a flawed granule 0 of cylinder 0 (55C5H).
5B08-5B09
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5B0A-5B1D
DEFM "Drive NOT SUPPORTED!" 44 72 69 76 65 20 4E 4F 54 20 53 55 50 50 4F 52 54 45 44 21
The message of a rigid drive (55CFH), which FORMAT does not format.
5B1E-5B1F
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5B20
DEFB 0DH 0D
The carriage return that starts the message I/O ERROR!.
5B21-5B3B
DEFM "I/O ERROR! routine aborted!" 49 2F 4F 20 45 52 52 4F 52 21 20 72 6F 75 74 69 6E 65 20 61 62 6F 72 74 65 64 21
The message of every error of the format and of the writes (55CAH).
5B3C-5B3D
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5B3E-5B57
DEFM " GRAN FLAWED! Locked out!" 20 20 47 52 41 4E 20 46 4C 41 57 45 44 21 20 4C 6F 63 6B 65 64 20 6F 75 74 21
The message after VERIFYING for a granule that does not verify (5458H).
5B58-5B59
DEFB 0DH,03H 0D 03
A carriage return and the 03H that ends the message.
5B5A-5B5C
DEFM "DCT" 44 43 54
The three letters that start the page made at 5512H, as in BOOT/SYS's sector 2; that page is not written.
5B5D-5B60
DEFM "DATA" 44 41 54 41
The diskette name for ENTER alone at Diskette name ? (52CAH), ended by the 00H at 5B61H.

5B61H - The Evaluation Block and the Variables

Data: the evaluation block of EVAL@ (5249H; its flag byte is also the 00H that ends the name DATA), its three fields all at 5BB1H, and the parameter block (9 byte entries: a six character name, the address for the value, the type byte: 80H a string, 40H a number). The values go straight into the operands of seven LD HL instructions. 5BAAH on is not loaded.

5B61
DEFB 00H 00
The flags of the evaluation block, set by EVAL@ (bits 0-2 a field), and the 00H after DATA.
5B62-5B63
DEFW 5BB1H B1 5B
The address of the source field's block, 5BB1H.
5B64-5B65
DEFW 5BB1H B1 5B
The address of the destination field's block, the same 5BB1H.
5B66-5B67
DEFW 5BB1H B1 5B
The address of the wildmask field's block, the same 5BB1H.
5B68-5B69
DEFW 5B6AH 6A 5B
The address of the parameter block, 5B6AH, with the seven entries.
5B6A-5B6F
DEFM "USE " 55 53 45 20 20 20
The name of the parameter USE: the answer to Diskette contains data, use or not ?.
5B70-5B71
DEFW 53CAH CA 53
The address for USE's value, the operand of LD HL at 53C9H.
5B72
DEFB 80H 80
The type byte of USE: a string only (bit 7), so USE=Y is not taken.
5B73-5B78
DEFM "DATE " 44 41 54 45 20 20
The name of the parameter DATE: the date of the diskette, up to 8 characters.
5B79-5B7A
DEFW 52D9H D9 52
The address for DATE's value, the operand of LD HL at 52D8H.
5B7B
DEFB 80H 80
The type byte of DATE: a string only (bit 7).
5B7C-5B81
DEFM "PW " 50 57 20 20 20 20
The name of the parameter PW: the master password, up to 8 characters.
5B82-5B83
DEFW 531CH 1C 53
The address for PW's value, the operand of LD HL at 531BH.
5B84
DEFB 80H 80
The type byte of PW: a string only (bit 7), in quotation marks.
5B85-5B8A
DEFM "NAME " 4E 41 4D 45 20 20
The name of the parameter NAME: the diskette name, up to 8 characters.
5B8B-5B8C
DEFW 52B6H B6 52
The address for NAME's value, the operand of LD HL at 52B5H.
5B8D
DEFB 80H 80
The type byte of NAME: a string only (bit 7).
5B8E-5B93
DEFM "DEN " 44 45 4E 20 20 20
The name of the parameter DEN: the density, S or D.
5B94-5B95
DEFW 5383H 83 53
The address for DEN's value, the operand of LD HL at 5382H.
5B96
DEFB 80H 80
The type byte of DEN: a string only (bit 7), so DEN=D is not taken.
5B97-5B9C
DEFM "CYLS " 43 59 4C 53 20 20
The name of the parameter CYLS: the count of cylinders.
5B9D-5B9E
DEFW 5335H 35 53
The address for CYLS's value, the operand of LD HL at 5334H.
5B9F
DEFB 40H 40
The type byte of CYLS: a number only (bit 6).
5BA0-5BA5
DEFM "SIDES " 53 49 44 45 53 20
The name of the parameter SIDES: the count of sides, 1 or 2.
5BA6-5BA7
DEFW 535EH 5E 53
The address for SIDES's value, the operand of LD HL at 535DH.
5BA8
DEFB 40H 40
The type byte of SIDES: a number only (bit 6).
5BA9
DEFB 00H 00
The 00H that ends the parameter block after its seven entries.
5BAA
DEFS 1
The drive to format (5295H); 03H from 5230H until then.
5BAB
DEFS 1
The count of cylinders (5355H), 20-96, written to DCT+13H at 550EH.
5BAC
DEFS 1
The GAT byte of an empty cylinder (5406H), FCH for two granules a cylinder.
5BAD
DEFS 1
The number of the directory's last granule on its cylinder (54CDH).
5BAE
DEFS 1
The format code (52AAH, 5381H, 53ACH): bit 0 double density, bit 1 8 inch, bit 2 two sides.
5BAF-5BB0
DEFS 2
The start of the buffer, 5D00H or the page above LOW$ (5219H).
5BB1-5BD1
DEFS 33
The field block of EVAL@, the reply to a prompt, the date being made and the copies of 573AH.
5BDA-5BF9
DEFS 32
The sector order of a track being formatted, one byte a place (5617H).
5C00-5CFF
DEFS 256
The new GAT (52ADH): the allocation table, the lock out table at 5C60H, the version +CBH, the cylinders +CCH, the flags +CDH, the password +CEH, the name +D0H, the date +D8H, the AUTO command +E0H.