DOSPLUS 3.5 for the Model III - TAPE/CMD Disassembled

Page Customization

Introduction/Summary

DOSPLUS 3.5 TAPE/CMD Disassembly - The Disk and Tape Manager (Model III)

TAPE/CMD moves machine language programs between system tapes and disk load modules, and can move them in memory on the way, run from the DOS command level as TAPE; its heading reads TAPE - DOSPLUS Disk/tape manager - 3.50. It is a load module of 7 blocks, 1728 bytes, at 5200H-58BFH with the transfer address 5200H, after the two comment records (the name TAPE and the copyright notice). TAPE/CMD is on the Model III master only.

TAPE keeps what it reads in a store from 5B42H up to 300 bytes below HMEM$: each block as the mark 01H, its address, the count of its bytes (00H for 256) and the bytes, and the end of each program as the mark 02H; up to ten programs, with their names in a table at 5948H. One transfer address is kept, that of the last program read, and one offset, which is added to every address when the programs are written. TAPE uses the ROM's cassette routines (0296H, 0235H, 0287H, 0264H, 01F8H) and its own stack at 41E5H.

The Parts of TAPE/CMD

AddressContents
5200H-526DHThe start, the command loop and the table of commands (5200H, 5212H).
526EH-52BCHB, H and I (526EH).
52BDH-5345HL, a disk load module (52BDH).
5346H-542CHM, the map (5346H, 53FEH).
542DH-54D0HO, Q and R, a system tape (542DH).
54D1H-560DHS, a disk load module, and W, a system tape (54D1H, 5572H).
560EH-57B8HRoom, a name, the loader of -A, the keys and output, the errors (560EH, 5638H, 56ECH, 577AH).
57B9H-58BFHThe two loaders, the texts and the messages (57B9H, 57F1H).

How TAPE Works

Each command is a letter after the asterisk; the line is up to 62 characters, and the stack is set again for each command (5212H). L name opens a disk file and keeps its 01H records; R name looks on the tape for the header 55H with the six character name and keeps its 3CH blocks, each checked against its checksum, up to the 78H record (52BDH, 543EH). Both take the transfer address of the program read. I empties the store; B H or B L sets the cassette speed (1500 or 500 baud); O nnnn sets the offset; Q returns to the DOS. M lists each program: its name, then each run of blocks that follow on in memory as start-end, and again with the offset added; then XFER= and OFFSET= (5346H).

S name writes every program in the store to one disk load module, W name to one system tape: each block at its address plus the offset, and at the end the transfer address plus the offset (54D1H, 5572H). With -A and an offset set, a 23 byte loader is added as one more block (5638H): it is placed just below the lowest block (for an offset below 0000H) or just after the highest, both with the offset, and it becomes the transfer address. When it runs it turns the interrupts off, makes RST 38H a RET, sets the I/O drivers back to the ROM's by 0069H, moves the program to the addresses it was read from (LDDR or LDIR, whichever is safe) and jumps to its transfer address (57B9H).

Differences from the Manual

The manual says M-P sends the map to the screen and the printer; the bytes send it to the printer only (56FBH). H shows only the ten command letters. -A adds nothing when the offset is 0000H, so a program that must load below the DOS needs an offset as well. B takes only upper case H or L. Only the last program's transfer address is kept, and S and W write all the programs in memory as one file with that one address. Neither L nor S tests the reads and writes of each byte, and L does not close the file.

R compares the tape's name with the name typed through Register Pair HL, which is not set back after a header with another name (546EH): when the wanted program is not the first on the tape, its name is compared with the wrong characters of the entry, and the search goes past it.

Variables

TAPE/CMD Variables

Address
Size
Contents
58C0H
1 byte
Printer flag
00H the display, FFH the printer (5362H).
58C1H
1 byte
Programs
The count in memory (5344H).
58C2H-58C3H
2 bytes
Transfer
Of the last program read (533DH).
58C4H-58C5H
2 bytes
Offset
(5430H).
58C6H
1 byte
To write
Programs to write (54D4H).
58C7H-58C8H
2 bytes
Store end
(52B9H).
58C9H-58CCH
4 bytes
Limits
The highest end and lowest start, for -A (5640H).
58CDH-58CEH
2 bytes
Transfer to write
(54DBH, 56B1H).
58CFH-58E7H
25 bytes
Name
For S or W (54E1H).
58E8H-5907H
32 bytes
FCB
For L and S (52DEH).
5908H-5947H
64 bytes
Line
(5220H).
5948H-5A41H
250 bytes
Names
Ten entries of 25 bytes (52CEH).
5A42H-5B41H
256 bytes
Disk buffer
(52E9H).
5B42H
upwards
Store
The programs (52B6H).

Memory Outside TAPE/CMD

Address
Size
Contents
4204H-4205H
2 bytes
BREAK vector
The ROM's cassette BREAK vector, set to 57B3H (5206H).
4211H
1 byte
Cassette speed
The ROM's baud rate selector (5282H).

Outside Routines

AddressContents
441CHSYS0/SYS: FSPEC@ (52E1H).
4424HSYS0/SYS: OPEN@ (52ECH).
4420HSYS0/SYS: INIT@ (550DH).
4428HSYS0/SYS: CLOSE@ (556BH).
4409HSYS0/SYS: ERROR@ (57ADH).
402DHSYS0/SYS: EXIT@ (543BH).
0013HROM: input a byte from a control block (52FBH).
001BHROM: output a byte to a control block (5526H).
002BHROM: scan the keyboard (56EDH).
0033HROM: display a character (5703H).
003BHROM: print a character (5707H).
0040HROM: line input (5223H).
0069HROM: set the I/O drivers back, called by the loader (57C3H).
0235HROM: read a byte from the cassette (5463H).
0264HROM: write a byte to the cassette (55A2H).
0287HROM: cassette on, leader and sync written (559DH).
0296HROM: cassette on, leader and sync found (545EH).
01F8HROM: cassette motor off (54ABH, 57B3H).

Disassembly

5200H - TAPE

TAPE/CMD's transfer address, entered from the DOS command level (TAPE takes no parameters). TAPE keeps up to ten programs in memory, read from disk load modules (L) or system tapes (R), lists them (M), sets an offset (O) that moves every block when it is written, and writes them as one disk load module (S) or system tape (W), with -A a small loader that moves the program back to its own addresses and starts it. Each command is one letter after the asterisk prompt; the stack is set again at 5212H for every command, and every error comes back there.

5200
LD SP,41E5H 31 E5 41
Load the Stack Pointer with 41E5H, TAPE's own stack below the DOS's 41E5H area.
5203
LD HL,57B3H 21 B3 57
Point Register Pair HL to 57B3H, the routine that turns the cassette motor off and restarts the command loop.
5206
LD (4204H),HL 22 04 42
Store Register Pair HL (57B3H) into 4204H-4205H, the ROM's cassette BREAK vector, so BREAK during cassette input or output comes back to TAPE.
5209
GOSUB to 52ACH, the start of the I command, to clear the variables and empty the store of programs.
520C
LD HL,57F1H 21 F1 57
Point Register Pair HL to 57F1H, TAPE's heading (TAPE - DOSPLUS Disk/tape manager - 3.50) and the copyright line.
520F
GOSUB to 570DH to send the text at Register Pair HL up to its 00H to the display.

5212H - The Command Loop

The stack is set again and the printer flag cleared; an asterisk, a line of up to 62 characters (BREAK asks again), and the first letter of the line, made upper case, is looked up in the table at 5250H. The command's routine is entered by RET with Register Pair HL after the letter and 5212H as its return address; a letter not in the table is Invalid command.

5212
LD SP,41E5H 31 E5 41
Load the Stack Pointer with 41E5H, so each command starts with an empty stack.
5215
XOR A AF
Set Register A to 00H (XOR A), the printer flag's value for output to the display.
5216
LD (58C0H),A 32 C0 58
Store Register A (00H) into 58C0H, the printer flag: 56FBH sends to the display.
5219
LD A,2AH 3E 2A
Load Register A with 2AH, the asterisk shown as TAPE's prompt.
521B
GOSUB to 56FBH to send the asterisk in Register A to the display.
521E
LD B,3EH 06 3E
Load Register B with 3EH, the most characters of a command line: 62.
5220
LD HL,5908H 21 08 59
Point Register Pair HL to 5908H, the buffer of the command line.
5223
GOSUB to 0040H, the ROM's line input of up to Register B characters into the buffer at Register Pair HL; the C FLAG for BREAK.
5226
If the C FLAG is set (BREAK), JUMP to 5219H for the prompt again.
5228
LD B,0AH 06 0A
Load Register B with 0AH, the ten commands of the table.
522A
LD IX,5250H DD 21 50 52
Point Index Register IX to 5250H, the table of the commands: a letter and the address of its routine.
522E
GOSUB to 571AH for the first character of the line after any spaces; the C FLAG for the end of the line.
5231
If the C FLAG is set (an empty line), JUMP to 5219H for the prompt again.
5233
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
5235
CP (IX+00H) DD BE 00
Compare Register A against the letter of the table's entry at Index Register IX+00H.
5238
If the Z FLAG is set (the command), JUMP to 5244H to run it.
523A
LD DE,0003H 11 03 00
Load Register Pair DE with 0003H, the three bytes of an entry of the table.
523D
ADD IX,DE DD 19
ADD Register Pair DE (0003H) to Index Register IX, to the next entry.
523F
DECrement Register B and, while it is not zero, LOOP BACK to 5235H for the next entry (DJNZ).
5241
JUMP to 577AH for the error 1, Invalid command, a letter not in the table.
5244
LD DE,5212H 11 12 52
Load Register Pair DE with 5212H, the command loop, the return address of the command's routine.
5247
PUSH DE D5
Save Register Pair DE (5212H) to the top of the stack.
5248
LD E,(IX+01H) DD 5E 01
Load Register E with the low byte of the routine's address at Index Register IX+01H.
524B
LD D,(IX+02H) DD 56 02
Load Register D with the high byte at Index Register IX+02H: Register Pair DE = the routine.
524E
PUSH DE D5
Save Register Pair DE, the routine's address, to the top of the stack.
524F
RET C9
RETurn to the address on the stack: the command's routine, with Register Pair HL after its letter.
5250-5252
DEFM "B" / DEFW 526EH 42 6E 52
B, the baud rate of the cassette, H or L (526EH): the letter and the routine.
5253-5255
DEFM "H" / DEFW 5286H 48 86 52
H, the list of the command letters (5286H): the letter and the routine.
5256-5258
DEFM "I" / DEFW 52A6H 49 A6 52
I, start again with nothing in memory (52A6H).
5259-525B
DEFM "L" / DEFW 52BDH 4C BD 52
L, load a disk load module (52BDH): the letter and the routine.
525C-525E
DEFM "M" / DEFW 5346H 4D 46 53
M, the map of the programs in memory (5346H).
525F-5261
DEFM "O" / DEFW 542DH 4F 2D 54
O, the offset of the blocks when they are written (542DH).
5262-5264
DEFM "Q" / DEFW 5435H 51 35 54
Q, back to the DOS (5435H): the letter and the routine of the command.
5265-5267
DEFM "R" / DEFW 543EH 52 3E 54
R, read a system tape (543EH): the letter and the routine of the command.
5268-526A
DEFM "S" / DEFW 54D1H 53 D1 54
S, save the programs as a disk load module (54D1H).
526B-526D
DEFM "W" / DEFW 5572H 57 72 55
W, write the programs as a system tape (5572H).

