4D00H - Command Entry and Function Code Validation
This is the main entry point for SYS14/SYS. The code receives a function code in Register A and validates that it is F0H (the base command code for this module). Register C contains a sub-function offset that determines which specific operation to perform. The code then dispatches to one of seven handler routines based on the sub-function value.
4D00
FD218043 LD IY,4380H
Point Index Register IY to 4380H, the base of the DOS system data area. This provides access to drive parameter blocks and system configuration data throughout the routine.
4D04
CP F0H FEF0
Compare Register A against F0H (the base SVC function code for this module). If Register A equals F0H, the Z FLAG is set; otherwise the NZ FLAG is set.
4D06
If the NZ FLAG (Not Zero) has been set (meaning this is NOT an F0H command), JUMP to 4D22H to trigger error 2AH (general error).
The function code is valid (F0H). Now dispatch based on the sub-function offset in Register C.
4D08
DEC C 0D
DECrement Register C by 1. If C becomes zero, the Z FLAG is set.
4D09
If the Z FLAG (Zero) has been set (meaning C was 01H, now 00H = F0H+01H = KB device command), JUMP to 4D4DH to handle keyboard device installation.
4D0C
DEC C 0D
DECrement Register C by 1. If C becomes zero, the Z FLAG is set.
4D0D
If the Z FLAG (Zero) has been set (meaning original C was 02H = F0H+02H = DO device command), JUMP to 4F7CH to handle display output device configuration.
4D10
DEC C 0D
DECrement Register C by 1. If C becomes zero, the Z FLAG is set.
4D11
If the Z FLAG (Zero) has been set (meaning original C was 03H = F0H+03H = PR device command), JUMP to 4D37H to handle printer device installation.
4D13
DEC C 0D
DECrement Register C by 1. If C becomes zero, the Z FLAG is set.
4D14
If the Z FLAG (Zero) has been set (meaning original C was 04H = F0H+04H = NL device command), JUMP to 505FH to handle non-line device configuration.
4D17
DEC C 0D
DECrement Register C by 1. If C becomes zero, the Z FLAG is set.
4D18
If the Z FLAG (Zero) has been set (meaning original C was 05H = F0H+05H = CLEAR command), JUMP to 50D8H to handle clearing line input configuration.
4D1B
DEC C 0D
DECrement Register C by 1. If C becomes zero, the Z FLAG is set.
4D1C
If the Z FLAG (Zero) has been set (meaning original C was 06H = F0H+06H = special MM= command), JUMP to 50D3H to set up memory management display.
4D1F
DEC C 0D
DECrement Register C by 1. If C becomes zero, the Z FLAG is set.
4D20
If the Z FLAG (Zero) has been set (meaning original C was 07H = F0H+07H = various system config commands), JUMP to 4D39H to handle memory configuration commands (START=, END=, MEM=, BASE=, BASC=).
If execution reaches here, the sub-function code was out of range (greater than 07H). Fall through to error handler.
4D22H - Invalid Command Error Handler
This routine handles invalid function codes by triggering error 2AH (general error) through the SYS0 error handler.
4D22
LD A,2AH 3E2A
Load Register A with 2AH, the error code for "general error" (invalid command or parameter).
4D24
JUMP to 4EEBH to display the error message and return to DOS Ready. This is a common error exit point that enables interrupts and calls the SYS0 error handler at 4409H.
4D27H - Special DOS Command Handler Setup
This unusual routine sets up a special return mechanism using alternate registers and the stack. It appears to be preparing for a DOS-CALL or MINI-DOS operation that needs to return through a specific path while preserving system state.
4D27
XOR A AF
Set Register A to ZERO and clear all flags. This prepares for a conditional test below.
4D28
EXX D9
EXchange primary register set with alternate register set (BC↔BC', DE↔DE', HL↔HL'). This switches to the alternate registers to set up return parameters without disturbing the main registers.
4D29
LD BC,F003H 0103F0
Load Register Pair BC' (alternate) with F003H. This appears to be a function code and parameter for a subsequent operation.
4D2C
LD DE,49D3H 11D349
Point Register Pair DE' (alternate) to 49D3H, which is in the SYS0 area and appears to be a return or continuation address.
4D2F
PUSH BC C5
Save the alternate Register Pair BC' (F003H) onto the stack. This will be used as a parameter after the register swap back.
4D30
PUSH DE D5
Save the alternate Register Pair DE' (49D3H) onto the stack. This sets up a return address for the upcoming operation.
4D31
EXX D9
EXchange back to primary register set (BC↔BC', DE↔DE', HL↔HL'). The stack now contains F003H and 49D3H but the primary registers are restored.
4D32
OR A B7
Perform OR operation on Register A with itself. This tests if Register A is zero (it was set to 00H at 4D27H). The Z FLAG will be set if A=00H.
4D33
If the Z FLAG (Zero) has been set (meaning A was 00H), JUMP to 0000H (ROM entry point for system reset/cold start). This appears to be a conditional escape mechanism.
4D36
RST 28H EF
Call RST 28H (SYS0 supervisor call handler at 0028H). This will process the function code in Register A using the values set up on the stack.
4D37H - Printer Device (PR) Command Handler - Return Point
This is the return point for the printer device installation command (F0H+03H). It simply cleans up the stack and returns to the caller.
4D37
POP AF F1
Restore Register Pair AF from the stack, discarding the return address that was placed there during the device installation process.
4D38
RET C9
RETurn to the caller (DOS command processor). The printer device has been successfully configured.
4D39H - Memory Configuration Commands Handler (START=, END=, MEM=, BASE=, BASC=)
This handler processes memory configuration commands (F0H+07H). It parses the command line for recognized keywords like "START=", "END=", "MEM=", "BASE=", or "BASC=", extracts hexadecimal address parameters, and either displays or sets the corresponding system values.
4D39
GOSUB to 4EEFH to parse and extract a hexadecimal address value from the command line. Returns with the address in Register Pair DE and advances HL past the parsed value.
4D3C
GOSUB to 4CD5H (SYS0 command line parser) to skip delimiters and check for end of command. Returns with Z FLAG set if end-of-line (0DH), NZ FLAG if more parameters exist, CARRY FLAG set if invalid character encountered.
4D3F
RET NZ C0
RETurn if the NZ FLAG (Not Zero) has been set (meaning there are more parameters on the command line). This returns control to the caller for further processing.
End of command line reached. Now validate the parsed address and look up which memory configuration command was specified.
4D40
EX DE,HL EB
EXchange Register Pairs DE and HL. The parsed address value (previously in DE) is now in HL, and the command line pointer (previously in HL) is now in DE.
4D41
LD DE,0040H 114000
Load Register Pair DE with 0040H, which will be used to compare against the parsed address to ensure it's at least 0040H (minimum valid address above ROM and system areas).
4D44
RST 18H DF
Call RST 18H (compare HL with DE). Sets CARRY FLAG if HL < DE, ZERO FLAG if HL = DE, NO CARRY FLAG if HL > DE.
4D45
If the NO CARRY FLAG has been set (meaning HL ≥ 0040H, the address is valid), JUMP to 4F0DH to trigger error 2FH (invalid parameter/address out of range). This is counter-intuitive and suggests the comparison logic is checking for addresses that are TOO HIGH or this is checking a different boundary.
4D48
LD H,L 65
Copy Register L into Register H. This effectively creates HL = LLLLH (duplicating the low byte into the high byte). This appears to be manipulating the address value in an unusual way.
4D49
LD A,66H 3E66
Load Register A with 66H, which is an SVC function code (specifically appears to be related to date/time display routines based on the SYS0 reference at 44A7H).
4D4B
PUSH HL E5
Save Register Pair HL (the manipulated address value) onto the stack for later use.
4D4C
RST 28H EF
Call RST 28H (SYS0 supervisor call handler) with function code 66H in Register A. This invokes a system service routine.
4D4DH - Parse KB Command and Initialize Device Installation
This routine handles the keyboard device installation command (F0H+01H). It processes the command line to extract device specifications, validates parameters, and installs a custom keyboard input handler into the device driver chain. The routine supports syntax like "KB :filename" to load a driver from disk or "KB" alone to use a default handler.
4D4D
DI F3
DIsable interrupts. This prevents interrupt-driven routines from interfering with the device driver chain manipulation that follows.
4D4E
LD A,(HL) 7E
Fetch the current character from the command line (pointed to by HL) into Register A.
4D4F
CP 0DH FE0D
Compare Register A against 0DH (ASCII carriage return, end-of-line marker). If Register A equals 0DH, the Z FLAG is set; otherwise the NZ FLAG is set.
4D51
If the Z FLAG (Zero) has been set (meaning end-of-line reached, no filename specified), JUMP to 4E0AH to use the default keyboard handler or display current configuration.
Command line has additional parameters. Parse the device specification.
4D54
GOSUB to 4EC6H to look up the device command in the device table (starting at 4F53H). Returns with A = device flags, DE = handler address, and Z FLAG set if valid device found.
4D57
BIT 7,A CB7F
Test bit 7 of Register A (the device flags byte). If bit 7 is set, the Z FLAG is cleared; if bit 7 is clear, the Z FLAG is set. Bit 7 indicates whether this is a valid loadable device type.
4D59
If the Z FLAG (Zero) has been set (meaning bit 7 was clear, invalid device type), JUMP to 4EE9H to trigger error 34H (parse error).
4D5C
BIT 4,A CB67
Test bit 4 of Register A (device flags). If bit 4 is set, the Z FLAG is cleared; if bit 4 is clear, the Z FLAG is set. Bit 4 distinguishes between different device installation methods.
4D5E
If the NZ FLAG (Not Zero) has been set (meaning bit 4 is set), JUMP to 4DFCH to handle this device type with an alternate installation method.
Standard device installation path. Store device parameters and prepare for driver loading.
4D61
LD (4DA5H),A 32A54D
Store the device flags (from Register A) into memory location 4DA5H. This is self-modifying code - the stored value will be used at instruction 4DA4H as an AND operand.
4D64
LD (4DCEH),DE ED53CE4D
Store Register Pair DE (the device handler address) into memory location 4DCEH. This is self-modifying code - this will become part of an LD DE,nnnn instruction at 4DCDH.
4D68
PUSH HL E5
Save Register Pair HL (command line pointer) onto the stack for later restoration.
4D69
GOSUB to 4E94H to locate an existing device entry in the driver chain that matches the device type in DE. Returns with HL pointing to the matching entry (or 0000H if not found) and BC pointing to the chain link.
4D6C
LD A,(DE) 1A
Fetch the byte at the address pointed to by DE into Register A. This retrieves a byte from the device driver chain structure.
4D6D
LD (4DD9H),A 32D94D
Store the fetched byte (from Register A) into memory location 4DD9H. This is self-modifying code - this will become the operand of an LD A,nn instruction at 4DD8H.
4D70
POP HL E1
Restore Register Pair HL (command line pointer) from the stack.
4D71
GOSUB to 4CD5H (SYS0 command line parser) to skip delimiters and advance to the next parameter. Returns with Z FLAG set if end-of-line, CARRY FLAG set if invalid character.
4D74
RET C D8
RETurn if the CARRY FLAG has been set (meaning an invalid character was encountered). This exits with the error condition already flagged.
4D75
If the Z FLAG (Zero) has been set (meaning end-of-line reached with no filename), JUMP to 4E54H to enable interrupts and return successfully.
More parameters exist on the command line. Parse the driver filename or additional device options.
4D78
GOSUB to 4EC6H to look up another device keyword in the table. This checks if the next parameter is a device modifier keyword.
4D7B
BIT 6,A CB77
Test bit 6 of Register A (device flags). If bit 6 is set, the Z FLAG is cleared; if bit 6 is clear, the Z FLAG is set.
4D7D
If the Z FLAG (Zero) has been set (meaning bit 6 is clear, invalid modifier), JUMP to 4EE9H to trigger error 34H (parse error).
4D80
BIT 5,A CB6F
Test bit 5 of Register A (device flags). If bit 5 is set, the Z FLAG is cleared; if bit 5 is clear, the Z FLAG is set. Bit 5 determines the parameter processing path.
4D82
If the Z FLAG (Zero) has been set (meaning bit 5 is clear), JUMP to 4DA0H to handle this parameter type with an alternate method.
Bit 5 is set. Parse a hexadecimal memory address parameter and validate it's in the valid range (5200H to high memory).
4D84
GOSUB to 4EEFH to parse and extract a hexadecimal address from the command line. Returns with the address in Register Pair DE.
4D87
LD A,D 7A
Copy Register D into Register A. This gets the high byte of the parsed address for range validation.
4D88
CP 52H FE52
Compare Register A against 52H. If Register A < 52H, the CARRY FLAG is set. This checks if the address is below 5200H (minimum allowed driver load address).
4D8A
If the CARRY FLAG has been set (meaning the address is below 5200H), JUMP to 4F0DH to trigger error 2FH (invalid address out of range).
Address is valid (≥5200H). Calculate the driver entry point addresses and store them in the driver load area.
4D8D
PUSH HL E5
Save Register Pair HL (command line pointer) onto the stack.
4D8E
PUSH DE D5
Save Register Pair DE (the base address for the driver) onto the stack.
4D8F
LD HL,0010H 211000
Load Register Pair HL with 0010H, an offset value of 16 bytes.
4D92
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL. This calculates base_address + 10H, which points to the driver's entry point table or initialization routine offset.
4D93
EX DE,HL EB
EXchange Register Pairs DE and HL. The calculated address (base+10H) is now in DE.
4D94
LD HL,FFFAH 21FAFF
Load Register Pair HL with FFFAH (which is -6 in two's complement, or 65530 unsigned).
4D97
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL. This calculates (base+10H) - 6 = base+0AH, pointing to another offset within the driver structure (6 bytes before the entry point).
4D98
LD (HL),D 72
Store Register D (high byte of base+10H address) into the memory location pointed to by HL (at base+0AH).
4D99
DEC HL 2B
DECrement Register Pair HL by 1, now pointing to base+09H.
4D9A
LD (HL),E 73
Store Register E (low byte of base+10H address) into the memory location pointed to by HL (at base+09H). Together with the previous instruction, this stores the 16-bit address (base+10H) at offset +09H in the driver structure.
4D9B
DEC HL 2B
DECrement Register Pair HL by 1, now pointing to base+08H.
4D9C
EX DE,HL EB
EXchange Register Pairs DE and HL. Now DE points to base+08H (for potential further use), and HL contains the entry point address (base+10H).
4D9D
POP HL E1
Restore the original base address from the stack into Register Pair HL.
4D9E
JUMP (unconditionally) to 4DABH to continue with device driver installation setup.
4DA0H - Alternate Parameter Processing Path
This section handles device parameters when bit 5 of the device flags is clear. It sets up default values and processes the parameter using self-modifying code.
4DA0
PUSH HL E5
Save Register Pair HL (command line pointer) onto the stack.
4DA1
LD HL,0000H 210000
Load Register Pair HL with 0000H, a null/default value.
4DA4
AND 00H E600
Perform AND operation between Register A and 00H. This is self-modifying code - the operand 00H was stored at 4DA5H by the instruction at 4D61H, and contains the device flags. This masks Register A to extract specific flag bits.
4DA6
AND 03H E603
Perform AND operation between Register A and 03H (binary 00000011). This isolates bits 0 and 1 of the device flags. If the result is 00H, the Z FLAG is set.
4DA8
If the Z FLAG (Zero) has been set (meaning bits 0-1 were both clear), JUMP to 4F0DH to trigger error 2FH (invalid parameter).
Valid flag bits detected. Continue with device driver chain setup.
4DABH - Device Driver Chain Entry Allocation
This routine allocates a new entry in the device driver chain. It searches for a free slot in the chain area (starting at 43AFH), initializes the new entry with the driver parameters, and links it into the chain.
4DAB
LD (4DE2H),DE ED53E24D
Store Register Pair DE into memory location 4DE2H. This is self-modifying code - this will become the operand of an LD DE,nnnn instruction at 4DE1H, preserving the driver address parameter.
4DAF
LD A,H 7C
Copy Register H into Register A to test if HL is zero.
4DB0
OR L B5
Perform OR operation between Register A and Register L. If HL = 0000H, the Z FLAG will be set.
4DB1
If the NZ FLAG (Not Zero) has been set (meaning HL is NOT zero, a driver address was provided), JUMP to 4DCDH to use that address directly.
[DRIVER CHAIN SEARCH] HL is zero, meaning no specific driver address was given. Search for a free slot in the device driver chain area.
4DB3
LD HL,43AFH 21AF43
Point Register Pair HL to 43AFH, which is near the start of the device driver chain storage area in the DOS system data region.
4DB6
LD A,L 7D
[LOOP START] Copy Register L into Register A. This will be used to check if we've reached the end of the available chain area.
4DB7
CP CBH FECB
Compare Register A against CBH. This checks if we've reached address 43CBH (the end of the driver chain area, allowing approximately 28 bytes or 3-4 driver entries).
4DB9
LD A,3BH 3E3B
Load Register A with 3BH, which is error code 59 decimal (preparing for "no more space" error if the area is full).
4DBB
If the NO CARRY FLAG has been set (meaning L ≥ CBH, we've run out of space in the driver chain area), JUMP to 4EEBH to display error 3BH and return to DOS Ready.
Still have space in the chain area. Check if this slot is free (marked with FFFFH).
4DBE
INC HL 23
INCrement Register Pair HL by 1, advancing to the next byte in the chain structure.
4DBF
INC HL 23
INCrement Register Pair HL by 1.
4DC0
INC HL 23
INCrement Register Pair HL by 1. After these three increments, HL points 3 bytes forward, which appears to be stepping through driver entry structures.
4DC1
LD D,H 54
Copy Register H into Register D, saving the current position's high byte.
4DC2
LD E,L 5D
Copy Register L into Register E, saving the current position's low byte. Register Pair DE now holds a copy of the current chain position.
4DC3
INC HL 23
INCrement Register Pair HL by 1.
4DC4
INC HL 23
INCrement Register Pair HL by 1.
4DC5
INC HL 23
INCrement Register Pair HL by 1. After 3 more increments (total 6 from the saved position), HL now points to what appears to be the "next link" field of the driver entry.
4DC6
LD A,(HL) 7E
Fetch the byte at the address pointed to by HL into Register A. This is the low byte of the next link pointer.
4DC7
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the next link.
4DC8
AND (HL) A6
Perform AND operation between Register A and the byte at (HL). If both bytes are FFH, the result will be FFH. If either byte is not FFH, the result will have at least one zero bit.
4DC9
INC A 3C
INCrement Register A by 1. If A was FFH (indicating both link bytes were FFH, meaning this slot is free), A becomes 00H and the Z FLAG is set.
4DCA
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning this slot is occupied), LOOP BACK to 4DB6H to check the next slot in the chain.
[LOOP END - FREE SLOT FOUND] Found a free driver entry slot. DE points to the start of this entry (3 bytes before the link field).
4DCC
EX DE,HL EB
EXchange Register Pairs DE and HL. HL now points to the start of the free driver entry structure.
4DCDH - Initialize Device Driver Entry Structure
This routine initializes a device driver entry in the allocated slot. It sets up the entry's device code, handler addresses, flags, and links it into the device driver chain. The entry structure appears to be approximately 6-8 bytes per entry.
4DCD
LD DE,0000H 110000
Load Register Pair DE with 0000H. This is self-modifying code - the operand 0000H was stored at 4DCEH by the instruction at 4D64H and contains the device handler address from the device table lookup.
4DD0
PUSH HL E5
Save Register Pair HL (pointer to the driver entry structure) onto the stack.
4DD1
LD (HL),E 73
Store Register E (low byte of handler address) into the first byte of the driver entry at (HL).
4DD2
INC HL 23
INCrement Register Pair HL by 1 to point to the next byte of the entry.
4DD3
LD (HL),D 72
Store Register D (high byte of handler address) into the second byte of the driver entry at (HL). The 16-bit handler address is now stored at offset +0 and +1.
4DD4
INC HL 23
INCrement Register Pair HL by 1 to point to offset +2 in the entry.
4DD5
LD A,C0H 3EC0
Load Register A with C0H (binary 11000000). This appears to be a device type code or flags byte.
4DD7
LD (DE),A 12
Store Register A (C0H) into the memory location pointed to by DE (which still contains the handler address). This writes the device code/flags into the handler's data area.
4DD8
LD A,00H 3E00
Load Register A with 00H. This is self-modifying code - the operand 00H was stored at 4DD9H by the instruction at 4D6DH and contains a byte fetched from the existing device driver chain.
4DDA
LD (HL),A 77
Store Register A into the memory location pointed to by HL (at offset +2 in the entry). This stores a device identifier or chain link byte.
4DDB
INC HL 23
INCrement Register Pair HL by 1 to point to offset +3.
4DDC
XOR A AF
Set Register A to ZERO by XORing it with itself. All flags are cleared.
4DDD
LD (HL),A 77
Store Register A (00H) into the memory location pointed to by HL (at offset +3). This initializes another entry field to zero.
4DDE
INC HL 23
INCrement Register Pair HL by 1 to point to offset +4.
4DDF
LD (HL),A 77
Store Register A (00H) into the memory location pointed to by HL (at offset +4). Another field initialized to zero.
4DE0
INC HL 23
INCrement Register Pair HL by 1 to point to offset +5.
4DE1
LD DE,0000H 110000
Load Register Pair DE with 0000H. This is self-modifying code - the operand 0000H was stored at 4DE2H by the instruction at 4DABH and contains a parameter address.
4DE4
LD (HL),E 73
Store Register E (low byte of parameter address) into the memory location pointed to by HL (at offset +5).
4DE5
INC HL 23
INCrement Register Pair HL by 1 to point to offset +6.
4DE6
LD (HL),D 72
Store Register D (high byte of parameter address) into the memory location pointed to by HL (at offset +6). The parameter address is now stored at offsets +5 and +6.
Driver entry structure is now initialized. Now link this new entry into the device driver chain by updating the chain head pointer.
4DE7
LD DE,4AD9H 11D94A
Point Register Pair DE to 4AD9H, which is in the SYS0 data area. This appears to be related to the device driver chain management (near 4ADAH which is mentioned in the SYS0 reference).
4DEAH - Link New Entry Into Device Driver Chain
This routine traverses the device driver chain to find the end (marked by 0000H link), then links the new driver entry by updating the chain pointers.
4DEA
EX DE,HL EB
EXchange Register Pairs DE and HL. HL now points to 4AD9H (chain management area), and DE points to offset +6 in the new driver entry.
4DEB
INC HL 23
[CHAIN TRAVERSAL LOOP START] INCrement Register Pair HL by 1.
4DEC
INC HL 23
INCrement Register Pair HL by 1.
4DED
INC HL 23
INCrement Register Pair HL by 1. After these increments, HL points 3 bytes forward in the chain structure.
4DEE
LD E,(HL) 5E
Fetch the byte at the address pointed to by HL into Register E. This is the low byte of the next link pointer in the chain.
4DEF
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the link.
4DF0
LD D,(HL) 56
Fetch the byte at the address pointed to by HL into Register D. Register Pair DE now contains the address of the next entry in the chain.
4DF1
LD A,D 7A
Copy Register D into Register A to test if the link pointer is null.
4DF2
OR E B3
Perform OR operation between Register A and Register E. If DE = 0000H (end of chain), the Z FLAG will be set.
4DF3
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning the link is not null, more entries exist), LOOP BACK to 4DEAH to follow the chain to the next entry.
[CHAIN TRAVERSAL LOOP END] Found the end of the chain (link = 0000H). HL points to the high byte of the null link. Update this link to point to our new entry.
4DF5
POP BC C1
Restore the saved driver entry pointer from the stack into Register Pair BC. This is the address of the new entry we initialized earlier.
4DF6
LD (HL),B 70
Store Register B (high byte of new entry address) into the memory location pointed to by HL (the high byte of what was the null link).
4DF7
DEC HL 2B
DECrement Register Pair HL by 1 to point to the low byte of the link.
4DF8
LD (HL),C 71
Store Register C (low byte of new entry address) into the memory location pointed to by HL. The chain now links to our new driver entry.
4DF9
JUMP to 4D70H to restore the command line pointer and continue processing any remaining parameters.
4DFCH - Alternate Device Installation Method (Bit 4 Set)
This routine handles device installation when bit 4 of the device flags is set (detected at 4D5CH). It appears to handle devices that don't require file loading but use a different installation mechanism.
4DFC
GOSUB to 4CD5H (SYS0 command line parser) to skip delimiters and check for more parameters. Returns with Z FLAG set if end-of-line, CARRY FLAG set if invalid character.
4DFF
If the NZ FLAG (Not Zero) has been set (meaning more parameters exist on command line), JUMP to 4E54H to enable interrupts and return. This path doesn't process additional parameters for this device type.
End of command line reached. Set up the device with default parameters.
4E01
DI F3
DIsable interrupts to prevent interference during device setup.
4E02
LD DE,0000H 110000
Load Register Pair DE with 0000H, a null device address indicator.
4E05
GOSUB to 4E94H to search the device driver chain for an existing entry matching the device type in DE (0000H in this case). Returns with HL pointing to the found entry or 0000H if not found.
4E08
JUMP (unconditionally) to 4E53H to clear Register A (success code) and return.
4E0AH - Default KB Handler (No Filename Specified)
This routine handles the keyboard device command when no filename was specified (end-of-line detected at 4D4FH). It retrieves the current keyboard handler address and displays it or uses a default configuration.
4E0A
LD HL,(4ADCH) 2ADC4A
Fetch the 16-bit value stored at memory location 4ADCH (in the SYS0 data area) into Register Pair HL. This appears to be a pointer to the current keyboard device handler or configuration data.
4E0D
JUMP (unconditionally) to 4E4FH to process the retrieved handler address.
4E0FH - Display Device Configuration Loop
This routine displays the current device configuration by traversing a list of device entries and showing their addresses. Each entry contains a device type code and handler address. The routine compares device codes with a lookup table to display friendly names.
4E0F
LD E,(HL) 5E
[DEVICE LIST LOOP START] Fetch the low byte of the device handler address from (HL) into Register E.
4E10
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte.
4E11
LD D,(HL) 56
Fetch the high byte of the device handler address from (HL) into Register D. Register Pair DE now contains the handler address.
4E12
INC HL 23
INCrement Register Pair HL by 1 to point to the device type byte.
4E13
INC HL 23
INCrement Register Pair HL by 1, skipping past the device type byte to the next field.
4E14
PUSH DE D5
Save Register Pair DE (handler address) onto the stack for later display.
4E15
PUSH HL E5
Save Register Pair HL (current position in device list) onto the stack.
4E16
GOSUB to 4E56H to look up and display the device name corresponding to the device code in DE. This routine searches a table at 4F53H for matching device codes and displays the associated name.
4E19
LD HL,4F4EH 214E4F
Point Register Pair HL to 4F4EH, which contains the string " TO " used as a separator in the display.
4E1C
GOSUB to 4467H (SYS0 routine) to display the null-terminated string pointed to by HL. This outputs " TO " to the screen.
4E1F
POP HL E1
Restore Register Pair HL (position in device list) from the stack.
4E20
PUSH HL E5
Save Register Pair HL back onto the stack (it's needed again after the next operation).
4E21
INC HL 23
INCrement Register Pair HL by 1.
4E22
INC HL 23
INCrement Register Pair HL by 1. HL now points to the device parameter address field (offset +5 from entry start).
4E23
LD E,(HL) 5E
Fetch the low byte of the parameter address from (HL) into Register E.
4E24
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte.
4E25
LD D,(HL) 56
Fetch the high byte of the parameter address from (HL) into Register D. Register Pair DE now contains the parameter address.
4E26
GOSUB to 4E56H to look up and display the device name or parameter corresponding to the address in DE.
4E29
POP HL E1
Restore Register Pair HL (position in device list) from the stack.
4E2A
POP DE D1
Restore Register Pair DE (handler address) from the stack.
4E2B
LD A,(HL) 7E
Fetch the low byte of the next link pointer from (HL) into Register A.
4E2C
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the link.
4E2D
LD H,(HL) 66
Fetch the high byte of the next link pointer from (HL) into Register H.
4E2E
LD L,A 6F
Copy Register A (the low byte fetched earlier) into Register L. Register Pair HL now contains the address of the next device entry in the list.
4E2F
PUSH HL E5
Save Register Pair HL (next entry address) onto the stack.
4E30
LD A,H 7C
Copy Register H into Register A to test if the link pointer is null.
4E31
OR L B5
Perform OR operation between Register A and Register L. If HL = 0000H (end of list), the Z FLAG will be set.
4E32
JUMP (unconditionally) to 4E49H to check if we should continue the loop or terminate.
4E34H - Device Code Comparison and Display
This routine compares device codes to match entries in the device table. It's used to determine if a displayed device entry matches a specific device type code, allowing the system to show configuration information for specific devices.
4E34
LD A,(HL) 7E
[DEVICE CODE COMPARE LOOP] Fetch the low byte of the device code from (HL) into Register A.
4E35
CP E BB
Compare Register A against Register E (low byte of target device code). If they match, the Z FLAG is set.
4E36
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte.
4E37
If the NZ FLAG (Not Zero) has been set (meaning low bytes don't match), JUMP to 4E3BH to skip the high byte comparison.
4E39
LD A,(HL) 7E
Fetch the high byte of the device code from (HL) into Register A.
4E3A
CP D BA
Compare Register A against Register D (high byte of target device code). If they match, the Z FLAG is set; otherwise NZ FLAG is set. If both bytes match, we found the device.
4E3B
INC HL 23
INCrement Register Pair HL by 1.
4E3C
INC HL 23
INCrement Register Pair HL by 1. HL now points to the next table entry (skipped past the device name string).
4E3D
If the NZ FLAG (Not Zero) has been set (meaning device codes don't match), JUMP to 4E49H to continue searching or handle end of display.
Device code match found. Display a comma separator and continue showing the next device in the configuration.
4E3F
POP AF F1
Discard the saved HL value from the stack (using AF to avoid disturbing other registers).
4E40
LD A,2CH 3E2C
Load Register A with 2CH (ASCII comma character ',').
4E42
PUSH HL E5
Save Register Pair HL (current table position) onto the stack.
4E43
PUSH DE D5
Save Register Pair DE (device code being matched) onto the stack.
4E44
GOSUB to ROM routine at 0033H to display the character in Register A (comma) on the screen at the current cursor position.
4E47
JUMP (unconditionally) BACK to 4E1FH to continue processing and displaying the next device entry in the list.
4E49H - Device Display Loop Termination
This routine handles the end of the device display loop by outputting a carriage return and checking if there are more devices to display.
4E49
LD A,0DH 3E0D
Load Register A with 0DH (ASCII carriage return).
4E4B
GOSUB to ROM routine at 0033H to display the carriage return character, moving the cursor to the next line.
4E4E
POP HL E1
Restore Register Pair HL (next device entry address) from the stack.
4E4FH - Check For More Device Entries
This routine tests if there are more device entries to process by checking if the link pointer is null (0000H).
4E4F
LD A,H 7C
Copy Register H into Register A to test if HL is null.
4E50
OR L B5
Perform OR operation between Register A and Register L. If HL = 0000H (no more entries), the Z FLAG will be set.
4E51
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning more device entries exist), LOOP BACK to 4E0FH to display the next device entry.
[DEVICE DISPLAY LOOP END] All device entries have been displayed. Return successfully.
4E53H - Success Return Path
This is a common success exit point that clears Register A (indicating no error) and enables interrupts before returning.
4E53
XOR A AF
Set Register A to ZERO by XORing it with itself. This indicates successful operation (no error code).
4E54H - Enable Interrupts and Return
This routine enables interrupts and returns to the caller, completing the device operation.
4E54
EI FB
Enable Interrupts. This re-enables interrupt processing that was disabled earlier during device driver chain manipulation.
4E55
RET C9
RETurn to the caller. The device operation has completed successfully.
4E56H - Device Name Lookup and Display
This routine searches the device name table (starting at 4F53H) for a device entry that matches the device code in Register Pair DE. When found, it displays the corresponding device name. If not found, it displays the device code as a hexadecimal address instead.
4E56
LD HL,4F53H 21534F
Point Register Pair HL to 4F53H, the start of the device name lookup table. This table contains device codes followed by null-terminated device name strings.
4E59
PUSH HL E5
Save Register Pair HL (table pointer) onto the stack for later use.
4E5A
LD A,(HL) 7E
[STRING SKIP LOOP START] Fetch the byte at the address pointed to by HL into Register A.
4E5B
OR A B7
Perform OR operation on Register A with itself to test if it's zero (null terminator). The Z FLAG will be set if A = 00H.
4E5C
INC HL 23
INCrement Register Pair HL by 1 to point to the next byte.
4E5D
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning not at string terminator yet), LOOP BACK to 4E5AH to continue skipping through the string.
[STRING SKIP LOOP END] Found the null terminator of the device name string. HL now points past the null to the device code bytes.
4E5F
INC HL 23
INCrement Register Pair HL by 1 to skip past an additional byte (padding or alignment byte after the null).
4E60
LD A,(HL) 7E
Fetch the low byte of the device code from (HL) into Register A.
4E61
CP E BB
Compare Register A against Register E (low byte of target device code). If they match, the Z FLAG is set.
4E62
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the device code.
4E63
If the NZ FLAG (Not Zero) has been set (meaning low bytes don't match), JUMP to 4E67H to skip high byte comparison.
4E65
LD A,(HL) 7E
Fetch the high byte of the device code from (HL) into Register A.
4E66
SUB D 92
SUBtract Register D (high byte of target device code) from Register A. If they're equal, the result is 00H and the Z FLAG is set.
4E67
If the Z FLAG (Zero) has been set (meaning both bytes match, device found), JUMP to 4E74H to display the device name.
Device code doesn't match this entry. Skip to the next entry in the table.
4E69
INC HL 23
INCrement Register Pair HL by 1 to move past the high byte of the device code.
4E6A
POP AF F1
Discard the saved table pointer from the stack (using AF to avoid disturbing other registers).
4E6B
LD A,(HL) 7E
Fetch the byte at the address pointed to by HL into Register A. This should be either the start of the next device name string or a null byte indicating end of table.
4E6C
OR A B7
Perform OR operation on Register A with itself to test if it's zero (end of table marker). The Z FLAG will be set if A = 00H.
4E6D
If the NZ FLAG (Not Zero) has been set (meaning more table entries exist), LOOP BACK to 4E59H to check the next device entry.
Reached end of table without finding a match. Display the device code as a hexadecimal address instead of a name.
4E6F
LD HL,4F74H 21744F
Point Register Pair HL to 4F74H, which contains a default display format string "MM=" or similar template for showing unknown device codes.
4E72
INC A 3C
INCrement Register A by 1. Since A was 00H (from the null byte), it becomes 01H. This sets the NZ FLAG to indicate "device not found in table".
4E73
PUSH HL E5
Save Register Pair HL (pointer to default format string) onto the stack.
4E74H - Display Device Name or Address
This routine displays either the device name (if found in table) or the hexadecimal address (if not found). It then optionally appends the address in hexadecimal format.
4E74
POP HL E1
Restore Register Pair HL from the stack. This contains either the device name string pointer (if found) or the default format string (if not found).
4E75
PUSH AF F5
Save Register Pair AF onto the stack. The flags indicate whether the device was found (Z FLAG) or not found (NZ FLAG).
4E76
PUSH DE D5
Save Register Pair DE (the device code/address to display) onto the stack.
4E77
LD A,(HL) 7E
[STRING DISPLAY LOOP START] Fetch the character byte from the string at (HL) into Register A.
4E78
INC HL 23
INCrement Register Pair HL by 1 to point to the next character.
4E79
GOSUB to ROM routine at 0033H to display the character in Register A on the screen.
4E7C
LD A,(HL) 7E
Fetch the next character byte from the string at (HL) into Register A.
4E7D
OR A B7
Perform OR operation on Register A with itself to test if it's the null terminator (00H). The Z FLAG will be set if A = 00H.
4E7E
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning more characters to display), LOOP BACK to 4E77H to display the next character.
[STRING DISPLAY LOOP END] The string has been displayed. Now check if we need to append the hexadecimal address.
4E80
POP DE D1
Restore Register Pair DE (the device code/address) from the stack.
4E81
POP AF F1
Restore Register Pair AF from the stack, recovering the flags that indicate whether device was found in table.
4E82
OR A B7
Perform OR operation on Register A with itself to restore/test the flags. The Z FLAG will be set if device was found, NZ FLAG if not found.
4E83
RET Z C8
RETurn if the Z FLAG (Zero) has been set (meaning device name was found and displayed, no need to show address). Operation complete.
Device was not found in table. Display the address in hexadecimal format with "MM=" prefix or similar.
4E84
LD HL,FFF8H 21F8FF
Load Register Pair HL with FFF8H (which is -8 in two's complement). This will be used to calculate an adjusted address for display.
4E87
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL. This calculates address - 8, adjusting the display address by subtracting 8 bytes (perhaps to show the base of a structure rather than an offset within it).
4E88
EX DE,HL EB
EXchange Register Pairs DE and HL. The adjusted address (original - 8) is now in DE for the hex conversion routine.
4E89
LD HL,4F48H 21484F
Point Register Pair HL to 4F48H, a 6-byte buffer where the hexadecimal ASCII representation will be stored ("000000" format).
4E8C
PUSH HL E5
Save Register Pair HL (buffer address) onto the stack for later display.
4E8D
GOSUB to 4063H (SYS0 hex conversion routine) to convert the 16-bit value in DE to 4 ASCII hexadecimal characters and store them at the address pointed to by HL. However, since we need 6 characters for a full address display, this might convert to 4F48H+2 position.
4E90
POP HL E1
Restore Register Pair HL (buffer start address) from the stack.
4E91
JUMP to 4467H (SYS0 string display routine) to display the null-terminated string at HL (the hexadecimal address), then return to caller. This displays the final formatted address string.
4E94H - Search Device Driver Chain for Matching Entry
This routine searches the device driver chain (starting at 4ADAH+3) for an existing entry that matches the device code in Register Pair DE. It's used to find and remove or update existing device drivers before installing new ones. Returns with HL pointing to the matching entry (or 0000H if not found) and BC pointing to the link field that points to the matched entry.
4E94
LD HL,4ADAH 21DA4A
Point Register Pair HL to 4ADAH, which is in the SYS0 data area and appears to be the device driver chain head pointer or management structure.
4E97
INC HL 23
[CHAIN SEARCH LOOP START] INCrement Register Pair HL by 1.
4E98
INC HL 23
INCrement Register Pair HL by 1.
4E99
LD B,H 44
Copy Register H into Register B, saving the current position's high byte.
4E9A
LD C,L 4D
Copy Register L into Register C, saving the current position's low byte. Register Pair BC now points to the link field of the current chain position.
4E9B
LD A,(HL) 7E
Fetch the low byte of the next entry pointer from (HL) into Register A.
4E9C
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the pointer.
4E9D
LD H,(HL) 66
Fetch the high byte of the next entry pointer from (HL) into Register H.
4E9E
LD L,A 6F
Copy Register A (low byte fetched earlier) into Register L. Register Pair HL now contains the address of the next driver entry in the chain.
4E9F
LD A,H 7C
Copy Register H into Register A to test if the pointer is null.
4EA0
OR L B5
Perform OR operation between Register A and Register L. If HL = 0000H (end of chain), the Z FLAG will be set.
4EA1
RET Z C8
RETurn if the Z FLAG (Zero) has been set (meaning reached end of chain without finding a match). HL = 0000H indicates "not found".
Chain entry exists. Check if DE is 0000H (search for any entry) or if it matches this entry's device code.
4EA2
LD A,D 7A
Copy Register D into Register A to test if DE is zero.
4EA3
OR E B3
Perform OR operation between Register A and Register E. If DE = 0000H (find any entry), the Z FLAG will be set.
4EA4
LD A,(HL) 7E
Fetch the low byte of the device code from the current entry at (HL) into Register A.
4EA5
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the device code.
4EA6
If the Z FLAG (Zero) has been set (meaning DE was 0000H, accept any entry), JUMP to 4EAFH to mark this entry as found and unlink it from the chain.
DE is not 0000H, so compare the device codes to see if this entry matches.
4EA8
CP E BB
Compare Register A (low byte of entry's device code) against Register E (low byte of search code). If they match, the Z FLAG is set.
4EA9
If the NZ FLAG (Not Zero) has been set (meaning low bytes don't match), JUMP to 4EADH to continue searching.
4EAB
LD A,(HL) 7E
Fetch the high byte of the entry's device code from (HL) into Register A.
4EAC
CP D BA
Compare Register A (high byte of entry's device code) against Register D (high byte of search code). If they match, the Z FLAG is set.
4EAD
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning device codes don't match), LOOP BACK to 4E97H to check the next entry in the chain.
[CHAIN SEARCH LOOP END - MATCH FOUND] The device codes match. Unlink this entry from the chain and return its address.
4EAFH - Unlink Matched Entry From Chain
This routine removes the matched device driver entry from the chain by updating the previous link to point to the next entry, then marks the unlinked entry with FFFFH sentinel values.
4EAF
PUSH BC C5
Save Register Pair BC (pointer to the link field that points to this entry) onto the stack.
4EB0
DEC HL 2B
DECrement Register Pair HL by 1. After incrementing at 4EA5H, we need to step back to the start of the entry.
4EB1
LD C,(HL) 4E
Fetch the low byte of the device code from (HL) into Register C (saving it for later use).
4EB2
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte.
4EB3
LD B,(HL) 46
Fetch the high byte of the device code from (HL) into Register B. Register Pair BC now contains the device code of the entry being unlinked.
4EB4
INC HL 23
INCrement Register Pair HL by 1. HL now points to offset +2 in the entry structure.
4EB5
LD A,(HL) 7E
Fetch the byte at offset +2 from (HL) into Register A.
4EB6
LD (BC),A 02
Store Register A into the memory location pointed to by BC (which contains the device code address). This appears to be storing configuration data back to the device handler area.
4EB7
INC HL 23
INCrement Register Pair HL by 1. HL now points to offset +3 in the entry (the link field).
4EB8
LD C,(HL) 4E
Fetch the low byte of the next link pointer from (HL) into Register C.
4EB9
LD A,FFH 3EFF
Load Register A with FFH, which will be used to mark this entry as free/deleted.
4EBB
LD (HL),A 77
Store Register A (FFH) into the memory location pointed to by HL (the low byte of the link). This marks the entry as freed.
4EBC
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the link.
4EBD
LD B,(HL) 46
Fetch the high byte of the next link pointer from (HL) into Register B. Register Pair BC now contains the address of the next entry in the chain.
4EBE
LD (HL),A 77
Store Register A (FFH) into the memory location pointed to by HL (the high byte of the link). The entry is now marked with FFFFH indicating it's free.
4EBF
POP HL E1
Restore the saved pointer (to the link field in the previous entry) from the stack into Register Pair HL.
4EC0
LD (HL),C 71
Store Register C (low byte of next entry address) into the memory location pointed to by HL. This updates the previous entry's link to skip over the unlinked entry.
4EC1
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the link field.
4EC2
LD (HL),B 70
Store Register B (high byte of next entry address) into the memory location pointed to by HL. The chain now bypasses the unlinked entry.
4EC3
DEC HL 2B
DECrement Register Pair HL by 1 to point back to the low byte of the link (for potential further processing).
4EC4
JUMP BACK to 4E99H to continue searching the chain (in case there are multiple matching entries to remove).
4EC6H - Device Command Keyword Lookup
This routine searches the device command table (starting at 4F53H) for a keyword that matches the text at the command line position pointed to by HL. It performs case-insensitive comparison and returns the device flags and handler address if a match is found.
4EC6
LD BC,4F53H 01534F
Point Register Pair BC to 4F53H, the start of the device command lookup table. This table contains device keywords (KB, DO, PR, NL, CLEAR) followed by flags and addresses.
4EC9
LD D,03H 1603
Load Register D with 03H. This appears to be a count or multiplier for stepping through table entries (each entry is 3 bytes: name + flags + address).
4ECB
GOSUB to 4ED7H to perform the string comparison between command line text at HL and table entries at BC. Returns with Z FLAG set if match found.
4ECE
PUSH BC C5
Save Register Pair BC (current table position) onto the stack.
4ECF
EX (SP),HL E3
EXchange the top of stack with Register Pair HL. HL now contains the table position (BC was saved), and the stack contains the command line position.
4ED0
LD A,(HL) 7E
Fetch the device flags byte from the table entry at (HL) into Register A.
4ED1
INC HL 23
INCrement Register Pair HL by 1 to point to the low byte of the handler address.
4ED2
LD E,(HL) 5E
Fetch the low byte of the handler address from (HL) into Register E.
4ED3
INC HL 23
INCrement Register Pair HL by 1 to point to the high byte of the handler address.
4ED4
LD D,(HL) 56
Fetch the high byte of the handler address from (HL) into Register D. Register Pair DE now contains the complete handler address for this device.
4ED5
POP HL E1
Restore Register Pair HL (command line position) from the stack.
4ED6
RET C9
RETurn to caller with: A = device flags, DE = handler address, Z FLAG set if match found, NZ FLAG if not found.
4ED7H - String Comparison for Table Lookup
This routine performs case-insensitive string comparison between the command line text at HL and the null-terminated keywords in the device table at BC. It steps through multiple table entries (D entries) until a match is found or the table is exhausted.
4ED7
[TABLE ENTRY LOOP START] GOSUB to 4CC5H (SYS0 string comparison routine) to compare the string at BC with the string at HL. Returns with Z FLAG set if they match (case-insensitive).
4EDA
RET Z C8
RETurn if the Z FLAG (Zero) has been set (meaning strings match). The keyword was found in the table.
No match. Skip to the next table entry by advancing past the current keyword string and its data.
4EDB
LD A,(BC) 0A
[STRING SKIP LOOP START] Fetch the byte from the table at (BC) into Register A.
4EDC
OR A B7
Perform OR operation on Register A with itself to test if it's the null terminator (00H). The Z FLAG will be set if A = 00H.
4EDD
INC BC 03
INCrement Register Pair BC by 1 to advance through the string.
4EDE
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning not at null terminator yet), LOOP BACK to 4EDBH to continue skipping characters.
[STRING SKIP LOOP END] Found null terminator. BC now points past the keyword string. Advance through the data fields (flags + address).
4EE0
LD E,D 5A
Copy Register D into Register E. D contains the entry size count (03H = 3 bytes to skip: null + flags + 2-byte address).
4EE1
INC BC 03
[DATA SKIP LOOP START] INCrement Register Pair BC by 1 to skip past a data byte.
4EE2
DEC E 1D
DECrement Register E by 1. When E reaches zero, we've skipped all data bytes.
4EE3
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning more data bytes to skip), LOOP BACK to 4EE1H.
[DATA SKIP LOOP END] BC now points to the start of the next table entry. Check if we've reached the end of the table.
4EE5
LD A,(BC) 0A
Fetch the first byte of the next entry (or end-of-table marker) from (BC) into Register A.
4EE6
OR A B7
Perform OR operation on Register A with itself to test if it's 00H (end of table). The Z FLAG will be set if A = 00H.
4EE7
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning more table entries exist), LOOP BACK to 4ED7H to compare with the next entry.
[TABLE ENTRY LOOP END] Reached end of table without finding a match. Fall through to error handler.
4EE9H - Parse Error Handler
This routine handles parse errors (invalid keywords or syntax) by triggering error 34H (parse error) through the SYS0 error system.
4EE9
LD A,34H 3E34
Load Register A with 34H, the error code for "parse error" (invalid command syntax or unrecognized keyword).
4EEBH - Common Error Exit Point
This is a common error exit routine that enables interrupts and jumps to the SYS0 error handler at 4409H to display the error message and return to DOS Ready.
4EEB
EI FB
Enable Interrupts before displaying the error and returning to DOS.
4EEC
JUMP to 4409H (SYS0 error handler) to display the error message corresponding to the error code in Register A, then return to DOS Ready.
4EEFH - Hexadecimal Address Parser (4 or 6 Digits)
This sophisticated routine parses hexadecimal address values from the command line. It supports both 4-digit hexadecimal addresses (0000H-FFFFH) and extended 6-digit hexadecimal addresses with drive prefix (A0000H-H9FFFFH where A-H represents drive 0-7). The parser validates the format and returns the parsed address in Register Pair DE.
4EEF
PUSH HL E5
Save Register Pair HL (command line pointer) onto the stack.
4EF0
LD B,00H 0600
Load Register B with 00H. This is a flags register: bit 0 will indicate hex digit mode, bit 1 will be set when valid digits are found.
4EF2
GOSUB to 4F12H to parse hexadecimal digits from the command line into Register Pair DE. This handles standard 4-digit hex addresses.
4EF5
LD A,(HL) 7E
Fetch the next character from the command line at (HL) into Register A. This checks what follows the parsed digits.
4EF6
SUB 41H D641
SUBtract 41H (ASCII 'A') from Register A. If A was 'A', result is 00H; if 'B', result is 01H, etc. If A < 41H, the CARRY FLAG is set.
4EF8
CP 08H FE08
Compare Register A against 08H. If A < 08H (meaning the character was 'A' through 'H'), the CARRY FLAG is set; otherwise NO CARRY.
4EFA
If the NO CARRY FLAG has been set (meaning the character was NOT 'A'-'H'), JUMP to 4F09H to validate and return the 4-digit address.
Character is 'A' through 'H', indicating a 6-digit extended address format. Reparse with hex mode enabled.
4EFC
POP HL E1
Restore Register Pair HL (original command line position) from the stack.
4EFD
LD B,01H 0601 LD B,01H
Load Register B with 01H. This sets bit 0 of the flags register, enabling hexadecimal parsing mode for all digits including the drive letter.
4EFF
PUSH HL E5
Save Register Pair HL (command line pointer) back onto the stack for the reparse.
4F00
GOSUB to 4F12H to reparse the address with hex mode enabled (B = 01H), treating the drive letter 'A'-'H' as the first hex digit (representing drive 0-7 in the high nibble).
4F03
LD A,(HL) 7E
Fetch the character following the 6-digit hex parse from (HL) into Register A.
4F04
CP 48H FE48
Compare Register A against 48H (ASCII 'H', the hexadecimal suffix marker). If Register A equals 48H, the Z FLAG is set.
4F06
INC HL 23
INCrement Register Pair HL by 1 to advance past the 'H' suffix (or whatever character was there).
4F07
If the NZ FLAG (Not Zero) has been set (meaning the suffix was NOT 'H'), JUMP to 4F0DH to trigger error 2FH (invalid address format).
Valid 6-digit hex address with 'H' suffix parsed successfully. Check if standard hex parsing found valid digits.
4F09H - Validate 4-Digit Hex Parse Result
This routine validates that the hex parsing routine found at least one valid digit (bit 1 of B is set). If no valid digits were found, it triggers an error.
4F09
BIT 1,B CB48
Test bit 1 of Register B (the "valid digits found" flag). If bit 1 is set, the Z FLAG is cleared; if bit 1 is clear, the Z FLAG is set.
4F0B
POP BC C1
Discard the saved command line pointer from the stack (using BC to restore the stack without disturbing HL which now points past the parsed address).
4F0C
RET NZ C0
RETurn if the NZ FLAG (Not Zero) has been set (meaning bit 1 was set, valid digits were found). The parsed address in DE is valid.
No valid hex digits were found. Trigger an error.
4F0DH - Invalid Address Format Error
This routine handles invalid address format errors by triggering error 2FH (invalid parameter/address).
4F0D
LD A,2FH 3E2F
Load Register A with 2FH, the error code for "invalid parameter" or "invalid address format".
4F0F
JUMP to 4409H (SYS0 error handler) to display error 2FH and return to DOS Ready.
4F12H - Hexadecimal Digit Parser
This is the core hexadecimal parsing routine. It reads characters from the command line at HL, converts valid hex digits (0-9, A-F) to binary, and accumulates them into a 16-bit value in Register Pair DE. The routine handles both decimal digits and hexadecimal letters, with special handling when bit 0 of Register B is set (allowing letters as the first character for extended addressing).
4F12
LD DE,0000H 110000
Load Register Pair DE with 0000H to initialize the accumulator for the parsed hex value.
4F15
LD A,(HL) 7E
[HEX PARSE LOOP START] Fetch the current character from the command line at (HL) into Register A.
4F16
SUB 30H D630
SUBtract 30H (ASCII '0') from Register A. This converts '0'-'9' to 0-9. If A was '0', result is 00H; if '5', result is 05H; if letter, result is higher.
4F18
CP 0AH FE0A
Compare Register A against 0AH (10 decimal). If A < 0AH (meaning it was a decimal digit '0'-'9'), the CARRY FLAG is set.
4F1A
If the CARRY FLAG has been set (meaning it was a decimal digit 0-9), JUMP to 4F26H to accumulate this digit into the result.
Character is not '0'-'9'. Check if hex letters are allowed and if this is a valid hex letter 'A'-'F'.
4F1C
BIT 0,B CB40
Test bit 0 of Register B (hex letter mode flag). If bit 0 is set, the Z FLAG is cleared; if bit 0 is clear, the Z FLAG is set.
4F1E
RET Z C8
RETurn if the Z FLAG (Zero) has been set (meaning hex letters are NOT allowed). The parsing stops here.
Hex letters are allowed. Check if this character is 'A'-'F' (after subtracting '0', 'A' = 11H).
4F1F
SUB 11H D611
SUBtract 11H from Register A. After the earlier SUB 30H, 'A' (41H) became 11H; subtracting 11H makes it 00H. 'B' becomes 01H, etc. This adjusts 'A'-'F' to the range 00H-05H.
4F21
CP 06H FE06
Compare Register A against 06H. If A < 06H (meaning it was 'A'-'F'), the CARRY FLAG is set; otherwise NO CARRY.
4F23
RET NC D0
RETurn if the NO CARRY FLAG has been set (meaning the character was NOT 'A'-'F'). The parsing stops here.
4F24
ADD 0AH C60A
ADD 0AH (10 decimal) to Register A. This converts the adjusted letter value (00H-05H) to the hex digit value (0AH-0FH). 'A' = 0AH, 'B' = 0BH, ..., 'F' = 0FH.
Valid hex digit in Register A (either 0-9 or A-F). Accumulate it into the 16-bit result in DE.
4F26H - Accumulate Hex Digit Into Result
This routine multiplies the current result in DE by 16 (shift left 4 bits) and adds the new digit. For standard hex mode (bit 0 of B clear), it multiplies by 10 instead. The routine uses an elegant shift-and-add algorithm.
4F26
PUSH HL E5
Save Register Pair HL (command line pointer) onto the stack.
4F27
LD H,D 62
Copy Register D into Register H.
4F28
LD L,E 6B
Copy Register E into Register L. Register Pair HL now contains a copy of the current accumulated value from DE.
4F29
LD C,A 4F
Copy Register A (the new hex digit to add) into Register C for safekeeping.
4F2A
XOR A AF
Set Register A to ZERO by XORing it with itself. This will be used as an overflow detector for 24-bit arithmetic.
4F2B
SET 1,B CBC8
SET bit 1 of Register B. This marks that at least one valid hex digit has been found (the "valid parse" flag).
4F2D
ADD HL,HL 29
Shift Left: ADD Register Pair HL to itself. This multiplies HL by 2. Any overflow sets the CARRY FLAG.
4F2E
ADC A,A 8F
Add with Carry: ADD Register A to itself plus the CARRY FLAG. This propagates any overflow from the HL shift into the high byte accumulator A (treating HL:A as a 24-bit value).
4F2F
ADD HL,HL 29
Shift Left again: ADD Register Pair HL to itself. This multiplies the original HL by 4 total. CARRY propagates any overflow.
4F30
ADC A,A 8F
Add with Carry: propagate overflow into Register A.
4F31
BIT 0,B CB40
Test bit 0 of Register B (hex mode flag). If bit 0 is set (hex mode), the Z FLAG is cleared; if bit 0 is clear (decimal mode), the Z FLAG is set.
4F33
If the Z FLAG (Zero) has been set (meaning decimal mode, bit 0 clear), JUMP to 4F38H to multiply by 10 instead of 16.
Hex mode: multiply by 16 (shift left 4 bits total). Already shifted twice (×4), need two more shifts.
4F35
ADD HL,HL 29
Shift Left again: multiplies by 8 total.
4F36
JUMP (unconditionally) to 4F39H to perform the final shift for ×16.
Decimal mode: multiply by 10 = ×8 + ×2. Already have ×4 in HL and original in DE.
4F38H - Decimal Mode Multiply by 10
In decimal mode, this adds the original value (in DE) to the ×4 value (in HL) to get ×5, then shifts left once more to get ×10.
4F38
ADD HL,DE 19
ADD Register Pair DE (the original value) to Register Pair HL (which is ×4), giving ×5. This implements the ×10 algorithm: (×4 + ×1) ×2 = ×10.
4F39H - Final Multiply and Add Digit
This completes the multiplication and adds the new digit to form the final accumulated value.
4F39
ADC A,A 8F
Add with Carry: propagate any overflow into Register A.
4F3A
ADD HL,HL 29
Shift Left one final time. For hex mode, this completes the ×16 multiplication. For decimal mode, this completes the ×10 multiplication (shifting ×5 left once more).
4F3B
ADC A,A 8F
Add with Carry: final overflow propagation into Register A.
4F3C
LD E,C 59
Copy Register C (the new digit) into Register E to prepare for addition.
4F3D
LD D,00H 1600
Load Register D with 00H, creating a 16-bit value in DE with the new digit in the low byte.
4F3F
ADD HL,DE 19
ADD Register Pair DE (the new digit) to Register Pair HL (the multiplied accumulated value). HL now contains the complete new accumulated value.
4F40
ADC A,A 8F
Add with Carry: if the addition caused overflow beyond 16 bits, propagate it into Register A. Register A now contains any overflow bits (making this effectively a 24-bit accumulator).
4F41
EX DE,HL EB
EXchange Register Pairs DE and HL. The new accumulated value (from HL) is now in DE where it belongs for the next iteration or return.
4F42
POP HL E1
Restore Register Pair HL (command line pointer) from the stack.
4F43
If the NZ FLAG (Not Zero) has been set (meaning Register A is not zero, there was overflow beyond 16 bits), JUMP to 4F0DH to trigger error 2FH (value too large).
4F45
INC HL 23
INCrement Register Pair HL by 1 to advance to the next character in the command line.
4F46
[LOOP] JUMP BACK to 4F15H to parse the next character. The loop continues until a non-hex character is encountered.
4F48H - Data Tables and String Constants
4F48H - Hexadecimal Output Buffer
This 6-byte buffer is used to store the ASCII hexadecimal representation of addresses for display purposes. The buffer is initialized with "000000" and gets filled by the hex conversion routine at 4E8DH.
4F48
JR NC,4F7AH 3030
DATA: Bytes 30 30 (ASCII "00") - This is actually data, not code. These are the first two characters of the hex output buffer template.
4F4A
JR NC,4F7CH 3030
DATA: Bytes 30 30 (ASCII "00") - Characters 3-4 of the buffer.
4F4C
LD C,B 48
DATA: Byte 48 (ASCII 'H') - This is the hexadecimal suffix character.
4F4D
INC BC 03
DATA: Byte 03 - Part of the next string or padding byte.
4F4EH - " TO " Separator String
This null-terminated string is used as a separator when displaying device configurations (between device name and address).
4F4E
JR NZ,4FA4H 2054
DATA: Bytes 20 54 (ASCII " T") - First two characters of " TO ".
4F50
LD C,A 4F
DATA: Byte 4F (ASCII 'O') - Third character.
4F51
JR NZ,4F56H 2003
DATA: Bytes 20 03 - Fourth character (space) and padding/null terminator.
4F53H - Device Command Lookup Table
This table contains device command keywords followed by their flags byte and handler address. Each entry consists of: null-terminated device name string, padding byte, device flags byte (1 byte), handler address (2 bytes). The table is terminated by a null byte. Device flags encoding: bit 7=valid device, bit 6=modifier keyword, bit 5=address parameter type, bit 4=alternate installation.
[KB Device Entry] Keyboard device command
4F53
LD C,E 4B
DATA: Byte 4B (ASCII 'K') - First character of "KB".
4F54
LD B,D 42
DATA: Byte 42 (ASCII 'B') - Second character of "KB".
4F55
NOP 00
DATA: Byte 00 - Null terminator for "KB" string.
4F56
POP BC C1
DATA: Byte C1 - Device flags: bit 7=1 (valid), bit 6=1 (modifier), bit 0=1.
4F57
DEC D 15
DATA: Byte 15 - Low byte of handler address.
4F58
LD B,B 40
DATA: Byte 40 - High byte of handler address. Handler = 4015H.
[DO Device Entry] Display Output device command
4F59
LD B,H 44
DATA: Byte 44 (ASCII 'D') - First character of "DO".
4F5A
LD C,A 4F
DATA: Byte 4F (ASCII 'O') - Second character of "DO".
4F5B
NOP 00
DATA: Byte 00 - Null terminator for "DO" string.
4F5C
JP NZ,401DH C2
DATA: Bytes C2 1D 40 - Flags (C2H) and handler address (401DH).
[PR Device Entry] Printer device command
4F5F
LD D,B 50
DATA: Byte 50 (ASCII 'P') - First character of "PR".
4F60
LD D,D 52
DATA: Byte 52 (ASCII 'R') - Second character of "PR".
4F61
NOP 00
DATA: Byte 00 - Null terminator for "PR" string.
4F62
JP NZ,4025H C2
DATA: Bytes C2 25 40 - Flags (C2H) and handler address (4025H).
[NL Device Entry] Non-Line device command
4F65
LD C,(HL) 4E
DATA: Byte 4E (ASCII 'N') - First character of "NL".
4F66
LD C,H 4C
DATA: Byte 4C (ASCII 'L') - Second character of "NL".
4F67
NOP 00
DATA: Byte 00 - Null terminator for "NL" string.
4F68
LD B,E 43
DATA: Byte 43 - Device flags: bit 6=1, bit 1-0=11.
4F69
CALL M,434CH FC
DATA: Bytes FC 4C 43 - Handler address (434CH, but FC is parsed as part of flags context).
[CLEAR Device Entry] Clear command
4F6C
LD C,H 4C
DATA: Byte 4C (ASCII 'L') - Character in "CLEAR".
4F6D
LD B,L 45
DATA: Byte 45 (ASCII 'E') - Character in "CLEAR".
4F6E
LD B,C 41
DATA: Byte 41 (ASCII 'A') - Character in "CLEAR".
4F6F
LD D,D 52
DATA: Byte 52 (ASCII 'R') - Last character of "CLEAR".
4F70
NOP 00
DATA: Byte 00 - Null terminator for "CLEAR" string.
4F71
SUB B 90
DATA: Byte 90 - Device flags: bit 7=1, bit 4=1.
4F72
NOP 00
DATA: Byte 00 - Low byte of handler address.
4F73
NOP 00
DATA: Byte 00 - High byte of handler address. Handler = 0000H (null/default). Also serves as table terminator.
4F74H - Memory Management Display Template
This string template is used when displaying unknown device codes or memory management parameters. It provides a "MM=00000000" format for showing hexadecimal values.
4F74
LD C,L 4D
DATA: Byte 4D (ASCII 'M') - First 'M' in "MM=".
4F75
LD C,L 4D
DATA: Byte 4D (ASCII 'M') - Second 'M' in "MM=".
4F76
DEC A 3D
DATA: Byte 3D (ASCII '=') - Equals sign.
4F77
NOP 00
DATA: Byte 00 - Null terminator for "MM=" string.
4F78
LD H,B 60
DATA: Byte 60 - Unknown purpose, padding or additional data.
4F79
NOP 00
DATA: Byte 00 - Padding.
4F7A
NOP 00
DATA: Byte 00 - Padding.
4F7B
NOP 00
DATA: Byte 00 - Padding.
4F7CH - Display Output (DO) and Other Commands Handler
This handler processes various system configuration commands (F0H+02H and others). It parses command keywords from a table at 503EH, evaluates Y/N parameters, and calls appropriate configuration routines. The handler supports commands like LRL=, REC=, BASE=, BASC=, OASC= with Yes/No options.
4F7C
LD BC,0000H 010000
Load Register Pair BC with 0000H to initialize parameter flags/counters.
4F7F
PUSH BC C5
Save Register Pair BC (initialized to 0000H) onto the stack. This sets up a default parameter value.
4F80
PUSH BC C5
Save Register Pair BC onto the stack again, creating two stack slots for parameters.
4F81
[COMMAND PARSE LOOP START] GOSUB to 4CD5H (SYS0 command line parser) to skip delimiters and check for more parameters. Returns with Z FLAG set if end-of-line, CARRY FLAG set if invalid character.
4F84
If the CARRY FLAG has been set (meaning invalid character encountered), JUMP to 4EEBH to display the error and exit.
4F87
If the Z FLAG (Zero) has been set (meaning end-of-line reached), JUMP to 4FBFH to process the collected parameters and execute the command.
More parameters exist. Look up the keyword in the command table.
4F89
LD BC,503EH 013E50
Point Register Pair BC to 503EH, the start of the configuration command keyword table (LRL=, REC=, BASE=, BASC=, OASC=).
4F8C
GOSUB to 4EC9H to look up the keyword in the table at BC. Returns with A = flags, DE = handler address, Z FLAG set if found.
4F8F
PUSH DE D5
Save Register Pair DE (handler address from table lookup) onto the stack.
4F90
LD D,A 57
Copy Register A (keyword flags) into Register D for later use.
4F91
RET C9
DATA/CODE HYBRID: This appears to be code but positioned oddly. RETurn would exit prematurely. This might be data or unreachable code.
4F92H - Y/N Parameter Parser
This routine parses Yes/No parameters from the command line. It looks for 'Y' (Yes) or 'N' (No) characters and returns the appropriate flag value in Register E.
4F92
LD E,00H 1E00
Load Register E with 00H, initializing it to "No" (false) by default.
4F94
LD A,(HL) 7E
Fetch the current character from the command line at (HL) into Register A.
4F95
CP 59H FE59
Compare Register A against 59H (ASCII 'Y' for Yes). If Register A equals 59H, the Z FLAG is set.
4F97
INC HL 23
INCrement Register Pair HL by 1 to advance past the Y/N character.
4F98
If the Z FLAG (Zero) has been set (meaning character was 'Y'), JUMP to 4FA0H to set the "Yes" flag.
Character was not 'Y'. Check if it's 'N' for No.
4F9A
DEC E 1D
DECrement Register E by 1. E was 00H, so it becomes FFH. This will be used to distinguish explicit 'N' from default.
4F9B
CP 4EH FE4E
Compare Register A against 4EH (ASCII 'N' for No). If Register A equals 4EH, the Z FLAG is set.
4F9D
If the NZ FLAG (Not Zero) has been set (meaning character was neither 'Y' nor 'N'), JUMP to 4F0DH to trigger error 2FH (invalid parameter).
Valid 'N' character found. Combine with flags and return.
4FA0H - Combine Y/N Flag With Device Flags
This routine combines the Yes/No flag (in E) with the device flags (in D) and updates the parameter stack.
4FA0
LD A,D 7A
Copy Register D (device/command flags) into Register A.
4FA1
AND E A3
Perform AND operation between Register A and Register E. This masks the flags with the Y/N value.
4FA2
POP BC C1
Restore Register Pair BC from the stack (previously pushed parameter value).
4FA3
OR C B1
Perform OR operation between Register A and Register C. This combines the new flag with any previously accumulated flags.
4FA4
LD C,A 4F
Copy the combined result from Register A into Register C.
4FA5
PUSH BC C5
Save the updated Register Pair BC (with combined flags) back onto the stack.
4FA6
JUMP (unconditionally) to 4FBDH to continue processing the next parameter.
4FA8H - Hexadecimal Address Parameter Handler
This routine handles configuration parameters that require hexadecimal address values. It parses the address, validates it, and stores it on the parameter stack for later processing.
4FA8
GOSUB to 4EEFH to parse a hexadecimal address from the command line. Returns with the address in Register Pair DE and advances HL past the parsed value.
4FAB
DEC DE 1B
DECrement Register Pair DE by 1. This adjusts the parsed address down by one byte for some reason (perhaps to convert from an inclusive end address to a count, or to adjust for off-by-one addressing).
4FAC
LD A,D 7A
Copy Register D (high byte of adjusted address) into Register A to check if the address is valid.
4FAD
OR A B7
Perform OR operation on Register A with itself to test if D is zero. If D = 00H (address < 0100H), the Z FLAG is set.
4FAE
If the NZ FLAG (Not Zero) has been set (meaning D is not zero, address is ≥ 0100H, invalid for this parameter), JUMP to 4F9DH which leads to error 2FH (invalid parameter). This suggests the parameter must be a single-byte value (00H-FFH).
Address is in valid range (00H-FFH). Store it on the parameter stack.
4FB0
POP BC C1
Restore Register Pair BC from the stack (parameter flags from previous processing).
4FB1
INC E 1C
INCrement Register E by 1. This undoes the DEC DE at 4FABH, restoring the original parsed value.
4FB2
LD B,E 43
Copy Register E (the parameter value) into Register B.
4FB3
PUSH BC C5
Save Register Pair BC (with the parameter value in B and flags in C) onto the stack.
4FB4
JUMP (unconditionally) to 4FBDH to continue processing.
4FB6H - Store Address Parameter Without Validation
This routine stores a full 16-bit address parameter onto the stack without the single-byte validation performed by 4FA8H. It's used for commands that accept full address ranges.
4FB6
GOSUB to 4EEFH to parse a hexadecimal address from the command line. Returns with the address in Register Pair DE.
4FB9
POP BC C1
Restore Register Pair BC from the stack (parameter flags).
4FBA
POP AF F1
Restore Register Pair AF from the stack (previously stored parameters or return address).
4FBB
PUSH DE D5
Save Register Pair DE (the parsed address) onto the stack.
4FBC
PUSH BC C5
Save Register Pair BC (flags) back onto the stack.
4FBDH - Continue Command Parameter Loop
This routine continues the parameter parsing loop, checking for more keywords and parameters on the command line.
4FBD
[LOOP] JUMP BACK to 4F81H to parse the next parameter or keyword from the command line.
4FBFH - Execute Configuration Command
This routine executes the configuration command after all parameters have been parsed and stored on the stack. It opens a File Control Block (FCB) for the default template at 4480H, validates it, and applies the configuration settings stored in the FCB extent table.
4FBF
POP BC C1
Restore Register Pair BC from the stack (accumulated parameter flags and values).
4FC0
PUSH BC C5
Save Register Pair BC back onto the stack immediately (preserving it for later use while keeping it accessible).
4FC1
LD A,44H 3E44
Load Register A with 44H, which is an SVC function code for opening or accessing files.
4FC3
LD DE,4480H 118044
Point Register Pair DE to 4480H, the default FCB template buffer in the SYS0 area. This buffer is used for temporary file operations.
4FC6
GOSUB to 4D28H (the special DOS command handler setup routine) to prepare the system for a file operation. This sets up alternate registers and return paths.
4FC9
PUSH DE D5
Save Register Pair DE (pointer to FCB at 4480H) onto the stack.
4FCA
POP IX DDE1
Restore the FCB pointer from the stack into Index Register IX. IX now points to the FCB at 4480H.
4FCC
RES 7,(IX+01H) DDCB01BE
RESET bit 7 of the byte at address IX+01H (FCB offset +01H = FCB flags byte). Bit 7 is the "file open" flag. This marks the FCB as closed/available.
4FD0
GOSUB to 494BH (SYS0 directory lookup routine) to search for the file specified in the FCB. Returns with Z FLAG set if file found, NZ FLAG if not found or error.
4FD3
If the NZ FLAG (Not Zero) has been set (meaning file not found or error occurred), JUMP to 4EEBH to display the error and exit.
File found. Extract configuration parameters from the FCB extent table and apply them.
4FD6
POP BC C1
Restore Register Pair BC from the stack (the parameter flags and values that were accumulated during parsing).
4FD7
LD A,C 79
Copy Register C (the flags byte) into Register A for processing.
4FD8
AND C0H E6C0
Perform AND operation between Register A and C0H (binary 11000000). This isolates bits 6-7 of the flags byte, masking off all other bits.
4FDA
LD C,A 4F
Copy the masked result back into Register C. C now contains only the high 2 bits of the original flags.
4FDB
INC HL 23
INCrement Register Pair HL by 1. HL appears to be pointing to some data structure, advancing to the next field.
4FDC
LD A,(HL) 7E
Fetch the byte from the address pointed to by HL into Register A.
4FDD
AND 1FHAND 00011111 E61F
Perform AND operation between Register A and 1FH (binary 00011111). This isolates the lower 5 bits, masking off the upper 3 bits.
4FDF
OR C B1
Perform OR operation between Register A and Register C. This combines the lower 5 bits from (HL) with the upper 2 bits from the flags, creating a composite configuration byte.
4FE0
LD (HL),A 77
Store the combined configuration byte back into the memory location pointed to by HL.
4FE1
INC HL 23
INCrement Register Pair HL by 1 to advance to the next field.
4FE2
INC HL 23
INCrement Register Pair HL by 1.
4FE3
INC HL 23
INCrement Register Pair HL by 1. HL has advanced 3 bytes total.
4FE4
LD (HL),B 70
Store Register B (the parameter value from earlier parsing) into the memory location pointed to by HL.
4FE5
LD (IX+02H),02H DD360200
Store 02H into the FCB at offset +02H (IX+02H). This sets a flag or counter in the FCB structure.
4FE9
GOSUB to 491FH (SYS0 write directory sector routine) to write the updated configuration back to the directory on disk. Returns with Z FLAG set if successful, NZ FLAG if error.
4FEC
If the NZ FLAG (Not Zero) has been set (meaning write error), JUMP to 4EEBH to display the error and exit.
Configuration successfully written to disk. Continue processing any additional parameters.
4FEF
POP HL E1
Restore Register Pair HL from the stack (likely a saved parameter or return address).
4FF0
LD A,H 7C
Copy Register H into Register A to test if HL is zero.
4FF1
OR L B5
Perform OR operation between Register A and Register L. If HL = 0000H, the Z FLAG will be set.
4FF2
If the Z FLAG (Zero) has been set (meaning HL is 0000H, no more processing needed), JUMP to 5035H to finalize and return.
HL is not zero. Process it as a multiplier or additional parameter.
4FF4
LD A,B 78
Copy Register B (parameter value) into Register A for multiplication setup.
4FF5
OR A B7
Perform OR operation on Register A with itself to test if B is zero. The Z FLAG will be set if A = 00H.
4FF6
LD C,A 4F
Copy Register A into Register C, preserving the parameter value.
4FF7
If the NZ FLAG (Not Zero) has been set (meaning B is not zero), GOSUB to 4C9DH (SYS0 16-bit multiply routine) to multiply HL by the value in a register (HL = HL × multiplier).
4FFA
LD A,C 79
Copy Register C back into Register A.
4FFB
OR A B7
Perform OR operation on Register A with itself to test flags and set up for the next operation.
4FFC
PUSH AF F5
Save Register Pair AF onto the stack (preserving flags and the parameter value).
4FFD
PUSH HL E5
Save Register Pair HL onto the stack (the multiplied result or address parameter).
4FFE
If the NZ FLAG (Not Zero) has been set (meaning the parameter was not zero), JUMP to 5001H to skip the adjustment.
5000
DEC HL 2B
DECrement Register Pair HL by 1. This adjusts the address down by one when the parameter was zero (some special case handling).
5001H - Store Configuration Address and Execute
This routine stores the final configuration address into system variables and executes the configuration by calling into DOS/MINI-DOS mode.
5001
LD (448AH),HL 228A44
Store Register Pair HL into memory location 448AH in the SYS0 area. This appears to be a configuration address or parameter storage location.
5004
PUSH HL E5
Save Register Pair HL onto the stack again for later use.
5005
LD HL,4439H 213944
Point Register Pair HL to 4439H in the SYS0 area. This appears to be a routine entry point or command handler.
5008
LD (4D34H),HL 22344D
Store Register Pair HL (4439H) into memory location 4D34H. This is self-modifying code - 4D34H is within this module at the instruction at 4D33H, modifying a JP 0000H to JP 4439H.
500B
LD HL,436BH 216B43
Point Register Pair HL to 436BH, the DOS system flags byte 2 in the SYS0 area.
500E
SET 1,(HL) CBCE SET 1,(HL)
SET bit 1 of the byte at address (HL). This sets bit 1 of the DOS system flags byte 2 at 436BH, enabling a special DOS mode or flag.
5010
GOSUB to 4D27H (special DOS command handler setup) to execute the configuration operation through the DOS/MINI-DOS system.
5013
RES 1,(HL) CB8E
RESET bit 1 of the byte at address (HL) (DOS flags at 436BH). This clears the special mode flag that was set at 500EH.
5015
LD HL,4D4DH 214D4D
Point Register Pair HL to 4D4DH, which is the KB device installation handler entry point in this module.
5018
LD (4483H),HL 228344
Store Register Pair HL into memory location 4483H in the SYS0 area. This appears to set a function pointer or handler address.
501B
XOR A AF
Set Register A to ZERO by XORing it with itself. This will be used to clear memory.
501C
LD B,A 47
Copy Register A (00H) into Register B, preparing for a memory clear loop counter.
501D
LD (HL),A 77
[MEMORY CLEAR LOOP START] Store Register A (00H) into the memory location pointed to by HL, clearing the byte.
501E
INC HL 23
INCrement Register Pair HL by 1 to point to the next byte.
501F
[LOOP] DECrement Register B and JUMP BACK to 501DH if B is not zero. This clears 256 bytes starting from 4D4DH (clearing the KB handler area or buffer).
[MEMORY CLEAR LOOP END] Buffer cleared. Now process the configuration operation in a loop until complete.
5021
POP BC C1
Restore Register Pair BC from the stack (the address or count parameter).
5022
INC BC 03
INCrement Register Pair BC by 1 (adjusting the count or address).
5023
LD H,A 67
Copy Register A (00H) into Register H.
5024
LD L,A 6F
Copy Register A (00H) into Register L. Register Pair HL is now 0000H.
5025
LD (448AH),HL 228A44
Store Register Pair HL (0000H) into memory location 448AH, clearing the configuration address.
5028
DEC BC 0B
DECrement Register Pair BC by 1 (undoing the increment at 5022H or counting down).
5029
[OPERATION LOOP START] GOSUB to 4439H (SYS0 routine) to execute one iteration of the configuration operation. Returns with Z FLAG set if successful.
502C
If the NZ FLAG (Not Zero) has been set (meaning an error occurred), JUMP to 4EEBH to display the error and exit.
502F
LD A,B 78
Copy Register B into Register A to test the counter.
5030
OR C B1
Perform OR operation between Register A and Register C. If BC = 0000H, the Z FLAG will be set.
5031
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning more iterations needed, BC not zero), LOOP BACK to 5028H to continue the operation.
[OPERATION LOOP END] All iterations complete. Clean up and return.
5033
POP HL E1
Restore Register Pair HL from the stack (saved earlier).
5034
POP AF F1
Restore Register Pair AF from the stack (saved flags and parameter).
5035H - Finalize Configuration and Return
This routine finalizes the configuration operation by storing the final parameters into system variables and calling a completion handler.
5035
LD (448CH),HL 228C44
Store Register Pair HL into memory location 448CH in the SYS0 area. This appears to store a final configuration address or end pointer.
5038
LD (4488H),A 328844
Store Register A into memory location 4488H in the SYS0 area. This stores a configuration flag or parameter byte.
503B
JUMP to 4428H (SYS0 routine) to complete the configuration operation and return to DOS Ready.
503EH - Memory Configuration Command Table
This table contains memory and record configuration command keywords. Each entry consists of: keyword string (null-terminated), padding byte, flags byte, handler address (2 bytes). Commands include LRL=, REC=, BASE=, BASC=, OASC= for various memory and record length settings.
[LRL= Command Entry] Logical Record Length configuration
503E
DEFM 'LRL='4C 52 4C 3D
"LRL="
5042
NOP 00
DATA: Byte 00 - Null terminator and padding.
5043
NOP 00
DATA: Byte 00 - Padding.
5044
XOR B A8
DATA: Byte A8 - Flags byte: bit 7=1, bit 5=1, bit 3=1.
5045
LD C,A 4F
DATA: Byte 4F - Low byte of handler address.
[REC= Command Entry] Record configuration
5046
DEFM 'REC=' 52 45 43 3D
"REC="
504A
NOP 00
DATA: Byte 00 - Null terminator and padding.
504B
NOP 00
DATA: Byte 00 - Padding.
504C
OR (HL) B6
DATA: Byte B6 - Flags byte: bit 7=1, bit 5=1, bit 4=1, bit 2=1, bit 1=1.
504D
LD C,A 4F
DATA: Byte 4F - Low byte of handler address. Handler = 4FB6H (from high byte at next entry).
[BASE= Command Entry] Base address configuration
504E
DEFM 'BASE=' 41 54 45 3D
"BASE="
5052
NOP 00
DATA: Byte 00 - Null terminator.
5053
ADD A,B 80
DATA: Byte 80 - Flags byte: bit 7=1.
5054
SUB D 92
DATA: Byte 92 - Low byte of handler address.
5055
LD C,A 4F
DATA: Byte 4F - High byte. Handler = 4F92H.
[BASC= Command Entry] Base ASCII configuration
5056
DEFM 'BASC=' 41 53 43 3D
"BASC="
505A
NOP 00
DATA: Byte 00 - Null terminator.
505B
LD B,B 40
DATA: Byte 40 - Flags byte: bit 6=1.
505C
SUB D 92
DATA: Byte 92 - Low byte of handler address.
505D
LD C,A 4F
DATA: Byte 4F - High byte. Handler = 4F92H.
505E
NOP 00
DATA: Byte 00 - Table terminator.
505FH - Non-Line (NL) Device Command Handler
This handler processes the non-line device command (F0H+04H). It parses START= address parameters from the command line and stores them in a parameter table. The routine supports multiple START= specifications for different device configurations.
505F
LD A,(HL) 7E
Fetch the current character from the command line at (HL) into Register A.
5060
CP 0DH FE0D
Compare Register A against 0DH (carriage return, end-of-line). If Register A equals 0DH, the Z FLAG is set.
5062
If the Z FLAG (Zero) has been set (meaning end-of-line reached), JUMP to 5079H to finalize the command.
Command line has parameters. Parse START= keywords and addresses.
5064
LD BC,50B8H 01B850
Point Register Pair BC to 50B8H, the start of the START=/END=/MEM= command table.
5067
GOSUB to 4EC9H to look up the keyword in the table at BC. Returns with A = flags, DE = handler address.
506A
PUSH DE D5
Save Register Pair DE (handler address) onto the stack for storage in the parameter table.
506B
GOSUB to 4EEFH to parse a hexadecimal address from the command line. Returns with the address in Register Pair DE.
506E
EX (SP),HL E3
EXchange the top of stack with Register Pair HL. HL now contains the handler address (from the stack), and the stack contains the command line pointer.
506F
LD (HL),E 73
Store Register E (low byte of parsed address) into the memory location pointed to by HL (the handler address position in the table).
5070
INC HL 23
INCrement Register Pair HL by 1 to point to the next byte.
5071
LD (HL),D 72
Store Register D (high byte of parsed address) into the memory location pointed to by HL. The 16-bit address is now stored in the table.
5072
POP HL E1
Restore Register Pair HL (command line pointer) from the stack.
5073
GOSUB to 4CD5H (SYS0 command line parser) to skip delimiters and check for more parameters. Returns with Z FLAG set if end-of-line, CARRY FLAG set if invalid.
5076
RET C D8
RETurn if the CARRY FLAG has been set (meaning invalid character encountered, error already flagged).
5077
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning more parameters exist), LOOP BACK to 5064H to parse the next START= parameter.
All parameters parsed. Initialize system for memory management operation.
5079H - Initialize Memory Management and RAM Testing
This routine initializes the system for memory management operations. It clears interrupt vectors, sets up timer callbacks, detects high memory, validates memory boundaries, and prepares a buffer area for memory operations.
5079
GOSUB to 4E01H to disable interrupts and search the device driver chain (with DE=0000H to find any entry). This clears device configurations.
507C
LD HL,0000H 210000
Load Register Pair HL with 0000H to clear the interrupt vector pointer.
507F
LD (4051H),HL 225140
Store Register Pair HL (0000H) into memory location 4051H in the SYS0 area. This appears to be the disk interrupt handler hook, clearing it to disable disk interrupts during memory operations.
5082
LD HL,44C9H 21C944
Point Register Pair HL to 44C9H, the timer callback table in the SYS0 area.
5085
LD (461DH),HL 221D46
Store Register Pair HL into memory location 461DH in the SYS0 area. This sets up or clears the timer callback pointer.
5088
LD HL,(43A9H) 2AA943
Fetch the 16-bit value stored at memory location 43A9H (high memory address pointer from SYS0) into Register Pair HL. This is the detected top of RAM.
508B
LD DE,FFFFH 11FFFF
Load Register Pair DE with FFFFH, the maximum possible 16-bit address.
508E
LD A,D 7A
Copy Register D (FFH) into Register A for comparison.
508F
CP 70H FE70
Compare Register A (FFH) against 70H. Since A=FFH, A > 70H, so the NO CARRY FLAG is set. This appears to be checking a different condition than intended.
5091
If the CARRY FLAG has been set (which it won't be since FFH > 70H), JUMP to 4F0DH to trigger error. This check seems unusual.
5094
RST 18H DF
Call RST 18H (compare HL with DE). Sets CARRY FLAG if HL < DE. This compares high memory pointer (HL) with FFFFH (DE).
5095
If the CARRY FLAG has been set (meaning HL < FFFFH, which should always be true), JUMP to 5098H to use HL as the high memory limit.
5097
EX DE,HL EB
EXchange Register Pairs DE and HL. This would set HL = FFFFH if HL ≥ FFFFH (but this path is unlikely to execute).
5098H - Set Memory Boundaries and Validate Buffer Area
This routine sets the high memory pointer, validates that there's sufficient memory available, and prepares a buffer area at 5200H by testing and initializing the memory.
5098
LD (4049H),HL 224940
Store Register Pair HL (the high memory limit) into memory location 4049H in the SYS0 area. This sets the high memory pointer that DOS uses to limit program loading.
509B
LD DE,FFFFH 11FFFF
Load Register Pair DE with FFFFH (a negative offset of -1 in two's complement).
509E
RST 18H DF
Call RST 18H (compare HL with DE / HL-DE). This subtracts FFFFH from HL, effectively adding 1.
509F
If the NO CARRY FLAG has been set (meaning HL was ≥ 0000H after subtraction, no underflow), JUMP to 50A2H to continue with HL unchanged.
50A1
EX DE,HL EB
EXchange Register Pairs DE and HL. This handles the underflow case by swapping values.
50A2
LD HL,5200H 210052
Point Register Pair HL to 5200H, which is the minimum required buffer/workspace address for memory operations.
50A5
LD A,H 7C
Copy Register H (52H) into Register A for validation.
50A6
CP 52H FE52
Compare Register A against 52H. This is a redundant check since H must be 52H. If A < 52H, CARRY FLAG is set.
50A8
If the CARRY FLAG has been set (meaning H < 52H, address < 5200H), JUMP to 4F0DH to trigger error 2FH (insufficient memory). This check will never trigger since we just loaded HL with 5200H.
Address is 5200H. Test if this memory location is accessible and within available RAM.
50AB
DEC HL 2B
DECrement Register Pair HL by 1 to point to 51FFH (one byte before the buffer area).
50AC
RST 18H DF
Call RST 18H (compare HL with DE). Sets CARRY FLAG if HL < DE. This checks if the buffer area (51FFH) is below the high memory limit.
50AD
If the NO CARRY FLAG has been set (meaning HL ≥ DE, buffer area is at or above high memory), JUMP to 4F0DH to trigger error 2FH (insufficient memory between system area and high memory).
Sufficient memory available. Initialize the buffer area by filling it with zeros and testing for proper write/read.
50B0
INC HL 23
INCrement Register Pair HL by 1 to point back to 5200H (the buffer start).
50B1
LD (HL),00H 3600
[BUFFER CLEAR LOOP START] Store 00H into the memory location pointed to by HL, clearing/initializing the byte.
50B3
RST 18H DF
Call RST 18H (compare HL with DE). This checks if we've reached the high memory limit.
50B4
[LOOP] If the CARRY FLAG has been set (meaning HL < DE, more memory to clear), LOOP BACK to 50B1H to clear the next byte.
[BUFFER CLEAR LOOP END] Buffer area cleared and tested. Return successfully.
50B6
XOR A AF
Set Register A to ZERO by XORing it with itself, indicating successful completion.
50B7
RET C9
RETurn to caller. The memory management system is now initialized and the buffer area is ready for use.
50B8H - Memory Range Command Table (START=, END=, MEM=)
This table contains keywords for memory range configuration commands. Each entry: keyword string, null terminator, padding, flags byte, handler address (2 bytes).
[START= Command Entry]
50B8
DEFM 'START=' 53 54 41 52 54 3D
"START=".
50BE
NOP 00
DATA: Byte 00 - Null terminator.
50BF
NOP 00
DATA: Byte 00 - Padding.
50C0
AND E A3
DATA: Byte A3 - Flags byte.
50C1
LD D,B 50
DATA: Byte 50 - High byte of handler address. Handler = 50A3H.
[END= Command Entry]
50C2
DEFM 'END=' 45 4E 44 3D
"END=".
50C6
NOP 00
DATA: Byte 00 - Null terminator.
50C7
NOP 00
DATA: Byte 00 - Padding.
50C8
SBC A,H 9C
DATA: Byte 9C - Flags byte.
50C9
LD D,B 50
DATA: Byte 50 - High byte of handler address. Handler = 509CH.
[MEM= Command Entry]
50CA
DEFM 'MEM=' 4D
"MEM=".
50CE
NOP 00
DATA: Byte 00 - Null terminator.
50CF
NOP 00
DATA: Byte 00 - Padding.
50D0
ADC A,H 8C
DATA: Byte 8C - Flags byte.
50D1
LD D,B 50
DATA: Byte 50 - High byte of handler address. Handler = 508CH.
50D2
NOP 00
DATA: Byte 00 - Table terminator.
50D3H - Memory Management (MM=) Display Setup
This handler prepares to display the memory management (MM=) configuration. It stores error code 3BH at 5170H and appears to set up for showing the current memory boundaries.
50D3
LD A,3BH 3E 3B
Load Register A with 3BH, error code 59 decimal (possibly "out of range" or "invalid memory configuration").
50D5
LD (5170H),A 32 70 51
Store Register A (3BH) into memory location 5170H, a variable used to store error codes during memory management operations.
50D8H - CLEAR Command Handler
This handler processes the CLEAR command (F0H+05H) which clears line input configuration. It manipulates the stack to restore previous state, validates command line syntax, and calls subroutines to process memory range parameters with direction flags (increment/decrement).
50D8
POP AF F1
Restore Register Pair AF from the stack, discarding a return address that was placed there during command processing.
50D9
POP HL E1
Restore Register Pair HL from the stack, recovering the command line pointer.
50DA
GOSUB to 4CD5H (SYS0 command line parser) to skip delimiters and check for more parameters. Returns with Z FLAG set if end-of-line, CARRY FLAG set if invalid character.
50DD
LD DE,0001H 11 01 00
Load Register Pair DE with 0001H, a direction flag indicating increment/forward operation.
50E0
If the NZ FLAG (Not Zero) has been set (meaning more parameters exist), GOSUB to 515DH to parse and validate the parameters with the increment direction.
50E3
PUSH DE D5
Save Register Pair DE (direction flag) onto the stack for later use.
50E4
LD DE,FFFFH 11 FF FF
Load Register Pair DE with FFFFH (which is -1 in two's complement), a direction flag indicating decrement/backward operation.
50E7
If the NZ FLAG (Not Zero) has been set, GOSUB to 515DH to parse and validate parameters with the decrement direction.
50EA
If the NZ FLAG (Not Zero) has been set (meaning an error occurred during parsing), JUMP to 5168H to handle the error.
Parameters validated successfully. Initialize the memory clearing operation by setting up the buffer and display loop.
50EC
POP BC C1
Restore Register Pair BC from the stack (the saved direction flag from 50E3H).
50ED
LD HL,4200H 21 00 42
Point Register Pair HL to 4200H, which appears to be a display buffer or work area for the clearing operation.
50F0
LD (4483H),HL 22 83 44
Store Register Pair HL (4200H) into memory location 4483H in the SYS0 area, setting up a pointer for the operation.
50F3
DEC BC 0B
DECrement Register Pair BC by 1, adjusting the count or direction value.
50F4
LD A,B 78
Copy Register B into Register A to test if BC is zero.
50F5
OR C B1
Perform OR operation between Register A and Register C. If BC = 0000H, the Z FLAG will be set.
50F6
If the Z FLAG (Zero) has been set (meaning BC is zero, no iterations needed), JUMP to 5101H to enter the single-character input loop.
[DISPLAY COUNTDOWN LOOP START] BC is not zero. Display carriage returns while counting down.
50F8
GOSUB to 5128H to read a keyboard character (with validation and filtering). Returns the character in Register A.
50FB
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If Register A equals 0DH, the Z FLAG is set.
50FD
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning the character was NOT carriage return), LOOP BACK to 50F8H to wait for Enter key.
50FF
JUMP BACK to 50F3H to decrement BC and continue the countdown loop.
5101H - Single Character Input Loop
This loop reads characters from the keyboard one at a time, displays them, and processes special keys like carriage return. It implements a character-by-character display mode with BREAK key detection.
5101
[CHARACTER INPUT LOOP START] GOSUB to 5128H to read and validate a keyboard character. Returns the character in Register A.
5104
GOSUB to 516DH to display the character in Register A on the screen (outputs carriage return first, then the character).
5107
DEC C 0D
DECrement Register C by 1. This counts down characters or operations.
5108
If the Z FLAG (Zero) has been set (meaning C reached zero, limit reached), JUMP to 5113H to enter BREAK key detection mode.
510A
CP 0DH FE 0D
Compare Register A against 0DH (carriage return). If Register A equals 0DH, the Z FLAG is set.
510C
[LOOP] If the NZ FLAG (Not Zero) has been set (meaning character was NOT carriage return), LOOP BACK to 5101H to get the next character.
Carriage return detected. Decrement DE counter and check if more lines needed.
510E
DEC DE 1B
DECrement Register Pair DE by 1, counting down the number of lines or operations remaining.
510F
LD A,D 7A
Copy Register D into Register A to test if DE is zero.
5110
OR E B3
Perform OR operation between Register A and Register E. If DE = 0000H (no more lines), the Z FLAG will be set.
5111
If the Z FLAG (Zero) has been set (meaning all lines processed), JUMP to 5158H to finalize and exit successfully.
5113H - BREAK Key Detection Mode
This routine enables BREAK key detection during the character processing loop. It checks for BREAK, CLEAR, UP, or DOWN arrow key presses to allow the user to interrupt or control the operation.
5113
LD C,00H 0E 00
Load Register C with 00H, resetting the character counter or clearing a flag.
5115
LD A,(3840H) 3A 40 38
[BREAK CHECK LOOP START] Fetch the byte from keyboard row 6 at memory location 3840H into Register A. This row contains ENTER, CLEAR, BREAK, and arrow keys.
5118
AND 48HAND 01001000 E6 48
Perform AND operation between Register A and 48H (binary 01001000). This tests bit 3 (BREAK key) and bit 6 (UP arrow key).
511A
If the Z FLAG (Zero) has been set (meaning neither BREAK nor UP is pressed), JUMP BACK to 5101H to continue normal character processing.
Either BREAK or UP arrow was pressed. Check which specific key by testing individual bits.
511C
LD A,(3840H) 3A 40 38
[KEY DEBOUNCE LOOP START] Fetch the keyboard row 6 byte again from 3840H into Register A.
511F
AND 09H E6 09
Perform AND operation between Register A and 09H (binary 00001001). This tests bit 0 (CLEAR key) and bit 3 (BREAK key).
5121
[LOOP] If the Z FLAG (Zero) has been set (meaning neither CLEAR nor BREAK is pressed), LOOP BACK to 511CH to continue checking (debounce loop waiting for key release).
[KEY DEBOUNCE LOOP END] A key is pressed. Determine which one and take appropriate action.
5123
RRCA 0F
Rotate Register A Right Circular. Bit 0 moves to CARRY FLAG and bit 7. This moves the CLEAR key bit (bit 0) into the CARRY FLAG.
5124
If the NO CARRY FLAG has been set (meaning bit 0 was clear, CLEAR key NOT pressed, so BREAK was pressed), JUMP to 5158H to exit (treating BREAK as abort).
5126
JUMP BACK to 5101H to continue character processing (CLEAR key was pressed, continue operation).
5128H - Keyboard Character Read with Validation
This routine reads a character from the keyboard with extensive validation and filtering. It checks for BREAK key, validates input against allowed character codes stored at 4480H, and filters control characters. Returns the validated character in Register A.
5128
LD A,(3840H) 3A 40 38
Fetch the byte from keyboard row 6 at memory location 3840H into Register A to check for BREAK key.
512B
AND 08HAND 00001000 E6 08
Perform AND operation between Register A and 08H (binary 00001000). This tests bit 3, which is the BREAK key.
512D
If the NZ FLAG (Not Zero) has been set (meaning bit 3 is set, BREAK key is pressed), JUMP to 5157H to handle the BREAK condition by exiting.
BREAK key not pressed. Read a character from the keyboard using ROM routine.
512F
PUSH DE D5
Save Register Pair DE onto the stack to preserve it during the ROM call.
5130
LD DE,4480H 11 80 44
Point Register Pair DE to 4480H, the filename parsing buffer / FCB template in the SYS0 area. This appears to contain allowed character codes or a validation table.
5133
GOSUB to ROM routine at 0013H (keyboard input with character set validation). Reads a character and validates it against the allowed set at DE. Returns character in Register A, Z FLAG set if invalid.
5136
POP DE D1
Restore Register Pair DE from the stack.
5137
If the NZ FLAG (Not Zero) has been set (meaning the character was invalid according to validation table), JUMP to 514EH to check for special error codes.
Valid character received. Filter control characters and check against system maximum.
5139
AND 7FHAND 01111111 E6 7F
Perform AND operation between Register A and 7FH (binary 01111111). This strips the high bit, ensuring the character is in the standard ASCII range (00H-7FH).
513B
PUSH HL E5
Save Register Pair HL onto the stack.
513C
LD HL,4370H 21 70 43
Point Register Pair HL to 4370H in the SYS0 area, which contains the disk parameter from boot sector or maximum allowed character code.
513F
CP (HL) BE
Compare Register A against the byte at (HL). This checks if the character code is within the allowed range. Sets Z FLAG if equal, CARRY FLAG if A < (HL).
5140
POP HL E1
Restore Register Pair HL from the stack.
5143
If the NZ FLAG (Not Zero) has been set (meaning A is not equal to the maximum and A is greater than or equal to the maximum, so A > maximum), JUMP to 514BH to substitute with a safe character.
5145H - Control Character Filter
This routine filters control characters (00H-1FH) to ensure only printable characters and carriage return are allowed through.
5145
CP 20H FE20
Compare Register A against 20H (ASCII space character). If A < 20H (control character range), the CARRY FLAG is set.
5147
RET NC D0
RETurn if the NO CARRY FLAG has been set (meaning A >= 20H, character is printable). The character in A is valid.
5148
CP 0DH FE0D
Compare Register A against 0DH (ASCII carriage return). If Register A equals 0DH, the Z FLAG is set.
514A
RET Z C8
RETurn if the Z FLAG (Zero) has been set (meaning character is carriage return, which is allowed). The character 0DH is valid.
Character is a control character (00H-1FH) other than carriage return. Substitute with a period.
514BH - Substitute Invalid Character With Period
This routine substitutes invalid or out-of-range characters with a period (2EH) for safe display.
514B
LD A,2EH 3E2E
Load Register A with 2EH (ASCII period character '.'). This is a safe substitution character for invalid input.
514D
RET C9
RETurn to caller with the substituted character (period) in Register A.
514EH - Handle Special Error Codes
This routine checks if the keyboard input returned special error codes (1CH or 1DH) which indicate position errors or special conditions.
514E
CP 1CH FE1C
Compare Register A against 1CH (error code 28 decimal - position error before start of file). If Register A equals 1CH, the Z FLAG is set.
5150
If the Z FLAG (Zero) has been set (meaning error 1CH detected), JUMP to 5157H to exit by discarding return address.
5152
CP 1DH FE1D
Compare Register A against 1DH (error code 29 decimal - position error past EOF). If Register A equals 1DH, the Z FLAG is set.
5154
If the NZ FLAG (Not Zero) has been set (meaning error was neither 1CH nor 1DH, some other error), JUMP to 4EEBH to display the error and exit.
Error code 1DH (position past EOF) detected. Exit through the same path as BREAK.
5157H - BREAK Key or Error Exit
This routine handles the BREAK key press or certain error conditions by discarding the return address from the stack to exit the current operation.
5157
POP AF F1
Discard the return address from the stack (using AF to restore stack without actually returning to that address). This aborts the current operation.
5158H - Success Exit - Display Final CR and Return
This routine completes the operation successfully by displaying a final carriage return and clearing the error code to indicate success.
5158
GOSUB to 516BH to display a carriage return character (0DH), moving the cursor to the next line.
515B
XOR A AF
Set Register A to ZERO by XORing it with itself. This indicates successful completion (no error).
515C
RET C9
RETurn to caller with A=00H indicating success.
515DH - Parse and Validate Memory Range Parameters
This routine validates memory range parameters by checking if the parsed value produces a CARRY condition, indicating an error or invalid range.
515D
If the CARRY FLAG has been set (meaning an error occurred during parsing), JUMP to 4EE9H to trigger error 34H (parse error).
5160
GOSUB to 4EEFH to parse a hexadecimal address from the command line. Returns with the address in Register Pair DE and advances HL past the value.
5163
LD A,D 7A
Copy Register D (high byte of parsed address) into Register A for validation.
5164
OR E B3
Perform OR operation between Register A and Register E. If DE = 0000H, the Z FLAG will be set.
5165
If the NZ FLAG (Not Zero) has been set (meaning DE is not zero, valid address), JUMP to 4CD5H (SYS0 parser) to continue processing and return normally.
DE is 0000H, indicating an invalid or null address. Fall through to error handler.
5168H - Invalid Parameter Error
This routine triggers error 2FH (invalid parameter) when memory range validation fails.
5168
JUMP to 4F0DH to load error code 2FH and display the error message.
516BH - Display Carriage Return
This routine displays a carriage return character (0DH) on the screen by calling the display routine at 516DH with CR pre-loaded.
516B
LD A,0DH 3E0D
Load Register A with 0DH (ASCII carriage return character).
516DH - Display Character With CR Prefix
This routine displays a carriage return followed by the character in Register A. It preserves DE and AF across the ROM display calls.
516D
PUSH DE D5
Save Register Pair DE onto the stack to preserve it during ROM calls.
516E
PUSH AF F5
Save Register Pair AF (which contains the character to display) onto the stack.
516F
GOSUB to ROM routine at 0033H to display the character in Register A (currently 0DH - carriage return) on the screen at the cursor position and advance cursor.
5172
POP AF F1
Restore Register Pair AF from the stack, recovering the original character to display.
5173
POP DE D1
Restore Register Pair DE from the stack.
5174
RET C9
RETurn to caller. The carriage return and character have been displayed.
5175H - Unused/Padding Area
This area contains unused bytes (all 00H/NOP) that pad the module to its end address. This ensures the module fits within its allocated memory space and provides room for future expansion.
5175-51E7
DEFB 00H (×115) 00 00 00...
DATA: 115 bytes of 00H (NOP instructions if executed, but intended as padding). This fills the remainder of the module from 5175H to 51E7H (the last address shown in the disassembly), providing unused space for potential patches or future code additions.