5741
↳SPCFIL
LD A,20H
LET Register A = 20H (ASCII: SPACE).
LD (DE),A
Store the value held in Register A (i.e., a SPACE) into the memory location pointed to by Register Pair DE (i.e., the 8 BYTE storage area for the FILENAME).
5744
INC DE
INCrement the value stored in Register Pair DE by 1 to point to the next byte in the 8 BYTE storage area for the FILENAME.
5745
LOOP back to 5743H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
LD DE,S6DCB1
LET Register Pair DE = 6280H, which is where the filename is currently stored.
574A
LD HL,CMD
LET Register Pair HL = 5822H, which points to a /CMD message.
574D
GOSUB to 444BH to add the extension pointed to by Register Pair HL to the end of the filename pointed to by Register Pair DE.
5750
LD B,00H
LET Register B = 00H to set up for creating a file with an LRL of 256.
5752
LD HL,S6BUF1
LET Register Pair HL = 6300H to use as a buffer for the 4420H CALL.
5755
GOSUB to 4420H.
NOTE: 4420H is the SYS00/SYS routine to INITIALIZE A DISK (i.e., CREATE or OPEN). This RST 28H's with a value of A2H so as to call ROUTINE 2 in OVERLAY 2. Register HL needs to point to a RAM BUFFER for the DCB's.
5758
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
575B
LD A,05H
LET Register A = 05H, which is a COMMENT BLOCK designator.
575D
GOSUB to 581CH to write the contents of Register A (i.e., a COMMENT BLOCK designator) to the file.
5760
If the NZ FLAG (Not Zero) is set, meaning that the prior CALL routine returned because of an ERROR, JUMP to 6132H.
5763
LD A,10H
LET Register A = 10H (Decimal: 16) to set up the next CALL for a write of 16 bytes.
5765
GOSUB to 581CH to write the contents of Register A (i.e., 10H) to the file.
5768
LD B,08H
LET Register B = 08H, to set up for a DJNZ loop of 8 characters, which is the length of the FILESPEC.
576A
LD HL,NAMFIL
LET Register Pair HL = 5846H, which is an 8 BYTE storage area for the FILENAME.
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a current byte from the FILESPEC) and put it into Register A.
576E
INC HL
INCrement the value stored in Register Pair HL by 1 to point to the next byte of the FILESPEC.
576F
GOSUB to 581CH to write the contents of Register A (i.e., a byte of the filename) to the file.
5772
LOOP back to 576DH, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
5774
PUSH BC
Save Register Pair BC to the top of the stack.
5775
PUSH DE
Save Register Pair DE to the top of the stack.
5776
PUSH IX
Save Register Pair IX to the top of the stack.
5778
LD C,2FH
LET Register C = 2FH (ASCII: /) in preparation for writing the DATE.
577A
GOSUB to 61F0H to generate the date and place it into the file.
577D
POP IX
Put the value held at the top of the STACK into Restore Register Pair IX, and then remove the entry from the stack.
577F
POP DE
Put the value held at the top of the STACK into Restore Register Pair DE, and then remove the entry from the stack.
5780
POP BC
Put the value held at the top of the STACK into Restore Register Pair BC, and then remove the entry from the stack.
5781
LD B,08H
LET Register B = 08H, to set up for a DJNZ loop of 8 characters, which is the length of the DATE.
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL and put it into Register A.
5784
INC HL
INCrement the value stored in Register Pair HL by 1.
5785
GOSUB to 581CH to write the contents of Register A (i.e., a byte of the DATE) to the file.
5788
LOOP back to 5783H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
578A
LD HL,(END)
Fetch the value stored at memory location 57BBH (i.e., the END address) and put it into Register HL.
578D
LD BC,(START)
Fetch the value stored at memory location 57B1H (i.e., the START address) and put it into Register BC.
5791
OR A
Set FLAGS based on the contents of Register A.
5792
SBC HL,BC
Subtracts the value stored in Register Pair BC (i.e., the START address) and the carry flag from the value stored in Register Pair HL (i.e., the END address).
5794
If the C FLAG (Carry) is set, then the END address in HL was > the START address in DE, which is a problem, so JUMP to 5220H.
5797
LD HL,5FFFH
LET Register Pair HL = 5FFFH, which is 1 byte below the lowest permitted START address.
579A
SBC HL,BC
Subtracts the value stored in Register Pair BC (i.e., the START address) and the carry flag from the value stored in Register Pair HL (i.e., 5FFFH, which is the lowest permitted START address).
If the NC FLAG (No Carry) is set, then the START address is too low, so JUMP to 5225H.
579F
LD HL,(RELO)
Fetch the value stored at memory location 57B5H (i.e., the RELO address) and put it into Register HL.
57A3
57A2
LD A,H
OR L
Since the Z-80 cannot test Register Pair HL against zero, the common trick is to set Register A to equal to Register H, and then OR A against Register L. Only if both Register H and Register L were zero can the Z FLAG be set.
57A4
If the NZ FLAG (Not Zero) is set, then we have a RELO parameter to deal with, so JUMP to 57B0H.
57A6
LD HL,(START)
Fetch the value stored at memory location 57B1H (i.e., the START address) and put it into Register HL.
57A9
LD (RELO),HL
Store the value held in Register HL (i.e., the START address) into the memory location 57B5H (i.e., the RELO address).
57AC
LD IX,DCOUNT
LET Register Pair IX = 5845H so as to point to the FILENAME.
LD HL,START
LET Register Pair HL = the value put into 57B1H, which is the START address.
57B3
LD IY,RELO
LET Register Pair IY = the value put into 57B5H, which is the RELO address.
PUSH HL
Save Register Pair HL (i.e., the START address) to the top of the stack.
57B8
LD B,H
LET Register B = Register H (i.e., MSB of the the START address).
57B9
LD C,L
LET Register C = Register L (i.e., LSB of the the START address).
57BA
LD HL,END
LET Register Pair HL = the value put into 57BBH, which is the END address.
57BD
INC HL
INCrement the value stored in Register Pair HL (i.e., the END address) by 1.
57BE
OR A
Set FLAGS based on the contents of Register A, which clears the CARRY FLAG.
57BF
SBC HL,BC
Subtracts the value stored in Register Pair BC (i.e., the START address) and the carry flag from the value stored in Register Pair HL (i.e., the END address + 1). With this, HL will now contain the number of bytes to save.
57C1
If the Z FLAG (Zero) is set, then there are no bytes to save, so JUMP to 57F4H.
57C3
LD B,0FEH
LET Register B = 0FEH for a loop of 254 bytes to write each time.
57C5
LD A,H
LET Register A = Register H (i.e., the MSB of the number of bytes to save).
57C6
OR A
Since a LD command does not set any FLAGS, Set FLAGS based on the contents of Register A.
57C7
If the NZ FLAG (Not Zero) is set, then there is more than just one page (meaning the number of bytes was more than what the LSB could hold) so JUMP to 57CFH.
57C9
LD A,L
LET Register A = Register L (i.e., the LSB of the number of bytes to save).
57CA
CP 0FFH
Compare the value held in Register A against 0FFH (Decimal: 255). Results:
- If Register A equals 255, the Z FLAG is set.
- If A < 255, the CARRY FLAG will be set.
- if A >= 255, the NO CARRY FLAG will be set.
57CC
If the NC FLAG (No Carry) is set, then there are 255 or more bytes, which is still too many since we need to write 254, so JUMP to 57CFH.
57CE
LD B,L
LET Register B = Register L (i.e., the LSB of the number of bytes to save).
POP HL
Put the value held at the top of the STACK (i.e., the START address) into Restore Register Pair HL, and then remove the entry from the stack.
57D0
LD A,01H
LET Register A = 01H, which is code for a DATA BLOCK.
57D2
GOSUB to 581CH to write the contents of Register A (i.e., a DATA BLOCK designator) to the file.
57D5
LD A,B
LET Register A = Register B (i.e., the LSB of the number of bytes to save).
57D6
ADD A,02H
LET Register A = Register A + 02H (i.e., the the number of bytes to save + 2).
57D8
GOSUB to 581CH to write the contents of Register A (i.e., the number of bytes about to be written) to the file.
57DB
PUSH IY
Save Register Pair IY (i.e., the RELO address) to the top of the stack.
57DD
EX (SP),HL
EXchange the value stored in Register Pair HL (i.e., the total number of bytes to save) with the value stored at the top of the STACK (i.e., the RELO address).
57DE
LD A,L
LET Register A = Register L (i.e., the LSB of the RELO address), which means we are writing out the RELO address instead of the TRANSFER address.
57DF
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the RELO address) to the file.
57E2
LD A,H
LET Register A = Register H (i.e., the MSB of the RELO address), which means we are writing out the RELO address instead of the TRANSFER address.
57E3
EX (SP),HL
EXchange the value stored in Register Pair HL (i.e., the RELO address) with the value stored at the top of the STACK (i.e., the total number of bytes to save).
57E4
POP IY
Put the value held at the top of the STACK (i.e., the RELO address) into Restore Register Pair IY, and then remove the entry from the stack.
57E6
GOSUB to 581CH to write the contents of Register A (i.e., the MSB of the RELO address) to the file.
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., a data byte) and put it into Register A.
57EA
INC HL
INCrement the value stored in Register Pair HL (i.e., a data byte) by 1.
57EB
INC IY
INCrement the value stored in Register Pair IY (i.e., the RELO address) by 1.
57ED
GOSUB to 581CH to write the contents of Register A (i.e., a data byte) to the file.
57F0
LOOP back to 57E9H (which is looping L), reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
57F2
BIG LOOP back to 57B7H until all of H is also exhausted.