DOSPLUS 3.5 for the Model I - SYS15/SYS Disassembled

Page Customization

Introduction/Summary

DOSPLUS 3.5 SYS15/SYS Disassembly - The Library Commands BUILD, CLEAR, CREATE, DUMP, LOAD and RENAME (Model I)

SYS15/SYS is the seventh of the high overlays: it loads at 5200H and holds six library commands, routines 3 to 8 of its table at 5200H with the request codes E3H to E8H: BUILD, CLEAR, CREATE, DUMP, LOAD and RENAME. CMNDI@ takes the codes from SYS1/SYS's table of the library commands and passes them to the overlay request handler, which loads SYS15/SYS and calls the routine with Register Pair HL at the rest of the command line. No file of the diskette requests routine 2 (E2H). The file is a load module of 7 blocks, 1751 bytes, from 5200H to 58D6H, with the transfer address 5200H and no gaps; the work area after the file starts at 58D7H. BUILD, CLEAR, CREATE, DUMP and LOAD share one evaluation block for EVAL@ (57B3H), whose three field blocks are all 58D7H, and each stores the address of its own parameter table into it; RENAME takes its two names by FSPEC@. LOAD requests 12H and 32H (routine 2 of SYS2/SYS and SYS4/SYS, which only bring the overlay in), RENAME 17H and 18H (SYS2/SYS's routines 7 and 8).

The Parts of SYS15/SYS

AddressContents
5200H-520FHThe routine table (routines 2-8) and routine 2 (5200H, 520EH).
5210H-5262HBUILD (5210H).
5263H-5324HCLEAR: a file, the fill of a file (also used by CREATE), the memory (5263H, 52A2H, 52ECH).
5325H-540AHCREATE and the size of its space (5325H, 53DAH).
540BH-54DCHDUMP, its output of bytes, its records and values (540BH, 54C1H, 54CBH).
54DDH-55FFHLOAD: a load module, a core image file, the prompt for a diskette, the keyboard scan, RUN's value (54DDH, 5556H, 55A7H, 55D2H, 55F1H, 55FEH).
5600H-5709HRENAME: a file, the two requests to SYS2/SYS, a device or a drive (5600H, 56BDH, 56C3H).
570AH-57B2HThe helpers: a table entry, the wildcard test, a comparison, a byte out, the field taken and opened, the close; the error exits and the overlay request (570AH, 572AH, 5733H, 5739H, 5747H, 5788H, 5793H, 57B2H).
57B3H-58D6HThe evaluation block, the five parameter tables, the default extensions and the texts (57B3H, 57BCH, 57C6H, 57E2H, 5822H, 5850H, 5875H, 587EH).

BUILD

BUILD (5210H) takes one field, a file or a device, and the switch APPEND. The file is opened by INIT@ with the default extension TXT (it is made when it is not there); a device by its control block from LOCDCB% (5747H). With APPEND an open file is first shown on the display to its end, so that what is typed is added after it; without APPEND the new lines are written from the start of the file. The prompt Enter text (63 chars/line) is shown, and every line taken by the ROM's 0040H, up to 63 characters, is written with its carriage return through the ROM's 001BH. BREAK ends BUILD and the file is closed (5788H).

CLEAR

CLEAR (5263H) takes START (5C00H when not given), END (the top of memory, 4049H) and DATA (0000H). Without a field the memory from START to END, both included, is filled with DATA (52ECH): the low byte at START, the high byte at the next address and so on, a value below 0100H in every byte; START below 5C00H, END above the top of memory or START above END is error 2DH. With a field it must be a file name (2CH); the file is opened by OPEN@ and every sector of it, up to its end of file, is written with the 128 words of DATA (52A2H). The file is then left open: CLEAR does not call CLOSE@, so its directory entry is not changed.

CREATE

CREATE (5325H) takes a file name (else error 2FH) and DATA, GRANS, KEEP, KILO, LRL, SIZE and VERIFY. INIT@ opens the file with the record length LRL (256 when LRL is 0 or not given) and must create it: a file that is there already is error 31H. The space (53DAH) is SIZE records of that length, or else GRANS granules (times the sectors per granule of the drive), or else KILO kilobytes (four sectors each); for GRANS and KILO the blocked records flag (bit 7 of FCB+01H) is cleared while the file is positioned, so the count is of sectors whatever the record length. POSN@ goes to the last record or sector of the space and WRITE@ writes it, which gives the file its whole space. DATA then fills every sector (52A2H) and VERIFY reads every record to the end of the file; KEEP sets the non-shrinkable bit (bit 7 of FCB+02H), and CLOSE@ closes the file. Without a size the file is made with no space, and DATA and VERIFY then have nothing to work on.

DUMP

DUMP (540BH) takes one field, a file or a device, and DATA, END, RELO, START and TRA: START is 5C00H, END the top of memory and TRA 402DH (EXIT@) when they are not given. A file name gets the default extension CMD, or CIM with DATA, and is opened by INIT@. START above END is error 2DH; neither is checked against 5C00H or the top of memory. The memory is written in pieces of up to 254 bytes: for a load module each piece gets a block header (01H, the length plus 2, the load address, which is the address plus RELO less START when RELO is given), and the transfer record 02H 02H TRA ends the file. TRA is not moved by RELO. With DATA only the bytes are written, without headers or a transfer record. The bytes go out through the ROM's 001BH (5739H) and an error there is not tested. The file is closed at the end (5788H).

LOAD

LOAD (54DDH) takes a file name (else error 2FH) and PROMPT, RUN, START and TRA (TRA 402DH when not given). No default extension is added. SYS2/SYS is brought in first (request 12H) so that OPEN@ needs no system diskette. With PROMPT the text Insert TARGET diskette (ENTER) is flashed until a key is pressed (55D2H; any key, and nothing is shown while a DO file runs), the file is opened, Insert SYSTEM diskette (ENTER) is asked for while SYS4/SYS is brought in (request 32H), and the target diskette is asked for again. With START the file is a core image: every byte goes to memory from START on, up to the end of the file (55A7H). Otherwise it is a load module (5556H): load blocks (type 01H) are loaded at their addresses, and the transfer record (02H) ends the load. With RUN the program is run; with PROMPT the system diskette is asked for first, also before an error is posted.

RENAME

RENAME (5600H) takes two specifications by FSPEC@ (the words TO and FROM are passed over); a missing one is error 2CH. Two devices (@xx) or two drives (:xx) are renamed in place (56C3H): the old name must be found by LOCDEV@, the new one must not be (error 32H), its two characters may not be wildcards (2BH), and they become the name of the entry in the DCB table (+09H) or in DCTTBL (+02H). A file and a device or drive mixed is error 2CH or 2BH. A file is opened by OPEN@, which checks its password, and an access level of 3 or above is error 25H. The new name may not carry a drive (error 20H): it is given the drive of the old file and must not be found there (31H). The directory entry is read by 490CH, its name and extension replaced by those of the new name, which OPEN@ left in SYS2/SYS's buffer 51E0H (routine 8), and written back by 4915H; then the hash index table (sector 1 of the directory) is read, the entry's byte replaced by the hash code of the new name (routine 7) and written back. The file stays open.

Differences from the Manual

BUILD does not write a line ended by BREAK: the manual says it is stored without its carriage return, but the BREAK exit closes the file at once. LOAD adds no default extension (the manual says CIM). LOAD's TRA is 402DH when it is not given and, with RUN, takes the place of the load module's own transfer address unless it is 0, so LOAD with RUN alone goes back to DOSPLUS instead of running the program (the manual says RUN runs it, like typing its name). In a load module LOAD tests the fourth byte of a record other than 01H and 02H, not its type: when that byte is 1EH or more, as the second character of a module name in a 05H comment record is, LOAD reads one more byte and ends without loading the rest and without an error. PROMPT goes on with any key, not only ENTER. DUMP checks only that START is not above END, not the limits of memory the manual gives; its own example says the transfer address of a dump without TRA is the start of the area, but the bytes give 402DH, as the manual's rule (2) says. CLEAR of a file leaves the file open. CREATE takes DATA=65535 (FFFFH) as no DATA. The GRANS abbreviation is G (the manual's table prints C).

Variables

Self-Modified Operands

Address
Size
Contents
5228H-5229H
2 bytes
APPEND
The value of APPEND: the operand of LD BC,0000H at 5227H.
52A9H-52AAH
2 bytes
DATA (CLEAR, CREATE)
The value of DATA (CLEAR, CREATE): the operand of LD DE,0000H at 52A8H.
52EDH-52EEH
2 bytes
START (CLEAR)
The value of START (CLEAR): the operand of LD HL,0000H at 52ECH.
52FAH-52FBH
2 bytes
END (CLEAR)
The value of END (CLEAR): the operand of LD DE,0000H at 52F9H.
536AH-536BH
2 bytes
LRL
The value of LRL: the operand of LD BC,0000H at 5369H.
53B4H-53B5H
2 bytes
VERIFY
The value of VERIFY: the operand of LD HL,0000H at 53B3H.
53C8H-53C9H
2 bytes
KEEP
The value of KEEP: the operand of LD BC,0000H at 53C7H.
53DBH-53DCH
2 bytes
SIZE
The value of SIZE: the operand of LD BC,0000H at 53DAH.
53EAH-53EBH
2 bytes
GRANS
The value of GRANS: the operand of LD BC,0000H at 53E9H.
53F4H-53F5H
2 bytes
KILO
The value of KILO: the operand of LD BC,0000H at 53F3H.
551CH-551DH
2 bytes
PROMPT
The value of PROMPT: the operand of LD HL,0000H at 551BH.
5597H-5598H
2 bytes
TRA (LOAD)
The value of TRA (LOAD): the operand of LD DE,0000H at 5596H.
55A8H-55A9H
2 bytes
START (LOAD)
The value of START (LOAD): the operand of LD HL,0000H at 55A7H.

Values in the File

Address
Size
Contents
54D3H-54D4H
2 bytes
TRA (DUMP)
The transfer address of DUMP's transfer record (54CBH).
54D5H-54D6H
2 bytes
START (DUMP)
The next byte of the area to write.
54D7H-54D8H
2 bytes
END (DUMP)
The last byte of the area.
54D9H-54DAH
2 bytes
RELO (DUMP)
RELO, then the offset RELO less START.
54DBH-54DCH
2 bytes
DATA (DUMP)
The switch DATA.
55FEH-55FFH
2 bytes
RUN
LOAD's switch RUN (55FEH).
57BAH-57BBH
2 bytes
Parameter Table
The address of the parameter table in the evaluation block (57B3H).

Work Areas

Address
Size
Contents
58D7H-58F7H
33 bytes
Field Block
The flag byte and file control block of EVAL@'s field; RENAME's old name (58D7H).
58F8H-5918H
33 bytes
New Name
RENAME's file control block of the new name.
5919H-5A18H
256 bytes
Sector Buffer
The buffer of the file's sectors.
5A19H-5A58H
64 bytes
Line Buffer
BUILD's line of up to 63 characters and its carriage return.

Outside Routines

AddressContents
4479HSYS0/SYS: EVAL@.
441CHSYS0/SYS: FSPEC@ (5603H).
4473HSYS0/SYS: FEXT@ (5779H).
4420HSYS0/SYS: INIT@.
4424HSYS0/SYS: OPEN@.
4428HSYS0/SYS: CLOSE@.
4436HSYS0/SYS: READ@ (53BDH).
4439HSYS0/SYS: WRITE@.
443FHSYS0/SYS: REW@.
4442HSYS0/SYS: POSN@ (5384H).
447FHSYS0/SYS: LOCDEV@ (56CDH).
4488HSYS0/SYS: LOCDCB% (5766H).
448BHSYS0/SYS: LOCDCT% (53E6H).
4485HSYS0/SYS: DISKIO%, functions 6 SREAD and 7 SWRITE (569FH).
444BHSYS0/SYS: MULT@ (53FEH).
490CHSYS0/SYS: read the directory sector of an entry (567DH).
4915HSYS0/SYS: write it back (5692H).
4934HSYS0/SYS: Register A times Register E (571FH).
4467HSYS0/SYS: DSPLY@.
4409HSYS0/SYS: ERROR@ (57AFH).
0013HROM: get a byte from a file or device.
001BHROM: put a byte to a file or device.
002BHROM: scan the keyboard (55F4H).
0033HROM: show the character in Register A on the display.
0040HROM: take a line from the keyboard (5250H).

Disassembly

5200H - The Routine Table

Data: SYS15/SYS's table of routines 2-8, one word each, used by SYS0/SYS's overlay request handler (its 49C9H-49DCH) for the request codes E2H-E8H. CMNDI@ takes the codes of the library commands from SYS1/SYS's table: BUILD E3H (51BFH), CLEAR E4H (51C1H), CREATE E5H (51C6H), DUMP E6H (51CBH), LOAD E7H (51D6H), RENAME E8H (51D9H). No file of the diskette requests E2H.

5200-5201
DEFW 520EH 0E 52
Routine 2: 520EH, XOR A and RET, which SYS0/SYS's record locator requests when it loads SYS15/SYS back (its 4D55H-4D62H).
5202-5203
DEFW 5210H 10 52
Routine 3: 5210H, BUILD (E3H): write the lines typed at the keyboard to a file or to a device.
5204-5205
DEFW 5263H 63 52
Routine 4: 5263H, CLEAR (E4H): fill a file or an area of memory with a one or two byte value.
5206-5207
DEFW 5325H 25 53
Routine 5: 5325H, CREATE (E5H): make a new file and give it its space on the diskette in advance.
5208-5209
DEFW 540BH 0B 54
Routine 6: 540BH, DUMP (E6H): write an area of memory to a file, as a load module or as data.
520A-520B
DEFW 54DDH DD 54
Routine 7: 54DDH, LOAD (E7H): load a load module or a core image file into memory, and run it.
520C-520D
DEFW 5600H 00 56
Routine 8: 5600H, RENAME (E8H): give a file, a device or a drive a new name.

520EH - Routine 2

Nothing to do when SYS0/SYS's record locator brings SYS15/SYS back.

520E
XOR A AF
Set Register A to 00H by XORing it with itself, and set the Z FLAG: routine 2 has no work to do.
520F
RET C9
RETurn to SYS0/SYS's overlay request handler (49DDH) with Register A = 00H.

5210H - BUILD

