DOSPLUS 3.5 for the Model III - DISKZAP/CMD Disassembled

Page Customization

Introduction/Summary

DOSPLUS 3.5 DISKZAP/CMD Disassembly - The Disk Zapper and Editor (Model III)

DISKZAP/CMD is DOSPLUS's sector editor, run from the DOS command level as DISKZAP with no parameters; its heading reads DISKZAP - DOSPLUS Disk zapper/editor - 3.50. It is a load module of 12 blocks, 2846 bytes, at 5200H-5D1DH with the transfer address 5200H, after the two comment records (the name DISKZAP and the copyright notice). DISKZAP/CMD is on the Model III master only.

DISKZAP needs HMEM$ at 89F8H or above; below that it returns to the DOS without a message. It uses its own stack at 41E5H, the sector buffer 5E00H and, for Copy and Format, the pages from 5F00H up to HMEM$. It keeps its own geometry for each of the eight drives in a table at 5B04H (as loaded 40 cylinders, one surface, 18 sectors of double density) and puts it into the drive's DCT whenever a drive or a cylinder is chosen, setting the DCT's log flag; the DCTs are not set back when DISKZAP ends.

The Parts of DISKZAP/CMD

AddressContents
5200H-527BHThe start and the main menu (5200H, 5219H).
527CH-5327HDisplay and F (527CH, 52D4H).
5328H-53A1HThe sector and the cylinder before and after (5328H).
53A2H-549BHThe modify mode, its keys, a hexadecimal number and the screen place of a byte (53A2H, 5431H, 545EH, 547DH).
5499H-56B6HSet, Fill, Copy, Print, Verify and Format (5499H, 552BH, 5562H, 55EFH, 562CH, 566EH).
56B7H-5845HThe register keeper, digits, the sector display, the keyboard, the count, the status line and the errors (56B7H, 56DBH, 578EH, 57C5H).
5846H-59EEHPrompts, the questions, numbers, the geometry and the disk calls (5846H, 587CH, 5920H, 595CH, 59B0H).
59EFH-5B33HFormatting a cylinder, the track descriptions and the geometry table (59EFH, 5AD8H, 5B04H).
5B34H-5D1DHThe texts and the loaded variables (5B34H).

How DISKZAP Works

The menu lists Set, Fill, Copy, Print, Verify, Format and Display; the up and down arrows move the asterisk, ENTER runs the option and O returns to the DOS (5219H). Each option asks its questions on row 11 of the screen; ENTER takes the default, BREAK at any question returns to the menu. Drivespec is the name of a drive in DCTTBL (0-7), Cylinder and Sector are hexadecimal, Sector count, Cylinder count and the values of Set decimal (587CH).

Display reads the sector and shows it in 16 rows of 16 bytes, with the drive's number, the cylinder and the sector at the left in hexadecimal (56DBH). Semicolon and minus step a sector, plus and equal sign a cylinder, wrapping round the geometry (5328H); CLEAR shows characters instead of hexadecimal; F flashes every byte of a value; M enters the modify mode, where the arrows (and SHIFT with them) move a block cursor, two hexadecimal digits or one character change a byte, @ fills, ENTER writes the sector back with the address mark it was read with (DWRITA for the directory's) and BREAK reads it again (53A2H).

Fill writes one byte to every byte of a run of sectors; Copy reads as many sectors as the pages up to HMEM$ hold, keeping each one's address mark, then writes them to the destination, pass after pass (5562H); Print prints the screen of each sector; Verify reads each sector and, with N to Ignore data AM, stops at the directory's address mark (562CH); Format builds each track at 5F00H with the drive's geometry and an interleave and writes it by DFORMT, both sides of a two sided drive (566EH, 59EFH). A run counts down at 5D1FH and stops when BREAK is pressed between sectors (57C5H).

Differences from the Manual

The density questions take D for double density and any other answer for single (the manual says 5 and 0). The drive shown at the top left is the drive's number. Copy, Print, Fill and Verify step through the sectors of the geometry set, wrapping from the last cylinder to cylinder 0. BREAK in the modify mode reads the sector again and returns to the display, not to the menu. @ takes up to four hexadecimal digits: with four the first two are the value and the last two the count, with two the value is 00H and the digits are the count, and a count of 00H fills to the end of the sector; with four digits the number goes on with whatever follows in the buffer 5D25H. F, the find of the display, is not in the manual. Format refuses a rigid drive (DRIVE NOT SUPPORTED!) and asks for the drive again. Verify waits for any key after an error; BREAK returns to the menu.

Three findings stand from the bytes. ENTER at Fill data does not give 00H: Register E keeps the low byte of the sector count from the question before, so the sectors are filled with that byte (5541H). ENTER at Interleave factor leaves Register H at 5DH, the high byte of the answer's buffer, an interleave of 93; and an interleave greater than the sectors per track can put a sector number outside the table of the sector order, as each place is brought back round the track only once (568EH, 5A30H). What such a track holds depends on the bytes the sector buffer 5E00H has left above the table, for a place outside the table is taken when its byte has bit 7 set (5A3DH). With 18 sectors and the interleave of 93, bytes with bit 7 clear give all 18 sectors, in the order 00H 05H 0AH 0FH 03H 08H 0DH 01H 06H 0BH 10H 04H 09H 0EH 02H 07H 0CH 11H round the track; bytes with bit 7 set (E5H or FFH) leave only sectors 00H, 0AH, 07H and 11H on the track, and the other 14 IDs carry the sector number FFH. ENTER at Cylinder count formats one cylinder (590DH), so Format with ENTER at every question after the drive formats cylinder 0 alone and returns to the menu. The decimal numbers take a character from 21H to 2FH as a digit of value 241-255 (5948H).

Variables

DISKZAP/CMD Variables

Address
Size
Contents
5B04H-5B33H
48 bytes
Geometry
Six bytes for each drive (59A0H).
5D18H
1 byte
Display drawn
(5769H).
5D19H
1 byte
Characters
The display mode (5444H).
5D1AH
1 byte
Flash phase
Of F (52F9H).
5D1BH-5D1DH
3 bytes
Menu
The line and the video address of the asterisk (5231H).
5D1EH
1 byte
Address mark
00H normal, 01H the directory's (59CAH).
5D1FH-5D24H
6 bytes
Counts
The count, the pass count and the room above 5F00H (5216H).
5D25H-5D2AH
6 bytes
Answer
(5872H).
5D2BH-5D30H
6 bytes
Positions
The other one, then the drive, the sector and the cylinder (55DDH).
5E00H-5EFFH
256 bytes
Sector buffer
(59B0H).
5F00H
up to HMEM$
Copy and Format
The pages of Copy, the track of Format (5586H).

Memory Outside DISKZAP/CMD

Address
Size
Contents
3C00H-3FFFH
1024 bytes
Video RAM
The sector shown, row 11 the questions (56DBH).
4020H-4021H
2 bytes
Cursor
Set to 3EC0H, row 11 (584AH).

Outside Routines

AddressContents
4488HSYS0/SYS: DISKIO%, DHOME, DREAD, DWRITE, DWRITA and DFORMT (59C0H).
44A3HSYS0/SYS: LOCDCT% (5966H).
44E8HSYS0/SYS: DCTTBL (5888H).
4491HSYS0/SYS: the 8 bit multiply (5995H).
4494HSYS0/SYS: the 8 bit divide (5A1FH).
402DHSYS0/SYS: EXIT@ (523FH).
002BHROM: scan the keyboard (579DH).
0033HROM: display a character (57B7H).
003BHROM: print a character (57BFH).
0040HROM: line input (57A5H).

Disassembly

5200H - DISKZAP

DISKZAP/CMD's transfer address, entered from the DOS command level as DISKZAP (no parameters). DISKZAP is a menu driven sector editor: Set (the geometry of a drive), Fill, Copy, Print, Verify, Format and Display (with the modify mode). It keeps its own geometry for each of the eight drives (5B04H) and puts it into the drive's DCT when the drive or cylinder 0 is chosen. It needs HMEM$ at 89F8H or above, else it goes back to the DOS at once; the room from 5F00H up to HMEM$ is the buffer of Copy.

5200
LD SP,41E5H 31 E5 41
Load the Stack Pointer with 41E5H, DISKZAP's own stack below the DOS's 41E5H area.
5203
LD HL,(4411H) 2A 11 44
Load Register Pair HL with the contents of 4411H-4412H, HMEM$, the highest address the programs may use.
5206
PUSH HL E5
Save Register Pair HL, HMEM$, to the top of the stack for the second subtraction.
5207
LD BC,89F8H 01 F8 89
Load Register Pair BC with 89F8H, the lowest HMEM$ DISKZAP runs with.
520A
OR A B7
Clear the C FLAG (OR A with Register A itself) for the 16 bit subtraction below.
520B
SBC HL,BC ED 42
SUBtract Register Pair BC (89F8H) from Register Pair HL (HMEM$) with the carry: the C FLAG when HMEM$ is below 89F8H.
520D
POP HL E1
Restore Register Pair HL, HMEM$, from the top of the stack; the flags of the subtraction are kept.
520E
If the C FLAG is set (HMEM$ below 89F8H), JUMP to 402DH, EXIT@, back to the DOS with no message.
5211
LD BC,5F00H 01 00 5F
Load Register Pair BC with 5F00H, the start of the buffer of Copy.
5214
SBC HL,BC ED 42
SUBtract Register Pair BC (5F00H) from Register Pair HL (HMEM$), the C FLAG clear: the room above 5F00H.
5216
LD (5D23H),HL 22 23 5D
Store Register Pair HL, the room above 5F00H, into 5D23H-5D24H: its high byte is the sectors one pass of Copy holds.

5219H - The Main Menu

The stack is set again and 5219H pushed as the return address of every option, so each one ends back here; the screen is cleared and the menu shown, with the asterisk at the line kept at 5D1BH (1 Set to 7 Display). The arrows move it, ENTER runs the option, O goes back to the DOS. BREAK at any prompt of an option also comes back here (57A3H).

5219
LD SP,41E5H 31 E5 41
Load the Stack Pointer with 41E5H, so the menu starts with an empty stack each time.
521C
LD HL,5219H 21 19 52
Point Register Pair HL to 5219H, the main menu itself, the return address of every option.
521F
PUSH HL E5
Save Register Pair HL (5219H) to the top of the stack, so an option's RET comes back to the menu.
5220
LD HL,5B34H 21 34 5B
Point Register Pair HL to 5B34H, the menu: the codes 1CH 1FH that clear the screen, the heading and the seven options.
5223
GOSUB to 5857H to display the text at Register Pair HL up to its 00H.
5226
LD A,(5D1BH) 3A 1B 5D
Load Register A with the menu line of the asterisk from 5D1BH: 1 Set up to 7 Display.
5229
LD C,A 4F
Load Register C with Register A, the menu line, which the keys move.
522A
LD HL,(5D1CH) 2A 1C 5D
Load Register Pair HL with the video address of the asterisk from 5D1CH-5D1DH (3CC1H as loaded, the line of Set).
522D
XOR A AF
Set Register A to 00H (XOR A), the flag of a sector display not yet drawn.
522E
LD (5D18H),A 32 18 5D
Store Register A (00H) into 5D18H, so the next display clears the four columns at the left of each row.
5231
LD (5D1CH),HL 22 1C 5D
Store Register Pair HL, the video address of the asterisk, into 5D1CH-5D1DH.
5234
LD A,C 79
Load Register A with Register C, the menu line.
5235
LD (5D1BH),A 32 1B 5D
Store Register A, the menu line, into 5D1BH, kept for the next menu.
5238
LD (HL),2AH 36 2A
Store 2AH, the asterisk, at the video address in Register Pair HL: the line the ENTER key runs.
523A
GOSUB to 578EH to wait for a key, made upper case, in Register A.
523D
CP 4FH FE 4F
Compare Register A against 4FH, the letter O, Out.
523F
If the Z FLAG is set (O), JUMP to 402DH, EXIT@, back to the DOS.
5242
CP 5BH FE 5B
Compare Register A against 5BH, the up arrow.
5244
If the NZ FLAG is set (not the up arrow), JUMP to 5253H to test for the down arrow.
5246
LD A,C 79
Load Register A with Register C, the menu line.
5247
DEC A 3D
DECrement Register A to the line above; the Z FLAG above Set, the first line.
5248
LD DE,FFC0H 11 C0 FF
Load Register Pair DE with FFC0H, minus 64, one line up on the screen.
524B
If the Z FLAG is set (past the first or the last line), JUMP to 523AH and wait for another key.
524D
LD C,A 4F
Load Register C with Register A, the new menu line.
524E
LD (HL),20H 36 20
Store 20H, a space, over the asterisk at Register Pair HL.
5250
ADD HL,DE 19
ADD Register Pair DE (one line up or down) to Register Pair HL, the video address of the asterisk.
5251
JUMP to 5231H to show the asterisk on the new line.
5253
CP 0AH FE 0A
Compare Register A against 0AH, the down arrow.
5255
If the NZ FLAG is set (not the down arrow), JUMP to 5260H to test for ENTER.
5257
LD A,C 79
Load Register A with Register C, the menu line.
5258
INC A 3C
INCrement Register A, the menu line, to the line below.
5259
CP 08H FE 08
Compare Register A against 08H: the Z FLAG below Display, the last line.
525B
LD DE,0040H 11 40 00
Load Register Pair DE with 0040H, plus 64, one line down on the screen.
525E
JUMP to 524BH to move the asterisk unless it would pass the last line.
5260
CP 0DH FE 0D
Compare Register A against 0DH, the ENTER key.
5262
If the NZ FLAG is set (another key), JUMP to 523AH and wait for another key.
5264
DEC C 0D
DECrement Register C, the menu line: the Z FLAG for line 1, Set.
5265
If the Z FLAG is set (Set), JUMP to 5499H, the option Set.
5268
DEC C 0D
DECrement Register C, the menu line: the Z FLAG for line 2, Fill.
5269
If the Z FLAG is set (Fill), JUMP to 552BH, the option Fill.
526C
DEC C 0D
DECrement Register C, the menu line: the Z FLAG for line 3, Copy.
526D
If the Z FLAG is set (Copy), JUMP to 5562H, the option Copy.
5270
DEC C 0D
DECrement Register C, the menu line: the Z FLAG for line 4, Print.
5271
If the Z FLAG is set (Print), JUMP to 55EFH, the option Print.
5274
DEC C 0D
DECrement Register C, the menu line: the Z FLAG for line 5, Verify.
5275
If the Z FLAG is set (Verify), JUMP to 562CH.
5278
DEC C 0D
DECrement Register C, the menu line: the Z FLAG for line 6, Format.
5279
If the Z FLAG is set (Format), JUMP to 566EH.

527CH - Display