526EH - B, H and I

B H sets the fast cassette speed, B L the slow one (4211H, the ROM's baud rate selector); the letter must be upper case and end the line. H shows the ten command letters with commas. I clears the variables 58C0H-58C5H and empties the store (5B42H on); the start of TAPE calls it at 52ACH.

526E
GOSUB to 571AH for the next character of the line after any spaces, the letter of the speed.
5271
PUSH AF F5
Save Register Pair AF, the letter in Register A, to the top of the stack.
5272
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
5275
If the NC FLAG is set (more on the line), JUMP to 578CH for the error 7, Parameter error.
5278
POP AF F1
Restore Register Pair AF, the letter in Register A, from the top of the stack.
5279
CP 48H FE 48
Compare Register A against 48H, the letter H, the high speed.
527B
If the Z FLAG is set (H), JUMP to 5282H with Register A = 48H, not zero, for the high speed.
527D
SUB 4CH D6 4C
SUBtract 4CH, the letter L, from Register A: 00H for L, the low speed.
527F
If the NZ FLAG is set (neither H nor L), JUMP to 578CH for the error 7, Parameter error.
5282
LD (4211H),A 32 11 42
Store Register A into 4211H, the ROM's cassette speed: 00H 500 baud, not zero 1500 baud.
5285
RET C9
RETurn to the command loop at 5212H with the speed set.
5286
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
5289
If the NC FLAG is set (more on the line), JUMP to 578CH for the error 7, Parameter error.
528C
LD B,09H 06 09
Load Register B with 09H, the nine letters shown before the last one.
528E
LD HL,5250H 21 50 52
Point Register Pair HL to 5250H, the table of the commands.
5291
LD A,(HL) 7E
Load Register A with the letter of the entry at Register Pair HL.
5292
INC HL 23
INCrement Register Pair HL by 1, the first of three steps to the next entry.
5293
INC HL 23
INCrement Register Pair HL by 1, the second of three steps.
5294
INC HL 23
INCrement Register Pair HL by 1, the third: Register Pair HL = the next entry.
5295
GOSUB to 56FBH to send the letter in Register A to the display.
5298
LD A,2CH 3E 2C
Load Register A with 2CH, the comma between the letters.
529A
GOSUB to 56FBH to send the comma in Register A to the display.
529D
DECrement Register B and, while it is not zero, LOOP BACK to 5291H for the next letter (DJNZ).
529F
LD A,(HL) 7E
Load Register A with the last letter of the table at Register Pair HL, W.
52A0
GOSUB to 56FBH to send the letter in Register A to the display.
52A3
JUMP to 56F9H to end the line with a carriage return, which returns to the command loop.
52A6
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
52A9
If the NC FLAG is set (more on the line), JUMP to 578CH for the error 7, Parameter error.
52AC
LD B,06H 06 06
Load Register B with 06H, the six bytes of the variables 58C0H-58C5H.
52AE
LD HL,58C0H 21 C0 58
Point Register Pair HL to 58C0H, the printer flag, the count of programs, the transfer address and the offset.
52B1
LD (HL),00H 36 00
Store 00H into the variable at Register Pair HL.
52B3
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the variables.
52B4
DECrement Register B and, while it is not zero, LOOP BACK to 52B1H for the next byte (DJNZ).
52B6
LD HL,5B42H 21 42 5B
Point Register Pair HL to 5B42H, the start of the store of the programs.
52B9
LD (58C7H),HL 22 C7 58
Store Register Pair HL (5B42H) into 58C7H-58C8H, the end of the store: the store is empty.
52BC
RET C9
RETurn to the caller, the command loop or the start of TAPE, with nothing in memory.

52BDH - L, Load a Disk Load Module

L filespec: the name (up to 24 characters, to the end of the line) goes into the program's 25 byte entry of the names table at 5948H; FSPEC@ and OPEN@ open the file, and its records are read by GET@ into the store: a type 01H block as 01H, its address, the count of its bytes and the bytes; the transfer record as 02H, its address kept at 58C2H. Other records are passed over; a type of 20H or more is Non program file. The file is not closed.

52BD
PUSH HL E5
Save Register Pair HL, the place in the command line, to the top of the stack.
52BE
LD A,(58C1H) 3A C1 58
Load Register A with the count of programs in memory from 58C1H.
52C1
CP 0AH FE 0A
Compare Register A against 0AH, the most programs the store holds: ten.
52C3
If the NC FLAG is set (ten already), JUMP to 5786H for the error 5, File area full.
52C6
LD E,19H 1E 19
Load Register E with 19H, the 25 bytes of an entry of the names table.
52C8
GOSUB to 5727H for Register A = Register A times Register E: the offset of the program's entry.
52CB
LD L,A 6F
Load Register L with Register A, the offset of the entry.
52CC
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the offset of the entry.
52CE
LD DE,5948H 11 48 59
Load Register Pair DE with 5948H, the start of the names table.
52D1
ADD HL,DE 19
ADD Register Pair DE (5948H) to Register Pair HL: the program's entry.
52D2
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the entry of the names table.
52D3
POP HL E1
Restore Register Pair HL, the place in the command line, from the top of the stack.
52D4
PUSH DE D5
Save Register Pair DE, the entry of the names table, to the top of the stack.
52D5
LD B,19H 06 19
Load Register B with 19H, the 25 bytes of the entry.
52D7
GOSUB to 561EH to copy the name from the command line into the entry, padded with spaces; the C FLAG when it ended the line.
52DA
If the NC FLAG is set (the name ended at a minus sign), JUMP to 578CH for the error 7, Parameter error.
52DD
POP HL E1
Restore Register Pair HL, the entry of the names table, from the top of the stack.
52DE
LD DE,58E8H 11 E8 58
Point Register Pair DE to 58E8H, TAPE's file control block.
52E1
GOSUB to 441CH, FSPEC@, to move the name at Register Pair HL into the file control block at Register Pair DE.
52E4
If the NZ FLAG is set (not a file specification), JUMP to 5780H for the error 3, Bad filename.
52E7
LD B,00H 06 00
Load Register B with 00H, the logical record length for OPEN@: 256 byte records.
52E9
LD HL,5A42H 21 42 5A
Point Register Pair HL to 5A42H, the 256 byte buffer of the file.
52EC
GOSUB to 4424H, OPEN@, to open the file of the file control block at Register Pair DE.
52EF
If the NZ FLAG is set (OPEN@ failed, its error code in Register A), JUMP to 57ABH to post the error.
52F2
LD HL,(58C7H) 2A C7 58
Load Register Pair HL with the end of the store from 58C7H-58C8H, where the program goes.
52F5
GOSUB to 560EH to test the room in the store: the C FLAG when fewer than 300 bytes are left below HMEM$.
52F8
If the C FLAG is set (no room), JUMP to 5789H for the error 6, Buffer area full.
52FB
GOSUB to 0013H, the ROM's input of a byte from the control block at Register Pair DE: the type of a record.
52FE
CP 20H FE 20
Compare Register A against 20H: the NC FLAG for a type no load module has.
5300
If the NC FLAG is set (not a load module), JUMP to 5783H for the error 4, Non program file.
5303
LD C,A 4F
Load Register C with Register A, the type of the record.
5304
GOSUB to 0013H to read the next byte of the file at Register Pair DE: the length of the record.
5307
LD B,A 47
Load Register B with Register A, the length of the record.
5308
DEC C 0D
DECrement Register C by 1: the Z FLAG for the type 01H, a block to load.
5309
If the Z FLAG is set (a block), JUMP to 5315H to keep it.
530B
DEC C 0D
DECrement Register C by 1: the Z FLAG for the type 02H, the transfer record.
530C
If the Z FLAG is set (the transfer record), JUMP to 532FH for the end of the program.
530E
GOSUB to 0013H to read the next byte of the record from the file at Register Pair DE, which is passed over.
5311
DECrement Register B and, while it is not zero, LOOP BACK to 530EH for the next byte (DJNZ).
5313
JUMP to 52F5H for the next record of the file, the record passed over.
5315
LD (HL),01H 36 01
Store 01H, the mark of a block in the store, at Register Pair HL.
5317
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
5318
GOSUB to 0013H to read the next byte of the file at Register Pair DE: the low byte of the block's address.
531B
DEC B 05
DECrement Register B by 1, the low byte of the address counted in the length.
531C
LD (HL),A 77
Store Register A, the low byte of the address, into the store at Register Pair HL.
531D
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
531E
GOSUB to 0013H to read the next byte of the file at Register Pair DE: the high byte of the address.
5321
DEC B 05
DECrement Register B by 1: Register B = the bytes of the block (00H for 256).
5322
LD (HL),A 77
Store Register A, the high byte of the address, into the store at Register Pair HL.
5323
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
5324
LD (HL),B 70
Store Register B, the count of the block's bytes, into the store at Register Pair HL.
5325
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
5326
GOSUB to 0013H to read the next byte of the block from the file at Register Pair DE.
5329
LD (HL),A 77
Store Register A, the byte of the block, into the store at Register Pair HL.
532A
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
532B
DECrement Register B and, while it is not zero, LOOP BACK to 5326H for the next byte (DJNZ).
532D
JUMP to 52F5H for the next record of the file, the block kept.
532F
LD (HL),02H 36 02
Store 02H, the mark of the end of a program in the store, at Register Pair HL.
5331
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
5332
GOSUB to 0013H to read the next byte of the file at Register Pair DE: the low byte of the transfer address.
5335
LD C,A 4F
Load Register C with Register A, the low byte of the transfer address.
5336
GOSUB to 0013H to read the next byte of the file at Register Pair DE: the high byte of the transfer address.
5339
LD B,A 47
Load Register B with Register A: Register Pair BC = the transfer address of the program.
533A
LD (58C7H),HL 22 C7 58
Store Register Pair HL, the new end of the store, into 58C7H-58C8H.
533D
LD (58C2H),BC ED 43 C2 58
Store Register Pair BC, the transfer address, into 58C2H-58C3H; the last program read gives it.
5341
LD HL,58C1H 21 C1 58
Point Register Pair HL to 58C1H, the count of programs in memory.
5344
INC (HL) 34
INCrement the count of programs at Register Pair HL by 1.
5345
RET C9
RETurn to the command loop at 5212H with the program in memory.

5346H - M, the Map

M, or M-P to send the map to the printer instead of the display. For each program its name, then each run of blocks that follow one another in memory as start-end and, after two spaces, start-end with the offset added; between runs the SHIFT and @ keys (60H) pause and BREAK ends the map. At the end XFER= the transfer address and OFFSET= the offset.

5346
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
5349
If the C FLAG is set (M alone), JUMP to 5365H for the map on the display.
534B
CP 2DH FE 2D
Compare Register A against 2DH, the minus sign before P.
534D
If the NZ FLAG is set (not a minus sign), JUMP to 578CH for the error 7, Parameter error.
5350
GOSUB to 571AH for the next character of the line after any spaces.
5353
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
5355
CP 50H FE 50
Compare Register A against 50H, the letter P, the printer.
5357
If the NZ FLAG is set (not P), JUMP to 578CH for the error 7, Parameter error.
535A
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
535D
If the NC FLAG is set (more on the line), JUMP to 578CH for the error 7, Parameter error.
5360
LD A,FFH 3E FF
Load Register A with FFH, the printer flag's value for output to the printer.
5362
LD (58C0H),A 32 C0 58
Store Register A (FFH) into 58C0H, the printer flag: 56FBH sends to the printer.
5365
LD E,00H 1E 00
Load Register E with 00H, the first program in memory.
5367
LD HL,5B42H 21 42 5B
Point Register Pair HL to 5B42H, the start of the store of the programs.
536A
LD A,(58C1H) 3A C1 58
Load Register A with the count of programs in memory from 58C1H.
536D
CP E BB
Compare Register A against Register E, the program to show next.
536E
If the NZ FLAG is set (another program), JUMP to 5390H to show it.
5370
LD HL,584BH 21 4B 58
Point Register Pair HL to 584BH, the text XFER=.
5373
GOSUB to 570DH to send the text at Register Pair HL up to its 00H.
5376
LD HL,(58C2H) 2A C2 58
Load Register Pair HL with the transfer address from 58C2H-58C3H.
5379
GOSUB to 5736H to send Register Pair HL as four hexadecimal digits.
537C
LD A,20H 3E 20
Load Register A with 20H, a space between the transfer address and the offset.
537E
GOSUB to 56FBH to send the space in Register A.
5381
LD HL,5851H 21 51 58
Point Register Pair HL to 5851H, the text OFFSET=.
5384
GOSUB to 570DH to send the text at Register Pair HL up to its 00H.
5387
LD HL,(58C4H) 2A C4 58
Load Register Pair HL with the offset from 58C4H-58C5H.
538A
GOSUB to 5736H to send Register Pair HL as four hexadecimal digits.
538D
JUMP to 56F9H to end the line with a carriage return, which returns to the command loop.
5390
PUSH DE D5
Save Register Pair DE, the number of the program in Register E, to the top of the stack.
5391
PUSH HL E5
Save Register Pair HL, the program's place in the store, to the top of the stack.
5392
LD A,19H 3E 19
Load Register A with 19H, the 25 bytes of an entry of the names table.
5394
GOSUB to 5727H for Register A = Register A times Register E: the offset of the program's entry.
5397
LD L,A 6F
Load Register L with Register A, the offset of the entry.
5398
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the offset of the entry.
539A
LD DE,5948H 11 48 59
Load Register Pair DE with 5948H, the start of the names table.
539D
ADD HL,DE 19
ADD Register Pair DE (5948H) to Register Pair HL: the program's entry.
539E
LD A,(HL) 7E
Load Register A with the next character of the name at Register Pair HL.
539F
CP 20H FE 20
Compare Register A against 20H, the space that ends the name.
53A1
PUSH AF F5
Save Register Pair AF, the Z FLAG of the end, to the top of the stack.
53A2
If the NZ FLAG is set (a character of the name), GOSUB to 56FBH to send it.
53A5
POP AF F1
Restore Register Pair AF, the Z FLAG of the end, from the top of the stack.
53A6
INC HL 23
INCrement Register Pair HL by 1, to the next character of the name.
53A7
If the NZ FLAG is set (not the end), JUMP to 539EH for the next character.
53A9
GOSUB to 56F9H to end the line of the name with a carriage return.
53AC
POP HL E1
Restore Register Pair HL, the program's place in the store, from the top of the stack.
53AD
LD A,(HL) 7E
Load Register A with the mark of the next item of the store at Register Pair HL.
53AE
INC HL 23
INCrement Register Pair HL by 1, past the mark.
53AF
DEC A 3D
DECrement Register A by 1: the Z FLAG for 01H, a block.
53B0
If the NZ FLAG is set (the end of the program), JUMP to 53F9H for the next program.
53B2
LD E,(HL) 5E
Load Register E with the low byte of the block's address at Register Pair HL.
53B3
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
53B4
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the block's address.
53B5
INC HL 23
INCrement Register Pair HL by 1, to the count of the block's bytes.
53B6
LD C,(HL) 4E
Load Register C with the count of the block's bytes at Register Pair HL (00H for 256).
53B7
INC HL 23
INCrement Register Pair HL by 1, to the bytes of the block.
53B8
PUSH DE D5
Save Register Pair DE, the start of the run of blocks, to the top of the stack.
53B9
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the block's address.
53BA
LD A,C 79
Load Register A with Register C, the count of the block's bytes.
53BB
SUB 01H D6 01
SUBtract 01H from Register A: the C FLAG for a count of 00H, 256 bytes.
53BD
LD A,00H 3E 00
Load Register A with 00H, the high byte of the count before the C FLAG is added.
53BF
ADC A,00H CE 00
ADD 00H and the C FLAG to Register A (ADC): 01H for 256 bytes, else 00H.
53C1
LD B,A 47
Load Register B with Register A: Register Pair BC = the bytes of the block.
53C2
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the address after the block.
53C3
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the address after the block.
53C4
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: past the bytes of the block in the store.
53C5
PUSH DE D5
Save Register Pair DE, the address after the block, to the top of the stack.
53C6
LD A,(HL) 7E
Load Register A with the mark of the next item of the store at Register Pair HL.
53C7
INC HL 23
INCrement Register Pair HL by 1, past the mark.
53C8
DEC A 3D
DECrement Register A by 1: the Z FLAG for 01H, another block.
53C9
If the NZ FLAG is set (the end of the program), JUMP to 53F2H to show the last run.
53CB
LD E,(HL) 5E
Load Register E with the low byte of the next block's address at Register Pair HL.
53CC
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
53CD
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the next block's address.
53CE
INC HL 23
INCrement Register Pair HL by 1, to the count of the block's bytes.
53CF
LD C,(HL) 4E
Load Register C with the count of the block's bytes at Register Pair HL.
53D0
INC HL 23
INCrement Register Pair HL by 1, to the bytes of the block.
53D1
EX (SP),HL E3
Exchange the top of the stack at the Stack Pointer with Register Pair HL: Register Pair HL = the address after the last block.
53D2
GOSUB to 5721H to compare Register Pair HL with Register Pair DE: the Z FLAG when the next block follows on.
53D5
If the NZ FLAG is set (a gap), JUMP to 53DAH to show the run so far.
53D7
POP HL E1
Restore Register Pair HL, the place in the store, from the top of the stack.
53D8
JUMP to 53B9H to add the block to the run of blocks that follow on.
53DA
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the address after the run, Register Pair HL = the next block's address.
53DB
POP AF F1
Restore Register Pair AF from the top of the stack: the place in the store, held in Register Pair AF.
53DC
EX (SP),HL E3
Exchange the top of the stack at the Stack Pointer with Register Pair HL: Register Pair HL = the start of the run.
53DD
PUSH AF F5
Save Register Pair AF, the place in the store, to the top of the stack.
53DE
DEC DE 1B
DECrement Register Pair DE by 1, to the last address of the run.
53DF
GOSUB to 53FEH to send the run start-end, and start-end with the offset.
53E2
POP HL E1
Restore Register Pair HL, the place in the store, from the top of the stack.
53E3
POP DE D1
Restore Register Pair DE, the next block's address, from the top of the stack.
53E4
GOSUB to 56ECH to scan the keyboard: Register A = the key pressed, or 00H.
53E7
CP 60H FE 60
Compare Register A against 60H, the code of SHIFT and @, the pause.
53E9
If the Z FLAG is set (the pause), GOSUB to 56F3H to wait for the next key: Register A = that key.
53EC
DEC A 3D
DECrement Register A by 1: the Z FLAG for 01H, BREAK.
53ED
If the NZ FLAG is set (not BREAK), JUMP to 53B8H to start the next run with this block.
53EF
JUMP to 5212H, the command loop, after BREAK.
53F2
POP DE D1
Restore Register Pair DE, the address after the run, from the top of the stack.
53F3
EX (SP),HL E3
Exchange the top of the stack at the Stack Pointer with Register Pair HL: Register Pair HL = the start of the run.
53F4
DEC DE 1B
DECrement Register Pair DE by 1, to the last address of the run.
53F5
GOSUB to 53FEH to send the run start-end, and start-end with the offset.
53F8
POP HL E1
Restore Register Pair HL, the place in the store, from the top of the stack.
53F9
POP DE D1
Restore Register Pair DE, the number of the program in Register E, from the top of the stack.
53FA
INC E 1C
INCrement Register E by 1, to the next program.
53FB
JUMP to 536AH for the next program of the map.

53FEH - A Run of the Map

Register Pair HL = the start, Register Pair DE = the last address: sends start-end, two spaces, and both again with the offset of 58C4H added, then a carriage return. Register Pair BC is saved.

53FE
PUSH BC C5
Save Register Pair BC to the top of the stack.
53FF
GOSUB to 5736H to send Register Pair HL, the start, as four hexadecimal digits.
5402
LD A,2DH 3E 2D
Load Register A with 2DH, the minus sign between the start and the end.
5404
GOSUB to 56FBH to send the minus sign in Register A.
5407
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the end.
5408
GOSUB to 5736H to send Register Pair HL, the end, as four hexadecimal digits.
540B
LD A,20H 3E 20
Load Register A with 20H, the first of two spaces before the offset run.
540D
GOSUB to 56FBH to send the space in Register A.
5410
LD A,20H 3E 20
Load Register A with 20H, the second of two spaces.
5412
GOSUB to 56FBH to send the space in Register A.
5415
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the start again.
5416
LD BC,(58C4H) ED 4B C4 58
Load Register Pair BC with the offset from 58C4H-58C5H.
541A
ADD HL,BC 09
ADD Register Pair BC (the offset) to Register Pair HL: the start with the offset.
541B
GOSUB to 5736H to send Register Pair HL as four hexadecimal digits.
541E
LD A,2DH 3E 2D
Load Register A with 2DH, the minus sign between the start and the end.
5420
GOSUB to 56FBH to send the minus sign in Register A.
5423
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the end.
5424
ADD HL,BC 09
ADD Register Pair BC (the offset) to Register Pair HL: the end with the offset.
5425
GOSUB to 5736H to send Register Pair HL as four hexadecimal digits.
5428
GOSUB to 56F9H to end the line with a carriage return.
542B
POP BC C1
Restore Register Pair BC from the top of the stack.
542C
RET C9
RETurn to the caller with the run shown, with and without the offset.

542DH - O, Q and R

O nnnn: the offset, hexadecimal (only the last four digits count), stored at 58C4H. Q returns to the DOS by EXIT@. R name: a system tape is searched for the header 55H and the six character name; its 3CH blocks are checked (the sum of the address bytes and the data) and kept in the store, and the 78H record gives the transfer address.

542D
GOSUB to 574FH for the hexadecimal number of the line in Register Pair BC.
5430
LD (58C4H),BC ED 43 C4 58
Store Register Pair BC, the offset, into 58C4H-58C5H.
5434
RET C9
RETurn to the command loop at 5212H with the offset set.
5435
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
5438
If the NC FLAG is set (more on the line), JUMP to 578CH for the error 7, Parameter error.
543B
JUMP to 402DH, EXIT@, back to the DOS, the programs in memory given up.
543E
PUSH HL E5
Save Register Pair HL, the place in the command line, to the top of the stack.
543F
LD A,(58C1H) 3A C1 58
Load Register A with the count of programs in memory from 58C1H.
5442
CP 0AH FE 0A
Compare Register A against 0AH, the most programs the store holds: ten.
5444
If the NC FLAG is set (ten already), JUMP to 5786H for the error 5, File area full.
5447
LD E,19H 1E 19
Load Register E with 19H, the 25 bytes of an entry of the names table.
5449
GOSUB to 5727H for Register A = Register A times Register E: the offset of the program's entry.
544C
LD L,A 6F
Load Register L with Register A, the offset of the entry.
544D
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the offset of the entry.
544F
LD DE,5948H 11 48 59
Load Register Pair DE with 5948H, the start of the names table.
5452
ADD HL,DE 19
ADD Register Pair DE (5948H) to Register Pair HL: the program's entry.
5453
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair DE = the entry of the names table.
5454
POP HL E1
Restore Register Pair HL, the place in the command line, from the top of the stack.
5455
LD B,06H 06 06
Load Register B with 06H, the six characters of a tape name.
5457
GOSUB to 561EH to copy the name from the command line into the entry, padded with spaces; the C FLAG when it ended the line.
545A
If the NC FLAG is set (the name ended at a minus sign), JUMP to 578CH for the error 7, Parameter error.
545D
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the name in the entry.
545E
GOSUB to 0296H, the ROM's start of a cassette read: the motor on, the leader and the sync byte found.
5461
LD B,06H 06 06
Load Register B with 06H, the six characters of the name to compare.
5463
GOSUB to 0235H, the ROM's input of a byte from the cassette into Register A.
5466
CP 55H FE 55
Compare Register A against 55H, the byte that starts the header of a system tape.
5468
If the NZ FLAG is set (not the header), JUMP to 5461H to read on.
546A
GOSUB to 0235H, the ROM's input of a byte from the cassette: a character of the tape's name.
546D
CP (HL) BE
Compare Register A against the character of the name at Register Pair HL.
546E
INC HL 23
INCrement Register Pair HL by 1, to the next character of the name, which is not set back after a wrong name.
546F
If the NZ FLAG is set (another name), JUMP to 5461H to look for the next header.
5471
DECrement Register B and, while it is not zero, LOOP BACK to 546AH for the next character (DJNZ).
5473
LD HL,(58C7H) 2A C7 58
Load Register Pair HL with the end of the store from 58C7H-58C8H, where the program goes.
5476
GOSUB to 560EH to test the room in the store: the C FLAG when fewer than 300 bytes are left below HMEM$.
5479
If the C FLAG is set (no room), JUMP to 54CBH to stop the cassette for the error 6.
547B
GOSUB to 0235H, the ROM's input of a byte from the cassette: the type of a record.
547E
CP 78H FE 78
Compare Register A against 78H, the record of the transfer address that ends a system tape.
5480
If the Z FLAG is set (the end), JUMP to 54B1H for the transfer address.
5482
CP 3CH FE 3C
Compare Register A against 3CH, the record of a block.
5484
If the NZ FLAG is set (neither), JUMP to 5476H to read the next byte.
5486
LD (HL),01H 36 01
Store 01H, the mark of a block in the store, at Register Pair HL.
5488
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
5489
GOSUB to 0235H, the ROM's input of a byte from the cassette: the count of the block's bytes.
548C
LD B,A 47
Load Register B with Register A, the count of the block's bytes (00H for 256).
548D
GOSUB to 0235H, the ROM's input of a byte from the cassette: the low byte of the block's address.
5490
LD C,A 4F
Load Register C with Register A, the checksum so far: the low byte of the address.
5491
LD (HL),A 77
Store Register A, the low byte of the address, into the store at Register Pair HL.
5492
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
5493
GOSUB to 0235H, the ROM's input of a byte from the cassette: the high byte of the block's address.
5496
LD (HL),A 77
Store Register A, the high byte of the address, into the store at Register Pair HL.
5497
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
5498
LD (HL),B 70
Store Register B, the count of the block's bytes, into the store at Register Pair HL.
5499
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
549A
ADD A,C 81
ADD Register C, the checksum so far, to Register A, the high byte of the address.
549B
LD C,A 4F
Load Register C with Register A, the checksum so far.
549C
GOSUB to 0235H, the ROM's input of a byte from the cassette: a byte of the block.
549F
LD (HL),A 77
Store Register A, the byte of the block, into the store at Register Pair HL.
54A0
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
54A1
ADD A,C 81
ADD Register C, the checksum so far, to Register A, the byte of the block.
54A2
LD C,A 4F
Load Register C with Register A, the checksum so far.
54A3
DECrement Register B and, while it is not zero, LOOP BACK to 549CH for the next byte (DJNZ).
54A5
GOSUB to 0235H, the ROM's input of a byte from the cassette: the checksum of the block.
54A8
CP C B9
Compare Register A against Register C, the checksum of the bytes read.
54A9
If the Z FLAG is set (they agree), JUMP to 5476H for the next record.
54AB
GOSUB to 01F8H, the ROM's routine that turns the cassette motor off.
54AE
JUMP to 577DH for the error 2, Checksum error.
54B1
LD (HL),02H 36 02
Store 02H, the mark of the end of a program in the store, at Register Pair HL.
54B3
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the store.
54B4
GOSUB to 0235H, the ROM's input of a byte from the cassette: the low byte of the transfer address.
54B7
LD C,A 4F
Load Register C with Register A, the low byte of the transfer address.
54B8
GOSUB to 0235H, the ROM's input of a byte from the cassette: the high byte of the transfer address.
54BB
LD B,A 47
Load Register B with Register A: Register Pair BC = the transfer address.
54BC
GOSUB to 01F8H, the ROM's routine that turns the cassette motor off.
54BF
LD (58C7H),HL 22 C7 58
Store Register Pair HL, the new end of the store, into 58C7H-58C8H.
54C2
LD (58C2H),BC ED 43 C2 58
Store Register Pair BC, the transfer address, into 58C2H-58C3H; the last program read gives it.
54C6
LD HL,58C1H 21 C1 58
Point Register Pair HL to 58C1H, the count of programs in memory.
54C9
INC (HL) 34
INCrement the count of programs at Register Pair HL by 1.
54CA
RET C9
RETurn to the command loop at 5212H with the program in memory.
54CB
GOSUB to 01F8H, the ROM's routine that turns the cassette motor off.
54CE
JUMP to 5789H for the error 6, Buffer area full.

54D1H - S, Save a Disk Load Module

S filespec, or S filespec-A with the loader of 5638H. The programs in memory (and the loader) are written to the file by INIT@ and PUT, each block as a type 01H record at its address plus the offset, then one transfer record with the transfer address plus the offset; CLOSE@. The PUTs are not tested.

54D1
LD A,(58C1H) 3A C1 58
Load Register A with the count of programs in memory from 58C1H.
54D4
LD (58C6H),A 32 C6 58
Store Register A into 58C6H, the programs to write.
54D7
LD DE,(58C2H) ED 5B C2 58
Load Register Pair DE with the transfer address from 58C2H-58C3H.
54DB
LD (58CDH),DE ED 53 CD 58
Store Register Pair DE into 58CDH-58CEH, the transfer address to write.
54DF
LD B,19H 06 19
Load Register B with 19H, the 25 bytes of the name.
54E1
LD DE,58CFH 11 CF 58
Point Register Pair DE to 58CFH, the place of the name to write.
54E4
GOSUB to 561EH to copy the name from the command line to Register Pair DE, padded with spaces; the C FLAG when it ended the line.
54E7
If the C FLAG is set (no -A), JUMP to 54FCH to open the file.
54E9
GOSUB to 571AH for the next character of the line after any spaces, the letter after the minus sign.
54EC
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
54EE
CP 41H FE 41
Compare Register A against 41H, the letter A, the loader.
54F0
If the NZ FLAG is set (not A), JUMP to 578CH for the error 7, Parameter error.
54F3
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
54F6
If the NC FLAG is set (more on the line), JUMP to 578CH for the error 7, Parameter error.
54F9
GOSUB to 5638H to add the loader that moves the program back, when an offset is set.
54FC
LD HL,58CFH 21 CF 58
Point Register Pair HL to 58CFH, the name of the file.
54FF
LD DE,58E8H 11 E8 58
Point Register Pair DE to 58E8H, TAPE's file control block.
5502
GOSUB to 441CH, FSPEC@, to move the name at Register Pair HL into the file control block at Register Pair DE.
5505
If the NZ FLAG is set (not a file specification), JUMP to 5780H for the error 3, Bad filename.
5508
LD B,00H 06 00
Load Register B with 00H, the logical record length for INIT@: 256 byte records.
550A
LD HL,5A42H 21 42 5A
Point Register Pair HL to 5A42H, the 256 byte buffer of the file.
550D
GOSUB to 4420H, INIT@, to open the file of the file control block at Register Pair DE, making it when it is not there.
5510
If the NZ FLAG is set (INIT@ failed, its error code in Register A), JUMP to 57ABH to post the error.
5513
LD C,00H 0E 00
Load Register C with 00H, the first program in the store.
5515
LD HL,5B42H 21 42 5B
Point Register Pair HL to 5B42H, the start of the store of the programs.
5518
LD A,(58C6H) 3A C6 58
Load Register A with the programs to write from 58C6H.
551B
CP C B9
Compare Register A against Register C, the program reached.
551C
If the Z FLAG is set (all are written), JUMP to 5551H for the transfer record.
551E
LD A,(HL) 7E
Load Register A with the mark of the next item of the store at Register Pair HL.
551F
INC HL 23
INCrement Register Pair HL by 1, past the mark.
5520
AND 01H E6 01
AND Register A with 01H, keeping bit 0: set for a block (01H, and the loader's 03H).
5522
If the Z FLAG is set (the end of a program), JUMP to 554EH for the next program.
5524
LD A,01H 3E 01
Load Register A with 01H, the type of a load record.
5526
GOSUB to 001BH, the ROM's output of the byte in Register A to the control block at Register Pair DE, the file.
5529
PUSH BC C5
Save Register Pair BC, the program reached in Register C, to the top of the stack.
552A
LD C,(HL) 4E
Load Register C with the low byte of the block's address at Register Pair HL.
552B
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
552C
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the block's address.
552D
INC HL 23
INCrement Register Pair HL by 1, to the count of the block's bytes.
552E
LD A,(HL) 7E
Load Register A with the count of the block's bytes at Register Pair HL.
552F
INC HL 23
INCrement Register Pair HL by 1, to the bytes of the block.
5530
PUSH HL E5
Save Register Pair HL, the bytes of the block, to the top of the stack.
5531
LD HL,(58C4H) 2A C4 58
Load Register Pair HL with the offset from 58C4H-58C5H.
5534
ADD HL,BC 09
ADD Register Pair BC (the block's address) to Register Pair HL: the address with the offset.
5535
LD B,A 47
Load Register B with Register A, the count of the block's bytes.
5536
ADD A,02H C6 02
ADD 02H to Register A: the length of the record, with the two address bytes.
5538
GOSUB to 001BH, the ROM's output of the length in Register A to the file at Register Pair DE.
553B
LD A,L 7D
Load Register A with Register L, the low byte of the address with the offset.
553C
GOSUB to 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
553F
LD A,H 7C
Load Register A with Register H, the high byte of the address with the offset.
5540
GOSUB to 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
5543
POP HL E1
Restore Register Pair HL, the bytes of the block, from the top of the stack.
5544
LD A,(HL) 7E
Load Register A with the next byte of the block at Register Pair HL.
5545
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the block.
5546
GOSUB to 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
5549
DECrement Register B and, while it is not zero, LOOP BACK to 5544H for the next byte (DJNZ).
554B
POP BC C1
Restore Register Pair BC, the program reached in Register C, from the top of the stack.
554C
JUMP to 551EH for the next item of the store.
554E
INC C 0C
INCrement Register C by 1, to the next program.
554F
JUMP to 5518H for the test of the programs to write.
5551
LD A,02H 3E 02
Load Register A with 02H, the type of the transfer record.
5553
GOSUB to 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
5556
LD A,02H 3E 02
Load Register A with 02H, the length of the transfer record.
5558
GOSUB to 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
555B
LD HL,(58C4H) 2A C4 58
Load Register Pair HL with the offset from 58C4H-58C5H.
555E
LD BC,(58CDH) ED 4B CD 58
Load Register Pair BC with the transfer address to write from 58CDH-58CEH.
5562
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the transfer address with the offset.
5563
LD A,L 7D
Load Register A with Register L, the low byte of the transfer address.
5564
GOSUB to 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
5567
LD A,H 7C
Load Register A with Register H, the high byte of the transfer address.
5568
GOSUB to 001BH, the ROM's output of the byte in Register A to the file at Register Pair DE.
556B
GOSUB to 4428H, CLOSE@, to close the file at Register Pair DE.
556E
If the NZ FLAG is set (CLOSE@ failed, its error code in Register A), JUMP to 57ABH to post the error.
5571
RET C9
RETurn to the command loop at 5212H with the file written.

5572H - W, Write a System Tape

W name or W name-A: the header 55H and the six character name, then each block as 3CH, the count, the address plus the offset, the bytes and the checksum (the sum of the address bytes and the data), and the end 78H with the transfer address plus the offset; the motor is turned off.

5572
LD A,(58C1H) 3A C1 58
Load Register A with the count of programs in memory from 58C1H.
5575
LD (58C6H),A 32 C6 58
Store Register A into 58C6H, the programs to write.
5578
LD DE,(58C2H) ED 5B C2 58
Load Register Pair DE with the transfer address from 58C2H-58C3H.
557C
LD (58CDH),DE ED 53 CD 58
Store Register Pair DE into 58CDH-58CEH, the transfer address to write.
5580
LD B,06H 06 06
Load Register B with 06H, the six characters of a tape name.
5582
LD DE,58CFH 11 CF 58
Point Register Pair DE to 58CFH, the place of the name to write.
5585
GOSUB to 561EH to copy the name from the command line to Register Pair DE, padded with spaces; the C FLAG when it ended the line.
5588
If the C FLAG is set (no -A), JUMP to 559DH to write the tape.
558A
GOSUB to 571AH for the next character of the line after any spaces, the letter after the minus sign.
558D
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
558F
CP 41H FE 41
Compare Register A against 41H, the letter A, the loader.
5591
If the NZ FLAG is set (not A), JUMP to 578CH for the error 7, Parameter error.
5594
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
5597
If the NC FLAG is set (more on the line), JUMP to 578CH for the error 7, Parameter error.
559A
GOSUB to 5638H to add the loader that moves the program back, when an offset is set.
559D
GOSUB to 0287H, the ROM's start of a cassette write: the motor on, the leader and the sync byte written.
55A0
LD A,55H 3E 55
Load Register A with 55H, the byte that starts the header of a system tape.
55A2
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
55A5
LD B,06H 06 06
Load Register B with 06H, the six characters of the name.
55A7
LD HL,58CFH 21 CF 58
Point Register Pair HL to 58CFH, the name to write.
55AA
LD A,(HL) 7E
Load Register A with the next character of the name at Register Pair HL.
55AB
INC HL 23
INCrement Register Pair HL by 1, to the next character.
55AC
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
55AF
DECrement Register B and, while it is not zero, LOOP BACK to 55AAH for the next character (DJNZ).
55B1
LD C,00H 0E 00
Load Register C with 00H, the first program in the store.
55B3
LD HL,5B42H 21 42 5B
Point Register Pair HL to 5B42H, the start of the store of the programs.
55B6
LD A,(58C6H) 3A C6 58
Load Register A with the programs to write from 58C6H.
55B9
CP C B9
Compare Register A against Register C, the program reached.
55BA
If the Z FLAG is set (all are written), JUMP to 55F5H for the end record.
55BC
LD A,(HL) 7E
Load Register A with the mark of the next item of the store at Register Pair HL.
55BD
INC HL 23
INCrement Register Pair HL by 1, past the mark.
55BE
AND 01H E6 01
AND Register A with 01H, keeping bit 0: set for a block (01H, and the loader's 03H).
55C0
If the Z FLAG is set (the end of a program), JUMP to 55F2H for the next program.
55C2
LD A,3CH 3E 3C
Load Register A with 3CH, the record of a block on a system tape.
55C4
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
55C7
PUSH BC C5
Save Register Pair BC, the program reached in Register C, to the top of the stack.
55C8
LD C,(HL) 4E
Load Register C with the low byte of the block's address at Register Pair HL.
55C9
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
55CA
LD B,(HL) 46
Load Register B with the high byte at Register Pair HL: Register Pair BC = the block's address.
55CB
INC HL 23
INCrement Register Pair HL by 1, to the count of the block's bytes.
55CC
LD A,(HL) 7E
Load Register A with the count of the block's bytes at Register Pair HL.
55CD
INC HL 23
INCrement Register Pair HL by 1, to the bytes of the block.
55CE
PUSH HL E5
Save Register Pair HL, the bytes of the block, to the top of the stack.
55CF
LD HL,(58C4H) 2A C4 58
Load Register Pair HL with the offset from 58C4H-58C5H.
55D2
ADD HL,BC 09
ADD Register Pair BC (the block's address) to Register Pair HL: the address with the offset.
55D3
LD B,A 47
Load Register B with Register A, the count of the block's bytes.
55D4
GOSUB to 0264H, the ROM's output of the count in Register A to the cassette.
55D7
LD A,L 7D
Load Register A with Register L, the low byte of the address with the offset.
55D8
LD C,A 4F
Load Register C with Register A, the checksum so far: the low byte of the address.
55D9
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
55DC
LD A,H 7C
Load Register A with Register H, the high byte of the address with the offset.
55DD
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
55E0
ADD A,C 81
ADD Register C, the checksum so far, to Register A, the high byte of the address.
55E1
LD C,A 4F
Load Register C with Register A, the checksum so far.
55E2
POP HL E1
Restore Register Pair HL, the bytes of the block, from the top of the stack.
55E3
LD A,(HL) 7E
Load Register A with the next byte of the block at Register Pair HL.
55E4
INC HL 23
INCrement Register Pair HL by 1, to the next byte of the block.
55E5
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
55E8
ADD A,C 81
ADD Register C, the checksum so far, to Register A, the byte of the block.
55E9
LD C,A 4F
Load Register C with Register A, the checksum so far.
55EA
DECrement Register B and, while it is not zero, LOOP BACK to 55E3H for the next byte (DJNZ).
55EC
GOSUB to 0264H, the ROM's output of the checksum in Register A to the cassette.
55EF
POP BC C1
Restore Register Pair BC, the program reached in Register C, from the top of the stack.
55F0
JUMP to 55BCH for the next item of the store.
55F2
INC C 0C
INCrement Register C by 1, to the next program.
55F3
JUMP to 55B6H for the test of the programs to write.
55F5
LD A,78H 3E 78
Load Register A with 78H, the record of the transfer address that ends a system tape.
55F7
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
55FA
LD HL,(58C4H) 2A C4 58
Load Register Pair HL with the offset from 58C4H-58C5H.
55FD
LD BC,(58CDH) ED 4B CD 58
Load Register Pair BC with the transfer address to write from 58CDH-58CEH.
5601
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the transfer address with the offset.
5602
LD A,L 7D
Load Register A with Register L, the low byte of the transfer address.
5603
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
5606
LD A,H 7C
Load Register A with Register H, the high byte of the transfer address.
5607
GOSUB to 0264H, the ROM's output of the byte in Register A to the cassette.
560A
GOSUB to 01F8H, the ROM's routine that turns the cassette motor off.
560D
RET C9
RETurn to the command loop at 5212H with the tape written.

560EH - Room and a Name

560EH returns the C FLAG when Register Pair HL plus 300 (012CH) reaches HMEM$. 561EH copies a name of up to Register B characters from the command line to Register Pair DE, ending at the end of the line (the C FLAG) or a minus sign (the NC FLAG), and pads it with at least one space; a longer name is Bad filename.

560E
PUSH HL E5
Save Register Pair HL, the end of the store, to the top of the stack.
560F
LD BC,012CH 01 2C 01
Load Register Pair BC with 012CH, the 300 bytes a record may need.
5612
ADD HL,BC 09
ADD Register Pair BC (012CH) to Register Pair HL: the C FLAG when past FFFFH.
5613
If the C FLAG is set (past FFFFH), JUMP to 561CH with the C FLAG: no room.
5615
LD BC,(4411H) ED 4B 11 44
Load Register Pair BC with HMEM$ from 4411H-4412H, the highest address free for programs.
5619
SBC HL,BC ED 42
SUBtract Register Pair BC (HMEM$) from Register Pair HL with the C FLAG: the NC FLAG when HMEM$ is reached.
561B
CCF 3F
Complement the C FLAG (CCF): the C FLAG when there is no room.
561C
POP HL E1
Restore Register Pair HL, the end of the store, from the top of the stack.
561D
RET C9
RETurn to the caller with the C FLAG when the store is full.
561E
PUSH DE D5
Save Register Pair DE, the place of the name, to the top of the stack.
561F
INC B 04
INCrement Register B by 1, so that Register B characters may be copied with room for one space.
5620
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
5623
If the C FLAG is set (the end of the line), JUMP to 5630H to pad the name.
5625
CP 2DH FE 2D
Compare Register A against 2DH, the minus sign before an option.
5627
If the Z FLAG is set (the minus sign), JUMP to 5630H to pad the name, with the NC FLAG.
5629
LD (DE),A 12
Store Register A, a character of the name, at Register Pair DE.
562A
INC DE 13
INCrement Register Pair DE by 1, to the next place of the name.
562B
DECrement Register B and, while it is not zero, LOOP BACK to 5620H for the next character (DJNZ).
562D
JUMP to 5780H for the error 3, Bad filename: the name is too long.
5630
LD A,20H 3E 20
Load Register A with 20H, a space after the name.
5632
LD (DE),A 12
Store Register A, the space, at Register Pair DE.
5633
INC DE 13
INCrement Register Pair DE by 1, to the next place of the name.
5634
DECrement Register B and, while it is not zero, LOOP BACK to 5630H for the next space (DJNZ).
5636
POP DE D1
Restore Register Pair DE, the place of the name, from the top of the stack.
5637
RET C9
RETurn to the caller with the C FLAG for the end of the line, the NC FLAG for a minus sign.

5638H - -A, the Loader

Only when an offset is set. The lowest address and the address after the highest of all blocks give the length to move; with an offset below 0000H (the sum carries) the 28 byte record at 57B9H (LDDR, placed 17H bytes below the lowest address) is used, else the one at 57D5H (LDIR, placed at the address after the highest). Its operands get the addresses, the length and the transfer address; it is added to the store as one more program, and the transfer address to write becomes the loader's.

5638
LD HL,(58C4H) 2A C4 58
Load Register Pair HL with the offset from 58C4H-58C5H.
563B
LD A,H 7C
Load Register A with Register H, the high byte of the offset.
563C
OR L B5
OR Register A with Register L: the Z FLAG for an offset of 0000H.
563D
RET Z C8
If the Z FLAG is set (no offset), RETurn to the caller: no loader is added.
563E
SBC HL,HL ED 62
SUBtract Register Pair HL from itself with the C FLAG (SBC HL,HL; the C FLAG is clear): Register Pair HL = 0000H.
5640
LD (58C9H),HL 22 C9 58
Store Register Pair HL (0000H) into 58C9H-58CAH, the highest end so far.
5643
DEC HL 2B
DECrement Register Pair HL by 1: FFFFH, the start before any block is seen.
5644
LD (58CBH),HL 22 CB 58
Store Register Pair HL (FFFFH) into 58CBH-58CCH, the lowest start so far.
5647
LD B,00H 06 00
Load Register B with 00H, the first program in the store.
5649
LD HL,5B42H 21 42 5B
Point Register Pair HL to 5B42H, the start of the store of the programs.
564C
LD A,(58C1H) 3A C1 58
Load Register A with the count of programs in memory from 58C1H.
564F
CP B B8
Compare Register A against Register B, the program reached.
5650
If the Z FLAG is set (all are seen), JUMP to 5689H to set the loader.
5652
LD A,(HL) 7E
Load Register A with the mark of the next item of the store at Register Pair HL.
5653
INC HL 23
INCrement Register Pair HL by 1, past the mark.
5654
DEC A 3D
DECrement Register A by 1: the Z FLAG for 01H, a block.
5655
If the NZ FLAG is set (the end of a program), JUMP to 5686H for the next program.
5657
PUSH BC C5
Save Register Pair BC, the program reached in Register B, to the top of the stack.
5658
LD E,(HL) 5E
Load Register E with the low byte of the block's address at Register Pair HL.
5659
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
565A
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the block's address.
565B
INC HL 23
INCrement Register Pair HL by 1, to the count of the block's bytes.
565C
LD C,(HL) 4E
Load Register C with the count of the block's bytes at Register Pair HL.
565D
INC HL 23
INCrement Register Pair HL by 1, to the bytes of the block.
565E
PUSH HL E5
Save Register Pair HL, the bytes of the block, to the top of the stack.
565F
LD HL,(58CBH) 2A CB 58
Load Register Pair HL with the lowest start so far from 58CBH-58CCH.
5662
GOSUB to 5721H to compare Register Pair HL with Register Pair DE: the C FLAG when the lowest start is below the block.
5665
If the C FLAG is set (the block is higher), JUMP to 566BH.
5667
LD (58CBH),DE ED 53 CB 58
Store Register Pair DE, the block's address, into 58CBH-58CCH, the new lowest start.
566B
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the block's address.
566C
LD A,C 79
Load Register A with Register C, the count of the block's bytes.
566D
SUB 01H D6 01
SUBtract 01H from Register A: the C FLAG for a count of 00H, 256 bytes.
566F
LD A,00H 3E 00
Load Register A with 00H, the high byte of the count before the C FLAG is added.
5671
ADC A,00H CE 00
ADD 00H and the C FLAG to Register A (ADC): 01H for 256 bytes, else 00H.
5673
LD B,A 47
Load Register B with Register A: Register Pair BC = the bytes of the block.
5674
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the address after the block.
5675
LD DE,(58C9H) ED 5B C9 58
Load Register Pair DE with the highest end so far from 58C9H-58CAH.
5679
GOSUB to 5721H to compare Register Pair HL with Register Pair DE: the C FLAG when this end is lower.
567C
If the C FLAG is set (lower than the highest end), JUMP to 5681H.
567E
LD (58C9H),HL 22 C9 58
Store Register Pair HL, the address after the block, into 58C9H-58CAH, the new highest end.
5681
POP HL E1
Restore Register Pair HL, the bytes of the block, from the top of the stack.
5682
ADD HL,BC 09
ADD Register Pair BC, the bytes of the block, to Register Pair HL: past them in the store.
5683
POP BC C1
Restore Register Pair BC, the program reached in Register B, from the top of the stack.
5684
JUMP to 5652H for the next item of the store.
5686
INC B 04
INCrement Register B by 1, to the next program.
5687
JUMP to 564CH for the test of the programs seen.
5689
LD HL,(58C9H) 2A C9 58
Load Register Pair HL with the highest end from 58C9H-58CAH.
568C
LD DE,(58CBH) ED 5B CB 58
Load Register Pair DE with the lowest start from 58CBH-58CCH.
5690
OR A B7
OR Register A with itself, to clear the C FLAG for the SBC below.
5691
SBC HL,DE ED 52
SUBtract Register Pair DE from Register Pair HL with the C FLAG: the length of the program area.
5693
LD (57CDH),HL 22 CD 57
Store Register Pair HL, the length, into 57CDH-57CEH, the operand of LD BC at 57CCH.
5696
LD (57E9H),HL 22 E9 57
Store Register Pair HL, the length, into 57E9H-57EAH, the operand of LD BC at 57E8H.
5699
LD HL,(58C2H) 2A C2 58
Load Register Pair HL with the transfer address from 58C2H-58C3H.
569C
LD (57D2H),HL 22 D2 57
Store Register Pair HL into 57D2H-57D3H, the operand of JP at 57D1H.
569F
LD (57EEH),HL 22 EE 57
Store Register Pair HL into 57EEH-57EFH, the operand of JP at 57EDH.
56A2
LD HL,(58C4H) 2A C4 58
Load Register Pair HL with the offset from 58C4H-58C5H.
56A5
ADD HL,DE 19
ADD Register Pair DE, the lowest start, to Register Pair HL: the place of the moved copy, the C FLAG when the offset is below 0000H.
56A6
If the NC FLAG is set (the copy lies higher), JUMP to 56C8H for the loader with LDIR.
56A8
EX DE,HL EB
Exchange Register Pair DE and Register Pair HL: Register Pair HL = the lowest start.
56A9
LD DE,0016H 11 16 00
Load Register Pair DE with 0016H, with the C FLAG the 17H bytes of the loader's code.
56AC
SBC HL,DE ED 52
SUBtract Register Pair DE and the C FLAG from Register Pair HL: 17H bytes below the lowest start.
56AE
LD (57BAH),HL 22 BA 57
Store Register Pair HL into 57BAH-57BBH, the address of the loader's block.
56B1
LD (58CDH),HL 22 CD 58
Store Register Pair HL into 58CDH-58CEH, the transfer address to write: the loader.
56B4
LD HL,(58C9H) 2A C9 58
Load Register Pair HL with the highest end from 58C9H-58CAH.
56B7
DEC HL 2B
DECrement Register Pair HL by 1, the last address of the program area.
56B8
LD DE,(58C4H) ED 5B C4 58
Load Register Pair DE with the offset from 58C4H-58C5H.
56BC
LD (57CAH),HL 22 CA 57
Store Register Pair HL into 57CAH-57CBH, the operand of LD DE at 57C9H: the last address it copies to.
56BF
ADD HL,DE 19
ADD Register Pair DE (the offset) to Register Pair HL: the last address of the moved copy.
56C0
LD (57C7H),HL 22 C7 57
Store Register Pair HL into 57C7H-57C8H, the operand of LD HL at 57C6H: the last address it copies from.
56C3
LD HL,57B9H 21 B9 57
Point Register Pair HL to 57B9H, the record of the loader with LDDR.
56C6
JUMP to 56DBH to add the loader's record to the end of the store.
56C8
LD (57E3H),HL 22 E3 57
Store Register Pair HL, the place of the moved copy, into 57E3H-57E4H, the operand of LD HL at 57E2H.
56CB
LD (57E6H),DE ED 53 E6 57
Store Register Pair DE, the lowest start, into 57E6H-57E7H, the operand of LD DE at 57E5H.
56CF
LD HL,(58C9H) 2A C9 58
Load Register Pair HL with the highest end from 58C9H-58CAH.
56D2
LD (57D6H),HL 22 D6 57
Store Register Pair HL into 57D6H-57D7H, the address of the loader's block: just after the program area.
56D5
LD (58CDH),HL 22 CD 58
Store Register Pair HL into 58CDH-58CEH, the transfer address to write: the loader.
56D8
LD HL,57D5H 21 D5 57
Point Register Pair HL to 57D5H, the record of the loader with LDIR.
56DB
LD DE,(58C7H) ED 5B C7 58
Load Register Pair DE with the end of the store from 58C7H-58C8H.
56DF
LD BC,001CH 01 1C 00
Load Register Pair BC with 001CH, the 28 bytes of the loader's record.
56E2
LDIR ED B0
Copy the loader's record to the end of the store: Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR).
56E4
LD A,(58C1H) 3A C1 58
Load Register A with the count of programs in memory from 58C1H.
56E7
INC A 3C
INCrement Register A by 1: one more, the loader.
56E8
LD (58C6H),A 32 C6 58
Store Register A into 58C6H, the programs to write, the loader with them.
56EB
RET C9
RETurn to the caller with the loader added to the store of programs.

56ECH - Keys, Output and the Line

56ECH scans the keyboard (002BH), 56F3H waits for a key; 56F9H sends a carriage return and 56FBH Register A, to the display or (printer flag 58C0H set) to the printer only; 570DH sends a text up to 00H; 571AH takes the next character of the line after spaces (the C FLAG below 20H); 5721H compares Register Pair HL with Register Pair DE; 5727H multiplies; 5736H sends Register Pair HL in hexadecimal; 574FH takes a hexadecimal number.

56EC
PUSH DE D5
Save Register Pair DE to the top of the stack around the scan of the keyboard.
56ED
GOSUB to 002BH, the ROM's scan of the keyboard: Register A = the key pressed, or 00H.
56F0
OR A B7
OR Register A with itself: the Z FLAG when no key is pressed.
56F1
POP DE D1
Restore Register Pair DE from the top of the stack.
56F2
RET C9
RETurn to the caller with the key in Register A.
56F3
GOSUB to 56ECH to scan the keyboard: Register A = the key pressed, or 00H.
56F6
If the Z FLAG is set (no key), JUMP to 56F3H to scan again.
56F8
RET C9
RETurn to the caller with the key in Register A.
56F9
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, and fall into 56FBH to send it.
56FB
PUSH DE D5
Save Register Pair DE to the top of the stack.
56FC
PUSH HL E5
Save Register Pair HL to the top of the stack.
56FD
LD HL,58C0H 21 C0 58
Point Register Pair HL to 58C0H, the printer flag.
5700
INC (HL) 34
INCrement the printer flag at Register Pair HL by 1, the first half of a test for zero.
5701
DEC (HL) 35
DECrement the printer flag at Register Pair HL by 1, back: the Z FLAG for output to the display.
5702
PUSH AF F5
Save Register Pair AF, the character and the Z FLAG, to the top of the stack.
5703
If the Z FLAG is set (the display), GOSUB to 0033H, the ROM's display of the character in Register A.
5706
POP AF F1
Restore Register Pair AF, the character and the Z FLAG, from the top of the stack.
5707
If the NZ FLAG is set (the printer), GOSUB to 003BH, the ROM's printing of the character in Register A.
570A
POP HL E1
Restore Register Pair HL from the top of the stack.
570B
POP DE D1
Restore Register Pair DE from the top of the stack.
570C
RET C9
RETurn to the caller with the character sent.
570D
PUSH HL E5
Save Register Pair HL, the text, to the top of the stack.
570E
LD A,(HL) 7E
Load Register A with the next character of the text at Register Pair HL.
570F
OR A B7
OR Register A with itself: the Z FLAG for the 00H that ends the text.
5710
PUSH AF F5
Save Register Pair AF, the character and the Z FLAG, to the top of the stack.
5711
If the NZ FLAG is set (a character), GOSUB to 56FBH to send it.
5714
POP AF F1
Restore Register Pair AF, the character and the Z FLAG, from the top of the stack.
5715
INC HL 23
INCrement Register Pair HL by 1, to the next character of the text.
5716
If the NZ FLAG is set (not the end), JUMP to 570EH for the next character.
5718
POP HL E1
Restore Register Pair HL, the text, from the top of the stack.
5719
RET C9
RETurn to the caller with the text sent up to its 00H.
571A
LD A,(HL) 7E
Load Register A with the next character of the line at Register Pair HL.
571B
INC HL 23
INCrement Register Pair HL by 1, to the character after it.
571C
CP 20H FE 20
Compare Register A against 20H, a space: the C FLAG for a control code, the end of the line.
571E
If the Z FLAG is set (a space), JUMP to 571AH for the next character.
5720
RET C9
RETurn to the caller with the character in Register A; the C FLAG at the end of the line.
5721
LD A,H 7C
Load Register A with Register H, the high byte of Register Pair HL.
5722
SUB D 92
SUBtract Register D from Register A: the Z FLAG when the high bytes agree, the C FLAG when Register H is lower.
5723
RET NZ C0
If the NZ FLAG is set (the high bytes differ), RETurn to the caller with those flags.
5724
LD A,L 7D
Load Register A with Register L, the low byte of Register Pair HL.
5725
SUB E 93
SUBtract Register E from Register A: the Z FLAG when they are equal, the C FLAG when Register Pair HL is lower.
5726
RET C9
RETurn to the caller with the flags of the compare of Register Pair HL with Register Pair DE.
5727
PUSH BC C5
Save Register Pair BC to the top of the stack.
5728
LD D,A 57
Load Register D with Register A, the first factor.
5729
XOR A AF
Set Register A to 00H (XOR A), the product so far.
572A
LD B,08H 06 08
Load Register B with 08H, the eight bits of Register E.
572C
ADD A,A 87
ADD Register A to itself, the product times 2.
572D
SLA E CB 23
Shift Register E left one bit (SLA): its top bit into the C FLAG.
572F
If the NC FLAG is set (the bit is 0), JUMP to 5732H.
5731
ADD A,D 82
ADD Register D, the first factor, to Register A, the product.
5732
DECrement Register B and, while it is not zero, LOOP BACK to 572CH for the next bit (DJNZ).
5734
POP BC C1
Restore Register Pair BC from the top of the stack.
5735
RET C9
RETurn to the caller with Register A = Register D times Register E, 8 bits.
5736
LD A,H 7C
Load Register A with Register H, the high byte of the word.
5737
GOSUB to 573BH to send Register A as two hexadecimal digits.
573A
LD A,L 7D
Load Register A with Register L, the low byte of the word, and fall into 573BH.
573B
PUSH AF F5
Save Register Pair AF, the byte in Register A, to the top of the stack for the low digit.
573C
RRA 1F
Rotate Register A right through the C FLAG, the first of four that bring the high digit to bits 3-0 (RRA).
573D
RRA 1F
Rotate Register A right through the C FLAG, the second of four (RRA).
573E
RRA 1F
Rotate Register A right through the C FLAG, the third of four (RRA).
573F
RRA 1F
Rotate Register A right through the C FLAG, the fourth: the high digit in bits 3-0 (RRA).
5740
GOSUB to 5744H to send the high digit in bits 3-0 of Register A.
5743
POP AF F1
Restore Register Pair AF, the byte in Register A, from the top of the stack, and fall into 5744H for the low digit.
5744
AND 0FH E6 0F
AND Register A with 0FH, keeping the digit in bits 3-0.
5746
ADD A,90H C6 90
ADD 90H to Register A, the first step of the DAA method for a hexadecimal digit.
5748
DAA 27
Decimal adjust Register A (DAA): 90H-99H for 0-9, or 00H-05H with the C FLAG for 0AH-0FH.
5749
ADC A,40H CE 40
ADD 40H and the C FLAG to Register A (ADC), the third step of the DAA method.
574B
DAA 27
Decimal adjust Register A (DAA): the character 0-9 or A-F of the digit.
574C
JUMP to 56FBH to send the digit, which returns to the caller.
574F
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the number before its first digit.
5752
GOSUB to 571AH for the next character of the line after any spaces; the C FLAG at the end of the line.
5755
RET C D8
If the C FLAG is set (the end), RETurn to the caller with the number in Register Pair BC.
5756
SUB 30H D6 30
SUBtract 30H from Register A, the character 0: the C FLAG below it.
5758
If the C FLAG is set (not a digit), JUMP to 578CH for the error 7, Parameter error.
575B
CP 0AH FE 0A
Compare Register A against 0AH: the C FLAG for 0-9.
575D
If the C FLAG is set (0-9), JUMP to 576DH to add the digit.
575F
RES 5,A CB AF
Reset bit 5 of Register A: a lower case letter becomes upper case.
5761
SUB 07H D6 07
SUBtract 07H from Register A: A-F become 0AH-0FH.
5763
CP 0AH FE 0A
Compare Register A against 0AH: the C FLAG for the characters between 9 and A.
5765
If the C FLAG is set (not a digit), JUMP to 578CH for the error 7, Parameter error.
5768
CP 10H FE 10
Compare Register A against 10H: the NC FLAG past F.
576A
If the NC FLAG is set (not a digit), JUMP to 578CH for the error 7, Parameter error.
576D
PUSH HL E5
Save Register Pair HL, the place in the line, to the top of the stack.
576E
LD H,B 60
Load Register H with Register B, the high byte of the number.
576F
LD L,C 69
Load Register L with Register C: Register Pair HL = the number so far.
5770
ADD HL,HL 29
ADD Register Pair HL to itself, the first of four doublings (ADD HL,HL).
5771
ADD HL,HL 29
ADD Register Pair HL to itself, the second of four doublings (ADD HL,HL).
5772
ADD HL,HL 29
ADD Register Pair HL to itself, the third of four doublings (ADD HL,HL).
5773
ADD HL,HL 29
ADD Register Pair HL to itself, the fourth: 16 times the number, the top digit lost (ADD HL,HL).
5774
LD B,H 44
Load Register B with Register H, the high byte of the new number.
5775
ADD A,L 85
ADD Register L to Register A, the value of the digit.
5776
LD C,A 4F
Load Register C with Register A: Register Pair BC = 16 times the number plus the digit.
5777
POP HL E1
Restore Register Pair HL, the place in the line, from the top of the stack.
5778
JUMP to 5752H for the next digit of the number.

577AH - The Errors

TAPE's own seven messages, numbered by Register E: 577AH Invalid command (1), and inside the LD BC instructions after it 577DH Checksum error (2), 5780H Bad filename (3), 5783H Non program file (4), 5786H File area full (5), 5789H Buffer area full (6), 578CH Parameter error (7). 578EH finds message Register E in the table at 5859H (each starts with a byte with bit 7 set) and shows it; a DOS error goes to ERROR@ (57ABH) with bits 7 and 6 set; both return to the command loop. 57B3H is the BREAK vector during cassette work.

577A
LD E,01H 1E 01
Load Register E with 01H, the number of the message Invalid command, and fall into the LD BC below.
577C
LD BC,021EH 01 1E 02
577DH enters inside this LD BC,021EH: its bytes 1EH 02H read as LD E,02H, Checksum error; from above it only loads Register Pair BC.
577F
LD BC,031EH 01 1E 03
5780H enters inside this LD BC,031EH: its bytes 1EH 03H read as LD E,03H, Bad filename; from above it only loads Register Pair BC.
5782
LD BC,041EH 01 1E 04
5783H enters inside this LD BC,041EH: its bytes 1EH 04H read as LD E,04H, Non program file; from above it only loads Register Pair BC.
5785
LD BC,051EH 01 1E 05
5786H enters inside this LD BC,051EH: its bytes 1EH 05H read as LD E,05H, File area full; from above it only loads Register Pair BC.
5788
LD BC,061EH 01 1E 06
5789H enters inside this LD BC,061EH: its bytes 1EH 06H read as LD E,06H, Buffer area full; from above it only loads Register Pair BC.
578B
LD BC,071EH 01 1E 07
578CH enters inside this LD BC,071EH: its bytes 1EH 07H read as LD E,07H, Parameter error; from above it only loads Register Pair BC.
578E
LD HL,5859H 21 59 58
Point Register Pair HL to 5859H, the table of TAPE's messages.
5791
LD A,(HL) 7E
Load Register A with the next byte of the table at Register Pair HL.
5792
INC HL 23
INCrement Register Pair HL by 1, to the byte after it.
5793
OR A B7
OR Register A with itself: the M FLAG for a byte with bit 7 set, the start of a message.
5794
If the P FLAG is set (bit 7 clear), JUMP to 5791H for the next byte.
5797
DEC E 1D
DECrement Register E by 1, one message start passed: the Z FLAG at the message wanted.
5798
If the NZ FLAG is set (not yet), JUMP to 5791H for the next byte.
579A
AND 7FH E6 7F
AND Register A with 7FH, clearing bit 7 of the message's first character.
579C
GOSUB to 56FBH to send the character in Register A.
579F
LD A,(HL) 7E
Load Register A with the next character of the message at Register Pair HL.
57A0
INC HL 23
INCrement Register Pair HL by 1, to the character after it.
57A1
OR A B7
OR Register A with itself: the M FLAG for the start of the next message.
57A2
If the P FLAG is set (a character of this message), JUMP to 579AH to send it.
57A5
GOSUB to 56F9H to end the message with a carriage return.
57A8
JUMP to 5212H, the command loop, after TAPE's own error message.
57AB
OR C0H F6 C0
OR Register A with C0H, setting bits 7 and 6: ERROR@ returns, and shows the message without the frame of asterisks.
57AD
GOSUB to 4409H, ERROR@, to show the message of the error code in Register A.
57B0
JUMP to 5212H, the command loop, after the DOS error.
57B3
GOSUB to 01F8H, the ROM's routine that turns the cassette motor off, after BREAK.
57B6
JUMP to 5212H, the command loop, after BREAK.

57B9H - The Two Loaders

Each is a record for the store, 28 bytes: the mark 03H (bit 0 set, so S and W write it as a block), its address, the count 17H and 23 bytes of code, then 02H. The code turns the interrupts off, makes the RST 38H vector a RET, calls the ROM's 0069H, which sets all I/O drivers back to the ROM's, moves the program from the copy to its own addresses and jumps to its transfer address. 57B9H moves it down from the top (LDDR), for an offset below 0000H; 57D5H from the bottom (LDIR).

57B9
DEFB 03H 03
The mark of the loader's block in the store, which S and W take as a block (bit 0 set).
57BA-57BB
DEFW 0000H 00 00
The address of the loader, set at 56AEH: 17H bytes below the program area.
57BC
DEFB 17H 17
The count of the loader's bytes, 23, the code that follows.
57BD
DI F3
Turn the maskable interrupts off (DI), so no DOS task runs while the program is moved.
57BE
LD A,C9H 3E C9
Load Register A with C9H, the opcode of RET, for the RST 38H vector.
57C0
LD (4012H),A 32 12 40
Store Register A (C9H) into 4012H, the RST 38H vector: an interrupt now returns at once.
57C3
GOSUB to 0069H, the ROM's routine that sets all I/O drivers back to the ROM's own.
57C6
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand 57C7H-57C8H set to the last address of the moved copy.
57C9
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 57CAH-57CBH set to the last address of the program area.
57CC
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the operand 57CDH-57CEH set to the length of the program area.
57CF
LDDR ED B8
Copy the program to its own place from the top down: Register Pair BC bytes from Register Pair HL to Register Pair DE (LDDR).
57D1
JUMP to the program's transfer address, the operand 57D2H-57D3H (0000H as loaded).
57D4
DEFB 02H 02
The mark of the end of the loader's program in the store.
57D5
DEFB 03H 03
The mark of the loader's block in the store, which S and W take as a block (bit 0 set).
57D6-57D7
DEFW 0000H 00 00
The address of the loader, set at 56D2H: the address after the program area.
57D8
DEFB 17H 17
The count of the loader's bytes, 23, the code that follows.
57D9
DI F3
Turn the maskable interrupts off (DI), so no DOS task runs while the program is moved.
57DA
LD A,C9H 3E C9
Load Register A with C9H, the opcode of RET, for the RST 38H vector.
57DC
LD (4012H),A 32 12 40
Store Register A (C9H) into 4012H, the RST 38H vector: an interrupt now returns at once.
57DF
GOSUB to 0069H, the ROM's routine that sets all I/O drivers back to the ROM's own.
57E2
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the operand 57E3H-57E4H set to the start of the moved copy.
57E5
LD DE,0000H 11 00 00
Load Register Pair DE with 0000H, the operand 57E6H-57E7H set to the start of the program area.
57E8
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the operand 57E9H-57EAH set to the length of the program area.
57EB
LDIR ED B0
Copy the program to its own place from the bottom up: Register Pair BC bytes from Register Pair HL to Register Pair DE (LDIR).
57ED
JUMP to the program's transfer address, the operand 57EEH-57EFH (0000H as loaded).
57F0
DEFB 02H 02
The mark of the end of the loader's program in the store.

57F1H - The Texts and the Variables

Data: the heading, the texts of the map, the table of the messages (the first character of each with bit 7 set, an 80H after the last). 58C0H on is not loaded: the variables, the name, the file control block, the line, the names table, the buffer and the store.

57F1-5818
DEFM "TAPE - DOSPLUS Disk/tape manager - 3.50" / DEFB 0DH 54 41 50 45 20 2D 20 44 4F 53 50 4C 55 53 20 44 69 73 6B 2F 74 61 70 65 20 6D 61 6E 61 67 65 72 20 2D 20 33 2E 35 30 0D
The heading (520CH): TAPE - DOSPLUS Disk/tape manager - 3.50 and a carriage return.
5819-5848
DEFM "(c) Copyright 1983, Micro-Systems Software Inc." / DEFB 0DH 28 63 29 20 43 6F 70 79 72 69 67 68 74 20 31 39 38 33 2C 20 4D 69 63 72 6F 2D 53 79 73 74 65 6D 73 20 53 6F 66 74 77 61 72 65 20 49 6E 63 2E 0D
The copyright line and a carriage return after the heading.
5849-584A
DEFB 0AH,00H 0A 00
A line feed, and the 00H that ends the heading for 570DH.
584B-5850
DEFM "XFER=" / DEFB 00H 58 46 45 52 3D 00
The text before the transfer address in the map (5370H).
5851-5858
DEFM "OFFSET=" / DEFB 00H 4F 46 46 53 45 54 3D 00
The text before the offset in the map (5381H).
5859-5867
DEFB C9H / DEFM "nvalid command" C9 6E 76 61 6C 69 64 20 63 6F 6D 6D 61 6E 64
Message 1, Invalid command: an unknown letter (577AH).
5868-5875
DEFB C3H / DEFM "hecksum error" C3 68 65 63 6B 73 75 6D 20 65 72 72 6F 72
Message 2, Checksum error: a block of a tape read badly (577DH).
5876-5881
DEFB C2H / DEFM "ad filename" C2 61 64 20 66 69 6C 65 6E 61 6D 65
Message 3, Bad filename: a name too long or not a file specification (5780H).
5882-5891
DEFB CEH / DEFM "on program file" CE 6F 6E 20 70 72 6F 67 72 61 6D 20 66 69 6C 65
Message 4, Non program file: a record type of 20H or more (5783H).
5892-589F
DEFB C6H / DEFM "ile area full" C6 69 6C 65 20 61 72 65 61 20 66 75 6C 6C
Message 5, File area full: ten programs in memory already (5786H).
58A0-58AF
DEFB C2H / DEFM "uffer area full" C2 75 66 66 65 72 20 61 72 65 61 20 66 75 6C 6C
Message 6, Buffer area full: fewer than 300 bytes left below HMEM$ (5789H).
58B0-58BE
DEFB D0H / DEFM "arameter error" D0 61 72 61 6D 65 74 65 72 20 65 72 72 6F 72
Message 7, Parameter error: anything else wrong in the line (578CH).
58BF
DEFB 80H 80
The byte with bit 7 set that ends the last message.
58C0
DEFS 1
The printer flag (5216H, 5362H): 00H the display, FFH the printer.
58C1
DEFS 1
The count of programs in memory, 0-10 (5344H, 54C9H).
58C2-58C3
DEFS 2
The transfer address of the last program read (533DH, 54C2H).
58C4-58C5
DEFS 2
The offset (5430H) added to every address written.
58C6
DEFS 1
The programs to write, with the loader one more (54D4H, 56E8H).
58C7-58C8
DEFS 2
The end of the store of the programs (52B9H, 533AH).
58C9-58CA
DEFS 2
The address after the highest block (5640H), for the loader.
58CB-58CC
DEFS 2
The lowest address of the blocks (5644H), for the loader.
58CD-58CE
DEFS 2
The transfer address to write (54DBH, 56B1H).
58CF-58E7
DEFS 25
The name of the file or tape for S or W (54E1H, 5582H).
58E8-5907
DEFS 32
TAPE's file control block for L and S (52DEH, 54FFH).
5908-5947
DEFS 64
The command line typed after the asterisk prompt (5220H).
5948-5A41
DEFS 250
The names table: 25 bytes for each of the ten programs (52CEH).
5A42-5B41
DEFS 256
The 256 byte buffer of the disk file of L and S (52E9H, 550AH).
5B42
DEFS 1
The start of the store of the programs, which grows up to 300 bytes below HMEM$ (52B6H).