Routine 3, entered from CMNDI@ through the overlay request handler with Register Pair HL at the rest of the command line. APPEND (table 57BCH) starts as 0000H. 5747H takes the field with EVAL@ (block 57B3H) and opens it: a file by INIT@ with the default extension TXT, a device through LOCDCB%; Register Pair DE is then the file control block or the device control block. With APPEND an open file is first shown to its end, so that the new lines follow it. Then the prompt is shown, and every line typed (up to 63 characters, by the ROM's 0040H) is written with its carriage return through the ROM's 001BH. BREAK ends BUILD and closes the file; the characters of a line ended by BREAK are not written.

5210
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the value of APPEND when it is not given.
5213
LD (5228H),DE ED 53 28 52
Store Register Pair DE (0000H) into 5228H-5229H, the operand of LD BC,0000H at 5227H, the value of APPEND.
5217
LD IX,57B3H DD 21 B3 57
Point Index Register IX to 57B3H, the evaluation block that BUILD, CLEAR, CREATE, DUMP and LOAD share.
521B
LD DE,57BCH 11 BC 57
Point Register Pair DE to 57BCH, BUILD's parameter table, whose one entry is APPEND.
521E
LD (57BAH),DE ED 53 BA 57
Store Register Pair DE (57BCH) into 57BAH-57BBH, the address of the parameter table in the evaluation block.
5222
LD C,01H 0E 01
Load Register C with 01H, the number of the default extension TXT in the list at 5875H.
5224
GOSUB to 5747H to take the field with EVAL@ and open it: Register Pair DE returns the file control block or the device's.
5227
LD BC,0000H 01 00 00
Load Register Pair BC with the value of APPEND, the operand 5228H-5229H: 0000H when APPEND is not given.
522A
INC C 0C
INCrement Register C by 1, so that the DEC C below sets the flags from the low byte of APPEND.
522B
DEC C 0D
DECrement Register C by 1: the Z FLAG when the low byte of APPEND's value is 00H (APPEND not given, or N).
522C
If the Z FLAG is set (no APPEND), JUMP to 5244H to show the prompt.
522E
LD A,(DE) 1A
Load Register A with the type byte of the control block at Register Pair DE: 80H for an open file.
522F
CP 80H FE 80
Compare Register A against 80H, the type byte of an open file: the NZ FLAG for a device.
5231
If the NZ FLAG is set (a device), JUMP to 5244H: there is nothing to show before the new lines.
5233
GOSUB to 0013H, the ROM's routine that gets a byte from the file at Register Pair DE into Register A: the NZ FLAG when there is none.
5236
If the NZ FLAG is set (no byte: the end of the file or an error), JUMP to 523FH.
5238
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
5239
GOSUB to 0033H, the ROM's routine that shows the character in Register A on the display.
523C
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
523D
JUMP back to 5233H for the next byte of the file, until its end.
523F
CP 1CH FE 1C
Compare Register A, the error code, against 1CH, Attempted to read past eof: the Z FLAG at the end of the file.
5241
If the NZ FLAG is set (another error), JUMP to 57ADH to post the error in Register A.
5244
LD HL,587EH 21 7E 58
Point Register Pair HL to 587EH, the prompt Enter text (63 chars/line) with its carriage return.
5247
GOSUB to 4467H, DSPLY@, to show the text at Register Pair HL up to its carriage return.
524A
LD B,3FH 06 3F
Load Register B with 3FH, the longest line the keyboard routine takes: 63 characters.
524C
LD HL,5A19H 21 19 5A
Point Register Pair HL to 5A19H, the line buffer after SYS15/SYS's buffer of the file's sectors.
524F
PUSH DE D5
Save Register Pair DE, the control block, to the top of the stack.
5250
GOSUB to 0040H, the ROM's routine that takes a line of up to Register B characters into the buffer at Register Pair HL, ended by a carriage return: Register B returns the count, the C FLAG when BREAK ended it.
5253
POP DE D1
Restore Register Pair DE, the control block, from the top of the stack.
5254
If the C FLAG is set (BREAK), JUMP to 5260H to end BUILD: the characters of that line are not written.
5256
INC B 04
INCrement Register B by 1, so that the carriage return after the characters is written too.
5257
LD A,(HL) 7E
Load Register A with the character at Register Pair HL, the next one of the line.
5258
INC HL 23
INCrement Register Pair HL by 1, to the next character of the line.
5259
GOSUB to 001BH, the ROM's routine that puts the byte in Register A to the file or device at Register Pair DE (its result is not tested).
525C
DECrement Register B and LOOP back to 5257H until the line and its carriage return are written.
525E
JUMP back to 524AH to take the next line from the keyboard.
5260
JUMP to 5788H to close the file at Register Pair DE (a device is not closed) and end BUILD.

5263H - CLEAR

Routine 4, entered from CMNDI@ through the overlay request handler with Register Pair HL at the rest of the command line. START (the operand 52EDH) starts as 5C00H, END (52FAH) as the top of memory HMEM$ and DATA (52A9H) as 0000H (table 57C6H). With no field the memory from START to END is filled (52ECH). With a field, which must be a file name (else error 2CH), the file is opened by OPEN@ and every one of its sectors is written with DATA (52A2H); START and END are not used then, and the file is not closed.

5263
PUSH HL E5
Save Register Pair HL, the command line, to the top of the stack.
5264
LD HL,(4049H) 2A 49 40
Load Register Pair HL with the top of memory, HMEM$, from 4049H-404AH.
5267
LD (52FAH),HL 22 FA 52
Store Register Pair HL (the top of memory) into 52FAH-52FBH, the operand of LD DE,0000H at 52F9H, the value of END.
526A
LD HL,5C00H 21 00 5C
Load Register Pair HL with 5C00H, the lowest address CLEAR fills, the start of the memory for programs.
526D
LD (52EDH),HL 22 ED 52
Store Register Pair HL (5C00H) into 52EDH-52EEH, the operand of LD HL,0000H at 52ECH, the value of START.
5270
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the value of DATA when it is not given.
5273
LD (52A9H),HL 22 A9 52
Store Register Pair HL (0000H) into 52A9H-52AAH, the operand of LD DE,0000H at 52A8H, the value of DATA.
5276
POP HL E1
Restore Register Pair HL, the command line, from the top of the stack.
5277
LD IX,57B3H DD 21 B3 57
Point Index Register IX to 57B3H, the evaluation block of SYS15/SYS for EVAL@.
527B
LD DE,57C6H 11 C6 57
Point Register Pair DE to 57C6H, CLEAR's parameter table: START, END and DATA.
527E
LD (57BAH),DE ED 53 BA 57
Store Register Pair DE (57C6H) into 57BAH-57BBH, the address of the parameter table in the evaluation block.
5282
GOSUB to 4479H, EVAL@, to take the fields and parameters from the command line at Register Pair HL: the NZ FLAG on an error.
5285
If the NZ FLAG is set (EVAL@ failed), JUMP to 57ADH to post the error in Register A.
5288
LD A,07H 3E 07
Load Register A with 07H, the mask of bits 0-2 of the evaluation block's flags, the fields given.
528A
AND (IX+00H) DD A6 00
AND Register A with the flags of the evaluation block at Index Register IX+00H: the Z FLAG when no field was given.
528D
If the Z FLAG is set (no field), JUMP to 52ECH to fill the memory from START to END.
528F
LD DE,58D7H 11 D7 58
Point Register Pair DE to 58D7H, the field block of EVAL@: its flag byte, then the file control block.
5292
LD A,(DE) 1A
Load Register A with the flag byte of the field at Register Pair DE (58D7H).
5293
INC DE 13
INCrement Register Pair DE by 1, to the file control block at 58D8H.
5294
AND 60H E6 60
AND Register A with 60H, bits 6 and 5 of the flag byte: set when a name or a wildcard was given.
5296
If the Z FLAG is set (no name: a drive or a device), JUMP to 5793H to post error 2CH, Illegal filespec.
5299
LD HL,5919H 21 19 59
Point Register Pair HL to 5919H, the buffer of the file's sectors.
529C
GOSUB to 4424H, OPEN@, to open the file at Register Pair DE with the buffer at Register Pair HL: the NZ FLAG on an error.
529F
If the NZ FLAG is set (OPEN@ failed), JUMP to 57ADH to post the error in Register A.

52A2H - Fill a File

Used by CLEAR and by CREATE's DATA (53A5H), with Register Pair DE at the open file. The buffer at 5919H is filled with 128 words of the value of DATA (the operand 52A9H; a value below 0100H is used for both bytes of the word). The file is then written sector by sector from its start: bit 7 of FCB+01H, the blocked records flag, is cleared for the writes so that every WRITE@ writes a whole sector, and put back at the end. The count is the file's ending record number at FCB+0CH-0DH, plus one when its end of file byte FCB+08H is not 00H.

52A2
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
52A3
LD HL,5919H 21 19 59
Point Register Pair HL to 5919H, the buffer of the file's sectors, to fill it with DATA.
52A6
LD B,80H 06 80
Load Register B with 80H, the 128 words of a sector of 256 bytes.
52A8
LD DE,0000H 11 00 00
Load Register Pair DE with the value of DATA, the operand 52A9H-52AAH (0000H for CLEAR, FFFFH for CREATE when it is not given).
52AB
INC D 14
INCrement Register D by 1, so that the DEC D below tests the high byte of DATA.
52AC
DEC D 15
DECrement Register D by 1: the Z FLAG when the high byte of DATA is 00H, a value of one byte.
52AD
If the NZ FLAG is set (a value of two bytes), JUMP to 52B0H to fill with Register E and Register D as they are.
52AF
LD D,E 53
Load Register D with Register E: a value of one byte is used for both bytes of the word.
52B0
LD (HL),E 73
Store Register E, the low byte of DATA, at Register Pair HL, the next byte of the buffer.
52B1
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the buffer.
52B2
LD (HL),D 72
Store Register D, the high byte of DATA, at Register Pair HL, the next byte of the buffer.
52B3
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the buffer.
52B4
DECrement Register B and LOOP back to 52B0H until the 128 words are stored.
52B6
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
52B7
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack, to take it into Index Register IX.
52B8
POP IX DD E1
Restore Index Register IX from the top of the stack: Index Register IX = the file control block.
52BA
LD A,80H 3E 80
Load Register A with 80H, the mask of bit 7, the blocked records flag of FCB+01H.
52BC
AND (IX+01H) DD A6 01
AND Register A with FCB+01H at Index Register IX+01H: Register A = 80H when the file is blocked.
52BF
LD H,A 67
Load Register H with Register A, the blocked records flag, to put it back at the end.
52C0
RES 7,(IX+01H) DD CB 01 BE
Reset bit 7 of FCB+01H at Index Register IX+01H, so that every WRITE@ writes a whole sector of the buffer.
52C4
LD C,(IX+0CH) DD 4E 0C
Load Register C with the low byte of the ending record number, FCB+0CH at Index Register IX+0CH.
52C7
LD B,(IX+0DH) DD 46 0D
Load Register B with the high byte of the ending record number, FCB+0DH at Index Register IX+0DH.
52CA
LD A,(IX+08H) DD 7E 08
Load Register A with the end of file byte, FCB+08H at Index Register IX+08H: 00H when the last sector is full.
52CD
OR A B7
OR Register A with itself: the NZ FLAG when the last sector is only partly used.
52CE
If the NZ FLAG is set (a part sector), JUMP to 52D5H, inside the next instruction, to count that sector too.
52D0
LD A,B 78
Load Register A with Register B, the high byte of the count of sectors.
52D1
OR C B1
OR Register A with Register C, the low byte: the Z FLAG when the file has no sectors.
52D2
If the Z FLAG is set (an empty file), JUMP to 52E4H: there is nothing to write.
52D4
LD A,03H 3E 03
Load Register A with 03H, which nothing uses; 52D5H enters inside this instruction, where its byte 03H reads as INC BC, so the part sector is counted in Register Pair BC.
52D6
GOSUB to 443FH, REW@, to position the file at Register Pair DE to its first sector.
52D9
GOSUB to 4439H, WRITE@, to write the buffer at 5919H to the next sector of the file at Register Pair DE: the NZ FLAG on an error.
52DC
If the NZ FLAG is set (WRITE@ failed), JUMP to 57ADH to post the error in Register A.
52DF
DEC BC 0B
DECrement Register Pair BC by 1, the count of the sectors still to write.
52E0
LD A,B 78
Load Register A with Register B, the high byte of the sectors still to write.
52E1
OR C B1
OR Register A with Register C, the low byte: the Z FLAG when every sector is written.
52E2
If the NZ FLAG is set (sectors left), JUMP back to 52D9H to write the next one.
52E4
LD A,H 7C
Load Register A with Register H, the blocked records flag saved at 52BFH.
52E5
OR (IX+01H) DD B6 01
OR Register A with FCB+01H at Index Register IX+01H, to put bit 7 back as it was.
52E8
LD (IX+01H),A DD 77 01
Store Register A into FCB+01H at Index Register IX+01H: the file is blocked again when it was.
52EB
RET C9
RETurn to the caller: CREATE at 53A8H, or for CLEAR the overlay request handler, so CLEAR leaves the file open (CLOSE@ is not called).

52ECH - CLEAR Memory

START must not be below 5C00H, END not above the top of memory, and START not above END, else error 2DH. The bytes from START to END, both included, are filled with DATA: its low byte at START, its high byte at the next address, and so on (a value below 0100H in every byte).

52EC
LD HL,0000H 21 00 00
Load Register Pair HL with the value of START, the operand 52EDH-52EEH (0000H in the file): 5C00H when START is not given.
52EF
LD DE,5C00H 11 00 5C
Load Register Pair DE with 5C00H, the lowest address CLEAR may fill.
52F2
GOSUB to 5733H to compare Register Pair HL with Register Pair DE: the C FLAG when START is below 5C00H.
52F5
If the C FLAG is set (START below 5C00H), JUMP to 5799H to post error 2DH, Invalid data provided.
52F8
PUSH HL E5
Save Register Pair HL, the value of START, to the top of the stack.
52F9
LD DE,0000H 11 00 00
Load Register Pair DE with the value of END, the operand 52FAH-52FBH (0000H in the file): the top of memory when END is not given.
52FC
LD HL,(4049H) 2A 49 40
Load Register Pair HL with the top of memory, HMEM$, from 4049H-404AH.
52FF
GOSUB to 5733H to compare Register Pair HL with Register Pair DE: the C FLAG when the top of memory is below END.
5302
If the C FLAG is set (END above the top of memory), JUMP to 5799H to post error 2DH, Invalid data provided.
5305
POP HL E1
Restore Register Pair HL, the value of START, from the top of the stack.
5306
GOSUB to 5733H to compare Register Pair HL (START) with Register Pair DE (END): the Z FLAG when equal, the C FLAG when START is lower.
5309
If the Z FLAG is set (START equals END), JUMP to 5317H to fill the one byte.
530B
If the NC FLAG is set (START above END), JUMP to 5799H to post error 2DH, Invalid data provided.
530E
LD BC,(52A9H) ED 4B A9 52
Load Register Pair BC with the value of DATA from 52A9H-52AAH, the operand of LD DE,0000H at 52A8H.
5312
INC B 04
INCrement Register B by 1, so that the DEC B below tests the high byte of DATA.
5313
DEC B 05
DECrement Register B by 1: the Z FLAG when the high byte of DATA is 00H, a value of one byte.
5314
If the NZ FLAG is set (a value of two bytes), JUMP to 5317H to fill with Register C and Register B as they are.
5316
LD B,C 41
Load Register B with Register C: a value of one byte is used for both bytes of the word.
5317
LD (HL),C 71
Store Register C, the low byte of DATA, at Register Pair HL, the next address to fill.
5318
GOSUB to 5733H to compare Register Pair HL with Register Pair DE (END): the Z FLAG at the last byte.
531B
RET Z C8
If the Z FLAG is set (END reached), RETurn to the overlay request handler: CLEAR is done.
531C
INC HL 23
INCrement Register Pair HL by 1, to the next address to fill.
531D
LD (HL),B 70
Store Register B, the high byte of DATA, at Register Pair HL, the next address to fill.
531E
GOSUB to 5733H to compare Register Pair HL with Register Pair DE (END): the Z FLAG at the last byte.
5321
RET Z C8
If the Z FLAG is set (END reached), RETurn to the overlay request handler: CLEAR is done.
5322
INC HL 23
INCrement Register Pair HL by 1, to the next address to fill.
5323
JUMP back to 5317H to fill the next two bytes.

5325H - CREATE

Routine 5, entered from CMNDI@ through the overlay request handler with Register Pair HL at the rest of the command line. GRANS (the operand 53EAH), KILO (53F4H), LRL (536AH), SIZE (53DBH), KEEP (53C8H) and VERIFY (53B4H) start as 0000H, DATA (52A9H) as FFFFH, the mark that it was not given (table 57E2H). The field must be a file name (else error 2FH); INIT@ opens it with the record length LRL (256 when 0) and must create it (a file that is there already is error 31H). The space (53DAH) is SIZE records, or GRANS granules, or KILO kilobytes of 4 sectors, the first of the three that was given; the file is positioned to the last record or sector of the space and that one is written, so that the whole space is given to the file. Then DATA fills it (52A2H), VERIFY reads it to its end, KEEP sets the non-shrinkable bit, and CLOSE@ closes the file.

5325
PUSH HL E5
Save Register Pair HL, the command line, to the top of the stack.
5326
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the value of a parameter that is not given.
5329
LD (53EAH),HL 22 EA 53
Store Register Pair HL (0000H) into 53EAH-53EBH, the operand of LD BC,0000H at 53E9H, the value of GRANS.
532C
LD (53F4H),HL 22 F4 53
Store Register Pair HL (0000H) into 53F4H-53F5H, the operand of LD BC,0000H at 53F3H, the value of KILO.
532F
LD (536AH),HL 22 6A 53
Store Register Pair HL (0000H) into 536AH-536BH, the operand of LD BC,0000H at 5369H, the value of LRL.
5332
LD (53DBH),HL 22 DB 53
Store Register Pair HL (0000H) into 53DBH-53DCH, the operand of LD BC,0000H at 53DAH, the value of SIZE.
5335
LD (53C8H),HL 22 C8 53
Store Register Pair HL (0000H) into 53C8H-53C9H, the operand of LD BC,0000H at 53C7H, the value of KEEP.
5338
LD (53B4H),HL 22 B4 53
Store Register Pair HL (0000H) into 53B4H-53B5H, the operand of LD HL,0000H at 53B3H, the value of VERIFY.
533B
DEC HL 2B
DECrement Register Pair HL by 1: FFFFH, the mark that DATA was not given.
533C
LD (52A9H),HL 22 A9 52
Store Register Pair HL (FFFFH) into 52A9H-52AAH, the operand of LD DE,0000H at 52A8H, the value of DATA.
533F
POP HL E1
Restore Register Pair HL, the command line, from the top of the stack.
5340
LD IX,57B3H DD 21 B3 57
Point Index Register IX to 57B3H, the evaluation block of SYS15/SYS for EVAL@.
5344
LD DE,57E2H 11 E2 57
Point Register Pair DE to 57E2H, CREATE's parameter table: DATA, GRANS, KEEP, KILO, LRL, SIZE and VERIFY.
5347
LD (57BAH),DE ED 53 BA 57
Store Register Pair DE (57E2H) into 57BAH-57BBH, the address of the parameter table in the evaluation block.
534B
GOSUB to 4479H, EVAL@, to take the fields and parameters from the command line at Register Pair HL: the NZ FLAG on an error.
534E
If the NZ FLAG is set (EVAL@ failed), JUMP to 57ADH to post the error in Register A.
5351
LD A,07H 3E 07
Load Register A with 07H, the mask of bits 0-2 of the evaluation block's flags, the fields given.
5353
AND (IX+00H) DD A6 00
AND Register A with the flags of the evaluation block at Index Register IX+00H: the Z FLAG when no field was given.
5356
If the Z FLAG is set (no field), JUMP to 5796H to post error 2FH, I/o field not found.
5359
LD DE,58D7H 11 D7 58
Point Register Pair DE to 58D7H, the field block of EVAL@: its flag byte, then the file control block.
535C
LD A,(DE) 1A
Load Register A with the flag byte of the field at Register Pair DE (58D7H).
535D
INC DE 13
INCrement Register Pair DE by 1, to the file control block at 58D8H.
535E
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack, to take it into Index Register IX.
535F
POP IX DD E1
Restore Index Register IX from the top of the stack: Index Register IX = the file control block at 58D8H.
5361
AND 60H E6 60
AND Register A with 60H, bits 6 and 5 of the flag byte: set when a name or a wildcard was given.
5363
If the Z FLAG is set (no name: a drive or a device), JUMP to 5796H to post error 2FH, I/o field not found.
5366
LD HL,5919H 21 19 59
Point Register Pair HL to 5919H, the buffer of the file's sectors.
5369
LD BC,0000H 01 00 00
Load Register Pair BC with the value of LRL, the operand 536AH-536BH: 0000H when LRL is not given.
536C
LD B,C 41
Load Register B with Register C, the low byte of LRL: the record length for INIT@ (00H is 256).
536D
GOSUB to 4420H, INIT@, to open the file at Register Pair DE with the buffer at Register Pair HL and the record length in Register B, creating it when it is not in the directory: the C FLAG when it was created.
5370
If the NZ FLAG is set (INIT@ failed), JUMP to 57ADH to post the error in Register A.
5373
If the NC FLAG is set (the file was there already), JUMP to 57A8H to post error 31H, File already exists.
5376
LD A,80H 3E 80
Load Register A with 80H, the mask of bit 7, the blocked records flag of FCB+01H.
5378
AND (IX+01H) DD A6 01
AND Register A with FCB+01H at Index Register IX+01H: Register A = 80H when the file is blocked.
537B
LD H,A 67
Load Register H with Register A, the blocked records flag, to put it back after the space is given.
537C
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
537D
GOSUB to 53DAH for the size of the space in Register Pair BC: the Z FLAG when no size was given.
5380
DEC BC 0B
DECrement Register Pair BC by 1, to the number of the last record or sector of the space (the flags are kept).
5381
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
5382
If the Z FLAG is set (no size), JUMP to 5394H: the file gets no space.
5384
GOSUB to 4442H, POSN@, to position the file at Register Pair DE to record Register Pair BC, the last of the space.
5387
GOSUB to 4439H, WRITE@, to write that record of the file at Register Pair DE, which gives the file the whole space: the NZ FLAG on an error.
538A
If the NZ FLAG is set (WRITE@ failed, the diskette full), JUMP to 57ADH to post the error in Register A.
538D
LD A,H 7C
Load Register A with Register H, the blocked records flag saved at 537BH.
538E
OR (IX+01H) DD B6 01
OR Register A with FCB+01H at Index Register IX+01H, to put bit 7 back as it was before 53DAH.
5391
LD (IX+01H),A DD 77 01
Store Register A into FCB+01H at Index Register IX+01H: the file is blocked again when it was.
5394
LD HL,(52A9H) 2A A9 52
Load Register Pair HL with the value of DATA from 52A9H-52AAH: FFFFH when DATA was not given.
5397
LD A,H 7C
Load Register A with Register H, the high byte of DATA.
5398
AND L A5
AND Register A with Register L, the low byte: Register A = FFH only when DATA is FFFFH.
5399
INC A 3C
INCrement Register A by 1: the Z FLAG when DATA is FFFFH (not given, or given as FFFFH), so that the file is not filled.
539A
LD A,(IX+08H) DD 7E 08
Load Register A with the end of file byte, FCB+08H at Index Register IX+08H, to keep it over the fill (LD does not change the flags).
539D
LD C,(IX+0CH) DD 4E 0C
Load Register C with FCB+0CH at Index Register IX+0CH, the low byte of the ending record number.
53A0
LD B,(IX+0DH) DD 46 0D
Load Register B with FCB+0DH at Index Register IX+0DH, the high byte of the ending record number.
53A3
PUSH AF F5
Save Register Pair AF, the end of file byte and the flags, to the top of the stack.
53A4
PUSH BC C5
Save Register Pair BC, the ending record number, to the top of the stack.
53A5
If the NZ FLAG is set (DATA given), GOSUB to 52A2H to fill every sector of the file with DATA.
53A8
POP BC C1
Restore Register Pair BC, the ending record number, from the top of the stack.
53A9
POP AF F1
Restore Register Pair AF, the end of file byte, from the top of the stack.
53AA
LD (IX+08H),A DD 77 08
Store Register A, the end of file byte, back into FCB+08H at Index Register IX+08H.
53AD
LD (IX+0CH),C DD 71 0C
Store Register C, the low byte of the ending record number, back into FCB+0CH at Index Register IX+0CH.
53B0
LD (IX+0DH),B DD 70 0D
Store Register B, the high byte of the ending record number, back into FCB+0DH at Index Register IX+0DH.
53B3
LD HL,0000H 21 00 00
Load Register Pair HL with the value of VERIFY, the operand 53B4H-53B5H: 0000H when VERIFY is not given.
53B6
INC L 2C
INCrement Register L by 1, so that the DEC L below tests the low byte of VERIFY.
53B7
DEC L 2D
DECrement Register L by 1: the Z FLAG when VERIFY is not given, or N.
53B8
If the Z FLAG is set (no VERIFY), JUMP to 53C7H for KEEP.
53BA
GOSUB to 443FH, REW@, to position the file at Register Pair DE to its first record.
53BD
GOSUB to 4436H, READ@, to read the next record of the file at Register Pair DE: the NZ FLAG at the end or on an error.
53C0
If the Z FLAG is set (the record was read), JUMP back to 53BDH to read the next record.
53C2
CP 1CH FE 1C
Compare Register A, the error code, against 1CH, Attempted to read past eof: the Z FLAG at the end of the file.
53C4
If the NZ FLAG is set (a read error), JUMP to 57ADH to post the error in Register A.
53C7
LD BC,0000H 01 00 00
Load Register Pair BC with the value of KEEP, the operand 53C8H-53C9H: FFFFH for KEEP, 0000H when it is not given.
53CA
LD A,80H 3E 80
Load Register A with 80H, the mask of bit 7, the non-shrinkable bit.
53CC
AND C A1
AND Register A with Register C, the low byte of KEEP: Register A = 80H for KEEP.
53CD
OR (IX+02H) DD B6 02
OR Register A with FCB+02H at Index Register IX+02H, the flags that CLOSE@ puts into the directory entry.
53D0
LD (IX+02H),A DD 77 02
Store Register A into FCB+02H at Index Register IX+02H: bit 7 set makes the file non-shrinkable.
53D3
GOSUB to 4428H, CLOSE@, to close the file at Register Pair DE: the NZ FLAG on an error.
53D6
If the NZ FLAG is set (CLOSE@ failed), JUMP to 57ADH to post the error in Register A.
53D9
RET C9
RETurn to the overlay request handler with the Z FLAG of CLOSE@: CREATE is done.

53DAH - The Size of the Space

Register Pair BC returns the number of records or sectors to give the file, with the NZ FLAG; the Z FLAG when none of SIZE, GRANS and KILO was given. SIZE is a count of records of the file's own length. GRANS is multiplied by the sectors per granule of the drive (DCT+0FH) and KILO by 4, the sectors of a kilobyte; for these two bit 7 of FCB+01H, the blocked records flag, is cleared, so that POSN@ takes the count as sectors whatever the record length. Only the low 16 bits of the product are used.

53DA
LD BC,0000H 01 00 00
Load Register Pair BC with the value of SIZE, the operand 53DBH-53DCH: 0000H when SIZE is not given.
53DD
LD A,B 78
Load Register A with Register B, the high byte of SIZE.
53DE
OR C B1
OR Register A with Register C, the low byte: the NZ FLAG when SIZE was given.
53DF
RET NZ C0
If the NZ FLAG is set (SIZE), RETurn with the count of records in Register Pair BC.
53E0
LD A,07H 3E 07
Load Register A with 07H, the mask of the drive number in FCB+06H.
53E2
AND (IX+06H) DD A6 06
AND Register A with FCB+06H at Index Register IX+06H: Register A = the drive of the file.
53E5
LD C,A 4F
Load Register C with Register A, the drive number for LOCDCT%.
53E6
GOSUB to 448BH, LOCDCT%, to point Index Register IY to the drive control table of the drive in Register C.
53E9
LD BC,0000H 01 00 00
Load Register Pair BC with the value of GRANS, the operand 53EAH-53EBH: 0000H when GRANS is not given.
53EC
LD A,B 78
Load Register A with Register B, the high byte of GRANS.
53ED
OR C B1
OR Register A with Register C, the low byte: the NZ FLAG when GRANS was given.
53EE
LD A,(IY+0FH) FD 7E 0F
Load Register A with the sectors per granule, DCT+0FH at Index Register IY+0FH (LD does not change the flags).
53F1
If the NZ FLAG is set (GRANS), JUMP to 53FBH to multiply the granules by the sectors per granule in Register A.
53F3
LD BC,0000H 01 00 00
Load Register Pair BC with the value of KILO, the operand 53F4H-53F5H: 0000H when KILO is not given.
53F6
LD A,B 78
Load Register A with Register B, the high byte of KILO.
53F7
OR C B1
OR Register A with Register C, the low byte: the Z FLAG when KILO was not given either.
53F8
RET Z C8
If the Z FLAG is set (no size at all), RETurn with the Z FLAG: the file gets no space.
53F9
LD A,04H 3E 04
Load Register A with 04H, the sectors of a kilobyte (four sectors of 256 bytes).
53FB
PUSH HL E5
Save Register Pair HL to the top of the stack, to keep it over the multiplication.
53FC
LD H,B 60
Load Register H with Register B, the high byte of the granules or kilobytes.
53FD
LD L,C 69
Load Register L with Register C: Register Pair HL = the granules or kilobytes.
53FE
GOSUB to 444BH, MULT@, to multiply Register Pair HL by Register A: a 24 bit product, Register Pair HL the high bytes, Register A the low byte.
5401
LD C,A 4F
Load Register C with Register A, the low byte of the product.
5402
LD B,L 45
Load Register B with Register L, the middle byte: Register Pair BC = the sectors (the high byte in Register H is dropped).
5403
POP HL E1
Restore Register Pair HL from the top of the stack.
5404
RES 7,(IX+01H) DD CB 01 BE
Reset bit 7 of FCB+01H at Index Register IX+01H, the blocked records flag, so that POSN@ takes Register Pair BC as a sector.
5408
OR FFH F6 FF
OR Register A with FFH to set the NZ FLAG: a size was given.
540A
RET C9
RETurn with the count of sectors in Register Pair BC and the NZ FLAG.

540BH - DUMP

Routine 6, entered from CMNDI@ through the overlay request handler with Register Pair HL at the rest of the command line. DATA (54DBH) starts as 0000H, RELO (54D9H) as FFFFH, the mark that it was not given, START (54D5H) as 5C00H, END (54D7H) as the top of memory HMEM$ and TRA (54D3H) as 402DH, EXIT@ (table 5822H). 574FH opens the field: a file by INIT@ with the default extension CMD, or CIM with DATA, or a device. START must not be above END (error 2DH); neither is checked against 5C00H or the top of memory. The area is written in pieces of up to 254 bytes: for a load module each piece is a load block (01H, the length with the two address bytes, the address plus the offset RELO less START), and a transfer record (02H, 02H, TRA) ends the file; with DATA only the bytes are written. TRA is not moved by RELO. 5788H closes the file.

540B
PUSH HL E5
Save Register Pair HL, the command line, to the top of the stack.
540C
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the value of DATA when it is not given.
540F
LD (54DBH),HL 22 DB 54
Store Register Pair HL (0000H) into 54DBH-54DCH, the value of DATA.
5412
DEC HL 2B
DECrement Register Pair HL by 1: FFFFH, the mark that RELO was not given.
5413
LD (54D9H),HL 22 D9 54
Store Register Pair HL (FFFFH) into 54D9H-54DAH, the value of RELO.
5416
LD HL,5C00H 21 00 5C
Load Register Pair HL with 5C00H, the value of START when it is not given.
5419
LD (54D5H),HL 22 D5 54
Store Register Pair HL (5C00H) into 54D5H-54D6H, the value of START.
541C
LD HL,(4049H) 2A 49 40
Load Register Pair HL with the top of memory, HMEM$, from 4049H-404AH, the value of END when it is not given.
541F
LD (54D7H),HL 22 D7 54
Store Register Pair HL (the top of memory) into 54D7H-54D8H, the value of END.
5422
LD HL,402DH 21 2D 40
Load Register Pair HL with 402DH, EXIT@, the value of TRA when it is not given: the program goes back to DOSPLUS.
5425
LD (54D3H),HL 22 D3 54
Store Register Pair HL (402DH) into 54D3H-54D4H, the value of TRA, the address of the transfer record.
5428
POP HL E1
Restore Register Pair HL, the command line, from the top of the stack.
5429
LD IX,57B3H DD 21 B3 57
Point Index Register IX to 57B3H, the evaluation block of SYS15/SYS for EVAL@.
542D
LD DE,5822H 11 22 58
Point Register Pair DE to 5822H, DUMP's parameter table: DATA, END, RELO, START and TRA.
5430
LD (57BAH),DE ED 53 BA 57
Store Register Pair DE (5822H) into 57BAH-57BBH, the address of the parameter table in the evaluation block.
5434
GOSUB to 4479H, EVAL@, to take the fields and parameters from the command line at Register Pair HL: the NZ FLAG on an error.
5437
If the NZ FLAG is set (EVAL@ failed), JUMP to 57ADH to post the error in Register A.
543A
LD A,(54DBH) 3A DB 54
Load Register A with the low byte of DATA from 54DBH: FFH with DATA, 00H without it.
543D
LD C,03H 0E 03
Load Register C with 03H, the number of the default extension CMD in the list at 5875H.
543F
ADD A,C 81
ADD Register C to Register A: 03H (CMD) without DATA, 02H (CIM) with DATA.
5440
LD C,A 4F
Load Register C with Register A, the number of the default extension for 574FH.
5441
GOSUB to 574FH to check the field EVAL@ took and open it: Register Pair DE returns the file control block or the device's.
5444
PUSH DE D5
Save Register Pair DE, the control block, to the top of the stack.
5445
LD HL,(54D5H) 2A D5 54
Load Register Pair HL with the value of START from 54D5H-54D6H.
5448
LD DE,(54D7H) ED 5B D7 54
Load Register Pair DE with the value of END from 54D7H-54D8H.
544C
GOSUB to 5733H to compare Register Pair HL (START) with Register Pair DE (END): the Z FLAG when equal, the C FLAG when START is lower.
544F
POP DE D1
Restore Register Pair DE, the control block, from the top of the stack.
5450
If the Z FLAG is set (START equals END), JUMP to 5455H: one byte is written.
5452
If the NC FLAG is set (START above END), JUMP to 5799H to post error 2DH, Invalid data provided.
5455
LD HL,(54D9H) 2A D9 54
Load Register Pair HL with the value of RELO from 54D9H-54DAH: FFFFH when RELO was not given.
5458
INC HL 23
INCrement Register Pair HL by 1: 0000H when RELO was not given.
5459
LD A,H 7C
Load Register A with Register H, the high byte of RELO plus 1.
545A
OR L B5
OR Register A with Register L: the Z FLAG when RELO was not given, with Register Pair HL = 0000H, no offset.
545B
If the Z FLAG is set (no RELO), JUMP to 5467H to store the offset 0000H.
545D
DEC HL 2B
DECrement Register Pair HL by 1, back to the value of RELO.
545E
PUSH DE D5
Save Register Pair DE, the control block, to the top of the stack.
545F
LD DE,(54D5H) ED 5B D5 54
Load Register Pair DE with the value of START from 54D5H-54D6H.
5463
OR A B7
OR Register A with itself to clear the C FLAG for the SBC below.
5464
SBC HL,DE ED 52
Subtract Register Pair DE (START) from Register Pair HL (RELO): Register Pair HL = the offset added to every load address.
5466
POP DE D1
Restore Register Pair DE, the control block, from the top of the stack.
5467
LD (54D9H),HL 22 D9 54
Store Register Pair HL, the offset, into 54D9H-54DAH, in place of RELO.
546A
LD HL,(54D7H) 2A D7 54
Load Register Pair HL with the value of END from 54D7H-54D8H, the last byte of the area.
546D
INC HL 23
INCrement Register Pair HL by 1, to the address after the area.
546E
PUSH DE D5
Save Register Pair DE, the control block, to the top of the stack.
546F
LD DE,(54D5H) ED 5B D5 54
Load Register Pair DE with the value of START from 54D5H-54D6H, the next byte to write.
5473
OR A B7
OR Register A with itself to clear the C FLAG for the SBC below.
5474
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: Register Pair HL = the bytes still to write, the Z FLAG when none are left.
5476
If the Z FLAG is set (the area is written), JUMP to 54B1H to end the file.
5478
LD DE,00FEH 11 FE 00
Load Register Pair DE with 00FEH, the 254 bytes of a full load block.
547B
OR A B7
OR Register A with itself to clear the C FLAG for the SBC below.
547C
SBC HL,DE ED 52
Subtract Register Pair DE (00FEH) from Register Pair HL: the C FLAG when fewer than 254 bytes are left.
547E
POP DE D1
Restore Register Pair DE, the control block, from the top of the stack.
547F
LD A,00H 3E 00
Load Register A with 00H, the length byte of a full block: 256, the 254 bytes and the two of the address.
5481
If the NC FLAG is set (254 bytes or more left), JUMP to 5484H with the length byte 00H.
5483
ADD A,L 85
ADD Register L to Register A: Register A = the bytes left less 254, modulo 256, which is the bytes left plus 2, the length byte of the last block.
5484
LD (54CDH),A 32 CD 54
Store Register A, the length byte, into 54CDH, the length of the block header.
5487
LD B,04H 06 04
Load Register B with 04H, the four bytes of the block header for 54C1H.
5489
LD C,A 4F
Load Register C with Register A, the length byte, to count the bytes of the block.
548A
LD A,(54DBH) 3A DB 54
Load Register A with the low byte of DATA from 54DBH: FFH with DATA.
548D
OR A B7
OR Register A with itself: the NZ FLAG with DATA.
548E
If the NZ FLAG is set (DATA), JUMP to 54A3H: a data file has no block headers.
5490
PUSH BC C5
Save Register Pair BC, the counts, to the top of the stack.
5491
LD HL,(54D5H) 2A D5 54
Load Register Pair HL with the value of START from 54D5H-54D6H, the first byte of the block.
5494
LD BC,(54D9H) ED 4B D9 54
Load Register Pair BC with the offset from 54D9H-54DAH, RELO less START.
5498
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the load address of the block, START plus the offset of RELO.
5499
LD (54CEH),HL 22 CE 54
Store Register Pair HL into 54CEH-54CFH, the load address of the block header.
549C
POP BC C1
Restore Register Pair BC, the counts, from the top of the stack.
549D
LD HL,54CBH 21 CB 54
Point Register Pair HL to 54CBH, the block header after its count of 4 bytes.
54A0
GOSUB to 54C1H to write the bytes of the header (01H, the length, the address) to the control block at Register Pair DE.
54A3
DEC C 0D
DECrement Register C by 1, the length byte less one.
54A4
DEC C 0D
DECrement Register C by 1: Register C = the bytes of the block, the length less the two address bytes.
54A5
LD B,C 41
Load Register B with Register C, the count of bytes to write.
54A6
LD HL,(54D5H) 2A D5 54
Load Register Pair HL with the value of START from 54D5H-54D6H, the first byte of the block.
54A9
GOSUB to 54C3H to write Register B bytes from Register Pair HL to the control block at Register Pair DE.
54AC
LD (54D5H),HL 22 D5 54
Store Register Pair HL, the address after the block, into 54D5H-54D6H as the new START.
54AF
JUMP back to 546AH for the next block of the area, until all of it is written.
54B1
POP DE D1
Restore Register Pair DE, the control block, from the top of the stack.
54B2
LD A,(54DBH) 3A DB 54
Load Register A with the low byte of DATA from 54DBH: FFH with DATA.
54B5
OR A B7
OR Register A with itself: the NZ FLAG with DATA.
54B6
If the NZ FLAG is set (DATA), JUMP to 54BEH: a data file has no transfer record.
54B8
LD HL,54D0H 21 D0 54
Point Register Pair HL to 54D0H, the transfer record after its count of 4 bytes.
54BB
GOSUB to 54C1H to write 02H, 02H and the address TRA to the control block at Register Pair DE.
54BE
JUMP to 5788H to close the file at Register Pair DE (a device is not closed) and end DUMP.

54C1H - Write Bytes

54C1H takes the count from the byte at Register Pair HL and writes the bytes after it; 54C3H writes Register B bytes from Register Pair HL. Each byte goes out through 5739H to the control block at Register Pair DE; the flags 5739H returns are not tested, so a write error does not stop DUMP.

54C1
LD B,(HL) 46
Load Register B with the count of bytes at Register Pair HL, the first byte of the record.
54C2
INC HL 23
INCrement Register Pair HL by 1, to the first byte to write.
54C3
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the next one to write.
54C4
INC HL 23
INCrement Register Pair HL by 1, to the byte after it.
54C5
GOSUB to 5739H to put the byte in Register A to the control block at Register Pair DE.
54C8
DECrement Register B and LOOP back to 54C3H until all the bytes are written.
54CA
RET C9
RETurn to the caller with Register Pair HL after the last byte written.

54CBH - DUMP's Records and Values

Data: the header of a load block and the transfer record, each after the count of its bytes for 54C1H, and the values of DUMP's parameters, which EVAL@ stores here (table 5822H) and 540BH-5425H set first.

54CB
DEFB 04H 04
The count of the bytes of the block header for 54C1H: four bytes follow.
54CC
DEFB 01H 01
The record type of a load block, 01H, the first byte of every block header.
54CD
DEFB 00H 00
The length byte of the block, stored at 5484H: the bytes of the block plus the two of the address (00H is 256).
54CE-54CF
DEFW 0000H 00 00
The load address of the block, stored at 5499H: START plus the offset of RELO.
54D0
DEFB 04H 04
The count of the bytes of the transfer record for 54C1H: four bytes follow.
54D1
DEFB 02H 02
The record type of the transfer record, 02H, which ends a load module.
54D2
DEFB 02H 02
The length byte of the transfer record: the two bytes of the transfer address.
54D3-54D4
DEFW 0000H 00 00
TRA, the transfer address of the transfer record: 402DH when TRA is not given (5422H).
54D5-54D6
DEFW 0000H 00 00
START, the next byte of the area to write: 5C00H when START is not given (5416H).
54D7-54D8
DEFW 0000H 00 00
END, the last byte of the area: the top of memory when END is not given (541CH).
54D9-54DA
DEFW 0000H 00 00
RELO, FFFFH when it is not given (5412H); from 5467H on, the offset RELO less START (0000H without RELO).
54DB-54DC
DEFW 0000H 00 00
DATA: FFFFH with DATA, 0000H without it (540FH); its low byte also picks the default extension (543AH).

54DDH - LOAD

Routine 7, entered from CMNDI@ through the overlay request handler with Register Pair HL at the rest of the command line. PROMPT (the operand 551CH), RUN (55FEH) and START (55A8H) start as 0000H, TRA (5597H) as 402DH, EXIT@ (table 5850H). The field must be a file name (else error 2FH); no default extension is added. SYS2/SYS is brought in first (request 12H), so that OPEN@ needs no system diskette; with PROMPT the target diskette is asked for, the file is opened, the system diskette is asked for while SYS4/SYS is brought in (request 32H), and then the target diskette again. With START the file is a core image, loaded from START to its end (55A7H); otherwise it is a load module (5556H). With RUN the program is then run; with PROMPT the system diskette is asked for first.

54DD
PUSH HL E5
Save Register Pair HL, the command line, to the top of the stack.
54DE
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the value of a parameter that is not given.
54E1
LD (551CH),HL 22 1C 55
Store Register Pair HL (0000H) into 551CH-551DH, the operand of LD HL,0000H at 551BH, the value of PROMPT.
54E4
LD (55FEH),HL 22 FE 55
Store Register Pair HL (0000H) into 55FEH-55FFH, the value of RUN.
54E7
LD (55A8H),HL 22 A8 55
Store Register Pair HL (0000H) into 55A8H-55A9H, the operand of LD HL,0000H at 55A7H, the value of START.
54EA
LD HL,402DH 21 2D 40
Load Register Pair HL with 402DH, EXIT@, the value of TRA when it is not given.
54ED
LD (5597H),HL 22 97 55
Store Register Pair HL (402DH) into 5597H-5598H, the operand of LD DE,0000H at 5596H, the value of TRA.
54F0
LD HL,5850H 21 50 58
Point Register Pair HL to 5850H, LOAD's parameter table: PROMPT, RUN, START and TRA.
54F3
LD (57BAH),HL 22 BA 57
Store Register Pair HL (5850H) into 57BAH-57BBH, the address of the parameter table in the evaluation block.
54F6
POP HL E1
Restore Register Pair HL, the command line, from the top of the stack.
54F7
LD IX,57B3H DD 21 B3 57
Point Index Register IX to 57B3H, the evaluation block of SYS15/SYS for EVAL@.
54FB
GOSUB to 4479H, EVAL@, to take the fields and parameters from the command line at Register Pair HL: the NZ FLAG on an error.
54FE
If the NZ FLAG is set (EVAL@ failed), JUMP to 57ADH to post the error in Register A.
5501
LD A,07H 3E 07
Load Register A with 07H, the mask of bits 0-2 of the evaluation block's flags, the fields given.
5503
AND (IX+00H) DD A6 00
AND Register A with the flags of the evaluation block at Index Register IX+00H: the Z FLAG when no field was given.
5506
If the Z FLAG is set (no field), JUMP to 5796H to post error 2FH, I/o field not found.
5509
LD DE,58D7H 11 D7 58
Point Register Pair DE to 58D7H, the field block of EVAL@: its flag byte, then the file control block.
550C
PUSH DE D5
Save Register Pair DE (58D7H) to the top of the stack, to take it into Index Register IX.
550D
POP IX DD E1
Restore Index Register IX from the top of the stack: Index Register IX = 58D7H, which LOAD does not use further.
550F
LD A,(DE) 1A
Load Register A with the flag byte of the field at Register Pair DE (58D7H).
5510
INC DE 13
INCrement Register Pair DE by 1, to the file control block at 58D8H.
5511
AND 60H E6 60
AND Register A with 60H, bits 6 and 5 of the flag byte: set when a name or a wildcard was given.
5513
If the Z FLAG is set (no name: a drive or a device), JUMP to 5796H to post error 2FH, I/o field not found.
5516
LD A,12H 3E 12
Load Register A with 12H, the request code of SYS2/SYS's routine 2, which only brings SYS2/SYS in.
5518
GOSUB to 57B2H to request the overlay routine in Register A: SYS2/SYS is loaded while the system diskette is in its drive.
551B
LD HL,0000H 21 00 00
Load Register Pair HL with the value of PROMPT, the operand 551CH-551DH: 0000H when PROMPT is not given.
551E
INC L 2C
INCrement Register L by 1, so that the DEC L below tests the low byte of PROMPT.
551F
DEC L 2D
DECrement Register L by 1: the NZ FLAG with PROMPT.
5520
LD HL,5899H 21 99 58
Point Register Pair HL to 5899H, the text Insert TARGET diskette (ENTER) (LD does not change the flags).
5523
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
5524
If the NZ FLAG is set (PROMPT), GOSUB to 55D2H to show the text at Register Pair HL and wait for a key.
5527
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
5528
LD HL,5919H 21 19 59
Point Register Pair HL to 5919H, the buffer of the file's sectors.
552B
LD B,00H 06 00
Load Register B with 00H, the record length 256 for OPEN@.
552D
GOSUB to 4424H, OPEN@, to open the file at Register Pair DE with the buffer at Register Pair HL and the record length in Register B: the NZ FLAG on an error.
5530
If the NZ FLAG is set (OPEN@ failed), JUMP to 5578H to ask for the system diskette and post the error.
5532
LD A,(551CH) 3A 1C 55
Load Register A with the low byte of PROMPT from 551CH.
5535
OR A B7
OR Register A with itself: the NZ FLAG with PROMPT.
5536
LD HL,58B8H 21 B8 58
Point Register Pair HL to 58B8H, the text Insert SYSTEM diskette (ENTER) (LD does not change the flags).
5539
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
553A
If the NZ FLAG is set (PROMPT), GOSUB to 55D2H to show the text at Register Pair HL and wait for a key.
553D
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
553E
LD A,32H 3E 32
Load Register A with 32H, the request code of SYS4/SYS's routine 2, which only brings SYS4/SYS in.
5540
GOSUB to 57B2H to request the overlay routine in Register A: SYS4/SYS is loaded from the system diskette.
5543
LD A,(551CH) 3A 1C 55
Load Register A with the low byte of PROMPT from 551CH.
5546
OR A B7
OR Register A with itself: the NZ FLAG with PROMPT.
5547
LD HL,5899H 21 99 58
Point Register Pair HL to 5899H, the text Insert TARGET diskette (ENTER) (LD does not change the flags).
554A
PUSH DE D5
Save Register Pair DE, the file control block, to the top of the stack.
554B
If the NZ FLAG is set (PROMPT), GOSUB to 55D2H to ask for the target diskette again.
554E
POP DE D1
Restore Register Pair DE, the file control block, from the top of the stack.
554F
LD HL,(55A8H) 2A A8 55
Load Register Pair HL with the value of START from 55A8H-55A9H, the operand of LD HL,0000H at 55A7H.
5552
LD A,H 7C
Load Register A with Register H, the high byte of START.
5553
OR L B5
OR Register A with Register L, the low byte: the NZ FLAG when START was given.
5554
If the NZ FLAG is set (START), JUMP to 55A7H to load a core image file from START.

5556H - Loading a Load Module

Each record starts with its type and its length; 5556H reads the type into Register C, the length into Register B and the next two bytes into Register Pair HL (the load address of a load block, the transfer address of a transfer record). Type 01H: the length less 2 bytes are loaded to Register Pair HL on (5587H). Type 02H: the end (5590H). Any other type is passed over (55A0H) only when the fourth byte of the record, still in Register A, is below 1EH: the code compares that byte, not the type. Otherwise the LD A,22H at 5572H runs on into 5574H, which reads one more byte and then RETurns from LOAD without loading the rest or posting an error (so a comment record whose second character is 1EH or more, such as the module name every DOSPLUS load module starts with, ends LOAD there). 5574H gets a byte of the file; on an error the system diskette is asked for (PROMPT) and the error is posted.

5556
GOSUB to 5574H to get the next byte of the file into Register A: the record type.
5559
LD C,A 4F
Load Register C with Register A, the record type.
555A
GOSUB to 5574H to get the next byte of the file into Register A: the length of the record.
555D
LD B,A 47
Load Register B with Register A, the length of the record.
555E
GOSUB to 5574H to get the next byte of the file into Register A: the low byte of the address.
5561
LD L,A 6F
Load Register L with Register A, the low byte of the address.
5562
GOSUB to 5574H to get the next byte of the file into Register A: the high byte of the address.
5565
LD H,A 67
Load Register H with Register A: Register Pair HL = the address of the record.
5566
DEC B 05
DECrement Register B by 1, for the first byte of the address.
5567
DEC B 05
DECrement Register B by 1, for the second byte: Register B = the bytes after the address.
5568
DEC C 0D
DECrement Register C by 1: the Z FLAG for the record type 01H, a load block.
5569
If the Z FLAG is set (a load block), JUMP to 5587H to load its bytes to Register Pair HL.
556B
DEC C 0D
DECrement Register C by 1: the Z FLAG for the record type 02H, the transfer record.
556C
If the Z FLAG is set (the transfer record), JUMP to 5590H for the end of the load module.
556E
CP 1EH FE 1E
Compare Register A against 1EH: Register A still holds the fourth byte read, the high byte in Register H, not the record type.
5570
If the C FLAG is set (below 1EH), JUMP to 55A0H to pass over the rest of the record.
5572
LD A,22H 3E 22
Load Register A with 22H, the error code Attempted to use non program file as a program, and run on into 5574H, which replaces it with the next byte read.
5574
GOSUB to 0013H, the ROM's routine that gets a byte from the file at Register Pair DE into Register A: the NZ FLAG on an error.
5577
RET Z C8
If the Z FLAG is set (a byte was read), RETurn to the caller with the byte in Register A.
5578
PUSH AF F5
Save Register Pair AF, the error code, to the top of the stack.
5579
LD A,(551CH) 3A 1C 55
Load Register A with the low byte of PROMPT from 551CH.
557C
OR A B7
OR Register A with itself: the NZ FLAG with PROMPT.
557D
LD HL,58B8H 21 B8 58
Point Register Pair HL to 58B8H, the text Insert SYSTEM diskette (ENTER) (LD does not change the flags).
5580
If the NZ FLAG is set (PROMPT), GOSUB to 55D2H to ask for the system diskette, which ERROR@ needs for SYS5/SYS.
5583
POP AF F1
Restore Register Pair AF, the error code, from the top of the stack.
5584
JUMP to 57ADH to post the error in Register A.
5587
GOSUB to 5574H to get the next byte of the load block into Register A.
558A
LD (HL),A 77
Store Register A, the byte, at Register Pair HL, its place in memory.
558B
INC HL 23
INCrement Register Pair HL by 1, to the next place in memory.
558C
DECrement Register B and LOOP back to 5587H until the bytes of the block are loaded.
558E
JUMP back to 5556H for the next record of the load module.
5590
LD A,(55FEH) 3A FE 55
Load Register A with the low byte of RUN from 55FEH: FFH with RUN.
5593
OR A B7
OR Register A with itself: the Z FLAG when RUN was not given.
5594
If the Z FLAG is set (no RUN), JUMP to 55C1H, inside the OR at 55C0H, where XOR A sets the Z FLAG: the program is not run.
5596
LD DE,0000H 11 00 00
Load Register Pair DE with the value of TRA, the operand 5597H-5598H (0000H in the file): 402DH when TRA is not given.
5599
LD A,D 7A
Load Register A with Register D, the high byte of TRA.
559A
OR E B3
OR Register A with Register E, the low byte: the Z FLAG when TRA is 0000H.
559B
If the Z FLAG is set (TRA=0), JUMP to 55C0H to run the program at the file's own transfer address in Register Pair HL.
559D
EX DE,HL EB
EXchange Register Pair DE and Register Pair HL: Register Pair HL = TRA, which takes the place of the file's transfer address (402DH when TRA is not given, so RUN alone goes back to DOSPLUS).
559E
JUMP to 55C0H to run the program at the address in Register Pair HL.
55A0
GOSUB to 5574H to get the next byte of the record into Register A, which is passed over.
55A3
DECrement Register B and LOOP back to 55A0H until the rest of the record is passed over.
55A5
JUMP back to 5556H for the next record of the load module.

55A7H - Loading a Core Image File

With START every byte of the file goes to memory from START on, up to the end of the file (error 1CH; any other error is posted). The address to run is TRA (402DH when it is not given), used only with RUN. The end (55B7H-55D1H, also reached from the load module) asks for the system diskette when PROMPT was given, then RETurns without RUN or jumps to the address with RUN.

55A7
LD HL,0000H 21 00 00
Load Register Pair HL with the value of START, the operand 55A8H-55A9H (0000H in the file), the first address to load.
55AA
GOSUB to 0013H, the ROM's routine that gets a byte from the file at Register Pair DE into Register A: the NZ FLAG at the end of the file or on an error.
55AD
If the NZ FLAG is set (no byte), JUMP to 55B3H.
55AF
LD (HL),A 77
Store Register A, the byte, at Register Pair HL, its place in memory.
55B0
INC HL 23
INCrement Register Pair HL by 1, to the next place in memory.
55B1
JUMP back to 55AAH for the next byte of the file.
55B3
CP 1CH FE 1C
Compare Register A, the error code, against 1CH, Attempted to read past eof: the Z FLAG at the end of the file.
55B5
If the NZ FLAG is set (another error), JUMP to 5578H to ask for the system diskette and post the error.
55B7
LD HL,(5597H) 2A 97 55
Load Register Pair HL with the value of TRA from 5597H-5598H: 402DH when TRA is not given.
55BA
LD A,(55FEH) 3A FE 55
Load Register A with the low byte of RUN from 55FEH: FFH with RUN.
55BD
OR A B7
OR Register A with itself: the Z FLAG when RUN was not given.
55BE
If the Z FLAG is set (no RUN), JUMP to 55C1H, inside the next instruction, where XOR A keeps the Z FLAG.
55C0
OR AFH F6 AF
OR Register A with AFH to set the NZ FLAG: the program is run. 55C1H enters inside this instruction, where its byte AFH reads as XOR A, which sets Register A to 00H and the Z FLAG: the program is not run.
55C2
PUSH AF F5
Save Register Pair AF, the NZ FLAG to run or the Z FLAG to return, to the top of the stack.
55C3
PUSH HL E5
Save Register Pair HL, the address to run, to the top of the stack.
55C4
LD A,(551CH) 3A 1C 55
Load Register A with the low byte of PROMPT from 551CH.
55C7
OR A B7
OR Register A with itself: the NZ FLAG with PROMPT.
55C8
LD HL,58B8H 21 B8 58
Point Register Pair HL to 58B8H, the text Insert SYSTEM diskette (ENTER) (LD does not change the flags).
55CB
If the NZ FLAG is set (PROMPT), GOSUB to 55D2H to ask for the system diskette before LOAD ends.
55CE
POP HL E1
Restore Register Pair HL, the address to run, from the top of the stack.
55CF
POP AF F1
Restore Register Pair AF, the flags, from the top of the stack.
55D0
RET Z C8
If the Z FLAG is set (no RUN), RETurn to the overlay request handler: LOAD is done.
55D1
JP (HL) E9
JUMP to the address in Register Pair HL to run the program that was loaded.

55D2H - Ask for a Diskette

Used by LOAD's PROMPT with Register Pair HL at a text that ends with a carriage return. Nothing is shown while a DO file runs (bit 5 of SFLAG1$). Otherwise the line is cleared and the text shown in turn, each for 500 scans of the keyboard (55F1H), until a key is pressed. The key is not tested, so any key goes on, where the text asks for ENTER.

55D2
LD A,(4302H) 3A 02 43
Load Register A with the system flags SFLAG1$ from 4302H.
55D5
BIT 5,A CB 6F
Test bit 5 of Register A, SFLAG1$: set while a DO file runs.
55D7
RET NZ C0
If the NZ FLAG is set (a DO file runs), RETurn to the caller: there is no prompt.
55D8
LD A,1EH 3E 1E
Load Register A with 1EH, the code that clears the line from the cursor to its end.
55DA
GOSUB to 0033H, the ROM's routine that shows the character in Register A: the text is cleared.
55DD
GOSUB to 55F1H to scan the keyboard 500 times: the NZ FLAG when a key was pressed.
55E0
PUSH AF F5
Save Register Pair AF, the flags of the scan, to the top of the stack.
55E1
GOSUB to 4467H, DSPLY@, to show the text at Register Pair HL and its carriage return.
55E4
LD A,1BH 3E 1B
Load Register A with 1BH, the code that moves the cursor up a line, back to the line of the text.
55E6
GOSUB to 0033H, the ROM's routine that shows the character in Register A: the cursor goes back to the start of the text.
55E9
POP AF F1
Restore Register Pair AF, the flags of the scan, from the top of the stack.
55EA
RET NZ C0
If the NZ FLAG is set (a key was pressed), RETurn to the caller: the diskette is in.
55EB
GOSUB to 55F1H to scan the keyboard 500 times while the text is shown: the NZ FLAG when a key was pressed.
55EE
RET NZ C0
If the NZ FLAG is set (a key was pressed), RETurn to the caller: the diskette is in.
55EF
JUMP back to 55D8H to clear the text again, until a key is pressed.

55F1H - Scan the Keyboard

Up to 500 (01F4H) scans of the keyboard by the ROM's 002BH. Returns the NZ FLAG with the key in Register A as soon as one is pressed, or the Z FLAG after 500 scans without a key.

55F1
LD BC,01F4H 01 F4 01
Load Register Pair BC with 01F4H, the 500 scans of the keyboard.
55F4
GOSUB to 002BH, the ROM's routine that scans the keyboard: Register A returns the key with the NZ FLAG, or 00H.
55F7
RET NZ C0
If the NZ FLAG is set (a key), RETurn to the caller with the key in Register A.
55F8
DEC BC 0B
DECrement Register Pair BC by 1, the count of the scans still to make.
55F9
LD A,B 78
Load Register A with Register B, the high byte of the count.
55FA
OR C B1
OR Register A with Register C, the low byte: the Z FLAG after 500 scans.
55FB
RET Z C8
If the Z FLAG is set (500 scans without a key), RETurn to the caller with the Z FLAG.
55FC
JUMP back to 55F4H to scan the keyboard again.

55FEH - RUN's Value

Data: the value of LOAD's switch RUN, which EVAL@ stores here (table 5850H) after 54E4H clears it.

55FE-55FF
DEFW 0000H 00 00
RUN: FFFFH with RUN, 0000H without it (54E4H); LOAD tests its low byte (5590H, 55BAH).

5600H - RENAME

Routine 8, entered from CMNDI@ through the overlay request handler with Register Pair HL at the rest of the command line. RENAME does not use EVAL@: FSPEC@ moves the old name into the file control block 58D7H and the new name into 58F8H (the words TO and FROM are passed over); a specification it cannot take is error 2CH. Two devices or two drives (both with @ or both with a colon) are renamed in their tables (56C3H); a file with a device or a drive is error 2CH or 2BH. A file is opened by OPEN@, which checks its password, and an access level of 3 or above is error 25H. The new name may not have a drive (error 20H): it takes the old file's drive and must not be on it (error 31H). The name and extension of the directory entry are replaced by those of the new name, as OPEN@ left them in SYS2/SYS's buffer 51E0H (routine 8), and the entry's byte in the hash index table by their hash code (routine 7). The file is not closed.

5600
LD DE,58D7H 11 D7 58
Point Register Pair DE to 58D7H, the first file control block, for the old name.
5603
GOSUB to 441CH, FSPEC@, to move the specification at Register Pair HL into the file control block at Register Pair DE: the NZ FLAG when there is none.
5606
If the NZ FLAG is set (no specification), JUMP to 5793H to post error 2CH, Illegal filespec.
5609
LD DE,58F8H 11 F8 58
Point Register Pair DE to 58F8H, the second file control block, for the new name.
560C
GOSUB to 441CH, FSPEC@, to move the next specification at Register Pair HL (TO passed over) into the file control block at Register Pair DE.
560F
If the NZ FLAG is set (no new name), JUMP to 5793H to post error 2CH, Illegal filespec.
5612
LD A,(58D7H) 3A D7 58
Load Register A with the first character of the old name at 58D7H.
5615
LD B,A 47
Load Register B with Register A, the first character of the old name, for 56C3H.
5616
CP 40H FE 40
Compare Register A against 40H, the character @ that starts the name of a device.
5618
If the Z FLAG is set (a device), JUMP to 56C3H to rename a device.
561B
CP 3AH FE 3A
Compare Register A against 3AH, the colon that starts the name of a drive.
561D
If the Z FLAG is set (a drive), JUMP to 56C3H to rename a drive.
5620
LD A,(58F8H) 3A F8 58
Load Register A with the first character of the new name at 58F8H.
5623
CP 40H FE 40
Compare Register A against 40H, the character @ that starts the name of a device.
5625
If the Z FLAG is set (a device as the new name of a file), JUMP to 5793H to post error 2CH, Illegal filespec.
5628
CP 3AH FE 3A
Compare Register A against 3AH, the colon that starts the name of a drive.
562A
If the Z FLAG is set (a drive as the new name of a file), JUMP to 5793H to post error 2CH, Illegal filespec.
562D
LD DE,58D7H 11 D7 58
Point Register Pair DE to 58D7H, the file control block of the old name.
5630
GOSUB to 4424H, OPEN@, to open the file at Register Pair DE and check its password (Register Pair HL, left by FSPEC@ in the command line, is the buffer, which is not read): the NZ FLAG on an error.
5633
If the NZ FLAG is set (OPEN@ failed), JUMP to 57ADH to post the error in Register A.
5636
INC DE 13
INCrement Register Pair DE by 1, to FCB+01H at 58D8H, the file flags with the access level in bits 2-0.
5637
LD A,(DE) 1A
Load Register A with FCB+01H at Register Pair DE, the flags OPEN@ set.
5638
AND 07H E6 07
AND Register A with 07H, bits 2-0: the access level OPEN@ granted.
563A
CP 03H FE 03
Compare Register A against 03H: the NC FLAG for an access level of 3 or above, which does not allow a rename.
563C
If the NC FLAG is set (no rename access), JUMP to 579FH to post error 25H, Illegal access attempted to protected file.
563F
LD HL,58F8H 21 F8 58
Point Register Pair HL to 58F8H, the text of the new name.
5642
LD A,(HL) 7E
Load Register A with the character of the new name at Register Pair HL.
5643
CP 3AH FE 3A
Compare Register A against 3AH, the colon of a drive.
5645
If the Z FLAG is set (the new name has a drive), JUMP to 57A2H to post error 20H, Improper drive number.
5648
CP 03H FE 03
Compare Register A against 03H, the byte that ends the specification.
564A
If the Z FLAG is set (the end of the new name), JUMP to 564FH to add the old file's drive.
564C
INC HL 23
INCrement Register Pair HL by 1, to the next character of the new name.
564D
JUMP back to 5642H to look at the next character of the new name.
564F
LD (HL),3AH 36 3A
Store 3AH, the colon of a drive, at Register Pair HL in place of the 03H.
5651
INC HL 23
INCrement Register Pair HL by 1, to the place of the drive's name.
5652
LD A,(58DDH) 3A DD 58
Load Register A with the drive of the old file, FCB+06H at 58DDH.
5655
OR 08H F6 08
OR Register A with 08H, bit 3, the mark of a drive for 570AH.
5657
LD C,A 4F
Load Register C with Register A, the drive with bit 3 set.
5658
GOSUB to 570AH to point Index Register IY to the drive's entry in DCTTBL.
565B
LD A,(IY+02H) FD 7E 02
Load Register A with the first character of the drive's name, DCTTBL +02H at Index Register IY+02H.
565E
LD (HL),A 77
Store Register A, the first character of the drive's name, at Register Pair HL.
565F
INC HL 23
INCrement Register Pair HL by 1, to the next place of the new name.
5660
LD A,(IY+03H) FD 7E 03
Load Register A with the second character of the drive's name, DCTTBL +03H at Index Register IY+03H.
5663
CP 20H FE 20
Compare Register A against 20H, the space that ends a drive name of one character.
5665
If the Z FLAG is set (one character), JUMP to 5669H to end the specification.
5667
LD (HL),A 77
Store Register A, the second character of the drive's name, at Register Pair HL.
5668
INC HL 23
INCrement Register Pair HL by 1, to the next place of the new name.
5669
LD (HL),03H 36 03
Store 03H, the byte that ends a specification, at Register Pair HL.
566B
LD DE,58F8H 11 F8 58
Point Register Pair DE to 58F8H, the new name with the old file's drive.
566E
GOSUB to 4424H, OPEN@, to look for the new name at Register Pair DE on that drive: the Z FLAG when it is there.
5671
If the Z FLAG is set (the new name is there), JUMP to 57A8H to post error 31H, File already exists.
5674
CP 18H FE 18
Compare Register A against 18H, File not in directory, the only error that lets RENAME go on.
5676
If the NZ FLAG is set (another error), JUMP to 57ADH to post the error in Register A.
5679
LD BC,(58DDH) ED 4B DD 58
Load Register Pair BC with FCB+06H-07H of the old file from 58DDH-58DEH: Register C the drive, Register B the logical file number.
567D
GOSUB to 490CH to read the directory sector of the entry of logical file number Register B on drive Register C to 4200H: Register Pair HL = the entry.
5680
If the NZ FLAG is set (the read failed), JUMP to 57ADH to post the error in Register A.
5683
PUSH BC C5
Save Register Pair BC, the drive and the logical file number, to the top of the stack.
5684
LD D,H 54
Load Register D with Register H, the high byte of the entry's address.
5685
LD A,L 7D
Load Register A with Register L, the low byte of the entry's address.
5686
ADD A,05H C6 05
ADD 05H, the offset of the name in a directory entry, to Register A.
5688
LD E,A 5F
Load Register E with Register A: Register Pair DE = the name of the entry, entry+05H.
5689
GOSUB to 56BDH, SYS2/SYS's routine 8: Register Pair HL = 51E0H, the name and extension of the new name as OPEN@ left them.
568C
LD BC,000BH 01 0B 00
Load Register Pair BC with 000BH, the 11 characters of the name and the extension.
568F
LDIR ED B0
Copy the 11 characters from Register Pair HL (51E0H) to Register Pair DE, the entry's name, by LDIR. Register Pair BC counts down.
5691
POP BC C1
Restore Register Pair BC, the drive and the logical file number, from the top of the stack.
5692
GOSUB to 4915H to write the directory sector at 4200H back to drive Register C.
5695
If the NZ FLAG is set (the write failed), JUMP to 57ADH to post the error in Register A.
5698
LD HL,4200H 21 00 42
Point Register Pair HL to 4200H, the buffer for the hash index table.
569B
LD E,01H 1E 01
Load Register E with 01H, sector 1 of the directory cylinder, the hash index table.
569D
LD A,06H 3E 06
Load Register A with 06H, the DISKIO% function SREAD, which reads a sector of the directory cylinder.
569F
GOSUB to 4485H, DISKIO%, function 6 SREAD, to read the hash index table of drive Register C to 4200H.
56A2
If the NZ FLAG is set (the read failed), JUMP to 57ADH to post the error in Register A.
56A5
PUSH BC C5
Save Register Pair BC, the drive and the logical file number, to the top of the stack.
56A6
PUSH DE D5
Save Register Pair DE, the sector number in Register E, to the top of the stack.
56A7
PUSH HL E5
Save Register Pair HL, the buffer, to the top of the stack.
56A8
LD D,H 54
Load Register D with Register H, the high byte of the buffer.
56A9
LD E,B 58
Load Register E with Register B, the logical file number: Register Pair DE = the entry's byte in the hash index table.
56AA
GOSUB to 56BDH, SYS2/SYS's routine 8: Register Pair HL = 51E0H, the name and extension of the new name.
56AD
GOSUB to 56C0H, SYS2/SYS's routine 7: Register A = the hash code of the 11 characters at Register Pair HL.
56B0
LD (DE),A 12
Store Register A, the hash code of the new name, at Register Pair DE, the entry's byte in the hash index table.
56B1
POP HL E1
Restore Register Pair HL, the buffer, from the top of the stack.
56B2
POP DE D1
Restore Register Pair DE, the sector number in Register E, from the top of the stack.
56B3
POP BC C1
Restore Register Pair BC, the drive and the logical file number, from the top of the stack.
56B4
LD A,07H 3E 07
Load Register A with 07H, the DISKIO% function SWRITE, which writes a sector of the directory cylinder.
56B6
GOSUB to 4485H, DISKIO%, function 7 SWRITE, to write the hash index table at Register Pair HL back to sector Register E.
56B9
If the NZ FLAG is set (the write failed), JUMP to 57ADH to post the error in Register A.
56BC
RET C9
RETurn to the overlay request handler: RENAME of the file is done.

56BDH - Two Requests to SYS2/SYS

56BDH requests SYS2/SYS's routine 8 (18H), which returns Register Pair HL = 51E0H, its buffer of the name and extension; 56C0H requests routine 7 (17H), which returns in Register A the hash code of the 11 characters at Register Pair HL. The overlay request handler discards the address the RST 28H pushes, so each RETurns to the caller of 56BDH or 56C0H.

56BD
LD A,18H 3E 18
Load Register A with 18H, the request code of SYS2/SYS's routine 8, which returns the address of its name buffer.
56BF
RST 28H EF
Request the overlay routine in Register A through RST 28H, SYS0/SYS's overlay request handler, which RETurns to the caller of 56BDH.
56C0
LD A,17H 3E 17
Load Register A with 17H, the request code of SYS2/SYS's routine 7, the hash code of a name and extension.
56C2
RST 28H EF
Request the overlay routine in Register A through RST 28H, SYS0/SYS's overlay request handler, which RETurns to the caller of 56C0H.

56C3H - RENAME a Device or a Drive

Both names must be of one kind, @ or colon (else error 2BH). LOCDEV@ must find the old name (its error is posted) and must not find the new one (error 32H). The two characters of the new name (the second a space when there is one) may not be wildcards (error 2BH); they are stored as the name of the device's entry in the DCB table (+09H-+0AH) or of the drive's entry in DCTTBL (+02H-+03H). A third character of the new name is not looked at.

56C3
LD A,(58F8H) 3A F8 58
Load Register A with the first character of the new name at 58F8H.
56C6
SUB B 90
SUBtract Register B, the first character of the old name, from Register A: the Z FLAG when both are @ or both are colons.
56C7
If the NZ FLAG is set (a device and a drive), JUMP to 57A5H to post error 2BH, Illegal devicespec.
56CA
LD DE,58D7H 11 D7 58
Point Register Pair DE to 58D7H, the old name.
56CD
GOSUB to 447FH, LOCDEV@, to look up the device or drive named at Register Pair DE: Register A = its number (08H plus the drive for a drive), the NZ FLAG when it is not found.
56D0
If the NZ FLAG is set (not found), JUMP to 57ADH to post the error in Register A.
56D3
LD C,A 4F
Load Register C with Register A, the number of the device or drive.
56D4
GOSUB to 570AH to point Index Register IY to its entry in the DCB table or in DCTTBL.
56D7
LD DE,58F8H 11 F8 58
Point Register Pair DE to 58F8H, the new name.
56DA
GOSUB to 447FH, LOCDEV@, to look up the new name at Register Pair DE: the Z FLAG when it is already a name.
56DD
If the Z FLAG is set (the name is taken), JUMP to 57ABH to post error 32H, Device already exists.
56E0
LD A,(58F9H) 3A F9 58
Load Register A with the first character of the new name after its @ or colon, from 58F9H.
56E3
GOSUB to 572AH to test the character in Register A: the Z FLAG for a wildcard.
56E6
If the Z FLAG is set (a wildcard), JUMP to 579CH to post error 2BH, Illegal devicespec.
56E9
LD L,A 6F
Load Register L with Register A, the first character of the new name.
56EA
LD A,(58FAH) 3A FA 58
Load Register A with the second character of the new name from 58FAH.
56ED
CP 03H FE 03
Compare Register A against 03H, the end of the specification: a name of one character.
56EF
If the NZ FLAG is set (a second character), JUMP to 56F3H to test it.
56F1
LD A,20H 3E 20
Load Register A with 20H, the space that is the second character of a name of one character.
56F3
GOSUB to 572AH to test the character in Register A: the Z FLAG for a wildcard.
56F6
If the Z FLAG is set (a wildcard), JUMP to 579CH to post error 2BH, Illegal devicespec.
56F9
LD H,A 67
Load Register H with Register A, the second character of the new name.
56FA
LD DE,0007H 11 07 00
Load Register Pair DE with 0007H, from +02H of an entry to +09H, the name in an entry of the DCB table.
56FD
BIT 3,C CB 59
Test bit 3 of Register C, the number LOCDEV@ returned: set for a drive.
56FF
If the NZ FLAG is set (a drive), JUMP to 5703H: the name of a DCTTBL entry is at +02H.
5701
ADD IY,DE FD 19
ADD Register Pair DE to Index Register IY: Index Register IY = the DCB table entry + 07H, so that IY+02H is its name at +09H.
5703
LD (IY+02H),L FD 75 02
Store Register L, the first character, into the name of the entry at Index Register IY+02H.
5706
LD (IY+03H),H FD 74 03
Store Register H, the second character, into the name of the entry at Index Register IY+03H.
5709
RET C9
RETurn to the overlay request handler: RENAME of the device or drive is done.

570AH - A Device's or a Drive's Table Entry

Register C: bit 3 set for a drive (bits 0-2 the drive), clear for a device (0-5). Index Register IY returns the entry: DCTTBL 43ABH plus 4 times the drive, or the DCB table 4369H plus 11 times the device. Register Pairs DE and HL are kept.

570A
PUSH DE D5
Save Register Pair DE to the top of the stack, to keep it over the routine.
570B
PUSH HL E5
Save Register Pair HL to the top of the stack, to keep it over the routine.
570C
LD A,C 79
Load Register A with Register C, the device or the drive with bit 3.
570D
LD E,0BH 1E 0B
Load Register E with 0BH, the 11 bytes of an entry in the DCB table.
570F
LD IY,4369H FD 21 69 43
Point Index Register IY to 4369H, the DCB table of the devices.
5713
BIT 3,A CB 5F
Test bit 3 of Register A, the number in Register C: set for a drive.
5715
If the Z FLAG is set (a device), JUMP to 571DH with the DCB table.
5717
LD E,04H 1E 04
Load Register E with 04H, the 4 bytes of an entry in DCTTBL.
5719
LD IY,43ABH FD 21 AB 43
Point Index Register IY to 43ABH, DCTTBL, the table of the drives.
571D
AND 07H E6 07
AND Register A with 07H, bits 0-2: the number of the device or the drive.
571F
GOSUB to 4934H to multiply Register A by Register E: Register A = the offset of the entry in the table.
5722
LD E,A 5F
Load Register E with Register A, the low byte of the offset.
5723
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the offset of the entry.
5725
ADD IY,DE FD 19
ADD Register Pair DE to Index Register IY: Index Register IY = the entry of the device or the drive.
5727
POP HL E1
Restore Register Pair HL from the top of the stack.
5728
POP DE D1
Restore Register Pair DE from the top of the stack.
5729
RET C9
RETurn to the caller with Index Register IY at the entry.

572AH - A Wildcard

Returns the Z FLAG when the character in Register A is a question mark (3FH), an asterisk (2AH) or an exclamation mark (21H), the wildcards of a wildmask.

572A
CP 3FH FE 3F
Compare Register A against 3FH, the question mark of a wildmask: the Z FLAG when it is one.
572C
RET Z C8
If the Z FLAG is set (a question mark), RETurn to the caller with the Z FLAG.
572D
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk of a wildmask: the Z FLAG when it is one.
572F
RET Z C8
If the Z FLAG is set (an asterisk), RETurn to the caller with the Z FLAG.
5730
CP 21H FE 21
Compare Register A against 21H, the exclamation mark of a wildmask: the Z FLAG when it is one.
5732
RET C9
RETurn to the caller with the Z FLAG for a wildcard, the NZ FLAG for any other character.

5733H - Compare Two Addresses

Sets the flags from Register Pair HL less Register Pair DE (the Z FLAG when they are equal, the C FLAG when Register Pair HL is lower) and keeps Register Pair HL.

5733
PUSH HL E5
Save Register Pair HL to the top of the stack, to keep it over the SBC.
5734
OR A B7
OR Register A with itself to clear the C FLAG for the SBC below.
5735
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: the Z FLAG when equal, the C FLAG when Register Pair HL is lower.
5737
POP HL E1
Restore Register Pair HL from the top of the stack (POP does not change the flags).
5738
RET C9
RETurn to the caller with the flags of the comparison.

5739H - Put a Byte

Puts the byte in Register A to the control block at Register Pair DE through the ROM's 001BH. For a file (type 80H) the flags of 001BH are returned, for a device the Z FLAG. DUMP's 54C5H, the only caller, does not test them.

5739
GOSUB to 001BH, the ROM's routine that puts the byte in Register A to the file or device at Register Pair DE.
573C
PUSH AF F5
Save Register Pair AF, the byte and the flags of 001BH, to the top of the stack.
573D
LD A,(DE) 1A
Load Register A with the type byte of the control block at Register Pair DE.
573E
CP 80H FE 80
Compare Register A against 80H, the type byte of an open file.
5740
If the Z FLAG is set (a file), JUMP to 5745H to return the flags of 001BH.
5742
POP AF F1
Restore Register Pair AF, the byte and the flags of 001BH, from the top of the stack.
5743
CP A BF
Compare Register A against itself to set the Z FLAG: for a device no error is returned.
5744
RET C9
RETurn to the caller with the Z FLAG, whatever 001BH returned for the device.
5745
POP AF F1
Restore Register Pair AF, the byte and the flags of 001BH, from the top of the stack.
5746
RET C9
RETurn to the caller with the flags of 001BH for the file.

5747H - Take and Open the Field

5747H calls EVAL@ (Register Pair BC kept); 574FH checks the field it took. No field is error 2FH. A name (bit 6 of the flag byte) is opened by INIT@ with the buffer 5919H and the record length 256, after FEXT@ has added the default extension number Register C (1 TXT, 2 CIM, 3 CMD; 0 none). A drive (bit 3) is error 2BH. Any other field is a device, whose control block address LOCDCB% returns. Register Pair DE returns the file control block or the device control block.

5747
PUSH BC C5
Save Register Pair BC, the number of the default extension in Register C, to the top of the stack.
5748
GOSUB to 4479H, EVAL@, to take the fields and parameters from the command line at Register Pair HL: the NZ FLAG on an error.
574B
POP BC C1
Restore Register Pair BC, the number of the default extension, from the top of the stack.
574C
If the NZ FLAG is set (EVAL@ failed), JUMP to 57ADH to post the error in Register A.
574F
LD A,07H 3E 07
Load Register A with 07H, the mask of bits 0-2 of the evaluation block's flags, the fields given.
5751
AND (IX+00H) DD A6 00
AND Register A with the flags of the evaluation block at Index Register IX+00H: the Z FLAG when no field was given.
5754
If the Z FLAG is set (no field), JUMP to 5796H to post error 2FH, I/o field not found.
5757
LD DE,58D7H 11 D7 58
Point Register Pair DE to 58D7H, the field block of EVAL@: its flag byte, then the file control block.
575A
LD A,(DE) 1A
Load Register A with the flag byte of the field at Register Pair DE (58D7H).
575B
BIT 6,A CB 77
Test bit 6 of Register A, the flag byte: set when the field has a name.
575D
If the NZ FLAG is set (a name), JUMP to 576AH to open the file.
575F
BIT 3,A CB 5F
Test bit 3 of Register A, the flag byte: set when the field is a drive.
5761
If the NZ FLAG is set (a drive), JUMP to 579CH to post error 2BH, Illegal devicespec.
5763
LD A,(DE) 1A
Load Register A with the flag byte of the field at Register Pair DE.
5764
AND 07H E6 07
AND Register A with 07H, bits 0-2: the number of the device.
5766
GOSUB to 4488H, LOCDCB%: Register Pair DE returns the address of the device control block of device Register A.
5769
RET C9
RETurn to the caller with Register Pair DE at the device's control block.
576A
LD A,C 79
Load Register A with Register C, the number of the default extension.
576B
OR A B7
OR Register A with itself: the Z FLAG when no extension is to be added.
576C
INC DE 13
INCrement Register Pair DE by 1, to the file control block at 58D8H (INC does not change the flags).
576D
If the Z FLAG is set (no default extension), JUMP to 577CH to open the file.
576F
LD HL,5872H 21 72 58
Point Register Pair HL to 5872H, three bytes before the list of default extensions at 5875H.
5772
LD BC,0003H 01 03 00
Load Register Pair BC with 0003H, the 3 characters of an extension.
5775
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL, to the next extension of the list.
5776
DEC A 3D
DECrement Register A by 1, the count of the extensions still to pass.
5777
If the NZ FLAG is set, JUMP back to 5775H until Register Pair HL is at the extension numbered Register C.
5779
GOSUB to 4473H, FEXT@, to add the extension at Register Pair HL to the specification at Register Pair DE when it has none.
577C
LD B,00H 06 00
Load Register B with 00H, the record length 256 for INIT@.
577E
LD HL,5919H 21 19 59
Point Register Pair HL to 5919H, the buffer of the file's sectors.
5781
GOSUB to 4420H, INIT@, to open the file at Register Pair DE with the buffer at Register Pair HL and the record length in Register B, creating it when needed: the NZ FLAG on an error.
5784
If the NZ FLAG is set (INIT@ failed), JUMP to 57ADH to post the error in Register A.
5787
RET C9
RETurn to the caller with Register Pair DE at the file control block.

5788H - Close the Output

Used by BUILD and DUMP: a file (type byte 80H at Register Pair DE) is closed by CLOSE@, a device is left as it is. The command then RETurns to the overlay request handler; an error of CLOSE@ is posted.

5788
LD A,(DE) 1A
Load Register A with the type byte of the control block at Register Pair DE.
5789
CP 80H FE 80
Compare Register A against 80H, the type byte of an open file: the NZ FLAG for a device.
578B
RET NZ C0
If the NZ FLAG is set (a device), RETurn: a device is not closed.
578C
GOSUB to 4428H, CLOSE@, to close the file at Register Pair DE: the NZ FLAG on an error.
578F
RET Z C8
If the Z FLAG is set (closed), RETurn to the overlay request handler: the command is done.
5790
JUMP to 57ADH to post the error of CLOSE@ in Register A.

5793H - The Error Exits

Nine entries, each loading its error code into Register A: 5793H 2CH Illegal filespec, 5796H 2FH I/o field not found, 5799H 2DH Invalid data provided, 579CH 2BH Illegal devicespec, 579FH 25H Illegal access attempted to protected file, 57A2H 20H Improper drive number, 57A5H 2BH again, 57A8H 31H File already exists, 57ABH 32H Device already exists. Each LD A,n after the first is the operand of an LD BC,nn entered from the entry above it. 57ADH posts the error in Register A by ERROR@ with bit 6 set (no frame), and ERROR@ ends with ABORT@.

5793
LD A,2CH 3E 2C
Load Register A with 2CH, the error code Illegal filespec.
5795
LD BC,2F3EH 01 3E 2F
5796H enters inside this LD BC,2F3EH: its bytes 3EH 2FH read as LD A,2FH, the error code I/o field not found; from above it only loads Register Pair BC.
5798
LD BC,2D3EH 01 3E 2D
5799H enters inside this LD BC,2D3EH: its bytes 3EH 2DH read as LD A,2DH, the error code Invalid data provided; from above it only loads Register Pair BC.
579B
LD BC,2B3EH 01 3E 2B
579CH enters inside this LD BC,2B3EH: its bytes 3EH 2BH read as LD A,2BH, the error code Illegal devicespec; from above it only loads Register Pair BC.
579E
LD BC,253EH 01 3E 25
579FH enters inside this LD BC,253EH: its bytes 3EH 25H read as LD A,25H, the error code Illegal access attempted to protected file; from above it only loads Register Pair BC.
57A1
LD BC,203EH 01 3E 20
57A2H enters inside this LD BC,203EH: its bytes 3EH 20H read as LD A,20H, the error code Improper drive number; from above it only loads Register Pair BC.
57A4
LD BC,2B3EH 01 3E 2B
57A5H enters inside this LD BC,2B3EH: its bytes 3EH 2BH read as LD A,2BH, the error code Illegal devicespec; from above it only loads Register Pair BC.
57A7
LD BC,313EH 01 3E 31
57A8H enters inside this LD BC,313EH: its bytes 3EH 31H read as LD A,31H, the error code File already exists; from above it only loads Register Pair BC.
57AA
LD BC,323EH 01 3E 32
57ABH enters inside this LD BC,323EH: its bytes 3EH 32H read as LD A,32H, the error code Device already exists; from above it only loads Register Pair BC.
57AD
OR 40H F6 40
OR Register A, the error code, with 40H, bit 6, so that ERROR@ shows the message without its frame.
57AF
JUMP to 4409H, ERROR@, to show the message of the error in Register A and end through ABORT@.

57B2H - Request an Overlay Routine

LOAD calls 57B2H with a request code in Register A (5518H, 5540H). The overlay request handler discards the address the RST 28H pushes, so the routine RETurns to the caller of 57B2H.

57B2
RST 28H EF
Request the overlay routine in Register A through RST 28H, SYS0/SYS's overlay request handler, which RETurns to the caller of 57B2H.

57B3H - The Evaluation Block

Data: the block that Index Register IX points to for EVAL@ (5217H, 5277H, 5340H, 5429H, 54F7H): EVAL@'s flags, the addresses of the source, destination and wildmask blocks, all the one field block 58D7H, and the address of the parameter table, which each command stores before it calls EVAL@. Each table entry is the name (6 characters), the address its value is stored to and a type byte (20H a switch, 40H a number); a 00H ends the table.

57B3
DEFB 00H 00
The flags of the evaluation block, set by EVAL@: bits 0-2 the source, destination and wildmask fields.
57B4-57B5
DEFW 58D7H D7 58
The address of the source block, 58D7H: the flag byte, then the file control block.
57B6-57B7
DEFW 58D7H D7 58
The address of the destination block: 58D7H again, so any field goes to the one block.
57B8-57B9
DEFW 58D7H D7 58
The address of the wildmask block: 58D7H again, so any field goes to the one block.
57BA-57BB
DEFW 0000H 00 00
The address of the parameter table, stored by each command: 57BCH BUILD, 57C6H CLEAR, 57E2H CREATE, 5822H DUMP, 5850H LOAD.

57BCH - BUILD's Parameter Table

Data: the one parameter of BUILD, APPEND, and the 00H that ends the table.

57BC-57C1
DEFM "APPEND" 41 50 50 45 4E 44
The name APPEND: show the file first and add the new lines after it (A is its abbreviation).
57C2-57C3
DEFW 5228H 28 52
APPEND's value goes to 5228H-5229H, the operand of LD BC,0000H at 5227H.
57C4
DEFB 20H 20
The type byte of APPEND: 20H, bit 5, a switch, so the name alone sets it.
57C5
DEFB 00H 00
The end of BUILD's parameter table: a 00H in place of the next name.

57C6H - CLEAR's Parameter Table

Data: START, END and DATA, each a number, and the 00H that ends the table.

57C6-57CB
DEFM "START " 53 54 41 52 54 20
The name START: the first address of the memory to fill (S is its abbreviation).
57CC-57CD
DEFW 52EDH ED 52
START's value goes to 52EDH-52EEH, the operand of LD HL,0000H at 52ECH.
57CE
DEFB 40H 40
The type byte of START: 40H, bit 6, a number, the first address to fill.
57CF-57D4
DEFM "END " 45 4E 44 20 20 20
The name END: the last address of the memory to fill (E is its abbreviation).
57D5-57D6
DEFW 52FAH FA 52
END's value goes to 52FAH-52FBH, the operand of LD DE,0000H at 52F9H.
57D7
DEFB 40H 40
The type byte of END: 40H, bit 6, a number, the last address to fill.
57D8-57DD
DEFM "DATA " 44 41 54 41 20 20
The name DATA: the one or two byte value to fill with (D is its abbreviation).
57DE-57DF
DEFW 52A9H A9 52
DATA's value goes to 52A9H-52AAH, the operand of LD DE,0000H at 52A8H.
57E0
DEFB 40H 40
The type byte of DATA: 40H, bit 6, a number, the value to fill with.
57E1
DEFB 00H 00
The end of CLEAR's parameter table: a 00H in place of the next name.

57E2H - CREATE's Parameter Table

Data: DATA, GRANS, KEEP, KILO, LRL, SIZE and VERIFY, and the 00H that ends the table. An abbreviation picks the first entry that starts with it, so G is GRANS, K is KEEP and KI is KILO.

57E2-57E7
DEFM "DATA " 44 41 54 41 20 20
The name DATA: the one or two byte value to fill the new file with.
57E8-57E9
DEFW 52A9H A9 52
DATA's value goes to 52A9H-52AAH, the operand of LD DE,0000H at 52A8H.
57EA
DEFB 40H 40
The type byte of DATA: 40H, bit 6, a number, the value to fill with.
57EB-57F0
DEFM "GRANS " 47 52 41 4E 53 20
The name GRANS: the space of the file in granules.
57F1-57F2
DEFW 53EAH EA 53
GRANS's value goes to 53EAH-53EBH, the operand of LD BC,0000H at 53E9H.
57F3
DEFB 40H 40
The type byte of GRANS: 40H, bit 6, a number, the count of granules.
57F4-57F9
DEFM "KEEP " 4B 45 45 50 20 20
The name KEEP: make the new file non-shrinkable.
57FA-57FB
DEFW 53C8H C8 53
KEEP's value goes to 53C8H-53C9H, the operand of LD BC,0000H at 53C7H.
57FC
DEFB 20H 20
The type byte of KEEP: 20H, bit 5, a switch, so the name alone sets it.
57FD-5802
DEFM "KILO " 4B 49 4C 4F 20 20
The name KILO: the space of the file in kilobytes of four sectors.
5803-5804
DEFW 53F4H F4 53
KILO's value goes to 53F4H-53F5H, the operand of LD BC,0000H at 53F3H.
5805
DEFB 40H 40
The type byte of KILO: 40H, bit 6, a number, the count of kilobytes.
5806-580B
DEFM "LRL " 4C 52 4C 20 20 20
The name LRL: the logical record length of the new file (0 or 256 for a sector).
580C-580D
DEFW 536AH 6A 53
LRL's value goes to 536AH-536BH, the operand of LD BC,0000H at 5369H.
580E
DEFB 40H 40
The type byte of LRL: 40H, bit 6, a number, the record length.
580F-5814
DEFM "SIZE " 53 49 5A 45 20 20
The name SIZE: the space of the file in records of its length.
5815-5816
DEFW 53DBH DB 53
SIZE's value goes to 53DBH-53DCH, the operand of LD BC,0000H at 53DAH.
5817
DEFB 40H 40
The type byte of SIZE: 40H, bit 6, a number, the count of records.
5818-581D
DEFM "VERIFY" 56 45 52 49 46 59
The name VERIFY: read the new file to its end after it is made.
581E-581F
DEFW 53B4H B4 53
VERIFY's value goes to 53B4H-53B5H, the operand of LD HL,0000H at 53B3H.
5820
DEFB 20H 20
The type byte of VERIFY: 20H, bit 5, a switch, so the name alone sets it.
5821
DEFB 00H 00
The end of CREATE's parameter table: a 00H in place of the next name.

5822H - DUMP's Parameter Table

Data: DATA, END, RELO, START and TRA, and the 00H that ends the table. The values go into DUMP's own words 54D3H-54DCH.

5822-5827
DEFM "DATA " 44 41 54 41 20 20
The name DATA: write the memory as data, without load blocks (D is its abbreviation).
5828-5829
DEFW 54DBH DB 54
DATA's value goes to 54DBH-54DCH, DUMP's word for the switch.
582A
DEFB 20H 20
The type byte of DATA: 20H, bit 5, a switch, so the name alone sets it.
582B-5830
DEFM "END " 45 4E 44 20 20 20
The name END: the last address of the memory to write (E is its abbreviation).
5831-5832
DEFW 54D7H D7 54
END's value goes to 54D7H-54D8H, DUMP's word for the last address.
5833
DEFB 40H 40
The type byte of END: 40H, bit 6, a number, the last address to write.
5834-5839
DEFM "RELO " 52 45 4C 4F 20 20
The name RELO: the address the file loads back to (R is its abbreviation).
583A-583B
DEFW 54D9H D9 54
RELO's value goes to 54D9H-54DAH, DUMP's word for the relocation.
583C
DEFB 40H 40
The type byte of RELO: 40H, bit 6, a number, the load address.
583D-5842
DEFM "START " 53 54 41 52 54 20
The name START: the first address of the memory to write (S is its abbreviation).
5843-5844
DEFW 54D5H D5 54
START's value goes to 54D5H-54D6H, DUMP's word for the next address.
5845
DEFB 40H 40
The type byte of START: 40H, bit 6, a number, the first address to write.
5846-584B
DEFM "TRA " 54 52 41 20 20 20
The name TRA: the transfer address of the load module (T is its abbreviation).
584C-584D
DEFW 54D3H D3 54
TRA's value goes to 54D3H-54D4H, the address in DUMP's transfer record.
584E
DEFB 40H 40
The type byte of TRA: 40H, bit 6, a number, the transfer address.
584F
DEFB 00H 00
The end of DUMP's parameter table: a 00H in place of the next name.

5850H - LOAD's Parameter Table

Data: PROMPT, RUN, START and TRA, and the 00H that ends the table.

5850-5855
DEFM "PROMPT" 50 52 4F 4D 50 54
The name PROMPT: ask for the target and system diskettes (P is its abbreviation).
5856-5857
DEFW 551CH 1C 55
PROMPT's value goes to 551CH-551DH, the operand of LD HL,0000H at 551BH.
5858
DEFB 20H 20
The type byte of PROMPT: 20H, bit 5, a switch, so the name alone sets it.
5859-585E
DEFM "RUN " 52 55 4E 20 20 20
The name RUN: run the program after it is loaded (R is its abbreviation).
585F-5860
DEFW 55FEH FE 55
RUN's value goes to 55FEH-55FFH, the word after the keyboard scan.
5861
DEFB 20H 20
The type byte of RUN: 20H, bit 5, a switch, so the name alone sets it.
5862-5867
DEFM "START " 53 54 41 52 54 20
The name START: load the file as a core image from this address (S is its abbreviation).
5868-5869
DEFW 55A8H A8 55
START's value goes to 55A8H-55A9H, the operand of LD HL,0000H at 55A7H.
586A
DEFB 40H 40
The type byte of START: 40H, bit 6, a number, the load address.
586B-5870
DEFM "TRA " 54 52 41 20 20 20
The name TRA: the address to run the program at (T is its abbreviation).
5871-5872
DEFW 5597H 97 55
TRA's value goes to 5597H-5598H, the operand of LD DE,0000H at 5596H.
5873
DEFB 40H 40
The type byte of TRA: 40H, bit 6, a number, the address to run.
5874
DEFB 00H 00
The end of LOAD's parameter table: a 00H in place of the next name.

5875H - The Default Extensions

Data: the three extensions 576FH-5779H picks by number for FEXT@: 1 TXT (BUILD), 2 CIM (DUMP with DATA), 3 CMD (DUMP).

5875-5877
DEFM "TXT" 54 58 54
Default extension 1, TXT, which BUILD gives a file name without an extension.
5878-587A
DEFM "CIM" 43 49 4D
Default extension 2, CIM, which DUMP gives a file name without an extension when DATA is given.
587B-587D
DEFM "CMD" 43 4D 44
Default extension 3, CMD, which DUMP gives a file name without an extension.

587EH - The Texts

Data: BUILD's prompt and LOAD's two prompts, each ended by a carriage return for DSPLY@.

587E-5897
DEFM "Enter text (63 chars/line)" 45 6E 74 65 72 20 74 65 78 74 20 28 36 33 20 63 68 61 72 73 2F 6C 69 6E 65 29
BUILD's prompt, shown by DSPLY@ at 5247H before the first line is typed.
5898
DEFB 0DH 0D
The carriage return that ends BUILD's prompt for DSPLY@ and starts a new line.
5899-58B6
DEFM "Insert TARGET diskette (ENTER)" 49 6E 73 65 72 74 20 54 41 52 47 45 54 20 64 69 73 6B 65 74 74 65 20 28 45 4E 54 45 52 29
LOAD's prompt for the diskette with the file (5520H, 5547H), shown by 55D2H.
58B7
DEFB 0DH 0D
The carriage return that ends the prompt for the target diskette for DSPLY@.
58B8-58D5
DEFM "Insert SYSTEM diskette (ENTER)" 49 6E 73 65 72 74 20 53 59 53 54 45 4D 20 64 69 73 6B 65 74 74 65 20 28 45 4E 54 45 52 29
LOAD's prompt for the system diskette (5536H, 557DH, 55C8H), shown by 55D2H.
58D6
DEFB 0DH 0D
The carriage return that ends the prompt for the system diskette, the last byte of the file.

58D7H - The Work Area

Not in the file: SYS15/SYS uses the memory after its last byte (58D6H) for the field block of EVAL@ and RENAME's two file control blocks, the buffer of a file's sectors and BUILD's line buffer.

58D7-58F7
DEFS 33
The field block of EVAL@: 58D7H the flag byte, 58D8H the file control block of INIT@ or OPEN@. RENAME uses 58D7H itself as the file control block of the old name.
58F8-5918
DEFS 33
RENAME's file control block of the new name (58F8H; 58F9H-58FAH the name of a device or drive).
5919-5A18
DEFS 256
The buffer of the file's sectors, which CLEAR and CREATE fill with DATA (52A2H).
5A19-5A58
DEFS 64
BUILD's line buffer: up to 63 characters from the ROM's 0040H and the carriage return.