Line 7: the drive, the cylinder and the sector are asked for, the sector is read into 5E00H (an error asks continue ?) and shown. Keys: semicolon the next sector, minus the one before, plus the next cylinder, equal sign the cylinder before (each wrapping round the drive's geometry), F flashes every byte of a value, M the modify mode, CLEAR hexadecimal or characters, BREAK the menu.

527C
GOSUB to 587CH to ask for the drivespec, kept at 5D2EH.
527F
GOSUB to 58BBH to ask for the cylinder, in hexadecimal, kept at 5D30H.
5282
GOSUB to 58D4H to ask for the sector, in hexadecimal, kept at 5D2FH.
5285
GOSUB to 59B0H to read the sector into 5E00H: the NZ FLAG and the error code in Register A for an error.
5288
If the NZ FLAG is set (an error), GOSUB to 57FFH to show it and ask continue ?: the Z FLAG for Y or C.
528B
RET NZ C0
If the NZ FLAG is set (not continued), RETurn to the main menu at 5219H, the option done.
528C
GOSUB to 56DBH to show the sector at 5E00H on the screen, with the drive, the cylinder and the sector at the left.
528F
LD HL,2020H 21 20 20
Load Register Pair HL with 2020H, two spaces.
5292
LD (3D00H),HL 22 00 3D
Store Register Pair HL (2020H) into 3D00H-3D01H, blanking the offset shown by the modify mode.
5295
LD (3D40H),HL 22 40 3D
Store Register Pair HL (2020H) into 3D40H-3D41H, blanking the byte shown by the modify mode.
5298
GOSUB to 578EH to wait for a key, made upper case, in Register A.
529B
CP 01H FE 01
Compare Register A against 01H, the BREAK key.
529D
RET Z C8
If the Z FLAG is set (BREAK), RETurn to the main menu at 5219H, the option done.
529E
CP 2DH FE 2D
Compare Register A against 2DH, the minus sign: the sector before.
52A0
If the NZ FLAG is set (not the minus sign), JUMP to 52A7H.
52A2
GOSUB to 5328H to step to the sector before, wrapping round.
52A5
JUMP to 5285H to read and show that sector of the drive.
52A7
CP 3BH FE 3B
Compare Register A against 3BH, the semicolon: the next sector.
52A9
If the NZ FLAG is set (not the semicolon), JUMP to 52B0H.
52AB
GOSUB to 5365H to step to the next sector, wrapping round.
52AE
JUMP to 5285H to read and show that sector of the drive.
52B0
CP 3DH FE 3D
Compare Register A against 3DH, the equal sign: the cylinder before.
52B2
If the NZ FLAG is set (not the equal sign), JUMP to 52B9H.
52B4
GOSUB to 5348H to step to the cylinder before.
52B7
JUMP to 5285H to read and show the sector there.
52B9
CP 2BH FE 2B
Compare Register A against 2BH, the plus sign: the next cylinder.
52BB
If the NZ FLAG is set (not the plus sign), JUMP to 52C2H.
52BD
GOSUB to 5382H to step to the next cylinder, wrapping round.
52C0
JUMP to 5285H to read and show the sector there.
52C2
CP 46H FE 46
Compare Register A against 46H, the letter F, find.
52C4
If the Z FLAG is set (F), JUMP to 52D4H to flash a value.
52C6
CP 4DH FE 4D
Compare Register A against 4DH, the letter M, the modify mode.
52C8
If the Z FLAG is set (M), JUMP to 53A2H for the modify mode.
52CB
CP 1FH FE 1F
Compare Register A against 1FH, the CLEAR key.
52CD
If the NZ FLAG is set (another key), JUMP to 5298H and wait for another key.
52CF
GOSUB to 5444H to switch between hexadecimal and characters (5D19H).
52D2
JUMP to 528CH to show the sector again the other way.

52D4H - F: Flash a Value

The value is one key in character mode, else a hexadecimal number typed (not shown) and ended by a key that is not a digit; its low byte is looked for in the sector, and every place that holds it is shown as two graphic blocks or as the byte, in turn, every 512 scans of the keyboard, until a key is pressed. Then the sector is shown again.

52D4
LD HL,5D19H 21 19 5D
Point Register Pair HL to 5D19H, the flag of the character display.
52D7
BIT 0,(HL) CB 46
Test bit 0 of the flag at Register Pair HL: set in character mode.
52D9
If the NZ FLAG is set (character mode), GOSUB to 578EH to wait for one key, the character to find.
52DC
LD C,A 4F
Load Register C with Register A, the character to find (in character mode).
52DD
BIT 0,(HL) CB 46
Test bit 0 of the flag at Register Pair HL again: clear in hexadecimal mode.
52DF
If the Z FLAG is set (hexadecimal mode), GOSUB to 545EH for a hexadecimal number in Register Pair BC, the byte in Register C.
52E2
LD DE,5E00H 11 00 5E
Point Register Pair DE to 5E00H, the first byte of the sector.
52E5
LD A,(DE) 1A
Load Register A with the byte of the sector at Register Pair DE.
52E6
CP C B9
Compare Register A against Register C, the value to find.
52E7
If the Z FLAG is set (found), JUMP to 5301H to mark its place.
52E9
INC E 1C
INCrement Register E to the next byte of the sector; the Z FLAG after the last.
52EA
If the NZ FLAG is set (more bytes), JUMP to 52E5H to compare the next byte.
52EC
LD HL,0200H 21 00 02
Load Register Pair HL with 0200H, the 512 scans of the keyboard of one phase of the flashing.
52EF
GOSUB to 579CH to scan the keyboard: the NZ FLAG and the key in Register A when one is pressed.
52F2
If the NZ FLAG is set (a key), JUMP to 528CH to show the sector again.
52F4
DEC HL 2B
DECrement Register Pair HL, the scans left in this phase.
52F5
LD A,H 7C
Load Register A with Register H, the high byte of the scans left.
52F6
OR L B5
OR Register A with Register L, the low byte: the Z FLAG when the phase is over.
52F7
If the NZ FLAG is set (more scans), JUMP to 52EFH to scan the keyboard again.
52F9
LD HL,5D1AH 21 1A 5D
Point Register Pair HL to 5D1AH, the phase of the flashing.
52FC
GOSUB to 5447H to change the phase at Register Pair HL (00H and FFH in turn).
52FF
JUMP to 52E2H to mark the places again in the new phase.
5301
GOSUB to 547DH to point Register Pair HL to the place of byte Register E on the screen.
5304
LD A,(5D1AH) 3A 1A 5D
Load Register A with the phase of the flashing from 5D1AH.
5307
RRCA 0F
Rotate Register A right one bit (RRCA): bit 0 of the phase to the C FLAG.
5308
If the NC FLAG is set (phase 00H), JUMP to 5321H to show the two graphic blocks.
530A
LD A,(5D19H) 3A 19 5D
Load Register A with the flag of the character display from 5D19H.
530D
OR A B7
Test Register A, the flag: the Z FLAG in hexadecimal mode.
530E
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL: HL the byte of the sector, DE its place on the screen.
530F
LD A,(HL) 7E
Load Register A with the byte of the sector at Register Pair HL; the flags are kept.
5310
If the NZ FLAG is set (character mode), JUMP to 5318H to show it as a character.
5312
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
5315
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL back: Register Pair DE the byte of the sector.
5316
JUMP to 52E9H to look for the value in the rest of the sector.
5318
GOSUB to 576EH to show Register A as a character at Register Pair DE.
531B
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL: Register Pair HL the place after the character.
531C
LD (HL),20H 36 20
Store 20H, a space, at Register Pair HL, the second place of the byte.
531E
INC HL 23
INCrement Register Pair HL past the second place of the byte.
531F
JUMP to 52E9H to look for the value in the rest of the sector.
5321
LD (HL),8FH 36 8F
Store 8FH, a graphic block, at Register Pair HL, the first place of the byte on the screen.
5323
INC HL 23
INCrement Register Pair HL to the second place of the byte.
5324
LD (HL),8FH 36 8F
Store 8FH, a graphic block, at Register Pair HL, the second place of the byte.
5326
JUMP to 52E9H to look for the value in the rest of the sector.

5328H - The Sector and the Cylinder Before and After

5328H the sector before (below the first sector, DCT+08H, the last of the cylinder before), 5348H the cylinder before (below 0 the last, DCT+13H less 1), 5365H the next sector (past the last, DCT+08H plus DCT+11H less 1, the first of the next cylinder), 5382H the next cylinder (past the last, 0). On reaching or leaving cylinder 0 the geometry is put into the DCT again (595CH). The sector is at 5D2FH, the cylinder at 5D30H.

5328
LD DE,(5D2FH) ED 5B 2F 5D
Load Register Pair DE with 5D2FH-5D30H: Register E the sector, Register D the cylinder.
532C
LD A,(IY+08H) FD 7E 08
Load Register A with the first sector, DCT+08H, at Index Register IY+08H.
532F
CP E BB
Compare Register A against Register E, the sector: the Z FLAG at the first sector.
5330
If the Z FLAG is set (the first sector), JUMP to 5338H for the last sector of the cylinder before.
5332
DEC E 1D
DECrement Register E to the sector before on the same cylinder.
5333
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H.
5337
RET C9
RETurn to the caller with the sector before at 5D2FH.
5338
GOSUB to 534CH to step to the cylinder before, Register D, with its geometry.
533B
LD A,(IY+11H) FD 7E 11
Load Register A with the sectors of a cylinder, DCT+11H, at Index Register IY+11H.
533E
ADD A,(IY+08H) FD 86 08
ADD the first sector, DCT+08H, at Index Register IY+08H to Register A.
5341
LD E,A 5F
Load Register E with Register A, one past the last sector of the cylinder.
5342
DEC E 1D
DECrement Register E to the last sector of the cylinder.
5343
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H.
5347
RET C9
RETurn to the caller with the last sector of the cylinder before.
5348
LD DE,(5D2FH) ED 5B 2F 5D
Load Register Pair DE with 5D2FH-5D30H: Register E the sector, Register D the cylinder.
534C
INC D 14
INCrement Register D, the first of two that test the cylinder.
534D
DEC D 15
DECrement Register D again: the Z FLAG at cylinder 0.
534E
If the Z FLAG is set (cylinder 0), JUMP to 5359H for the last cylinder.
5350
DEC D 15
DECrement Register D to the cylinder before; the Z FLAG when it is cylinder 0.
5351
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H.
5355
If the Z FLAG is set (now cylinder 0), GOSUB to 595CH to put the geometry of cylinder 0 into the DCT.
5358
RET C9
RETurn to the caller with the cylinder before.
5359
LD D,(IY+13H) FD 56 13
Load Register D with the cylinders of the drive, DCT+13H, at Index Register IY+13H.
535C
DEC D 15
DECrement Register D, the cylinder count, to the last cylinder.
535D
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H.
5361
GOSUB to 595CH to put the geometry of the other cylinders into the DCT.
5364
RET C9
RETurn to the caller with the last cylinder at 5D30H.
5365
LD DE,(5D2FH) ED 5B 2F 5D
Load Register Pair DE with 5D2FH-5D30H: Register E the sector, Register D the cylinder.
5369
LD A,(IY+11H) FD 7E 11
Load Register A with the sectors of a cylinder, DCT+11H, at Index Register IY+11H.
536C
ADD A,(IY+08H) FD 86 08
ADD the first sector, DCT+08H, at Index Register IY+08H to Register A.
536F
DEC A 3D
DECrement Register A to the last sector of the cylinder.
5370
INC E 1C
INCrement Register E, the sector, to the next sector.
5371
CP E BB
Compare Register A, the last sector, against Register E: the NC FLAG while it is not past the last.
5372
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H; the flags are kept.
5376
RET NC D0
If the NC FLAG is set (still on the cylinder), RETurn to the caller with the next sector.
5377
GOSUB to 5386H to step to the next cylinder, Register D, with its geometry.
537A
LD E,(IY+08H) FD 5E 08
Load Register E with the first sector, DCT+08H, at Index Register IY+08H.
537D
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H.
5381
RET C9
RETurn to the caller with the first sector of the next cylinder.
5382
LD DE,(5D2FH) ED 5B 2F 5D
Load Register Pair DE with 5D2FH-5D30H: Register E the sector, Register D the cylinder.
5386
LD A,(IY+13H) FD 7E 13
Load Register A with the cylinders of the drive, DCT+13H, at Index Register IY+13H.
5389
DEC A 3D
DECrement Register A, the cylinder count, to the last cylinder.
538A
INC D 14
INCrement Register D, the cylinder, to the next cylinder.
538B
CP D BA
Compare Register A, the last cylinder, against Register D: the C FLAG past the last.
538C
If the C FLAG is set (past the last), JUMP to 5398H for cylinder 0.
538E
LD A,D 7A
Load Register A with Register D, the next cylinder.
538F
DEC A 3D
DECrement Register A: the Z FLAG when the cylinder left is cylinder 0.
5390
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H; the flags are kept.
5394
If the Z FLAG is set (cylinder 0 left), GOSUB to 595CH to put the geometry of the other cylinders into the DCT.
5397
RET C9
RETurn to the caller with the next cylinder at 5D30H.
5398
LD D,00H 16 00
Load Register D with 00H, cylinder 0, after the last cylinder.
539A
LD (5D2FH),DE ED 53 2F 5D
Store Register Pair DE, the sector and the cylinder, into 5D2FH-5D30H.
539E
GOSUB to 595CH to put the geometry of cylinder 0 into the DCT.
53A1
RET C9
RETurn to the caller with cylinder 0 at 5D30H, after the last.

53A2H - The Modify Mode

Two graphic blocks show the byte at the cursor, with its offset at 3D00H and its value at 3D40H. The arrows move the cursor (with SHIFT to the end or the start of the row, SHIFT up arrow to the first byte; the table at 541BH), wrapping round the sector; a hexadecimal digit pair (or in character mode a key) changes the byte; @ fills; CLEAR switches the display; ENTER writes the sector back with its own address mark and returns to the display; BREAK reads the sector again and returns to the display.

53A2
LD DE,5E00H 11 00 5E
Point Register Pair DE to 5E00H, the cursor on the first byte of the sector.
53A5
GOSUB to 56DBH to show the sector at 5E00H on the screen with any changes.
53A8
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL: Register Pair HL = the byte at the cursor.
53A9
LD DE,3D00H 11 00 3D
Point Register Pair DE to 3D00H, the screen place of the offset of the cursor.
53AC
LD A,L 7D
Load Register A with Register L, the offset of the cursor in the sector.
53AD
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
53B0
LD DE,3D40H 11 40 3D
Point Register Pair DE to 3D40H, the screen place of the byte at the cursor.
53B3
LD A,(HL) 7E
Load Register A with the byte at the cursor at Register Pair HL.
53B4
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
53B7
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL back: Register Pair DE = the byte at the cursor.
53B8
GOSUB to 547DH to point Register Pair HL to the place of byte Register E on the screen.
53BB
LD (HL),8FH 36 8F
Store 8FH, a graphic block, at Register Pair HL, the first place of the byte at the cursor.
53BD
INC HL 23
INCrement Register Pair HL to the second place of the byte.
53BE
LD (HL),8FH 36 8F
Store 8FH, a graphic block, at Register Pair HL, the second place of the byte.
53C0
LD BC,53A5H 01 A5 53
Load Register Pair BC with 53A5H, the start of the modify loop.
53C3
PUSH BC C5
Save Register Pair BC (53A5H) to the top of the stack: each key's routine returns there.
53C4
GOSUB to 579CH to scan the keyboard: the NZ FLAG and the key in Register A when one is pressed.
53C7
If the Z FLAG is set (no key), JUMP to 53C4H to scan again.
53C9
CP 40H FE 40
Compare Register A against 40H, the at sign, fill.
53CB
If the Z FLAG is set (@), JUMP to 5431H to fill from the cursor.
53CE
CP 1FH FE 1F
Compare Register A against 1FH, the CLEAR key.
53D0
If the Z FLAG is set (CLEAR), JUMP to 5444H to switch between hexadecimal and characters.
53D3
CP 0DH FE 0D
Compare Register A against 0DH, the ENTER key.
53D5
If the Z FLAG is set (ENTER), JUMP to 544CH to write the sector back.
53D8
CP 01H FE 01
Compare Register A against 01H, the BREAK key.
53DA
If the Z FLAG is set (BREAK), JUMP to 545AH to leave the modify mode without writing.
53DD
LD HL,541BH 21 1B 54
Point Register Pair HL to 541BH, the table of the cursor keys: the key, a mask and a step.
53E0
INC (HL) 34
INCrement the byte of the table at Register Pair HL, the first of two that test it.
53E1
DEC (HL) 35
DECrement the byte at Register Pair HL again: the Z FLAG at the 00H that ends the table.
53E2
If the Z FLAG is set (not a cursor key), JUMP to 53F1H to take the key as data.
53E4
CP (HL) BE
Compare Register A, the key, against the key of the entry at Register Pair HL.
53E5
INC HL 23
INCrement Register Pair HL to the mask of the entry; the flags are kept.
53E6
LD C,(HL) 4E
Load Register C with the mask of the entry at Register Pair HL.
53E7
INC HL 23
INCrement Register Pair HL to the step of the entry.
53E8
LD B,(HL) 46
Load Register B with the step of the entry at Register Pair HL.
53E9
INC HL 23
INCrement Register Pair HL to the next entry; the flags of the compare are kept.
53EA
If the NZ FLAG is set (another key), JUMP to 53E0H for the next entry.
53EC
LD A,E 7B
Load Register A with Register E, the offset of the cursor.
53ED
AND C A1
AND Register A with Register C, the mask: FFH keeps it, F0H keeps the row, 00H clears it.
53EE
ADD A,B 80
ADD Register B, the step, to Register A: the new offset, wrapping round the sector.
53EF
LD E,A 5F
Load Register E with Register A, the new offset of the cursor.
53F0
RET C9
RETurn to 53A5H to show the cursor at its new place.
53F1
LD HL,5D19H 21 19 5D
Point Register Pair HL to 5D19H, the flag of the character display.
53F4
BIT 0,(HL) CB 46
Test bit 0 of the flag at Register Pair HL: set in character mode.
53F6
If the NZ FLAG is set (character mode), JUMP to 5418H to store the key itself.
53F8
GOSUB to 5793H to make a lower case letter in Register A upper case.
53FB
GOSUB to 56CAH to take Register A as a hexadecimal digit: the C FLAG when it is not one, Register B = the key.
53FE
If the C FLAG is set (not a digit), JUMP to 53C4H to wait for another key.
5400
LD C,A 4F
Load Register C with Register A, the value of the first digit.
5401
GOSUB to 547DH to point Register Pair HL to the place of byte Register E on the screen.
5404
LD (HL),B 70
Store Register B, the digit typed, at Register Pair HL, the first place of the byte.
5405
SLA C CB 21
Shift Register C left one bit, the first of four that make the digit the high half (SLA).
5407
SLA C CB 21
Shift Register C left one bit, the second of four (SLA).
5409
SLA C CB 21
Shift Register C left one bit, the third of four (SLA).
540B
SLA C CB 21
Shift Register C left one bit, the fourth: the first digit in bits 7-4 of Register C (SLA).
540D
GOSUB to 578EH to wait for the second key, made upper case, in Register A.
5410
GOSUB to 56CAH to take Register A as a hexadecimal digit: the C FLAG when it is not one, Register B = the key.
5413
If the C FLAG is set (not a digit), JUMP to 540DH to wait for another key.
5415
INC HL 23
INCrement Register Pair HL to the second place of the byte on the screen.
5416
LD (HL),B 70
Store Register B, the second digit typed, at Register Pair HL.
5417
ADD A,C 81
ADD Register C, the first digit times 16, to Register A, the second digit: the new byte.
5418
LD (DE),A 12
Store Register A, the new byte, at the cursor at Register Pair DE.
5419
INC E 1C
INCrement Register E: the cursor to the next byte, wrapping round the sector.
541A
RET C9
RETurn to 53A5H to show the sector and the cursor again.
541B-541D
DEFB 09H,FFH,01H 09 FF 01
The right arrow: the offset kept (mask FFH) and 01H added, the next byte.
541E-5420
DEFB 08H,FFH,FFH 08 FF FF
The left arrow: the offset kept and FFH added, the byte before.
5421-5423
DEFB 0AH,FFH,10H 0A FF 10
The down arrow: the offset kept and 10H added, the next row.
5424-5426
DEFB 5BH,FFH,F0H 5B FF F0
The up arrow: the offset kept and F0H added, the row before.
5427-5429
DEFB 19H,F0H,0FH 19 F0 0F
SHIFT right arrow: the row kept (mask F0H) and 0FH added, the end of the row.
542A-542C
DEFB 18H,F0H,00H 18 F0 00
SHIFT left arrow: the row kept and 00H added, the start of the row.
542D-542F
DEFB 1BH,00H,00H 1B 00 00
SHIFT up arrow: the offset cleared (mask 00H), the first byte of the sector.
5430
DEFB 00H 00
The 00H that ends the table of the cursor keys.

5431H - Fill, CLEAR, ENTER and BREAK

@ takes a hexadecimal number (not shown, up to four digits, 545EH): the high byte is the value and the low byte the count, 00H for the rest of the sector; the bytes from the cursor are filled, wrapping round the sector. 5444H and 5447H change a flag between 00H and FFH. ENTER writes the sector (59CFH) and, on an error, asks continue ? (Y or C writes again). BREAK drops the loop's return address and reads the sector again (5285H).

5431
PUSH DE D5
Save Register Pair DE, the cursor, to the top of the stack.
5432
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL: Register Pair HL = the cursor.
5433
GOSUB to 545EH for a hexadecimal number in Register Pair BC: Register B the value, Register C the count.
5436
INC C 0C
INCrement Register C, the first of two that test the count.
5437
DEC C 0D
DECrement Register C again: the Z FLAG for a count of 00H.
5438
If the NZ FLAG is set (a count), JUMP to 543DH to fill that many bytes.
543A
XOR A AF
Set Register A to 00H (XOR A) for the count to the end of the sector.
543B
SUB L 95
SUBtract Register L, the offset of the cursor, from Register A: the bytes left in the sector.
543C
LD C,A 4F
Load Register C with Register A, the bytes left in the sector.
543D
LD (HL),B 70
Store Register B, the value, at Register Pair HL.
543E
INC L 2C
INCrement Register L to the next byte, wrapping round the sector.
543F
DEC C 0D
DECrement Register C, the count of the bytes left to fill.
5440
If the NZ FLAG is set (more to fill), JUMP to 543DH.
5442
POP DE D1
Restore Register Pair DE, the cursor, from the top of the stack.
5443
RET C9
RETurn to 53A5H to show the sector with the bytes filled.
5444
LD HL,5D19H 21 19 5D
Point Register Pair HL to 5D19H, the flag of the character display.
5447
LD A,(HL) 7E
Load Register A with the flag at Register Pair HL.
5448
XOR FFH EE FF
XOR Register A with FFH, changing 00H into FFH and FFH into 00H.
544A
LD (HL),A 77
Store Register A, the flag changed, back at Register Pair HL.
544B
RET C9
RETurn to the caller with the flag at Register Pair HL changed.
544C
GOSUB to 59CFH to write the sector at 5E00H back: the NZ FLAG and the error code in Register A for an error.
544F
If the Z FLAG is set (written), JUMP to 5456H to return to the display.
5451
GOSUB to 57FFH to show the error and ask continue ?: the Z FLAG for Y or C.
5454
If the Z FLAG is set (Y or C), JUMP to 544CH to write the sector again.
5456
POP BC C1
Restore Register Pair BC from the top of the stack, which drops the return address 53A5H.
5457
JUMP to 528CH to show the sector and take the keys of the display.
545A
POP BC C1
Restore Register Pair BC from the top of the stack, which drops the return address 53A5H.
545B
JUMP to 5285H to read the sector again, undoing the changes, and show it.

545EH - A Hexadecimal Number Typed

Up to four keys into 5D25H, not shown, ended early by a key below 21H or one that is not a hexadecimal digit; 5920H takes the number, which is returned in Register Pair BC. With four digits the number goes on with what follows in 5D25H.

545E
PUSH HL E5
Save Register Pair HL to the top of the stack.
545F
LD HL,5D25H 21 25 5D
Point Register Pair HL to 5D25H, the buffer of the keys typed.
5462
PUSH HL E5
Save Register Pair HL (5D25H) to the top of the stack for the conversion.
5463
LD B,04H 06 04
Load Register B with 04H, the most keys of the number.
5465
GOSUB to 578EH to wait for a key, made upper case, in Register A.
5468
LD (HL),A 77
Store Register A, the key, into the buffer at Register Pair HL.
5469
CP 21H FE 21
Compare Register A against 21H: the C FLAG for a space, ENTER or a control key.
546B
If the C FLAG is set (the end of the number), JUMP to 5475H.
546D
GOSUB to 56CAH to take Register A as a hexadecimal digit: the C FLAG when it is not one.
5470
If the C FLAG is set (not a digit), JUMP to 5475H, the end of the number.
5472
INC HL 23
INCrement Register Pair HL to the next place of the buffer.
5473
DECrement Register B and, while it is not zero, LOOP BACK to 5465H for the next key (DJNZ).
5475
POP HL E1
Restore Register Pair HL (5D25H) from the top of the stack.
5476
GOSUB to 5920H to take the hexadecimal number at Register Pair HL into Register Pair DE.
5479
PUSH DE D5
Save Register Pair DE, the number, to the top of the stack.
547A
POP BC C1
Restore Register Pair BC from the top of the stack: Register Pair BC = the number.
547B
POP HL E1
Restore Register Pair HL from the top of the stack.
547C
RET C9
RETurn to the caller with the number in Register Pair BC.

547DH - The Screen Place of a Byte

Register Pair HL = the video address of byte Register E of the sector: row E/16 of the screen (3C00H plus 64 for each row) and column 8 plus 2.5 times E's low digit, as 56DBH shows the bytes.

547D
PUSH BC C5
Save Register Pair BC to the top of the stack.
547E
LD A,E 7B
Load Register A with Register E, the offset of the byte.
547F
RLCA 07
Rotate Register A left one bit, the first of two that bring the row's bits apart (RLCA).
5480
RLCA 07
Rotate Register A left one bit, the second of two: the row's bits 1-0 now in bits 7-6, bits 3-2 in bits 1-0 (RLCA).
5481
LD C,A 4F
Load Register C with Register A, the offset turned.
5482
AND C0H E6 C0
AND Register A with C0H, keeping bits 7-6: the place of the row in its 256 bytes of video RAM.
5484
LD L,A 6F
Load Register L with Register A, the low byte of the row's address.
5485
LD A,C 79
Load Register A with Register C, the offset turned.
5486
AND 03H E6 03
AND Register A with 03H, keeping bits 1-0: the 256 bytes of video RAM the row is in.
5488
ADD A,3CH C6 3C
ADD 3CH to Register A: the high byte of the row's address, 3CH-3FH.
548A
LD H,A 67
Load Register H with Register A, the high byte of the row's address.
548B
LD A,E 7B
Load Register A with Register E, the offset of the byte.
548C
AND 0FH E6 0F
AND Register A with 0FH, keeping the column of the byte, 0-15.
548E
LD C,A 4F
Load Register C with Register A, the column of the byte, 0-15.
548F
ADD A,A 87
ADD Register A to itself: two places for each byte.
5490
SRL C CB 39
Shift Register C right one bit (SRL): one more place for each pair of bytes.
5492
ADD A,C 81
ADD Register C to Register A: 2.5 places for each byte.
5493
ADD A,08H C6 08
ADD 08H to Register A: the bytes start in column 8 of the row.
5495
OR L B5
OR Register A with Register L, the place of the row.
5496
LD L,A 6F
Load Register L with Register A: Register Pair HL = the video address of the byte.
5497
POP BC C1
Restore Register Pair BC from the top of the stack.
5498
RET C9
RETurn to the caller with the video address in Register Pair HL.

5499H - Set

Line 1: the drivespec, then the six values of that drive's entry in the table at 5B04H: Cylinder count (decimal), Surface count, CYL 0 sec/trk, CYL 0 density (D double, any other answer single), Sectors/track and Track density. ENTER keeps a value, 0 asks again, BREAK goes back to the menu; only the low byte of a number is kept. The DCT gets the new values when the drive or cylinder is next chosen (595CH).

5499
GOSUB to 587CH to ask for the drivespec, kept at 5D2EH.
549C
LD A,(5D2EH) 3A 2E 5D
Load Register A with the drive in use from 5D2EH.
549F
GOSUB to 59A0H to point Index Register IX to the drive's entry of six bytes in the table at 5B04H.
54A2
LD B,03H 06 03
Load Register B with 03H, the most characters of the answer: three digits.
54A4
LD HL,5BFAH 21 FA 5B
Point Register Pair HL to 5BFAH, the prompt Cylinder count.
54A7
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
54AA
If the Z FLAG is set (ENTER), JUMP to 54B8H, keeping the cylinder count.
54AC
GOSUB to 593EH to take the decimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
54AF
If the NC FLAG is set (a bad number), JUMP to 54A2H to ask again.
54B1
INC E 1C
INCrement Register E, the first of two that test the low byte of the number.
54B2
DEC E 1D
DECrement Register E again: the Z FLAG when it is 00H.
54B3
If the Z FLAG is set (0), JUMP to 54A2H to ask again.
54B5
LD (IX+00H),E DD 73 00
Store Register E, the cylinder count, into the entry at Index Register IX+00H.
54B8
LD B,01H 06 01
Load Register B with 01H, the most characters of the answer: one digit.
54BA
LD HL,5C25H 21 25 5C
Point Register Pair HL to 5C25H, the prompt Surface count.
54BD
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
54C0
If the Z FLAG is set (ENTER), JUMP to 54CEH, keeping the surface count.
54C2
GOSUB to 593EH to take the decimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
54C5
If the NC FLAG is set (a bad number), JUMP to 54B8H to ask again.
54C7
INC E 1C
INCrement Register E, the first of two that test the low byte of the number.
54C8
DEC E 1D
DECrement Register E again: the Z FLAG when it is 00H.
54C9
If the Z FLAG is set (0), JUMP to 54B8H to ask again.
54CB
LD (IX+01H),E DD 73 01
Store Register E, the surface count, into the entry at Index Register IX+01H.
54CE
LD B,02H 06 02
Load Register B with 02H, the most characters of the answer: two digits.
54D0
LD HL,5C33H 21 33 5C
Point Register Pair HL to 5C33H, the prompt CYL 0 sec/trk.
54D3
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
54D6
If the Z FLAG is set (ENTER), JUMP to 54E4H, keeping the sectors of cylinder 0.
54D8
GOSUB to 593EH to take the decimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
54DB
If the NC FLAG is set (a bad number), JUMP to 54CEH to ask again.
54DD
INC E 1C
INCrement Register E, the first of two that test the low byte of the number.
54DE
DEC E 1D
DECrement Register E again: the Z FLAG when it is 00H.
54DF
If the Z FLAG is set (0), JUMP to 54CEH to ask again.
54E1
LD (IX+03H),E DD 73 03
Store Register E, the sectors per track of cylinder 0, into the entry at Index Register IX+03H.
54E4
LD B,01H 06 01
Load Register B with 01H, the most characters of the answer: one letter.
54E6
LD HL,5C41H 21 41 5C
Point Register Pair HL to 5C41H, the prompt CYL 0 density.
54E9
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
54EC
If the Z FLAG is set (ENTER), JUMP to 54FDH, keeping the density of cylinder 0.
54EE
SET 7,(IX+02H) DD CB 02 FE
Set bit 7 of the entry's byte at Index Register IX+02H: double density for cylinder 0.
54F2
LD A,(HL) 7E
Load Register A with the answer at Register Pair HL.
54F3
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
54F5
CP 44H FE 44
Compare Register A against 44H, the letter D, double density.
54F7
If the Z FLAG is set (D), JUMP to 54FDH with double density kept.
54F9
RES 7,(IX+02H) DD CB 02 BE
Reset bit 7 of the entry's byte at Index Register IX+02H: single density for cylinder 0, for any other answer.
54FD
LD B,02H 06 02
Load Register B with 02H, the most characters of the answer: two digits.
54FF
LD HL,5C4FH 21 4F 5C
Point Register Pair HL to 5C4FH, the prompt Sectors/track.
5502
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
5505
If the Z FLAG is set (ENTER), JUMP to 5513H, keeping the sectors per track.
5507
GOSUB to 593EH to take the decimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
550A
If the NC FLAG is set (a bad number), JUMP to 54FDH to ask again.
550C
INC E 1C
INCrement Register E, the first of two that test the low byte of the number.
550D
DEC E 1D
DECrement Register E again: the Z FLAG when it is 00H.
550E
If the Z FLAG is set (0), JUMP to 54FDH to ask again.
5510
LD (IX+05H),E DD 73 05
Store Register E, the sectors per track of the other cylinders, into the entry at Index Register IX+05H.
5513
LD B,01H 06 01
Load Register B with 01H, the most characters of the answer: one letter.
5515
LD HL,5C5DH 21 5D 5C
Point Register Pair HL to 5C5DH, the prompt Track density.
5518
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
551B
RET Z C8
If the Z FLAG is set (ENTER), RETurn to the main menu with the density kept.
551C
SET 7,(IX+04H) DD CB 04 FE
Set bit 7 of the entry's byte at Index Register IX+04H: double density for the other cylinders.
5520
LD A,(HL) 7E
Load Register A with the answer at Register Pair HL.
5521
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
5523
CP 44H FE 44
Compare Register A against 44H, the letter D, double density.
5525
RET Z C8
If the Z FLAG is set (D), RETurn to the main menu with double density kept.
5526
RES 7,(IX+04H) DD CB 04 BE
Reset bit 7 of the entry's byte at Index Register IX+04H: single density, for any other answer.
552A
RET C9
RETurn to the main menu at 5219H, the option done.

552BH - Fill

Line 2: drive, cylinder, sector, sector count (decimal, ENTER 1) and Fill data (hexadecimal). The buffer at 5E00H is filled with the low byte of the value and written to each sector with the normal address mark, the status line showing each one. ENTER at Fill data leaves Register E as the last prompt left it, the low byte of the sector count, so the sectors are filled with that byte, not 00H. An error is shown and a key returns to the menu.

552B
GOSUB to 587CH to ask for the drivespec, kept at 5D2EH.
552E
GOSUB to 58BBH to ask for the cylinder, in hexadecimal, kept at 5D30H.
5531
GOSUB to 58D4H to ask for the sector, in hexadecimal, kept at 5D2FH.
5534
GOSUB to 58EAH to ask for the sector count, in decimal, kept at 5D1FH: Register Pair DE = the count.
5537
LD B,02H 06 02
Load Register B with 02H, the most characters of the answer: two digits.
5539
LD HL,5C1BH 21 1B 5C
Point Register Pair HL to 5C1BH, the prompt Fill data.
553C
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
553F
LD B,00H 06 00
Load Register B with 00H; the flags of the prompt are kept.
5541
If the Z FLAG is set (ENTER), JUMP to 5548H with Register E as it is, the low byte of the sector count.
5543
GOSUB to 5920H to take the hexadecimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
5546
If the NC FLAG is set (a bad number), JUMP to 5537H to ask again.
5548
LD HL,5E00H 21 00 5E
Point Register Pair HL to 5E00H, the sector buffer.
554B
LD (HL),E 73
Store Register E, the fill byte, at Register Pair HL.
554C
INC L 2C
INCrement Register L to the next byte of the buffer; the Z FLAG after the last.
554D
If the NZ FLAG is set (more bytes), JUMP to 554BH.
554F
XOR A AF
Set Register A to 00H (XOR A), the code of the normal data address mark.
5550
LD (5D1EH),A 32 1E 5D
Store Register A (00H) into 5D1EH, so 59CFH writes with DWRITE.
5553
GOSUB to 57DAH to show the status line Drive, Cylinder, Sector of the sector about to be written.
5556
GOSUB to 59CFH to write the sector buffer to the sector: the NZ FLAG and the error code in Register A for an error.
5559
If the NZ FLAG is set (an error), JUMP to 5825H to show it, wait for a key and return to the menu.
555C
GOSUB to 57C5H for the next sector and one fewer in the count: the Z FLAG when the count is done or for BREAK.
555F
If the NZ FLAG is set (more sectors), JUMP to 5553H to write the next one.
5561
RET C9
RETurn to the main menu at 5219H, the option done.

5562H - Copy

Line 3: the source drive, cylinder and sector, the destination drive, cylinder and sector, and the sector count. The two positions are swapped by 55DDH (the other one kept at 5D2BH-5D2DH). Each pass reads as many sectors as the pages above 5F00H hold (5D24H), keeping each one's address mark at 5E00H on, then writes them to the destination with the same marks. A read error asks continue ?; a write error is shown and a key returns to the menu.

5562
GOSUB to 587CH to ask for the source drivespec, kept at 5D2EH.
5565
GOSUB to 58BBH to ask for the source cylinder, in hexadecimal, kept at 5D30H.
5568
GOSUB to 58D4H to ask for the source sector, in hexadecimal, kept at 5D2FH.
556B
GOSUB to 55DDH to swap the position at 5D2EH-5D30H with 5D2BH-5D2DH: the source kept there.
556E
GOSUB to 587CH to ask for the destination drivespec, kept at 5D2EH.
5571
GOSUB to 58BBH to ask for the destination cylinder, in hexadecimal, kept at 5D30H.
5574
GOSUB to 58D4H to ask for the destination sector, in hexadecimal, kept at 5D2FH.
5577
GOSUB to 58EAH to ask for the sector count, in decimal, kept at 5D1FH.
557A
GOSUB to 55DDH to swap the positions: the source at 5D2EH-5D30H, the destination at 5D2BH-5D2DH.
557D
GOSUB to 595CH to put the source drive's geometry into its DCT.
5580
LD HL,(5D1FH) 2A 1F 5D
Load Register Pair HL with the sectors still to copy from 5D1FH-5D20H.
5583
LD (5D21H),HL 22 21 5D
Store Register Pair HL into 5D21H-5D22H, the count at the start of this pass.
5586
LD HL,5F00H 21 00 5F
Point Register Pair HL to 5F00H, the first page of the buffer of Copy.
5589
LD IX,5E00H DD 21 00 5E
Point Index Register IX to 5E00H, the address marks of the sectors of this pass.
558D
LD BC,(5D23H) ED 4B 23 5D
Load Register Pair BC with the room above 5F00H from 5D23H-5D24H: Register B = the pages, the sectors of one pass.
5591
GOSUB to 57DAH to show the status line Drive, Cylinder, Sector of the sector about to be read.
5594
GOSUB to 59B3H to read the source sector into the page at Register Pair HL: the NZ FLAG and the code in Register A for an error.
5597
If the NZ FLAG is set (an error), GOSUB to 57FFH to show it and ask continue ?: the Z FLAG for Y or C.
559A
RET NZ C0
If the NZ FLAG is set (not continued), RETurn to the main menu at 5219H, the option done.
559B
LD A,(5D1EH) 3A 1E 5D
Load Register A with the sector's address mark from 5D1EH: 00H normal, 01H the directory's.
559E
LD (IX+00H),A DD 77 00
Store Register A, the address mark, at Index Register IX+00H.
55A1
INC IX DD 23
INCrement Index Register IX to the address mark of the next sector.
55A3
GOSUB to 57C5H for the next sector and one fewer in the count: the Z FLAG when the count is done or for BREAK.
55A6
If the Z FLAG is set (done), JUMP to 55ABH to write what was read.
55A8
INC H 24
INCrement Register H: Register Pair HL to the next page of the buffer.
55A9
DECrement Register B and, while it is not zero, LOOP BACK to 5591H for the next sector (DJNZ).
55AB
GOSUB to 55DDH to swap the positions: the destination at 5D2EH-5D30H.
55AE
GOSUB to 595CH to put the destination drive's geometry into its DCT.
55B1
LD HL,(5D21H) 2A 21 5D
Load Register Pair HL with the count at the start of the pass from 5D21H-5D22H.
55B4
LD (5D1FH),HL 22 1F 5D
Store Register Pair HL into 5D1FH-5D20H, so the writes count the same sectors.
55B7
LD HL,5F00H 21 00 5F
Point Register Pair HL to 5F00H, the first page of the buffer of Copy.
55BA
LD IX,5E00H DD 21 00 5E
Point Index Register IX to 5E00H, the address marks of the sectors of this pass.
55BE
LD BC,(5D23H) ED 4B 23 5D
Load Register Pair BC with the room above 5F00H from 5D23H-5D24H: Register B = the pages, the sectors of one pass.
55C2
GOSUB to 57DAH to show the status line Drive, Cylinder, Sector of the sector about to be written.
55C5
LD A,(IX+00H) DD 7E 00
Load Register A with the sector's address mark at Index Register IX+00H.
55C8
LD (5D1EH),A 32 1E 5D
Store Register A, the address mark, into 5D1EH for the write.
55CB
INC IX DD 23
INCrement Index Register IX to the address mark of the next sector.
55CD
GOSUB to 59D2H to write the page at Register Pair HL to the destination sector: the NZ FLAG for an error.
55D0
If the NZ FLAG is set (an error), JUMP to 5825H to show it, wait for a key and return to the menu.
55D3
GOSUB to 57C5H for the next sector and one fewer in the count: the Z FLAG when the count is done or for BREAK.
55D6
RET Z C8
If the Z FLAG is set (done), RETurn to the main menu at 5219H, the option done.
55D7
INC H 24
INCrement Register H: Register Pair HL to the next page of the buffer.
55D8
DECrement Register B and, while it is not zero, LOOP BACK to 55C2H for the next sector (DJNZ).
55DA
JUMP to 557AH for the next pass, from the source again.
55DD
LD HL,5D2BH 21 2B 5D
Point Register Pair HL to 5D2BH, the other position: drive, sector and cylinder.
55E0
LD DE,5D2EH 11 2E 5D
Point Register Pair DE to 5D2EH, the current position: drive, sector and cylinder.
55E3
LD B,03H 06 03
Load Register B with 03H, the three bytes of a position.
55E5
LD A,(DE) 1A
Load Register A with the byte of the current position at Register Pair DE.
55E6
LD C,A 4F
Load Register C with Register A, the byte of the current position.
55E7
LD A,(HL) 7E
Load Register A with the byte of the other position at Register Pair HL.
55E8
LD (DE),A 12
Store Register A, the other position's byte, into the current position at Register Pair DE.
55E9
LD (HL),C 71
Store Register C, the current position's byte, into the other position at Register Pair HL.
55EA
INC DE 13
INCrement Register Pair DE to the next byte of the current position.
55EB
INC HL 23
INCrement Register Pair HL to the next byte of the other position.
55EC
DECrement Register B and, while it is not zero, LOOP BACK to 55E5H for the next byte (DJNZ).
55EE
RET C9
RETurn to the caller with the two positions swapped.

55EFH - Print

Line 4: drive, cylinder, sector and sector count. Each sector is read and shown, then the 16 rows of 64 characters of the screen are sent to the printer by the ROM's 003BH (a byte of 80H or above as a period), each row ended by a carriage return and the sector by a line feed. A read error asks continue ?.

55EF
GOSUB to 587CH to ask for the drivespec, kept at 5D2EH.
55F2
GOSUB to 58BBH to ask for the cylinder, in hexadecimal, kept at 5D30H.
55F5
GOSUB to 58D4H to ask for the sector, in hexadecimal, kept at 5D2FH.
55F8
GOSUB to 58EAH to ask for the sector count, in decimal, kept at 5D1FH.
55FB
GOSUB to 59B0H to read the sector into 5E00H: the NZ FLAG and the error code in Register A for an error.
55FE
If the NZ FLAG is set (an error), GOSUB to 57FFH to show it and ask continue ?: the Z FLAG for Y or C.
5601
RET NZ C0
If the NZ FLAG is set (not continued), RETurn to the main menu at 5219H, the option done.
5602
GOSUB to 56DBH to show the sector at 5E00H on the screen.
5605
LD HL,3C00H 21 00 3C
Point Register Pair HL to 3C00H, the start of the video RAM.
5608
LD C,10H 0E 10
Load Register C with 10H, the 16 rows of the screen.
560A
LD B,40H 06 40
Load Register B with 40H, the 64 characters of a row.
560C
LD A,(HL) 7E
Load Register A with the character of the screen at Register Pair HL.
560D
INC HL 23
INCrement Register Pair HL to the next character of the screen.
560E
CP 80H FE 80
Compare Register A against 80H: the C FLAG for a character below 80H.
5610
If the C FLAG is set (below 80H), JUMP to 5614H to print it.
5612
LD A,2EH 3E 2E
Load Register A with 2EH, a period, printed for a graphic character.
5614
GOSUB to 57BDH to send the character in Register A to the printer.
5617
DECrement Register B and, while it is not zero, LOOP BACK to 560CH for the next character (DJNZ).
5619
LD A,0DH 3E 0D
Load Register A with 0DH, the carriage return that ends the row.
561B
GOSUB to 57BDH to send the carriage return in Register A to the printer.
561E
DEC C 0D
DECrement Register C, the rows of the screen left to print.
561F
If the NZ FLAG is set (more rows), JUMP to 560AH for the next row.
5621
LD A,0AH 3E 0A
Load Register A with 0AH, the line feed after the sector.
5623
GOSUB to 57BDH to send the line feed in Register A to the printer.
5626
GOSUB to 57C5H for the next sector and one fewer in the count: the Z FLAG when the count is done or for BREAK.
5629
If the NZ FLAG is set (more sectors), JUMP to 55FBH to read and print the next one.
562B
RET C9
RETurn to the main menu at 5219H, the option done.

562CH - Verify

Line 5: drive, cylinder, sector, sector count and Ignore data AM. Each sector is read into 5E00H (DREAD). A read error is shown and waits for a key (BREAK the menu, any other key goes on); with N to Ignore data AM a sector with the directory's address mark shows AM/WRITE FAULT! and waits too. Holding BREAK ends the run (57C5H).

562C
GOSUB to 587CH to ask for the drivespec, kept at 5D2EH.
562F
GOSUB to 58BBH to ask for the cylinder, in hexadecimal, kept at 5D30H.
5632
GOSUB to 58D4H to ask for the sector, in hexadecimal, kept at 5D2FH.
5635
GOSUB to 58EAH to ask for the sector count, in decimal, kept at 5D1FH.
5638
LD B,03H 06 03
Load Register B with 03H, the most characters of the answer.
563A
LD HL,5C6BH 21 6B 5C
Point Register Pair HL to 5C6BH, the prompt Ignore data AM.
563D
GOSUB to 5860H to show the prompt and take the answer at 5D25H.
5640
LD B,00H 06 00
Load Register B with 00H, the flag of the address marks: ignored.
5642
LD A,(HL) 7E
Load Register A with the answer at Register Pair HL.
5643
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
5645
CP 4EH FE 4E
Compare Register A against 4EH, the letter N: the address marks are reported.
5647
If the NZ FLAG is set (not N), JUMP to 564BH with the address marks ignored.
5649
SET 0,B CB C0
Set bit 0 of Register B: the directory's address mark is reported.
564B
GOSUB to 57DAH to show the status line Drive, Cylinder, Sector of the sector about to be read.
564E
GOSUB to 59B0H to read the sector into 5E00H: the NZ FLAG and the error code in Register A for an error.
5651
If the NZ FLAG is set (an error), JUMP to 565FH to show it.
5653
BIT 0,B CB 40
Test bit 0 of Register B: set when the address marks are reported.
5655
If the Z FLAG is set (ignored), JUMP to 5668H for the next sector.
5657
LD A,(5D1EH) 3A 1E 5D
Load Register A with the sector's address mark from 5D1EH.
565A
OR A B7
Test Register A, the address mark: the Z FLAG for the normal mark.
565B
If the Z FLAG is set (the normal mark), JUMP to 5668H for the next sector.
565D
LD A,06H 3E 06
Load Register A with 06H, the code whose text is AM/WRITE FAULT!.
565F
GOSUB to 582BH to show the status line and the text of the code in Register A.
5662
GOSUB to 578EH to wait for a key, made upper case, in Register A.
5665
CP 01H FE 01
Compare Register A against 01H, the BREAK key.
5667
RET Z C8
If the Z FLAG is set (BREAK), RETurn to the main menu at 5219H, the option done.
5668
GOSUB to 57C5H for the next sector and one fewer in the count: the Z FLAG when the count is done or for BREAK.
566B
If the NZ FLAG is set (more sectors), JUMP to 564BH to read the next one.
566D
RET C9
RETurn to the main menu at 5219H, the option done.

566EH - Format

Line 6: drive, cylinder, cylinder count (decimal, ENTER 1) and Interleave factor. A rigid drive shows DRIVE NOT SUPPORTED! and asks for the drive again. The drive is sent to cylinder 0 (DHOME), then each cylinder is formatted (59EFH) with the drive's geometry from the table, both sides when it has two. With ENTER at Interleave factor Register H keeps 5DH from the address of the answer (5D25H), so the interleave is 93.

566E
GOSUB to 587CH to ask for the drivespec, kept at 5D2EH.
5671
GOSUB to 58BBH to ask for the cylinder, in hexadecimal, kept at 5D30H.
5674
GOSUB to 5905H to ask for the cylinder count, in decimal, kept at 5D1FH.
5677
BIT 5,(IY+03H) FD CB 03 6E
Test bit 5 of the drive control table's flags, DCT+03H, at Index Register IY+03H: set for a rigid drive.
567B
If the Z FLAG is set (a floppy drive), JUMP to 5684H for the interleave.
567D
LD B,09H 06 09
Load Register B with 09H, the number of the text DRIVE NOT SUPPORTED!.
567F
GOSUB to 5838H to show text Register B of the table at 5CAAH.
5682
JUMP to 566EH to ask for the drive again: Format takes floppies only.
5684
LD B,02H 06 02
Load Register B with 02H, the most characters of the answer: two digits.
5686
LD HL,5C09H 21 09 5C
Point Register Pair HL to 5C09H, the prompt Interleave factor.
5689
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
568C
LD B,01H 06 01
Load Register B with 01H; the flags of the prompt are kept and Register B is not used after it.
568E
If the Z FLAG is set (ENTER), JUMP to 5696H with Register H = 5DH from 5860H, the interleave used.
5690
GOSUB to 593EH to take the decimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
5693
If the NC FLAG is set (a bad number), JUMP to 5684H to ask again.
5695
LD H,E 63
Load Register H with Register E, the interleave factor.
5696
LD A,(5D2EH) 3A 2E 5D
Load Register A with the drive in use from 5D2EH.
5699
LD C,A 4F
Load Register C with Register A, the drive, for DISKIO%.
569A
GOSUB to 59E9H to send drive Register C to cylinder 0 (DHOME); its result is not tested.
569D
XOR A AF
Set Register A to 00H (XOR A), sector 0, shown on the status line.
569E
LD (5D2FH),A 32 2F 5D
Store Register A (00H) into 5D2FH, the sector of the status line.
56A1
GOSUB to 57DAH to show the status line Drive, Cylinder, Sector of the cylinder about to be formatted.
56A4
LD A,(5D30H) 3A 30 5D
Load Register A with the cylinder from 5D30H.
56A7
LD D,A 57
Load Register D with Register A, the cylinder to format.
56A8
GOSUB to 59EFH to format cylinder Register D with the interleave in Register H: the NZ FLAG for an error.
56AB
If the NZ FLAG is set (an error), JUMP to 5825H to show it, wait for a key and return to the menu.
56AE
GOSUB to 5382H to step to the next cylinder, past the last to 0, with its geometry.
56B1
GOSUB to 57C8H for one fewer in the count: the Z FLAG when the count is done or for BREAK.
56B4
If the NZ FLAG is set (more cylinders), JUMP to 56A1H to format the next one.
56B6
RET C9
RETurn to the main menu at 5219H, the option done.

56B7H - Keep the Registers

Called at the start of a routine: the rest of the routine, from the return address, is called as a subroutine (the address stored into the CALL at 56C1H) with Register Pairs BC, DE, HL and Index Register IX saved; Register A and the flags come back as the routine left them.

56B7
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the return address, the rest of the routine.
56B8
LD (56C2H),HL 22 C2 56
Store Register Pair HL, the rest of the routine, into 56C2H-56C3H, the operand of the CALL at 56C1H.
56BB
POP HL E1
Restore Register Pair HL, the caller's Register Pair HL, from the top of the stack.
56BC
PUSH BC C5
Save Register Pair BC, the caller's Register Pair BC, to the top of the stack.
56BD
PUSH DE D5
Save Register Pair DE, the caller's Register Pair DE, to the top of the stack.
56BE
PUSH HL E5
Save Register Pair HL, the caller's Register Pair HL, to the top of the stack.
56BF
PUSH IX DD E5
Save Index Register IX, the caller's value, to the top of the stack.
56C1
GOSUB to the rest of the routine, the address stored at 56C2H (0000H as loaded).
56C4
POP IX DD E1
Restore Index Register IX, the caller's value, from the top of the stack.
56C6
POP HL E1
Restore Register Pair HL, the caller's Register Pair HL, from the top of the stack.
56C7
POP DE D1
Restore Register Pair DE, the caller's Register Pair DE, from the top of the stack.
56C8
POP BC C1
Restore Register Pair BC, the caller's Register Pair BC, from the top of the stack.
56C9
RET C9
RETurn to the caller of the routine with Register A and the flags of the routine.

56CAH - A Hexadecimal Digit

Register A, a character (kept in Register B by the entry at 56CAH), as a digit 0-9 or A-F: the NC FLAG and its value 00H-0FH in Register A, else the C FLAG.

56CA
LD B,A 47
Load Register B with Register A, the character, kept for the caller.
56CB
SUB 30H D6 30
SUBtract 30H from Register A: the C FLAG for a character below 0.
56CD
RET C D8
If the C FLAG is set (below 0), RETurn with the C FLAG: not a digit.
56CE
CP 0AH FE 0A
Compare Register A against 0AH: the C FLAG for 0-9.
56D0
If the C FLAG is set (0-9), JUMP to 56D9H to clear the carry.
56D2
CP 11H FE 11
Compare Register A against 11H: the C FLAG for the characters between 9 and A.
56D4
RET C D8
If the C FLAG is set (between 9 and A), RETurn with the C FLAG: not a digit.
56D5
SUB 07H D6 07
SUBtract 07H from Register A: A-F become 0AH-0FH.
56D7
CP 10H FE 10
Compare Register A against 10H: the C FLAG for A-F, the NC FLAG past F.
56D9
CCF 3F
Complement the C FLAG (CCF): the NC FLAG for a digit, the C FLAG for anything else.
56DA
RET C9
RETurn to the caller with the digit's value in Register A and the NC FLAG, or the C FLAG.

56DBH - Show the Sector

The sector at 5E00H fills the 16 rows of the screen: on each row four columns at the left (blanked only on the first display, 5D18H 00H), the offset and a colon, eight groups of a space and two bytes (four hexadecimal digits, or two characters each with a space), a space and the 16 characters (spaces in character mode). Then the drive's number at 3C00H, the cylinder at 3C40H and the sector at 3C80H, in hexadecimal, in those columns.

56DB
GOSUB to 56B7H, so the rest of this routine runs with Register Pairs BC, DE and HL and Index Register IX kept.
56DE
LD DE,3C00H 11 00 3C
Point Register Pair DE to 3C00H, the start of the video RAM, the first row.
56E1
LD HL,5E00H 21 00 5E
Point Register Pair HL to 5E00H, the first byte of the sector.
56E4
LD B,04H 06 04
Load Register B with 04H, the four columns at the left of the row.
56E6
LD A,(5D18H) 3A 18 5D
Load Register A with the flag of the sector display from 5D18H: 00H before the first display.
56E9
OR A B7
Test Register A, the flag: the Z FLAG before the first display.
56EA
If the NZ FLAG is set (shown before), JUMP to 56EFH, keeping what the columns hold.
56EC
LD A,20H 3E 20
Load Register A with 20H, a space, to blank the column.
56EE
LD (DE),A 12
Store Register A, the space, at Register Pair DE on the screen.
56EF
INC DE 13
INCrement Register Pair DE to the next column of the screen.
56F0
DECrement Register B and, while it is not zero, LOOP BACK to 56E6H for the next column (DJNZ).
56F2
LD A,L 7D
Load Register A with Register L, the offset of the row in the sector.
56F3
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
56F6
LD A,3AH 3E 3A
Load Register A with 3AH, the colon after the offset.
56F8
GOSUB to 578BH to put the colon in Register A at Register Pair DE.
56FB
LD A,20H 3E 20
Load Register A with 20H, the space before each group of two bytes.
56FD
GOSUB to 578BH to put the space in Register A at Register Pair DE.
5700
LD A,(5D19H) 3A 19 5D
Load Register A with the flag of the character display from 5D19H.
5703
OR A B7
Test Register A, the flag: the Z FLAG in hexadecimal mode.
5704
If the Z FLAG is set (hexadecimal mode), JUMP to 571AH to show the two bytes as digits.
5706
GOSUB to 576DH to put the byte at Register Pair HL as a character at Register Pair DE.
5709
LD A,20H 3E 20
Load Register A with 20H, the space after the character.
570B
GOSUB to 578BH to put the space in Register A at Register Pair DE.
570E
INC L 2C
INCrement Register L to the next byte of the sector.
570F
GOSUB to 576DH to put the byte at Register Pair HL as a character at Register Pair DE.
5712
LD A,20H 3E 20
Load Register A with 20H, the space after the character.
5714
GOSUB to 578BH to put the space in Register A at Register Pair DE.
5717
INC L 2C
INCrement Register L to the next byte of the sector.
5718
JUMP to 5724H to test for the end of the row.
571A
LD A,(HL) 7E
Load Register A with the byte of the sector at Register Pair HL.
571B
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
571E
INC L 2C
INCrement Register L to the next byte of the sector.
571F
LD A,(HL) 7E
Load Register A with the byte of the sector at Register Pair HL.
5720
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
5723
INC L 2C
INCrement Register L to the next byte of the sector.
5724
LD A,L 7D
Load Register A with Register L, the offset of the next byte.
5725
AND 0FH E6 0F
AND Register A with 0FH: the Z FLAG at the end of the row of 16 bytes.
5727
If the NZ FLAG is set (more of the row), JUMP to 56FBH for the next group.
5729
LD A,20H 3E 20
Load Register A with 20H, the space before the characters of the row.
572B
GOSUB to 578BH to put the space in Register A at Register Pair DE.
572E
LD A,L 7D
Load Register A with Register L, the offset after the row.
572F
SUB 10H D6 10
SUBtract 10H from Register A, back to the first byte of the row.
5731
LD L,A 6F
Load Register L with Register A: Register Pair HL to the first byte of the row again.
5732
LD A,(5D19H) 3A 19 5D
Load Register A with the flag of the character display from 5D19H.
5735
OR A B7
Test Register A, the flag: the Z FLAG in hexadecimal mode.
5736
PUSH AF F5
Save Register Pair AF, the flags of the test, to the top of the stack.
5737
LD A,20H 3E 20
Load Register A with 20H, the space shown in character mode.
5739
If the NZ FLAG is set (character mode), GOSUB to 578BH to put the space at Register Pair DE.
573C
POP AF F1
Restore Register Pair AF, the flags of the test, from the top of the stack.
573D
If the Z FLAG is set (hexadecimal mode), GOSUB to 576DH to put the byte at Register Pair HL as a character.
5740
INC L 2C
INCrement Register L to the next byte of the row.
5741
LD A,L 7D
Load Register A with Register L, the offset of the next byte.
5742
AND 0FH E6 0F
AND Register A with 0FH: the Z FLAG at the end of the row.
5744
If the NZ FLAG is set (more of the row), JUMP to 5732H for the next character.
5746
INC L 2C
INCrement Register L, the first of two that test the offset.
5747
DEC L 2D
DECrement Register L again: the Z FLAG when the offset has wrapped to 00H, the end of the sector.
5748
If the NZ FLAG is set (more rows), JUMP to 56E4H for the next row.
574A
LD DE,3C00H 11 00 3C
Point Register Pair DE to 3C00H, the first column of row 0.
574D
LD A,(5D2EH) 3A 2E 5D
Load Register A with the drive in use from 5D2EH.
5750
AND 0FH E6 0F
AND Register A with 0FH, keeping the drive's number.
5752
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
5755
LD DE,3C40H 11 40 3C
Point Register Pair DE to 3C40H, the first column of row 1.
5758
LD A,(5D30H) 3A 30 5D
Load Register A with the cylinder from 5D30H.
575B
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
575E
LD DE,3C80H 11 80 3C
Point Register Pair DE to 3C80H, the first column of row 2.
5761
LD A,(5D2FH) 3A 2F 5D
Load Register A with the sector in use from 5D2FH.
5764
GOSUB to 577AH to show Register A as two hexadecimal digits at Register Pair DE.
5767
LD A,FFH 3E FF
Load Register A with FFH, the flag of a sector display drawn.
5769
LD (5D18H),A 32 18 5D
Store Register A (FFH) into 5D18H: the next display keeps the four columns at the left.
576C
RET C9
RETurn to the caller with the sector shown on the screen.

576DH - Characters and Digits on the Screen

576DH the byte at Register Pair HL (576EH Register A) as a character at Register Pair DE: below 20H or C0H and above as a period. 577AH Register A as two hexadecimal digits at Register Pair DE. 578BH Register A at Register Pair DE. Register Pair DE ends after them.

576D
LD A,(HL) 7E
Load Register A with the byte of the sector at Register Pair HL.
576E
CP 20H FE 20
Compare Register A against 20H: the C FLAG for a control code.
5770
If the C FLAG is set (a control code), JUMP to 5776H to show a period.
5772
CP C0H FE C0
Compare Register A against C0H: the C FLAG below C0H, a character or a graphic.
5774
If the C FLAG is set (below C0H), JUMP to 5778H to show it.
5776
LD A,2EH 3E 2E
Load Register A with 2EH, a period, for a byte that is not shown as it is.
5778
JUMP to 578BH to put Register A at Register Pair DE.
577A
PUSH AF F5
Save Register Pair AF, the byte in Register A, to the top of the stack.
577B
RRA 1F
Rotate Register A right through the carry, the first of four that bring the high digit down (RRA).
577C
RRA 1F
Rotate Register A right through the carry, the second of four that bring the high digit down (RRA).
577D
RRA 1F
Rotate Register A right through the carry, the third of four that bring the high digit down (RRA).
577E
RRA 1F
Rotate Register A right through the carry, the fourth: the high digit in bits 3-0 (RRA).
577F
GOSUB to 5783H to put the high digit in Register A at Register Pair DE.
5782
POP AF F1
Restore Register Pair AF, the byte in Register A, from the top of the stack, for its low digit.
5783
AND 0FH E6 0F
AND Register A with 0FH, keeping the digit 0-15 in bits 3-0.
5785
ADD A,90H C6 90
ADD 90H to Register A, the first step of the DAA trick that makes a hexadecimal digit.
5787
DAA 27
Decimal adjust Register A (DAA): 90H-99H for 0-9, 00H-05H with the C FLAG for 10-15.
5788
ADC A,40H CE 40
ADD 40H with the carry to Register A, the second step of the DAA trick.
578A
DAA 27
Decimal adjust Register A (DAA): the character 0-9 or A-F of the digit.
578B
LD (DE),A 12
Store Register A, the character, at Register Pair DE.
578C
INC DE 13
INCrement Register Pair DE to the next place.
578D
RET C9
RETurn to the caller with the character stored.

578EH - The Keyboard and the Display

578EH waits for a key and makes a lower case letter upper case (5793H only the latter); 579CH scans the keyboard once (the NZ FLAG for a key); 57A3H the ROM's line input, BREAK going back to the menu; 57AEH clears the screen; 57B5H displays and 57BDH prints Register A, keeping Register Pair DE.

578E
GOSUB to 579CH to scan the keyboard: the NZ FLAG and the key in Register A when one is pressed.
5791
If the Z FLAG is set (no key), JUMP to 578EH to scan again.
5793
CP 61H FE 61
Compare Register A against 61H: the C FLAG below the lower case letters.
5795
RET C D8
If the C FLAG is set (below a), RETurn with the key as it is.
5796
CP 7BH FE 7B
Compare Register A against 7BH: the NC FLAG past the lower case letters.
5798
RET NC D0
If the NC FLAG is set (past z), RETurn with the key as it is.
5799
RES 5,A CB AF
Reset bit 5 of Register A: the lower case letter becomes upper case.
579B
RET C9
RETurn to the caller with the key in Register A.
579C
PUSH DE D5
Save Register Pair DE to the top of the stack.
579D
GOSUB to 002BH, the ROM's scan of the keyboard: Register A = the key pressed, or 00H.
57A0
POP DE D1
Restore Register Pair DE from the top of the stack.
57A1
OR A B7
Test Register A, the key: the Z FLAG for no key.
57A2
RET C9
RETurn to the caller with the NZ FLAG and the key, or the Z FLAG.
57A3
PUSH BC C5
Save Register Pair BC, the length in Register B, to the top of the stack.
57A4
PUSH DE D5
Save Register Pair DE to the top of the stack.
57A5
GOSUB to 0040H, the ROM's line input of up to Register B characters into the buffer at Register Pair HL; the C FLAG for BREAK.
57A8
If the C FLAG is set (BREAK), JUMP to 5219H, the main menu, which sets the stack again.
57AB
POP DE D1
Restore Register Pair DE from the top of the stack.
57AC
POP BC C1
Restore Register Pair BC from the top of the stack.
57AD
RET C9
RETurn to the caller with the answer in the buffer at Register Pair HL.
57AE
LD A,1CH 3E 1C
Load Register A with 1CH, the code that puts the cursor at the top left of the screen.
57B0
GOSUB to 57B5H to display the code in Register A.
57B3
LD A,1FH 3E 1F
Load Register A with 1FH, the code that clears from the cursor to the end of the screen.
57B5
PUSH AF F5
Save Register Pair AF, the character in Register A, to the top of the stack.
57B6
PUSH DE D5
Save Register Pair DE to the top of the stack.
57B7
GOSUB to 0033H, the ROM's display of the character in Register A.
57BA
POP DE D1
Restore Register Pair DE from the top of the stack.
57BB
POP AF F1
Restore Register Pair AF, the character in Register A, from the top of the stack.
57BC
RET C9
RETurn to the caller with the character displayed.
57BD
PUSH AF F5
Save Register Pair AF, the character in Register A, to the top of the stack.
57BE
PUSH DE D5
Save Register Pair DE to the top of the stack.
57BF
GOSUB to 003BH, the ROM's output of the character in Register A to the printer.
57C2
POP DE D1
Restore Register Pair DE from the top of the stack.
57C3
POP AF F1
Restore Register Pair AF, the character in Register A, from the top of the stack.
57C4
RET C9
RETurn to the caller with the character printed.

57C5H - The Count, the Status Line and the Errors

57C5H steps to the next sector, 57C8H counts one fewer at 5D1FH: the Z FLAG when the count is done or BREAK is pressed. 57DAH the status line Drive $nn, Cylinder nn, Sector nn on row 11. 57FFH clears the screen, shows the status line and the error's text and asks continue ? (the Z FLAG for Y or C); 5825H shows the error and waits for a key; 582BH shows the text of error code Register A, reduced to 1-8 by ((code less 1) AND 07H) plus 1, from the table at 5CAAH.

57C5
GOSUB to 5365H to step to the next sector, past the last of the cylinder to the next cylinder.
57C8
PUSH HL E5
Save Register Pair HL to the top of the stack.
57C9
LD HL,(5D1FH) 2A 1F 5D
Load Register Pair HL with the count from 5D1FH-5D20H.
57CC
DEC HL 2B
DECrement Register Pair HL, the count: one sector or cylinder fewer.
57CD
LD (5D1FH),HL 22 1F 5D
Store Register Pair HL, the count, into 5D1FH-5D20H.
57D0
LD A,H 7C
Load Register A with Register H, the high byte of the count.
57D1
OR L B5
OR Register A with Register L, the low byte: the Z FLAG when the count is done.
57D2
POP HL E1
Restore Register Pair HL from the top of the stack.
57D3
RET Z C8
If the Z FLAG is set (the count is done), RETurn with the Z FLAG.
57D4
GOSUB to 579CH to scan the keyboard: the NZ FLAG and the key in Register A when one is pressed.
57D7
CP 01H FE 01
Compare Register A against 01H, the BREAK key: the Z FLAG for BREAK.
57D9
RET C9
RETurn to the caller with the Z FLAG for BREAK.
57DA
GOSUB to 56B7H, so the rest of this routine runs with Register Pairs BC, DE and HL and Index Register IX kept.
57DD
LD A,(5D2EH) 3A 2E 5D
Load Register A with the drive in use from 5D2EH.
57E0
LD DE,5C81H 11 81 5C
Point Register Pair DE to 5C81H, the two digits of the drive in the status line.
57E3
GOSUB to 577AH to put Register A as two hexadecimal digits at Register Pair DE.
57E6
LD A,(5D30H) 3A 30 5D
Load Register A with the cylinder from 5D30H.
57E9
LD DE,5C8EH 11 8E 5C
Point Register Pair DE to 5C8EH, the two digits of the cylinder in the status line.
57EC
GOSUB to 577AH to put Register A as two hexadecimal digits at Register Pair DE.
57EF
LD A,(5D2FH) 3A 2F 5D
Load Register A with the sector in use from 5D2FH.
57F2
LD DE,5C99H 11 99 5C
Point Register Pair DE to 5C99H, the two digits of the sector in the status line.
57F5
GOSUB to 577AH to put Register A as two hexadecimal digits at Register Pair DE.
57F8
LD HL,5C7AH 21 7A 5C
Point Register Pair HL to 5C7AH, the status line Drive $nn, Cylinder nn, Sector nn.
57FB
GOSUB to 5846H to show the text at Register Pair HL at the start of row 11 and clear the rest of the row.
57FE
RET C9
RETurn to the caller with the status line shown.
57FF
GOSUB to 56B7H, so the rest of this routine runs with Register Pairs BC, DE and HL and Index Register IX kept.
5802
LD B,A 47
Load Register B with Register A, the error code.
5803
GOSUB to 57AEH to clear the screen before the error is shown.
5806
XOR A AF
Set Register A to 00H (XOR A), the flag of a sector display not yet drawn.
5807
LD (5D18H),A 32 18 5D
Store Register A (00H) into 5D18H, so the next display blanks the columns at the left again.
580A
LD A,B 78
Load Register A with Register B, the error code.
580B
GOSUB to 582EH to show the status line and the text of the error code in Register A.
580E
LD HL,5C9DH 21 9D 5C
Point Register Pair HL to 5C9DH, the text continue ? after the error.
5811
GOSUB to 5857H to display the text at Register Pair HL up to its 00H.
5814
LD B,03H 06 03
Load Register B with 03H, the most characters of the answer.
5816
LD HL,5D25H 21 25 5D
Point Register Pair HL to 5D25H, the buffer of the answer.
5819
GOSUB to 57A3H for the answer at Register Pair HL; BREAK goes back to the menu.
581C
LD A,(HL) 7E
Load Register A with the first character of the answer at Register Pair HL.
581D
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
581F
CP 59H FE 59
Compare Register A against 59H, the letter Y, Yes.
5821
RET Z C8
If the Z FLAG is set (Y), RETurn with the Z FLAG: go on.
5822
CP 43H FE 43
Compare Register A against 43H, the letter C, Continue: the Z FLAG for C.
5824
RET C9
RETurn to the caller with the Z FLAG for C, the NZ FLAG for any other answer.
5825
GOSUB to 582BH to show the status line and the text of the error code in Register A.
5828
JUMP to 578EH to wait for a key, which returns to the caller of the option, the main menu.
582B
GOSUB to 56B7H, so the rest of this routine runs with Register Pairs BC, DE and HL and Index Register IX kept.
582E
PUSH AF F5
Save Register Pair AF, the error code in Register A, to the top of the stack.
582F
GOSUB to 57DAH to show the status line Drive, Cylinder, Sector of the sector at fault.
5832
POP AF F1
Restore Register Pair AF, the error code in Register A, from the top of the stack.
5833
DEC A 3D
DECrement Register A, the first step that reduces the error code to 1-8.
5834
AND 07H E6 07
AND Register A with 07H: the code less 1, modulo 8.
5836
INC A 3C
INCrement Register A: the number of the text, 1-8.
5837
LD B,A 47
Load Register B with Register A, the number of the text.
5838
LD HL,5CAAH 21 AA 5C
Point Register Pair HL to 5CAAH, the texts of the errors, each ended by 00H, the first one empty.
583B
LD A,(HL) 7E
Load Register A with the character of the texts at Register Pair HL.
583C
OR A B7
Test Register A, the character: the Z FLAG at the 00H that ends a text.
583D
INC HL 23
INCrement Register Pair HL to the next character; the flags are kept.
583E
If the NZ FLAG is set (not the end), JUMP to 583BH.
5840
DECrement Register B and, while it is not zero, LOOP BACK to 583BH to pass the next text (DJNZ).
5842
GOSUB to 5857H to display text Register B at Register Pair HL up to its 00H.
5845
RET C9
RETurn to the caller with the error's text shown.

5846H - Texts and Prompts

5846H shows the text at Register Pair HL at the start of row 11 (the cursor 4020H set to 3EC0H) and clears the rest of the row; 5857H displays a text up to its 00H. 5860H shows a prompt as 5846H does, then a space, a question mark and a space, and takes up to Register B characters into 5D25H: the Z FLAG for ENTER alone.

5846
PUSH HL E5
Save Register Pair HL, the address of the text, to the top of the stack.
5847
LD HL,3EC0H 21 C0 3E
Load Register Pair HL with 3EC0H, the start of row 11 of the screen.
584A
LD (4020H),HL 22 20 40
Store Register Pair HL (3EC0H) into 4020H-4021H, the cursor of the display.
584D
POP HL E1
Restore Register Pair HL, the address of the text, from the top of the stack.
584E
GOSUB to 5857H to display the text at Register Pair HL up to its 00H.
5851
LD A,1EH 3E 1E
Load Register A with 1EH, the code that clears from the cursor to the end of the row.
5853
GOSUB to 57B5H to display the code in Register A.
5856
RET C9
RETurn to the caller with the text on row 11.
5857
LD A,(HL) 7E
Load Register A with the character of the text at Register Pair HL.
5858
OR A B7
Test Register A, the character: the Z FLAG at the 00H that ends the text.
5859
RET Z C8
If the Z FLAG is set (the end), RETurn to the caller.
585A
GOSUB to 57B5H to display the character in Register A.
585D
INC HL 23
INCrement Register Pair HL to the next character of the text.
585E
JUMP to 5857H for the next character of the text.
5860
GOSUB to 5846H to show the prompt at Register Pair HL at the start of row 11.
5863
LD A,20H 3E 20
Load Register A with 20H, the space after the prompt.
5865
GOSUB to 57B5H to display the space in Register A.
5868
LD A,3FH 3E 3F
Load Register A with 3FH, the question mark of the prompt.
586A
GOSUB to 57B5H to display the question mark in Register A.
586D
LD A,20H 3E 20
Load Register A with 20H, the space after the question mark.
586F
GOSUB to 57B5H to display the space in Register A.
5872
LD HL,5D25H 21 25 5D
Point Register Pair HL to 5D25H, the buffer of the answer.
5875
GOSUB to 57A3H for up to Register B characters at Register Pair HL; BREAK goes back to the menu.
5878
LD A,(HL) 7E
Load Register A with the first character of the answer at Register Pair HL.
5879
CP 0DH FE 0D
Compare Register A against 0DH, the ENTER key: the Z FLAG for ENTER alone.
587B
RET C9
RETurn to the caller with the answer at Register Pair HL (5D25H).

587CH - The Questions

587CH Drivespec: ENTER is drive 0, else the answer's two characters (the second a space when the answer has one) are looked for among the names in DCTTBL (44E8H); not found asks again; the geometry is put into the DCT (595CH). 58BBH Cylinder and 58D4H Sector in hexadecimal (ENTER 0); 58EAH Sector count and 5905H Cylinder count in decimal (ENTER 1, 0 asks again). A bad number asks again.

587C
LD B,02H 06 02
Load Register B with 02H, the most characters of the answer.
587E
LD HL,5BD3H 21 D3 5B
Point Register Pair HL to 5BD3H, the prompt Drivespec.
5881
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
5884
LD A,00H 3E 00
Load Register A with 00H, drive 0 for ENTER; the flags are kept.
5886
If the Z FLAG is set (ENTER), JUMP to 58B4H with drive 0.
5888
LD IX,44E8H DD 21 E8 44
Point Index Register IX to 44E8H, DCTTBL, the table of the drives: the DCT address and the two character name.
588C
LD DE,0004H 11 04 00
Load Register Pair DE with 0004H, the four bytes of an entry of DCTTBL.
588F
LD B,08H 06 08
Load Register B with 08H, the eight drives of DCTTBL.
5891
LD A,(HL) 7E
Load Register A with the first character of the answer at Register Pair HL.
5892
GOSUB to 5793H to make a lower case letter in Register A upper case.
5895
CP (IX+02H) DD BE 02
Compare Register A against the first character of the name at Index Register IX+02H.
5898
If the NZ FLAG is set (not this drive), JUMP to 58ABH for the next entry.
589A
INC HL 23
INCrement Register Pair HL to the second character of the answer.
589B
LD A,(HL) 7E
Load Register A with the second character of the answer at Register Pair HL.
589C
GOSUB to 5793H to make a lower case letter in Register A upper case.
589F
DEC HL 2B
DECrement Register Pair HL back to the first character of the answer.
58A0
CP 21H FE 21
Compare Register A against 21H: the NC FLAG for a character, the C FLAG for the end of the answer.
58A2
If the NC FLAG is set (a character), JUMP to 58A6H to compare it.
58A4
LD A,20H 3E 20
Load Register A with 20H, a space, for a name of one character.
58A6
CP (IX+03H) DD BE 03
Compare Register A against the second character of the name at Index Register IX+03H.
58A9
If the Z FLAG is set (this drive), JUMP to 58B1H for its number.
58AB
ADD IX,DE DD 19
ADD Register Pair DE (0004H) to Index Register IX, to the next entry of DCTTBL.
58AD
DECrement Register B and, while it is not zero, LOOP BACK to 5891H for the next drive (DJNZ).
58AF
JUMP to 587CH to ask for the drivespec again: no drive has that name.
58B1
LD A,08H 3E 08
Load Register A with 08H, the drives of DCTTBL.
58B3
SUB B 90
SUBtract Register B, the drives not passed, from Register A: the number of the drive found.
58B4
LD (5D2EH),A 32 2E 5D
Store Register A, the drive, into 5D2EH, the drive in use.
58B7
GOSUB to 595CH to put the drive's geometry from the table at 5B04H into its DCT.
58BA
RET C9
RETurn to the caller with the drive at 5D2EH.
58BB
LD B,02H 06 02
Load Register B with 02H, the most characters of the answer: two digits.
58BD
LD HL,5BDDH 21 DD 5B
Point Register Pair HL to 5BDDH, the prompt Cylinder.
58C0
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
58C3
LD A,00H 3E 00
Load Register A with 00H, cylinder 0 for ENTER; the flags are kept.
58C5
If the Z FLAG is set (ENTER), JUMP to 58CDH with cylinder 0.
58C7
GOSUB to 5920H to take the hexadecimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
58CA
If the NC FLAG is set (a bad number), JUMP to 58BBH to ask again.
58CC
LD A,E 7B
Load Register A with Register E, the cylinder.
58CD
LD (5D30H),A 32 30 5D
Store Register A, the cylinder, into 5D30H, the cylinder in use.
58D0
GOSUB to 595CH to put the geometry of cylinder 0 or of the other cylinders into the DCT.
58D3
RET C9
RETurn to the caller with the cylinder at 5D30H.
58D4
LD B,02H 06 02
Load Register B with 02H, the most characters of the answer: two digits.
58D6
LD HL,5BE6H 21 E6 5B
Point Register Pair HL to 5BE6H, the prompt Sector.
58D9
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
58DC
LD A,00H 3E 00
Load Register A with 00H, sector 0 for ENTER; the flags are kept.
58DE
If the Z FLAG is set (ENTER), JUMP to 58E6H with sector 0.
58E0
GOSUB to 5920H to take the hexadecimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
58E3
If the NC FLAG is set (a bad number), JUMP to 58D4H to ask again.
58E5
LD A,E 7B
Load Register A with Register E, the low byte of the sector typed.
58E6
LD (5D2FH),A 32 2F 5D
Store Register A, the sector, into 5D2FH, the sector in use.
58E9
RET C9
RETurn to the caller with the sector at 5D2FH.
58EA
LD B,05H 06 05
Load Register B with 05H, the most characters of the answer: five digits.
58EC
LD HL,5BEDH 21 ED 5B
Point Register Pair HL to 5BEDH, the prompt Sector count.
58EF
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
58F2
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H, one sector for ENTER; the flags are kept.
58F5
If the Z FLAG is set (ENTER), JUMP to 5900H with the count 1.
58F7
GOSUB to 593EH to take the decimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
58FA
If the NC FLAG is set (a bad number), JUMP to 58EAH to ask again.
58FC
LD A,D 7A
Load Register A with Register D, the high byte of the count.
58FD
OR E B3
OR Register A with Register E, the low byte: the Z FLAG for a count of 0.
58FE
If the Z FLAG is set (0), JUMP to 58EAH to ask again.
5900
LD (5D1FH),DE ED 53 1F 5D
Store Register Pair DE, the sector count, into 5D1FH-5D20H.
5904
RET C9
RETurn to the caller with the count in Register Pair DE.
5905
LD B,03H 06 03
Load Register B with 03H, the most characters of the answer: three digits.
5907
LD HL,5BFAH 21 FA 5B
Point Register Pair HL to 5BFAH, the prompt Cylinder count.
590A
GOSUB to 5860H to show the prompt and take the answer at 5D25H: the Z FLAG for ENTER alone.
590D
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H, one cylinder for ENTER; the flags are kept.
5910
If the Z FLAG is set (ENTER), JUMP to 591BH with the count 1.
5912
GOSUB to 593EH to take the decimal number at Register Pair HL into Register Pair DE: the NC FLAG for a bad character.
5915
If the NC FLAG is set (a bad number), JUMP to 5905H to ask again.
5917
LD A,D 7A
Load Register A with Register D, the high byte of the count.
5918
OR E B3
OR Register A with Register E, the low byte: the Z FLAG for a count of 0.
5919
If the Z FLAG is set (0), JUMP to 5905H to ask again.
591B
LD (5D1FH),DE ED 53 1F 5D
Store Register Pair DE, the cylinder count, into 5D1FH-5D20H.
591F
RET C9
RETurn to the caller with the count in Register Pair DE.

5920H - Numbers

5920H a hexadecimal number at Register Pair HL into Register Pair DE, 593EH a decimal one: each ends at a character below 21H with the C FLAG, or at a bad character with the NC FLAG. In 593EH a character from 21H to 2FH is not refused (5948H): it is taken as a digit of value 241-255.

5920
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the number so far.
5923
LD A,(HL) 7E
Load Register A with the character of the answer at Register Pair HL.
5924
GOSUB to 5793H to make a lower case letter in Register A upper case.
5927
INC HL 23
INCrement Register Pair HL to the next character of the answer.
5928
CP 21H FE 21
Compare Register A against 21H: the C FLAG for the end of the number.
592A
RET C D8
If the C FLAG is set (the end), RETurn with the C FLAG and the number in Register Pair DE.
592B
GOSUB to 56CBH to take Register A as a hexadecimal digit: the NC FLAG and its value for a digit.
592E
If the NC FLAG is set (a digit), JUMP to 5932H to add it to the number.
5930
CCF 3F
Complement the C FLAG (CCF) to the NC FLAG: a bad character.
5931
RET C9
RETurn to the caller with the NC FLAG for a bad number.
5932
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL: Register Pair HL = the number so far.
5933
ADD HL,HL 29
ADD Register Pair HL to itself, the first of four that multiply the number by 16.
5934
ADD HL,HL 29
ADD Register Pair HL to itself, the second of four: the number times 4.
5935
ADD HL,HL 29
ADD Register Pair HL to itself, the third of four: the number times 8.
5936
ADD HL,HL 29
ADD Register Pair HL to itself, the fourth: the number times 16.
5937
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit.
5939
LD C,A 4F
Load Register C with Register A, the digit: Register Pair BC = the digit.
593A
ADD HL,BC 09
ADD Register Pair BC, the digit, to Register Pair HL.
593B
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL back: Register Pair DE = the number.
593C
JUMP to 5923H for the next character of the number.
593E
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the number so far.
5941
LD A,(HL) 7E
Load Register A with the character of the answer at Register Pair HL.
5942
INC HL 23
INCrement Register Pair HL to the next character of the answer.
5943
CP 21H FE 21
Compare Register A against 21H: the C FLAG for the end of the number.
5945
RET C D8
If the C FLAG is set (the end), RETurn with the C FLAG and the number in Register Pair DE.
5946
SUB 30H D6 30
SUBtract 30H from Register A: the value of a digit, the C FLAG below 0.
5948
If the C FLAG is set (below 0), JUMP to 594DH, which adds the character as a digit of 241-255.
594A
CP 0AH FE 0A
Compare Register A against 0AH: the NC FLAG past 9.
594C
RET NC D0
If the NC FLAG is set (past 9), RETurn with the NC FLAG for a bad number.
594D
PUSH HL E5
Save Register Pair HL, the place in the answer, to the top of the stack.
594E
LD H,D 62
Load Register H with Register D, the high byte of the number so far.
594F
LD L,E 6B
Load Register L with Register E: Register Pair HL = the number so far.
5950
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 2.
5951
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 4.
5952
ADD HL,DE 19
ADD Register Pair DE, the number, to Register Pair HL: the number times 5.
5953
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 10.
5954
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit.
5956
LD C,A 4F
Load Register C with Register A, the digit: Register Pair BC = the digit.
5957
ADD HL,BC 09
ADD Register Pair BC, the digit, to Register Pair HL.
5958
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL: Register Pair DE = the number.
5959
POP HL E1
Restore Register Pair HL, the place in the answer, from the top of the stack.
595A
JUMP to 5941H for the next character of the number.

595CH - The Geometry into the DCT

The drive's entry in the table at 5B04H (59A0H) goes into its DCT, unless the DCT's type byte has bit 3 (no drive): DCT+13H the cylinders, DCT+0CH the surfaces, and for cylinder 0 (5D30H) the first pair, else the second: bit 7 of DCT+0BH the density, DCT+0DH the sectors per track, DCT+11H the sectors per cylinder (sectors times surfaces by 4491H). Bit 0 of DCT+03H is set, so the DOS logs the diskette at its next use.

595C
GOSUB to 56B7H, so the rest of this routine runs with Register Pairs BC, DE and HL and Index Register IX kept.
595F
LD A,(5D2EH) 3A 2E 5D
Load Register A with the drive in use from 5D2EH.
5962
LD C,A 4F
Load Register C with Register A, the drive, for LOCDCT%.
5963
GOSUB to 59A0H to point Index Register IX to the drive's entry in the table at 5B04H.
5966
GOSUB to 44A3H, LOCDCT%, to point Index Register IY to the drive control table of drive Register C.
5969
BIT 3,(IY+00H) FD CB 00 5E
Test bit 3 of the DCT's type byte at Index Register IY+00H: set for a drive that is not there.
596D
RET NZ C0
If the NZ FLAG is set (no drive), RETurn with the DCT as it is.
596E
LD A,(IX+00H) DD 7E 00
Load Register A with the cylinders from the entry at Index Register IX+00H.
5971
LD (IY+13H),A FD 77 13
Store Register A, the cylinders, into DCT+13H at Index Register IY+13H.
5974
LD E,(IX+01H) DD 5E 01
Load Register E with the surfaces from the entry at Index Register IX+01H.
5977
LD (IY+0CH),E FD 73 0C
Store Register E, the surfaces, into DCT+0CH at Index Register IY+0CH.
597A
LD A,(5D30H) 3A 30 5D
Load Register A with the cylinder from 5D30H.
597D
OR A B7
Test Register A, the cylinder: the Z FLAG for cylinder 0.
597E
If the Z FLAG is set (cylinder 0), JUMP to 5984H with the first pair of the entry.
5980
INC IX DD 23
INCrement Index Register IX, the first of two that move to the second pair.
5982
INC IX DD 23
INCrement Index Register IX: the second pair, for the other cylinders.
5984
LD A,(IY+0BH) FD 7E 0B
Load Register A with DCT+0BH at Index Register IY+0BH, whose bit 7 is double density.
5987
AND 7FH E6 7F
AND Register A with 7FH, clearing bit 7, the density.
5989
OR (IX+02H) DD B6 02
OR Register A with the density byte of the entry at Index Register IX+02H: bit 7 for double density.
598C
LD (IY+0BH),A FD 77 0B
Store Register A, the flags with the density, into DCT+0BH at Index Register IY+0BH.
598F
LD A,(IX+03H) DD 7E 03
Load Register A with the sectors per track from the entry at Index Register IX+03H.
5992
LD (IY+0DH),A FD 77 0D
Store Register A, the sectors per track, into DCT+0DH at Index Register IY+0DH.
5995
GOSUB to 4491H, the 8 bit multiply: Register A = Register A times Register E, the sectors of a cylinder.
5998
LD (IY+11H),A FD 77 11
Store Register A, the sectors of a cylinder, into DCT+11H at Index Register IY+11H.
599B
SET 0,(IY+03H) FD CB 03 C6
Set bit 0 of DCT+03H at Index Register IY+03H: the DOS logs the diskette at its next use.
599F
RET C9
RETurn to the caller with the geometry in the DCT.
59A0
PUSH DE D5
Save Register Pair DE to the top of the stack.
59A1
ADD A,A 87
ADD Register A, the drive, to itself: two times the drive.
59A2
LD E,A 5F
Load Register E with Register A, two times the drive.
59A3
ADD A,A 87
ADD Register A to itself: four times the drive.
59A4
ADD A,E 83
ADD Register E to Register A: six times the drive, the offset of its entry.
59A5
LD E,A 5F
Load Register E with Register A, the offset of the entry.
59A6
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the offset.
59A8
LD IX,5B04H DD 21 04 5B
Point Index Register IX to 5B04H, the table of the eight drives' geometry.
59AC
ADD IX,DE DD 19
ADD Register Pair DE, the offset, to Index Register IX: the drive's entry.
59AE
POP DE D1
Restore Register Pair DE from the top of the stack.
59AF
RET C9
RETurn to the caller with Index Register IX at the drive's entry.

59B0H - Read, Write and Home

59B0H reads the sector at 5D2FH (sector) and 5D30H (cylinder) of the drive into 5E00H, 59B3H into Register Pair HL, by DREAD; the code 06H (the directory's address mark) counts as good and sets 5D1EH to 01H, else 00H. 59CFH writes 5E00H, 59D2H Register Pair HL, by DWRITE (05H) or, when 5D1EH is 01H, DWRITA (08H). 59E9H DHOME.

59B0
LD HL,5E00H 21 00 5E
Point Register Pair HL to 5E00H, the sector buffer.
59B3
GOSUB to 56B7H, so the rest of this routine runs with Register Pairs BC, DE and HL and Index Register IX kept.
59B6
LD A,(5D2EH) 3A 2E 5D
Load Register A with the drive in use from 5D2EH.
59B9
LD C,A 4F
Load Register C with Register A, the drive, for DISKIO%.
59BA
LD DE,(5D2FH) ED 5B 2F 5D
Load Register Pair DE with 5D2FH-5D30H: Register E the sector, Register D the cylinder.
59BE
LD A,03H 3E 03
Load Register A with 03H, the function DREAD of DISKIO%: read sector Register E of cylinder Register D.
59C0
GOSUB to 4488H, DISKIO%, to read the sector into Register Pair HL.
59C3
If the Z FLAG is set (read with the normal mark, Register A 00H), JUMP to 59CAH.
59C5
CP 06H FE 06
Compare Register A against 06H, the code of a sector with the directory's address mark.
59C7
RET NZ C0
If the NZ FLAG is set (another error), RETurn with the error code in Register A.
59C8
SUB 05H D6 05
SUBtract 05H from Register A: 01H, the directory's address mark.
59CA
LD (5D1EH),A 32 1E 5D
Store Register A, 00H or 01H, the address mark, into 5D1EH.
59CD
XOR A AF
Set Register A to 00H (XOR A) and the Z FLAG: the sector was read.
59CE
RET C9
RETurn to the caller with the Z FLAG: the sector is in the buffer.
59CF
LD HL,5E00H 21 00 5E
Point Register Pair HL to 5E00H, the sector buffer.
59D2
GOSUB to 56B7H, so the rest of this routine runs with Register Pairs BC, DE and HL and Index Register IX kept.
59D5
LD A,(5D2EH) 3A 2E 5D
Load Register A with the drive in use from 5D2EH.
59D8
LD C,A 4F
Load Register C with Register A, the drive, for DISKIO%.
59D9
LD DE,(5D2FH) ED 5B 2F 5D
Load Register Pair DE with 5D2FH-5D30H: Register E the sector, Register D the cylinder.
59DD
LD A,(5D1EH) 3A 1E 5D
Load Register A with the address mark from 5D1EH: 00H or 01H.
59E0
LD B,A 47
Load Register B with Register A, the address mark.
59E1
ADD A,A 87
ADD Register A to itself: two times the mark.
59E2
ADD A,B 80
ADD Register B to Register A: three times the mark.
59E3
ADD A,05H C6 05
ADD 05H to Register A: 05H DWRITE, or 08H DWRITA for the directory's mark.
59E5
GOSUB to 4488H, DISKIO%, to write the sector at Register Pair HL.
59E8
RET C9
RETurn to the caller with the Z FLAG, or the error code in Register A.
59E9
LD A,01H 3E 01
Load Register A with 01H, the function DHOME of DISKIO%: send the head to cylinder 0.
59EB
GOSUB to 4488H, DISKIO%, to send drive Register C to cylinder 0.
59EE
RET C9
RETurn to the caller with the result of DHOME.

59EFH - Format a Cylinder

Each side of cylinder Register D (Register E 00H, then DCT+0DH for the second side when DCT+0CH is 2). 5A03H: the track's number (the cylinder, or twice it plus the side), the first sector's place (twice the interleave Register H times the track, modulo the sectors per track), the sector order at 5E00H (each sector the interleave further on, past the end once round, or the next free place), the track built at 5F00H from the description at 5AD8H (single density) or 5AEEH (double): count and byte pairs, the ID (FEH, cylinder, side, sector, 01H, F7H), the data mark FBH and 256 bytes of 6CH, F7H; then DFORMT. An interleave greater than the sectors per track can place a number outside the order's table.

59EF
PUSH DE D5
Save Register Pair DE, the cylinder in Register D, to the top of the stack.
59F0
LD E,00H 1E 00
Load Register E with 00H, the first side of the cylinder.
59F2
GOSUB to 5A03H to format the first side of cylinder Register D.
59F5
If the NZ FLAG is set (an error), JUMP to 5A01H to return it.
59F7
LD A,(IY+0CH) FD 7E 0C
Load Register A with the surfaces, DCT+0CH, at Index Register IY+0CH.
59FA
DEC A 3D
DECrement Register A: the NZ FLAG for two surfaces.
59FB
LD E,(IY+0DH) FD 5E 0D
Load Register E with the sectors per track, DCT+0DH, at Index Register IY+0DH, the first sector of the second side.
59FE
If the NZ FLAG is set (two surfaces), GOSUB to 5A03H to format the second side.
5A01
POP DE D1
Restore Register Pair DE, the cylinder, from the top of the stack.
5A02
RET C9
RETurn to the caller with the Z FLAG, or the error code in Register A.
5A03
PUSH HL E5
Save Register Pair HL, the interleave in Register H, to the top of the stack.
5A04
PUSH BC C5
Save Register Pair BC, the drive in Register C, to the top of the stack.
5A05
PUSH DE D5
Save Register Pair DE, the cylinder and the side, to the top of the stack.
5A06
LD B,D 42
Load Register B with Register D, the cylinder: the track's number on one side.
5A07
LD A,(IY+0CH) FD 7E 0C
Load Register A with the surfaces, DCT+0CH, at Index Register IY+0CH.
5A0A
DEC A 3D
DECrement Register A: the Z FLAG for one surface.
5A0B
If the Z FLAG is set (one surface), JUMP to 5A14H with the cylinder as the track.
5A0D
SLA B CB 20
Shift Register B left one bit (SLA): two times the cylinder.
5A0F
INC E 1C
INCrement Register E, the first of two that test the side.
5A10
DEC E 1D
DECrement Register E again: the Z FLAG for the first side.
5A11
If the Z FLAG is set (the first side), JUMP to 5A14H.
5A13
INC B 04
INCrement Register B: the track of the second side.
5A14
LD E,B 58
Load Register E with Register B, the track's number.
5A15
LD A,H 7C
Load Register A with Register H, the interleave.
5A16
ADD A,A 87
ADD Register A to itself: two times the interleave.
5A17
GOSUB to 4491H, the 8 bit multiply: Register A = Register A times Register E, the skew of the track.
5A1A
LD E,A 5F
Load Register E with Register A, the skew of the track.
5A1B
LD C,(IY+0DH) FD 4E 0D
Load Register C with the sectors per track, DCT+0DH, at Index Register IY+0DH.
5A1E
LD A,C 79
Load Register A with Register C, the sectors per track.
5A1F
GOSUB to 4494H, the 8 bit divide: Register A = Register E divided by Register A, Register E = the remainder, the first place.
5A22
LD A,E 7B
Load Register A with Register E, the place of the first sector on the track.
5A23
LD D,H 54
Load Register D with Register H, the interleave.
5A24
LD HL,5E00H 21 00 5E
Point Register Pair HL to 5E00H, the table of the sector order.
5A27
LD B,C 41
Load Register B with Register C, the sectors per track.
5A28
LD (HL),FFH 36 FF
Store FFH into the table at Register Pair HL: the place is free.
5A2A
INC HL 23
INCrement Register Pair HL to the next place of the table.
5A2B
DECrement Register B and, while it is not zero, LOOP BACK to 5A28H (DJNZ).
5A2D
LD E,00H 1E 00
Load Register E with 00H, the first sector number to place.
5A2F
LD B,C 41
Load Register B with Register C, the sectors to place.
5A30
CP C B9
Compare Register A, the place, against Register C, the sectors per track: the C FLAG on the track.
5A31
If the C FLAG is set (on the track), JUMP to 5A34H.
5A33
SUB C 91
SUBtract Register C, the sectors per track, from Register A, once round the track.
5A34
PUSH DE D5
Save Register Pair DE, the sector number and the interleave, to the top of the stack.
5A35
LD HL,5E00H 21 00 5E
Point Register Pair HL to 5E00H, the table of the sector order.
5A38
LD E,A 5F
Load Register E with Register A, the place in the sector order.
5A39
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the place.
5A3B
ADD HL,DE 19
ADD Register Pair DE, the place, to Register Pair HL.
5A3C
POP DE D1
Restore Register Pair DE, the sector number and the interleave, from the top of the stack.
5A3D
BIT 7,(HL) CB 7E
Test bit 7 of the table at Register Pair HL: set while the place is free.
5A3F
If the NZ FLAG is set (free), JUMP to 5A44H to put the sector there.
5A41
INC A 3C
INCrement Register A to the next place of the sector order.
5A42
JUMP to 5A30H to try that place of the sector order.
5A44
LD (HL),E 73
Store Register E, the sector number, at the place at Register Pair HL.
5A45
INC E 1C
INCrement Register E to the next sector number.
5A46
ADD A,D 82
ADD Register D, the interleave, to Register A: the place of the next sector.
5A47
DECrement Register B and, while it is not zero, LOOP BACK to 5A30H for the next sector (DJNZ).
5A49
POP DE D1
Restore Register Pair DE, the cylinder and the side, from the top of the stack.
5A4A
POP BC C1
Restore Register Pair BC, the drive, from the top of the stack.
5A4B
PUSH BC C5
Save Register Pair BC, the drive, to the top of the stack again.
5A4C
PUSH DE D5
Save Register Pair DE, the cylinder and the side, to the top of the stack again.
5A4D
LD A,E 7B
Load Register A with Register E, the side: 00H or the first sector of the second side.
5A4E
OR A B7
Test Register A: the Z FLAG for the first side.
5A4F
If the Z FLAG is set (the first side), JUMP to 5A53H with 00H.
5A51
LD A,01H 3E 01
Load Register A with 01H, the side byte of the IDs of the second side.
5A53
LD (5A8EH),A 32 8E 5A
Store Register A, the side, into 5A8EH, the operand of the LD (HL) at 5A8DH.
5A56
LD A,D 7A
Load Register A with Register D, the cylinder.
5A57
LD (5A8BH),A 32 8B 5A
Store Register A, the cylinder, into 5A8BH, the operand of the LD (HL) at 5A8AH.
5A5A
LD HL,5AEEH 21 EE 5A
Point Register Pair HL to 5AEEH, the description of a double density track.
5A5D
BIT 7,(IY+0BH) FD CB 0B 7E
Test bit 7 of DCT+0BH at Index Register IY+0BH: set for double density.
5A61
If the NZ FLAG is set (double density), JUMP to 5A66H.
5A63
LD HL,5AD8H 21 D8 5A
Point Register Pair HL to 5AD8H, the description of a single density track.
5A66
LD C,(IY+0DH) FD 4E 0D
Load Register C with the sectors per track, DCT+0DH, at Index Register IY+0DH.
5A69
LD DE,5E00H 11 00 5E
Point Register Pair DE to 5E00H, the table of the sector order.
5A6C
PUSH DE D5
Save Register Pair DE, the place in the sector order, to the top of the stack.
5A6D
EX DE,HL EB
EXchange Register Pair DE with Register Pair HL: Register Pair DE = the description.
5A6E
LD HL,5F00H 21 00 5F
Point Register Pair HL to 5F00H, the buffer of the track.
5A71
GOSUB to 5ACEH for the first pair of the description at the start of the track.
5A74
GOSUB to 5ACEH for the second pair of the start of the track.
5A77
GOSUB to 5ACEH for the third pair of the start of the track.
5A7A
LD (5A7FH),DE ED 53 7F 5A
Store Register Pair DE, the description of a sector, into 5A7FH-5A80H, the operand of the LD DE at 5A7EH.
5A7E
LD DE,0000H 11 00 00
Load Register Pair DE with the description of a sector, the operand set at 5A7AH (0000H as loaded).
5A81
GOSUB to 5ACEH for the first pair before the ID of the sector.
5A84
GOSUB to 5ACEH for the second pair before the ID.
5A87
LD (HL),FEH 36 FE
Store FEH, the ID address mark, at Register Pair HL.
5A89
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5A8A
LD (HL),00H 36 00
Store the cylinder, the operand 5A8BH set at 5A57H (00H as loaded), at Register Pair HL.
5A8C
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5A8D
LD (HL),00H 36 00
Store the side, the operand 5A8EH set at 5A53H (00H as loaded), at Register Pair HL.
5A8F
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5A90
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the place in the sector order.
5A91
LD A,(HL) 7E
Load Register A with the sector number at Register Pair HL.
5A92
INC HL 23
INCrement Register Pair HL to the next place in the sector order.
5A93
EX (SP),HL E3
EXchange Register Pair HL with the top of the stack at the Stack Pointer: Register Pair HL = the track again.
5A94
LD (HL),A 77
Store Register A, the sector number, at Register Pair HL.
5A95
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5A96
LD (HL),01H 36 01
Store 01H, the size code of 256 bytes, at Register Pair HL.
5A98
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5A99
LD (HL),F7H 36 F7
Store F7H, which makes the controller write the two bytes of the ID's CRC, at Register Pair HL.
5A9B
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5A9C
GOSUB to 5ACEH for the first pair after the ID.
5A9F
GOSUB to 5ACEH for the second pair after the ID.
5AA2
GOSUB to 5ACEH for the third pair after the ID.
5AA5
LD B,80H 06 80
Load Register B with 80H, the 128 pairs of the 256 data bytes.
5AA7
LD (HL),FBH 36 FB
Store FBH, the data address mark, at Register Pair HL.
5AA9
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5AAA
LD (HL),6CH 36 6C
Store 6CH, the data of a new sector, at Register Pair HL.
5AAC
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5AAD
LD (HL),6CH 36 6C
Store 6CH, the data of a new sector, at Register Pair HL.
5AAF
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5AB0
DECrement Register B and, while it is not zero, LOOP BACK to 5AAAH for the next two bytes (DJNZ).
5AB2
LD (HL),F7H 36 F7
Store F7H, which makes the controller write the data's CRC, at Register Pair HL.
5AB4
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5AB5
GOSUB to 5ACEH for the pair after the data, the gap.
5AB8
DEC C 0D
DECrement Register C, the sectors of the track left to build.
5AB9
If the NZ FLAG is set (more sectors), JUMP to 5A7EH for the next sector.
5ABB
GOSUB to 5ACEH for the first pair at the end of the track.
5ABE
GOSUB to 5ACEH for the second pair at the end of the track.
5AC1
POP DE D1
Restore Register Pair DE from the top of the stack, which drops the place in the sector order.
5AC2
POP DE D1
Restore Register Pair DE, the cylinder in Register D and the side in Register E, from the top of the stack.
5AC3
POP BC C1
Restore Register Pair BC, the drive in Register C, from the top of the stack.
5AC4
LD HL,5F00H 21 00 5F
Point Register Pair HL to 5F00H, the track built.
5AC7
LD A,09H 3E 09
Load Register A with 09H, the function DFORMT of DISKIO%: write the track at Register Pair HL.
5AC9
GOSUB to 4488H, DISKIO%, to format the track of cylinder Register D, the side by Register E.
5ACC
POP HL E1
Restore Register Pair HL, the interleave in Register H, from the top of the stack.
5ACD
RET C9
RETurn to the caller with the Z FLAG, or the error code in Register A.
5ACE
LD A,(DE) 1A
Load Register A with the count of the pair at Register Pair DE.
5ACF
INC DE 13
INCrement Register Pair DE to the byte of the pair.
5AD0
LD B,A 47
Load Register B with Register A, the count: 00H for 256.
5AD1
LD A,(DE) 1A
Load Register A with the byte of the pair at Register Pair DE.
5AD2
INC DE 13
INCrement Register Pair DE to the next pair of the description.
5AD3
LD (HL),A 77
Store Register A, the byte, at Register Pair HL in the track.
5AD4
INC HL 23
INCrement Register Pair HL to the next byte of the track.
5AD5
DECrement Register B and, while it is not zero, LOOP BACK to 5AD3H (DJNZ).
5AD7
RET C9
RETurn to the caller with the bytes of the pair in the track.

5AD8H - The Track Descriptions

Pairs of a count (00H for 256) and a byte, taken by 5ACEH: three at the start of the track, then for each sector two before the ID, three after it and one after the data, then two at the end of the track. 5AD8H single density, 5AEEH double density (F5H makes the controller write the A1H sync bytes).

5AD8-5AD9
DEFB 0BH,FFH 0B FF
Single density, the start of the track: 11 bytes of FFH.
5ADA-5ADB
DEFB 01H,FCH 01 FC
Single density, the start of the track: 1 byte of FCH, the index address mark.
5ADC-5ADD
DEFB 14H,FFH 14 FF
Single density, the start of the track: 20 bytes of FFH.
5ADE-5ADF
DEFB 03H,00H 03 00
Single density, before each ID: 3 bytes of 00H.
5AE0-5AE1
DEFB 03H,00H 03 00
Single density, before each ID: 3 bytes of 00H, the second pair.
5AE2-5AE3
DEFB 0BH,FFH 0B FF
Single density, after each ID: 11 bytes of FFH.
5AE4-5AE5
DEFB 03H,00H 03 00
Single density, after each ID: 3 bytes of 00H, the second pair.
5AE6-5AE7
DEFB 03H,00H 03 00
Single density, after each ID: 3 bytes of 00H, the third pair.
5AE8-5AE9
DEFB 0BH,FFH 0B FF
Single density, after the data of each sector: 11 bytes of FFH.
5AEA-5AEB
DEFB 00H,FFH 00 FF
Single density, the end of the track: 256 bytes of FFH.
5AEC-5AED
DEFB 00H,FFH 00 FF
Single density, the end of the track: 256 more bytes of FFH.
5AEE-5AEF
DEFB 16H,4EH 16 4E
Double density, the start of the track: 22 bytes of 4EH.
5AF0-5AF1
DEFB 01H,FCH 01 FC
Double density, the start of the track: 1 byte of FCH, the index address mark.
5AF2-5AF3
DEFB 28H,4EH 28 4E
Double density, the start of the track: 40 bytes of 4EH.
5AF4-5AF5
DEFB 08H,00H 08 00
Double density, before each ID: 8 bytes of 00H.
5AF6-5AF7
DEFB 03H,F5H 03 F5
Double density, before each ID: 3 bytes of F5H, the sync bytes.
5AF8-5AF9
DEFB 16H,4EH 16 4E
Double density, after each ID: 22 bytes of 4EH.
5AFA-5AFB
DEFB 0CH,00H 0C 00
Double density, after each ID: 12 bytes of 00H, the second pair.
5AFC-5AFD
DEFB 03H,F5H 03 F5
Double density, after each ID: 3 bytes of F5H, the sync bytes.
5AFE-5AFF
DEFB 18H,4EH 18 4E
Double density, after the data of each sector: 24 bytes of 4EH.
5B00-5B01
DEFB 00H,4EH 00 4E
Double density, the end of the track: 256 bytes of 4EH.
5B02-5B03
DEFB 00H,4EH 00 4E
Double density, the end of the track: 256 more bytes of 4EH.

5B04H - The Geometry of the Drives

Six bytes for each of the eight drives, as loaded 40 cylinders, one surface and 18 sectors of double density on every cylinder: +00H the cylinders, +01H the surfaces, +02H the density of cylinder 0 (bit 7 double), +03H its sectors per track, +04H the density of the other cylinders, +05H their sectors per track. Set changes them; 595CH puts them into the DCT.

5B04-5B09
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 0: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.
5B0A-5B0F
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 1: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.
5B10-5B15
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 2: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.
5B16-5B1B
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 3: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.
5B1C-5B21
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 4: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.
5B22-5B27
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 5: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.
5B28-5B2D
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 6: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.
5B2E-5B33
DEFB 28H,01H,80H,12H,80H,12H 28 01 80 12 80 12
Drive 7: 40 cylinders, 1 surface, cylinder 0 double density with 18 sectors, the others double density with 18 sectors.

5B34H - The Texts

The menu (shown after the codes 1CH 1FH that clear the screen), the prompts, the status line, continue ? and the texts of the errors, each ended by 00H (the menu by 0DH for each line).

5B34-5B35
DEFB 1CH,1FH 1C 1F
The codes that put the cursor at the top left and clear the screen, before the menu.
5B36-5B61
DEFM "DISKZAP - DOSPLUS Disk zapper/editor - 3.50" / DEFB 0DH 44 49 53 4B 5A 41 50 20 2D 20 44 4F 53 50 4C 55 53 20 44 69 73 6B 20 7A 61 70 70 65 72 2F 65 64 69 74 6F 72 20 2D 20 33 2E 35 30 0D
The heading of the menu: DISKZAP - DOSPLUS Disk zapper/editor - 3.50 and a carriage return.
5B62-5B91
DEFM "(c) Copyright 1983, Micro-Systems Software Inc." / DEFB 0DH 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 0D
The copyright line of the heading and a carriage return.
5B92
DEFB 0DH 0D
The carriage return of the empty line before the options.
5B93-5B99
DEFM " Set" / DEFB 0DH 20 20 20 53 65 74 0D
Menu line 1 (5265H), Set: the geometry of a drive.
5B9A-5BA1
DEFM " Fill" / DEFB 0DH 20 20 20 46 69 6C 6C 0D
Menu line 2 (5269H), Fill: sectors filled with one byte.
5BA2-5BA9
DEFM " Copy" / DEFB 0DH 20 20 20 43 6F 70 79 0D
Menu line 3 (526DH), Copy: sectors from one place to another.
5BAA-5BB2
DEFM " Print" / DEFB 0DH 20 20 20 50 72 69 6E 74 0D
Menu line 4 (5271H), Print: sectors to the printer.
5BB3-5BBC
DEFM " Verify" / DEFB 0DH 20 20 20 56 65 72 69 66 79 0D
Menu line 5 (5275H), Verify: sectors read and checked.
5BBD-5BC6
DEFM " Format" / DEFB 0DH 20 20 20 46 6F 72 6D 61 74 0D
Menu line 6 (5279H), Format: cylinders formatted.
5BC7-5BD1
DEFM " Display" / DEFB 0DH 20 20 20 44 69 73 70 6C 61 79 0D
Menu line 7, Display: a sector shown and changed.
5BD2
DEFB 00H 00
The 00H that ends the text of the menu for 5857H.
5BD3-5BDC
DEFM "Drivespec" / DEFB 00H 44 72 69 76 65 73 70 65 63 00
The prompt Drivespec (587EH), a name of DCTTBL, ended by 00H.
5BDD-5BE5
DEFM "Cylinder" / DEFB 00H 43 79 6C 69 6E 64 65 72 00
The prompt Cylinder, a hexadecimal number (58BDH).
5BE6-5BEC
DEFM "Sector" / DEFB 00H 53 65 63 74 6F 72 00
The prompt Sector, a hexadecimal number (58D6H).
5BED-5BF9
DEFM "Sector count" / DEFB 00H 53 65 63 74 6F 72 20 63 6F 75 6E 74 00
The prompt Sector count, a decimal number (58ECH).
5BFA-5C08
DEFM "Cylinder count" / DEFB 00H 43 79 6C 69 6E 64 65 72 20 63 6F 75 6E 74 00
The prompt Cylinder count, a decimal number (54A4H, 5907H).
5C09-5C1A
DEFM "Interleave factor" / DEFB 00H 49 6E 74 65 72 6C 65 61 76 65 20 66 61 63 74 6F 72 00
The prompt Interleave factor of Format (5686H).
5C1B-5C24
DEFM "Fill data" / DEFB 00H 46 69 6C 6C 20 64 61 74 61 00
The prompt Fill data, a hexadecimal number (5539H).
5C25-5C32
DEFM "Surface count" / DEFB 00H 53 75 72 66 61 63 65 20 63 6F 75 6E 74 00
The prompt Surface count of Set (54BAH), ended by 00H.
5C33-5C40
DEFM "CYL 0 sec/trk" / DEFB 00H 43 59 4C 20 30 20 73 65 63 2F 74 72 6B 00
The prompt CYL 0 sec/trk of Set (54D0H), ended by 00H.
5C41-5C4E
DEFM "CYL 0 density" / DEFB 00H 43 59 4C 20 30 20 64 65 6E 73 69 74 79 00
The prompt CYL 0 density of Set (54E6H), ended by 00H.
5C4F-5C5C
DEFM "Sectors/track" / DEFB 00H 53 65 63 74 6F 72 73 2F 74 72 61 63 6B 00
The prompt Sectors/track of Set (54FFH), ended by 00H.
5C5D-5C6A
DEFM "Track density" / DEFB 00H 54 72 61 63 6B 20 64 65 6E 73 69 74 79 00
The prompt Track density of Set (5515H), ended by 00H.
5C6B-5C79
DEFM "Ignore data AM" / DEFB 00H 49 67 6E 6F 72 65 20 64 61 74 61 20 41 4D 00
The prompt Ignore data AM of Verify (563AH), ended by 00H.
5C7A-5C9C
DEFM "Drive $00, Cylinder 00, Sector 00 " / DEFB 00H 44 72 69 76 65 20 24 30 30 2C 20 43 79 6C 69 6E 64 65 72 20 30 30 2C 20 53 65 63 74 6F 72 20 30 30 20 00
The status line (57F8H); the drive is written at 5C81H, the cylinder at 5C8EH and the sector at 5C99H.
5C9D-5CA9
DEFM " continue ? " / DEFB 00H 20 63 6F 6E 74 69 6E 75 65 20 3F 20 00
The question after an error (580EH): continue ?
5CAA
DEFB 00H 00
The empty text before the texts of the errors (5838H).
5CAB-5CAC
DEFM "?" / DEFB 00H 3F 00
Error text 1: a question mark (codes 01H and 09H).
5CAD-5CAE
DEFM "?" / DEFB 00H 3F 00
Error text 2: a question mark (codes 02H and 0AH).
5CAF-5CB9
DEFM "LOST DATA!" / DEFB 00H 4C 4F 53 54 20 44 41 54 41 21 00
Error text 3 (codes 03H and 0BH): LOST DATA!, ended by 00H.
5CBA-5CC4
DEFM "CRC ERROR!" / DEFB 00H 43 52 43 20 45 52 52 4F 52 21 00
Error text 4 (codes 04H and 0CH): CRC ERROR!, ended by 00H.
5CC5-5CD6
DEFM "SECTOR NOT FOUND!" / DEFB 00H 53 45 43 54 4F 52 20 4E 4F 54 20 46 4F 55 4E 44 21 00
Error text 5 (codes 05H and 0DH): SECTOR NOT FOUND!
5CD7-5CE6
DEFM "AM/WRITE FAULT!" / DEFB 00H 41 4D 2F 57 52 49 54 45 20 46 41 55 4C 54 21 00
Error text 6 (codes 06H and 0EH, and the address mark of Verify): AM/WRITE FAULT!
5CE7-5CF7
DEFM "WRITE PROTECTED!" / DEFB 00H 57 52 49 54 45 20 50 52 4F 54 45 43 54 45 44 21 00
Error text 7 (codes 07H and 0FH): WRITE PROTECTED!
5CF8-5D02
DEFM "NOT READY!" / DEFB 00H 4E 4F 54 20 52 45 41 44 59 21 00
Error text 8 (codes 08H and 10H): NOT READY!, ended by 00H.
5D03-5D17
DEFM "DRIVE NOT SUPPORTED!" / DEFB 00H 44 52 49 56 45 20 4E 4F 54 20 53 55 50 50 4F 52 54 45 44 21 00
Text 9, shown by Format for a rigid drive (567DH): DRIVE NOT SUPPORTED!
5D18
DEFB 00H 00
The flag of the sector display (522EH, 5769H): 00H until a sector has been shown, then FFH.
5D19
DEFB 00H 00
The flag of the character display (5444H): 00H hexadecimal, FFH characters.
5D1A
DEFB 00H 00
The phase of the flashing of F (52F9H): 00H the graphic blocks, FFH the bytes.
5D1B
DEFB 01H 01
The menu line of the asterisk (5235H): 1 Set up to 7 Display.
5D1C-5D1D
DEFW 3CC1H C1 3C
The video address of the asterisk (5231H), as loaded the line of Set.
5D1E
DEFS 1
The address mark of the sector (59CAH): 00H normal, 01H the directory's, used again when it is written (59DDH).
5D1F-5D20
DEFS 2
The count of sectors or cylinders left (5900H, 57CDH).
5D21-5D22
DEFS 2
The count at the start of a pass of Copy (5583H).
5D23-5D24
DEFS 2
The room from 5F00H up to HMEM$ (5216H); its high byte at 5D24H is the sectors of one pass of Copy.
5D25-5D2A
DEFS 6
The answer to a prompt (5872H) and the keys of a hexadecimal number (545FH).
5D2B-5D2D
DEFS 3
The other position of Copy (55DDH): drive, sector and cylinder.
5D2E
DEFS 1
The drive in use (58B4H), 0-7, the place in DCTTBL.
5D2F
DEFS 1
The sector (58E6H), a byte below the cylinder for LD DE.
5D30
DEFS 1
The cylinder in use (58CDH), after the sector for LD DE.
5E00-5EFF
DEFS 256
The sector buffer (59B0H); also the address marks of a pass of Copy (5589H) and the sector order of Format (5A24H).
5F00
DEFS 1
The start of the buffer of Copy, one page for each sector up to HMEM$ (5586H), and of the track built by Format (5A6EH).