4E5D
POP HL
Restore Register Pair HL (i.e., the pointer to the current location in the directory entry) from the top of the STACK.
4E5E
LD A,(IX+08H)
Fetch the value stored at the memory location pointed to by IX+08H (i.e., the position in the DCB for the EOF byte) and put it into Register A.
4E61
LD (HL),A
Store the value held in Register A (i.e., EOF byte from the DCB) into the memory location pointed to by Register Pair HL (i.e., the pointer to the EOF byte in the directory entry).
4E62
INC HL
Bump the value stored in Register Pair HL by 1 to point to the next byte in the directory entry.
4E63
LD A,(IX+09H)
Fetch the value stored at the memory location pointed to by IX+09H (i.e., the position in the DCB for the LOGICAL RECORD LENGTH) and put it into Register A.
4E66
LD (HL),A
Store the value held in Register A (i.e., the LOGICAL RECORD LENGTH in the DCB) into the memory location pointed to by Register Pair HL (i.e., the position in the directory entry for the LRL byte).
4E67
LD A,10H
LET Register A = 10H so we can move HL to point to the directory entry for the SECTOR EOF.
4E69
ADD A,L
ADD the value held in Register L to Register A (Results held in Register A).
4E6A
LD L,A
LET Register L = Register A, so now HL points to the directory entry for the SECTOR EOF.
4E6B
LD A,(IX+0CH)
Fetch the value stored at the memory location pointed to by IX+0CH (i.e., the position in the DCB for the NMSB OF THE LAST RECORD) and put it into Register A.
4E6E
LD (HL),A
Store the value held in Register A (i.e., the NMSB OF THE LAST RECORD in the DCB) into the memory location pointed to by Register Pair HL (i.e., the position in the directory entry for the NMSB of the last record).
4E6F
INC L
Bump the value stored in Register L by 1 so that HL now points to the position in the directory entry for the MSB of the last record).
4E70
LD A,(IX+0DH)
Fetch the value stored at the memory location pointed to by IX+0DH (i.e., the position in the DCB for the MSB OF THE LAST RECORD) and put it into Register A.
4E73
LD (HL),A
Store the value held in Register A (i.e., the MSB OF THE LAST RECORD in the DCB) into the memory location pointed to by Register Pair HL (i.e., the position in the DCB for the MSB OF THE LAST RECORD).
4E74
INC L
Bump the value stored in Register L by 1 so that HL now points to the next position in the directory entry.
4E75
LD DE,0010H
LET Register Pair DE = 0010H (Decimal: 16).
4E78
PUSH IX
Save Register IX (i.e., DCB + 00H) to the top of the stack.
4E7A
ADD IX,DE
ADD the value held in Register Pair DE (i.e., 16 bytes) to Register Pair IX, so that IX = IX + 16 bytes (to point to the extents).
4E7C
PUSH IX
Save Register IX (i.e., the pointer in the DCB to the extents) to the top of the stack.
4E7E
POP DE
Restore the pointer in the DCB to the extents into Register Pair DE.
4E7F
POP IX
Restore the DCB + 00H (from the top of the stack) into Register Pair IX.
4E81
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the current working position in the directory entry) with the value stored in Register Pair DE (i.e., the pointer in the DCB to the extents).
4E82
PUSH DE
Save Register DE (i.e., the current working position in the directory entry) to the top of the stack.
4E83
LD BC,001AH
LET Register Pair BC = 001AH (Decimal: 26) to prepare to move 26 bytes via a LDIR.
4E86
LDIR
Transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.
4E88
LD C,(IX+06H)
Fetch the value stored at the memory location pointed to by IX+06H (i.e., the position in the DCB for the DRIVE NUMBER) and put it into Register C.
4E8B
LD B,(IX+07H)
Fetch the value stored at the memory location pointed to by IX+07H (i.e., the position in the DCB for the LOGICAL FILE NUMBER) and put it into Register B.
4E8E
LD A,(IX+0EH)
Fetch the value stored at the memory location pointed to by IX+0EH (i.e., the position in the DCB for the DISK SIDE NUMBER) and put it into Register A.
4E91
LD (4463H),A
Store the value held in Register A (i.e., the DISK SIDE NUMBER from the DCB) into the memory location 4463H.
NOTE: 4463H is the storage location for the old system disk side number.
4E94
GOSUB to 4A7BH (from SYS00/SYS) to write the directory entry from the copy in RAM to the diskette.
4E97
POP HL
Restore the current working position in the directory entry (held at the top of the stack) into Register Pair HL.
4E98
RET NZ
If the NZ FLAG (Not Zero) is set then that the prior CALL routine (to write the directory from the copy in RAM) returned an ERROR, so RETurn to caller with the NZ FLAG set (to signify an error).
4E99
DEC L
DECrement the value stored in Register L by 1 so that HL now points to the directory entry byte which is 1 byte before the EXTENTS.
4E9A
INC L
Bump the value stored in Register L by 1 so that HL now points to the directory entry byte for the EXTENTS.
4E9B
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the pointer in the directory entry for the EXTENTS) with the value stored in Register Pair DE.
4E9C
LD L,(IX+0CH)
Fetch the value stored at the memory location pointed to by IX+0CH (i.e., the position in the DCB for the NMSB OF THE LAST RECORD/EOF) and put it into Register L.
4E9F
LD H,(IX+0DH)
Fetch the value stored at the memory location pointed to by IX+0DH (i.e., the position in the DCB for the MSB OF THE LAST RECORD/EOF) and put it into Register H.
4EA2
INC HL
Bump the value stored in Register Pair HL (i.e., the EOF location) by 1.
4EA3
LD A,03H
LET Register A = 03H to prepare to divide that EOF by 3, so as to calculate the number of GRANs
4EA5
GOSUB to 4451H to divide Register Pair HL by Register A; result in Register A.
4EA8
OR A
Set FLAGS based on the contents of Register A.
4EA9
If the Z FLAG (Zero) is set then there is no remainder, so skip the next instruction and JUMP to 4EACH.
4EAB
INC HL
Bump the value stored in Register Pair HL by 1 so that the gran count includes the remainder as a whole number.
LD A,0CH
LET Register A = 0CH (Decimal: 13) in preparation for a loop to skip over all 13 extents.
4EAE
LD (4EC5H),A
Store the value held in Register A (which will be the counter of the extents) into the memory location 4EC5H which is in the middle of a LD A,nn OPCode.
INC E
Bump the value stored in Register E by 1 so that Register Pair DE points to the next extent in the directory entry.
4EB2
LD A,(DE)
Fetch the value stored at memory location pointed to by Register Pair DE (i.e., the pointer in the directory entry for the next extent) and put it into Register A.
4EB3
CP 0FEH
Compare the value held in Register A (i.e., the next extent) against 0FEH. Results:
- If Register A equals 0FEH, the Z FLAG is set.
- If A < 0FEH, the CARRY FLAG will be set.
- if A >= 0FEH, the NO CARRY FLAG will be set.
4EB5
If the NC FLAG (No Carry) is set then A >= 0FEH meaning that we reached the end of the extents, so JUMP to 4F07H to avoid continuing to parse the extents.
4EB7
AND 1FH
MASK the value of Register A against 1FH (0001 1111). This has the effect of turning off bits 7, 6, 5, leaving only bits 4, 3, 2, 1, 0 active, which will be the number of GRANS in that extent.
4EB9
LD C,A
LET Register C = Register A (i.e., the number of GRANs in the current extent).
4EBA
LD B,00H
LET Register B = 00H, so now Register Pair BC = the number of GRANs in the current extent.
4EBC
OR A
Set FLAGS based on the contents of Register A, but most notedly, clear the CARRY FLAG as we are about to use it.
4EBD
SBC HL,BC
Subtracts the value stored in Register Pair BC (i.e., the number of GRANs in the current extent) and the carry flag from the value stored in Register Pair HL (i.e., the EOF).
4EBF
If the Z FLAG (Zero) is set then the EOF = 0, so JUMP to 4EF3H.
4EC1
If the C FLAG (Carry) is set then the EOF < 0 so JUMP to 4ECEH.
4EC3
INC E
Bump the value stored in Register E by 1 so that Register Pair DE points to the next extent in the directory entry.
4EC4
LD A,nn
LET Register A = nn (i.e., the value in 4EC5H), which is the current counter of extents left to process.
4EC6
DEC A
DECrement the value stored in Register A by 1 to indicate one less extent to process.
4EC7
LD (4EC5H),A
Store the value held in Register A (i.e., the number of extents left to process) into the memory location 4EC5H.
4ECA
If the NZ FLAG (Not Zero) is set then we still have more extents to process, so LOOP BACK to 4EB1H.
4ECC
JUMP to 4F07H to continue once all 13 extents have been checked.