4E00H - Entry: Function 1 Only
SYS10/SYS is loaded at 4E00H by the request handler of SYS0/SYS (4C31H) for a request code whose bits 3-0 are CH (directory entry code 24H) and called at 4E00H with Register A = the request code. Its one function is 1, request 9CH, which SYS0/SYS's 442CH issues: Register Pair DE = the control block of an open file or device. KILL (SYS6/SYS member 4), PURGE (member 27) and SYSGEN (member 9) call 442CH. Any other code returns at once.
4E00
AND 70H E6 70
Mask Register A (the request code) with 70H, keeping bits 6-4, the function number times 10H.
4E02
CP 10H FE 10
Compare Register A against 10H, function 1 (request 9CH).
4E04
RET NZ C0
If the NZ FLAG is set (another function), RETURN to the request handler with Register A = the masked code and the NZ FLAG.
4E05H - Function 1: Remove a File or a Device
Register Pair DE = the control block. A first byte 00H-1FH (bits 7-5 all 0; SYS2/SYS's device open stores 10H) goes to 4E6DH; an open file has 80H or above, and a block that is not open takes the file path and gets error 26H. For a file the control block must be open (49EBH, error 26H) with access level 0 or 1 (the full access or the KILL level of the passwords), else error 25H. The allocation table of the drive is read into 5100H, and each directory record of the file, the first one and the extension records its link bytes name, has its extents given back on the table (4EE4H), its in use bit 4 cleared and its hash index byte set to 00H. The table is then written back and the 32 bytes of the control block cleared. 49EBH has saved Register Pairs BC, DE, HL and Index Register IX; the RETURNs of function 1 go through SYS0/SYS's 4A0CH, which restores them.
4E05
LD A,(DE) 1A
Fetch the first byte of the control block at Register Pair DE into Register A.
4E06
AND E0H E6 E0
Mask Register A to bits 7-5: 00H for a first byte 00H-1FH (SYS2/SYS's device open stores 10H), not 00H for an open file (80H and up) or a block that is not open (a letter, which then gets error 26H).
4E08
If the Z FLAG is set (a device), JUMP to 4E6DH.
4E0A
GOSUB to 49EBH to check that the control block at Register Pair DE is open: it stores Register Pair DE at 430AH and the return address 4E0DH at 430CH, points Index Register IX at the block and saves Register Pairs BC, DE, HL and Index Register IX under the return address 4A0CH. Not open: error 26H to the request handler (4C4BH), which returns to the caller of 442CH.
4E0D
LD A,(IX+01H) DD 7E 01
Fetch byte +01H of the control block at Index Register IX into Register A: bits 2-0 the access level the open granted.
4E10
AND 07H E6 07
Mask Register A to bits 2-0, the access level.
4E12
CP 02H FE 02
Compare Register A against 02H: the C FLAG is set for level 0 (full access) or 1 (KILL).
4E14
If the C FLAG is set (removing is allowed), JUMP to 4E1AH.
4E16
LD A,25H 3E 25
Load Register A with 25H, the error ILLEGAL ACCESS ATTEMPTED TO PROTECTED FILE.
4E18
OR A B7
OR Register A with itself: the NZ FLAG set for the error.
4E19
RET C9
RETURN with error 25H through 4A0CH, which restores the saved registers.
4E1A
LD C,(IX+06H) DD 4E 06
Fetch the drive from +06H of the control block at Index Register IX into Register C.
4E1D
LD B,(IX+07H) DD 46 07
Fetch the directory entry code of the file from +07H of the control block at Index Register IX into Register B.
4E20
GOSUB to 4F21H to read the allocation table of drive Register C into 5100H: the NZ FLAG and error 14H when it cannot be read.
4E23
RET NZ C0
If the NZ FLAG is set (the table could not be read), RETURN with error 14H.
4E24H - Give Back the Extents of a Record
Register B = the entry code of the record, Register C = the drive. The record is read (4B10H) and its extents from +16H (cylinder, granule byte) are given back one by one (4EE4H) up to the pair FEH (the link to an extension record, whose entry code follows) or FFH (the end). The last pair read is kept at 4E56H for 4E55H. 4E5CH comes back here for each extension record.
4E24
GOSUB to 4B10H to read the directory sector of entry Register B, drive Register C, into 4200H: Register Pair HL = the record; error 11H when it fails.
4E27
RET NZ C0
If the NZ FLAG is set (the directory read failed), RETURN with error 11H.
4E28
LD A,16H 3E 16
Load Register A with 16H, the offset of the extents in a directory record.
4E2A
ADD A,L 85
Add Register L (the low byte of the record's address) to Register A.
4E2B
LD L,A 6F
Copy Register A into Register L: Register Pair HL = +16H of the record, the first extent.
4E2C
LD E,(HL) 5E
Fetch the cylinder byte of the extent at Register Pair HL into Register E.
4E2D
INC L 2C
Increment Register L to the extent's granule byte.
4E2E
LD D,(HL) 56
Fetch the granule byte at Register Pair HL into Register D: Register Pair DE = the extent (Register E the cylinder, Register D the granule byte).
4E2F
LD (4E56H),DE ED 53 56 4E
Store Register Pair DE to 4E56H-4E57H, the operand of LD DE,0000H at 4E55H: the pair that ends the list is kept there.
4E33
LD A,E 7B
Copy Register E (the cylinder) into Register A.
4E34
CP FEH FE FE
Compare Register A against FEH: the NC FLAG for FEH (a link) or FFH (the end).
4E36
If the NC FLAG is set (the end of this record's extents), JUMP to 4E3EH.
4E38
INC L 2C
Increment Register L to the next extent's cylinder byte.
4E39
GOSUB to 4EE4H to give back the granules of the extent in Register Pair DE on the allocation table at 5100H.
4E3C
LOOP BACK to 4E2CH for the next extent at Register Pair HL.
4E3EH - Free the Record
The record's in use bit 4 is cleared and its sector written back; the hash index is read, the record's byte (entry code Register B) set to 00H and the index written back. A link (FEH) leads on to the extension record; at the end (FFH) the allocation table is written back and the control block cleared.
4E3E
LD A,L 7D
Copy Register L (inside the record) into Register A.
4E3F
AND E0H E6 E0
Mask Register A with E0H: the low byte of the record's start (records are 32 bytes).
4E41
LD L,A 6F
Copy Register A into Register L: Register Pair HL = the record's attribute byte.
4E42
RES 4,(HL) CB A6
Reset bit 4 of the attribute byte at Register Pair HL: the record is no longer in use.
4E44
GOSUB to 4B1FH to write the directory sector in 4200H back to entry Register B, drive Register C, and read it back; Register Pair HL is left at 4200H.
4E47
RET NZ C0
If the NZ FLAG is set (the write failed), RETURN with error 12H, or 0FH for a write protected diskette.
4E48
GOSUB to 4F4DH to read the hash index (directory sector 1) of drive Register C into 4200H: Register A = 16H with the read's flags.
4E4B
RET NZ C0
If the NZ FLAG is set (the index could not be read), RETURN with error 16H.
4E4C
LD H,42H 26 42
Load Register H with 42H, the page of the hash index at 4200H.
4E4E
LD L,B 68
Copy Register B (the entry code) into Register L: Register Pair HL = the record's byte in the hash index.
4E4F
LD (HL),00H 36 00
Store 00H at Register Pair HL: the record is free in the hash index.
4E51
GOSUB to 4F5FH to write the hash index back and read it back: the NZ FLAG and error 17H when it fails.
4E54
RET NZ C0
If the NZ FLAG is set (the write failed), RETURN with error 17H.
4E55
LD DE,0000H 11 00 00
Self-Modifying Code
Load Register Pair DE with the pair that ended the record's extents, the operand 4E56H-4E57H (0000H in the file, stored at 4E2FH): Register E FEH or FFH, Register D the entry code after FEH.
4E58
LD B,D 42
Copy Register D (the entry code after FEH; FFH at the end, which is not used since 4A0CH restores Register Pair BC) into Register B.
4E59
LD A,E 7B
Copy Register E (FEH or FFH) into Register A.
4E5A
CP FEH FE FE
Compare Register A against FEH, the link to an extension record.
4E5C
If the Z FLAG is set (a link), LOOP BACK to 4E24H to free the extension record of entry code Register B.
4E5E
GOSUB to 4F34H to write the allocation table at 5100H back and read it back: the NZ FLAG and error 15H when it fails.
4E61
RET NZ C0
If the NZ FLAG is set (the write failed), RETURN with error 15H.
4E62H - Clear the Control Block
The 32 bytes of the file's control block are set to 00H: byte +00H with bit 7 clear marks it not open.
4E62
PUSH IX DD E5
Save Index Register IX (the control block) to the stack.
4E64
POP HL E1
Pop the copy of Index Register IX into Register Pair HL: Register Pair HL = the control block.
4E65
LD B,20H 06 20
Load Register B with 20H, the 32 bytes of a control block.
4E67
XOR A AF
Set Register A to 00H and the Z FLAG (XOR A).
4E68
LD (HL),A 77
Store Register A (00H) at Register Pair HL, a byte of the control block.
4E69
INC HL 23
Increment Register Pair HL to the next byte of the control block.
4E6A
Decrement Register B and LOOP BACK to 4E68H until the 32 bytes are 00H.
4E6C
RET C9
RETURN with Register A = 00H and the Z FLAG through 4A0CH: the file is removed.
4E6DH - A Device
Register Pair DE = a control block that SYS2/SYS filled for a device (+06H-+07H the two letters of the name). The device control blocks 4015H, 401DH, 4025H and 43C0H-43F8H are searched for the name at their +06H-+07H; none: error 08H, DEVICE NOT AVAILABLE.
4E6D
GOSUB to 49E9H to point Index Register IX at the block at Register Pair DE, with no test that it is open: it stores Register Pair DE at 430AH and 4E70H at 430CH, and saves Register Pairs BC, DE, HL and Index Register IX under the return address 4A0CH.
4E70
LD E,(IX+06H) DD 5E 06
Fetch the first letter of the device name from +06H of the block at Index Register IX into Register E.
4E73
LD D,(IX+07H) DD 56 07
Fetch the second letter from +07H of the block at Index Register IX into Register D.
4E76
LD HL,4015H 21 15 40
Point Register Pair HL to 4015H, the KI device control block, the first one.
4E79
PUSH HL E5
Save Register Pair HL (the device control block) to the stack.
4E7A
LD A,L 7D
Copy Register L (its low byte) into Register A.
4E7B
ADD A,06H C6 06
Add 06H to Register A: the name's place in the block.
4E7D
LD L,A 6F
Copy Register A into Register L: Register Pair HL = +06H of the device control block.
4E7E
LD A,(HL) 7E
Fetch the first letter of the block's name from Register Pair HL into Register A.
4E7F
INC L 2C
Increment Register L to the second letter, +07H.
4E80
CP E BB
Compare Register A against Register E (the first letter wanted).
4E81
If the NZ FLAG is set (another name), JUMP to 4E8AH.
4E83
LD A,(HL) 7E
Fetch the second letter of the block's name from Register Pair HL into Register A.
4E84
CP D BA
Compare Register A against Register D (the second letter wanted).
4E85
If the NZ FLAG is set (another name), JUMP to 4E8AH.
4E87
POP HL E1
Restore Register Pair HL from the stack: the device control block found.
4E88
JUMP to 4E9CH to remove the device control block at Register Pair HL.
4E8A
POP AF F1
Pop the saved block address into Register Pair AF to drop it (Register A and the flags change); Register Pair HL stays at the block's +07H.
4E8B
INC L 2C
Increment Register L to +08H: the next device control block.
4E8C
If the NZ FLAG is set (Register L did not wrap: not past 43F8H), JUMP to 4E92H.
4E8E
LD A,08H 3E 08
Load Register A with 08H, the error DEVICE NOT AVAILABLE.
4E90
OR A B7
OR Register A with itself: the NZ FLAG set for the error.
4E91
RET C9
RETURN with error 08H through 4A0CH, which restores the saved registers.
4E92
LD A,L 7D
Copy Register L (low byte of the next block) into Register A.
4E93
CP 2DH FE 2D
Compare Register A against 2DH: the byte after PR's block 4025H-402CH.
4E95
If the NZ FLAG is set (still in 4015H-402CH or in 43C0H-43FFH), LOOP BACK to 4E79H.
4E97
LD HL,43C0H 21 C0 43
Point Register Pair HL to 43C0H, the JL device control block, the first of the second group.
4E9A
LOOP BACK to 4E79H to search the second group.
4E9CH - Remove the Device
Register Pair HL = the device control block found. The system devices (KI, DO, PR, JL, SI, LO: blocks below 43D8H) give error 28H, PROTECTED SYSTEM DEVICE; a device that is not NIL (type bit 3 clear) gives 27H, DEVICE IN USE. Otherwise its 8 bytes are set to 00H.
4E9C
LD A,L 7D
Copy Register L (low byte of the block) into Register A.
4E9D
CP D8H FE D8
Compare Register A against D8H: the blocks of 43D8H-43F8H give the NC FLAG; 4015H, 401DH, 4025H, 43C0H, 43C8H and 43D0H give the C FLAG.
4E9F
If the NC FLAG is set (one of the user blocks 43D8H-43F8H, which SET, LINK and ROUTE fill), JUMP to 4EA5H.
4EA1
LD A,28H 3E 28
Load Register A with 28H, the error PROTECTED SYSTEM DEVICE.
4EA3
OR A B7
OR Register A with itself: the NZ FLAG set for the error.
4EA4
RET C9
RETURN with error 28H through 4A0CH, which restores the saved registers.
4EA5
BIT 3,(HL) CB 5E
Test bit 3 of the type byte at Register Pair HL: set for a NIL device (type 08H).
4EA7
If the NZ FLAG is set (NIL), JUMP to 4EADH to remove it.
4EA9
LD A,27H 3E 27
Load Register A with 27H, the error DEVICE IN USE.
4EAB
OR A B7
OR Register A with itself: the NZ FLAG set for the error.
4EAC
RET C9
RETURN with error 27H through 4A0CH, which restores the saved registers.
4EAD
LD B,08H 06 08
Load Register B with 08H, the 8 bytes of a device control block.
4EAF
XOR A AF
Set Register A to 00H (XOR A), the value the 8 bytes get.
4EB0
LD (HL),A 77
Store Register A (00H) at Register Pair HL, a byte of the device control block.
4EB1
INC L 2C
Increment Register L to the next byte of the block.
4EB2
Decrement Register B and LOOP BACK to 4EB0H until the 8 bytes are 00H.
4EB4H - Routes to a Removed Device Become NIL
Every device control block is walked from 4015H; a routed one (type bit 4) whose target block has the type byte 00H (the block just cleared, or any free block) is made NIL (08H), and the walk starts again from 4015H. At the end the first 8 bytes of the caller's block at Index Register IX are set to 00H.
4EB4
LD HL,4015H 21 15 40
Point Register Pair HL to 4015H, the first device control block.
4EB7
BIT 4,(HL) CB 66
Test bit 4 of the type byte at Register Pair HL: set for a routed device (type 10H).
4EB9
If the Z FLAG is set (not routed), JUMP to 4ECAH for the next block.
4EBB
PUSH HL E5
Save Register Pair HL (the routed block) to the stack.
4EBC
INC L 2C
Increment Register L to +01H, the low byte of the target block's address.
4EBD
LD A,(HL) 7E
Fetch the low byte of the target's address from Register Pair HL into Register A.
4EBE
INC L 2C
Increment Register L to +02H, the high byte of the target's address.
4EBF
LD H,(HL) 66
Fetch the high byte of the target's address from Register Pair HL into Register H.
4EC0
LD L,A 6F
Copy Register A (the low byte) into Register L: Register Pair HL = the target block.
4EC1
LD A,(HL) 7E
Fetch the type byte of the target block at Register Pair HL into Register A.
4EC2
POP HL E1
Restore Register Pair HL from the stack: the routed block.
4EC3
OR A B7
OR Register A with itself: the Z FLAG is set when the target's type is 00H, a free block.
4EC4
If the NZ FLAG is set (the target is in use), JUMP to 4ECAH for the next block.
4EC6
LD (HL),08H 36 08
Store 08H at Register Pair HL, the type byte: the routed device becomes NIL (its old target stays at +01H-+02H, unused for type 08H).
4EC8
LOOP BACK to 4EB4H to walk all blocks again from 4015H.
4ECA
LD A,L 7D
Copy Register L (low byte of the block) into Register A.
4ECB
ADD A,08H C6 08
Add 08H to Register A: the next device control block.
4ECD
LD L,A 6F
Copy Register A into Register L. LD does not change the flags of the ADD.
4ECE
If the Z FLAG is set (Register L wrapped to 00H: past 43F8H), JUMP to 4ED9H.
4ED0
CP 2DH FE 2D
Compare Register A against 2DH: the byte after PR's block.
4ED2
If the NZ FLAG is set (another block in a group), LOOP BACK to 4EB7H.
4ED4
LD HL,43C0H 21 C0 43
Point Register Pair HL to 43C0H, the second group of device control blocks.
4ED7
LOOP BACK to 4EB7H to test the block at Register Pair HL.
4ED9
PUSH IX DD E5
Save Index Register IX (the caller's block) to the stack.
4EDB
POP HL E1
Pop the copy of Index Register IX into Register Pair HL: Register Pair HL = the caller's block.
4EDC
LD B,08H 06 08
Load Register B with 08H, the 8 bytes cleared.
4EDE
XOR A AF
Set Register A to 00H and the Z FLAG (XOR A).
4EDF
LD (HL),A 77
Store Register A (00H) at Register Pair HL, a byte of the caller's block.
4EE0
INC HL 23
Increment Register Pair HL to the next byte of the caller's block.
4EE1
Decrement Register B and LOOP BACK to 4EDFH until the 8 bytes are 00H.
4EE3
RET C9
RETURN with Register A = 00H and the Z FLAG through 4A0CH: the device is removed.
4EE4H - Give Back the Granules of an Extent
Register E = the extent's cylinder, Register D = its granule byte (bits 7-5 the first granule, bits 4-0 the granules less one), Register C = the drive, the allocation table at 5100H. Each granule's bit is cleared, the granule number going on to the next cylinder after the last granule of one (the granules of a cylinder from drive code table +08H bits 7-5). Register Pairs HL, BC and DE are kept; Register A and the flags are not.
4EE4
PUSH HL E5
Save Register Pair HL (the place in the record) to the stack.
4EE5
PUSH BC C5
Save Register Pair BC (the entry code and the drive) to the stack.
4EE6
LD A,08H 3E 08
Load Register A with 08H, the offset of the granule byte in a drive code table.
4EE8
GOSUB to 4797H to fetch byte +08H of the drive code table of drive Register C into Register A.
4EEB
RLCA 07
Rotate Register A (the drive code table byte) left, the first of three.
4EEC
RLCA 07
Rotate Register A (the drive code table byte) left, the second of three.
4EED
RLCA 07
Rotate Register A left: bits 7-5 are now bits 2-0.
4EEE
AND 07H E6 07
Mask Register A to bits 2-0: the granules of a cylinder less one.
4EF0
INC A 3C
Increment Register A: the granules of a cylinder.
4EF1
LD (4F09H),A 32 09 4F
Store Register A (the granules of a cylinder) to 4F09H, the operand of CP 00H at 4F08H.
4EF4
LD L,E 6B
Copy Register E (the extent's cylinder) into Register L.
4EF5
LD H,51H 26 51
Load Register H with 51H: Register Pair HL = 5100H + the cylinder, its allocation byte.
4EF7
LD A,D 7A
Copy Register D (the granule byte) into Register A.
4EF8
AND 1FH E6 1F
Mask Register A to bits 4-0: the granules less one.
4EFA
LD C,A 4F
Copy Register A (the granules less one) into Register C.
4EFB
INC C 0C
Increment Register C: the count of granules to give back.
4EFC
XOR D AA
Exclusive OR Register A with Register D: Register A = bits 7-5 of the granule byte alone.
4EFD
RLCA 07
Rotate Register A left, the first of three, moving bits 7-5 round.
4EFE
RLCA 07
Rotate Register A left, the second of three, moving bits 7-5 round.
4EFF
RLCA 07
Rotate Register A left: bits 7-5 are now bits 2-0, the first granule.
4F00
PUSH AF F5
Save Register Pair AF (Register A the granule) to the stack.
4F01
LD B,(HL) 46
Fetch the allocation byte of the cylinder from Register Pair HL into Register B.
4F02
GOSUB to 4F14H to clear the bit of granule Register A in Register B.
4F05
LD (HL),B 70
Store Register B (the allocation byte with the granule free) at Register Pair HL.
4F06
POP AF F1
Restore Register Pair AF from the stack: Register A = the granule.
4F07
INC A 3C
Increment Register A: the next granule on the cylinder.
4F08
CP 00H FE 00
Self-Modifying Code
Compare Register A against the granules of a cylinder, the operand 4F09H (00H in the file, stored at 4EF1H).
4F0A
If the NZ FLAG is set (still on this cylinder), JUMP to 4F0EH.
4F0C
XOR A AF
Set Register A to 00H (XOR A): granule 0 of the next cylinder.
4F0D
INC L 2C
Increment Register L to the allocation byte of the next cylinder.
4F0E
DEC C 0D
Decrement Register C, the granules left to give back.
4F0F
If the NZ FLAG is set (granules left), LOOP BACK to 4F00H.
4F11
POP BC C1
Restore Register Pair BC (the entry code and the drive) from the stack.
4F12
POP HL E1
Restore Register Pair HL (the place in the record) from the stack.
4F13
RET C9
RETURN to 4E3CH with Register Pairs BC and HL as they were.
4F14H - Clear the Bit of a Granule
Register A = a granule (0-7), Register B = an allocation byte. Builds RES n,B at 4F1EH and runs it: Register B returns with the granule's bit 0.
4F14
AND 07H E6 07
Mask Register A to bits 2-0, the granule 0-7.
4F16
RLCA 07
Rotate Register A left, the first of three, moving the granule up.
4F17
RLCA 07
Rotate Register A left, the second of three, moving the granule up.
4F18
RLCA 07
Rotate Register A left: the granule in bits 5-3.
4F19
OR 80H F6 80
OR Register A with 80H: the second byte of RES n,B (10 nnn 000).
4F1B
LD (4F1FH),A 32 1F 4F
Store Register A to 4F1FH, the second byte of the RES instruction at 4F1EH.
4F1E
RES 0,B CB 80
Self-Modifying Code
Reset bit n of Register B (the opcode's second byte at 4F1FH, 80H in the file, set at 4F1BH): the granule is free.
4F20
RET C9
RETURN with Register B = the allocation byte with the granule's bit 0.
4F21H - The Allocation Table and the Hash Index
Register C = the drive; each routine finds the directory cylinder with 4B65H. 4F21H reads sector 0, the allocation table, into 5100H (error 14H); 4F34H writes it with the FAH data mark and reads it back (error 15H); 4F4DH reads sector 1, the hash index, into 4200H (Register A = 16H with the read's flags); 4F5FH writes it back (error 17H). The reads go through 4B45H, which checks the directory's data mark.
4F21
PUSH DE D5
Save Register Pair DE (the caller's) to the stack.
4F22
PUSH HL E5
Save Register Pair HL (the caller's) to the stack.
4F23
GOSUB to 4B65H to load Register D with the directory cylinder of drive Register C (drive code table +09H).
4F26
LD E,00H 1E 00
Load Register E with 00H, sector 0: the allocation table.
4F28
LD HL,5100H 21 00 51
Point Register Pair HL to 5100H, the buffer of the allocation table.
4F2B
GOSUB to 4B45H to read cylinder Register D, sector Register E of drive Register C into Register Pair HL: the Z FLAG when it is read with the directory's data mark (with an ordinary mark 4B45H takes the directory cylinder from byte +02H of cylinder 0 sector 0 into the drive code table and reads again).
4F2E
POP HL E1
Restore Register Pair HL (the caller's) from the stack.
4F2F
POP DE D1
Restore Register Pair DE (the caller's) from the stack.
4F30
RET Z C8
If the Z FLAG is set (read), RETURN with the Z FLAG.
4F31
LD A,14H 3E 14
Load Register A with 14H, the error GAT READ ERROR.
4F33
RET C9
RETURN with error 14H and the NZ FLAG of the read.
4F34
PUSH DE D5
Save Register Pair DE (the caller's) to the stack.
4F35
PUSH HL E5
Save Register Pair HL (the caller's) to the stack.
4F36
GOSUB to 4B65H to load Register D with the directory cylinder of drive Register C.
4F39
LD E,00H 1E 00
Load Register E with 00H, sector 0: the allocation table.
4F3B
LD HL,5100H 21 00 51
Point Register Pair HL to 5100H, the buffer of the allocation table.
4F3E
GOSUB to 4768H, driver function 0EH: write the sector from Register Pair HL with the data mark FAH.
4F41
If the NZ FLAG is set (the write failed), JUMP to 4F48H.
4F43
GOSUB to 4772H, driver function 0AH: read the sector back without storing it; Register A = 06H for the FAH mark.
4F46
CP 06H FE 06
Compare Register A against 06H: the Z FLAG is set when the sector reads back with the directory's mark.
4F48
LD A,15H 3E 15
Load Register A with 15H, the error GAT WRITE ERROR. LD does not change the flags, so a failed write also gives 15H.
4F4A
POP HL E1
Restore Register Pair HL (the caller's) from the stack.
4F4B
POP DE D1
Restore Register Pair DE (the caller's) from the stack.
4F4C
RET C9
RETURN with the Z FLAG for a good write, else the NZ FLAG and error 15H.
4F4D
PUSH BC C5
Save Register Pair BC (the caller's) to the stack.
4F4E
PUSH DE D5
Save Register Pair DE (the caller's) to the stack.
4F4F
GOSUB to 4B65H to load Register D with the directory cylinder of drive Register C.
4F52
LD E,01H 1E 01
Load Register E with 01H, sector 1: the hash index.
4F54
LD HL,4200H 21 00 42
Point Register Pair HL to 4200H, SYS0/SYS's sector buffer.
4F57
GOSUB to 4B45H to read cylinder Register D, sector Register E of drive Register C into Register Pair HL: the Z FLAG when it is read with the directory's data mark (with an ordinary mark the directory cylinder is taken again from cylinder 0 sector 0).
4F5A
POP DE D1
Restore Register Pair DE (the caller's) from the stack.
4F5B
POP BC C1
Restore Register Pair BC (the caller's) from the stack.
4F5C
LD A,16H 3E 16
Load Register A with 16H, the error HIT READ ERROR. LD does not change the flags.
4F5E
RET C9
RETURN with the flags of the read: Register A = 16H matters only with the NZ FLAG.
4F5F
PUSH BC C5
Save Register Pair BC (the caller's) to the stack.
4F60
PUSH DE D5
Save Register Pair DE (the caller's) to the stack.
4F61
GOSUB to 4B65H to load Register D with the directory cylinder of drive Register C.
4F64
LD E,01H 1E 01
Load Register E with 01H, sector 1: the hash index.
4F66
LD HL,4200H 21 00 42
Point Register Pair HL to 4200H, the hash index in SYS0/SYS's sector buffer.
4F69
GOSUB to 4768H, driver function 0EH: write the sector from Register Pair HL with the data mark FAH.
4F6C
If the NZ FLAG is set (the write failed), JUMP to 4F73H.
4F6E
GOSUB to 4772H, driver function 0AH: read the sector back without storing it; Register A = 06H for the FAH mark.
4F71
CP 06H FE 06
Compare Register A against 06H: the Z FLAG is set when the sector reads back with the directory's mark.
4F73
LD A,17H 3E 17
Load Register A with 17H, the error HIT WRITE ERROR. LD does not change the flags.
4F75
POP DE D1
Restore Register Pair DE (the caller's) from the stack.
4F76
POP BC C1
Restore Register Pair BC (the caller's) from the stack.
4F77
RET C9
RETURN with the Z FLAG for a good write, else the NZ FLAG and error 17H.
5100H - The Allocation Table Buffer
Not in the file.
5100-51FF
DEFS 256
Not in the file. The allocation table of the drive (directory cylinder, sector 0), read by 4F21H, its bits cleared by 4F05H, written back by 4F34H.