4E00H - Function Dispatcher
SYS0/SYS's overlay call (4BFBH) enters SYS1/SYS here with Register A = the RST 28H code whose bits 0-3 are 3. Bits 4-6 select the function: 10H (code 93H, DOS READY from 4400H and 402DH) and 20H (code A3H, the exit after an error at 4030H) both go to the command prompt, 30H (B3H, 4405H) runs the command at Register Pair HL, 40H (C3H, 441CH) parses a filespec, 50H (D3H, 4473H) adds a default extension and 60H (E3H, 4476H) parses a parameter list. Register Pair BC, Register Pair DE and Register Pair HL are the caller's.
4E00
AND 70H E6 70
AND Register A (the RST 28H code) with 70H, keeping bits 4-6, the function number.
4E02
CP 10H FE 10
Compare Register A (the function) against 10H, DOS READY (code 93H).
4E04
If the Z FLAG is set (10H), JUMP to 4E1FH, the command prompt.
4E07
CP 20H FE 20
Compare Register A (the function) against 20H, the exit after an error (code A3H from 4030H).
4E09
If the Z FLAG is set (20H), JUMP to 4E1FH, the same command prompt.
4E0B
CP 30H FE 30
Compare Register A (the function) against 30H, run a command line (code B3H from 4405H).
4E0D
If the Z FLAG is set (30H), JUMP to 4E4EH with Register Pair HL = the command text.
4E0F
CP 40H FE 40
Compare Register A (the function) against 40H, parse a filespec (code C3H from 441CH).
4E11
If the Z FLAG is set (40H), JUMP to 4F56H with Register Pair HL = the text and Register Pair DE = the FCB.
4E14
CP 50H FE 50
Compare Register A (the function) against 50H, add a default extension (code D3H from 4473H).
4E16
If the Z FLAG is set (50H), JUMP to 4FC0H with Register Pair HL = the extension and Register Pair DE = the FCB.
4E19
CP 60H FE 60
Compare Register A (the function) against 60H, parse a parameter list (code E3H from 4476H).
4E1B
If the Z FLAG is set (60H), JUMP to 507DH with Register Pair HL = the text and Register Pair DE = the parameter table.
4E1E
RET C9
RETURN to SYS0/SYS (4BFEH) for any other function number, doing nothing.
4E1FH - DOS READY: the Command Prompt
Entered for functions 10H and 20H and from the DEBUG command (5181H). Interrupts are enabled and the stack is reset to 41FCH. The BIT tests at 4E26H-4E34H work on the byte whose address is the word at 430FH-4310H (the system flags and the spare byte 4310H, 00H): with 430FH = 01H they read the ROM's byte at 0001H (AFH), which arms the BREAK vector at 4315H and makes a held BREAK key exit through 4030H; with 11H (SYS6/SYS in memory) the byte at 0011H (03H) does neither. Then DOS READY is displayed and a command line of up to 63 characters is read into 4318H.
4E1F
EI FB
Enable interrupts (EI). SYS0/SYS's start-up code leaves them disabled, so the clock and the timer tasks start running from here. 4E04H and 4E09H come here; 5181H jumps here.
4E20
LD SP,41FCH 31 FC 41
Set the Stack Pointer to 41FCH, dropping whatever the last command left on the stack.
4E23
LD HL,4359H 21 59 43
Point Register Pair HL to 4359H, the second byte of the keyboard control block copy (the low byte of the driver address, D8H).
4E26
BIT 5,(HL) CB 6E
Test bit 5 of (HL) (Register Pair HL = 4359H). The result is not used: the BIT at 4E2BH sets the flags again before any test.
4E28
LD HL,(430FH) 2A 0F 43
Fetch the word at 430FH-4310H into Register Pair HL: Register L = the system flags (430FH), Register H = the spare byte 4310H (00H). Register Pair HL is used as an address in the ROM (0001H, 0011H, 0081H or 0091H for the flag values 01H, 11H, 81H and 91H).
4E2B
BIT 7,(HL) CB 7E
Test bit 7 of (HL) (Register Pair HL = the address taken from 430FH-4310H): set for the ROM byte at 0001H (AFH) and 0081H (E5H), clear for 0011H (03H) and 0091H (06H).
4E2D
If the Z FLAG is set (bit 7 clear), JUMP to 4E34H without arming the BREAK vector.
4E2F
LD A,C3H 3E C3
Load Register A with C3H, the opcode of JP, for the first byte of the BREAK vector at 4315H.
4E31
LD (4315H),A 32 15 43
Store Register A (C3H) into 4315H, arming SYS0/SYS's BREAK vector: BREAK during a clock interrupt now leaves through the address in 4316H-4317H (400FH after the DEBUG command has run).
4E34
BIT 5,(HL) CB 6E
Test bit 5 of (HL) (Register Pair HL = the same ROM address): set for 0001H (AFH) and 0081H (E5H). 4E2DH comes here.
4E36
If the Z FLAG is set (bit 5 clear), JUMP to 4E40H without looking at the BREAK key.
4E38
LD A,(3840H) 3A 40 38
Fetch keyboard row 6 from 3840H into Register A (ENTER, CLEAR, BREAK, the arrows, SPACE).
4E3B
AND 04H E6 04
AND Register A (keyboard row 6) with 04H, keeping bit 2, the BREAK key.
4E3D
If the NZ FLAG is set (BREAK is down), JUMP to 4030H, the exit after an error (DEBUG when SYS1/SYS's DEBUG command has made 4030H a CALL 400FH).
4E40
LD HL,51B8H 21 B8 51
Point Register Pair HL to 51B8H, the message line feed, DOS READY, ENTER. 4E36H comes here.
4E43
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (51B8H) up to its 0DH.
4E46
LD HL,4318H 21 18 43
Point Register Pair HL to 4318H, SYS0/SYS's command line buffer.
4E49
LD B,3FH 06 3F
Load Register B with 3FH: at most 63 characters may be typed.
4E4B
GOSUB to ROM routine at 0040H to read a line of up to Register B (63) characters into the buffer at Register Pair HL (4318H), ended by ENTER (0DH). Register Pair HL is returned pointing to the start of the line; the CARRY FLAG, which the ROM sets when the line was ended with BREAK, is not tested, and execution falls into 4E4EH to run the line.
4E4EH - Run a Command Line
Entered from 4E4BH and for function 30H (4405H: the AUTO command, BASIC/CMD). Register Pair HL = the command text. The first word is parsed as a filespec into the command FCB at 4480H. A name in the first table (BASIC2, DEBUG, TRACE) runs its handler here; a name in the second table (the library commands) runs SYS6/SYS with the command's number in Register C; any other name is run as a program with the default extension /CMD. Every command returns to 402DH (DOS READY).
4E4E
LD BC,402DH 01 2D 40
Load Register Pair BC with 402DH, the DOS READY exit. 4E0DH comes here.
4E51
PUSH BC C5
Save Register Pair BC (402DH) onto the stack: the address every command returns to.
4E52
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, SYS0/SYS's command FCB.
4E55
GOSUB to 4F56H to parse the word at Register Pair HL into the FCB at Register Pair DE (4480H); Register Pair HL is left after it.
4E58
If the NZ FLAG is set (the word is not a valid filespec), JUMP to 4E87H to display WHAT?.
4E5B
LD A,(DE) 1A
Fetch the first character of the parsed name from (DE) (Register Pair DE = 4480H) into Register A.
4E5C
CP 2AH FE 2A
Compare Register A against 2AH, the asterisk that starts a device name.
4E5E
If the Z FLAG is set (a device name), JUMP to 4E87H: a device is not a command.
4E61
PUSH HL E5
Save Register Pair HL (the command line after the name) onto the stack.
4E62
LD BC,4EA4H 01 A4 4E
Point Register Pair BC to 4EA4H, the first command table (BASIC2, DEBUG, TRACE).
4E65
GOSUB to 502AH to look up the name at Register Pair DE (4480H) in the table at Register Pair BC; on a match it returns the Z FLAG, Register Pair DE = the entry's handler and Register C = the entry number.
4E68
If the Z FLAG is set (found), JUMP to 4E84H to run the handler.
4E6A
LD BC,4EBDH 01 BD 4E
Point Register Pair BC to 4EBDH, the second command table (the nineteen library commands).
4E6D
GOSUB to 502AH to look up the name at Register Pair DE (4480H) in the table at Register Pair BC.
4E70
If the Z FLAG is set (found: Register Pair DE = 4E90H, Register C = 1-19), JUMP to 4E84H.
4E72
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A.
4E75
RES 4,A CB A7
Reset bit 4 of Register A (the system flags): the program about to be loaded at 5200H will overwrite SYS6/SYS.
4E77
LD (430FH),A 32 0F 43
Store Register A (the system flags) back into 430FH.
4E7A
LD HL,51B5H 21 B5 51
Point Register Pair HL to 51B5H, the default extension CMD.
4E7D
GOSUB to 4FC0H to add /CMD to the filespec in the FCB at Register Pair DE (4480H) when it has no extension.
4E80
POP HL E1
Restore Register Pair HL (the command line after the program name) from the stack, for the program to read its parameters.
4E81
JUMP to SYS0/SYS's 4433H to load and run the program in the FCB at Register Pair DE (4480H); it returns to 402DH, which is on the stack.
4E84
POP HL E1
Restore Register Pair HL (the command line after the name) from the stack. 4E68H and 4E70H come here.
4E85
PUSH DE D5
Save Register Pair DE (the handler address from the table) onto the stack.
4E86
RET C9
RETURN, which jumps to the handler with Register Pair HL = the rest of the command line, Register C = the entry number and 402DH on the stack.
4E87
LD HL,51C3H 21 C3 51
Point Register Pair HL to 51C3H, the message WHAT? and ENTER. 4E58H and 4E5EH come here.
4E8A
GOSUB to SYS0/SYS's 4467H to display the text at Register Pair HL (51C3H).
4E8D
JUMP to 4030H, the exit after an error (back to DOS READY, or DEBUG when it is on).
4E90H - Run a Library Command (SYS6/SYS)
The handler of every entry of the second table. Register C = the command number (1 APPEND ... 19 VERIFY). When bit 4 of the system flags at 430FH shows SYS6/SYS is already at 5200H it is entered directly; otherwise the bit is set and SYS6/SYS is loaded through RST 28H code 88H (overlay 8), whose transfer address 5200H dispatches on Register C.
4E90
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A.
4E93
BIT 4,A CB 67
Test bit 4 of Register A (the system flags): set while SYS6/SYS is in memory at 5200H.
4E95
JP NZ,5200H C2 00 52
If the NZ FLAG is set (SYS6/SYS is there), JUMP to 5200H, its command dispatcher, with Register C = the command number.
4E98
LD A,(430FH) 3A 0F 43
Fetch the system flags from 430FH into Register A again.
4E9B
SET 4,A CB E7
Set bit 4 of Register A: SYS6/SYS will be in memory from now on.
4E9D
LD (430FH),A 32 0F 43
Store Register A (the system flags) back into 430FH.
4EA0
LD A,88H 3E 88
Load Register A with 88H: overlay 8 (SYS6/SYS, directory sector 2, entry 1), function 0.
4EA2
PUSH AF F5
Save Register Pair AF (Register A = 88H) onto the stack. Nothing in SYS1/SYS takes this word back; SYS6/SYS returns through the 402DH it pushes itself.
4EA3
RST 28H EF
Execute RST 28H with Register A = 88H: SYS0/SYS loads SYS6/SYS into 5200H and calls 5200H with Register C (the command number) unchanged.
4EA4H - First Command Table
Eight bytes per entry: the command name padded with spaces to six characters, then the handler address. A 00H byte ends the table. 502AH returns the handler in Register Pair DE and the entry number in Register C.
4EA4-4EAB
DEFM "BASIC2" / DEFW 514CH 42 41 53 49 43 32 4C 51
Entry 1: BASIC2
Handler 514CH: leave TRSDOS for the ROM's Level II BASIC.
4EAC-4EB3
DEFM "DEBUG " / DEFW 5162H 44 45 42 55 47 20 62 51
Entry 2: DEBUG
Handler 5162H: DEBUG, DEBUG (ON) or DEBUG (OFF).
4EB4-4EBB
DEFM "TRACE " / DEFW 5191H 54 52 41 43 45 20 91 51
Entry 3: TRACE
Handler 5191H: TRACE (ON) or TRACE (OFF), the program address display in timer slot 11.
4EBC
DEFB 00H 00
End of the First Table
502AH stops at the entry whose first byte is 00H and returns the NZ FLAG.
4EBDH - Second Command Table: the Library Commands
Nineteen entries of eight bytes, all with the handler 4E90H, so the entry number (Register C, 1-19, counted by 502AH) tells SYS6/SYS which command to run. A 00H byte ends the table.
4EBD-4EC4
DEFM "APPEND" / DEFW 4E90H 41 50 50 45 4E 44 90 4E
Entry 1: APPEND
SYS6/SYS command number 1 (Register C = 01H).
4EC5-4ECC
DEFM "ATTRIB" / DEFW 4E90H 41 54 54 52 49 42 90 4E
Entry 2: ATTRIB
SYS6/SYS command number 2 (Register C = 02H).
4ECD-4ED4
DEFM "AUTO " / DEFW 4E90H 41 55 54 4F 20 20 90 4E
Entry 3: AUTO
SYS6/SYS command number 3 (Register C = 03H).
4ED5-4EDC
DEFM "CLOCK " / DEFW 4E90H 43 4C 4F 43 4B 20 90 4E
Entry 4: CLOCK
SYS6/SYS command number 4 (Register C = 04H); SYS6/SYS's 52C5H puts the time display task 4CA9H into timer slot 6.
4EDD-4EE4
DEFM "COPY " / DEFW 4E90H 43 4F 50 59 20 20 90 4E
Entry 5: COPY
SYS6/SYS command number 5 (Register C = 05H).
4EE5-4EEC
DEFM "DATE " / DEFW 4E90H 44 41 54 45 20 20 90 4E
Entry 6: DATE
SYS6/SYS command number 6 (Register C = 06H).
4EED-4EF4
DEFM "DEVICE" / DEFW 4E90H 44 45 56 49 43 45 90 4E
Entry 7: DEVICE
SYS6/SYS command number 7 (Register C = 07H); SYS6/SYS's 531DH lists the device names at 43C0H.
4EF5-4EFC
DEFM "DIR " / DEFW 4E90H 44 49 52 20 20 20 90 4E
Entry 8: DIR
SYS6/SYS command number 8 (Register C = 08H).
4EFD-4F04
DEFM "DUMP " / DEFW 4E90H 44 55 4D 50 20 20 90 4E
Entry 9: DUMP
SYS6/SYS command number 9 (Register C = 09H).
4F05-4F0C
DEFM "FREE " / DEFW 4E90H 46 52 45 45 20 20 90 4E
Entry 10: FREE
SYS6/SYS command number 10 (Register C = 0AH).
4F0D-4F14
DEFM "KILL " / DEFW 4E90H 4B 49 4C 4C 20 20 90 4E
Entry 11: KILL
SYS6/SYS command number 11 (Register C = 0BH).
4F15-4F1C
DEFM "LIB " / DEFW 4E90H 4C 49 42 20 20 20 90 4E
Entry 12: LIB
SYS6/SYS command number 12 (Register C = 0CH).
4F1D-4F24
DEFM "LIST " / DEFW 4E90H 4C 49 53 54 20 20 90 4E
Entry 13: LIST
SYS6/SYS command number 13 (Register C = 0DH).
4F25-4F2C
DEFM "LOAD " / DEFW 4E90H 4C 4F 41 44 20 20 90 4E
Entry 14: LOAD
SYS6/SYS command number 14 (Register C = 0EH).
4F2D-4F34
DEFM "PRINT " / DEFW 4E90H 50 52 49 4E 54 20 90 4E
Entry 15: PRINT
SYS6/SYS command number 15 (Register C = 0FH).
4F35-4F3C
DEFM "PROT " / DEFW 4E90H 50 52 4F 54 20 20 90 4E
Entry 16: PROT
SYS6/SYS command number 16 (Register C = 10H).
4F3D-4F44
DEFM "RENAME" / DEFW 4E90H 52 45 4E 41 4D 45 90 4E
Entry 17: RENAME
SYS6/SYS command number 17 (Register C = 11H).
4F45-4F4C
DEFM "TIME " / DEFW 4E90H 54 49 4D 45 20 20 90 4E
Entry 18: TIME
SYS6/SYS command number 18 (Register C = 12H).
4F4D-4F54
DEFM "VERIFY" / DEFW 4E90H 56 45 52 49 46 59 90 4E
Entry 19: VERIFY
SYS6/SYS command number 19 (Register C = 13H).
4F55
DEFB 00H 00
End of the Second Table
502AH stops at the entry whose first byte is 00H and returns the NZ FLAG.
4F56H - Parse a File Specification (441CH)
Register Pair HL = the text, Register Pair DE = the FCB. Copies NAME/EXT.PASSWORD:D into the FCB as text: up to 8 letters or digits for the name, then optionally a slash and up to 3 for the extension, a period and up to 8 for the password, a colon and 1 for the drive, in that order, and puts 03H after the last field. A name that is empty but starts with an asterisk is a device name: the asterisk and up to 2 characters. When the name is TO, ON or OVER (table 4FA7H) the next word is parsed into the same FCB instead. Returns Register A = 00H and the Z FLAG with Register Pair HL past the delimiter that ended the filespec, or the NZ FLAG for an empty field.
4F56
PUSH DE D5
Save Register Pair DE (the start of the FCB) onto the stack. 4E11H and 4E55H come here; 4F94H loops back here after a noise word.
4F57
LD B,08H 06 08
Load Register B with 08H: the name has at most 8 characters.
4F59
GOSUB to 4FF4H to copy the name from Register Pair HL to Register Pair DE; Register A returns the character that ended it and the Z FLAG is set when at least one character was copied.
4F5C
If the NZ FLAG is set (no name), JUMP to 4F98H to see whether it is a device name (asterisk).
4F5E
CP 2FH FE 2F
Compare Register A (the character that ended the name) against 2FH, the slash before an extension.
4F60
If the NZ FLAG is set (no extension), JUMP to 4F6BH.
4F62
LD (DE),A 12
Store the slash (Register A) into the FCB at (DE) (Register Pair DE = the position after the name, where 4FF4H put 03H).
4F63
INC DE 13
INCrement Register Pair DE (the FCB pointer) by 1.
4F64
LD B,03H 06 03
Load Register B with 03H: the extension has at most 3 characters.
4F66
GOSUB to 4FF4H to copy the extension from Register Pair HL to Register Pair DE.
4F69
If the NZ FLAG is set (a slash with no extension), JUMP to 4FA5H to return the NZ FLAG.
4F6B
CP 2EH FE 2E
Compare Register A (the character that ended the last field) against 2EH, the period before a password. 4F60H comes here.
4F6D
If the NZ FLAG is set (no password), JUMP to 4F78H.
4F6F
LD (DE),A 12
Store the period (Register A) into the FCB at (DE) (Register Pair DE = the position after the last field).
4F70
INC DE 13
INCrement Register Pair DE (the FCB pointer) by 1.
4F71
LD B,08H 06 08
Load Register B with 08H: the password has at most 8 characters.
4F73
GOSUB to 4FF4H to copy the password from Register Pair HL to Register Pair DE.
4F76
If the NZ FLAG is set (a period with no password), JUMP to 4FA5H.
4F78
CP 3AH FE 3A
Compare Register A (the character that ended the last field) against 3AH, the colon before a drive number. 4F6DH comes here.
4F7A
If the NZ FLAG is set (no drive), JUMP to 4F85H to finish.
4F7C
LD (DE),A 12
Store the colon (Register A) into the FCB at (DE) (Register Pair DE = the position after the last field).
4F7D
INC DE 13
INCrement Register Pair DE (the FCB pointer) by 1.
4F7E
LD B,01H 06 01
Load Register B with 01H: the drive is one character.
4F80
GOSUB to 4FF4H to copy the drive number from Register Pair HL to Register Pair DE.
4F83
If the NZ FLAG is set (a colon with no drive), JUMP to 4FA5H.
4F85
LD C,A 4F
Copy the character that ended the filespec from Register A into Register C. 4F7AH and 4FA3H come here.
4F86
LD A,03H 3E 03
Load Register A with 03H, the end mark of a filespec.
4F88
LD (DE),A 12
Store Register A (03H) into the FCB at (DE) (Register Pair DE = the position after the last field).
4F89
XOR A AF
Set Register A to ZERO and clear all flags, which also clears the CARRY FLAG; Register A is reloaded next.
4F8A
LD A,C 79
Copy the character that ended the filespec from Register C back into Register A.
4F8B
POP DE D1
Restore Register Pair DE (the start of the FCB) from the stack.
4F8C
PUSH DE D5
Save Register Pair DE (the start of the FCB) onto the stack again.
4F8D
LD BC,4FA7H 01 A7 4F
Point Register Pair BC to 4FA7H, the table of noise words TO, ON and OVER.
4F90
GOSUB to 502AH to look up the name at Register Pair DE in the table at Register Pair BC (it changes Register Pair DE on a match).
4F93
POP DE D1
Restore Register Pair DE (the start of the FCB) from the stack.
4F94
If the Z FLAG is set (the word was TO, ON or OVER), LOOP BACK to 4F56H to parse the next word from Register Pair HL into the same FCB.
4F96
XOR A AF
Set Register A to ZERO and clear all flags: a filespec was parsed.
4F97
RET C9
RETURN with Register A = 00H, the Z FLAG and Register Pair HL past the filespec.
4F98
CP 2AH FE 2A
No Name: Device Name?
Compare Register A (the character that ended the empty name) against 2AH, the asterisk that starts a device name such as the printer's PR. 4F5CH comes here.
4F9A
If the NZ FLAG is set (not an asterisk), JUMP to 4FA5H to return the NZ FLAG.
4F9C
LD (DE),A 12
Store the asterisk (Register A) into the FCB at (DE) (Register Pair DE = the start of the FCB).
4F9D
INC DE 13
INCrement Register Pair DE (the FCB pointer) by 1.
4F9E
LD B,02H 06 02
Load Register B with 02H: a device name has two characters.
4FA0
GOSUB to 4FF4H to copy the device name from Register Pair HL to Register Pair DE.
4FA3
If the Z FLAG is set (a device name was copied), JUMP to 4F85H to finish.
4FA5
POP DE D1
Restore Register Pair DE (the start of the FCB) from the stack. 4F69H, 4F76H, 4F83H and 4F9AH come here.
4FA6
RET C9
RETURN with the NZ FLAG: the text is not a valid filespec.
4FA7H - Noise Word Table
Words that 4F56H skips, in the same eight-byte layout as the command tables (six characters, then a word that is not used here). A 00H byte ends the table. They let a command read COPY A TO B or RENAME A TO B.
4FA7-4FAE
DEFM "TO " / DEFW 0000H 54 4F 20 20 20 20 00 00
Noise Word 1: TO
The word 0000H is not used; 4F94H only tests the Z FLAG.
4FAF-4FB6
DEFM "ON " / DEFW 0000H 4F 4E 20 20 20 20 00 00
Noise Word 2: ON
Skipped by 4F94H like TO; the word 0000H is not used.
4FB7-4FBE
DEFM "OVER " / DEFW 0000H 4F 56 45 52 20 20 00 00
Noise Word 3: OVER
Skipped by 4F94H like TO; the word 0000H is not used.
4FBF
DEFB 00H 00
End of the Noise Word Table
502AH stops here and returns the NZ FLAG.
4FC0H - Add a Default Extension (4473H)
Register Pair DE = an FCB holding a filespec as text (from 4F56H), Register Pair HL = a three-character extension (51B5H, CMD, for programs). When the name already has a slash, nothing is done. Otherwise the slash and the extension are inserted where the name ends (at a period, colon or 03H), moving the rest of the filespec up four bytes.
4FC0
PUSH DE D5
Save Register Pair DE (the FCB) onto the stack. 4E16H and 4E7DH come here.
4FC1
PUSH HL E5
Save Register Pair HL (the extension) onto the stack.
4FC2
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the FCB.
4FC3
INC HL 23
INCrement Register Pair HL by 1, past the first character of the name.
4FC4
LD B,09H 06 09
Load Register B with 09H: look at no more than nine characters.
4FC6
LD A,(HL) 7E
Loop Start
Fetch the next character of the filespec from (HL) (Register Pair HL = the FCB pointer) into Register A. 4FD6H loops back here.
4FC7
CP 2FH FE 2F
Compare Register A (the filespec character) against 2FH, the slash before an extension.
4FC9
If the Z FLAG is set (the filespec has an extension), JUMP to 4FD8H to return unchanged.
4FCB
If the CARRY FLAG is set (below the slash: a period or the 03H end mark), JUMP to 4FDBH to insert the extension here.
4FCD
CP 3AH FE 3A
Compare Register A against 3AH, one past the digit 9.
4FCF
If the CARRY FLAG is set (a digit), JUMP to 4FD5H to go on.
4FD1
CP 41H FE 41
Compare Register A against 41H, the letter A.
4FD3
If the CARRY FLAG is set (the colon before a drive), JUMP to 4FDBH to insert the extension here.
4FD5
INC HL 23
INCrement Register Pair HL by 1 to the next character of the filespec. 4FCFH comes here.
4FD6
Loop End
DECrement Register B and loop back to 4FC6H while characters are left to look at.
4FD8
POP HL E1
Restore Register Pair HL (the extension) from the stack. 4FC9H comes here.
4FD9
POP DE D1
Restore Register Pair DE (the FCB) from the stack.
4FDA
RET C9
RETURN to the caller with the filespec in the FCB unchanged, because it already has an extension.
4FDB
LD BC,000FH 01 0F 00
Load Register Pair BC with 000FH. 4FCBH and 4FD3H come here with Register Pair HL = where the name ends.
4FDE
ADD HL,BC 09
ADD Register Pair BC (000FH) to Register Pair HL: Register Pair HL = the end of the name plus 15, the last byte to move.
4FDF
LD D,H 54
Copy the high byte from Register H into Register D.
4FE0
LD E,L 5D
Copy the low byte from Register L into Register E, so Register Pair DE = the same address.
4FE1
INC DE 13
INCrement Register Pair DE (the destination of the move) by 1: the end of the name plus 16.
4FE2
INC DE 13
INCrement Register Pair DE (the destination of the move) by 1: the end of the name plus 17.
4FE3
INC DE 13
INCrement Register Pair DE (the destination of the move) by 1: the end of the name plus 18.
4FE4
INC DE 13
INCrement Register Pair DE by 1: Register Pair DE = four bytes further on, where that byte goes.
4FE5
INC BC 03
INCrement Register Pair BC by 1, to 0010H: sixteen bytes to move.
4FE6
LDDR ED B8
Move Register Pair BC (sixteen) bytes downward from Register Pair HL to Register Pair DE: the rest of the filespec moves up four bytes. Register Pair HL ends one below the end of the name and Register Pair DE at the end of the name plus 3.
4FE8
POP HL E1
Restore Register Pair HL (the extension, 51B5H) from the stack.
4FE9
INC HL 23
INCrement Register Pair HL (the extension pointer, 51B5H) by 1, to its second character.
4FEA
INC HL 23
INCrement Register Pair HL by 1, to the extension's last character.
4FEB
LD C,03H 0E 03
Load Register C with 03H (Register B is 00H after the LDDR): three characters.
4FED
LDDR ED B8
Move Register Pair BC (three) bytes downward from Register Pair HL (the extension) to Register Pair DE: the extension goes into the end of the name plus 1 to plus 3, and Register Pair DE ends at the end of the name.
4FEF
LD A,2FH 3E 2F
Load Register A with 2FH, the slash that goes in front of the inserted extension.
4FF1
LD (DE),A 12
Store the slash (Register A) into (DE) (Register Pair DE = where the name ended).
4FF2
POP DE D1
Restore Register Pair DE (the FCB) from the stack.
4FF3
RET C9
RETURN to the caller with /EXT inserted into the filespec in the FCB at Register Pair DE.
4FF4H - Copy One Field of a Filespec
Register Pair HL = the text, Register Pair DE = where the field goes, Register B = the most characters to keep. Copies letters and digits, skipping (not storing) any beyond the limit, until a character that is neither: 03H and 0DH end the field without being passed; anything else is passed over and returned as the delimiter. 03H is stored after the field. Returns Register A = the delimiter and the Z FLAG when at least one character was copied (the NZ FLAG for an empty field).
4FF4
LD A,B 78
Copy the field's limit from Register B into Register A. 4F59H, 4F66H, 4F73H, 4F80H, 4FA0H and 5095H call here.
4FF5
LD (5026H),A 32 26 50
Store Register A (the limit, never 00H) into 5026H, the operand of LD A,nn at 5025H: it stays non-zero while nothing has been copied. Self-Modifying Code
4FF8
INC B 04
INCrement Register B by 1, so the DEC at 5013H leaves room for the limit.
4FF9
LD A,(HL) 7E
Loop Start
Fetch the next character from (HL) (Register Pair HL = the text pointer) into Register A. 501CH and 501FH loop back here.
4FFA
CP 03H FE 03
Compare Register A against 03H, the end of a text.
4FFC
If the Z FLAG is set (03H), JUMP to 5021H without passing it.
4FFE
CP 0DH FE 0D
Compare Register A against 0DH, ENTER at the end of a command line.
5000
If the Z FLAG is set (0DH), JUMP to 5021H without passing it.
5002
INC HL 23
INCrement Register Pair HL (the text pointer) by 1, past this character.
5003
CP 30H FE 30
Compare Register A (the character just fetched) against 30H, the digit 0.
5005
If the CARRY FLAG is set (below 0: space, asterisk, comma, period, slash, parentheses ...), JUMP to 5021H: the delimiter.
5007
CP 3AH FE 3A
Compare Register A against 3AH, one past the digit 9.
5009
If the CARRY FLAG is set (a digit), JUMP to 5013H to copy it.
500B
CP 41H FE 41
Compare Register A against 41H, the letter A.
500D
If the CARRY FLAG is set (colon to at-sign), JUMP to 5021H: the delimiter.
500F
CP 5BH FE 5B
Compare Register A against 5BH, one past the letter Z.
5011
If the NO CARRY FLAG is set (above Z), JUMP to 5021H: the delimiter.
5013
DEC B 05
DECrement Register B (room left plus 1) by 1. 5009H comes here for a digit.
5014
If the Z FLAG is set (the field is full), JUMP to 501EH to skip the character.
5016
LD (DE),A 12
Store the character (Register A) into the field at (DE) (Register Pair DE = the field pointer).
5017
XOR A AF
Set Register A to ZERO and clear all flags, giving the 00H to store at 5026H.
5018
LD (5026H),A 32 26 50
Store Register A (00H) into 5026H, the operand of LD A,nn at 5025H: the field is not empty. Self-Modifying Code
501B
INC DE 13
INCrement Register Pair DE (the field pointer) by 1.
501C
LOOP BACK to 4FF9H to fetch and copy the next character of the field.
501E
INC B 04
INCrement Register B by 1, keeping the field full for the next character. 5014H comes here.
501F
Loop End
LOOP BACK to 4FF9H: the extra character has been passed over and not stored.
5021
LD C,A 4F
Copy the delimiter from Register A into Register C. 4FFCH, 5000H, 5005H, 500DH and 5011H come here.
5022
LD A,03H 3E 03
Load Register A with 03H, the end mark stored after every field.
5024
LD (DE),A 12
Store Register A (03H) into (DE) (Register Pair DE = the position after the field).
5025
LD A,00H 3E 00
Load Register A with the operand stored at 5026H: 00H when a character was copied, the limit when none was. Self-Modifying Code
00H in the file.
5027
OR A B7
OR Register A with itself: the Z FLAG is set when the field is not empty.
5028
LD A,C 79
Copy the delimiter from Register C back into Register A (the flags are kept).
5029
RET C9
RETURN with Register A = the delimiter and the Z FLAG for a field with characters.
502AH - Look Up a Name in a Table
Register Pair DE = a name as text ending in 03H or 0DH (an FCB at 4480H or the buffer at 51AFH), Register Pair BC = a table of eight-byte entries (six characters padded with spaces, then a word) ending with a 00H byte. Returns the Z FLAG on a match with Register Pair DE = the entry's word, Register C = the entry number counting from 1 and Register B = the high byte of the entry's address; returns the NZ FLAG with Register Pair DE unchanged when no entry matches. Register Pair HL is preserved. Only the first six characters of the name are compared, so a longer name such as APPENDXY matches APPEND.
502A
PUSH HL E5
Save Register Pair HL (the caller's text pointer) onto the stack. 4E65H, 4E6DH, 4F90H and 50A1H call here.
502B
LD H,B 60
Copy Register B (the high byte of the table address) into Register H.
502C
LD L,C 69
Copy Register C (the low byte of the table address) into Register L: Register Pair HL = the first entry.
502D
LD C,01H 0E 01
Load Register C with 01H, the number of the first entry.
502F
LD A,(DE) 1A
Loop Start
Fetch the first character of the name from (DE) (Register Pair DE = the name) into Register A. 503CH loops back here.
5030
CP (HL) BE
Compare Register A against the first character of the entry at (HL) (Register Pair HL = the entry).
5031
If the Z FLAG is set (the first characters match), JUMP to 5042H to compare the other five.
5033
PUSH BC C5
Save Register Pair BC (Register C = the entry number) onto the stack. 507BH comes here after a partial match.
5034
LD BC,0008H 01 08 00
Load Register Pair BC with 0008H, the length of one entry.
5037
ADD HL,BC 09
ADD Register Pair BC (8) to Register Pair HL: Register Pair HL = the next entry.
5038
POP BC C1
Restore Register Pair BC (Register C = the entry number) from the stack.
5039
INC C 0C
INCrement Register C (the entry number) by 1.
503A
LD A,(HL) 7E
Fetch the first byte of the next entry from (HL) (Register Pair HL = the entry) into Register A.
503B
OR A B7
OR Register A with itself to test for 00H, the end of the table.
503C
Loop End
If the NZ FLAG is set (another entry), LOOP BACK to 502FH.
503E
POP HL E1
Restore Register Pair HL (the caller's text pointer) from the stack.
503F
OR 01H F6 01
OR Register A (00H) with 01H to set the NZ FLAG: not found.
5041
RET C9
RETURN with the NZ FLAG and Register Pair DE unchanged.
5042
LD B,05H 06 05
First Character Matches
Load Register B with 05H, the number of characters left to compare. 5031H comes here.
5044
PUSH HL E5
Save Register Pair HL (the start of the entry) onto the stack.
5045
PUSH DE D5
Save Register Pair DE (the start of the name) onto the stack.
5046
INC DE 13
Loop Start
INCrement Register Pair DE (the name pointer) by 1. 5054H loops back here.
5047
INC HL 23
INCrement Register Pair HL (the entry pointer) by 1.
5048
LD A,(DE) 1A
Fetch the next character of the name from (DE) (Register Pair DE = the name pointer) into Register A.
5049
CP 03H FE 03
Compare Register A against 03H, the end mark of a name.
504B
If the Z FLAG is set (the name has ended), JUMP to 5074H: the entry must have a space here.
504D
CP 0DH FE 0D
Compare Register A (the name character) against 0DH, the ENTER that ends a command line.
504F
If the Z FLAG is set (the name has ended), JUMP to 5074H.
5051
CP (HL) BE
Compare Register A (the name character) against the entry character at (HL) (Register Pair HL = the entry pointer).
5052
If the NZ FLAG is set (they differ), JUMP to 5064H.
5054
Loop End
DECrement Register B (characters left) and LOOP BACK to 5046H until it reaches zero.
5056
POP DE D1
Match
Restore Register Pair DE (the start of the name) from the stack. 5077H comes here.
5057
LD A,C 79
Copy the entry number from Register C into Register A.
5058
POP BC C1
Restore Register Pair BC (the start of the entry) from the stack.
5059
LD HL,0006H 21 06 00
Load Register Pair HL with 0006H, the offset of the entry's word.
505C
ADD HL,BC 09
ADD Register Pair BC (the start of the entry) to Register Pair HL: Register Pair HL = the entry's word.
505D
LD C,A 4F
Copy the entry number from Register A into Register C.
505E
LD E,(HL) 5E
Fetch the low byte of the entry's word from (HL) (Register Pair HL = the entry's word) into Register E.
505F
INC HL 23
INCrement Register Pair HL by 1, to the high byte.
5060
LD D,(HL) 56
Fetch the high byte of the entry's word from (HL) (Register Pair HL = the entry's word plus 1) into Register D.
5061
POP HL E1
Restore Register Pair HL (the caller's text pointer) from the stack.
5062
XOR A AF
Set Register A to ZERO and set the Z FLAG: found.
5063
RET C9
RETURN with the Z FLAG, Register Pair DE = the entry's word and Register C = the entry number.
5064
CP 30H FE 30
Characters Differ
Compare Register A (the name character) against 30H, the digit 0. 5052H comes here.
5066
If the CARRY FLAG is set (below 0, a delimiter), JUMP to 5074H: the name has ended.
5068
CP 3AH FE 3A
Compare Register A against 3AH, one past the digit 9.
506A
If the CARRY FLAG is set (a digit), JUMP to 5079H: a real mismatch.
506C
CP 41H FE 41
Compare Register A against 41H, the letter A.
506E
If the CARRY FLAG is set (colon to at-sign, a delimiter), JUMP to 5074H.
5070
CP 5BH FE 5B
Compare Register A against 5BH, one past the letter Z.
5072
If the CARRY FLAG is set (a letter), JUMP to 5079H: a real mismatch.
5074
LD A,(HL) 7E
Name Ended
Fetch the entry character from (HL) (Register Pair HL = the entry pointer) into Register A. 504BH, 504FH, 5066H and 506EH come here; a character above Z also falls through to here.
5075
CP 20H FE 20
Compare Register A (the entry character) against 20H, the space that pads a shorter entry.
5077
If the Z FLAG is set (the entry ends here too), JUMP to 5056H: a match.
5079
POP DE D1
Mismatch
Restore Register Pair DE (the start of the name) from the stack. 506AH and 5072H come here.
507A
POP HL E1
Restore Register Pair HL (the start of the entry) from the stack.
507B
JUMP to 5033H to step Register Pair HL to the next entry and try it.
507DH - Parse a Parameter List (4476H)
Register Pair HL = the command line after the command, Register Pair DE = a parameter table in the eight-byte layout of 502AH, whose word is the address of a two-byte variable. Reads (NAME=value,NAME,...): each name is looked up and its variable gets the value, FFFFH when there is no equals sign. A value is X followed by hexadecimal digits in quotes, a decimal number, or a word starting with Y, N, ON or OF (YES/NO/ON/OFF give FFFFH or 0000H). Returns the Z FLAG with Register Pair HL past the closing parenthesis, or at the ENTER when there is no list; returns the NZ FLAG for an unknown name or bad text.
507D
LD A,(HL) 7E
Loop Start
Fetch the next character from (HL) (Register Pair HL = the command line) into Register A. 4E1BH jumps here; 508CH loops back here.
507E
CP 0DH FE 0D
Compare Register A (the command line character) against 0DH, the ENTER at the end of the line.
5080
RET Z C8
If the Z FLAG is set (no parameters), RETURN with the Z FLAG.
5081
CP 28H FE 28
Compare Register A against 28H, the opening parenthesis.
5083
If the Z FLAG is set, JUMP to 508EH to read the first parameter.
5085
CP 20H FE 20
Compare Register A (the command line character) against 20H, a space before the list.
5087
If the Z FLAG is set, JUMP to 508BH to pass it.
5089
OR A B7
OR Register A (a character that is not 00H) with itself to set the NZ FLAG.
508A
RET C9
RETURN with the NZ FLAG: something other than a parameter list follows the command.
508B
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the space. 5087H comes here.
508C
Loop End
LOOP BACK to 507DH to look at the next character of the command line.
508E
PUSH DE D5
Next Parameter
Save Register Pair DE (the parameter table) onto the stack. 5083H and 50B9H come here.
508F
LD B,06H 06 06
Load Register B with 06H: a parameter name has at most 6 characters.
5091
LD DE,51AFH 11 AF 51
Point Register Pair DE to 51AFH, the parameter name buffer.
5094
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the parenthesis or comma.
5095
GOSUB to 4FF4H to copy the name from Register Pair HL into the buffer at Register Pair DE (51AFH); a six-character name puts its 03H end mark at 51B5H, over the C of the default extension CMD.
5098
DEC HL 2B
DECrement Register Pair HL by 1, back to the delimiter that ended the name (one character before an ENTER, which 4FF4H does not pass).
5099
POP DE D1
Restore Register Pair DE (the parameter table) from the stack.
509A
RET NZ C0
If the NZ FLAG is set (an empty name), RETURN with the NZ FLAG.
509B
PUSH DE D5
Save Register Pair DE (the parameter table) onto the stack.
509C
LD B,D 42
Copy Register D (the high byte of the parameter table) into Register B.
509D
LD C,E 4B
Copy Register E (the low byte of the parameter table) into Register C: Register Pair BC = the parameter table.
509E
LD DE,51AFH 11 AF 51
Point Register Pair DE to 51AFH, the name just copied.
50A1
GOSUB to 502AH to look up the name; on a match Register Pair DE = the address of the parameter's variable.
50A4
If the Z FLAG is set (a known name), JUMP to 50A8H.
50A6
POP DE D1
Error Exit
Restore Register Pair DE (the parameter table) from the stack. 50D0H and 50D8H come here.
50A7
RET C9
RETURN with the NZ FLAG: an unknown name or a bad value.
50A8
LD A,(HL) 7E
Fetch the character after the name from (HL) (Register Pair HL = the command line pointer) into Register A. 50A4H comes here.
50A9
CP 3DH FE 3D
Compare Register A against 3DH, the equals sign.
50AB
If the Z FLAG is set, JUMP to 50C1H to read the value.
50AD
LD BC,FFFFH 01 FF FF
Load Register Pair BC with FFFFH, the value of a parameter named without a value.
50B0
LD A,C 79
Store the Value
Copy the low byte of the value from Register C into Register A. 50CEH, 50D6H and 50DDH come here.
50B1
LD (DE),A 12
Store Register A (the low byte) into the variable at (DE) (Register Pair DE = the variable's address).
50B2
INC DE 13
INCrement Register Pair DE (the variable pointer) by 1.
50B3
LD A,B 78
Copy the high byte of the value from Register B into Register A.
50B4
LD (DE),A 12
Store Register A (the high byte) into the variable at (DE) (Register Pair DE = the variable's address plus 1).
50B5
POP DE D1
Restore Register Pair DE (the parameter table) from the stack.
50B6
LD A,(HL) 7E
Fetch the character after the value from (HL) (Register Pair HL = the command line pointer) into Register A.
50B7
CP 2CH FE 2C
Compare Register A (the character after the value) against 2CH, a comma before the next parameter.
50B9
If the Z FLAG is set, LOOP BACK to 508EH for the next parameter.
50BB
CP 29H FE 29
Compare Register A against 29H, the closing parenthesis.
50BD
RET NZ C0
If the NZ FLAG is set (neither), RETURN with the NZ FLAG.
50BE
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the closing parenthesis.
50BF
XOR A AF
Set Register A to ZERO and set the Z FLAG: the parameter list was read without an error.
50C0
RET C9
RETURN to the caller with the Z FLAG and Register Pair HL past the list: the list was read.
50C1
INC HL 23
Read a Value
INCrement Register Pair HL (the command line pointer) by 1, past the equals sign. 50ABH comes here.
50C2
LD A,(HL) 7E
Fetch the first character of the value from (HL) (Register Pair HL = the command line pointer) into Register A.
50C3
CP 58H FE 58
Compare Register A against 58H, the letter X before a hexadecimal value.
50C5
If the Z FLAG is set (an X), JUMP to 50D2H to read a quoted hexadecimal value.
50C7
CP 41H FE 41
Compare Register A against 41H, the letter A.
50C9
If the CARRY FLAG is set (below A: a digit), JUMP to 50DAH for a decimal value.
50CB
GOSUB to 50DFH to read YES, NO, ON or OFF into Register Pair BC.
50CE
If the Z FLAG is set (a known word), JUMP to 50B0H to store it.
50D0
JUMP to 50A6H to return the NZ FLAG for an unknown word.
50D2
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the X. 50C5H comes here.
50D3
GOSUB to 511FH to read a quoted hexadecimal value into Register Pair BC.
50D6
If the Z FLAG is set (read), JUMP to 50B0H to store it.
50D8
JUMP to 50A6H to return the NZ FLAG when no quote follows the X.
50DA
GOSUB to 5104H to read a decimal value into Register Pair BC. 50C9H comes here.
50DD
JUMP to 50B0H to store the decimal value in Register Pair BC into the variable.
50DFH - Read YES, NO, ON or OFF
Register Pair HL = the word. Only the first letter is tested for Y and N and the first two for ON and OF. Returns the Z FLAG with Register Pair BC = FFFFH for Y or ON, 0000H for N or OF, and Register Pair HL at the comma or closing parenthesis that follows the word; returns the NZ FLAG with Register Pair BC = 0000H for any other word. The skip loop at 50FAH stops only at a comma or a closing parenthesis, so a list without one is searched past its ENTER into the memory that follows.
50DF
LD BC,0000H 01 00 00
Load Register Pair BC with 0000H, the value of NO and OFF. 50CBH and 51A9H call here.
50E2
LD A,(HL) 7E
Fetch the first letter from (HL) (Register Pair HL = the word) into Register A.
50E3
CP 59H FE 59
Compare Register A against 59H, the letter Y.
50E5
If the Z FLAG is set, JUMP to 50F7H for the value FFFFH.
50E7
CP 4EH FE 4E
Compare Register A against 4EH, the letter N.
50E9
If the Z FLAG is set, JUMP to 50FAH with the value 0000H.
50EB
CP 4FH FE 4F
Compare Register A against 4FH, the letter O.
50ED
RET NZ C0
If the NZ FLAG is set (another letter), RETURN with the NZ FLAG.
50EE
INC HL 23
INCrement Register Pair HL (the word pointer) by 1, to the second letter.
50EF
LD A,(HL) 7E
Fetch the second letter from (HL) (Register Pair HL = the word pointer) into Register A.
50F0
CP 46H FE 46
Compare Register A against 46H, the letter F of OFF.
50F2
If the Z FLAG is set, JUMP to 50FAH with the value 0000H.
50F4
CP 4EH FE 4E
Compare Register A against 4EH, the letter N of ON.
50F6
RET NZ C0
If the NZ FLAG is set (another letter), RETURN with the NZ FLAG.
50F7
LD BC,FFFFH 01 FF FF
Load Register Pair BC with FFFFH, the value of YES and ON. 50E5H comes here.
50FA
INC HL 23
Loop Start
INCrement Register Pair HL (the word pointer) by 1. 50E9H and 50F2H come here; 5102H loops back here.
50FB
LD A,(HL) 7E
Fetch the next character from (HL) (Register Pair HL = the word pointer) into Register A.
50FC
CP 29H FE 29
Compare Register A against 29H, the closing parenthesis.
50FE
RET Z C8
If the Z FLAG is set, RETURN with the Z FLAG and the value in Register Pair BC.
50FF
CP 2CH FE 2C
Compare Register A (the character after the word) against 2CH, a comma.
5101
RET Z C8
If the Z FLAG is set, RETURN with the Z FLAG and the value in Register Pair BC.
5102
Loop End
LOOP BACK to 50FAH to pass the rest of the word.
5104H - Read a Decimal Number
Register Pair HL = the first digit. Returns Register Pair BC = the value of the digits that follow, with Register Pair HL at the first character that is not a digit. A value above 65535 keeps only its low sixteen bits; there is no error return.
5104
LD BC,0000H 01 00 00
Load Register Pair BC (the value) with 0000H. 50DAH calls here.
5107
LD A,(HL) 7E
Loop Start
Fetch the next character from (HL) (Register Pair HL = the text pointer) into Register A. 511DH loops back here.
5108
SUB 30H D6 30
SUBtract 30H from Register A, turning the digits 0-9 into 00H-09H.
510A
RET C D8
If the CARRY FLAG is set (below 0), RETURN with the value in Register Pair BC.
510B
CP 0AH FE 0A
Compare Register A (the character minus 30H) against 0AH, one past the digit 9.
510D
RET NC D0
If the NO CARRY FLAG is set (above 9), RETURN with the value in Register Pair BC.
510E
PUSH HL E5
Save Register Pair HL (the text pointer) onto the stack.
510F
LD H,B 60
Copy Register B (the high byte of the value) into Register H.
5110
LD L,C 69
Copy Register C (the low byte of the value) into Register L: Register Pair HL = the value.
5111
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
5112
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
5113
ADD HL,BC 09
ADD Register Pair BC (the value) to Register Pair HL: the value times 5.
5114
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 10.
5115
LD B,00H 06 00
Load Register B with 00H, the high byte of the digit to add.
5117
LD C,A 4F
Copy the digit from Register A into Register C: Register Pair BC = the digit.
5118
ADD HL,BC 09
ADD Register Pair BC (the digit) to Register Pair HL (the value times 10).
5119
LD B,H 44
Copy Register H (the high byte of the new value) into Register B.
511A
LD C,L 4D
Copy Register L into Register C: Register Pair BC = the new value.
511B
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
511C
INC HL 23
INCrement Register Pair HL (the text pointer) by 1, past the digit.
511D
Loop End
LOOP BACK to 5107H to read the next character of the number.
511FH - Read a Quoted Hexadecimal Number
Register Pair HL = the character after the X. Reads 'digits' with the digits 0-9 and A-F. Returns the Z FLAG with Register Pair BC = the value and Register Pair HL past the closing quote, or the NZ FLAG when no opening quote is there. Any other character also ends the number with the Z FLAG, Register Pair HL at that character; the characters colon to at-sign (3AH-40H) are taken as the digits 3 to 9.
511F
LD BC,0000H 01 00 00
Load Register Pair BC (the value) with 0000H. 50D3H calls here.
5122
LD A,(HL) 7E
Fetch the character after the X from (HL) (Register Pair HL = the text pointer) into Register A.
5123
CP 27H FE 27
Compare Register A (the character after the X) against 27H, the opening quote.
5125
RET NZ C0
If the NZ FLAG is set (no quote), RETURN with the NZ FLAG.
5126
INC HL 23
INCrement Register Pair HL (the text pointer) by 1, past the quote.
5127
LD A,(HL) 7E
Loop Start
Fetch the next character from (HL) (Register Pair HL = the text pointer) into Register A. 514AH loops back here.
5128
SUB 30H D6 30
SUBtract 30H from Register A, turning the digits 0-9 into 00H-09H.
512A
If the CARRY FLAG is set (below 0), JUMP to 5136H: the number has ended.
512C
CP 0AH FE 0A
Compare Register A (the character minus 30H) against 0AH, one past the digit 9.
512E
If the CARRY FLAG is set (0-9), JUMP to 513EH to add the digit.
5130
SUB 07H D6 07
SUBtract 07H from Register A, turning the letters A-F into 0AH-0FH (and the characters 3AH-40H into 03H-09H).
5132
CP 10H FE 10
Compare Register A (the character minus 37H) against 10H, one past the digit F.
5134
If the CARRY FLAG is set (below 10H), JUMP to 513EH to add the digit.
5136
LD A,(HL) 7E
End of the Number
Fetch the character that ended the number from (HL) (Register Pair HL = the text pointer) into Register A. 512AH comes here.
5137
CP 27H FE 27
Compare Register A against 27H, the closing quote.
5139
INC HL 23
INCrement Register Pair HL (the text pointer) by 1 (the flags are kept).
513A
RET Z C8
If the Z FLAG is set (the closing quote), RETURN with the Z FLAG and Register Pair HL past the quote.
513B
DEC HL 2B
DECrement Register Pair HL (the text pointer) by 1, back to the character that ended the number.
513C
XOR A AF
Set Register A to ZERO and set the Z FLAG, even though no closing quote was found.
513D
RET C9
RETURN with the Z FLAG and the value in Register Pair BC.
513E
PUSH HL E5
Add a Digit
Save Register Pair HL (the text pointer) onto the stack. 512EH and 5134H come here.
513F
LD H,B 60
Copy Register B (the high byte of the value) into Register H.
5140
LD L,C 69
Copy Register C (the low byte of the value) into Register L: Register Pair HL = the value.
5141
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 2.
5142
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 4.
5143
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 8.
5144
ADD HL,HL 29
ADD Register Pair HL to itself: the value times 16, with its low four bits zero.
5145
LD B,H 44
Copy Register H into Register B, the new high byte.
5146
ADD A,L 85
ADD Register L (the low byte times 16) to Register A (the digit 00H-0FH); there is no carry because the low four bits of Register L are zero.
5147
LD C,A 4F
Copy Register A into Register C: Register Pair BC = the new value.
5148
POP HL E1
Restore Register Pair HL (the text pointer) from the stack.
5149
INC HL 23
INCrement Register Pair HL (the text pointer) by 1, past the digit.
514A
Loop End
LOOP BACK to 5127H to read the next character of the number.
514CH - BASIC2 Command
Entry 1 of the table at 4EA4H. Leaves TRSDOS 2.3 for the ROM's Level II BASIC: copies the ROM's initial values for 4000H-4035H back over the RST vectors and the device control blocks, clears 4036H-405CH and enters the ROM's start-up code at 0075H, which never returns to TRSDOS 2.3.
514C
LD HL,06D2H 21 D2 06
Point Register Pair HL to 06D2H, the ROM's table of initial values for 4000H-4035H.
514F
LD DE,4000H 11 00 40
Point Register Pair DE to 4000H, the RST 08H vector.
5152
LD BC,0036H 01 36 00
Load Register Pair BC with 0036H, the 54 bytes of 4000H-4035H.
5155
LDIR ED B0
Copy Register Pair BC (54) bytes from the ROM at Register Pair HL to 4000H at Register Pair DE (LDIR): the RST vectors, the RST 38H vector and the keyboard, video and printer control blocks get the ROM's values. Register Pair DE ends at 4036H.
5157
XOR A AF
Set Register A to ZERO and clear all flags, giving the 00H used to clear 4036H-405CH.
5158
LD B,27H 06 27
Load Register B with 27H, the 39 bytes of 4036H-405CH.
515A
LD (DE),A 12
Loop Start
Store Register A (00H) into (DE) (Register Pair DE = 4036H-405CH): the keyboard image, the clock, the time and date and the interrupt vectors are cleared. 515CH loops back here.
515B
INC DE 13
INCrement Register Pair DE (the destination) by 1.
515C
Loop End
DECrement Register B and LOOP BACK to 515AH until it reaches zero.
515E
DI F3
Disable interrupts (DI); the RST 38H vector now holds the ROM's value.
515F
JUMP to the ROM's 0075H, INIT2, the Level II BASIC start-up that the power-up code takes when BREAK is held; it asks MEMORY SIZE? and starts Level II BASIC.
5162H - DEBUG Command
Entry 2 of the table at 4EA4H. DEBUG and DEBUG (ON) or (YES) set bit 7 of the system flags at 430FH, turn the BREAK vector at 4315H into JP 400FH and the exit after an error at 4030H into CALL 400FH, so both the BREAK key and the next error enter DEBUG through the RST 30H vector. DEBUG (OFF) or (NO), and any other word in parentheses, clear bit 7 and 4315H and put back LD A,A3H / RST 28H at 4030H.
5162
GOSUB to 51A0H to read the optional (ON) or (OFF); the Z FLAG means OFF.
5165
LD HL,430FH 21 0F 43
Point Register Pair HL to 430FH, the system flags.
5168
DI F3
Disable interrupts (DI) while the vectors change.
5169
If the Z FLAG is set (OFF or NO), JUMP to 5184H to turn DEBUG off.
516B
SET 7,(HL) CB FE
Set bit 7 of the system flags at (HL) (Register Pair HL = 430FH): DEBUG is on.
516D
LD HL,400FH 21 0F 40
Load Register Pair HL with 400FH, the RST 30H vector (JP 44B4H, the DEBUG entry in SYS0/SYS).
5170
LD A,C3H 3E C3
Load Register A with C3H, the JP opcode for the first byte of the BREAK vector.
5172
LD (4316H),HL 22 16 43
Store Register Pair HL (400FH) into 4316H, the target of the BREAK vector.
5175
LD (4315H),A 32 15 43
Store Register A (C3H) into 4315H: the BREAK vector is armed as JP 400FH.
5178
LD A,CDH 3E CD
Load Register A with CDH, the CALL opcode for the first byte at 4030H.
517A
LD (4031H),HL 22 31 40
Store Register Pair HL (400FH, or A3H EFH for OFF) into 4031H-4032H, the operand bytes at 4030H. 518FH comes here.
517D
EI FB
Enable interrupts (EI), with the BREAK vector at 4315H-4317H complete.
517E
LD (4030H),A 32 30 40
Store Register A (CDH, or 3EH for OFF) into 4030H: CALL 400FH for ON, LD A,A3H for OFF.
5181
JUMP to 4E1FH, DOS READY, to display the prompt and read the next command.
5184
RES 7,(HL) CB BE
DEBUG Off
Reset bit 7 of the system flags at (HL) (Register Pair HL = 430FH): DEBUG is off. 5169H comes here.
5186
XOR A AF
Set Register A to ZERO and clear all flags, giving the 00H that disarms 4315H.
5187
LD (4315H),A 32 15 43
Store Register A (00H) into 4315H: the BREAK vector is disarmed. 4316H-4317H keep their last value.
518A
LD A,3EH 3E 3E
Load Register A with 3EH, the LD A,nn opcode.
518C
LD HL,EFA3H 21 A3 EF
Load Register Pair HL with EFA3H: Register L = A3H, the operand of LD A,nn, and Register H = EFH, RST 28H.
518F
JUMP to 517AH to store LD A,A3H / RST 28H at 4030H-4032H.
5191H - TRACE Command
Entry 3 of the table at 4EA4H. TRACE or TRACE (ON) puts the task at 4CD9H (SYS0/SYS), which shows the interrupted program counter on the screen, into timer slot 11; TRACE (OFF) removes it.
5191
GOSUB to 51A0H to read the optional (ON) or (OFF); the Z FLAG means OFF.
5194
LD DE,4CD9H 11 D9 4C
Point Register Pair DE to 4CD9H, the task control block of the trace display.
5197
LD A,0BH 3E 0B
Load Register A with 0BH, timer slot 11, the slot that runs on every clock tick.
5199
If the Z FLAG is set (OFF), JUMP to SYS0/SYS's 4413H to remove the task in slot 11; it returns to 402DH, DOS READY.
519C
JUMP to SYS0/SYS's 4410H to add the task at Register Pair DE (4CD9H) to slot 11; it returns to 402DH, DOS READY.
519FH - Read ON or OFF
Register Pair HL = the command line after DEBUG or TRACE. Skips spaces; with no opening parenthesis returns the NZ FLAG (ON). With one, reads the word through 50DFH and returns the NZ FLAG for Y or ON and the Z FLAG for N, OF or any other word.
519F
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past a space. 51A3H comes here.
51A0
LD A,(HL) 7E
Loop Start
Fetch the next character from (HL) (Register Pair HL = the command line pointer) into Register A. 5162H and 5191H call here.
51A1
CP 20H FE 20
Compare Register A (the command line character) against 20H, a space.
51A3
Loop End
If the Z FLAG is set, LOOP BACK to 519FH.
51A5
CP 28H FE 28
Compare Register A against 28H, the opening parenthesis.
51A7
RET NZ C0
If the NZ FLAG is set (no parenthesis), RETURN with the NZ FLAG: ON.
51A8
INC HL 23
INCrement Register Pair HL (the command line pointer) by 1, past the parenthesis.
51A9
GOSUB to 50DFH to read the word into Register Pair BC (FFFFH for Y or ON, 0000H otherwise).
51AC
LD A,B 78
Copy the high byte of the value from Register B into Register A.
51AD
OR A B7
OR Register A with itself: the NZ FLAG for FFFFH, the Z FLAG for 0000H.
51AE
RET C9
RETURN to 5165H or 5194H with the Z FLAG for OFF and the NZ FLAG for ON.
51AFH - Data
The parameter name buffer is not in the file. The default extension and the two messages follow it in the last load record (51B5H-51C8H).
51AF-51B4
DEFS 6
Parameter Name Buffer
Not in the file: no load record covers 51AFH-51B4H. 5095H copies a parameter name of up to six characters here and 50A1H looks it up.
51B5-51B7
DEFM "CMD" 43 4D 44
Default Extension
4E7AH points Register Pair HL here for 4FC0H, which adds /CMD to a program name without an extension. A six-character parameter name read by 5095H overwrites the C with 03H.
51B8
DEFB 0AH 0A
DOS READY Message
A line feed first, so the prompt starts on a new line. 4E40H points Register Pair HL here for SYS0/SYS's 4467H.
51B9-51C1
DEFM "DOS READY" 44 4F 53 20 52 45 41 44 59
DOS READY Message (continued)
The text of the command prompt.
51C2
DEFB 0DH 0D
DOS READY Message (end)
ENTER ends the message for 4467H.
51C3-51C7
DEFM "WHAT?" 57 48 41 54 3F
Unknown Command Message
4E87H points Register Pair HL here for 4467H when the command word is not a valid filespec or is a device name.
51C8
DEFB 0DH 0D
Unknown Command Message (end)
ENTER ends the message for 4467H.