TRS-80 DOS - NEWDOS/80 v2.0 for the Model I - SUPERZAP/CMD Disassembled

Page Customization

SUPERZAP/CMD/CMD - NEWDOS/80 v2.0 Disk Checker Utility

Variable and Memory Map

Self-Modifying Code Locations

Major Routines and Entry Points

Pool File Format

Technical Notes and Implementation Details

Disassembly:

5200H - Conditional Copy of Relative Sector to Current Display Position

This routine checks bit 3 of the mode flags at 5491H (the "memory mode" flag indicating whether we're working with memory rather than disk). If bit 3 is set, the routine exits early without doing anything. Otherwise, it copies the relative sector value from 54B4H to the current display position variable at 5495H. This allows SUPERZAP to track which relative sector is currently being displayed.

5200
LD A,(5491H) 3A 91 54
Load Register A with the mode flags byte from address 5491H. This byte contains various operational mode bits: bit 1 = file mode, bit 3 = memory mode, bit 4 = jump pending, bit 5 = alternate display, bit 6 = file open.
5203
BIT 3,A CB 5F
Test bit 3 of Register A (the memory mode flag). If bit 3 is set (1), the Z flag is cleared (NZ condition); if bit 3 is clear (0), the Z flag is set (Z condition). Bit 3 indicates we are in memory zap mode rather than disk sector mode.
5205
RET NZ C0
If the NZ flag is set (meaning bit 3 was 1, indicating memory mode), return immediately from this subroutine. In memory mode, there is no concept of "relative sector" so we skip this operation.
5206
LD HL,(54B4H) 2A B4 54
Load Register pair HL with the 16-bit relative sector number from addresses 54B4H-54B5H. This is the sector offset within the current file or disk being examined.
5209
LD (5495H),HL 22 95 54
Store the relative sector number from HL into the current display position variable at 5495H-5496H. This records which relative sector is currently being shown on screen.
520C
RET C9
Return from subroutine.

520DH - Initialize HL and C from E, Store to 54C3H

This short routine sets Register L, Register H, and Register C all to the value in Register E, then stores HL to address 54C3H. This appears to be used for initializing position or offset values. The address 54C3H holds a 16-bit position value used in various SUPERZAP operations.

520D
LD L,E 6B
Copy Register E into Register L. Register E contains the initialization value passed by the caller.
520E
LD H,E 63
Copy Register E into Register H. Now HL contains E in both bytes (forming E*256+E if E≠0, or 0000H if E=0).
520F
LD C,E 4B
Copy Register E into Register C. This sets C to the same initialization value.
5210
LD (54C3H),HL 22 C3 54
Store Register pair HL into the position/offset variable at addresses 54C3H-54C4H. This variable is used by SUPERZAP to track various position states.
5213
RET C9
Return from subroutine.

5214H - Load H from 54B3H and Store HL to 54C3H

This routine loads a byte from 54B3H into Register H (the high byte of the track/sector indicator), then jumps to 5210H to store HL into 54C3H. This is used to set up position tracking with a specific high byte value.

5214
LD A,(54B3H) 3A B3 54
Load Register A with the byte stored at address 54B3H. This location holds the high byte of the relative sector or a track indicator value.
5217
LD H,A 67
Copy Register A into Register H. This sets the high byte of HL to the value just loaded.
5218
Jump relative backward to 5210H to store HL into 54C3H and return. The L register retains whatever value it had on entry.

521AH - Reserved Space (NOP Padding)

This area from 521AH to 52FFH contains NOP instructions (00H bytes). This is reserved space, possibly for future expansion or patch area. The NOPs serve no functional purpose in normal execution.

521A-52FF
NOP (repeated) 00
No operation. This block of 230 bytes (521AH through 52FFH) is filled with NOPs, serving as reserved/unused space within SUPERZAP.

54C5H - SUPERZAP Main Entry Point and Initialization

This is the main entry point for SUPERZAP (as indicated by "PROGRAM ENTRY = 54C5H" in the disassembly). This routine initializes the stack pointer, clears mode flags, sets up buffer pointers, copies default values from ROM to RAM, and then proceeds to display the main menu and parse command line arguments. The initialization sets up the operating environment for all SUPERZAP functions.

54C5
LD SP,5300H 31 00 53
Initialize the Stack Pointer to 5300H. This establishes the stack area just below the sector buffer at 5300H, growing downward toward lower addresses.
54C8
XOR A AF
Clear Register A to zero by XORing it with itself. Also clears the carry flag.
54C9
LD (5493H),A 32 93 54
Store zero into the secondary mode flags at address 5493H. This clears all secondary mode bits (bit 4 = sector changed, bit 5 = alternate mode, bit 7 = reverse direction).
54CC
LD HL,5300H 21 00 53
Load Register pair HL with 5300H, the address of the sector data buffer.
54CF
LD (5423H),HL 22 23 54
Store 5300H into the buffer pointer at 5423H-5424H. This sets up the pointer to the sector buffer used for disk read/write operations.
54D2
LD (5495H),HL 22 95 54
Store 5300H into the display position variable at 5495H-5496H. This initializes the current display position.
54D5
LD HL,5420H 21 20 54
Load Register pair HL with 5420H, the address of the default initialization data stored in ROM/initial data area.
54D8
LD DE,5400H 11 00 54
Load Register pair DE with 5400H, the address of the working variable area where the defaults will be copied.
54DB
LD BC,0020H 01 20 00
Load Register pair BC with 0020H (32 decimal), the number of bytes to copy from the default area to the working area.
54DE
LDIR ED B0
Block copy 32 bytes from address 5420H (pointed to by HL) to address 5400H (pointed to by DE). HL and DE are incremented, BC is decremented until BC=0. This initializes the working variables with default values.

Initialization complete. Now display the main menu banner and process command line.

54E0
Load Register pair HL with 6C30H, the address of the SUPERZAP banner/menu text string to be displayed.
54E3
Call the display string with prompt routine at 634EH. This displays the SUPERZAP menu/banner and waits for user input, returning the command line pointer in HL and Z flag set if only ENTER was pressed.
54E6
LD DE,690FH 11 0F 69
Load Register pair DE with 690FH, the address of the command keyword table. This table contains the valid SUPERZAP command names and their associated flags/addresses.
54E9
If the Z flag is set (user pressed only ENTER with no command), jump forward to 550BH to handle the empty command case (likely re-display menu or default action).

[LOOP START] - Command parsing loop. Search the keyword table for a matching command.

54EB
DEC DE 1B
Decrement DE by 1 to adjust the table pointer position.
54EC
DEC DE 1B
Decrement DE again. The table pointer is now positioned for the search loop.
54ED
PUSH HL E5
Save the current command line pointer (HL) onto the stack for later restoration if this keyword doesn't match.
54EE
DEC HL 2B
Decrement HL to prepare for the comparison loop that follows.
54EF
DEC DE 1B
Decrement DE to move backward in the keyword table.
54F0
INC DE 13
Increment DE to advance to the next character in the keyword.
54F1
INC HL 23
Increment HL to advance to the next character in the user's input.
54F2
LD A,(DE) 1A
Load Register A with the current character from the keyword table (pointed to by DE).
54F3
CP (HL) BE
Compare Register A with the character from the user's command line (pointed to by HL). If they match, Z flag is set.
54F4
If the characters match (Z flag set), jump back to 54F0H to compare the next character pair. [LOOP]
54F6
BIT 7,A CB 7F
Test bit 7 of Register A. In the keyword table, bit 7 being set indicates the end of the keyword (last character has high bit set).
54F8
If bit 7 was set (NZ), we've reached the end of a keyword and the match was successful. Jump to 550BH to process the matched command.

Keyword didn't match - skip to the next keyword in the table.

54FA
INC DE 13
Increment DE to scan forward in the keyword table.
54FB
LD A,(DE) 1A
Load the next byte from the keyword table.
54FC
BIT 7,A CB 7F
Test bit 7 to check if this is the last character of the current keyword.
54FE
If bit 7 is clear (Z), we haven't reached the end of this keyword yet. Loop back to continue scanning. [LOOP]
5500
INC DE 13
Increment DE past the keyword's terminator.
5501
INC DE 13
Skip past the first byte of the keyword's data (flags byte).
5502
INC DE 13
Skip past the second byte of the keyword's data (address low).
5503
INC DE 13
Skip past the third byte of the keyword's data (address high). DE now points to the next keyword.
5504
POP HL E1
Restore the original command line pointer from the stack.
5505
LD A,(DE) 1A
Load the first byte of the next keyword entry.
5506
OR A B7
Test if Register A is zero (OR A sets Z flag if A=0). A zero byte marks the end of the keyword table.
5507
If not zero (more keywords remain), jump back to 54EDH to try matching the next keyword. [LOOP]
5509
No keyword matched and we've reached the end of the table. Jump back to 54C5H to reinitialize and redisplay the menu.

550BH - Process Matched Command or Handle Options

This routine is called when a command keyword has been matched (or when handling the command line after the keyword). It checks for the ",P" option (printer mode), validates command flags, and ultimately dispatches to the appropriate command handler. The routine reads the command flags byte and the handler address from the keyword table entry.

550B
LD B,00H 06 00
Clear Register B to zero. This initializes the command modifier flags (bit 1 will be set if ",P" option is found).
550D
LD A,(HL) 7E
Load Register A with the current character from the command line (pointed to by HL).
550E
CP 2CH FE 2C
Compare Register A with 2CH (ASCII comma ,). Check if the user specified an option.
5510
If not a comma, jump to 5521H to check for end of line and proceed with command execution.
5512
INC HL 23
Increment HL to point past the comma to the option character.
5513
LD A,(HL) 7E
Load the option character into Register A.
5514
CP 50H FE 50
Compare with 50H (ASCII P). Check if this is the ",P" (printer) option.
5516
INC HL 23
Increment HL to point past the option character.
5517
If not P, this is an unrecognized option. Jump to 5500H to skip to the next keyword (treating this as a non-match).
5519
LD A,(DE) 1A
Load the command flags byte from the keyword table entry (pointed to by DE).
551A
BIT 0,A CB 47
Test bit 0 of the flags byte. Bit 0 indicates whether this command supports the printer option.
551C
If bit 0 is clear (Z), the command doesn't support printer mode. Jump to the error handler at 65B9H to display an error message.
551F
LD B,02H 06 02
Set Register B to 02H. This sets bit 1 in B, indicating the printer option was specified.
5521
LD A,(HL) 7E
Load the current command line character into Register A.
5522
CP 0DH FE 0D
Compare with 0DH (ASCII carriage return). Check if we've reached the end of the command line.
5524
If not at end of line, there's extra text after the command. Jump to 5500H to try the next keyword match.

Command matched and validated. Now extract and process the command entry from the keyword table.

5526
EX DE,HL EB
Exchange DE and HL. Now HL points to the keyword table entry and DE points to the command line.
5527
LD A,(HL) 7E
Load the command flags byte from the keyword table entry into Register A.
5528
AND 7FHAND 01111111 E6 7F
Mask off bit 7 (the high-bit marker) keeping only the flag bits 0-6.
552A
OR B B0
OR in the modifier flags from Register B (bit 1 = printer option). This combines the command flags with any user-specified options.
552B
LD (5491H),A 32 91 54
Store the combined flags into the mode flags variable at 5491H. This configures the operation mode for the command.
552E
INC HL 23
Increment HL to point to the next byte in the keyword table entry (secondary flags).
552F
LD A,(HL) 7E
Load the secondary flags byte from the keyword table entry.
5530
LD (5492H),A 32 92 54
Store the secondary flags into address 5492H. These control additional command behavior.
5533
BIT 3,A CB 5F
Test bit 3 of the secondary flags. Bit 3 indicates this command requires system disk validation.
5535
If bit 3 is clear, skip the system disk check and continue to 553FH.
5537
LD A,(436AH) 3A 6A 43
Load Register A with the system configuration byte from DOS address 436AH. This contains system status flags.
553A
BIT 5,A CB 6F
Test bit 5 of the system configuration. Bit 5 indicates write-protected system mode or similar restriction.
553C
If bit 5 is set (system is protected), jump to the error handler at 65BEH to display an appropriate error message.
553F
INC HL 23
Increment HL to point to the command handler address (low byte).
5540
LD A,(HL) 7E
Load the low byte of the handler address into Register A.
5541
INC HL 23
Increment HL to point to the high byte of the handler address.
5542
LD H,(HL) 66
Load the high byte of the handler address into Register H.
5543
LD L,A 6F
Load the low byte (from Register A) into Register L. Now HL contains the command handler address.
5544
JP (HL) E9
Jump to the address in HL. This dispatches to the command handler for the matched command.

5545H - "J" Command Handler (Jump to Disk/Track/Sector)

This routine handles the "J" (Jump) command when in disk mode with the jump pending flag set. It prompts for disk/track/sector parameters, validates input, and positions SUPERZAP to display the specified location.

5545
Load HL with 6D3BH, the address of the disk number prompt string.
5548
Call the display string and get input routine at 634EH. Display the prompt and wait for user input.
554B
If Z flag is set (user pressed ENTER only), jump to 55A0H to use default values and continue.
554D
Call the parse disk number routine at 670FH. Parse the disk number from user input.
5550
If carry flag is set (parse error), jump back to 5545H to re-prompt. [LOOP]
5552
Jump forward to 555AH to continue with track/sector prompts.

5554H - "K" Command Handler (Track/Sector Jump) Entry

This entry point handles the "K" command when the jump pending flag (bit 4) is set. It prompts for track number input.

5554
Load HL with 6D44H, the address of the track number prompt string.
5557
Call the display string and get input routine. Display track prompt and wait for user input.
555A
If Z flag is set (ENTER only), jump to 55A0H to use defaults.
555C
Call the parse track number routine at 6732H.
555F
If carry set (error), loop back to re-prompt for track. [LOOP]
5561
Jump forward to 5569H to continue with sector prompt.

5563H - Sector Number Prompt

Prompts for sector number input after disk and track have been specified.

5563
Load HL with 6D4BH, the address of the sector number prompt string.
5566
Display the sector prompt and get user input.
5569
If Z flag set (ENTER only), jump to 5570H to continue with defaults.
556B
Call the parse sector number routine at 6751H.
556E
If carry set (error), loop back to re-prompt. [LOOP]
5570
LD A,(549EH) 3A 9E 54
Load Register A with the sectors per track value from address 549EH.
5573
LD L,A 6F
Copy sectors per track into Register L.
5574
LD A,(549BH) 3A 9B 54
Load Register A with the tracks per side (or granules) value from 549BH.
5577
Call the multiply A×L routine at 687BH to calculate total sectors.
557A
LD A,(54A0H) 3A A0 54
Load Register A with the starting sector offset from 54A0H.
557D
LD E,A 5F
Copy the offset into Register E.
557E
LD D,00H 16 00
Clear Register D, making DE a 16-bit value with the offset.
5580
ADD HL,DE 19
Add the offset (DE) to the total (HL). HL now contains the absolute sector address.
5581
EX DE,HL EB
Exchange DE and HL. DE now holds the absolute sector address.
5582
Jump forward to 55A7H to continue processing.

5584H - "J" Command - Physical Disk/Sector Jump

This routine handles the physical disk jump when no special mode flags are set.

5584
Load HL with 6D50H, the address of the disk prompt string for physical mode.
5587
Display the disk prompt and get user input.
558A
If Z flag set (ENTER only), jump to 55A0H for defaults.
558C
Call the parse disk number routine.
558F
If error, loop back to re-prompt. [LOOP]
5591
Jump forward to continue.

5593H - Absolute Sector Prompt

Prompts for absolute sector number in physical disk mode.

5593
Load HL with 6D58H, the address of the absolute sector prompt string.
5596
Display the prompt and get user input.
5599
If Z flag set, jump to 55A0H for defaults.
559B
Call the parse absolute sector routine at 679EH.
559E
If error, loop back to re-prompt. [LOOP]
55A0
Call the read disk parameters routine at 67B5H to set up disk geometry information.
55A3
LD DE,(54A2H) ED 5B A2 54
Load Register pair DE with the current absolute sector from address 54A2H-54A3H.
55A7
LD HL,(54A8H) 2A A8 54
Load Register pair HL with the maximum sector number from address 54A8H-54A9H.
55AA
LD (540CH),HL 22 0C 54
Store the maximum sector into address 540CH-540DH (working variable).
55AD
LD (54A2H),DE ED 53 A2 54
Store DE (current sector) into the absolute sector variable at 54A2H-54A3H.
55B1
LD HL,(54A2H) 2A A2 54
Load HL with the absolute sector number (just stored).
55B4
LD (540AH),HL 22 0A 54
Store it into the FCB sector field at 540AH-540BH for the DOS read operation.
55B7
LD A,(5491H) 3A 91 54
Load the mode flags byte from 5491H.
55BA
BIT 1,A CB 4F
Test bit 1 (printer mode flag).
55BC
If printer mode is active (bit 1 set), jump to 5BB8H for printer output handling.
55BF
Call the read sector routine at 6457H to read the sector into the buffer.
55C2
Jump to 56BAH to enter the main display/edit loop.

55C5H - File Zap Command Handler Entry

This routine handles file-based zap operations. It prompts for a filespec, opens the file, and sets up for file sector editing. The routine validates the file exists and is accessible before proceeding.

55C5
OR 0C0HOR 11000000 F6 C0
OR Register A with C0H, setting bits 6 and 7. This sets the file mode flags.
55C7
Call the DOS routine at 4409H to prepare for file operations.
55CA
Load HL with 6D5DH, the address of the filespec prompt string.
55CD
LD DE,5400H 11 00 54
Load DE with 5400H, the address of the FCB (File Control Block) buffer.
55D0
LD B,1FH 06 1F
Load Register B with 1FH (31 decimal), the maximum filespec length.
55D2
Call the get filespec input routine at 633CH.
55D5
If Z flag set (empty input), return to the main menu at 54C5H.
55D8
LD DE,5400H 11 00 54
Load DE with the FCB buffer address again.
55DB
LD HL,5300H 21 00 53
Load HL with 5300H, the sector buffer address.
55DE
LD B,00H 06 00
Clear Register B (file open flags = 0 for read mode).
55E0
Call the DOS OPEN file routine at 4424H.
55E3
If NZ (file open failed), jump back to 55C5H to re-prompt. [LOOP]
55E5
LD HL,5401H 21 01 54
Load HL with 5401H, pointing to the FCB flags byte.
55E8
SET 6,(HL) CB F6
Set bit 6 of the FCB flags, indicating file is open.
55EA
LD A,(5406H) 3A 06 54
Load Register A with the drive number from FCB offset 06H.
55ED
LD (5499H),A 32 99 54
Store the drive number into the current drive variable at 5499H.
55F0
LD A,(5491H) 3A 91 54
Load the mode flags from 5491H.
55F3
BIT 3,A CB 5F
Test bit 3 (memory mode flag).
55F5
If bit 3 is clear (not memory mode), jump to 5641H for normal file handling.

Memory mode - load file into memory for editing.

55F7
LD HL,5300H 21 00 53
Load HL with 5300H, the memory load address.
55FA
LD (5403H),HL 22 03 54
Store the load address into FCB offset 03H-04H.
55FD
LD HL,0000H 21 00 00
Load HL with 0000H.
5600
LD (540AH),HL 22 0A 54
Store 0000H into FCB offset 0AH-0BH (starting record = 0).
5603
Call the read sector/file routine to load the file.
5606
LD HL,(5300H) 2A 00 53
Load HL with the first two bytes of the loaded file (load address for /CMD files).
5609
LD (54B2H),HL 22 B2 54
Store this value into 54B2H-54B3H for reference.
560C
EX DE,HL EB
Exchange DE and HL. DE now contains the load address.
560D
LD HL,5487H 21 87 54
Load HL with 5487H, address of a display format buffer.
5610
PUSH HL E5
Save HL on the stack.
5611
Call the convert DE to hex string routine at 61EAH.
5614
LD (HL),48H 36 48
Store 48H (ASCII H) at the current position as the hex suffix.
5616
INC HL 23
Increment HL past the 'H'.
5617
POP HL E1
Restore HL from the stack (back to 5487H).
5618
LD B,05H 06 05
Load B with 05H, the number of characters to display.
561A
Call the display B characters from HL routine at 62BAH.
561D
Load HL with 6D2DH, address of a continuation message.
5620
Call the display string routine at 6245H.
5623
Load HL with 6D7BH, address of the relative sector prompt.
5626
Display prompt and get input.
5629
Call the parse hex/decimal number routine at 6770H.
562C
If error (carry set), loop back to re-prompt. [LOOP]
562E
LD E,00H 1E 00
Clear Register E.
5630
LD (54B4H),DE ED 53 B4 54
Store DE into the relative sector variable at 54B4H-54B5H.
5634
LD A,(5491H) 3A 91 54
Load the mode flags.
5637
BIT 1,A CB 4F
Test bit 1 (printer mode).
5639
If printer mode, jump to 5668H for printer output.
563B
Call routine at 617BH to set up display.
563E
Jump to the main display/edit loop at 56BAH.

5641H - File Relative Sector Prompt

Prompts for relative sector number when in file mode (not memory mode).

5641
Load HL with 6D68H, address of the relative sector prompt for file mode.
5644
Display prompt and get input.
5647
Parse the relative sector number.
564A
If error, loop back. [LOOP]
564C
Jump to 55ADH to continue with sector setup.

564FH - Alternate Relative Sector Prompt

Alternative entry for relative sector prompting with different initial conditions.

564F
Load HL with 6D36H, address of alternate relative sector prompt.
5652
Display prompt and get input.
5655
Parse the input as hex/decimal.
5658
If error, loop back. [LOOP]
565A
LD E,00H 1E 00
Clear Register E.
565C
LD (54B4H),DE ED 53 B4 54
Store DE into the relative sector variable.
5660
LD A,(5491H) 3A 91 54
Load mode flags.
5663
BIT 1,A CB 4F
Test printer mode flag.
5665
If not printer mode, jump to 56BDH.

5668H - Printer Output Setup

Sets up for printer output mode, calculating how many sectors to print.

5668
Call routine at 66E1H to initialize printer output mode.
566B
LD C,10H 0E 10
Load Register C with 10H (16 decimal), the sectors per page for printing.
566D
LD HL,(54ACH) 2A AC 54
Load HL with the remaining byte count from 54ACH-54ADH.
5670
LD DE,0100H 11 00 01
Load DE with 0100H (256 decimal), one sector's worth of bytes.
5673
OR A B7
Clear the carry flag for the subtraction.
5674
SBC HL,DE ED 52
Subtract 256 from the remaining count. Check if at least one more sector remains.
5676
If no borrow (NC), at least 256 bytes remain. Jump to 568FH to continue.
5678
OR A B7
Clear carry for addition.
5679
ADC HL,DE ED 5A
Add 256 back to restore the original count (since we borrowed).
567B
If result is zero (Z), no more data to print. Jump to 65C6H to finish.
567E
LD A,L 7D
Load Register A with the low byte of remaining count.
567F
RRCA 0F
Rotate A right (divide by 2).
5680
RRCA 0F
Rotate again (divide by 4).
5681
RRCA 0F
Rotate again (divide by 8).
5682
RRCA 0F
Rotate again (divide by 16). A now contains bytes/16 = lines to print.
5683
AND 0FHAND 00001111 E6 0F
Mask to keep only lower 4 bits (0-15 lines).
5685
LD C,A 4F
Copy line count to Register C.
5686
LD A,L 7D
Reload the low byte of remaining count.
5687
AND 0FHAND 00001111 E6 0F
Check if there's a partial line (count mod 16).
5689
If no partial line (Z), skip incrementing C.
568B
INC C 0C
Increment C to account for the partial line.
568C
LD HL,0000H 21 00 00
Clear HL to zero.
568F
LD (54ACH),HL 22 AC 54
Store the updated remaining count.
5692
Call the update display position routine at 5200H.
5695
BIT 3,A CB 5F
Test bit 3 (memory mode) of Register A (returned from 5200H).
5697
If in memory mode, jump to 56A2H.
5699
Call routine at 613AH to output sector data.
569C
LD HL,54B5H 21 B5 54
Load HL with address of relative sector high byte.
569F
INC (HL) 34
Increment the relative sector number (high byte).
56A0
Loop back to 566BH to continue printing. [LOOP]
56A2
PUSH BC C5
Save BC on the stack.
56A3
Call routine at 617BH for memory mode output setup.
56A6
POP BC C1
Restore BC from the stack.
56A7
Jump to 5699H to continue processing.

56A9H - Display Error Message (Sector Out of Range)

Displays an error message when the user attempts to access a sector that is out of the valid range.

56A9
Load HL with 6E20H, address of the "out of range" error message.
56AC
LD A,4BH 3E 4B
Load Register A with 4BH (ASCII K), the command to retry.
56AE
PUSH AF F5
Save AF on the stack.
56AF
Call the display string routine to show the error message.
56B2
Load HL with 6DD5H, address of a continuation prompt.
56B5
Call routine to display string and wait for keypress.
56B8
Jump to 571AH to process the keystroke.

56BAH - Main Display/Edit Loop Initialization

This is the main entry point for the sector display and editing loop. It initializes the stack pointer and display position, then enters the command processing loop where users can view and modify sector data.

56BA
LD DE,5300H 11 00 53
Load DE with 5300H, the sector buffer address.
56BD
LD (5495H),DE ED 53 95 54
Store DE into the display position variable at 5495H-5496H.
56C1
LD SP,5300H 31 00 53
Reset the Stack Pointer to 5300H, cleaning up any stale stack data.
56C4
Call the display sector contents routine at 5FB2H to show the current sector on screen.
56C7
LD HL,5493H 21 93 54
Load HL with 5493H, address of the secondary mode flags.
56CA
BIT 4,(HL) CB 66
Test bit 4 of the flags (sector modified flag).
56CC
If bit 4 is clear (sector not modified), jump to 56DBH.

Sector was modified - prompt to write it back to disk.

56CE
RES 4,(HL) CB A6
Clear bit 4 (the modified flag) since we're about to write.
56D0
LD A,(54AEH) 3A AE 54
Load Register A with the original sector number that was modified, from 54AEH.
56D3
LD C,A 4F
Copy the sector number to Register C.
56D4
LD A,95H 3E 95
Load A with 95H, a flag value indicating write with verification.
56D6
Call the write sector routine at 5DBCH to save the modified sector.
56D9
Jump to 56DEH to continue.
56DB
Call routine at 620BH (display status or prompt).
56DE
Call the get command key routine at 5DFAH. Wait for user input and return the key in Register A.

Process the command key entered by the user.

56E1
LD HL,5491H 21 91 54
Load HL with 5491H, address of the mode flags.
56E4
CP 4DH FE 4D
Compare A with 4DH (ASCII M for Modify).
56E6
If not M, jump to 56EDH to check next command.
56E8
BIT 3,(HL) CB 5E
Test bit 3 of mode flags (memory mode).
56EA
If not in memory mode (Z), jump to the Modify handler at 5C5AH.
56ED
CP 58H FE 58
Compare A with 58H (ASCII X for eXit).
56EF
If X, jump to 54C5H to exit to main menu.
56F2
CP 45H FE 45
Compare A with 45H (ASCII E for Edit).
56F4
If E, jump to the Edit handler at 5814H.
56F7
CP 53H FE 53
Compare A with 53H (ASCII S for Search).
56F9
If Register A equals 53H (ASCII S for Search), jump to the Search command handler at 5795H.
56FC
CP 46H FE 46
Compare Register A with 46H (ASCII F for Find/File).
56FE
If F, jump to the Find/File command handler at 582CH.
5701
CP 4CH FE 4C
Compare Register A with 4CH (ASCII L for List).
5703
If not L, jump to 570AH to check next command.
5705
BIT 6,(HL) CB 76
Test bit 6 of the mode flags at (HL=5491H). Bit 6 indicates a file is currently open.
5707
If bit 6 is set (file is open), jump to the List file handler at 5821H.

Check for alternate key mappings: semicolon (;) maps to plus (+), equals (=) maps to minus (-).

570A
CP 3BH FE 3B
Compare Register A with 3BH (ASCII ; semicolon).
570C
If not semicolon, jump to 5710H to continue checking.
570E
LD A,2BH 3E 2B
Replace semicolon with 2BH (ASCII +). This maps ; to + for easier keyboard access on TRS-80.
5710
CP 3DH FE 3D
Compare Register A with 3DH (ASCII = equals sign).
5712
If not equals, jump to 5716H to continue.
5714
LD A,2DH 3E 2D
Replace equals with 2DH (ASCII -). This maps = to - for easier keyboard access.
5716
PUSH AF F5
Save Register A (the command key) and flags onto the stack.
5717
Call the clear command line area routine at 62A7H to prepare for status display.
571A
POP AF F1
Restore Register A (command key) and flags from the stack.
571B
LD HL,5491H 21 91 54
Load HL with 5491H, address of the mode flags byte for testing.
571E
CP 4AH FE 4A
Compare Register A with 4AH (ASCII J for Jump).
5720
If not J, jump to 5734H to check for K command.

J (Jump) command - dispatch based on current mode flags.

5722
BIT 4,(HL) CB 66
Test bit 4 of mode flags (jump pending/disk prompt needed).
5724
If bit 4 set (jump pending), jump to 5545H for disk/track/sector prompt.
5727
BIT 5,(HL) CB 6E
Test bit 5 of mode flags (alternate display mode).
5729
If bit 5 set (alternate mode), jump back to 56C1H to redisplay (J is invalid here).
572B
LD A,(HL) 7E
Load Register A with the mode flags byte from (HL).
572C
AND 48HAND 01001000 E6 48
Mask with 48H to test bits 3 and 6 (memory mode and file open flags).
572E
If either bit 3 or 6 is set, jump to 55CAH for file/memory jump handling.
5731
Otherwise, jump to 5584H for physical disk jump (standard disk sector mode).

5734H - "K" Command Handler (Sector Navigation)

Handles the K command which is used for sector navigation. The behavior varies based on current mode: in alternate mode it prompts for relative sector, in file mode it prompts for file sector, in memory mode it prompts for memory address, and in disk mode it prompts for track/sector.

5734
CP 4BH FE 4B
Compare Register A with 4BH (ASCII K).
5736
If not K, jump to 574FH to check navigation commands (+/-/R).
5738
BIT 5,(HL) CB 6E
Test bit 5 of mode flags (alternate display mode).
573A
If in alternate mode (bit 5 set), jump to 564FH for relative sector prompt.
573D
BIT 6,(HL) CB 76
Test bit 6 of mode flags (file open).
573F
If file is open (bit 6 set), jump to 5641H for file relative sector prompt.
5742
BIT 3,(HL) CB 5E
Test bit 3 of mode flags (memory mode).
5744
If in memory mode (bit 3 set), jump to 5623H for memory address prompt.
5747
BIT 4,(HL) CB 66
Test bit 4 of mode flags (jump pending/track mode).
5749
If bit 4 set, jump to 5554H for track/sector prompt.
574C
Otherwise, jump to 5593H for absolute sector prompt.

574FH - Navigation Key Handler (+, -, R)

Handles the navigation keys: + advances to the next sector, - goes to the previous sector, and R re-reads/refreshes the current sector. The behavior varies based on whether we're in alternate mode (bit 5) or memory mode (bit 3), which changes whether we navigate by absolute sector or relative sector.

574F
BIT 5,(HL) CB 6E
Test bit 5 of mode flags at (HL=5491H) to check for alternate display mode.
5751
If in alternate mode (bit 5 set), jump to 5774H for relative sector navigation.
5753
BIT 3,(HL) CB 5E
Test bit 3 of mode flags (memory mode).
5755
If in memory mode (bit 3 set), jump to 5774H for relative navigation.

Normal disk mode - navigate by absolute sector number.

5757
LD DE,(54A2H) ED 5B A2 54
Load Register pair DE with the current absolute sector number from 54A2H-54A3H.
575B
CP 52H FE 52
Compare Register A with 52H (ASCII R for Re-read/Refresh).
575D
If R, jump to 5771H to re-read the current sector without changing position.
575F
INC DE 13
Increment DE (tentatively advance to next sector).
5760
CP 2BH FE 2B
Compare Register A with 2BH (ASCII +).
5762
If +, jump to 5771H to use the incremented sector number.
5764
CP 2DH FE 2D
Compare Register A with 2DH (ASCII -).
5766
If not -, the key is unrecognized. Jump back to 56C1H to redisplay and wait for valid input.

- key pressed - decrement sector number, but check for underflow (going below sector 0).

5769
DEC DE 1B
Decrement DE (undo the earlier INC).
576A
DEC DE 1B
Decrement DE again to go to the previous sector.
576B
LD A,D 7A
Load Register A with the high byte of DE (sector number).
576C
AND E A3
AND the high byte with the low byte. Result is FFH only if both D and E are FFH (DE=FFFFH, indicating underflow).
576D
INC A 3C
Increment A. If A was FFH (underflow), it becomes 00H and Z flag is set.
576E
If Z flag is set (sector underflowed to FFFFH), jump to 56A9H to display "out of range" error.
5771
Jump to 55ADH to store the new sector number and read/display it.

5774H - Relative Sector Navigation (Alternate/Memory Mode)

Handles navigation when in alternate display mode or memory mode. Instead of navigating by absolute sector number, this uses the relative sector value stored at 54B4H. The high byte of the relative sector (D register) is incremented or decremented.

5774
LD DE,(54B4H) ED 5B B4 54
Load Register pair DE with the relative sector number from 54B4H-54B5H.
5778
CP 52H FE 52
Compare Register A with 52H (ASCII R for Refresh).
577A
If R, jump to 5789H to re-read without changing position.
577C
INC D 14
Increment the high byte of relative sector (D register). This advances by 256 bytes (one display page).
577D
CP 2BH FE 2B
Compare Register A with 2BH (ASCII +).
577F
If +, jump to 5789H to use the incremented value.
5782
CP 2DH FE 2D
Compare Register A with 2DH (ASCII -).
5784
If not -, unrecognized key. Jump back to 56C1H to redisplay.
5787
DEC D 15
Decrement D (undo the earlier INC).
5788
DEC D 15
Decrement D again to go to the previous page.
5789
LD (54B4H),DE ED 53 B4 54
Store the updated relative sector back to 54B4H-54B5H.
578D
BIT 3,(HL) CB 5E
Test bit 3 of mode flags (memory mode).
578F
If not in memory mode (bit 3 clear), jump to 56BDH for standard display update.
5792
In memory mode, jump to 563BH for memory-specific display handling.

5795H - "S" Command Handler (Search)

Handles the S (Search) command. This command searches for a byte pattern across sectors. It validates that the command is appropriate for the current mode, then uses inline parameter data to configure the search. The pattern "COPY" at 579EH-57A1H appears to be placeholder data that gets overwritten with the actual search pattern.

5795
LD A,(HL) 7E
Load Register A with the mode flags byte from (HL=5491H).
5796
AND 68HAND 01101000 E6 68
Mask with 68H to test bits 3, 5, and 6 (memory mode, alternate mode, file open).
5798
If any of these bits are set, Search is not valid. Jump to 56C1H to redisplay.
579B
Call the inline parameter processor at 5803H. This reads parameters from the bytes following this CALL instruction.

The following bytes are inline data, not executable code. They spell "COPY" followed by a NOP (00H) terminator, representing a command signature that 5803H validates.

579E
DEFM "COPY " + 00H 43 4F 50 59 00

Execution resumes here after 5803H returns (it adjusts the return address past the inline data).

57A3
Call the clear command line area routine at 62A7H.
57A6
Call routine at 65D0H to initialize search parameters.
57A9
Load HL with 6DB7H, address of the search pattern prompt string.
57AC
Call routine at 678FH to display prompt and get search pattern input.
57AF
If carry set (user cancelled or error), jump to 6582H to abort the search.
57B2
LD HL,4200H 21 00 42
Load HL with 4200H, the search buffer address where found sectors will be loaded.
57B5
LD (5403H),HL 22 03 54
Store the search buffer address into FCB offset 03H-04H (DMA address).
57B8
LD HL,(54A2H) 2A A2 54
Load HL with the current absolute sector from 54A2H.
57BB
LD (540AH),HL 22 0A 54
Store it into FCB offset 0AH-0BH (sector to search from).
57BE
PUSH HL E5
Save the current sector on the stack.
57BF
Call the sector search routine at 644CH. This performs the actual search operation.
57C2
LD HL,5300H 21 00 53
Load HL with 5300H, the standard sector buffer address.
57C5
LD (5403H),HL 22 03 54
Restore the DMA address to the standard buffer.
57C8
POP HL E1
Restore the original sector number from the stack.
57C9
LD (540AH),HL 22 0A 54
Store it back into the FCB sector field.
57CC
Load HL with 6EABH, address of "NOT FOUND" message (default result).
57CF
If NZ flag (pattern not found), jump to 57DEH to display "NOT FOUND".

Pattern was found. Determine which result message to display based on search type.

57D1
Load HL with 6EB8H, address of "FOUND" message.
57D4
LD A,(5494H) 3A 94 54
Load Register A with the search type flag from 5494H.
57D7
CP 50H FE 50
Compare with 50H (ASCII P for Pattern search).
57D9
If pattern search, jump to 57DEH to display "FOUND".
57DB
Load HL with 6EB3H, address of alternate "FOUND AT" message (for hex search).
57DE
PUSH HL E5
Save the message address on the stack.
57DF
Load HL with 6D0EH, address of a prefix/header message.
57E2
Call routine to display the prefix message.
57E5
POP HL E1
Restore the result message address from the stack.
57E6
Call the display string routine to show the result message.
57E9
Load HL with 6EBCH, address of "PROTECT?" or similar prompt.
57EC
Call routine at 6231H to check/display protection status.
57EF
LD A,20H 3E 20
Load A with 20H (ASCII space), the default search type value.
57F1
If Z flag set, jump to 57F5H to use space as search type.
57F3
LD A,50H 3E 50
Load A with 50H (ASCII P), indicating pattern search type.
57F5
LD (5494H),A 32 94 54
Store the search type flag to 5494H.
57F8
Call routine at 6474H to write sector or finalize the operation.
57FB
Load HL with 6C2DH, address of a completion/status message.
57FE
LD A,52H 3E 52
Load A with 52H (ASCII R), the key code to simulate a Re-read command.
5800
Jump to 56AEH to display the message and return to the command loop.

5803H - Inline Parameter Processor

This utility routine processes inline parameter data that follows a CALL instruction. It reads bytes from the return address, comparing them against user input character by character. When a zero byte (terminator) is found, the routine adjusts the return address to point past the inline data and returns. This allows commands to embed their parameter signatures directly after the CALL instruction.

5803
Call routine at 5DF7H to get the next input character into Register A.
5806
POP HL E1
Pop the return address from the stack into HL. This points to the inline data following the CALL 5803H.
5807
CP (HL) BE
Compare the input character (A) with the expected character at (HL).
5808
INC HL 23
Increment HL to point to the next byte of inline data.
5809
If the characters don't match (NZ), the parameter is wrong. Jump to 56C1H to redisplay the sector.
580C
PUSH HL E5
Push the updated address back onto the stack (for the recursive CALL or final return).
580D
LD A,(HL) 7E
Load the next byte from the inline data.
580E
OR A B7
Test if this byte is zero (the terminator).
580F
If not zero, more characters to check. Jump back to 5803H to process the next one. [LOOP]

Terminator found - all parameters matched. Adjust return address and exit.

5811
POP HL E1
Pop the address (now pointing to the terminator) from the stack.
5812
INC HL 23
Increment HL past the terminator to the actual code that follows the inline data.
5813
JP (HL) E9
Jump to the address in HL, effectively returning past the inline data to continue execution.

5814H - "E" Command Handler (Exit to DOS)

This routine handles the E (Exit) command. It uses the inline parameter processor at 5803H to verify the user typed "EXIT", then clears the command line area and jumps to the DOS warm start entry point at 402DH to return to NEWDOS/80 Ready prompt.

5814
Call the inline parameter processor at 5803H. This routine reads bytes following this CALL and compares them against user input to verify the command keyword.

The following bytes are inline data spelling "XIT" (the "E" was already matched). The routine at 5803H compares each byte against user input.

5817
DEFB 58H 58
Inline data: 58H = ASCII X
5818
DEFB 49H 49
Inline data: 49H = ASCII I
5819
DEFB 54H 54
Inline data: 54H = ASCII T
581A
DEFB 00H 00
Inline data: 00H = terminator byte marking end of keyword

Execution continues here after 5803H validates "EXIT" was typed.

581B
Call the clear command line area routine at 62A7H to clean up the display before exiting.
581E
JP 402DH C3 2D 40
Jump to 402DH, the DOS warm start entry point. This exits SUPERZAP and returns to the NEWDOS/80 Ready prompt.

5821H - "L" Command Handler (List File Sectors)

This routine handles the L (List) command when a file is open (bit 6 of mode flags is set). It saves the current key code, calls the file sector read routine, and determines whether to continue listing or return to the display loop.

5821
LD B,A 47
Copy Register A (the command key L = 4CH) into Register B for later use.
5822
Call the read next file sector routine at 5E37H. This reads the next sector of the open file. Returns with carry set on error, Z flag set if end of file.
5825
If carry flag is set (read error occurred), jump to 5829H to return to the display loop.
5827
If NZ flag (not end of file, more sectors available), jump to 5834H to continue processing.
5829
Jump to 56C1H to return to the main display/edit loop and redisplay the current sector.

582CH - "F" Command Handler (Find/File Operations)

This routine handles the F (Find) command. It initializes the search parameters and calls the file sector read routine to begin searching. If no match is found immediately, it continues to the search setup at 5834H.

582C
LD B,00H 06 00
Clear Register B to zero. This initializes the search direction/mode flags.
582E
Call the read file sector routine at 5E37H. Returns Z flag if at end of file, carry if error.
5831
If Z flag is set (end of file reached), jump to 58BEH to finalize the search setup.

5834H - Find Command Parameter Setup

This section sets up the search parameters for the Find command. It saves various state variables including the search position, mode flags, and relative sector information. The routine handles both memory mode and disk mode searches differently based on the mode flags.

5834
PUSH AF F5
Save Register A and flags onto the stack. A contains the result from the previous sector read.
5835
LD A,B 78
Load Register A with the value from Register B (search mode/direction flags).
5836
LD (54BEH),A 32 BE 54
Store the search mode flags into address 54BEH. This variable controls the search direction (forward/backward).
5839
XOR A AF
Clear Register A to zero.
583A
LD (54C0H),A 32 C0 54
Store zero into address 54C0H. This clears the search offset counter.
583D
LD C,A 4F
Copy zero into Register C, initializing the byte position counter.
583E
LD A,(HL) 7E
Load Register A with the byte at (HL). HL points to the mode flags at 5491H.
583F
AND 28HAND 00101000 E6 28
Mask with 28H to isolate bits 3 and 5 (memory mode and alternate display mode flags).
5841
LD B,A 47
Save the masked mode flags into Register B for later testing.
5842
LD HL,(54B4H) 2A B4 54
Load Register pair HL with the relative sector number from 54B4H-54B5H.
5845
LD (54C3H),HL 22 C3 54
Store the relative sector into 54C3H-54C4H as the search starting position.
5848
If NZ (either memory mode or alternate mode is active), jump to 5851H to skip absolute sector setup.

Standard disk mode - set up search using absolute sector number.

584A
LD L,C 69
Load Register L with C (zero), clearing the low byte.
584B
LD DE,(54A2H) ED 5B A2 54
Load Register pair DE with the current absolute sector from 54A2H-54A3H.
584F
LD H,E 63
Copy the low byte of absolute sector (E) into Register H.
5850
LD C,D 4A
Copy the high byte of absolute sector (D) into Register C.
5851
POP AF F1
Restore Register A and flags from the stack.
5852
If carry flag is set (indicating a special search mode), jump to 586AH for alternate processing.
5854
LD E,00H 1E 00
Clear Register E to zero, initializing the search byte offset.
5856
Call the initialize position variables routine at 520DH. This sets up HL and C from E, then stores to 54C3H.
5859
BIT 3,B CB 58
Test bit 3 of Register B (memory mode flag).
585B
If bit 3 is clear (not in memory mode), jump to 5860H.
585D
Call routine at 5214H to load H from 54B3H and store HL to 54C3H (memory mode position setup).
5860
Call the read file sector routine at 5E37H to get the next sector for searching.
5863
If carry set (error), jump to 5872H to handle the result.
5865
If Z flag set (end of file), jump to 5872H to handle the result.
5867
Jump to 56C1H to return to main display loop (search completed or aborted).

586AH - Alternate Search Mode Entry

This section handles the alternate search mode when the carry flag was set on entry. It processes hex input for the search pattern.

586A
Call routine at 5E2EH to get hex byte input for the search pattern.
586D
If carry set (input error or cancel), jump to 5867H to abort and return to display.
586F
If NZ (valid input received), call the read file sector routine at 5E37H.

5872H - Search Position Calculation

This section calculates and stores the search position within the current sector. It handles the byte offset calculation and adjusts for memory mode if needed.

5872
PUSH AF F5
Save Register A and flags onto the stack.
5873
LD A,E 7B
Load Register A with the value from Register E (the byte offset within the sector).
5874
LD (54C2H),A 32 C2 54
Store the byte offset into address 54C2H. This is the position within sector for the search.
5877
ADD A,L 85
Add the byte offset (A) to Register L (low byte of position).
5878
LD L,A 6F
Store the result back into Register L.
5879
BIT 3,B CB 58
Test bit 3 of Register B (memory mode flag).
587B
If bit 3 is clear (not memory mode), jump to 5896H to skip memory-specific calculations.

Memory mode - adjust position relative to file load address.

587D
LD DE,(54B2H) ED 5B B2 54
Load Register pair DE with the file load address from 54B2H-54B3H. This is where the file was loaded into memory.
5881
OR A B7
Clear the carry flag for subtraction.
5882
SBC HL,DE ED 52
Subtract the load address (DE) from the current position (HL). This gives the offset from start of file.
5884
If no carry (position ≥ load address), jump to 588FH to continue.

Position is before load address - adjust to start of file.

5886
LD A,L 7D
Load Register A with the low byte of the result (negative offset).
5887
LD HL,54C2H 21 C2 54
Load HL with the address of the byte offset variable at 54C2H.
588A
SUB (HL) 96
Subtract the current byte offset from A to get the adjustment needed.
588B
LD (HL),A 77
Store the adjusted offset back to 54C2H.
588C
LD HL,0000H 21 00 00
Clear HL to zero (start of file).
588F
LD DE,0002H 11 02 00
Load DE with 0002H, an offset adjustment value (skip the 2-byte load address header).
5892
ADD HL,DE 19
Add 2 to HL to skip past the load address header in the file.
5893
If no carry (no overflow), jump to 5896H.
5895
INC C 0C
Increment C to account for the carry (position wrapped past 64K).
5896
LD (54B6H),HL 22 B6 54
Store the calculated position into 54B6H-54B7H. This is the search start position.
5899
LD A,C 79
Load Register A with Register C (high byte of position or sector count).
589A
LD (54B8H),A 32 B8 54
Store the high byte/count into address 54B8H.
589D
POP AF F1
Restore Register A and flags from the stack.
589E
If Z flag is set (end of data), jump to 58BEH to finalize search setup.

58A0H - Multi-Byte Search Pattern Input

This section collects multiple bytes for the search pattern. It allows up to 4 bytes to be entered for the search string.

58A0
LD B,04H 06 04
Load Register B with 04H, the maximum search pattern length (4 bytes).
58A2
LD HL,54B9H 21 B9 54
Load HL with 54B9H, the address of the search pattern buffer.
58A5
Call routine at 5E2EH to get the next hex byte from user input.
58A8
If carry set (input error or cancel), jump to 5867H to abort the search.
58AB
LD (HL),E 73
Store the input byte (E) into the search pattern buffer at (HL).
58AC
INC HL 23
Increment HL to point to the next position in the pattern buffer.
58AD
If Z flag set (end of input), jump to 58B8H to finish pattern collection.
58AF
DEC B 05
Decrement the remaining byte count in B.
58B0
If B reached zero (4 bytes collected), jump to 5867H - pattern is full.
58B3
Call routine at 5E33H to get additional input for the pattern.
58B6
Loop back to 58A8H to process the next byte. [LOOP]
58B8
LD A,05H 3E 05
Load Register A with 05H (maximum pattern length + 1).
58BA
SUB B 90
Subtract the remaining count (B) from 5 to get the actual pattern length.
58BB
LD (54BDH),A 32 BD 54
Store the pattern length into address 54BDH.

58BEH - Search Initialization Complete

This section finalizes the search setup by storing the starting position and initiating the search loop. It checks for the BREAK key and handles both disk sector and memory mode searches.

58BE
PUSH HL E5
Save HL onto the stack (preserves current position).
58BF
POP HL E1
Immediately restore HL from the stack. This is effectively a NOP but may be a placeholder or alignment.
58C0
LD HL,(54C3H) 2A C3 54
Load HL with the search starting position from 54C3H-54C4H.
58C3
LD (54B4H),HL 22 B4 54
Store it into the relative sector variable at 54B4H-54B5H.
58C6
LD A,(38C0H) 3A C0 38
Load Register A with the byte at 38C0H. This is the keyboard matrix address for detecting the BREAK key.
58C9
AND 08HAND 00001000 E6 08
Mask with 08H to isolate the BREAK key bit.
58CB
If NZ (BREAK key is pressed), jump to 5937H to abort the search.

BREAK not pressed - continue with the search.

58CD
LD A,(54C0H) 3A C0 54
Load Register A with the search offset counter from 54C0H.
58D0
LD (54BFH),A 32 BF 54
Store it into address 54BFH (working copy of offset).
58D3
LD A,(54B6H) 3A B6 54
Load Register A with the low byte of the search position from 54B6H.
58D6
LD C,A 4F
Copy the position low byte into Register C.
58D7
LD HL,(54B7H) 2A B7 54
Load HL with the search position high word from 54B7H-54B8H.
58DA
Call the search execution routine at 593CH. This performs the actual byte-by-byte search.
58DD
LD A,C 79
Load Register A with Register C (updated position low byte).
58DE
LD (54B6H),A 32 B6 54
Store the updated position back to 54B6H.
58E1
LD (54B7H),HL 22 B7 54
Store the updated high word back to 54B7H-54B8H.
58E4
PUSH HL E5
Save HL (current position) onto the stack.
58E5
LD A,(54BFH) 3A BF 54
Load Register A with the working offset from 54BFH.
58E8
LD (54C0H),A 32 C0 54
Store it back to the master offset counter at 54C0H.
58EB
LD A,(5491H) 3A 91 54
Load Register A with the mode flags from 5491H.
58EE
AND 28HAND 00101000 E6 28
Mask with 28H to test bits 3 and 5 (memory mode and alternate display).
58F0
PUSH AF F5
Save the masked flags onto the stack.
58F1
If NZ (memory or alternate mode active), jump to 5902H to skip disk sector calculations.

Standard disk mode - calculate absolute sector from position.

58F3
LD D,H 54
Copy H to D (high byte of position).
58F4
LD E,L 5D
Copy L to E (mid byte of position). DE now holds the sector number.
58F5
LD A,C 79
Load Register A with C (low byte of position = byte offset in sector).
58F6
OR A B7
Test if the byte offset is zero.
58F7
If NZ (offset not zero), jump to 58FAH.
58F9
DEC DE 1B
Decrement DE (sector number) if offset was zero, pointing to previous sector.
58FA
DEC A 3D
Decrement A (adjust byte offset).
58FB
LD (54C2H),A 32 C2 54
Store the adjusted byte offset to 54C2H.
58FE
LD (54A2H),DE ED 53 A2 54
Store DE as the new current absolute sector at 54A2H-54A3H.

5902H - Update Search State and Continue

This section updates the search state variables and determines whether to continue searching or if a match was found. It handles incrementing through sectors and checking for sector boundaries.

5902
LD HL,54C2H 21 C2 54
Load HL with 54C2H, the address of the byte offset variable.
5905
LD A,(HL) 7E
Load Register A with the current byte offset from (HL).
5906
LD (54AEH),A 32 AE 54
Store the byte offset into address 54AEH for later reference.
5909
POP AF F1
Restore the masked mode flags from the stack.
590A
If Z flag (standard disk mode), jump to 5919H to continue with search pattern matching.

Memory or alternate mode - check for sector boundary crossing.

590C
INC (HL) 34
Increment the byte offset at (HL).
590D
If NZ (offset didn't wrap to zero), jump to 5919H to continue.

Byte offset wrapped - advance to next 256-byte page.

590F
LD HL,(54C3H) 2A C3 54
Load HL with the current page/sector position from 54C3H-54C4H.
5912
LD DE,0100H 11 00 01
Load DE with 0100H (256 decimal), one page/sector worth of bytes.
5915
ADD HL,DE 19
Add 256 to HL to advance to the next page.
5916
LD (54C3H),HL 22 C3 54
Store the updated page position back to 54C3H-54C4H.

5919H - Search Pattern Matching Loop

This is the core pattern matching loop. It compares bytes from the search pattern buffer against the current position in the data being searched. When all pattern bytes match, the search is successful.

5919
LD HL,54B9H 21 B9 54
Load HL with 54B9H, the address of the search pattern buffer.
591C
LD A,(54BDH) 3A BD 54
Load Register A with the search pattern length from 54BDH.
591F
LD D,A 57
Copy the pattern length into Register D as a byte counter.
5920
LD A,(HL) 7E
Load Register A with the next byte from the search pattern at (HL).
5921
CP B B8
Compare the pattern byte (A) with the data byte (B). If they match, Z flag is set.
5922
INC HL 23
Increment HL to point to the next pattern byte.
5923
If NZ (bytes don't match), jump back to 58BFH to continue searching from next position. [LOOP - NO MATCH]
5925
DEC D 15
Decrement the pattern byte counter D.
5926
If D reached zero (all pattern bytes matched), jump to 5931H - MATCH FOUND!

More pattern bytes to check - get next data byte.

5928
EX (SP),HL E3
Exchange HL with the value on the stack. This retrieves the data position while saving the pattern position.
5929
PUSH DE D5
Save DE (byte counter) onto the stack.
592A
Call the get next data byte routine at 593CH. Returns next byte in B.
592D
POP DE D1
Restore DE (byte counter) from the stack.
592E
EX (SP),HL E3
Exchange HL with stack again, restoring the pattern position and saving the updated data position.
592F
Loop back to 5920H to compare the next pattern byte. [LOOP - CONTINUE MATCHING]

5931H - Search Match Found

This section executes when a search pattern match is found. It cleans up the stack, sets the "sector modified" flag to indicate a match was found at this location, and returns to the command loop with the 'R' command to re-read and display the found sector.

5931
POP HL E1
Pop and discard the saved position from the stack (cleanup).
5932
LD HL,5493H 21 93 54
Load HL with 5493H, the address of the secondary mode flags.
5935
SET 4,(HL) CB E6
Set bit 4 of the secondary flags. This indicates a match was found and the sector should be displayed.
5937
LD A,52H 3E 52
Load Register A with 52H (ASCII R for Re-read). This will cause the found sector to be displayed.
5939
Jump to 5716H to process the R command, which re-reads and displays the current sector showing the match.

593CH - Get Next Byte for Search

This routine retrieves the next byte from the data being searched. It handles both alternate display mode (reading from a buffer) and normal mode (reading from disk sectors). The routine advances the position counters and handles sector boundaries.

593C
LD A,(5491H) 3A 91 54
Load Register A with the mode flags from 5491H.
593F
AND 20HAND 00100000 E6 20
Mask with 20H to test bit 5 (alternate display mode).
5941
If bit 5 is clear (not alternate mode), jump to 5951H for normal sector reading.

Alternate display mode - read from memory buffer.

5943
LD A,H 7C
Load Register A with the high byte of position (H).
5944
OR A B7
Test if H is zero.
5945
If H is not zero (position out of buffer range), jump to 59B4H to reset search.
5947
PUSH DE D5
Save DE onto the stack.
5948
LD D,L 55
Copy L (mid position byte) to D.
5949
LD E,C 59
Copy C (low position byte) to E. DE now holds the buffer offset.
594A
LD A,(DE) 1A
Load Register A with the byte at address DE (from the buffer).
594B
POP DE D1
Restore DE from the stack.
594C
LD B,A 47
Copy the data byte to Register B (return value).
594D
INC C 0C
Increment C (low byte of position).
594E
RET NZ C0
If C didn't wrap to zero, return with byte in B.
594F
INC HL 23
C wrapped - increment HL (advance to next page).
5950
RET C9
Return with byte in B and updated position in C,HL.

5951H - Normal Mode Sector Read for Search

This routine reads the next sector from disk during a search operation. It calls the DOS sector read routine and handles various conditions including end-of-file, sector boundaries, and file mode operations. The routine manages the search offset counter and handles multi-sector spanning searches.

5951
Call the DOS sector read routine at 5990H. This reads the next sector and returns the first byte in B, with status flags set.
5954
LD A,(54BEH) 3A BE 54
Load Register A with the search direction flag from 54BEH. Zero indicates forward search.
5957
OR A B7
Test if the search direction flag is zero.
5958
RET Z C8
If zero (forward search without special handling), return with byte in B.

Non-zero direction flag - this is a file mode search requiring additional handling.

5959
LD A,(5491H) 3A 91 54
Load Register A with the mode flags from 5491H.
595C
BIT 6,A CB 77
Test bit 6 (file open flag).
595E
If bit 6 is clear (no file open), jump to 56C1H to return to the display loop.
5961
LD A,(54BFH) 3A BF 54
Load Register A with the search offset counter from 54BFH.
5964
OR A B7
Test if the offset counter is zero.
5965
If offset is zero, jump to 596CH to handle sector boundary.
5967
DEC A 3D
Decrement the offset counter.
5968
LD (54BFH),A 32 BF 54
Store the decremented counter back to 54BFH.
596B
RET C9
Return with byte in B (continue using same sector data).

596CH - Handle File Sector Boundary

This routine handles crossing sector boundaries during file searches. It reads the next sector and determines whether to continue the search, skip sectors, or reset based on the file structure.

596C
LD D,B 50
Save the current data byte (B) into Register D for later comparison.
596D
Call the DOS sector read routine to get the next sector.
5970
LD A,D 7A
Load Register A with the saved byte from D.
5971
CP 20H FE 20
Compare with 20H (32 decimal). This checks if the value indicates a granule continuation.
5973
If A ≥ 20H (not a valid granule pointer), jump to 6576H to handle the end of file condition.
5976
DEC A 3D
Decrement A to test the granule value.
5977
If A is now zero (was 01H, indicating a Data Address Mark), jump to 5982H for special handling.
5979
DEC A 3D
Decrement A again.
597A
If A is now zero (was 02H, indicating end of granule chain), jump to 59B4H to reset search state.
597C
LD D,B 50
Save the new byte (B) into D.
597D
Call routine at 5989H to skip sectors based on granule structure.
5980
Loop back to 5951H to continue reading. [LOOP]

5982H - Handle Data Address Mark

This routine handles a Data Address Mark (DAM) encountered during file search. It calculates the proper offset for continuing the search past the header bytes.

5982
LD D,03H 16 03
Load Register D with 03H, the number of header bytes to skip (typically load address + length).
5984
LD A,B 78
Load Register A with the current data byte from B.
5985
SUB D 92
Subtract the skip count (3) from the current byte value.
5986
LD (54BFH),A 32 BF 54
Store the result as the new search offset counter at 54BFH. This adjusts the position past the header.

5989H - Skip Sectors Loop

This routine skips a specified number of sectors during file search. It repeatedly calls the DOS sector read until the counter in D reaches zero.

5989
Call the DOS sector read routine to read and advance to the next sector.
598C
DEC D 15
Decrement the sector skip counter in D.
598D
If D is not zero (more sectors to skip), loop back to 5989H. [LOOP]
598F
RET C9
Return when all sectors have been skipped.

5990H - DOS Sector Read for Search

This routine performs the actual DOS sector read operation. It calls the NEWDOS/80 file read routine at 444EH with the FCB at 5400H. The routine handles various return conditions including successful read, end of file (error 06H), and break key detection.

5990
PUSH DE D5
Save Register pair DE onto the stack.
5991
LD DE,5400H 11 00 54
Load DE with 5400H, the address of the File Control Block (FCB).
5994
Call the NEWDOS/80 sequential file read routine at 444EH. Returns Z flag if successful, error code in A if failed.
5997
If read was successful (Z flag), call the BREAK key check routine at 0013H. This allows the user to abort the search.
599A
If Z flag still set (no BREAK pressed), jump to 594BH to return the data byte in B.

Either read error occurred or BREAK was pressed. Check error type.

599C
CP 06H FE 06
Compare error code with 06H (NEWDOS/80 End of File error).
599E
If not EOF error, jump to 59ABH to check for other conditions.

End of file - return the last byte from the buffer.

59A0
LD B,00H 06 00
Clear Register B to zero (high byte of offset).
59A2
PUSH HL E5
Save HL onto the stack.
59A3
LD HL,(5403H) 2A 03 54
Load HL with the DMA buffer address from FCB offset 03H-04H.
59A6
ADD HL,BC 09
Add the current offset (BC) to get the address of the last byte read.
59A7
LD A,(HL) 7E
Load Register A with the byte at that address.
59A8
POP HL E1
Restore HL from the stack.
59A9
Jump to 594BH to restore DE, copy byte to B, and return.
59AB
CP 1CH FE 1C
Compare error code with 1CH (BREAK key pressed code).
59AD
If BREAK was pressed, jump to 59B4H to reset and abort the search.
59AF
CP 1DH FE 1D
Compare error code with 1DH (alternate BREAK/abort code).
59B1
If not BREAK, this is a real disk error. Jump to 6578H to display the error message.

59B4H - Reset Search State

This routine resets all search state variables to their initial values. It clears the position counters, offset variables, and prepares for a new search or returning to normal display mode. This is called when the search is aborted or reaches the end of searchable data.

59B4
XOR A AF
Clear Register A to zero.
59B5
LD (54B8H),A 32 B8 54
Store zero into 54B8H (high byte of search position).
59B8
LD H,A 67
Clear Register H to zero.
59B9
LD L,A 6F
Clear Register L to zero. HL is now 0000H.
59BA
LD D,A 57
Clear Register D to zero.
59BB
LD E,A 5F
Clear Register E to zero. DE is now 0000H.
59BC
LD (54BFH),A 32 BF 54
Store zero into 54BFH (search offset counter).
59BF
LD (54C2H),A 32 C2 54
Store zero into 54C2H (byte position within sector).
59C2
LD A,(5491H) 3A 91 54
Load Register A with the mode flags from 5491H.
59C5
AND 08HAND 00001000 E6 08
Mask with 08H to test bit 3 (memory mode).
59C7
If bit 3 is clear (not memory mode), jump to 59CEH.

Memory mode - use file load address as base.

59C9
LD DE,54B2H 11 B2 54
Load DE with 54B2H, the address of the file load address variable.
59CC
LD L,02H 2E 02
Set L to 02H (offset past the load address header).
59CE
LD (54C3H),DE ED 53 C3 54
Store DE into 54C3H-54C4H (search starting position).
59D2
LD (54B6H),HL 22 B6 54
Store HL into 54B6H-54B7H (current search position).
59D5
Load HL with 6EDBH, the address of the "NOT FOUND" message string.
59D8
Call the display string routine at 6245H to show "NOT FOUND".
59DB
LD A,4BH 3E 4B
Load Register A with 4BH (ASCII K command).
59DD
Jump to 571BH to process the K command, returning to the sector prompt.

59E0H - Copy Command Setup (Source Specification)

This routine handles the setup for the Copy command. It displays prompts for the source disk/sector and collects the parameters needed for the copy operation. The routine saves the source parameters for later use when specifying the destination.

59E0
Load HL with 6D28H, the address of the "COPY FROM" prompt string.
59E3
Call routine at 6224H to display the prompt and prepare for input.
59E6
Load HL with 6D0BH, the address of the "DISK" prompt string.
59E9
Call routine at 678FH to display prompt and get disk number input.
59EC
If carry set (invalid input), loop back to 59E6H to re-prompt. [LOOP]
59EE
Call routine at 66EFH to process and validate the disk number.
59F1
LD A,(5499H) 3A 99 54
Load Register A with the source disk number from 5499H.
59F4
LD (549AH),A 32 9A 54
Store the disk number into 549AH (saved source disk).
59F7
LD HL,(54A2H) 2A A2 54
Load HL with the current absolute sector from 54A2H-54A3H.
59FA
LD (54A4H),HL 22 A4 54
Store it into 54A4H-54A5H (saved source sector).
59FD
LD A,(54AEH) 3A AE 54
Load Register A with the byte offset from 54AEH.
5A00
LD (54AFH),A 32 AF 54
Store the byte offset into 54AFH (saved source offset).
5A03
LD HL,(54A8H) 2A A8 54
Load HL with the maximum sector number from 54A8H-54A9H.
5A06
LD (54AAH),HL 22 AA 54
Store it into 54AAH-54ABH (saved source max sector).

5A09H - Copy Command Setup (Destination Specification)

This section prompts for the destination disk and sector for the copy operation. It validates the input and prepares the parameters for the actual copy.

5A09
Load HL with 6D0EH, the address of the "TO DISK" prompt string.
5A0C
Call routine to display prompt and get destination disk number.
5A0F
If carry set (invalid input), loop back to re-prompt. [LOOP]
5A11
Call routine to process and validate the destination disk number.
5A14
Call routine at 66E1H to calculate transfer parameters.
5A17
LD A,(54ADH) 3A AD 54
Load Register A with the high byte of the remaining byte count from 54ADH.
5A1A
LD E,A 5F
Copy to Register E.
5A1B
LD D,00H 16 00
Clear D. DE now holds the sector count.
5A1D
LD A,(54AFH) 3A AF 54
Load Register A with the saved source byte offset from 54AFH.
5A20
LD B,A 47
Copy to Register B.
5A21
LD A,(54AEH) 3A AE 54
Load Register A with the current byte offset from 54AEH.
5A24
LD C,A 4F
Copy to Register C. BC now holds the byte offsets.
5A25
INC DE 13
Increment DE (sector count) to include the partial last sector.
5A26
PUSH BC C5
Save BC (byte offsets) onto the stack.
5A27
Call routine at 6111H to calculate the total transfer size.
5A2A
POP BC C1
Restore BC (byte offsets) from the stack.
5A2B
LD HL,(54ACH) 2A AC 54
Load HL with the remaining byte count from 54ACH-54ADH.
5A2E
PUSH HL E5
Save the byte count onto the stack.
5A2F
LD E,C 59
Copy C (destination offset) to E.
5A30
LD C,B 48
Copy B (source offset) to C.
5A31
LD B,00H 06 00
Clear B.
5A33
LD D,B 50
Clear D. Now BC = source offset, DE = dest offset.
5A34
LD HL,5493H 21 93 54
Load HL with 5493H, address of secondary mode flags.
5A37
BIT 7,(HL) CB 7E
Test bit 7 (reverse copy direction flag).
5A39
If bit 7 is clear (forward copy), jump to 5A57H.

Reverse copy mode - adjust source and destination positions.

5A3B
POP HL E1
Pop byte count into HL.
5A3C
PUSH HL E5
Push it back (we just need to read it).
5A3D
ADD HL,DE 19
Add destination offset to byte count.
5A3E
DEC HL 2B
Decrement to point to last byte.
5A3F
LD A,L 7D
Get low byte of end position.
5A40
LD E,H 5C
Get high byte into E.
5A41
LD HL,(54A2H) 2A A2 54
Load current absolute sector.
5A44
ADD HL,DE 19
Add sector offset.
5A45
LD (54A2H),HL 22 A2 54
Store as new destination sector.
5A48
LD E,A 5F
Copy offset to E.
5A49
POP HL E1
Pop byte count.
5A4A
PUSH HL E5
Push it back.
5A4B
ADD HL,BC 09
Add source offset to byte count.
5A4C
DEC HL 2B
Decrement to point to last byte.
5A4D
LD A,L 7D
Get low byte.
5A4E
LD C,H 4C
Get high byte into C.
5A4F
LD HL,(54A4H) 2A A4 54
Load saved source sector.
5A52
ADD HL,BC 09
Add sector offset.
5A53
LD (54A4H),HL 22 A4 54
Store as new source sector.
5A56
LD C,A 4F
Copy offset to C.

5A57H - Copy Operation Main Loop Setup

This section sets up the buffer addresses and begins the main copy loop. It calculates the source and destination buffer addresses and initiates the byte-by-byte copy process.

5A57
LD A,E 7B
Load Register A with E (destination byte offset).
5A58
LD HL,5300H 21 00 53
Load HL with 5300H, the destination sector buffer address.
5A5B
ADD HL,DE 19
Add destination offset (DE) to get the actual buffer address.
5A5C
EX DE,HL EB
Exchange - DE now points to destination in buffer.
5A5D
LD HL,4200H 21 00 42
Load HL with 4200H, the source sector buffer address.
5A60
ADD HL,BC 09
Add source offset (BC) to get the actual buffer address.
5A61
LD B,C 41
Copy source low offset to B.
5A62
LD C,A 4F
Copy destination low offset to C.
5A63
Call routine at 5AACH to read the source sector into buffer 4200H.
5A66
Call routine at 5AF2H to read the destination sector into buffer 5300H.
5A69
LD A,(5493H) 3A 93 54
Load Register A with secondary mode flags.
5A6C
BIT 7,A CB 7F
Test bit 7 (reverse direction flag).
5A6E
If forward direction, jump to 5A72H.
5A70
INC B 04
Adjust source offset for reverse copy.
5A71
INC C 0C
Adjust destination offset for reverse copy.

5A72H - Copy Operation Byte Transfer Loop

This is the main byte-by-byte copy loop. It transfers data from the source buffer to the destination buffer, handling sector boundaries and direction control.

5A72
LD A,(HL) 7E
Load Register A with the byte from source buffer at (HL).
5A73
LD (DE),A 12
Store the byte into the destination buffer at (DE).
5A74
EX (SP),HL E3
Exchange HL with the top of stack (byte count). HL now has remaining count.
5A75
DEC HL 2B
Decrement the remaining byte count.
5A76
LD A,H 7C
Load high byte of count into A.
5A77
OR L B5
OR with low byte to test if count reached zero.
5A78
If not zero (more bytes to copy), jump to 5A80H to continue.

Copy complete - write the final destination sector.

5A7A
Call routine at 5AD2H to write the destination sector to disk.
5A7D
Jump to 65C6H to complete the copy operation and return to the command loop.
5A80
EX (SP),HL E3
Exchange HL back with stack. HL now points to source buffer again.
5A81
LD A,(5493H) 3A 93 54
Load secondary mode flags.
5A84
BIT 7,A CB 7F
Test bit 7 (reverse direction).
5A86
If reverse direction, jump to 5A9AH.

Forward copy - increment pointers.

5A88
INC HL 23
Increment source buffer pointer.
5A89
INC DE 13
Increment destination buffer pointer.
5A8A
INC B 04
Increment source byte counter.
5A8B
If source didn't wrap past 256, jump to 5A91H.
5A8D
DEC H 25
Wrapped - adjust H to point to next page (actually previous in memory).
5A8E
Call routine to read the next source sector.
5A91
INC C 0C
Increment destination byte counter.
5A92
If destination didn't wrap, jump to 5A98H.
5A94
DEC D 15
Wrapped - adjust D for next page.
5A95
Call routine to write current destination sector and read next.
5A98
Loop back to 5A72H to copy the next byte. [LOOP]

5A9AH - Reverse Copy Pointer Adjustment

This section handles pointer adjustment for reverse direction copying. It decrements the buffer pointers instead of incrementing them.

5A9A
DEC HL 2B
Decrement source buffer pointer (reverse direction).
5A9B
DEC DE 1B
Decrement destination buffer pointer.
5A9C
DEC B 05
Decrement source byte counter.
5A9D
If source didn't underflow, jump to 5AA3H.
5A9F
INC H 24
Underflowed - adjust H to point to previous sector's page.
5AA0
Call routine to read the previous source sector.
5AA3
DEC C 0D
Decrement destination byte counter.
5AA4
If destination didn't underflow, jump to 5AAAH.
5AA6
INC D 14
Underflowed - adjust D for previous sector's page.
5AA7
Call routine to write and read previous destination sector.
5AAA
Loop back to 5A72H to copy the next byte. [LOOP]

5AACH - Read Source Sector for Copy

This routine reads the source sector for the copy operation into the buffer at 4200H. It saves and restores all working registers, handles the sector position update, and accounts for forward or reverse direction.

5AAC
PUSH HL E5
Save HL (source buffer pointer) onto the stack.
5AAD
PUSH DE D5
Save DE (destination buffer pointer) onto the stack.
5AAE
PUSH BC C5
Save BC (byte counters) onto the stack.
5AAF
LD HL,(54A4H) 2A A4 54
Load HL with the source sector number from 54A4H-54A5H.
5AB2
LD DE,(54AAH) ED 5B AA 54
Load DE with the source maximum sector from 54AAH-54ABH.
5AB6
LD BC,4200H 01 00 42
Load BC with 4200H, the source buffer address.
5AB9
LD A,(549AH) 3A 9A 54
Load Register A with the source disk number from 549AH.
5ABC
PUSH HL E5
Save the source sector number.
5ABD
Call routine at 5B16H to perform the disk read.
5AC0
POP HL E1
Restore the source sector number.
5AC1
INC HL 23
Increment to next sector (assume forward direction).
5AC2
LD A,(5493H) 3A 93 54
Load secondary mode flags.
5AC5
BIT 7,A CB 7F
Test bit 7 (reverse direction).
5AC7
If forward direction, jump to 5ACBH.
5AC9
DEC HL 2B
Reverse - undo the increment.
5ACA
DEC HL 2B
Decrement to previous sector.
5ACB
LD (54A4H),HL 22 A4 54
Store the updated source sector number back to 54A4H-54A5H.
5ACE
POP BC C1
Restore BC (byte counters).
5ACF
POP DE D1
Restore DE (destination pointer).
5AD0
POP HL E1
Restore HL (source pointer).
5AD1
RET C9
Return to caller.

5AD2H - Write Destination Sector for Copy

This routine writes the destination sector to disk during copy operations. It saves all working registers, clears the search type flag at 5494H, calls the sector write routine, updates the destination sector number based on the copy direction (forward or reverse), and restores the registers before returning. The routine at 5AD6H contains self-modifying code where the search type flag value is stored.

5AD2
PUSH HL E5
Save Register pair HL (current source buffer pointer) onto the stack for later restoration.
5AD3
PUSH DE D5
Save Register pair DE (current destination buffer pointer) onto the stack.
5AD4
PUSH BC C5
Save Register pair BC (byte offset counters: B=source offset, C=destination offset) onto the stack.
5AD5
LD A,00H 3E 00
Load Register A with 00H. This value will be stored to clear the search type flag. Note: The 00H at address 5AD6H is modified at runtime by the code at 5B11H.
5AD7
LD (5494H),A 32 94 54
Store Register A (00H or modified value) into address 5494H, the search/copy type flag. This clears any previous search state.
5ADA
Call the write sector to disk routine at 5B29H. This writes the destination sector buffer at 5300H to the current destination sector.
5ADD
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current destination absolute sector number from addresses 54A2H-54A3H.
5AE0
INC HL 23
Increment HL to point to the next sector (assuming forward copy direction).
5AE1
LD A,(5493H) 3A 93 54
Load Register A with the secondary mode flags from address 5493H. Bit 7 indicates reverse copy direction.
5AE4
BIT 7,A CB 7F
Test bit 7 of the secondary mode flags. If set, copy is proceeding in reverse direction (high to low addresses).
5AE6
If bit 7 is clear (Z flag set, forward direction), jump to 5AEAH to store the incremented sector number.

Reverse copy direction - need to decrement sector number instead of increment.

5AE8
DEC HL 2B
Decrement HL to undo the earlier INC (now back to original sector number).
5AE9
DEC HL 2B
Decrement HL again to move to the previous sector (reverse direction).
5AEA
LD (54A2H),HL 22 A2 54
Store the updated sector number back to 54A2H-54A3H as the new current destination sector.
5AED
Jump to 5ACEH to restore BC, DE, HL from the stack and return to the caller.

5AEFH - Write and Read Next Destination Sector

This routine handles destination sector boundary crossing during copy operations. It first writes the current destination sector to disk, then reads the next destination sector into the buffer. This is called when the destination byte offset wraps around (crosses a 256-byte sector boundary).

5AEF
Call the write destination sector routine at 5AD2H. This writes the current 5300H buffer contents to disk and advances the destination sector number.

5AF2H - Read Destination Sector for Copy

This routine reads the destination sector into the buffer at 5300H. It sets up the FCB parameters (sector number, buffer address, disk number), performs the read via 5B42H and 6457H, checks for sector overflow beyond the disk's maximum sector, and handles self-modifying code to track the operation type.

5AF2
PUSH HL E5
Save Register pair HL (current source buffer pointer) onto the stack.
5AF3
PUSH DE D5
Save Register pair DE (current destination buffer pointer) onto the stack.
5AF4
PUSH BC C5
Save Register pair BC (byte offset counters) onto the stack.
5AF5
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current destination sector number from addresses 54A2H-54A3H.
5AF8
LD DE,(54A8H) ED 5B A8 54
Load Register pair DE with the maximum sector number for the destination disk from addresses 54A8H-54A9H.
5AFC
LD BC,5300H 01 00 53
Load Register pair BC with 5300H, the address of the destination sector buffer.
5AFF
LD A,(5499H) 3A 99 54
Load Register A with the current disk number from address 5499H. This is the destination disk for the copy operation.
5B02
Call the setup FCB parameters routine at 5B42H. This stores HL to 540AH (sector), BC to 5403H (buffer), and A to 5406H (disk).
5B05
OR A B7
Clear the carry flag by ORing A with itself. This prepares for the SBC instruction that follows.
5B06
SBC HL,DE ED 52
Subtract DE (maximum sector) from HL (current sector) with borrow. If HL ≥ DE, the carry flag is clear (NC condition).
5B08
If no carry (current sector ≥ maximum sector), call the sector overflow handler at 6593H. This handles attempts to access beyond the disk's capacity.
5B0B
Call the read sector from disk routine at 6457H. This reads the sector specified in the FCB into the buffer at 5300H.
5B0E
LD A,(5494H) 3A 94 54
Load Register A with the operation type flag from address 5494H. This tracks what type of operation is in progress.
5B11
LD (5AD6H),A 32 D6 5A
Store Register A into address 5AD6H. This is self-modifying code - it changes the immediate value in the "LD A,00H" instruction at 5AD5H, preserving the operation type across calls.
5B14
Jump to 5ACEH to restore BC, DE, HL from the stack and return to the caller.

5B16H - Read Sector with Overflow Check

This routine reads a sector from disk after setting up the FCB parameters. It checks for sector overflow (attempting to read beyond the disk's maximum sector) but only in standard disk mode (not in memory or file mode). Used by the copy operation to read source sectors.

5B16
Call the setup FCB parameters routine at 5B42H. This stores HL (sector number) to 540AH, BC (buffer address) to 5403H, and A (disk number) to 5406H.
5B19
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from address 5491H. Bits 3 and 6 indicate memory mode and file open respectively.
5B1C
AND 48HAND 01001000 E6 48
Mask with 48H to isolate bits 3 (memory mode) and 6 (file open). If either is set, skip the overflow check.
5B1E
If NZ (either memory mode or file mode is active), jump to 5B26H to skip the sector overflow check.

Standard disk mode - check for sector overflow before reading.

5B20
OR A B7
Clear the carry flag by ORing A with itself. Prepares for the SBC instruction.
5B21
SBC HL,DE ED 52
Subtract DE (maximum sector from 54A8H) from HL (current sector from 54A2H). If HL ≥ DE, carry is clear.
5B23
If no carry (sector ≥ maximum), call the read overflow error handler at 658EH. This displays an error for attempting to read beyond disk capacity.
5B26
Jump to 6457H to read the sector from disk into the buffer and return to the caller.

5B29H - Write Sector with Overflow Check

This routine writes a sector to disk after setting up the FCB parameters. It loads the current sector number, maximum sector, buffer address, and disk number, then checks for overflow before calling the disk write routine at 6474H.

5B29
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current absolute sector number from addresses 54A2H-54A3H. This is the sector to be written.
5B2C
LD DE,(54A8H) ED 5B A8 54
Load Register pair DE with the maximum sector number from addresses 54A8H-54A9H. This is used for overflow checking.
5B30
LD BC,5300H 01 00 53
Load Register pair BC with 5300H, the address of the sector data buffer containing the data to be written.
5B33
LD A,(5499H) 3A 99 54
Load Register A with the current disk number from address 5499H.
5B36
Call the setup FCB parameters routine at 5B42H. This stores HL, BC, and A into the appropriate FCB fields.
5B39
OR A B7
Clear the carry flag by ORing A with itself. Prepares for the SBC instruction.
5B3A
SBC HL,DE ED 52
Subtract DE (maximum sector) from HL (current sector). If HL ≥ DE, carry is clear indicating overflow.
5B3C
If no carry (sector ≥ maximum), call the write overflow error handler at 6593H.
5B3F
Jump to 6474H to write the sector to disk and return to the caller.

5B42H - Setup FCB Parameters

This utility routine stores the sector number, buffer address, and disk number into the File Control Block (FCB) at 5400H. The FCB is used by NEWDOS/80 for all disk I/O operations. On entry: HL=sector number, BC=buffer address, A=disk number.

5B42
LD (540AH),HL 22 0A 54
Store Register pair HL into addresses 540AH-540BH. This is the sector number field in the FCB (offset 0AH from FCB base at 5400H).
5B45
LD (5403H),BC ED 43 03 54
Store Register pair BC into addresses 5403H-5404H. This is the DMA buffer address field in the FCB (offset 03H), pointing to where sector data will be read/written.
5B49
LD (5406H),A 32 06 54
Store Register A into address 5406H. This is the disk drive number field in the FCB (offset 06H), specifying which physical drive to access (0-3).
5B4C
RET C9
Return to the caller with FCB parameters now configured for the disk operation.

5B4DH - Move Command Setup (Source Specification)

This routine handles the setup for the Move command. It displays prompts for specifying the source disk and sector parameters. The Move command differs from Copy in that it operates on sectors within the same file or disk structure. The routine saves the source parameters for later use when specifying the destination.

5B4D
Load Register pair HL with 6D21H, the address of the "MOVE FROM" prompt string in the message table.
5B50
Call the display prompt routine at 6224H. This displays "MOVE FROM" and positions the cursor for input.
5B53
Load Register pair HL with 6D0BH, the address of the "DISK" prompt string.
5B56
Call the display prompt and get input routine at 678FH. This displays "DISK" and waits for the user to enter a disk number.
5B59
If carry flag is set (invalid input or error), jump back to 5B53H to re-prompt for the disk number. [LOOP]
5B5B
LD A,(5406H) 3A 06 54
Load Register A with the disk number from FCB offset 06H at address 5406H. This was stored by the input parsing routine.
5B5E
LD (549AH),A 32 9A 54
Store the disk number into address 549AH as the saved source disk number for the move operation.
5B61
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current absolute sector number from addresses 54A2H-54A3H.
5B64
LD (54A4H),HL 22 A4 54
Store the sector number into addresses 54A4H-54A5H as the saved source sector number.
5B67
LD HL,(54A8H) 2A A8 54
Load Register pair HL with the maximum sector number for this disk from addresses 54A8H-54A9H.
5B6A
LD (54AAH),HL 22 AA 54
Store the maximum sector into addresses 54AAH-54ABH as the saved source maximum sector.

5B6DH - Move Command Setup (Destination Specification)

This section prompts for the destination disk for the move operation. After validating the input, it calculates the transfer parameters and handles reverse direction if specified.

5B6D
Load Register pair HL with 6D0EH, the address of the "TO DISK" prompt string.
5B70
Call the display prompt and get input routine at 678FH. This displays "TO DISK" and waits for destination disk number input.
5B73
If carry flag is set (invalid input), jump back to 5B6DH to re-prompt. [LOOP]
5B75
Call routine at 66DCH to validate and process the destination disk parameters.
5B78
LD BC,0000H 01 00 00
Load Register pair BC with 0000H. This initializes the byte offset to zero (start at beginning of sectors).
5B7B
LD DE,(54ACH) ED 5B AC 54
Load Register pair DE with the remaining byte count from addresses 54ACH-54ADH. This is the total number of bytes to transfer.
5B7F
Call routine at 6111H to calculate transfer size and validate the operation parameters.
5B82
LD A,(5493H) 3A 93 54
Load Register A with the secondary mode flags from address 5493H.
5B85
BIT 7,A CB 7F
Test bit 7 of the secondary mode flags. Bit 7 indicates reverse direction for the move operation.
5B87
If bit 7 is clear (Z flag set, forward direction), jump to 5BBBH to proceed with forward move.

Reverse direction move - adjust starting positions to end of transfer range.

5B89
LD DE,(54ACH) ED 5B AC 54
Load Register pair DE with the byte count from 54ACH-54ADH again.
5B8D
DEC DE 1B
Decrement DE by 1 to get the offset to the last byte (count - 1).
5B8E
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current destination sector from 54A2H-54A3H.
5B91
ADD HL,DE 19
Add the byte offset (DE) to the sector (HL). This calculates the ending sector for reverse transfer.
5B92
LD (54A2H),HL 22 A2 54
Store the ending sector back to 54A2H-54A3H as the new starting point for reverse move.
5B95
LD HL,(54A4H) 2A A4 54
Load Register pair HL with the saved source sector from 54A4H-54A5H.
5B98
ADD HL,DE 19
Add the byte offset (DE) to the source sector (HL). This calculates the source ending sector.
5B99
LD (54A4H),HL 22 A4 54
Store the ending sector back to 54A4H-54A5H as the new source starting point.
5B9C
Jump to 5BBBH to continue with the move operation.

5B9EH - Zeroize/Fill Command Setup

This routine handles the Zeroize (or Fill) command setup. It displays the appropriate prompt and collects input for specifying the range of sectors to fill with zeros or a specified byte value.

5B9E
Load Register pair HL with 6D1AH, the address of the "ZEROIZE" prompt string in the message table.
5BA1
Call the display prompt routine at 6224H. This displays "ZEROIZE" and positions for input.
5BA4
Jump to 5BB3H to continue with sector input prompts.

5BA6H - Purge Command Setup

This routine handles the Purge command which securely erases sectors by overwriting them. It checks for a special option flag and sets the purge mode if specified.

5BA6
Load Register pair HL with 6D81H, the address of a purge option prompt string.
5BA9
Call routine at 6231H to display the prompt and check response. Returns Z flag if user selected the default option.
5BAC
If Z flag is set (default option selected), jump to 5BB3H to continue with standard input.
5BAE
LD HL,5493H 21 93 54
Load Register pair HL with 5493H, the address of the secondary mode flags.
5BB1
SET 5,(HL) CB EE
Set bit 5 of the secondary mode flags at (HL). Bit 5 indicates purge mode (multiple overwrite passes for secure erasure).

5BB3H - Sector Range Input Loop

This routine collects the sector range input for zeroize/purge operations. It loops until valid input is received, then processes the disk parameters.

5BB3
Call routine at 6792H to get sector range input from the user. This prompts for starting and ending sectors.
5BB6
If carry flag is set (invalid input or error), jump back to 5BB3H to re-prompt. [LOOP]
5BB8
Call routine at 66DCH to validate and process the disk parameters for the operation.

5BBBH - Zeroize/Purge/Move Main Loop Setup

This is the main setup and dispatch point for the zeroize, purge, and move operations. It determines which disk and sector to operate on based on the mode flags, then reads the sector into the buffer.

5BBB
LD A,(5492H) 3A 92 54
Load Register A with the tertiary mode flags from address 5492H.
5BBE
BIT 5,A CB 6F
Test bit 5 of the tertiary mode flags. Bit 5 indicates whether to use source or destination parameters.
5BC0
LD A,(5499H) 3A 99 54
Load Register A with the current disk number from address 5499H.
5BC3
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current destination sector from addresses 54A2H-54A3H.
5BC6
LD DE,(54A8H) ED 5B A8 54
Load Register pair DE with the maximum sector number from addresses 54A8H-54A9H.
5BCA
If Z flag is set (bit 5 was clear, use destination), jump to 5BD6H with current values.

Bit 5 was set - use saved source parameters instead of destination.

5BCC
LD A,(549AH) 3A 9A 54
Load Register A with the saved source disk number from address 549AH.
5BCF
LD HL,(54A4H) 2A A4 54
Load Register pair HL with the saved source sector from addresses 54A4H-54A5H.
5BD2
LD DE,(54AAH) ED 5B AA 54
Load Register pair DE with the saved source maximum sector from addresses 54AAH-54ABH.
5BD6
LD BC,5300H 01 00 53
Load Register pair BC with 5300H, the address of the sector data buffer.
5BD9
Call the read sector with overflow check routine at 5B16H. This reads the current sector into the buffer at 5300H.
5BDC
If NZ flag (read error occurred), jump to 5C30H to advance to next sector and retry.
5BDE
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from address 5491H.
5BE1
BIT 1,A CB 4F
Test bit 1 of the primary mode flags. Bit 1 indicates printer output mode.
5BE3
If bit 1 is clear (no printer output), jump to 5BECH to continue with the operation.

Printer mode - output the sector to the printer.

5BE5
LD C,10H 0E 10
Load Register C with 10H (16 decimal). This specifies 16 lines per sector for printer output (16 lines × 16 bytes = 256 bytes).
5BE7
Call the printer output routine at 613AH. This prints the sector contents in hex dump format.
5BEA
Jump to 5C30H to advance to the next sector.

5BECH - Check Operation Mode and Execute

This section determines what operation to perform based on the mode flags. It handles verify mode, purge mode, and zeroize mode differently.

5BEC
LD A,(5492H) 3A 92 54
Load Register A with the tertiary mode flags from address 5492H.
5BEF
BIT 7,A CB 7F
Test bit 7 of the tertiary mode flags. Bit 7 indicates verify mode (check for specific pattern).
5BF1
If bit 7 is clear (not verify mode), jump to 5C1AH to check for zeroize/purge mode.

Verify mode - check for BREAK key and search for pattern.

5BF3
LD A,(3840H) 3A 40 38
Load Register A from address 3840H, the keyboard matrix address for the BREAK key row.
5BF6
AND 08HAND 00001000 E6 08
Mask with 08H to isolate the BREAK key bit.
5BF8
If NZ (BREAK key pressed), jump to 65C6H to abort the operation and return to command loop.
5BFB
LD A,(5494H) 3A 94 54
Load Register A with the search/operation type flag from address 5494H.
5BFE
CP 50H FE 50
Compare Register A with 50H (ASCII P). This checks if it's a pattern search operation.
5C00
If not pattern search (NZ), jump to 5C30H to advance to next sector.
5C02
LD A,(5493H) 3A 93 54
Load Register A with the secondary mode flags from address 5493H.
5C05
BIT 5,A CB 6F
Test bit 5 of the secondary mode flags. Bit 5 indicates a match was found in this sector.
5C07
If bit 5 is clear (no match found), jump to 5C30H to try next sector.

Pattern match found - display the result message.

5C09
Call routine at 65D0H to prepare the display for showing the result.
5C0C
Load Register pair HL with 6EB8H, the address of the "FOUND" message string.
5C0F
Call the display string routine at 6245H to show "FOUND".
5C12
Load Register pair HL with 6DD5H, the address of a location details message showing where the pattern was found.
5C15
Call routine at 6345H to display the location details and wait for user acknowledgment.
5C18
Jump to 5C30H to advance to the next sector.

5C1AH - Zeroize/Purge Sector Execution

This section performs the actual zeroize or purge operation on the current sector. For purge mode, it sets bit 5 indicating multiple passes. It fills the sector buffer with zeros and writes it to disk.

5C1A
BIT 5,A CB 6F
Test bit 5 of Register A (tertiary mode flags loaded at 5BECH). Bit 5 indicates purge mode.
5C1C
If NZ (purge mode active), jump to 5C2DH to skip the zero-fill since purge uses different values.
5C1E
BIT 6,A CB 77
Test bit 6 of Register A. Bit 6 indicates file mode.
5C20
If bit 6 is clear (Z flag, not file mode), call routine at 65AFH to display progress or status.

Fill the sector buffer with zeros.

5C23
LD HL,5300H 21 00 53
Load Register pair HL with 5300H, the starting address of the sector data buffer.
5C26
LD A,00H 3E 00
Load Register A with 00H, the fill byte value (zero).
5C28
LD B,A 47
Copy zero to Register B. B will be the loop counter (256 iterations, since B=0 causes DJNZ to execute 256 times).
5C29
LD (HL),A 77
Store zero (from Register A) into the buffer at address (HL).
5C2A
INC HL 23
Increment HL to point to the next byte in the buffer.
5C2B
Decrement B and jump to 5C29H if B is not zero. This fills 256 bytes with zeros. [LOOP]
5C2D
Call the write sector with overflow check routine at 5B29H. This writes the zeroed buffer to the disk.

5C30H - Advance to Next Sector

This routine advances to the next sector in the sequence (forward or reverse based on mode flags), decrements the remaining count, and loops back until all sectors are processed.

5C30
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current destination sector from addresses 54A2H-54A3H.
5C33
LD DE,(54A4H) ED 5B A4 54
Load Register pair DE with the current source sector from addresses 54A4H-54A5H.
5C37
INC HL 23
Increment HL to advance to the next destination sector (assuming forward direction).
5C38
INC DE 13
Increment DE to advance to the next source sector (assuming forward direction).
5C39
LD A,(5493H) 3A 93 54
Load Register A with the secondary mode flags from address 5493H.
5C3C
BIT 7,A CB 7F
Test bit 7 of the secondary mode flags. Bit 7 indicates reverse direction.
5C3E
If bit 7 is clear (Z flag set, forward direction), jump to 5C44H to store the incremented values.

Reverse direction - need to decrement instead of increment.

5C40
DEC HL 2B
Decrement HL to undo the earlier INC.
5C41
DEC HL 2B
Decrement HL again to move to the previous destination sector.
5C42
DEC DE 1B
Decrement DE to undo the earlier INC.
5C43
DEC DE 1B
Decrement DE again to move to the previous source sector.
5C44
LD (54A2H),HL 22 A2 54
Store the updated destination sector number back to 54A2H-54A3H.
5C47
LD (54A4H),DE ED 53 A4 54
Store the updated source sector number back to 54A4H-54A5H.
5C4B
LD HL,(54ACH) 2A AC 54
Load Register pair HL with the remaining sector count from addresses 54ACH-54ADH.
5C4E
DEC HL 2B
Decrement the remaining count by 1.
5C4F
LD (54ACH),HL 22 AC 54
Store the decremented count back to 54ACH-54ADH.
5C52
LD A,H 7C
Load Register A with the high byte of the remaining count (H).
5C53
OR L B5
OR with the low byte (L). Result is zero only if both H and L are zero.
5C54
If NZ (more sectors to process), jump back to 5BBBH to continue the operation. [MAIN LOOP]
5C57
All sectors processed. Jump to 65C6H to complete the operation and return to the command loop.

5C5AH - "MOD" Command Handler (Sector Modification)

This routine handles the MOD (Modify) command which allows direct editing of sector data at the byte/nibble level. It uses inline parameter verification to confirm "OD" was typed after "M", then enters an interactive editing mode where the user can modify individual bytes using hex input. The cursor position tracks location within the sector buffer.

5C5A
Call the inline parameter processor at 5803H. This verifies that the characters following "M" spell "OD" to confirm the MOD command.

The following bytes are inline data spelling "OD" (the "M" was already matched). A 00H byte terminates the keyword.

5C5D
DEFB 4FH 4F
Inline data: 4FH = ASCII O
5C5E
DEFB 44H 44
Inline data: 44H = ASCII D
5C5F
DEFB 00H 00
Inline data: 00H = terminator byte marking end of keyword

Execution continues here after 5803H validates "MOD" was typed. Now get the starting position.

5C60
Call the get hex address input routine at 5E19H. Returns the entered hex value in DE, carry set on error.
5C63
If carry flag is set (input error or cancel), jump to 56C1H to return to the display loop without making changes.
5C66
EX DE,HL EB
Exchange DE and HL. Now HL contains the starting byte offset within the sector where editing will begin.
5C67
LD B,00H 06 00
Clear Register B to 00H. B serves as the edit mode flags: bit 0 = high/low nibble toggle, bit 1 = sector boundary crossed flag.

5C69H - Modify Mode Main Loop

This is the main loop for the Modify mode. It stores the current edit position, reads a hex nibble from the user, and processes the input to update the sector buffer. The loop continues until the user presses ENTER to confirm or another key to exit.

5C69
LD (5497H),HL 22 97 54
Store Register pair HL into addresses 5497H-5498H. This saves the current edit position (byte offset within sector).
5C6C
PUSH HL E5
Save HL (current edit position) onto the stack for later restoration.
5C6D
LD C,L 4D
Copy the low byte of the position (L) into Register C. This is used for cursor positioning on screen.
5C6E
Call routine at 5FB2H to position the cursor at the edit location on the screen display.
5C71
LD A,0BFH 3E BF
Load Register A with 0BFH, the cursor character (inverse video block on TRS-80) to show the edit position.
5C73
Call routine at 5DBCH to display the cursor and get a keypress. Returns the key code in Register A.
5C76
POP HL E1
Restore HL (edit position) from the stack.
5C77
LD C,A 4F
Copy the key code from Register A into Register C for later processing.
5C78
Call routine at 686DH to convert the key to a hex nibble. Returns carry set if key is a valid hex digit (0-9, A-F), nibble value in A.
5C7B
If carry is clear (key is not a valid hex digit), jump to 5CAEH to check for control keys.

Valid hex digit entered - update the sector buffer with the new nibble value.

5C7D
BIT 1,B CB 48
Test bit 1 of Register B. Bit 1 is the sector boundary crossed flag, set when edit position wraps past 255.
5C7F
RES 1,B CB 88
Clear bit 1 of Register B (reset the boundary flag after checking).
5C81
If bit 1 was set (NZ, sector boundary crossed), jump to 5DA6H to handle sector overflow.

Determine which nibble (high or low) of the byte is being edited.

5C84
LD E,0F0H 1E F0
Load Register E with F0H, a mask to preserve the high nibble and clear the low nibble.
5C86
BIT 0,B CB 40
Test bit 0 of Register B. Bit 0 is the nibble toggle flag: 0=editing high nibble, 1=editing low nibble.
5C88
If bit 0 is set (NZ, editing low nibble), jump to 5C90H to use the current mask.

Editing high nibble - need to shift the input value left by 4 bits.

5C8A
LD E,0FH 1E 0F
Load Register E with 0FH, a mask to preserve the low nibble and clear the high nibble.
5C8C
RLCA 07
Rotate A left (shift the hex nibble value left by 1 bit position).
5C8D
RLCA 07
Rotate A left again (2 bits shifted).
5C8E
RLCA 07
Rotate A left again (3 bits shifted).
5C8F
RLCA 07
Rotate A left again (4 bits shifted). The nibble value is now in the high 4 bits of A.
5C90
LD C,A 4F
Copy the positioned nibble value from Register A into Register C.
5C91
PUSH HL E5
Save HL (edit position offset) onto the stack.
5C92
PUSH DE D5
Save DE (E contains the nibble mask) onto the stack.
5C93
LD DE,(5495H) ED 5B 95 54
Load Register pair DE with the current display position from addresses 5495H-5496H. This is the base offset for the buffer.
5C97
ADD HL,DE 19
Add the display position (DE) to the edit offset (HL). HL now points to the actual byte in the sector buffer.
5C98
POP DE D1
Restore DE (E contains the nibble mask).
5C99
LD A,(HL) 7E
Load Register A with the current byte value from the sector buffer at (HL).
5C9A
AND E A3
AND with the mask (E). This preserves the nibble we're NOT editing and clears the nibble we ARE editing.
5C9B
OR C B1
OR with the new nibble value (C). This inserts the new nibble into the correct position.
5C9C
LD (HL),A 77
Store the modified byte back into the sector buffer at (HL). The byte is now updated.
5C9D
POP HL E1
Restore HL (edit position offset).
5C9E
BIT 0,B CB 40
Test bit 0 of Register B (nibble toggle). Check if we just edited the low nibble.
5CA0
If Z (we edited the high nibble), jump to 5CA7H to toggle to low nibble.

We edited the low nibble - advance to the next byte.

5CA2
INC L 2C
Increment L to move to the next byte position.
5CA3
If NZ (L didn't wrap to 0), jump to 5CA7H to toggle nibble flag.
5CA5
SET 1,B CB C8
L wrapped to 0 (position went past 255). Set bit 1 of B as the sector boundary crossed flag.
5CA7
LD A,B 78
Load Register A with the current mode flags from Register B.
5CA8
XOR 01H EE 01
XOR with 01H to toggle bit 0 (switch between high and low nibble editing).
5CAA
LD B,A 47
Store the toggled flags back into Register B.
5CAB
Jump back to 5C69H to continue the edit loop. [MAIN LOOP]

5CAEH - Process Non-Hex Key Input

This section handles keypresses that are not valid hex digits. It checks for control keys like ENTER (confirm changes), SPACE/TAB (advance position), BACKSPACE (move back), and arrow keys (navigation).

5CAE
RES 1,B CB 88
Clear bit 1 of Register B (reset the sector boundary flag since we're processing a control key).
5CB0
LD A,C 79
Load Register A with the key code from Register C (saved earlier at 5C77H).
5CB1
CP 0DH FE 0D
Compare with 0DH (ASCII carriage return = ENTER key).
5CB3
If ENTER key pressed (Z flag), jump to 5D01H to confirm and save changes.
5CB6
CP 20H FE 20
Compare with 20H (ASCII space).
5CB8
If SPACE key pressed (Z flag), jump to 5CBEH to advance position.
5CBA
CP 09H FE 09
Compare with 09H (ASCII tab = TAB key on TRS-80 is right arrow).
5CBC
If not TAB, jump to 5CC7H to check other keys.

SPACE or TAB key - advance to next position.

5CBE
BIT 0,B CB 40
Test bit 0 of Register B (nibble toggle flag).
5CC0
If Z (on high nibble), jump to 5CA7H to just toggle to low nibble without advancing.
5CC2
INC L 2C
Increment L to advance to the next byte position.
5CC3
If NZ (didn't wrap), jump to 5CA7H to toggle nibble and continue.
5CC5
L wrapped past 255 - jump to 5CE1H to handle position overflow.

5CC7H - Check Backspace and Arrow Keys

This section handles the BACKSPACE key (move cursor backward) and arrow keys for navigation within the sector buffer.

5CC7
CP 08H FE 08
Compare with 08H (ASCII backspace = LEFT ARROW/BACKSPACE).
5CC9
If not BACKSPACE, jump to 5CD6H to check other keys.

BACKSPACE/LEFT ARROW - move cursor backward.

5CCB
BIT 0,B CB 40
Test bit 0 of Register B (nibble toggle flag).
5CCD
If NZ (on low nibble), jump to 5CA7H to toggle back to high nibble of same byte.
5CCF
INC L 2C
Increment L temporarily (this is a trick to test if L is 0).
5CD0
DEC L 2D
Decrement L back. If L was 0, Z flag is now set.
5CD1
If Z (L was 0, at start of buffer), jump to 5CABH to stay at position 0.
5CD3
DEC L 2D
Decrement L to move to the previous byte position.
5CD4
Jump to 5CA7H to toggle nibble (will be on low nibble of previous byte) and continue.

5CD6H - Check Down Arrow Key

This section handles the DOWN ARROW key to move the cursor down by one line (2 bytes in hex display).

5CD6
LD E,02H 1E 02
Load Register E with 02H, the step size for vertical movement (2 bytes = 1 line in hex display).
5CD8
CP 19H FE 19
Compare with 19H (TRS-80 DOWN ARROW key code).
5CDA
If not DOWN ARROW, jump to 5CE7H to check other keys.

DOWN ARROW - move cursor down by 2 bytes.

5CDC
LD A,L 7D
Load Register A with the current position (L).
5CDD
ADD A,E 83
Add the step size (E=2) to move down one line.
5CDE
LD L,A 6F
Store the new position back into L.
5CDF
If no carry (didn't overflow past 255), jump to 5CABH to continue editing.

Position overflowed past 255 - set to end of buffer.

5CE1
LD B,01H 06 01
Load Register B with 01H, setting bit 0 (nibble toggle) so we're on the low nibble.
5CE3
LD L,0FFH 2E FF
Load Register L with FFH (255), the last byte position in the buffer.
5CE5
Jump to 5CABH to continue editing at position 255.

5CE7H - Check Up Arrow and Other Navigation Keys

This section handles UP ARROW, LINE FEED (down by 16 bytes), and begins checking for special command keys.

5CE7
CP 18H FE 18
Compare with 18H (TRS-80 UP ARROW key code).
5CE9
If UP ARROW pressed (Z flag), jump to 5CF7H to move cursor up.
5CEB
LD E,10H 1E 10
Load Register E with 10H (16 decimal), the step size for large movement (16 bytes = one display row).
5CED
CP 0AH FE 0A
Compare with 0AH (ASCII line feed = move down by larger step).
5CEF
If LINE FEED pressed (Z flag), jump to 5CDCH to add 16 to position.
5CF1
LD C,L 4D
Copy L (current position) into Register C for preservation.
5CF2
CP 5BH FE 5B
Compare with 5BH (ASCII [ left bracket).
5CF4
If not [, jump to 5D34H to check for other command keys (Q, Z, etc.).

UP ARROW or [ key - move cursor up by E bytes.

5CF7
LD A,L 7D
Load Register A with the current position (L).
5CF8
SUB E 93
Subtract the step size (E) to move up.
5CF9
LD L,A 6F
Store the new position back into L.
5CFA
If no carry (didn't underflow below 0), jump to 5CABH to continue editing.

Position underflowed below 0 - set to start of buffer.

5CFC
LD B,00H 06 00
Clear Register B (clear nibble toggle, so we're on high nibble).
5CFE
LD L,B 68
Load L with B (00H), the first byte position in the buffer.
5CFF
Jump to 5CABH to continue editing at position 0.

5D01H - Confirm and Save Sector Changes

This routine handles the ENTER key press during Modify mode. It prompts the user to confirm whether to write the changes to disk. If in alternate display mode (bit 5 set), it skips the confirmation. Otherwise, it displays "WRITE CHANGES (Y/N)?" and waits for user response. If 'Y' is pressed, the sector is written to disk.

5D01
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from address 5491H.
5D04
BIT 5,A CB 6F
Test bit 5 of the mode flags. Bit 5 indicates alternate display mode.
5D06
If bit 5 is set (NZ, alternate mode), jump to 5D23H to skip confirmation and display completion message.

Standard mode - prompt for write confirmation.

5D08
PUSH HL E5
Save Register pair HL (current edit position) onto the stack.
5D09
PUSH BC C5
Save Register pair BC (mode flags and position) onto the stack.
5D0A
Load Register pair HL with 6DA2H, the address of the "WRITE CHANGES (Y/N)?" prompt string.
5D0D
Call the display string routine at 6245H to show the confirmation prompt.
5D10
Call the get single keypress routine at 620BH. Returns the key code in Register A.
5D13
POP BC C1
Restore Register pair BC from the stack.
5D14
POP HL E1
Restore Register pair HL from the stack.
5D15
CP 59H FE 59
Compare with 59H (ASCII Y for Yes).
5D17
If not 'Y' (NZ), user declined to save. Jump back to 5C69H to continue editing without writing.

User confirmed 'Y' - write the sector to disk.

5D1A
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current absolute sector number from addresses 54A2H-54A3H.
5D1D
LD (540AH),HL 22 0A 54
Store the sector number into the FCB sector field at 540AH-540BH.
5D20
Call the write sector to disk routine at 6474H. This writes the buffer at 5300H to the specified sector.

5D23H - Display Modification Complete Message

This routine displays a completion message after modifications have been made (or skipped). It shows "MODIFICATION COMPLETE" and waits for user acknowledgment before returning to the main display loop with a Re-read command.

5D23
Load Register pair HL with 6DC4H, the address of the "MODIFICATION COMPLETE" message string.
5D26
Call the display string routine at 6245H to show the completion message.
5D29
Load Register pair HL with 6DD5H, the address of a "PRESS ANY KEY" or status message.
5D2C
Call routine at 6345H to display message and wait for keypress.
5D2F
LD A,52H 3E 52
Load Register A with 52H (ASCII R for Re-read). This will cause the sector to be re-displayed with updated contents.
5D31
Jump to 5716H to process the R command and return to the main display loop.

5D34H - Check for Quit Command

This section checks if the user pressed Q to quit the Modify mode without saving. It also handles alternate mode differently, showing an "ABORTED" message.

5D34
CP 51H FE 51
Compare with 51H (ASCII Q for Quit).
5D36
If not Q (NZ), jump to 5D45H to check for other commands.

Q pressed - quit editing without saving.

5D38
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from address 5491H.
5D3B
BIT 5,A CB 6F
Test bit 5 (alternate display mode).
5D3D
If bit 5 is set (NZ, alternate mode), jump to 5DA6H to handle quit in alternate mode.
5D40
Load Register pair HL with 6DC8H, the address of the "ABORTED" message string.
5D43
Jump to 5D26H to display the abort message and return to the display loop.

5D45H - Check for Zap Byte Command

This section checks for Z (zap/zero a byte) or A (set to alternate value) commands. These allow quickly setting a byte to 00H or another preset value.

5D45
LD C,00H 0E 00
Load Register C with 00H. This will be the fill value if Z (zero) is pressed.
5D47
CP 5AH FE 5A
Compare with 5AH (ASCII Z for Zero/Zap).
5D49
If Z pressed (Z flag), jump to 5D51H to fill the byte with 00H.
5D4B
INC C 0C
Increment C to 01H. This will be the fill value for the next check.
5D4C
CP 41H FE 41
Compare with 41H (ASCII A).
5D4E
If A pressed (Z flag), jump to 5D51H to fill the byte with 01H.
5D50
INC C 0C
Increment C to 02H for the next potential command check.

5D51H - Zap/Repeat Fill Command Processing

This routine processes the Zap (Z) or Repeat fill (R) command. It echoes the command character, gets additional parameters (end address and optionally fill value), validates the range, and fills the specified bytes. For Zap, it fills with 00H. For Repeat fill, it prompts for a fill value. The syntax is "ZT<end>" for Zap or "RT<end>,<value>" for Repeat fill.

5D51
PUSH HL E5
Save Register pair HL (current edit position) onto the stack.
5D52
PUSH BC C5
Save Register pair BC (B=mode flags, C=command type: 0=Zap, 1=Repeat) onto the stack.
5D53
Call the echo character to buffer routine at 5DFDH. This displays the command letter on screen.
5D56
Call the get character routine at 5DF7H to get the next input character.
5D59
CP 54H FE 54
Compare with 54H (ASCII T for "TO", indicating end address follows).
5D5B
If not T (NZ), jump to 5DAAH to display error message.
5D5E
Call the get hex value routine at 5E33H to get the end address of the fill range. Returns value in DE.
5D61
If carry set (input error), jump to 5DAAH to display error.
5D63
PUSH DE D5
Save Register pair DE (end address from hex input) onto the stack.
5D64
LD E,00H 1E 00
Initialize Register E with 00H. E will hold the fill value (default is 00H for Zap command).
5D66
DEC C 0D
Decrement C (command type). If C was 0 (Zap), it becomes FFH (NZ). If C was 1 (Repeat), it becomes 0 (Z).
5D67
If NZ (was Zap command), jump to 5D72H to skip fill value input and use default 00H.

Repeat fill command - need to get the fill value from user.

5D69
CP 2CH FE 2C
Compare last input character (A) with 2CH (ASCII comma ,). Comma separates end address from fill value.
5D6B
If not comma (NZ), jump to 5DA9H to handle error (missing fill value).
5D6D
Call the get hex value routine to get the fill value. Returns value in E (low byte of DE).
5D70
If carry set (input error), jump to 5DA9H to handle error.
5D72
CP 0DH FE 0D
Compare last character with 0DH (ASCII carriage return = ENTER). Input should end with ENTER.
5D74
If not ENTER (NZ), jump to 5DAAH to display error (invalid termination).
5D76
LD A,E 7B
Load Register A with the fill value from Register E.
5D77
LD (5D9CH),A 32 9C 5D
Store the fill value into address 5D9CH. This is self-modifying code that sets the fill byte used at 5D9BH.
5D7A
POP DE D1
Restore Register pair DE (end address) from the stack.
5D7B
POP BC C1
Restore Register pair BC (B=mode flags, C=command type) from the stack.
5D7C
POP HL E1
Restore Register pair HL (start position) from the stack.
5D7D
LD A,E 7B
Load Register A with E (low byte of end address).
5D7E
SUB L 95
Subtract L (start position) from A (end position). Result is the byte count - 1.
5D7F
LD C,A 4F
Copy the difference to Register C. C will be the fill byte counter.
5D80
If carry set (end < start, invalid range), jump to 5DA6H to display error.
5D83
INC C 0C
Increment C to get the actual byte count (difference + 1).
5D84
EX DE,HL EB
Exchange DE and HL. Now DE=start position, HL=end position.
5D85
LD HL,(5495H) 2A 95 54
Load Register pair HL with the sector buffer base address from 5495H-5496H.
5D88
ADD HL,DE 19
Add the start offset (DE) to the buffer base. HL now points to the first byte to fill in the sector buffer.
5D89
BIT 0,B CB 40
Test bit 0 of Register B (nibble toggle flag: 0=high nibble, 1=low nibble).
5D8B
If Z (starting on high nibble), jump to 5D9AH to fill complete bytes.

Starting on low nibble - need to preserve the high nibble of the first byte.

5D8D
LD A,(HL) 7E
Load Register A with the current byte from the buffer at (HL).
5D8E
AND 0F0HAND 11110000 E6 F0
Mask with F0H to preserve the high nibble and clear the low nibble.
5D90
LD (HL),A 77
Store the byte with cleared low nibble back to the buffer.
5D91
LD A,(5D9CH) 3A 9C 5D
Load Register A with the fill value from address 5D9CH.
5D94
AND 0FHAND 00001111 E6 0F
Mask with 0FH to isolate the low nibble of the fill value.
5D96
OR (HL) B6
OR with the current byte (preserved high nibble). This combines the fill nibble with the preserved nibble.
5D97
EX DE,HL EB
Exchange DE and HL. DE now points to the buffer, HL holds the position offset.
5D98
Jump to 5D9DH to store the combined byte and continue filling.

5D9AH - Fill Bytes Loop

This is the main fill loop that writes the fill value to consecutive bytes in the sector buffer. It continues until the byte count in C reaches zero, then returns to the modify mode.

5D9A
EX DE,HL EB
Exchange DE and HL. DE now points to the buffer position, HL holds the offset counter.
5D9B
LD A,00H 3E 00
Load Register A with 00H. Note: The 00H at address 5D9CH is self-modified by 5D77H to contain the actual fill value.
5D9D
LD (DE),A 12
Store the fill value (A) into the sector buffer at address (DE).
5D9E
INC DE 13
Increment DE to point to the next byte in the buffer.
5D9F
INC L 2C
Increment L (position offset counter) to track progress.
5DA0
DEC C 0D
Decrement C (remaining byte count).
5DA1
If C is not zero (NZ, more bytes to fill), loop back to 5D9BH. [FILL LOOP]
5DA3
All bytes filled. Jump to 5C67H to return to Modify mode with updated position.

5DA6H - Error Handler and Recovery

This routine handles errors and boundary conditions during Modify mode. It displays an error message, waits for the user to press * to acknowledge, then returns to the edit loop. This is called when the user tries to edit beyond sector boundaries or when an invalid operation is attempted.

5DA6
PUSH HL E5
Save Register pair HL (current edit position) onto the stack.
5DA7
PUSH BC C5
Save Register pair BC (mode flags and counter) onto the stack.
5DA8
PUSH AF F5
Save Register A and flags onto the stack.
5DA9
POP AF F1
Restore Register A and flags from the stack (effectively discards the saved value).
5DAA
Load Register pair HL with 6DDBH, the address of the error message string (likely "ERROR - PRESS * TO CONTINUE").
5DAD
Call routine at 6255H to display the error message on screen.
5DB0
Call the get single keypress routine at 620BH. Returns the key code in Register A.
5DB3
CP 2AH FE 2A
Compare with 2AH (ASCII * asterisk).
5DB5
If not * (NZ), loop back to 5DB0H to wait for the correct key. [LOOP]
5DB7
POP BC C1
Restore Register pair BC from the stack.
5DB8
POP HL E1
Restore Register pair HL from the stack.
5DB9
Jump back to 5C69H to resume the edit loop.

5DBCH - Display Cursor and Wait for Keypress

This routine displays a cursor character at the current screen position, waits for a keypress (with cursor blinking), and returns the key code. It calculates the screen address from the buffer position and handles cursor blinking by alternating the character display. Entry: A=cursor character, B=mode flags, C=buffer position. Exit: A=key code pressed.

5DBC
LD (5DE1H),A 32 E1 5D
Store Register A (cursor character 0BFH) into address 5DE1H. This is self-modifying code that sets the cursor character used in the display routine.
5DBF
LD H,00H 26 00
Clear Register H to zero. H will be the high byte of the screen row offset.
5DC1
LD D,H 54
Copy H (00H) to Register D.
5DC2
LD E,H 5C
Copy H (00H) to Register E. DE is now 0000H.
5DC3
LD A,C 79
Load Register A with the buffer position from Register C.
5DC4
RRA 1F
Rotate A right through carry. This divides by 2 and puts the low bit into carry.
5DC5
RL E CB 13
Rotate E left through carry. This captures the low bit of the position (nibble selector).
5DC7
AND 07HAND 00000111 E6 07
Mask with 07H to get the column within the hex display (0-7).
5DC9
LD L,A 6F
Copy the column to Register L.
5DCA
ADD A,A 87
Double A (column × 2).
5DCB
ADD A,E 83
Add E (nibble offset) to get column × 2 + nibble.
5DCC
ADD A,A 87
Double A again ((column × 2 + nibble) × 2).
5DCD
ADD A,L 85
Add original column. This calculates the screen column offset.
5DCE
LD E,A 5F
Store the column offset in Register E.
5DCF
BIT 0,B CB 40
Test bit 0 of Register B (nibble toggle: 0=high, 1=low).
5DD1
If Z (on high nibble), jump to 5DD4H.
5DD3
INC E 1C
On low nibble - increment E to point to the second hex digit.
5DD4
LD A,C 79
Load Register A with the buffer position (C).
5DD5
AND 0F0HAND 11110000 E6 F0
Mask with F0H to get the row number × 16.
5DD7
LD L,A 6F
Store row × 16 in Register L.
5DD8
ADD HL,HL 29
Double HL (row × 32).
5DD9
ADD HL,HL 29
Double HL again (row × 64 = screen row offset since each row is 64 characters).
5DDA
ADD HL,DE 19
Add the column offset (DE) to get the total screen offset.
5DDB
LD DE,3C08H 11 08 3C
Load DE with 3C08H. This is the base screen address plus an offset for the hex display area (3C00H + 08H).
5DDE
ADD HL,DE 19
Add the base address to get the final screen memory address.
5DDF
LD C,(HL) 4E
Load Register C with the original character at the screen position (to restore after cursor blink).
5DE0
LD (HL),00H 36 00
Store 00H at the screen position. Note: The 00H at 5DE1H is modified by the code at 5DBCH to be the cursor character.
5DE2
Call routine at 5DECH to wait for keypress with timeout. Returns Z if timeout, NZ with key in A.
5DE5
LD (HL),C 71
Restore the original character at the screen position.
5DE6
If Z (timeout, no key), call 5DECH again to continue waiting (cursor blink cycle).
5DE9
If still Z (still no key), jump back to 5DE0H to show cursor again. [BLINK LOOP]
5DEB
RET C9
Return with the key code in Register A.

5DECH - Wait for Keypress with Timeout

This routine waits for a keypress with a timeout counter. If no key is pressed before the timeout expires, it returns with Z flag set (for cursor blinking). If a key is pressed, it returns with NZ and the key code in A.

5DEC
LD D,00H 16 00
Load Register D with 00H. D will be the timeout counter (256 iterations).
5DEE
Call routine at 6205H to scan keyboard. Returns A=key code if pressed (NZ), A=0 if no key (Z).
5DF1
OR A B7
Test if A is zero (no key pressed).
5DF2
RET NZ C0
If NZ (key was pressed), return immediately with key code in A.
5DF3
DEC D 15
Decrement the timeout counter D.
5DF4
If D is not zero (NZ), loop back to 5DEEH to check keyboard again. [TIMEOUT LOOP]
5DF6
RET C9
Timeout expired. Return with Z flag set (A=0).

5DF7H - Get Character from Input

This routine gets a character from user input. It waits for a keypress, checks if it's a printable character (ASCII 20H or higher), and optionally echoes it to a buffer. If the key is below 20H (control character), it returns with carry set.

5DF7
Call the get single keypress routine at 620BH. Returns the key code in Register A.
5DFA
CP 20H FE 20
Compare with 20H (ASCII space). Characters below 20H are control characters.
5DFC
RET C D8
If carry set (character < 20H, control character), return immediately with carry flag set.

5DFDH - Echo Character to Command Buffer

This routine stores a character into the command line echo buffer area. It calculates the buffer position, checks for overflow, and stores the character. The buffer is located in video memory at 4000H.

5DFD
PUSH HL E5
Save Register pair HL onto the stack.
5DFE
PUSH DE D5
Save Register pair DE onto the stack.
5DFF
LD HL,(54B0H) 2A B0 54
Load Register pair HL with the current buffer pointer from addresses 54B0H-54B1H.
5E02
LD DE,4000H 11 00 40
Load DE with 4000H, the start of video memory (used as boundary check).
5E05
OR A B7
Clear carry flag for subtraction.
5E06
SBC HL,DE ED 52
Subtract 4000H from the buffer pointer. If result is negative, buffer is valid.
5E08
If carry (buffer pointer < 4000H, invalid), jump to 5E0DH.
5E0A
XOR A AF
Clear A (buffer overflow - don't store character).
5E0B
Jump to 5E16H to skip storing and return.
5E0D
ADD HL,DE 19
Add 4000H back to restore the original pointer value.
5E0E
LD (HL),A 77
Store the character (A) into the buffer at (HL).
5E0F
LD DE,0040H 11 40 00
Load DE with 0040H (64 decimal), the screen width.
5E12
ADD HL,DE 19
Add 64 to advance to the next row position (for vertical display of typed characters).
5E13
LD (54B0H),HL 22 B0 54
Store the updated buffer pointer back to 54B0H-54B1H.
5E16
POP DE D1
Restore Register pair DE from the stack.
5E17
POP HL E1
Restore Register pair HL from the stack.
5E18
RET C9
Return to the caller.

5E19H - Get Hex Address Input

This routine gets a hexadecimal address value from user input. It first gets a character, then parses up to 4 hex digits into a 16-bit value in Register pair DE. If the input is invalid or the user presses a control key, carry is set on return. Used by the MOD command to get the starting edit position.

5E19
Call the get character from input routine at 5DF7H. Returns the first character in A, carry set if control character.

5E1CH - Parse Hex Digits into DE

This routine parses hexadecimal digits from user input into a 16-bit value. It accumulates digits into Register pair DE, shifting previous digits left by 4 bits for each new digit entered. Entry: Called after first character is in A. Exit: DE=parsed value, carry set on error.

5E1C
PUSH HL E5
Save Register pair HL onto the stack.
5E1D
PUSH BC C5
Save Register pair BC onto the stack.
5E1E
LD DE,0000H 11 00 00
Initialize Register pair DE to 0000H. DE will accumulate the parsed hex value.
5E21
Call routine at 685AH to convert character to hex nibble and accumulate. This shifts DE left 4 bits and adds the new nibble.
5E24
If carry set (invalid hex digit), jump to 5E46H to return with error.
5E26
Call the get next character routine to get another input character.
5E29
Call routine at 685AH to convert and accumulate the second hex digit.
5E2C
Jump to 5E46H to restore registers and return.

5E2EH - Get Hex Byte with Validation

This routine gets a hex byte value from input with additional validation. It calls the parse routine and then checks for proper termination. Used for getting search patterns and other byte values.

5E2E
Call the parse hex digits routine at 5E1CH to get a hex value into DE.
5E31
Jump to 5E36H to check result and return.

5E33H - Get Hex Value with Full Parsing

This routine gets a complete hex value from input, handling up to 4 digits. It's the main entry point for hex input when a full address or value is expected.

5E33
Call the get hex address input routine at 5E19H. This gets the first character and begins parsing.
5E36
RET C D8
If carry is set (error in input), return immediately to caller with error indication.

5E37H - Check Input Termination

This routine checks if the input was properly terminated with ENTER (0DH) or a comma (2CH). It's called after parsing to validate that the user completed the input correctly. Returns: Z flag if terminated with ENTER, carry clear if comma (more input follows), carry set if invalid terminator.

5E37
PUSH HL E5
Save Register pair HL onto the stack.
5E38
PUSH BC C5
Save Register pair BC onto the stack.
5E39
Call the get character routine to get the terminating character.
5E3C
CP 0DH FE 0D
Compare with 0DH (ASCII carriage return = ENTER).
5E3E
If ENTER (Z flag), jump to 5E46H to return success with Z flag set.
5E40
CP 2CH FE 2C
Compare with 2CH (ASCII comma ,).
5E42
SCF 37
Set the carry flag (assume invalid terminator).
5E43
If not comma (NZ), jump to 5E46H with carry set (error).
5E45
OR A B7
Clear carry flag (comma is valid, more input expected). Also clears Z flag.
5E46
POP BC C1
Restore Register pair BC from the stack.
5E47
POP HL E1
Restore Register pair HL from the stack.
5E48
RET C9
Return to caller. Z flag set if ENTER, carry clear if comma, carry set if invalid.

5E49H - Password Entry and Checksum Calculation

This routine handles password entry for protected operations. It displays a password prompt, collects up to 8 characters of input, clears the entry area on screen with spaces, and then calculates a 16-bit checksum of the entered password combined with stored data. The checksum algorithm uses a complex series of rotations and XOR operations to create a hash value. This is used for disk copy protection verification.

5E49
Load Register pair HL with 6EE6H, the address of the password prompt string in the message table.
5E4C
Call routine at 634EH to display the password prompt and collect input. Returns B=number of characters entered.
5E4F
LD C,B 48
Copy B (character count) into Register C.
5E50
LD B,00H 06 00
Clear Register B to 00H. BC now holds the character count as a 16-bit value.
5E52
ADD HL,BC 09
Add BC to HL to point past the entered characters to the start of the fill area.
5E53
LD B,08H 06 08
Load Register B with 08H (8 decimal). This is the number of positions to clear with spaces.
5E55
LD (HL),20H 36 20
Store 20H (ASCII space) at address (HL) to clear the password display area.
5E57
INC HL 23
Increment HL to point to the next position.
5E58
Decrement B and jump back to 5E55H if not zero. [CLEAR LOOP] Clears 8 characters.

Password display cleared. Now calculate the checksum hash.

5E5A
LD HL,5447H 21 47 54
Load Register pair HL with 5447H, pointing to the password buffer in the data area.
5E5D
PUSH DE D5
Save Register pair DE onto the stack.
5E5E
PUSH BC C5
Save Register pair BC onto the stack.
5E5F
LD DE,0FFFFH 11 FF FF
Initialize Register pair DE with FFFFH. DE will accumulate the checksum hash value.
5E62
LD B,08H 06 08
Load Register B with 08H (8 decimal). Process 8 characters for the checksum.

5E64H - Checksum Calculation Loop

This is the main checksum calculation loop. It processes each byte of the password buffer through a complex series of rotations and XOR operations to generate a pseudo-random hash. The algorithm is designed to make it difficult to reverse-engineer the expected password from the stored checksum.

5E64
PUSH BC C5
Save the loop counter (B) onto the stack.
5E65
LD A,E 7B
Load Register A with the low byte of the hash (E).
5E66
AND 07HAND 00000111 E6 07
Mask with 07H to isolate the lowest 3 bits of the hash.
5E68
LD C,A 4F
Copy the masked value to Register C for later use.
5E69
LD A,E 7B
Load Register A with E again (low byte of hash).
5E6A
RLCA 07
Rotate A left through carry (1 bit).
5E6B
RLCA 07
Rotate A left again (2 bits total).
5E6C
RLCA 07
Rotate A left again (3 bits total).
5E6D
XOR C A9
XOR A with C (the low 3 bits). This mixes the rotated and unrotated values.
5E6E
RLCA 07
Rotate A left again (4 bits from original position).
5E6F
LD C,A 4F
Save the intermediate result in C.
5E70
AND 0F0HAND 11110000 E6 F0
Mask with F0H to isolate the high nibble.
5E72
LD B,A 47
Save the high nibble in B.
5E73
LD A,C 79
Reload A with the intermediate value from C.
5E74
RLCA 07
Rotate A left (5 bits from original).
5E75
AND 1FHAND 00011111 E6 1F
Mask with 1FH to isolate the low 5 bits.
5E77
XOR B A8
XOR with B (the saved high nibble). More bit mixing.
5E78
XOR D AA
XOR with D (the high byte of the running hash).
5E79
LD E,A 5F
Store the result as the new low byte of the hash (E).
5E7A
LD A,C 79
Reload A with the intermediate value from C.
5E7B
AND 0FHAND 00001111 E6 0F
Mask with 0FH to isolate the low nibble.
5E7D
LD B,A 47
Save the low nibble in B.
5E7E
LD A,C 79
Reload A with the intermediate value.
5E7F
RLCA 07
Rotate A left (1 bit).
5E80
RLCA 07
Rotate A left (2 bits).
5E81
RLCA 07
Rotate A left (3 bits).
5E82
RLCA 07
Rotate A left (4 bits = nibble swap).
5E83
XOR B A8
XOR with B (the saved low nibble). This mixes the swapped nibbles.
5E84
POP BC C1
Restore the loop counter from the stack.
5E85
XOR (HL) AE
XOR with the current password character from the buffer at (HL).
5E86
LD D,A 57
Store the result as the new high byte of the hash (D).
5E87
LD (HL),20H 36 20
Store 20H (space) to clear the password character from the buffer for security.
5E89
DEC HL 2B
Decrement HL to point to the previous character (processing right to left).
5E8A
Decrement B and jump back to 5E64H if not zero. [CHECKSUM LOOP]

5E8CH - Display Checksum Result

After calculating the checksum, this section converts the 16-bit hash value in DE to hexadecimal ASCII and displays it. The checksum is shown as a 4-digit hex number.

5E8C
INC HL 23
Increment HL to point back to the start of the output area.
5E8D
LD B,04H 06 04
Load Register B with 04H. This is the number of hex digits to display (4 digits for 16-bit value).
5E8F
LD A,E 7B
Load Register A with E (low byte of checksum hash).
5E90
Call routine at 6674H to convert byte to 2 hex ASCII characters and store at (HL). HL is advanced.
5E93
LD A,D 7A
Load Register A with D (high byte of checksum hash).
5E94
Call routine at 6674H to convert the high byte to hex ASCII.
5E97
LD HL,5440H 21 40 54
Load Register pair HL with 5440H, the address of the password/checksum display buffer.
5E9A
Call routine at 62BAH to display the buffer contents on screen.
5E9D
Jump to 65C3H to return to the command loop.

5EA0H - Filespec Entry and Validation

This routine handles filename input with validation. It displays a prompt for the filespec, collects up to 8 characters for the filename, pads with spaces if needed, then collects up to 3 characters for the extension. It calculates a checksum of the entered filespec for validation purposes.

5EA0
LD B,08H 06 08
Load Register B with 08H (8 decimal). This is the maximum filename length (8 characters).
5EA2
Load Register pair HL with 6D60H, the address of the filename prompt string.
5EA5
Call routine at 6339H to display prompt and get filename input. Returns B=characters remaining (8 - entered).
5EA8
LD C,B 48
Copy B (remaining characters) to Register C.
5EA9
LD B,00H 06 00
Clear Register B. BC now holds the offset to the end of entered filename.
5EAB
ADD HL,BC 09
Add BC to HL to point past the entered filename characters.
5EAC
LD A,09H 3E 09
Load Register A with 09H (9 decimal = 8 + 1 for the slash separator).
5EAE
SUB C 91
Subtract C (remaining) from 9. Result is number of padding spaces needed.
5EAF
LD B,A 47
Copy the padding count to Register B for the fill loop.
5EB0
LD (HL),20H 36 20
Store 20H (ASCII space) at (HL) to pad the filename.
5EB2
INC HL 23
Increment HL to point to the next position.
5EB3
Decrement B and loop back to 5EB0H if not zero. [PAD FILENAME LOOP]
5EB5
EX DE,HL EB
Exchange DE and HL. DE now points past the padded filename.
5EB6
Load Register pair HL with 6D64H, the address of the extension prompt string (or separator).
5EB9
LD B,03H 06 03
Load Register B with 03H (3 decimal). This is the maximum extension length.
5EBB
DEC DE 1B
Decrement DE to point to the position for the extension.
5EBC
Call routine at 633CH to get extension input. Returns B=characters remaining.
5EBF
LD C,B 48
Copy B (remaining) to Register C.
5EC0
LD B,00H 06 00
Clear Register B. BC now holds remaining extension characters.
5EC2
ADD HL,BC 09
Add BC to HL to point past the entered extension.
5EC3
LD A,04H 3E 04
Load Register A with 04H (4 = 3 + 1 for terminator).
5EC5
SUB C 91
Subtract C from 4. Result is number of padding spaces needed for extension.
5EC6
LD B,A 47
Copy the padding count to B.
5EC7
LD (HL),20H 36 20
Store 20H (space) at (HL) to pad the extension.
5EC9
INC HL 23
Increment HL to next position.
5ECA
Decrement B and loop if not zero. [PAD EXTENSION LOOP]

5ECCH - Filespec Checksum Calculation

This section calculates a checksum of the entered filespec for validation. It XORs all 11 characters (8 filename + 3 extension) together with rotation to create a hash value.

5ECC
LD HL,5440H 21 40 54
Load Register pair HL with 5440H, the address of the filespec buffer.
5ECF
LD B,0BH 06 0B
Load Register B with 0BH (11 decimal). Process 11 characters (8 filename + 3 extension).
5ED1
XOR A AF
Clear Register A to 00H. A will accumulate the checksum.
5ED2
XOR (HL) AE
XOR Register A with the character at (HL). This adds the character to the checksum.
5ED3
INC HL 23
Increment HL to point to the next character.
5ED4
RLCA 07
Rotate A left. This spreads the bits for better hash distribution.
5ED5
Decrement B and loop if not zero. [CHECKSUM LOOP]
5ED7
If NZ (checksum is not zero), jump to 5EDAH.
5ED9
INC A 3C
If checksum was zero, increment A to 01H (avoid zero checksum).
5EDA
POP HL E1
Restore Register pair HL from the stack.
5EDB
LD B,02H 06 02
Load Register B with 02H. This specifies 2 hex digits to display.
5EDD
Jump to 5E94H to convert and display the checksum as 2 hex digits.

5EDFH - Raw Track Read Command Setup

This routine sets up and initiates a raw track read operation for disk analysis. It prompts for track/sector parameters, sets the file mode flag in the secondary mode flags at 5493H, configures the FCB (File Control Block) at 5400H with the maximum sector count and starting sector, then calls NEWDOS/80's directory search routine. This allows SUPERZAP to read raw track data directly from the floppy disk controller for analyzing disk format and copy protection.

5EDF
Call routine at 6792H to prompt for and get sector parameters from the user. This routine displays prompts and parses the user's input for track/sector selection.
5EE2
If carry flag is set (invalid input or user error), jump back to 5EDFH to re-prompt for valid parameters. [INPUT VALIDATION LOOP]
5EE4
LD HL,5493H 21 93 54
Load Register pair HL with 5493H, the address of the secondary mode flags byte. This byte tracks various operation modes.
5EE7
SET 6,(HL) CB F6
Set bit 6 of the byte at (HL). Bit 6 of 5493H indicates raw track/file mode is active, which changes how sector I/O is performed.
5EE9
LD HL,(54A8H) 2A A8 54
Load Register pair HL with the 16-bit value at addresses 54A8H-54A9H. This is the maximum sector number for the current disk, representing the disk capacity limit.
5EEC
LD (540CH),HL 22 0C 54
Store HL into addresses 540CH-540DH. This is FCB offset 0CH (the record count/extent field), setting the maximum sectors to read.
5EEF
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the 16-bit value at addresses 54A2H-54A3H. This is the current absolute sector number that was entered or calculated.
5EF2
LD (540AH),HL 22 0A 54
Store HL into addresses 540AH-540BH. This is FCB offset 0AH (the sector number field), setting the starting sector for the read operation.
5EF5
LD DE,5400H 11 00 54
Load Register pair DE with 5400H, the base address of the File Control Block (FCB). NEWDOS/80 disk routines use this FCB for all file and sector operations.
5EF8
Call NEWDOS/80 routine at 4436H. This is the @FSPEC (File Specification) or directory search routine. It searches the directory for the file matching the FCB. Returns Z flag if found, error code in A if not found.
5EFB
If Z flag is set (file/sector found successfully), jump to 5F05H to continue with the raw track read operation.

File not found or error occurred - check if it's a recoverable error.

5EFD
CP 03H FE 03
Compare the error code in Register A with 03H. Error codes 00H-02H are fatal disk errors (drive not ready, write protect, etc.).
5EFF
If carry set (error code < 03H, fatal error), jump to 5F63H to display the error and abort the operation.
5F01
CP 08H FE 08
Compare the error code with 08H. Error codes 03H-07H are recoverable file errors (file not found, directory full, etc.).
5F03
If no carry (error code >= 08H, fatal hardware error), jump to 5F63H to display the error and abort.

5F05H - Raw Track Read Initialization

This routine initializes the WD1771 floppy disk controller for a raw track read operation. It saves the current disk select byte from the DOS workspace at 4309H, disables interrupts for precise timing, calls the drive select routine, then restores the select byte. Raw track reads require uninterrupted execution to capture every byte as it streams off the disk.

5F05
LD A,(4309H) 3A 09 43
Load Register A with the byte at 4309H. This is the NEWDOS/80 disk select byte which contains the currently selected drive number and density settings.
5F08
PUSH AF F5
Push AF (disk select byte and flags) onto the stack. This saves the current disk controller state for restoration after the raw read completes.
5F09
DI F3
Disable all maskable interrupts. This is critical - the raw track read loop must execute without any interruption to capture data at disk speed (250 kbps for single density).
5F0A
Call routine at 67B5H to select the disk drive and seek to the target track. This prepares the FDC hardware for the read operation.
5F0D
POP AF F1
Pop the saved disk select byte back into Register A.
5F0E
LD (4309H),A 32 09 43
Restore the original disk select byte to 4309H. This ensures DOS workspace remains consistent even though we're doing direct hardware access.
5F11
Call routine at 5FA2H to output the disk select byte to the hardware at port 37E1H, physically selecting the drive.
5F14
Call routine at 5FA9H to perform a short timing delay and read the FDC status register. This ensures the controller is ready.
5F17
LD HL,37ECH 21 EC 37
Load Register pair HL with 37ECH. This is the WD1771 FDC command/status register address (memory-mapped I/O on TRS-80).
5F1A
LD (HL),0E4H 36 E4
Write E4H to the FDC command register at (HL). E4H is the Read Track command (E0H base + 04H for head load delay). This starts the raw track read operation.
5F1C
LD DE,37EFH 11 EF 37
Load Register pair DE with 37EFH. This is the WD1771 FDC data register address where raw bytes will be read from.
5F1F
LD BC,7000H 01 00 70
Load Register pair BC with 7000H. This is the destination buffer address where captured raw track data will be stored. The buffer extends from 7000H upward.
5F22
Call the timing delay routine again to wait for the Read Track command to initialize and data to start arriving.
5F25
NOP 00
No operation. This provides a small additional timing delay for FDC synchronization before entering the tight capture loop.

5F26H - Wait for FDC Busy

This short loop waits for the FDC to transition from "just busy" (status=01H) to "busy with data ready" (status has DRQ bit set). This synchronizes the capture loop with the actual data stream from the disk.

5F26
LD A,01H 3E 01
Load Register A with 01H. This is the BUSY bit mask - when status equals exactly 01H, the FDC is busy but no data is available yet.
5F28
CP (HL) BE
Compare A (01H) with the FDC status register at (HL=37ECH). Z flag set if status is exactly 01H (busy, no data).
5F29
If Z (status still 01H, waiting for data), loop back to 5F28H. [BUSY WAIT LOOP] Exits when DRQ or other status bits become set.

5F2BH - Raw Track Data Capture Loop

This is the critical high-speed data capture loop. It reads raw bytes from the FDC data register at 37EFH as fast as possible and stores them into the buffer at 7000H. The loop must complete each iteration within the byte time of the disk (32 microseconds for single density) or data will be lost. Multiple DRQ checks handle timing variations.

5F2B
LD A,(DE) 1A
Load Register A with the byte from (DE=37EFH), the FDC data register. This reads one raw byte from the disk data stream.
5F2C
LD (BC),A 02
Store the captured byte into the buffer at address (BC). BC starts at 7000H and increments with each byte.
5F2D
INC BC 03
Increment BC to point to the next buffer location for the next captured byte.
5F2E
BIT 1,(HL) CB 4E
Test bit 1 of the FDC status at (HL=37ECH). Bit 1 is DRQ (Data Request) - set when another byte is ready to read.
5F30
If NZ (DRQ is set, more data ready), jump back to 5F2BH to capture the next byte immediately. [DATA CAPTURE LOOP]
5F32
BIT 1,(HL) CB 4E
Test DRQ again - handles case where data arrives between the previous test and the branch.
5F34
If DRQ now set, jump to capture the byte.
5F36
BIT 1,(HL) CB 4E
Test DRQ a third time - provides additional timing margin for slow data arrival.
5F38
If DRQ set, jump to capture.
5F3A
BIT 0,(HL) CB 46
Test bit 0 of FDC status. Bit 0 is BUSY - cleared when the Read Track operation completes.
5F3C
If Z (BUSY clear, operation complete), jump to 5F46H to finish and process results.
5F3E
BIT 1,(HL) CB 4E
Still busy - check DRQ one more time in case data arrived during the BUSY check.
5F40
If DRQ set, jump to capture the data.
5F42
BIT 7,(HL) CB 7E
Test bit 7 of FDC status. Bit 7 is NOT READY - set if the drive becomes not ready (door open, disk removed).
5F44
If Z (drive still ready), jump back to 5F2EH to continue checking for data. Otherwise fall through to completion.

5F46H - Track Read Completion and Error Check

This section handles completion of the raw track read. It checks for CRC errors in the captured data, marks error locations in the buffer, sends a Force Interrupt command to reset the FDC, re-enables interrupts, and saves the final buffer position for later analysis.

5F46
LD A,(4311H) 3A 11 43
Load Register A from address 4311H. This is a secondary disk controller status location that may contain additional error information.
5F49
RLCA 07
Rotate A left. This moves bit 7 (error flag) into the carry flag for testing.
5F4A
If no carry (bit 7 was clear, no error), jump to 5F50H to continue without error marking.

Error detected during read - mark the error location in the buffer.

5F4C
DEC DE 1B
Decrement DE (was pointing to FDC data register 37EFH). This is repurposed to point to the last buffer location.
5F4D
LD A,80H 3E 80
Load Register A with 80H. This is an error marker byte that will be visible when analyzing the captured data.
5F4F
LD (DE),A 12
Store the error marker at (DE) to flag where the error occurred in the data stream.
5F50
LD A,(HL) 7E
Load Register A with the final FDC status from (HL=37ECH). This captures any error bits before resetting the controller.
5F51
LD (HL),0D0H 36 D0
Write D0H to the FDC command register at (HL). D0H is the Force Interrupt command which immediately terminates any operation and resets the controller to idle state.
5F53
EI FB
Enable interrupts. The critical timing section is complete, normal system operation can resume.

5F54H - Save Buffer Position and Check Errors

This section saves the final buffer position, extracts error bits from the FDC status, and determines whether to display results or an error message. The buffer position indicates how many bytes were captured from the raw track read.

5F54
LD (5F7CH),BC ED 43 7C 5F
Store Register pair BC into addresses 5F7CH-5F7DH. BC contains the final buffer pointer (end of captured data). This address minus 7000H gives the byte count.
5F58
AND 0F8HAND 11111000 E6 F8
AND Register A (FDC status from 5F50H) with F8H. This isolates error bits 3-7 (CRC error, seek error, lost data, write fault, not ready).
5F5A
LD C,A 4F
Copy the masked error bits to Register C for further analysis.
5F5B
If Z (no error bits set), jump to 5F69H to display successful results.

Error bits present - determine which specific error occurred.

5F5D
XOR A AF
Clear Register A to 00H. A will be used as an error code counter.
5F5E
INC A 3C
Increment A to count which error bit is set (A=1 for bit 3, A=2 for bit 4, etc.).
5F5F
RRC C CB 09
Rotate Register C right through carry. This shifts the error bits, putting the lowest set bit into carry.
5F61
If no carry (this bit was 0), loop back to 5F5EH to check the next bit. [ERROR BIT SCAN LOOP] Exits when carry is set (found the error bit).

5F63H - Display Disk Error

This routine displays a disk error message based on the error code in Register A, then returns to the error handler to allow the user to retry or abort.

5F63
Call routine at 64BCH to display the disk error message. The error code in A selects which message to display from the error message table.
5F66
Jump to 6582H, the error handler. This routine displays "PRESS ANY KEY" and returns to the main command loop.

5F69H - Display Track Read Results

This routine displays the results of a successful raw track read operation. It shows the buffer start address (7000H), the buffer end address (from 5F7CH), allowing the user to see how much data was captured.

5F69
Load Register pair HL with 6EFBH, the address of a results label string (such as "START=" or "FROM ").
5F6C
Call routine at 6255H to display the label string at (HL) on the screen.
5F6F
LD DE,7000H 11 00 70
Load Register pair DE with 7000H, the buffer start address where raw track data was stored.
5F72
Call routine at 665BH to convert DE to hex ASCII and display the start address.
5F75
Load Register pair HL with 6EA7H, the address of another label string (such as "END=" or "TO ").
5F78
Call routine at 6255H to display the end address label.
5F7B
LD DE,0000H 11 00 00
Load Register pair DE with 0000H. Note: The 0000H at address 5F7CH is self-modified by the code at 5F54H to contain the actual end address.
5F7E
DEC DE 1B
Decrement DE. This adjusts from "next byte to write" to "last byte written" for display purposes.
5F7F
Call routine at 665BH to convert and display the end address.
5F82
Jump to 65C3H to return to the main command loop.

5F85H - FDC Status Check with Retry

This routine checks the FDC status and handles busy/not ready conditions with automatic retry. It's used during drive initialization to wait for the drive to become ready.

5F85
Call the timing delay and status read routine at 5FA9H. Returns with FDC status in Register A.
5F88
RRCA 0F
Rotate A right through carry. This puts bit 0 (BUSY) into the carry flag.
5F89
If carry set (FDC is busy), jump to 5F8DH to handle the busy condition.
5F8B
XOR A AF
Clear Register A to 00H, indicating ready status (not busy).
5F8C
RET C9
Return with A=00H indicating FDC is ready.

5F8DH - Handle FDC Busy Condition

This section handles the case where the FDC is busy. It checks if the controller is simply completing an operation or if it needs to be reset with a Force Interrupt command.

5F8D
RLCA 07
Rotate A left to restore the original bit position.
5F8E
RLCA 07
Rotate A left again. Now bit 7 (NOT READY) is in carry.
5F8F
If carry set (drive not ready), jump to 5F96H to send Force Interrupt command.
5F91
Call routine at 5FA2H to re-select the drive by outputting the select byte to the hardware.
5F94
Jump back to 5F85H to retry the status check. [RETRY LOOP]
5F96
LD A,0D0H 3E D0
Load Register A with D0H, the Force Interrupt command for the WD1771 FDC.
5F98
LD (37ECH),A 32 EC 37
Write the Force Interrupt command to the FDC command register at 37ECH. This aborts any pending operation and resets the controller.
5F9B
Jump back to 5F85H to check status again after the reset.

5F9DH - Check FDC Not Ready

This short routine checks if the FDC is reporting "not ready" status, which indicates the drive door is open or no disk is inserted.

5F9D
LD A,(37ECH) 3A EC 37
Load Register A with the current FDC status from the command/status register at 37ECH.
5FA0
RLCA 07
Rotate A left. This puts bit 7 (NOT READY) into the carry flag.
5FA1
RET C D8
If carry set (drive not ready), return immediately with carry flag indicating the error condition.

5FA2H - Output Drive Select Byte

This routine outputs the current drive select byte to the disk controller hardware. It reads the select byte from the DOS workspace at 4309H and writes it to the drive select latch at 37E1H.

5FA2
LD A,(4309H) 3A 09 43
Load Register A with the drive select byte from NEWDOS/80 workspace at 4309H. This byte contains drive number (bits 0-1), side select, and motor on bits.
5FA5
LD (37E1H),A 32 E1 37
Write the select byte to address 37E1H, the drive select latch (memory-mapped I/O). This physically selects the drive and turns on the motor.
5FA8
RET C9
Return to the caller.

5FA9H - Timing Delay and Read FDC Status

This routine provides a short timing delay (approximately 30 microseconds) then reads the FDC status register. The delay allows the FDC time to update its status after a command or operation.

5FA9
LD A,06H 3E 06
Load Register A with 06H. This is the delay loop counter - 6 iterations provides approximately 30 microseconds of delay.
5FAB
DEC A 3D
Decrement the delay counter in Register A.
5FAC
If A is not zero (NZ), loop back to 5FABH. [TIMING DELAY LOOP] Each iteration takes approximately 5 microseconds.
5FAE
LD A,(37ECH) 3A EC 37
Load Register A with the FDC status register contents from address 37ECH.
5FB1
RET C9
Return with the FDC status in Register A.

5FB2H - Initialize Sector Display Screen

This routine initializes the screen for displaying sector contents. It sets up the cursor position pointer at 54B0H, clears the command line area, and prepares the video memory starting at 3C00H for the hex/ASCII dump display. The display shows 16 rows of 16 bytes each (256 bytes total per sector).

5FB2
LD HL,3C06H 21 06 3C
Load Register pair HL with 3C06H. This is the screen position for command input (row 0, column 6 in video memory which starts at 3C00H).
5FB5
LD (54B0H),HL 22 B0 54
Store HL into addresses 54B0H-54B1H. This saves the current cursor position for the command echo buffer.
5FB8
Call routine at 62A7H to clear the command line area on screen, preparing for new input.
5FBB
LD HL,3C00H 21 00 3C
Load Register pair HL with 3C00H, the start of TRS-80 video memory. This is where the sector display will begin.
5FBE
LD DE,(5495H) ED 5B 95 54
Load Register pair DE with the 16-bit value at addresses 5495H-5496H. This is the display offset into the sector buffer (5300H + offset = current display position).
5FC2
LD A,10H 3E 10
Load Register A with 10H (16 decimal). This is the row counter - 16 rows of 16 bytes each will be displayed.
5FC4
PUSH BC C5
Save Register pair BC onto the stack. BC holds the current edit position from the MOD command.
5FC5
EX AF,AF' 08
Exchange AF with the alternate AF' register. This preserves the row counter (A=10H) in AF' while using A for other purposes.

5FC6H - Format Display Row Address

This section calculates and displays the address prefix for each row of the hex dump. It shows the offset within the sector at the left margin.

5FC6
INC L 2C
Increment L (low byte of screen position). Advance past the first 4 character positions.
5FC7
INC L 2C
Increment L again (2 positions).
5FC8
INC L 2C
Increment L again (3 positions).
5FC9
INC L 2C
Increment L again (4 positions). HL now points to column 4 of the current row for the hex data area.
5FCA
LD A,(5495H) 3A 95 54
Load Register A with the low byte of the display offset from 5495H.
5FCD
NEG ED 44
Negate A (A = 0 - A). This calculates the two's complement for offset calculation.
5FCF
ADD A,E 83
Add E (low byte of current data pointer) to A. This calculates the relative offset within the current display page.
5FD0
LD C,A 4F
Copy the calculated offset to Register C for later use when formatting the address display.
5FD1
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from address 5491H.
5FD4
AND 28HAND 00101000 E6 28
Mask with 28H to isolate bits 3 and 5. Bit 3 = memory mode, bit 5 = alternate display mode.
5FD6
If Z (neither memory mode nor alternate mode), jump to 5FE0H to skip the high byte display.

Memory or alternate mode - display the high byte of the address.

5FD8
DEC L 2D
Decrement L to move screen position back 2 characters for the high byte.
5FD9
DEC L 2D
Decrement L again (2 positions back).
5FDA
LD A,(54B5H) 3A B5 54
Load Register A with the byte at 54B5H. This is the high byte of the display address (page number in memory mode).
5FDD
Call routine at 61EFH to convert byte in A to 2 hex ASCII characters and store at (HL), advancing HL by 2.
5FE0
LD A,C 79
Load Register A with C (the low byte offset calculated earlier).
5FE1
Call routine at 61EFH to convert the low byte offset to hex ASCII and display it.
5FE4
LD C,08H 0E 08
Load Register C with 08H (8 decimal). This is the byte pair counter - 8 pairs of bytes per row (16 bytes total).
5FE6
INC L 2C
Increment L to add a space between address and hex data.
5FE7
INC L 2C
Increment L again (2-character space).

5FE8H - Format Hex Bytes and ASCII Display

This is the main formatting loop that displays each row of the hex dump. For each row, it shows 8 pairs of hex bytes in the left portion of the screen, and the corresponding ASCII characters in the right portion. Non-printable characters are displayed as periods.

5FE8
PUSH HL E5
Save HL (current hex display position) onto the stack.
5FE9
LD A,L 7D
Load Register A with L (low byte of screen position).
5FEA
ADD 28H C6 28
Add 28H (40 decimal) to A. This calculates the position for the ASCII display area (40 columns to the right).
5FEC
LD L,A 6F
Store the ASCII display position back into L.
5FED
EX (SP),HL E3
Exchange HL with the top of stack. Now HL=hex position (from stack), ASCII position is saved on stack.
5FEE
LD B,02H 06 02
Load Register B with 02H. This is the bytes per pair counter - 2 bytes are displayed with a space between pairs.
5FF0
LD A,(DE) 1A
Load Register A with the byte from (DE), the sector data buffer. DE points to the current byte being displayed.
5FF1
Call routine at 61EFH to convert the byte to 2 hex ASCII characters and store at (HL) on screen.

Now determine if this byte is printable ASCII for the right-side display.

5FF4
PUSH BC C5
Save BC (counters) onto the stack.
5FF5
LD C,3FH 0E 3F
Load Register C with 3FH (63 decimal). This is the default printable range limit (characters 21H-5FH are printable in standard ASCII).
5FF7
LD A,(436CH) 3A 6C 43
Load Register A from address 436CH. This is a system flag byte that may indicate lowercase support.
5FFA
BIT 4,A CB 67
Test bit 4 of the system flags. Bit 4 indicates lowercase display enabled.
5FFC
If Z (no lowercase support), jump to 6000H with C=3FH.
5FFE
LD C,5FH 0E 5F
Lowercase enabled - load C with 5FH (95 decimal). Extends printable range to include lowercase letters (21H-7FH).
6000
LD A,(DE) 1A
Reload Register A with the byte from (DE) for the printability check.
6001
SUB 21H D6 21
Subtract 21H (first printable character) from A. If A was < 21H, this will set carry.
6003
CP C B9
Compare A with C (printable range limit). If A ≥ C (non-printable high character), carry is clear.
6004
POP BC C1
Restore BC (counters) from the stack.
6005
LD A,(DE) 1A
Reload Register A with the original byte from (DE) for potential display.
6006
INC DE 13
Increment DE to point to the next byte in the sector buffer.
6007
If carry set (character is printable), jump to 600BH to display the actual character.
6009
LD A,2EH 3E 2E
Character not printable - load A with 2EH (ASCII . period) as a placeholder.
600B
EX (SP),HL E3
Exchange HL with top of stack. Now HL = ASCII display position.
600C
LD (HL),A 77
Store the ASCII character (or period) at the screen position (HL).
600D
INC HL 23
Increment HL to the next ASCII display position.
600E
EX (SP),HL E3
Exchange back - HL = hex position, ASCII position saved on stack.
600F
Decrement B and jump back to 5FF0H if not zero. [BYTE PAIR LOOP] Processes 2 bytes per iteration.
6011
INC HL 23
Increment HL to add a space between byte pairs in the hex display.
6012
DEC C 0D
Decrement C (byte pair counter).
6013
If C not zero (more pairs to display), jump back to 5FEEH. [PAIR LOOP]
6015
POP HL E1
Pop the ASCII position off the stack (no longer needed).
6016
EX AF,AF' 08
Exchange AF with AF' to retrieve the row counter.
6017
DEC A 3D
Decrement the row counter (A).
6018
If A not zero (more rows to display), jump back to 5FC5H. [ROW LOOP]

601AH - Check Display Mode and Show Status

After displaying the 16 rows of hex/ASCII dump, this section checks the display mode flags and adds status information at the bottom of the screen. It shows disk number, track, sector, and granule information depending on the active mode (file mode, memory mode, or standard disk mode).

601A
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from address 5491H.
601D
BIT 5,A CB 6F
Test bit 5 of the mode flags. Bit 5 indicates alternate display mode (raw display without status).
601F
If bit 5 is set (NZ, alternate mode), jump to 60EAH to skip status display and return.
6022
BIT 3,A CB 5F
Test bit 3 of the mode flags. Bit 3 indicates memory mode (viewing RAM/ROM instead of disk).
6024
If bit 3 is clear (Z, not memory mode), jump to 6032H to display standard disk status.

Memory mode - display "M" indicator at start of first line.

6026
LD HL,3C00H 21 00 3C
Load Register pair HL with 3C00H, the start of video memory (first character position).
6029
LD DE,444DH 11 4D 44
Load Register pair DE with 444DH. E=4DH (ASCII M), D=44H (ASCII D). This spells "MD" for Memory Display.
602C
LD (HL),E 73
Store E (ASCII M) at the screen position (HL=3C00H).
602D
INC HL 23
Increment HL to the next screen position.
602E
LD (HL),D 72
Store D (ASCII D) at position 3C01H, completing the "MD" indicator.
602F
Jump to 60EAH to restore BC and return (no further status needed for memory mode).

6032H - Display Disk Number Status

This section displays the disk drive number on the status line at the top of the screen. It sets up the display parameters and calls the status formatting routine.

6032
LD BC,68FEH 01 FE 68
Load Register pair BC with 68FEH. B=68H points to the format string table, C=FEH is the format code for disk number display.
6035
LD DE,3C00H 11 00 3C
Load Register pair DE with 3C00H, the screen position for the disk number display (top-left corner).
6038
LD A,(5406H) 3A 06 54
Load Register A with the current disk number from FCB offset 06H at address 5406H. This is 0-3 for drives 0-3.
603B
LD L,A 6F
Copy the disk number to Register L.
603C
LD H,00H 26 00
Clear Register H. HL now contains the disk number as a 16-bit value (0-3).
603E
Call routine at 60ECH to format and display the disk number using the format string at B and code in C.

6041H - Check for File Mode Status

This section loads the current sector number and checks if file mode is active. In file mode, additional information about granules and file position is displayed. Otherwise, track and sector information is shown.

6041
LD HL,(54A2H) 2A A2 54
Load Register pair HL with the current absolute sector number from addresses 54A2H-54A3H.
6044
PUSH HL E5
Save the sector number onto the stack for later use in status display.
6045
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from 5491H.
6048
BIT 6,A CB 77
Test bit 6 of the mode flags. Bit 6 indicates file mode is active (viewing a file rather than raw disk).
604A
If bit 6 is clear (Z, not file mode), jump to 60ACH to display standard track/sector status.

604CH - Calculate File Position for Status

When in file mode, this section calculates the current position within the file by traversing the granule allocation chain. It determines which granule contains the current sector and calculates the offset within the file.

604C
LD A,(549DH) 3A 9D 54
Load Register A with the byte at 549DH. This is the sectors per granule value for the current disk format.
604F
Call routine at 6896H to convert sectors per granule to a bit mask or multiplier for position calculations.
6052
PUSH AF F5
Save the conversion result (AF) onto the stack.
6053
EX DE,HL EB
Exchange DE and HL. DE now contains the screen position from earlier, HL is free for calculations.
6054
LD BC,0000H 01 00 00
Initialize Register pair BC to 0000H. BC will accumulate the file byte offset.
6057
LD A,08H 3E 08
Load Register A with 08H (8 decimal). This is the granule chain loop limit (maximum 8 granule pointers to check per extent).
6059
LD HL,540EH 21 0E 54
Load Register pair HL with 540EH, pointing to the FCB granule chain at offset 0EH. This contains up to 8 granule numbers for the file.
605C
EX AF,AF' 08
Exchange AF with AF' to save the loop counter while using A for data.

605DH - Traverse Granule Chain

This loop traverses the granule allocation chain in the FCB to calculate the file position. It checks each granule entry to see if the current sector falls within that granule, accumulating the byte offset as it goes.

605D
LD A,(HL) 7E
Load Register A with the granule number from the FCB chain at (HL).
605E
CP 0FEH FE FE
Compare with FEH. Granule values >= FEH indicate end of file or deleted granule.
6060
If no carry (granule >= FEH, end of chain), jump to 6089H to finish position calculation.
6063
INC HL 23
Increment HL to point to the sector count byte for this granule entry.
6064
LD A,(HL) 7E
Load Register A with the sector count for this granule.
6065
EX DE,HL EB
Exchange DE and HL. HL now has the working value, DE points to FCB.
6066
OR A B7
Clear carry flag by ORing A with itself (also tests if A is zero).
6067
SBC HL,BC ED 42
Subtract the accumulated count (BC) from the current sector (HL) with borrow.
6069
If carry (current sector < accumulated count), jump to 6089H - sector is in a previous granule.
606B
INC H 24
Increment H to test if HL high byte is non-zero.
606C
DEC H 25
Decrement H back. Z flag is set only if H was (and still is) zero.
606D
If NZ (H > 0, more than 256 sectors remaining), jump to 6074H to continue accumulating.
606F
AND 1FHAND 00011111 E6 1F
Mask the sector count with 1FH (31 decimal) to get sectors in last granule.
6071
CP L BD
Compare sector count with L (low byte of remaining sectors).
6072
If no carry (sector count >= remaining), jump to 608DH - found the correct granule.
6074
ADD HL,BC 09
Add BC back to HL to restore the original sector number.
6075
INC A 3C
Increment A (sector count from this granule entry).
6076
ADD A,C 81
Add C (low byte of accumulated count) to A.
6077
LD C,A 4F
Store the new low byte back into C.
6078
If no carry from addition, jump to 607BH.
607A
INC B 04
Carry occurred - increment B (high byte of accumulated count).
607B
EX DE,HL EB
Exchange back - HL points to FCB, DE has sector value.
607C
INC HL 23
Increment HL to point to the next granule entry in the FCB chain.
607D
EX AF,AF' 08
Exchange AF with AF' to get the loop counter.
607E
CP 05H FE 05
Compare loop counter with 05H. At entry 5, there's a 2-byte pointer to the next extent.
6080
If not at entry 5, jump to 6086H to continue normally.
6082
LD C,(HL) 4E
Load C with the low byte of the extent pointer.
6083
INC HL 23
Increment HL past the low byte.
6084
LD B,(HL) 46
Load B with the high byte of the extent pointer.
6085
INC HL 23
Increment HL to point to the next granule entry.
6086
DEC A 3D
Decrement the loop counter.
6087
If counter not zero, jump back to 605CH to process the next granule entry. [GRANULE CHAIN LOOP]

6089H - Complete File Position Calculation

This section completes the file position calculation and proceeds to display the track/sector status line.

6089
POP AF F1
Pop AF from the stack (the sectors-per-granule conversion result saved at 6052H).
608A
Jump to 60B5H to continue with track/sector display.

608DH - Calculate Exact File Offset

When the correct granule is found, this section calculates the exact byte offset within the file based on the granule position and sector offset.

608D
LD A,(DE) 1A
Load Register A with the byte from (DE), the granule entry sector count.
608E
AND 0E0HAND 11100000 E6 E0
Mask with E0H to isolate the high 3 bits (granule type flags or high sector bits).
6090
DEC DE 1B
Decrement DE to point back to the granule number byte.
6091
RLCA 07
Rotate A left (1 bit).
6092
RLCA 07
Rotate A left again (2 bits).
6093
RLCA 07
Rotate A left again (3 bits). The high 3 bits are now in the low 3 bit positions.
6094
ADD A,L 85
Add L (sector offset within granule) to A.
6095
LD L,A 6F
Store the combined offset back into L.
6096
PUSH HL E5
Save the calculated offset onto the stack.
6097
LD A,(DE) 1A
Load Register A with the granule number from (DE).
6098
LD L,A 6F
Copy granule number to L.
6099
LD A,(549CH) 3A 9C 54
Load Register A with the byte at 549CH. This is the sectors per track value.
609C
Call routine at 687DH to multiply or convert the granule number to a sector offset.
609F
POP DE D1
Pop the saved offset into DE.
60A0
ADD HL,DE 19
Add DE (granule offset) to HL (sector conversion). HL now has the total sector number.
60A1
LD A,(549DH) 3A 9D 54
Load Register A with the sectors per granule from 549DH.
60A4
Call the conversion routine again.
60A7
POP AF F1
Pop the saved AF (original conversion result).
60A8
LD E,A 5F
Copy A to E.
60A9
LD D,00H 16 00
Clear Register D. DE now contains the offset value from A as a 16-bit value (D=00H, E=offset).
60AB
ADD HL,DE 19
Add DE (final offset adjustment) to HL (accumulated sector position). HL now contains the complete file sector position.
60AC
LD DE,3D00H 11 00 3D
Load Register pair DE with 3D00H. This is the screen position for sector status (row 4 of video memory, which starts at 3C00H with 64 bytes per row).
60AF
LD BC,6907H 01 07 69
Load Register pair BC with 6907H. B=69H points to the format string table base, C=07H is the format code for "SEC=" display.
60B2
Call routine at 60ECH to format and display the sector number from HL using the format string specified by BC.

60B5H - Display Track Number Status

This section displays the track number on the status line. It retrieves the sector number from the stack, checks if file mode is active, and calculates the track number based on sectors per track.

60B5
LD BC,690AH 01 0A 69
Load Register pair BC with 690AH. B=69H is the format string table base, C=0AH is the format code for "TRK=" display.
60B8
POP HL E1
Pop the absolute sector number from the stack (saved at 6044H).
60B9
LD A,(5491H) 3A 91 54
Load Register A with the primary mode flags from address 5491H.
60BC
BIT 6,A CB 77
Test bit 6 of the mode flags. Bit 6 indicates file mode is active.
60BE
If bit 6 is set (NZ, file mode), jump to 60DEH to display the track number at a different screen location.

Standard disk mode - calculate and display track number from absolute sector.

60C0
LD A,(549BH) 3A 9B 54
Load Register A with the byte at 549BH. This is the sectors per track value for the current disk format (typically 10 or 18).
60C3
Call routine at 6896H to divide HL by sectors per track. Returns quotient (track number) in A, remainder (sector within track) in HL.
60C6
PUSH AF F5
Save AF (track number in A) onto the stack.
60C7
LD (54A0H),A 32 A0 54
Store the track number into address 54A0H for later reference by other routines.
60CA
LD A,L 7D
Load Register A with L (the sector within track from the division remainder).
60CB
LD (549EH),A 32 9E 54
Store the sector-within-track into address 549EH for later reference.
60CE
LD BC,6901H 01 01 69
Load Register pair BC with 6901H. C=01H is the format code for sector-within-track display.
60D1
LD DE,3E00H 11 00 3E
Load Register pair DE with 3E00H. This is the screen position for sector-within-track (row 8 of video memory).
60D4
Call routine at 60ECH to display the sector-within-track number.
60D7
POP AF F1
Pop the saved track number back into Register A.
60D8
LD L,A 6F
Copy the track number to Register L.
60D9
LD H,00H 26 00
Clear Register H. HL now contains the track number as a 16-bit value.
60DB
LD BC,6904H 01 04 69
Load Register pair BC with 6904H. C=04H is the format code for track number display.

60DEH - Display Track Number and Search Type

This section displays the track number at screen position 3F00H (bottom status row), then displays the current search/operation type indicator at position 3FC1H.

60DE
LD DE,3F00H 11 00 3F
Load Register pair DE with 3F00H. This is the screen position for track number display (row 12 of video memory, near bottom of screen).
60E1
Call routine at 60ECH to format and display the track number from HL using format code in C.
60E4
LD A,(5494H) 3A 94 54
Load Register A with the search/operation type flag from address 5494H. This indicates the current mode (F=Find, L=List, etc.).
60E7
LD (3FC1H),A 32 C1 3F
Store the operation type character directly to screen position 3FC1H. This shows the current command mode indicator at the bottom right of the display.

60EAH - Restore Registers and Return

This is the common exit point for the sector display routine. It restores the BC register pair that was saved at the beginning and returns to the caller.

60EA
POP BC C1
Pop Register pair BC from the stack. BC was saved at 5FC4H and contains the edit position from the MOD command.
60EB
RET C9
Return to the caller with the sector display complete.

60ECH - Format and Display Status Value

This is a general-purpose routine for formatting and displaying numeric status values on the screen. It takes a 16-bit value in HL, a screen position in DE, and a format string address in BC. It calculates three screen positions (base, +64, +128 for multi-line display), copies a 3-character label from the format string to the base position, then displays the value in three formats: as a formatted string, in decimal, and in hexadecimal with an "H" suffix.

60EC
PUSH HL E5
Save Register pair HL (the numeric value to display) onto the stack.
60ED
LD HL,0080H 21 80 00
Load Register pair HL with 0080H (128 decimal). This is the offset for the third display line (2 rows × 64 bytes per row in TRS-80 video memory).
60F0
ADD HL,DE 19
Add DE (base screen position) to HL. HL now points to screen position + 128 (two rows below base).
60F1
EX (SP),HL E3
Exchange HL with top of stack. The third-line position is saved on stack, HL now has the numeric value again.
60F2
PUSH HL E5
Save the numeric value onto the stack (needed later for decimal display).
60F3
PUSH HL E5
Save the numeric value a third time (needed for formatted string display).
60F4
LD HL,0040H 21 40 00
Load Register pair HL with 0040H (64 decimal). This is the offset for the second display line (1 row × 64 bytes).
60F7
ADD HL,DE 19
Add DE (base screen position) to HL. HL now points to screen position + 64 (one row below base).
60F8
EX (SP),HL E3
Exchange HL with top of stack. The second-line position is saved, HL has numeric value.
60F9
PUSH HL E5
Save the numeric value onto the stack (for label copy source address calculation).
60FA
LD H,B 60
Copy B (high byte of format string address, typically 69H) to Register H.
60FB
LD L,C 69
Copy C (low byte of format string address) to Register L. HL now points to the format string (e.g., "SEC", "TRK", "DSK" at addresses like 6901H, 6904H, etc.).
60FC
LD BC,0003H 01 03 00
Load Register pair BC with 0003H. This is the label length - copy 3 characters for the status label.
60FF
LDIR ED B0
Block copy BC (3) bytes from (HL) to (DE). This copies the 3-character label (like "SEC" or "TRK") to the screen at the base position. DE advances to base+3.
6101
POP DE D1
Pop DE from the stack. DE now contains the numeric value (was pushed at 60F9H).
6102
Call routine at 68AFH to format and display the value in a special format (possibly with leading zeros or spacing). Screen position in HL (from LDIR), value in DE.
6105
POP DE D1
Pop DE from the stack. DE now contains the second-line screen position (base + 64, pushed at 60F8H).
6106
Call routine at 668AH to display the value in decimal at screen position DE. The numeric value is retrieved from the stack inside this routine.
6109
POP DE D1
Pop DE from the stack. DE now contains the third-line screen position (base + 128, pushed at 60F1H).
610A
POP HL E1
Pop HL from the stack. HL now contains the numeric value (original value pushed at 60ECH).
610B
Call routine at 6665H to convert HL to hexadecimal ASCII and display at screen position DE. Returns with HL pointing past the hex digits.
610E
LD (HL),48H 36 48
Store 48H (ASCII H) at the current screen position (HL). This adds the "H" suffix to indicate hexadecimal notation.
6110
RET C9
Return to the caller. The status value has been displayed in three formats on three consecutive lines.

6111H - Boundary Range Check

This routine checks if the current position falls within a specified boundary range. It compares values at 5499H and 549AH, then checks if the current sector (54A2H) is within range of the target sector (54A4H). If within range, it sets bit 7 of the secondary mode flags at 5493H. This is used during search operations to determine if a match has been found within the current sector.

6111
LD HL,549AH 21 9A 54
Load Register pair HL with 549AH, pointing to the boundary comparison high byte.
6114
LD A,(5499H) 3A 99 54
Load Register A with the byte at 5499H, the boundary comparison low byte.
6117
CP (HL) BE
Compare A with the byte at (HL=549AH). Checks if the two boundary bytes match.
6118
RET NZ C0
If NZ (boundary bytes don't match), return immediately - not in range.
6119
PUSH DE D5
Save Register pair DE onto the stack (contains position offset from caller).
611A
LD HL,(54A4H) 2A A4 54
Load Register pair HL with the target sector number from addresses 54A4H-54A5H.
611D
LD DE,(54A2H) ED 5B A2 54
Load Register pair DE with the current sector number from addresses 54A2H-54A3H.
6121
OR A B7
Clear the carry flag by ORing A with itself.
6122
SBC HL,DE ED 52
Subtract DE (current sector) from HL (target sector) with borrow. Result = target - current.
6124
If carry (target < current, searching backwards), jump to 612DH to handle reverse range check.

Forward search - target ≥ current sector.

6126
POP HL E1
Pop the saved DE value into HL (position offset).
6127
RET NZ C0
If NZ (target != current sector), return - not on the target sector yet.

On the target sector - check byte position within sector.

6128
LD A,B 78
Load Register A with B (high byte of position or search parameter from caller).
6129
CP C B9
Compare A (B) with C (low byte of position). Checks position against boundary.
612A
RET NC D0
If no carry (B ≥ C, position not past boundary), return - not yet at boundary.
612B
Jump to 6134H to set the boundary flag.

612DH - Reverse Range Check

This section handles the reverse search case where the target sector is before the current sector. It recalculates the range to determine if the current position is within the search boundary.

612D
ADD HL,DE 19
Add DE back to HL. This restores HL to the target sector (undoing the previous SBC).
612E
POP BC C1
Pop the saved position offset into BC (was pushed as DE at 6119H).
612F
ADD HL,BC 09
Add BC (position offset) to HL (target sector). HL = target + offset.
6130
OR A B7
Clear the carry flag.
6131
SBC HL,DE ED 52
Subtract DE (current sector) from HL (target + offset). Checks if current is within range.
6133
RET C D8
If carry (current sector is past the adjusted target), return - out of range.

6134H - Set Boundary Flag

This section sets bit 7 of the secondary mode flags to indicate that the boundary condition has been met. This flag signals to the calling code that the search target has been found.

6134
LD HL,5493H 21 93 54
Load Register pair HL with 5493H, the address of the secondary mode flags byte.
6137
SET 7,(HL) CB FE
Set bit 7 of the byte at (HL). Bit 7 indicates boundary/target found.
6139
RET C9
Return to the caller with the boundary flag set.

613AH - Print Sector Display to Printer

This routine prints the current sector display to the printer. It first refreshes the screen display, then outputs each character of the first row (64 characters) to the printer, converting TRS-80 graphics characters to printable ASCII. The user can press H to halt, P to pause, or let it continue for multiple pages.

613A
PUSH BC C5
Save Register pair BC onto the stack. BC contains the page counter from the caller.
613B
Call routine at 5FB8H to refresh the sector display on screen, showing the current sector contents in hex/ASCII format.
613E
Call routine at 6379H to output a carriage return to the printer, starting a new line.
6141
POP BC C1
Restore Register pair BC (page counter) from the stack.
6142
LD HL,3C00H 21 00 3C
Load Register pair HL with 3C00H, the start of video memory. This is where the sector display begins.
6145
LD B,40H 06 40
Load Register B with 40H (64 decimal). This is the number of characters per row to print.

6147H - Print Row Character Loop

This loop reads each character from video memory and outputs it to the printer. TRS-80 graphics characters (codes 00H-1FH and 80H-BFH) are converted to printable ASCII by adding 40H to codes below 20H.

6147
LD A,(HL) 7E
Load Register A with the character from video memory at (HL).
6148
CP 20H FE 20
Compare A with 20H (ASCII space). Characters below 20H are TRS-80 graphics characters that need conversion.
614A
INC HL 23
Increment HL to point to the next character in video memory.
614B
If no carry (character ≥ 20H, already printable), jump to 614FH to output it directly.
614D
ADD 40H C6 40
Add 40H to A. This converts TRS-80 graphics codes (00H-1FH) to printable characters (40H-5FH, which are @, A-Z, etc.).
614F
Call routine at 62C8H to output character A to the printer.
6152
Decrement B and jump back to 6147H if not zero. [PRINT ROW LOOP] Prints all 64 characters of the row.
6154
Call routine at 6248H to output a newline to the printer after the row.

6157H - Check for User Interrupt

After printing each row, this section checks if the user has pressed a key to halt or pause the printing. H halts completely, P pauses until Enter is pressed.

6157
Call routine at 6205H to scan the keyboard for a keypress. Returns A=key code if pressed, or 0 if no key.
615A
CP 48H FE 48
Compare A with 48H (ASCII H for Halt).
615C
If not H (NZ), jump to 6164H to check for other keys.

User pressed H - halt printing and return to command loop.

615E
Call routine at 6374H to flush the printer buffer and finalize output.
6161
Jump to 65B4H to return to the command loop, aborting the print operation.
6164
CP 50H FE 50
Compare A with 50H (ASCII P for Pause).
6166
If not P (NZ), jump to 616FH to continue printing.

6168H - Pause and Wait for Enter

When the user presses P, this loop waits for them to press Enter before resuming the print operation.

6168
Call routine at 620BH to wait for a keypress. Returns the key code in A.
616B
CP 0DH FE 0D
Compare A with 0DH (ASCII carriage return = Enter).
616D
If not Enter (NZ), loop back to 6168H to wait. [PAUSE LOOP]

616FH - Continue Printing or Finish

This section decrements the page counter and either continues printing the next row or finishes the print job with extra newlines.

616F
DEC C 0D
Decrement Register C (the row counter for the current page).
6170
If C not zero (more rows to print), jump back to 6145H. [PAGE LOOP]

Finished printing all rows - add blank lines and finalize.

6172
Call routine at 6248H to output a blank line to the printer.
6175
Call routine at 6248H again to output a second blank line for spacing.
6178
Jump to 6374H to flush the printer buffer and return to the caller.

617BH - Initialize Edit Buffers

This routine initializes the edit buffers for sector operations. It calculates the buffer size based on the value at 54B4H, sets up the source buffer at 4200H and destination buffer at 5300H, stores the buffer address in the FCB, and fills the destination buffer with FFH bytes while reading keyboard input. This allows the user to enter data while the buffer is being initialized.

617B
LD HL,(54B4H) 2A B4 54
Load Register pair HL with the 16-bit value at addresses 54B4H-54B5H. This is the buffer size or page value used for calculations.
617E
Call routine at 61BFH to calculate the buffer parameters based on HL. Returns B=byte count.
6181
LD HL,4200H 21 00 42
Load Register pair HL with 4200H, the source buffer address. This buffer holds the original sector data for comparison during Copy operations.
6184
LD (5403H),HL 22 03 54
Store HL into addresses 5403H-5404H. This is FCB offset 03H, storing the source buffer address for disk operations.
6187
LD HL,5300H 21 00 53
Load Register pair HL with 5300H, the destination buffer address. This is the main edit buffer where sector data is displayed and modified.
618A
LD C,00H 0E 00
Load Register C with 00H. C serves as a secondary counter or flag for the fill loop.
618C
LD DE,5400H 11 00 54
Load Register pair DE with 5400H, the FCB base address. This is passed to the keyboard routine for reference.
618F
Jump to 6195H to start the fill/input loop, skipping the first fill iteration.

6191H - Fill Buffer with FFH

This loop fills the destination buffer at 5300H with FFH bytes. The FFH value represents "empty" or "uninitialized" data in the TRS-80 disk format.

6191
LD (HL),0FFH 36 FF
Store FFH at the buffer position (HL). FFH is the default fill byte representing empty/uninitialized data.
6193
DEC C 0D
Decrement Register C (secondary counter). This tracks additional operations during the fill.
6194
INC HL 23
Increment HL to point to the next buffer position.
6195
Decrement B and jump back to 6191H if not zero. [BUFFER FILL LOOP] Fills B bytes with FFH.

6197H - Keyboard Input During Fill

After filling the buffer, this section reads keyboard input using the ROM routine at 0013H. Characters are stored into the buffer, allowing the user to enter data. Special keys (BREAK, CLEAR) are handled separately.

6197
LD B,C 41
Copy C (secondary counter) to B. B becomes the input character counter.
6198
Call ROM routine at 0013H. This is the TRS-80 keyboard input routine that waits for and returns a character in A. Z flag set if no special key.
619B
If NZ (special key pressed like BREAK or CLEAR), jump to 61A2H to handle it.
619D
LD (HL),A 77
Store the input character A into the buffer at (HL).
619E
INC HL 23
Increment HL to point to the next buffer position.
619F
Decrement B and loop back to 6198H if not zero. [INPUT LOOP] Reads up to B characters.
61A1
RET C9
Return to the caller with the buffer filled and input complete.

61A2H - Handle Special Keys

This section handles special keys returned by the ROM keyboard routine. Key code 1CH indicates BREAK was pressed (fill remaining buffer with FFH and show error), while 1DH indicates CLEAR was pressed (return to a specific menu).

61A2
CP 1CH FE 1C
Compare A with 1CH. This is the BREAK key code returned by the ROM routine.
61A4
If not BREAK (NZ), jump to 61B7H to check for other special keys.

BREAK pressed - fill remaining buffer with FFH and show abort message.

61A6
LD (HL),0FFH 36 FF
Store FFH at the current buffer position (HL) to fill remaining space.
61A8
INC HL 23
Increment HL to the next position.
61A9
Decrement B and loop if not zero. [BREAK FILL LOOP] Fills remaining buffer with FFH.
61AB
Load Register pair HL with 6ECBH, the address of an abort/break message string.
61AE
Call routine at 6245H to display the message with a newline.
61B1
Load Register pair HL with 6DD5H, the address of a prompt or continuation message.
61B4
Jump to 6345H to display the message and wait for a keypress before returning.
61B7
CP 1DH FE 1D
Compare A with 1DH. This is the CLEAR key code.
61B9
If not CLEAR (NZ), jump to 6578H to handle as an unknown/error key.
61BC
CLEAR was pressed - jump to 56A9H to return to the main menu.

61BFH - Calculate Buffer Parameters from Input Value

This routine calculates sector and offset values from an input address in HL. It compares HL against the limit value at 54B2H, computes the sector number and byte offset within sector, and sets up the FCB fields for file positioning. On entry: HL = input address value. On exit: FCB at 540AH contains sector number, 5405H contains byte offset, bit 5 of 5401H is set to indicate special buffer mode.

61BF
LD DE,(54B2H) ED 5B B2 54
Load DE with the buffer limit value from 54B2H. This is the comparison/boundary value for range checking.
61C3
OR A B7
Clear the Carry flag by ORing A with itself. Prepares for the SBC instruction.
61C4
SBC HL,DE ED 52
Subtract DE (buffer limit) from HL with borrow. HL = HL - DE. If HL was less than DE, Carry is set.
61C6
LD BC,0100H 01 00 01
Load BC with 0100H. B = 01H (page/sector multiplier), C = 00H (initial offset). This is the default for when HL ≥ DE.
61C9
If no carry (HL ≥ DE, input is at or beyond limit), jump to 61D4H to continue with default BC values.

HL was less than DE (input below limit). Set up alternative calculation.

61CB
LD H,C 61
Load H with C (which is 00H). Start building result with H = 0.
61CC
LD L,C 69
Load L with C (00H). Now HL = 0000H.
61CD
LD B,E 43
Load B with E (low byte of the limit). B now holds the page value from the limit.
61CE
LD E,C 59
Load E with C (00H). E is now 0.
61CF
LD (54B4H),DE ED 53 B4 54
Store DE to 54B4H, the buffer size/page value location. This records the calculated page info.
61D3
INC B 04
Increment B (the page counter). Adjusts for the calculation.
61D4
LD DE,0002H 11 02 00
Load DE with 0002H. This is an adjustment value for the sector calculation.
61D7
ADD HL,DE 19
Add 2 to HL. This adjusts the offset for sector boundary alignment.
61D8
If no carry (no overflow), jump to 61DBH to continue.
61DA
INC C 0C
Increment C if there was a carry (overflow into next page). C tracks the high byte of the sector number.
61DB
LD A,L 7D
Load A with L, the low byte of the adjusted value. This becomes the byte offset within sector.
61DC
LD L,H 6C
Load L with H. Shift the high byte down to become the low byte of sector number.
61DD
LD H,C 61
Load H with C (the overflow counter). HL now contains the sector number.
61DE
LD (540AH),HL 22 0A 54
Store HL to 540AH, the sector number field in the FCB. This is the calculated sector.
61E1
LD (5405H),A 32 05 54
Store A to 5405H, the byte offset field in the FCB. This is the position within the sector.
61E4
LD HL,5401H 21 01 54
Load HL with 5401H, the address of the FCB mode/attribute flags.
61E7
SET 5,(HL) CB EE
Set bit 5 of the FCB flags, indicating special buffer mode is active. This tells the I/O routines to use the calculated buffer position.
61E9
RET C9
Return to caller. Buffer parameters are now set up in the FCB.

61EAH - Convert DE to Hex ASCII at (HL)

This routine converts the 16-bit value in DE to 4 hex ASCII characters, storing them at the address in HL. It calls the byte conversion routine twice - once for D (high byte) and once for E (low byte). On entry: DE = 16-bit value to convert, HL = destination buffer address. On exit: HL points past the 4 stored characters.

61EA
LD A,D 7A
Load A with D, the high byte of the value to convert.
61EB
Call the byte to hex routine at 61EFH. Converts A (high byte) to 2 hex ASCII chars at (HL), advances HL by 2.
61EE
LD A,E 7B
Load A with E, the low byte of the value to convert. Fall through to convert this byte as well.

61EFH - Convert Byte A to 2 Hex ASCII Characters at (HL)

This routine converts the byte in A to two hex ASCII characters, storing them at the address in HL. It converts the high nibble first, then the low nibble. On entry: A = byte to convert, HL = destination address. On exit: HL points past the 2 stored characters (HL = HL + 2).

61EF
PUSH AF F5
Save A onto the stack. We need the original value for the low nibble later.
61F0
RRCA 0F
Rotate A right. First of 4 rotations to move high nibble to low nibble position.
61F1
RRCA 0F
Rotate A right again.
61F2
RRCA 0F
Rotate A right again.
61F3
RRCA 0F
Rotate A right a fourth time. The high nibble is now in the low nibble position (bits 0-3).
61F4
Call the nibble to hex routine at 61F8H to convert and store the high nibble as an ASCII character.
61F7
POP AF F1
Restore the original A value. The low nibble is now ready for conversion. Fall through to convert it.

61F8H - Convert Low Nibble of A to Hex ASCII and Store at (HL)

This routine converts the low nibble (bits 0-3) of A to a hex ASCII character ('0'-'9' or 'A'-'F') and stores it at the address in HL, then increments HL. On entry: A = value with nibble to convert in bits 0-3, HL = destination address. On exit: Character stored at (HL), HL = HL + 1.

61F8
AND 0FHAND 00001111 E6 0F
Mask A with 0FH to isolate the low nibble (bits 0-3). A is now 00H-0FH.
61FA
CP 0AH FE 0A
Compare A with 0AH (10 decimal). Check if nibble is 0-9 or A-F.
61FC
If A < 0AH (nibble is 0-9), jump to 6200H to skip the letter adjustment.
61FE
ADD A,07H C6 07
Add 7 to A. This adjusts for the gap between '9' (39H) and 'A' (41H) in ASCII. A is now 11H-16H.
6200
ADD A,30H C6 30
Add 30H ('0') to A. Converts nibble value to ASCII character. Result is '0'-'9' (30H-39H) or 'A'-'F' (41H-46H).
6202
LD (HL),A 77
Store the hex ASCII character at the destination address (HL).
6203
INC HL 23
Increment HL to point to the next buffer position.
6204
RET C9
Return to caller. One hex character has been stored.

6205H - Non-Blocking Keyboard Scan

This routine performs a non-blocking keyboard scan by calling ROM routine 002BH. It preserves DE and converts any lowercase letters to uppercase. On entry: None. On exit: A = key code if key pressed (converted to uppercase), A = 0 if no key, DE preserved.

6205
PUSH DE D5
Save DE onto the stack. DE is preserved through the ROM call.
6206
CALL 002BH CD 2B 00
Call ROM routine at 002BH. This is the TRS-80 ROM keyboard scan routine. Returns A = key code, or A = 0 if no key pressed. This is non-blocking.
6209
Jump to 620FH to restore DE and convert lowercase to uppercase.

620BH - Blocking Keyboard Wait

This routine waits for a keypress by calling ROM routine 0049H. It preserves DE and converts any lowercase letters to uppercase. This is a blocking call - execution pauses until a key is pressed. On entry: None. On exit: A = key code (converted to uppercase), DE preserved.

620B
PUSH DE D5
Save DE onto the stack. DE is preserved through the ROM call.
620C
CALL 0049H CD 49 00
Call ROM routine at 0049H. This is the TRS-80 ROM wait for key routine. Blocks until a key is pressed, returns key code in A.

620FH - Restore DE and Convert Lowercase to Uppercase

This is the common exit point for keyboard routines. It restores DE from the stack and converts any lowercase letter in A to uppercase. On entry: A = key code from keyboard. On exit: A = key code (uppercase if was lowercase letter), DE restored.

620F
POP DE D1
Restore DE from the stack.

6210H - Convert Lowercase to Uppercase

This routine converts a lowercase letter (a-z) in A to uppercase (A-Z). If A is not a lowercase letter, it is returned unchanged. On entry: A = character to convert. On exit: A = uppercase character (if was lowercase) or original character.

6210
CP 61H FE 61
Compare A with 61H, the ASCII code for a. Check if character is at or above lowercase 'a'.
6212
RET C D8
If carry set (A < 61H, character is below 'a'), return immediately. Not a lowercase letter.
6213
CP 7BH FE 7B
Compare A with 7BH, one past the ASCII code for z. Check if character is at or below 'z'.
6215
RET NC D0
If no carry (A >= 7BH, character is above 'z'), return immediately. Not a lowercase letter.
6216
SUB 20H D6 20
Subtract 20H from A. This converts lowercase to uppercase (e.g., 'a' 61H becomes 'A' 41H).
6218
RET C9
Return with A containing the uppercase character.

6219H - Clear Command Line and Display String with Newlines

This routine clears the command line area on screen, then displays the string pointed to by HL, followed by 3 carriage returns (newlines) to the printer. It's used to prepare the display for new prompts or messages.

6219
Call the clear command line routine at 62A7H. This clears the bottom command line area of the screen by outputting a "home cursor" control code (1FH), preparing the screen for new output.
621C
Call the display string with newline routine. This displays the string at (HL) and outputs one carriage return to the printer. Register HL must point to the string to display.
621F
LD B,03H 06 03
Load Register B with 3, the number of additional newlines to output. Combined with the one from 6245H, this produces a total of 3 blank lines.
6221
Jump to the newline output loop at 624AH. This outputs B carriage returns (0DH characters) to the printer, creating vertical spacing.

6224H - Display String and Prompt for Y/N Confirmation

This routine displays a string at (HL), then displays the standard Y/N prompt from 6D11H and calls the confirmation input routine. On exit: Z flag set if user entered Y, NZ if N. If Z flag is set, execution jumps to 54C5H (main command handler).

6224
Call the display string with newline routine. Register HL points to the message to display before the Y/N prompt (e.g., "WRITE CHANGES").
6227
Load HL with 6D11H, the address of the Y/N prompt string (contains " (Y/N)?" or similar confirmation prompt text).
622A
Call the Y/N confirmation loop at 6231H. This displays the prompt and waits for the user to enter either Y or N. Returns with Z flag set if Y, NZ if N.
622D
If Z flag is set (user entered Y for Yes), jump to 54C5H, the main command handler entry point. This executes the confirmed action.
6230
RET C9
Return to caller. If we reach here, the user entered N for No, so the Z flag is clear (NZ). The caller can check this to handle the rejection.

6231H - Y/N Confirmation Input Loop

This routine repeatedly displays the prompt string at (HL), collects keyboard input, and loops until the user enters either Y (59H) or N (4EH). The routine gives the user 3 attempts, re-displaying the prompt each time. On entry: HL = prompt string address. On exit: A = key pressed (59H for Y or 4EH for N), Z flag set if Y, NZ if N.

[LOOP START] - Y/N input loop. Prompts user up to 3 times for valid input.

6231
PUSH HL E5
Save HL (the prompt string address) onto the stack. This preserves the prompt address since the input routine at 634EH will modify HL.
6232
Call the display prompt and collect input routine. This displays the string at HL and waits for keyboard input. Returns with A containing the key pressed (converted to uppercase).
6235
POP HL E1
Restore HL to point to the prompt string address again, in case we need to re-prompt.
6236
DEC B 05
Decrement Register B, the retry counter. B was set to 64 (40H) by the input routine at 6354H, but we use it here to track prompt attempts.
6237
If B is not zero (more retries available), jump back to 6231H to re-display the prompt and try again. This allows multiple attempts for valid input.

After the loop, check if the user entered a valid response (Y or N).

6239
CP 4EH FE 4E
Compare A (the key pressed) with 4EH, the ASCII code for N. If equal, Z flag is set.
623B
RET Z C8
If Z flag is set (user pressed N), return immediately. The Z flag indicates the response, but note: Z=set means "No" here, which will be inverted by the next check.
623C
CP 59H FE 59
Compare A with 59H, the ASCII code for Y. If equal, Z flag is set.
623E
If Z flag is not set (user pressed neither Y nor N), jump back to 6231H to re-prompt. Invalid keys cause the loop to repeat.

[LOOP END] - User entered Y. Clear carry and return with Z flag set.

6240
OR A B7
OR A with itself. This clears the Carry flag and preserves the Z flag (which is currently set from the CP 59H comparison). A still contains 59H (Y).
6241
RET C9
Return to caller with Z flag set (indicating Y was pressed) and A = 59H. The caller can check Z to determine the user's response.

6242H - Flush Printer and Display String with Newline

This routine flushes the printer buffer, then displays the string at (HL) followed by a newline. Used when printer output needs to be synchronized before displaying new content.

6242
Call the flush printer buffer routine at 6374H. This ensures any pending printer output is sent before continuing.

6245H - Display String with Single Newline

This routine displays the string pointed to by HL, then outputs one carriage return (0DH) to the printer. On entry: HL = string address. The string display routine at 6255H is called first.

6245
Call the display string routine at 6255H. This outputs each character of the string at (HL) until a terminator is reached.
6248
LD B,01H 06 01
Load Register B with 1, the number of newlines to output. This is used as a loop counter for the carriage return output loop.

[LOOP START] - Newline output loop. Outputs B carriage returns to printer.

624A
LD A,0DH 3E 0D
Load A with 0DH, the ASCII code for carriage return (newline character for the printer).
624C
Call the character output routine at 62C8H. This outputs the carriage return character A to the printer with appropriate handling.
624F
Decrement B and jump to 624AH if B is not zero. This loops to output multiple newlines when B > 1.

[LOOP END] - All newlines output.

6251
RET C9
Return to caller. The string has been displayed and B newlines have been output to the printer.

6252H - Flush Printer and Display Compressed String

This routine flushes the printer buffer before displaying a compressed string. It's an entry point that ensures printer synchronization before string output.

6252
Call the flush printer buffer routine to ensure any pending output is sent before displaying new content.

6255H - Display Compressed String

This is the main compressed string display routine. SUPERZAP uses a sophisticated string compression system where common words are stored in tables at 696BH (short words) and 6A23H (longer words). Strings contain special control codes (60H and above) that index into these word tables. The high bit of each character in the tables marks the end of a word. On entry: HL points to the compressed string. Register C tracks state: bit 0 indicates if a space should precede the next word.

6255
PUSH BC C5
Save BC onto the stack to preserve the caller's values. BC will be used internally by this routine.
6256
LD C,00H 0E 00
Initialize Register C to 0. Bit 0 of C is the space flag: when set, a space will be output before the next word to separate it from the previous word.
6258
Jump to 6264H to begin fetching characters from the string. This skips the terminator check on first entry.

[LOOP START] - Main character processing loop. Each character is checked for control codes or terminators.

625A
CP 03H FE 03
Compare A (the current character) with 03H, the ETX (End of Text) control code. This marks the end of the string.
625C
If A is not 03H (not end of string), jump to 6260H to continue processing this character.
625E
POP BC C1
Restore BC from the stack. The string display is complete.
625F
RET C9
Return to caller. The entire compressed string has been output.
6260
Call the character output filter at 629FH. This outputs the character in A (unless it's 08H, the backspace control that resets the space flag).
6263
INC HL 23
Advance HL to point to the next character in the string.
6264
LD A,(HL) 7E
Load A with the current character from the string at (HL).
6265
CP 60H FE 60
Compare A with 60H (96 decimal). Characters 60H and above are compressed word tokens that index into word tables.
6267
If A < 60H (a literal character or control code), jump back to 625AH to output it directly.

Character is 60H or above - it's a compressed word token. Decode and output the word from the table.

6269
SUB 5FH D6 5F
Subtract 5FH (95) from A. This converts the token to a 1-based word index. Token 60H becomes index 1, 61H becomes 2, etc.
626B
LD B,A 47
Copy the word index to B. B will count down as we scan through the word table to find the correct entry.
626C
PUSH HL E5
Save HL (the current string position) onto the stack. HL will be modified to point into the word tables.
626D
Load HL with 696BH, the address of the first word table. This table contains shorter, more common words.
6270
SUB 38H D6 38
Subtract 38H (56) from A. If the result is negative (carry set), the word is in the first table. Otherwise, it's in the second table.
6272
If carry is set (original index was < 57), jump to 6279H to search the first word table at 696BH.
6274
LD B,A 47
The index is for the second table. Update B with the adjusted index (original - 56).
6275
Load HL with 6A23H, the address of the second word table. This table contains longer words.
6278
INC B 04
Increment B to adjust for the table change. The DJNZ loop decrements before comparing, so we need to compensate.

[INNER LOOP START] - Scan through word table to find the entry at index B. Words end with high bit set.

6279
BIT 7,(HL) CB 7E
Test bit 7 of the byte at (HL). In compressed words, the high bit is set on the last character of each word.
627B
INC HL 23
Advance HL to the next byte in the word table.
627C
If bit 7 was 0 (not end of word), loop back to 6279H to continue scanning past this word.

Found end of a word. Check if this is the word we're looking for.

627E
LD A,(HL) 7E
Load A with the first byte of the next word (or 00H if end of table).
627F
OR A B7
Test if A is zero. A zero byte marks the end of the word table.
6280
If A is zero (end of table reached without finding word), jump to 629CH to restore HL and continue with the main string.
6282
Decrement B and jump to 6279H if B is not zero. Continue scanning until we've skipped B-1 words to reach our target.

[INNER LOOP END] - Found the target word. Now output it character by character.

6284
INC HL 23
Advance HL past the end marker of the previous word to the first character of our target word.
6285
CP 08H FE 08
Compare A (first char of word) with 08H, the backspace control code. This special code suppresses the inter-word space.
6287
If A is 08H (backspace), jump to 628FH to skip the space handling and begin outputting the word.
6289
DEC HL 2B
Back up HL by one so we can re-read this character after potentially outputting a space.
628A
BIT 0,C CB 41
Test bit 0 of C, the space flag. If set, a space should be output before this word.
628C
If the space flag is set (NZ), call 62C6H to output a space character (20H) before the word.
628F
SET 0,C CB C1
Set bit 0 of C to enable the space flag. The next word will be preceded by a space (unless overridden by 08H).

[WORD OUTPUT LOOP] - Output each character of the word until high bit is set.

6291
LD A,(HL) 7E
Load A with the current character of the word from the table at (HL).
6292
AND 7FHAND 01111111 E6 7F
Mask off bit 7 to get the actual ASCII character. The high bit is used only as an end-of-word marker.
6294
Call the character output filter to output this character (A) to the display/printer.
6297
BIT 7,(HL) CB 7E
Test bit 7 of the original byte at (HL). If set, this was the last character of the word.
6299
INC HL 23
Advance HL to the next character in the word table.
629A
If bit 7 was 0 (not end of word), loop back to 6291H to output the next character.

[WORD OUTPUT LOOP END] - Word complete. Restore string position and continue.

629C
POP HL E1
Restore HL to point to the current position in the original string (where the token was).
629D
Jump back to 6263H to advance HL and continue processing the next character in the string.

629FH - Character Output Filter

This routine filters character output. If the character is 08H (backspace control code), it resets the space flag in C and returns without output. Otherwise, it outputs the character via the main character output routine at 62C8H. On entry: A = character to output, C = flags (bit 0 = space flag). On exit: Character output to display/printer (unless A was 08H).

629F
CP 08H FE 08
Compare A with 08H, the backspace/suppress-space control code. This code prevents a space from being output before the next word.
62A1
If A is not 08H (a normal printable character), jump to 62C8H to output the character.
62A4
RES 0,C CB 81
Reset bit 0 of C, clearing the space flag. The next word will not be preceded by a space.
62A6
RET C9
Return without outputting anything. The 08H code is consumed silently.

62A7H - Clear Command Line Area

This routine clears the command line area on the screen by first outputting a "home to command line" code (1CH) followed by a "clear to end of line" code (1FH). Used to prepare the screen for new prompts or messages.

62A7
Call 62B6H to output 1CH, which moves the cursor to the command line home position at the bottom of the screen.
62AA
LD A,1FH 3E 1F
Load A with 1FH, the control code for clear to end of line. This erases all characters from cursor to the right edge.
62AC
Jump to 62C8H to output the clear control code. Execution continues there.

62AEH - Output "Turn On Expanded Print" Control

Outputs control code 0EH to enable expanded (double-width) printing on compatible printers.

62AE
LD A,0EH 3E 0E
Load A with 0EH, the printer control code for expanded print on (double-width characters).
62B0
Jump to 62C8H to output the control code to the printer.

62B2H - Output "Turn Off Expanded Print" Control

Outputs control code 0FH to disable expanded (double-width) printing on compatible printers.

62B2
LD A,0FH 3E 0F
Load A with 0FH, the printer control code for expanded print off (return to normal width).
62B4
Jump to 62C8H to output the control code to the printer.

62B6H - Output "Home to Command Line" Control

Outputs control code 1CH to position the cursor at the command line area (bottom of screen).

62B6
LD A,1CH 3E 1C
Load A with 1CH, the control code for home cursor to command line. On the TRS-80, this positions the cursor at the start of the command input area.
62B8
Jump to 62C8H to output the control code.

62BAH - Output Buffer Contents (B bytes from HL)

Outputs B bytes from the buffer at (HL) to the character output routine. On entry: HL = buffer address, B = byte count. On exit: HL points past the last byte output, B = 0.

[LOOP START] - Output B bytes from buffer at (HL).

62BA
LD A,(HL) 7E
Load A with the current byte from the buffer at (HL).
62BB
INC HL 23
Advance HL to point to the next byte in the buffer.
62BC
Call the character output routine to output the byte in A.
62BF
Decrement B and jump back to 62BAH if B is not zero. Continue until all bytes are output.

[LOOP END]

62C1
RET C9
Return to caller. All B bytes have been output.

62C2H - Output Single Character from (HL) and Advance

Outputs one character from (HL) and advances HL. Used for inline string output where HL tracks position.

62C2
LD A,(HL) 7E
Load A with the character at (HL).
62C3
INC HL 23
Advance HL to the next position.
62C4
Jump to 62C8H to output the character in A.

62C6H - Output Space Character

Outputs a space character (20H). Called by the compressed string routine to insert spaces between words.

62C6
LD A,20H 3E 20
Load A with 20H, the ASCII code for space.

62C8H - Main Character Output Routine

This is the central character output routine for SUPERZAP. It handles both screen and printer output, managing column tracking, line wrapping, and special control codes. The routine uses several workspace variables: 5483H (current column position), 5484H (line width), 5480H (output mode flags where bit 6 = printer output enabled), 5481H (lines per page), 5482H (current line count). On entry: A = character to output. All registers are preserved.

62C8
PUSH HL E5
Save HL onto the stack. All registers will be preserved through this routine.
62C9
PUSH DE D5
Save DE onto the stack.
62CA
PUSH BC C5
Save BC onto the stack.
62CB
PUSH AF F5
Save AF onto the stack. A contains the character to output.
62CC
LD HL,5483H 21 83 54
Load HL with 5483H, the address of the current column position variable. This tracks horizontal position for line wrapping.
62CF
CP 0EH FE 0E
Compare A with 0EH. Characters 0EH and above get special handling for screen/printer output.
62D1
If A >= 0EH (printable or high control), jump to 62D7H to output via the display/printer routine.
62D3
CP 0AH FE 0A
Compare A with 0AH (line feed). Characters 0AH-0DH are line control codes.
62D5
If A >= 0AH (line feed, vertical tab, form feed, or carriage return), jump to 62FDH to handle line ending.

Character is 00H-09H (low control code). Output directly then handle column tracking.

62D7
Call the device output routine at 63E8H. This outputs character A to the screen and/or printer depending on mode flags.
62DA
CP 20H FE 20
Compare A with 20H (space). Characters 20H and above are printable and advance the column.
62DC
If A >= 20H (printable character), jump to 62FAH to decrement the column counter.

Character is a control code (00H-1FH). Handle special cases.

62DE
CP 08H FE 08
Compare A with 08H (backspace). Backspace moves the column position left.
62E0
If A is not 08H (not backspace), jump to 62EEH to check for other control codes.

Handle backspace (08H) - move column position left if possible.

62E2
LD A,(5484H) 3A 84 54
Load A with the line width from 5484H. This is the maximum column number (e.g., 64 or 80).
62E5
DEC A 3D
Decrement A to get max column - 1. Column positions are counted down from line width.
62E6
CP (HL) BE
Compare A (max column - 1) with the current column position at (HL=5483H). Check if we're at start of line.
62E7
INC (HL) 34
Increment the column counter at (HL). Moving left means increasing the "remaining columns" count.
62E8
If no carry (column was not at leftmost position), jump to 6322H to exit. Backspace handled successfully.
62EA
LD (HL),01H 36 01
We're at the start of the line. Set column to 1 (can't go further left). This prevents wrapping backwards.
62EC
Jump to 6322H to exit.

Check for cursor positioning codes (1CH-38H range).

62EE
SUB 1CH D6 1C
Subtract 1CH from A. Codes 1CH-38H are cursor positioning controls that reset column position.
62F0
CP 1DH FE 1D
Compare result with 1DH (29 decimal). Check if original code was in the 1CH-38H range.
62F2
If A >= 1DH (original code was 39H or above, not a positioning code), jump to 6322H to exit without column change.
62F4
LD A,(5484H) 3A 84 54
Load A with the line width from 5484H. Cursor positioning resets to the start of a line.
62F7
LD (HL),A 77
Store the line width as the new column position at (HL=5483H). This resets position to start of line.
62F8
Jump to 6322H to exit.

Handle printable characters (20H and above) - decrement column counter.

62FA
DEC (HL) 35
Decrement the column counter at (HL=5483H). Each printed character uses one column.
62FB
If column counter is not zero (still room on line), jump to 6322H to exit.

Column counter reached zero - end of line. Handle auto line wrap.

62FD
LD A,(5484H) 3A 84 54
Load A with the line width from 5484H.
6300
CP (HL) BE
Compare line width with current column at (HL). If equal, we're at the start of a line.
6301
LD A,20H 3E 20
Load A with 20H (space character). This may be output to fill the line.
6303
If Z flag is set (column equals line width, meaning we're at line start), call 63E8H to output a space. This handles empty line case.
6306
LD A,0DH 3E 0D
Load A with 0DH (carriage return). This ends the current line.
6308
Call 63E8H to output the carriage return to screen/printer.
630B
Call 63B5H to handle end of line processing. This resets the column counter and handles page breaks for printer.

Check if printer is ready for next line (paper out check).

This is bizarre to me. It makes sense as written that these functions would do this, but 3840H is the keyboard, not the printer. These checks would be BREAK and ENTER, in that order, on 3840H.

630E
LD A,(3840H) 3A 40 38
Load A with the printer status byte from 3840H (TRS-80 printer port status).
6311
AND 04HAND 00000100 E6 04
Mask with 04H to isolate bit 2, the printer "paper out" or "not ready" indicator.
6313
If bit 2 is clear (printer ready), jump to 6322H to exit normally.

Printer not ready. Wait for user intervention then continue.

6315
LD BC,0000H 01 00 00
Load BC with 0000H. This is a delay time frame parameter for the ROM wait routine at 0060H.
6318
CALL 0060H CD 60 00
Call ROM routine at 0060H. This is a system wait or delay routine.

[LOOP START] - Wait for printer ready.

631B
LD A,(3840H) 3A 40 38
Load A with the printer status from 3840H again.
631E
AND 01HAND 00000001 E6 01
Mask with 01H to isolate bit 0, another printer status bit (busy/ready).
6320
If bit 0 is clear (printer still busy/not ready), loop back to 631BH to keep waiting.

[LOOP END] - Printer ready. Exit the routine.

6322
POP AF F1
Restore AF from the stack. A contains the original character.
6323
POP BC C1
Restore BC from the stack.
6324
POP DE D1
Restore DE from the stack.
6325
POP HL E1
Restore HL from the stack.
6326
RET C9
Return to caller with all registers preserved.

6327H - Output Padding Spaces

This routine outputs padding spaces to align output. It calculates how many spaces are needed based on the difference between line width and current position, then outputs that many spaces. On entry: B = alignment parameter. On exit: Spaces output to current position, or returns immediately if already past alignment point.

6327
LD A,(5484H) 3A 84 54
Load A with the line width from 5484H (e.g., 64 or 80 columns).
632A
SUB B 90
Subtract B (the alignment parameter) from the line width. A now contains the target column.
632B
LD B,A 47
Copy the target column to B.
632C
LD A,(5483H) 3A 83 54
Load A with the current column position from 5483H.
632F
SUB B 90
Subtract target column from current position. A = number of spaces needed to reach target.
6330
RET C D8
If carry is set (current position is past target), return immediately. No padding needed.
6331
RET Z C8
If Z flag is set (current position equals target), return. Already at the right position.
6332
LD B,A 47
Copy the space count to B for the loop counter.

[LOOP START] - Output B spaces.

6333
Call 62C6H to output a space character (20H).
6336
Decrement B and loop back to 6333H if not zero. Continue until all padding spaces are output.

[LOOP END]

6338
RET C9
Return to caller. Output is now aligned to the target column.

6339H - Display Prompt and Get Filename

This routine displays a prompt string at (HL), then collects filename input from the user into the buffer at 5440H. The input is limited by the value in B (maximum characters). On entry: HL = prompt string address, B = maximum input length. On exit: HL = 5440H (input buffer address).

6339
LD DE,5440H 11 40 54
Load DE with 5440H, the address of the input buffer where the filename will be stored.
633C
PUSH BC C5
Save BC onto the stack. B contains the maximum input length (usually 8 for filename, 3 for extension).
633D
PUSH DE D5
Save DE (the buffer address 5440H) onto the stack.
633E
Call the display compressed string routine to show the prompt at (HL) to the user.
6341
POP HL E1
Pop the buffer address into HL. Now HL = 5440H (the input buffer).
6342
POP BC C1
Restore BC. B = maximum input length.
6343
Jump to 6356H to begin collecting keyboard input into the buffer.

6345H - Display String and Wait for Keypress

This routine displays the string at (HL), then waits for the user to press ENTER. It loops until ENTER is pressed. Used for "Press ENTER to continue" prompts.

6345
Call the display compressed string routine to show the message at (HL).

[LOOP START] - Wait for user to press ENTER.

6348
Call 6351H to get keyboard input. Returns with Z flag set if ENTER was pressed.
634B
If Z flag is not set (user pressed something other than ENTER), loop back to 6348H to keep waiting.

[LOOP END] - User pressed ENTER.

634D
RET C9
Return to caller. User has acknowledged by pressing ENTER.

634EH - Display Prompt and Collect Input

This routine displays a prompt string at (HL), then collects keyboard input into the buffer at 5440H. Maximum input length is 64 characters (40H). On entry: HL = prompt string address. On exit: A = first character of input, Z flag set if first char is ENTER (0DH), HL = 5440H.

634E
Call the display compressed string routine to show the prompt at (HL).
6351
LD HL,5440H 21 40 54
Load HL with 5440H, the address of the input buffer.
6354
LD B,40H 06 40
Load B with 40H (64 decimal), the maximum input length.
6356
CALL 0040H CD 40 00
Call ROM routine at 0040H. This is the TRS-80 ROM line input routine that collects characters from the keyboard into the buffer at (HL), maximum B characters.
6359
PUSH HL E5
Save HL (the input buffer address) onto the stack.
635A
PUSH BC C5
Save BC onto the stack.
635B
INC B 04
Increment B. The loop will process B+1 characters (the input plus any remaining buffer positions).

[LOOP START] - Convert all characters in buffer to uppercase.

635C
LD A,(HL) 7E
Load A with the current character from the input buffer at (HL).
635D
Call the lowercase to uppercase conversion routine at 6210H. If A is a lowercase letter (61H-7AH), it's converted to uppercase.
6360
LD (HL),A 77
Store the converted character back to the buffer at (HL).
6361
INC HL 23
Advance HL to the next buffer position.
6362
Decrement B and loop back to 635CH if not zero. Process all characters in the buffer.

[LOOP END] - All characters converted to uppercase.

6364
POP BC C1
Restore BC from the stack.
6365
POP HL E1
Restore HL to point to the start of the input buffer (5440H).
6366
LD A,(HL) 7E
Load A with the first character of the input.
6367
CP 0DH FE 0D
Compare A with 0DH (ENTER). Sets Z flag if the user just pressed ENTER without typing anything.
6369
RET C9
Return to caller. A = first character, Z flag set if input was empty (just ENTER), HL = buffer address.

636AH - Disable Printer Output Mode

This routine flushes the printer buffer, then clears the output mode flags at 5480H to disable printer output. Printer output is controlled by bit 6 of 5480H.

636A
PUSH AF F5
Save AF onto the stack to preserve the caller's registers.
636B
Call the flush printer buffer routine to output any pending data.
636E
XOR A AF
Set A to 0 by XORing it with itself.
636F
LD (5480H),A 32 80 54
Store 0 to 5480H, clearing all output mode flags. This disables printer output (bit 6).
6372
POP AF F1
Restore AF from the stack.
6373
RET C9
Return to caller. Printer output is now disabled.

6374H - Flush Printer Buffer

This routine flushes any pending output and prepares for new output. It sets the output device to printer mode (22H stored at self-modifying location 63ECH) and initializes column position. If the current column is not at line start, a newline is output first.

6374
PUSH AF F5
Save AF onto the stack.
6375
LD A,22H 3E 22
Load A with 22H, the code for printer output mode. This value will be stored in the self-modifying location at 63ECH.
6377
Jump to 637CH to continue the initialization.

6379H - Output Carriage Return to Printer

This routine initializes for screen output mode (00H) and ensures the cursor is at the start of a line.

6379
PUSH AF F5
Save AF onto the stack.
637A
LD A,00H 3E 00
Load A with 00H, the code for screen-only output mode.
637C
PUSH AF F5
Save the output mode code (22H or 00H) onto the stack.
637D
PUSH HL E5
Save HL onto the stack.
637E
LD HL,5483H 21 83 54
Load HL with 5483H, the address of the current column position variable.
6381
LD A,(5484H) 3A 84 54
Load A with the line width from 5484H.
6384
CP (HL) BE
Compare line width with current column. If equal, cursor is at start of line.
6385
If NZ (not at start of line), call 6248H to output a newline. This ensures output starts on a fresh line.
6388
POP HL E1
Restore HL from the stack.
6389
POP AF F1
Pop the output mode code into A.
638A
CP 22H FE 22
Compare A with 22H. Sets Z flag if this is printer mode initialization.
638C
LD (63ECH),A 32 EC 63
Store the output mode code to 63ECH. This is a self-modifying location checked by the output routine to determine where to send characters.
638F
LD A,(5485H) 3A 85 54
Load A with the printer line width from 5485H.
6392
If Z flag is set (printer mode), jump to 6397H to use the printer line width.
6394
LD A,(5486H) 3A 86 54
Load A with the screen line width from 5486H. Used when not in printer mode.
6397
LD (5484H),A 32 84 54
Store the line width to 5484H, the active line width variable.
639A
LD (5483H),A 32 83 54
Store the same value to 5483H, resetting the column position to start of line.
639D
POP AF F1
Restore AF from the stack.
639E
RET C9
Return to caller. Output mode and column position are initialized.

639FH - Enable Printer Output Mode

This routine enables printer output by setting bit 6 of the output mode flags at 5480H. When bit 6 is set, characters are sent to both screen and printer.

639F
LD A,(5480H) 3A 80 54
Load A with the current output mode flags from 5480H.
63A2
SET 6,A CB F7
Set bit 6 of A, the printer output enable flag. When set, output goes to the printer.
63A4
LD (5480H),A 32 80 54
Store the updated flags back to 5480H. Printer output is now enabled.
63A7
RET C9
Return to caller.

63A8H - Disable Printer Output Mode

This routine disables printer output by clearing bit 6 of the output mode flags at 5480H. Output will go to screen only.

63A8
LD A,(5480H) 3A 80 54
Load A with the current output mode flags from 5480H.
63AB
RES 6,A CB B7
Reset bit 6 of A, clearing the printer output enable flag.
63AD
Jump to 63A4H to store the updated flags and return. Printer output is now disabled.

63AFH - Check if Line Counter at Page Boundary

This routine checks if the current line counter (at 5482H) equals 60 (3CH), which indicates a page boundary for printer pagination. On exit: Z flag set if at page boundary (line counter = 3CH).

63AF
LD A,(5482H) 3A 82 54
Load A with the current line counter from 5482H. This tracks lines printed on the current page.
63B2
CP 3CH FE 3C
Compare A with 3CH (60 decimal), the lines per page value. Sets Z flag if at page boundary.
63B4
RET C9
Return to caller. Z flag indicates if we're at a page boundary.

63B5H - Handle End of Line for Printer

This routine handles end-of-line processing for the printer. It checks the output mode, manages page breaks (outputting extra carriage returns at page boundaries), and resets the column position. The self-modifying location at 63ECH determines the current output mode (22H = printer, 00H = screen).

63B5
LD A,(63ECH) 3A EC 63
Load A with the output mode code from 63ECH. This is a self-modifying location set by the initialization routines.
63B8
CP 22H FE 22
Compare A with 22H (printer mode indicator). Z flag set if in printer mode.
63BA
If Z flag is set (printer mode), jump to 63D6H to just reset column position. Printer pagination is handled differently.

Screen mode - check for page boundary and handle form feed.

63BC
LD A,(5482H) 3A 82 54
Load A with the current line counter from 5482H.
63BF
DEC A 3D
Decrement A. Check if we've reached the last line of the page.
63C0
If A is not zero (not at page boundary), jump to 63D3H to update line counter and continue.

At page boundary (line 1). Check if lines-per-page is configured.

63C2
LD A,(5481H) 3A 81 54
Load A with the lines per page setting from 5481H. If 0, page breaks are disabled.
63C5
OR A B7
Test if A is zero. Sets Z flag if lines-per-page is 0 (pagination disabled).
63C6
If Z flag is set (pagination disabled), jump to 63D1H to reset line counter to 60 and continue.

Pagination enabled - output 6 carriage returns for page break.

63C8
LD B,06H 06 06
Load B with 6, the number of carriage returns to output for a page break.

[LOOP START] - Output B carriage returns.

63CA
LD A,0DH 3E 0D
Load A with 0DH, the carriage return character.
63CC
Call the device output routine to send the carriage return.
63CF
Decrement B and loop back to 63CCH if not zero. Output 6 blank lines total.

[LOOP END] - Page break complete.

63D1
LD A,3CH 3E 3C
Load A with 3CH (60 decimal), resetting the line counter to the lines per page value.
63D3
LD (5482H),A 32 82 54
Store A to the line counter at 5482H. This decrements with each line or resets at page boundary.
63D6
LD A,(5484H) 3A 84 54
Load A with the line width from 5484H.
63D9
LD (5483H),A 32 83 54
Store the line width to the column position at 5483H, resetting cursor to start of new line.
63DC
RET C9
Return to caller. Line/page handling complete.

63DDH - Output Multiple Newlines Until Page Boundary

This routine outputs newlines until the line counter reaches a page boundary (60 lines). Register C specifies the maximum number of newlines to output. Used to advance to a new page or create vertical spacing. On entry: C = maximum newline count.

[LOOP START] - Output newlines until page boundary or C reaches zero.

63DD
Call 63AFH to check if we're at a page boundary (line counter = 60). Returns Z flag set if at boundary.
63E0
RET Z C8
If Z flag is set (at page boundary), return immediately. No more newlines needed.
63E1
Call 6248H to output a single newline (carriage return).
63E4
DEC C 0D
Decrement C, the remaining newline count.
63E5
If C is not zero (more newlines allowed), loop back to 63DDH to check boundary and output another newline.

[LOOP END] - Maximum count reached or page boundary found.

63E7
RET C9
Return to caller. Either C newlines output or page boundary reached.

63E8H - Device Output Dispatcher

This routine outputs a character to the current output device(s). It uses a clever self-modifying dispatch mechanism to handle the return path. The routine at 6427H captures the return address and patches it into jump targets at 6434H and 6442H, allowing different return paths depending on how the output completes. On entry: A = character to output.

63E8
Call the output setup routine at 6427H. This saves the return address and patches it into the self-modifying jump targets. After setup, it jumps to a DOS output routine at 0000H (patched).
63EB
After returning from the DOS call, jump to 640FH to handle printer output. This is the "continue to printer" path.

63EDH - Screen Output with Character Filtering

This routine outputs a character to the screen with filtering for non-printable characters. Characters above a configurable threshold (stored at 4370H) are replaced with a period (2EH). Control characters are handled specially. On entry: A = character to output.

63ED
PUSH AF F5
Save AF onto the stack. A contains the character to output.
63EE
LD HL,4370H 21 70 43
Load HL with 4370H, the address of the character filter threshold. Characters above this value are replaced.
63F1
CP (HL) BE
Compare A with the filter threshold at (4370H). If A > threshold, the character is non-printable.
63F2
If carry set (A < threshold), jump to 63F8H. Character is within printable range.
63F4
If Z flag set (A = threshold), jump to 63F8H. Character equals the limit, still printable.
63F6
LD A,2EH 3E 2E
Character exceeds threshold. Replace with 2EH (period/dot). This makes unprintable graphics characters visible as dots.
63F8
CP 20H FE 20
Compare A with 20H (space). Check if character is a printable ASCII character.
63FA
If A >= 20H (printable character), jump to 6404H to output via ROM.

Character is a control code (00H-1FH). Check if it should be displayed.

63FC
CP 0EH FE 0E
Compare A with 0EH. Codes 0EH-1FH are displayable control characters.
63FE
If A >= 0EH, jump to 6407H to skip screen output. These are printer-only control codes.
6400
CP 0AH FE 0A
Compare A with 0AH (line feed). Codes 0AH-0DH are line control characters.
6402
If A < 0AH (codes 00H-09H), jump to 6407H to skip screen output. These low controls don't display.
6404
CALL 003BH CD 3B 00
Call ROM routine at 003BH. This is the TRS-80 ROM display character routine that outputs A to the screen.
6407
POP AF F1
Restore AF. A contains the original character (unfiltered) for printer output.
6408
LD HL,5480H 21 80 54
Load HL with 5480H, the address of the output mode flags.
640B
BIT 6,(HL) CB 76
Test bit 6 of the flags, the printer enable flag.
640D
If bit 6 is clear (printer disabled), jump to 6444H to exit without printer output.

Printer output is enabled. Continue to send character to printer.

640F
CP 0DH FE 0D
Compare A with 0DH (carriage return). CR needs special handling for printer.
6411
If not carriage return, jump to 6422H to output the character directly to printer.

Handle carriage return - check if line has content before sending CR.

6413
LD HL,5483H 21 83 54
Load HL with 5483H, the address of the column position counter.
6416
LD A,(5484H) 3A 84 54
Load A with the line width from 5484H.
6419
SUB (HL) 96
Subtract current column from line width. A = number of characters printed on this line.
641A
If Z (line is empty, no chars printed), jump to 6420H to still output CR.
641C
AND 3FHAND 00111111 E6 3F
Mask with 3FH (63). Check lower 6 bits for position within 64-character boundary.
641E
If result is zero (on 64-character boundary), jump to 6444H to skip CR. Printer auto-wraps at boundaries.
6420
LD A,0DH 3E 0D
Load A with 0DH, the carriage return character.
6422
CALL 0033H CD 33 00
Call ROM routine at 0033H. This is the TRS-80 ROM printer output routine that sends A to the printer.
6425
Jump to 6444H to restore registers and return.

6427H - Output Setup with Self-Modifying Return Path

This routine implements a sophisticated dispatch mechanism using self-modifying code. It captures the return address from the stack and patches it into two jump targets (6434H and 6442H), allowing the output routines to return to different points depending on the execution path. This technique avoids multiple returns and simplifies control flow.

6427
EX (SP),HL E3
Exchange HL with top of stack. HL now contains the return address (63EBH when called from 63E8H), and the original HL is on the stack.
6428
LD (6434H),HL 22 34 64
Store the return address to 6434H. This is a self-modifying location - the JP at 6433H will jump to this address.
642B
POP HL E1
Pop the original HL value back from the stack.
642C
PUSH HL E5
Push HL back onto the stack for later restoration.
642D
PUSH DE D5
Save DE onto the stack.
642E
PUSH BC C5
Save BC onto the stack.
642F
PUSH IX DD E5
Save IX onto the stack.
6431
PUSH IY FD E5
Save IY onto the stack. All index registers preserved for the DOS call.
6433
JP 0000H C3 00 00
Jump to address stored at 6434H-6435H. This is self-modifying - the actual address was patched by the LD at 6428H. Jumps back to 63EBH (after the CALL).

6436H - Alternate Return Path Setup

This routine provides an alternate entry for setting up return path. It patches the address into 6442H instead of 6434H, creating a different return destination.

6436
PUSH HL E5
Push HL onto the stack temporarily.
6437
LD (6442H),HL 22 42 64
Store HL to 6442H, the second self-modifying location. The JP at 6441H will jump to this address.
643A
POP IY FD E1
Pop the value into IY (restoring from stack).
643C
POP IX DD E1
Pop IX from the stack.
643E
POP BC C1
Pop BC from the stack.
643F
POP DE D1
Pop DE from the stack.
6440
POP HL E1
Pop HL from the stack.
6441
JP 0000H C3 00 00
Jump to address stored at 6442H-6443H. This is self-modifying - the actual address was patched earlier.

6444H - Common Exit - Restore Registers and Return

This is the common exit point for the output routines. It restores all saved registers (IY, IX, BC, DE, HL) and returns to the caller.

6444
POP IY FD E1
Restore IY from the stack.
6446
POP IX DD E1
Restore IX from the stack.
6448
POP BC C1
Restore BC from the stack.
6449
POP DE D1
Restore DE from the stack.
644A
POP HL E1
Restore HL from the stack.
644B
RET C9
Return to caller. All registers have been restored to their entry values.

644CH - Read File with Raw Mode Flag Set

This routine sets the raw/track mode flag (bit 6 of 5493H), calls the main file read routine at 6457H, then clears the flag. This wraps the file read operation with raw mode enabled for track-level access.

644C
LD HL,5493H 21 93 54
Load HL with 5493H, the address of the secondary mode flags.
644F
SET 6,(HL) CB F6
Set bit 6 of the flags at (HL), enabling raw/track mode for the file operation.
6451
Call the main file read routine at 6457H. This performs the actual file/sector read operation.
6454
RES 6,(HL) CB B6
Reset bit 6 of the flags at (HL), clearing raw/track mode. HL still points to 5493H.
6456
RET C9
Return to caller with raw mode flag cleared.

6457H - Main File Read Setup

This routine prepares for and executes a DOS file operation. It sets up the FCB flags, calls the DOS @FSPEC routine at 4436H, and handles any errors. On entry: None (uses FCB at 5400H). On exit: Carry set on error, Z flag set if operation succeeded without error code.

6457
XOR A AF
Set A to 0 by XORing with itself. This will be the read operation flag.
6458
Call the FCB setup routine at 6497H. This initializes FCB fields and sets up the self-modifying return path.
645B
CALL 4436H CD 36 44
Call NEWDOS/80 @FSPEC routine at 4436H. This is the file specification/directory search DOS call.
645E
Call the error check routine at 64BCH. This examines the DOS return status and handles any errors.
6461
If carry set (error occurred), jump to 64B3H to store the sector info and exit via self-modifying jump.
6463
If NZ (non-zero error code but not critical), jump to 6471H to exit with registers restored.

Operation succeeded. Determine the operation type indicator character.

6465
CP 06H FE 06
Compare A with 06H. Check if this was a specific file operation type.
6467
LD A,50H 3E 50
Load A with 50H, ASCII for P. This indicates "Protected" or "Password" file mode.
6469
If Z (operation type was 06H), jump to 646DH to store 'P' as the type indicator.
646B
LD A,20H 3E 20
Load A with 20H, ASCII for space. This indicates normal file mode (no special status).
646D
LD (5494H),A 32 94 54
Store the operation type indicator at 5494H. This character ('P' or space) shows the file's status.
6470
CP A BF
Compare A with itself. This always sets the Z flag and clears carry, indicating success.
6471
POP DE D1
Restore DE from the stack (pushed by the setup routine at 6497H).
6472
POP HL E1
Restore HL from the stack.
6473
RET C9
Return to caller. Flags indicate success (Z, NC) or error type.

6474H - Write Sector to Disk

This routine writes a sector to disk. It sets up the FCB for a write operation (80H flag), checks the operation type, and calls the DOS write routine. On exit: Carry set on error.

6474
LD A,80H 3E 80
Load A with 80H, the write operation flag. Bit 7 set indicates a write rather than read.
6476
Call the FCB setup routine at 6497H. Sets up the FCB with the write flag.
6479
LD A,(5494H) 3A 94 54
Load A with the operation type indicator from 5494H. This was set during the read operation.
647C
CP 20H FE 20
Compare A with 20H (space). Check if this is a normal (unprotected) file.
647E
If Z (normal file), jump to 6489H to proceed with the write operation.
6480
CP 50H FE 50
Compare A with 50H ('P'). Check if file is password protected.
6482
If NZ (neither space nor 'P'), jump to 65AAH to display an error message. Invalid operation type.

Password-protected file. Set the protection bit before writing.

6485
EX DE,HL EB
Exchange DE and HL. HL now points to the FCB.
6486
SET 0,(HL) CB C6
Set bit 0 of the FCB byte at (HL). This sets the write-protect flag for the operation.
6488
EX DE,HL EB
Exchange DE and HL back to original positions.
6489
CALL 443CH CD 3C 44
Call NEWDOS/80 DOS routine at 443CH. This is the write sector DOS call.
648C
EX DE,HL EB
Exchange DE and HL. HL now points to FCB for flag cleanup.
648D
RES 0,(HL) CB 86
Reset bit 0 of the FCB byte. Clear the write-protect flag after operation.
648F
EX DE,HL EB
Exchange DE and HL back.
6490
Call the error check routine to examine the write operation result.
6493
If carry set (error), jump to 64B3H to handle the error and exit.
6495
Jump to 6471H to restore registers and return normally.

6497H - FCB Setup with Self-Modifying Return Path

This routine sets up the FCB (File Control Block) for a disk operation and configures the self-modifying return address. It captures the return address from the stack, patches it into 64BAH, and initializes FCB fields. On entry: A = operation flag (00H = read, 80H = write). On exit: FCB prepared, self-modifying jump target set.

6497
EX (SP),HL E3
Exchange HL with top of stack. HL now contains the return address, original HL is on stack.
6498
PUSH DE D5
Save DE onto the stack for later restoration.
6499
LD (64BAH),HL 22 BA 64
Store the return address to 64BAH, the self-modifying jump target. The JP at 64B9H will use this.
649C
LD E,A 5F
Copy the operation flag (00H read or 80H write) from A to E for safekeeping.
649D
LD HL,5491H 21 91 54
Load HL with 5491H, the address of the primary mode flags.
64A0
LD A,(HL) 7E
Load A with the current mode flags from 5491H.
64A1
AND 7FHAND 01111111 E6 7F
Mask off bit 7, clearing any previous error/status flag.
64A3
OR E B3
OR in the operation flag from E. This sets bit 7 for write operations (80H).
64A4
LD (HL),A 77
Store the updated flags back to 5491H.
64A5
LD HL,5401H 21 01 54
Load HL with 5401H, the address of FCB byte 1 (mode/attribute flags).
64A8
RES 7,(HL) CB BE
Reset bit 7 of FCB byte 1. Clear any previous special flag.
64AA
DEC HL 2B
Decrement HL to point to 5400H, the FCB base address (byte 0, drive spec).
64AB
EX DE,HL EB
Exchange DE and HL. DE now points to FCB base (5400H).
64AC
LD HL,(540AH) 2A 0A 54
Load HL with the sector number from FCB bytes 0AH-0BH.
64AF
XOR A AF
Set A to 0.
64B0
LD (5405H),A 32 05 54
Store 0 to 5405H, the byte offset field. Start at beginning of sector.
64B3
LD (540AH),HL 22 0A 54
Store HL back to the sector number field at 540AH (may be updated by caller).
64B6
LD (54A6H),HL 22 A6 54
Also store sector number to 54A6H, a secondary location for tracking.
64B9
JP 0000H C3 00 00
Jump to address at 64BAH-64BBH. This is self-modifying - the actual address was patched by the LD at 6499H.

64BCH - Check DOS Error Status

This routine checks the result of a DOS operation. It examines flags and the error code in A, returning appropriate status or jumping to error display. On entry: Flags from DOS call, A = error code. On exit: Z set if no error, Carry set for critical errors, NZ for warnings.

64BC
If NZ (error flag set from DOS), jump to 64C0H to examine the error code.
64BE
XOR A AF
Set A to 0. Clear any error code, sets Z flag.
64BF
RET C9
Return with Z set and Carry clear, indicating success.
64C0
If Z flag set (error code is 0), jump to 64C5H to display error message.
64C2
CP 06H FE 06
Compare error code with 06H. Code 06H is a special "not found" or "end of file" condition.
64C4
RET Z C8
If error code is 06H, return with Z set. This is not a critical error (e.g., EOF).

64C5H - Display DOS Error Message

This routine displays a DOS error message based on the error code. It saves registers, clears the command line, displays drive/sector status, looks up the error message in the error table at 6BEDH, and prompts for user response. On entry: A = DOS error code, flags from error check. On exit: May jump to retry, skip, or exit based on user input.

64C5
PUSH HL E5
Save HL onto the stack.
64C6
PUSH DE D5
Save DE onto the stack.
64C7
PUSH BC C5
Save BC onto the stack.
64C8
PUSH AF F5
Save AF onto the stack. A contains the DOS error code.
64C9
Call the clear command line routine to prepare the display area for the error message.
64CC
Call the display drive/sector status routine at 65D0H. Shows which drive and sector caused the error.
64CF
LD A,(5491H) 3A 91 54
Load A with the primary mode flags from 5491H.
64D2
BIT 7,A CB 7F
Test bit 7, the write operation flag. Was this a write or read operation?
64D4
If bit 7 is clear (read operation), jump to 64E7H to display read error message.

Write operation error. Select appropriate write error messages.

64D6
LD DE,6E30H 11 30 6E
Load DE with 6E30H, address of write error message suffix.
64D9
Load HL with 6D0EH, address of error message prefix ("WRITE" or similar).
64DC
POP AF F1
Pop AF to get the error code back into A.
64DD
CP 09H FE 09
Compare error code with 09H. Check for write-protect error.
64DF
PUSH AF F5
Push AF back onto the stack for later use.
64E0
If error code ≥ 09H, jump to 64F2H to display the error message.
64E2
LD DE,6E34H 11 34 6E
Load DE with 6E34H, address of alternate write error suffix (for codes < 09H).
64E5
Jump to 64F2H to display the error message.

Read operation error. Set up read error messages.

64E7
LD A,45H 3E 45
Load A with 45H, ASCII for E. This is the "Error" type indicator.
64E9
LD (5494H),A 32 94 54
Store 'E' to the operation type indicator at 5494H.
64EC
LD DE,6E2CH 11 2C 6E
Load DE with 6E2CH, address of read error message suffix.
64EF
Load HL with 6D0BH, address of read error message prefix.
64F2
Call the display compressed string routine. Display the error prefix message from (HL).
64F5
EX DE,HL EB
Exchange DE and HL. HL now points to the suffix message.
64F6
Call display string with newline. Display the error suffix message.

Now look up the specific error message in the error table at 6BEDH.

64F9
POP BC C1
Pop BC. B now contains the error code (was pushed as AF, so A went into high byte position).
64FA
Load HL with 6BEDH, the address of the error message table. Each entry has error code followed by message.

[LOOP START] - Search error table for matching error code.

64FD
LD A,(HL) 7E
Load A with the error code from the current table entry.
64FE
CP B B8
Compare table error code with B (the actual error code we're looking for).
64FF
INC HL 23
Advance HL past the error code byte to the message text.
6500
If Z (error codes match), jump to 652EH to display this error message.

No match. Skip past this error message to the next entry.

6502
LD A,(HL) 7E
Load A with the current byte of the message.
6503
OR A B7
Test if A is zero (end of message marker).
6504
If not zero (not end of message), loop back to 64FDH to check next byte.

Found end of message (00H). Check for end of table (03H).

6506
LD A,(HL) 7E
Load A with the byte after the zero terminator.
6507
CP 03H FE 03
Compare with 03H, the end of table marker.
6509
INC HL 23
Advance HL.
650A
If not end of table, loop to skip any padding and find next entry.
650C
LD A,(HL) 7E
Load the next byte.
650D
OR A B7
Test if zero (true end of table).
650E
If not zero, continue searching from 64FDH.

[LOOP END] - Error code not found in table. Display numeric code.

6510
LD A,(5491H) 3A 91 54
Load A with the mode flags from 5491H.
6513
AND 48HAND 01001000 E6 48
Mask with 48H. Check bits 6 and 3 (raw mode flags).
6515
If zero (normal mode), jump to 651FH to display generic error with code number.
6517
LD A,B 78
Load A with B (the error code).
6518
OR 0C0HOR 11000000 F6 C0
OR with C0H to set bits 7 and 6. This creates a DOS error display code.
651A
CALL 4409H CD 09 44
Call NEWDOS/80 routine at 4409H. This is a DOS error message display routine.
651D
Jump to 6536H to output newline and continue with user prompt.
651F
Load HL with 6E38H, address of "ERROR #" message prefix.
6522
Call display compressed string to show "ERROR #".
6525
LD E,B 58
Copy error code B to E for conversion.
6526
Call numeric conversion routine at 68A7H. Converts E to displayable format.
6529
Call buffer display routine to output the converted number.
652C
Jump to 6536H to continue with newline and prompt.

Found matching error code. Display the error message text.

652E
LD A,(HL) 7E
Load A with the current message byte.
652F
OR A B7
Test if zero (end of message).
6530
INC HL 23
Advance HL past this byte.
6531
If not zero, loop to skip to end of message (we need to find the compressed message after it).
6533
Call display compressed string. Display the error message starting at (HL).
6536
Call output newline routine. Move to next line after the error message.

Check mode flags to determine appropriate user prompt.

6539
LD A,(5492H) 3A 92 54
Load A with flags from 5492H (additional mode flags).
653C
OR A B7
Test if any flags are set.
653D
If NZ (flags set), jump to 6553H for special handling.
653F
LD A,(5493H) 3A 93 54
Load A with secondary mode flags from 5493H.
6542
BIT 6,A CB 77
Test bit 6, the raw/track mode flag.
6544
If raw mode is active, jump to 656FH to restore registers and return.
6546
BIT 1,A CB 4F
Test bit 1 of mode flags.
6548
If bit 1 set, jump to 6558H to display retry prompt.
654A
Load HL with 6D90H, address of "PRESS ANY KEY" message.
654D
Call display and wait for key routine. Show message and wait for any keypress.
6550
Jump to 56C1H, the main command loop entry point.
6553
AND 0E0HAND 11100000 E6 E0
Mask A with E0H to check upper 3 bits.
6555
If upper bits are zero, jump to 6582H for "press any key" handling.

Display retry prompt and get user response (R=retry, S=skip, X=exit).

6558
Load HL with 6E71H, address of "RETRY/SKIP/EXIT" prompt.
655B
Call display prompt and collect input. Show prompt and get user response.
655E
Decrement B and loop back to 6558H if not zero. Allow multiple attempts for valid input.
6560
CP 58H FE 58
Compare A with 58H, ASCII for X (exit).
6562
If user pressed X, jump to 65B4H to exit/abort the operation.
6565
CP 52H FE 52
Compare A with 52H, ASCII for R (retry).
6567
SCF 37
Set the Carry flag. This will be used as a retry indicator.
6568
If user pressed R, jump to 656FH to return with Carry set (retry).
656A
CP 53H FE 53
Compare A with 53H, ASCII for S (skip).
656C
If not S (invalid key), loop back to 6558H to re-prompt.
656E
OR A B7
Clear the Carry flag (user chose Skip). OR A with itself clears carry.
656F
POP BC C1
Restore BC from the stack.
6570
POP DE D1
Restore DE from the stack.
6571
POP HL E1
Restore HL from the stack.
6572
RET C9
Return to caller. Carry set = retry requested, Carry clear = skip/continue.

6573H - Display Error from DE

Entry point that exchanges DE and HL, then displays an error message. Used when the message address is in DE instead of HL.

6573
EX DE,HL EB
Exchange DE and HL. The message address moves from DE to HL.
6574
Jump to 657FH to display the message and wait for keypress.

6576H - Display Unknown Key Error

Entry point for handling unknown/invalid key presses. Displays DOS error code 01 (with C0H prefix) and waits for user acknowledgment.

6576
LD A,01H 3E 01
Load A with 01H, error code for "unknown key" or general input error.
6578
OR 0C0HOR 11000000 F6 C0
OR with C0H to set bits 7 and 6. This formats the code for DOS error display.
657A
CALL 4409H CD 09 44
Call NEWDOS/80 routine at 4409H to display the formatted error message.
657D
Jump to 6582H to flush printer and wait for keypress.

657FH - Display Message and Wait for Any Key

Displays a message from (HL) with printer flush, then waits for any keypress before returning to the main command loop.

657F
Call flush printer and display string with newline. Displays message at (HL).
6582
Call the flush printer buffer routine to ensure all output is sent.
6585
Load HL with 6D89H, address of "PRESS ANY KEY" continuation message.
6588
Call display and wait for keypress. Shows message and waits for user.
658B
Jump to 54C5H, the main command handler. Returns to command loop after error acknowledged.

658EH - Display "INVALID" Error

Entry point for displaying "INVALID" error message from 6E20H.

658E
Load HL with 6E20H, address of "INVALID" error message.
6591
Jump to 657FH to display message and wait for key.

6593H - Display "BEYOND" Error

Entry point for displaying "BEYOND" (out of range) error message from 6E26H.

6593
Load HL with 6E26H, address of "BEYOND" error message (sector beyond disk limit).
6596
Jump to 657FH to display message and wait for key.

6598H - Display Message and Return with Carry Set

Displays error message from 6E0AH, then returns with Carry flag set to indicate error to caller.

6598
Load HL with 6E0AH, address of an error message.
659B
Call display string with newline to show the message.
659E
SCF 37
Set the Carry flag to indicate an error condition to the caller.
659F
RET C9
Return with Carry set. Caller can check C flag for error status.

65A0H - Display Error Message from 6E0FH

Entry point for displaying error message from 6E0FH, returns with Carry set.

65A0
Load HL with 6E0FH, address of another error message.
65A3
Jump to 659BH to display message and return with Carry set.

65A5H - Display Error Message from 6E14H

Entry point for displaying error message from 6E14H, returns with Carry set.

65A5
Load HL with 6E14H, address of another error message.
65A8
Jump to 659BH to display message and return with Carry set.

65AAH - Display "ILLEGAL OPERATION" Error

Entry point for displaying "ILLEGAL OPERATION" (or similar) error from 6E3DH. Used when an invalid operation is attempted.

65AA
Load HL with 6E3DH, address of "ILLEGAL" operation error message.
65AD
Jump to 657FH to display message and wait for key.

65AFH - Display Error Message from 6E59H

Entry point for displaying error message from 6E59H.

65AF
Load HL with 6E59H, address of an error message.
65B2
Jump to 657FH to display message and wait for key.

65B4H - Display "ABORTED" Message

Entry point for displaying "ABORTED" message from 6E85H. Used when user chooses to exit/abort an operation.

65B4
Load HL with 6E85H, address of "ABORTED" message.
65B7
Jump to 657FH to display message and wait for key.

65B9H - Display Error Message from 6DE7H

Entry point for displaying error message from 6DE7H.

65B9
Load HL with 6DE7H, address of an error message.
65BC
Jump to 657FH to display message and wait for key.

65BEH - Display Error Message from 6EE9H

Entry point for displaying error message from 6EE9H.

65BE
Load HL with 6EE9H, address of an error message.
65C1
Jump to 657FH to display message and wait for key.

65C3H - Main Return to Command Loop

Entry point that outputs a newline, displays a message from 6C2DH, and returns to command loop.

65C3
Call output newline routine.
65C6
Load HL with 6C2DH, address of a completion/status message.
65C9
Jump to 657FH to display message and return to command loop.

65CBH - Add A to HL (HL = HL + A)

This utility routine adds the value in A to the 16-bit value in HL. Used for table indexing and address calculations. On entry: A = offset to add, HL = base address. On exit: HL = HL + A.

65CB
ADD A,L 85
Add L to A. A = A + L. If overflow, Carry is set.
65CC
LD L,A 6F
Store result back to L. L = A + original L.
65CD
RET NC D0
If no carry (no overflow), return. HL is now HL + original A.
65CE
INC H 24
Carry occurred, so increment H to propagate the carry to the high byte.
65CF
RET C9
Return with HL = original HL + original A.

65D0H - Display Drive and Sector Status

This routine displays the current drive number, sector number, track, and sector-within-track for error messages and status displays. It retrieves values from the FCB and mode flags, formats them, and outputs to the display. Uses label strings from 6E8DH (drive), 6E90H (track), 6E93H (sector), 6E96H (absolute sector), and 6E9BH.

65D0
LD A,(5406H) 3A 06 54
Load A with the current disk number from FCB byte 6 at 5406H. This is the drive number (0-3).
65D3
Load HL with 6E8DH, address of the "DRIVE" label string.
65D6
Call 660AH to display the drive label and number. A contains drive number, HL contains label.
65D9
Load HL with 6E9BH, address of another status label string.
65DC
LD DE,(54A6H) ED 5B A6 54
Load DE with the sector number from 54A6H. This was saved during the file operation setup.
65E0
LD A,(5491H) 3A 91 54
Load A with the primary mode flags from 5491H.
65E3
AND 48HAND 01001000 E6 48
Mask with 48H to check bits 6 and 3 (memory mode and raw mode flags).
65E5
If either flag is set (special mode), jump to 6604H to display only the sector number without track breakdown.

Normal disk mode - display sector as track + sector-within-track.

65E7
Load HL with 6E96H, address of the "SECTOR" (absolute) label string.
65EA
PUSH DE D5
Save DE (the sector number) onto the stack.
65EB
Call 660DH to display the label and value. DE contains value to display, HL contains label.
65EE
POP HL E1
Pop the sector number into HL for division.
65EF
LD A,(549BH) 3A 9B 54
Load A with sectors per track from 549BH. Used to calculate track and sector-within-track.
65F2
Call the division routine at 6896H. Divides HL by A. Returns quotient in DE (track), remainder in A (sector within track).
65F5
EX DE,HL EB
Exchange DE and HL. HL now contains the track number.
65F6
PUSH AF F5
Save AF (A contains sector within track).
65F7
Load HL with 6E90H, address of the "TRACK" label string.
65FA
Call 660DH to display track label and number. DE contains track number.
65FD
POP AF F1
Restore AF. A = sector within track.
65FE
LD E,A 5F
Copy sector-within-track to E.
65FF
LD D,00H 16 00
Set D to 0. DE now contains sector within track as a 16-bit value.
6601
Load HL with 6E93H, address of the "SEC" (sector within track) label string.
6604
Call 660DH to display the label and sector value.
6607
Jump to 6248H to output a newline and return. Status display complete.

660AH - Display Label with 8-bit Value

Entry point that expands an 8-bit value in A to 16-bit in DE, then displays it with a label. On entry: A = 8-bit value, HL = label string address.

660A
LD E,A 5F
Copy the 8-bit value from A to E.
660B
LD D,00H 16 00
Set D to 0. DE now contains the value as a 16-bit number.

660DH - Display Label with Numeric Value and Decimal Conversion

This routine displays a label string, converts a value to decimal, and outputs it with leading zero suppression. It also shows the value in hex format. On entry: DE = value to display, HL = label string address. Uses buffer at 5487H for conversion.

660D
PUSH DE D5
Save DE (the value to display) onto the stack.
660E
Call display compressed string to output the label from (HL).
6611
Call the numeric format conversion routine at 68AFH. Prepares the display buffer.
6614
Call buffer display routine to output the formatted numeric string.
6617
Load HL with 6EA0H, address of separator/suffix string (e.g., " = " or similar).
661A
Call display compressed string to output the separator.
661D
LD HL,5487H 21 87 54
Load HL with 5487H, the decimal conversion buffer address.
6620
LD B,04H 06 04
Load B with 4, the number of buffer bytes to initialize.

[LOOP START] - Clear the conversion buffer to zeros.

6622
PUSH HL E5
Save HL (buffer start) for later use.
6623
LD (HL),00H 36 00
Store 00H at current buffer position, clearing it.
6625
INC HL 23
Advance to next buffer position.
6626
Decrement B and loop if not zero. Clear all 4 buffer bytes.

[LOOP END] - Buffer cleared.

6628
POP HL E1
Restore HL to point to buffer start (5487H).
6629
POP DE D1
Restore DE, the value to convert.
662A
PUSH HL E5
Save buffer start address again.
662B
Call 6665H to convert DE to hex ASCII and store in buffer at (HL).
662E
POP HL E1
Restore HL to buffer start.
662F
LD B,04H 06 04
Load B with 4, maximum hex digits to display.

[LOOP START] - Output hex digits with leading zero handling.

6631
LD A,(HL) 7E
Load A with current hex digit character from buffer.
6632
CP 3AH FE 3A
Compare with 3AH (one past '9'). Check if this is a letter (A-F) vs digit (0-9).
6634
If digit is '0'-'9', jump to 663BH to check for leading zero.
6636
LD A,30H 3E 30
Character is A-F (hex letter). Load A with '0' to output a leading zero before hex letters.
6638
Call character output to display the leading '0'.
663B
LD A,(HL) 7E
Reload A with the hex digit character.
663C
OR A B7
Test if A is zero (empty/unused digit position).
663D
INC HL 23
Advance to next buffer position.
663E
If character is not zero, call character output to display it.
6641
Decrement B and loop back to 663BH if not zero. Process all 4 hex digits.

[LOOP END] - All hex digits output.

6643
Load HL with 6EA3H, address of "H" suffix string (hex indicator).
6646
Jump to display compressed string to output "H" suffix and return.

6649H - Convert Byte to Hex and Display

Converts a byte in A to two hex ASCII characters in the buffer at 5487H, then displays them. On entry: A = byte to convert. On exit: Two hex characters displayed.

6649
PUSH HL E5
Save HL onto the stack.
664A
PUSH BC C5
Save BC onto the stack.
664B
LD HL,5487H 21 87 54
Load HL with 5487H, the conversion buffer address.
664E
Call 6674H to convert byte A to two hex ASCII characters at (HL). HL advances by 2.
6651
DEC HL 2B
Decrement HL to point back to the second character.
6652
DEC HL 2B
Decrement HL again to point to the first character.
6653
LD B,02H 06 02
Load B with 2, the number of characters to display.
6655
Call buffer display to output the 2 hex characters.
6658
POP BC C1
Restore BC.
6659
POP HL E1
Restore HL.
665A
RET C9
Return to caller.

665BH - Convert DE to Hex and Display with Suffix

Converts the 16-bit value in DE to 4 hex ASCII characters and displays them, followed by the "H" suffix. On entry: DE = 16-bit value to display.

665B
LD A,D 7A
Load A with D, the high byte of the value.
665C
Call 6649H to convert and display the high byte as 2 hex digits.
665F
LD A,E 7B
Load A with E, the low byte of the value.
6660
Call 6649H to convert and display the low byte as 2 hex digits.
6663
Jump to 6643H to display the "H" suffix and return.

6665H - Convert DE to Hex ASCII at (HL)

Converts the 16-bit value in DE to hex ASCII characters stored at (HL). Handles leading zeros by only outputting significant digits. On entry: DE = value to convert, HL = buffer address. On exit: HL points past the stored characters.

6665
LD A,D 7A
Load A with D, the high byte of the value.
6666
OR A B7
Test if D is zero. If high byte is zero, skip it for leading zero suppression.
6667
If D is zero, jump to 666FH to process only the low byte.
6669
Call 6670H to convert the high byte with possible leading zero handling.
666C
LD A,E 7B
Load A with E, the low byte.
666D
Jump to 6674H to convert the low byte (always both nibbles since high byte was non-zero).
666F
LD A,E 7B
High byte was zero. Load A with E, the low byte only.
6670
CP 10H FE 10
Compare A with 10H (16). Check if value needs both nibbles or just one.
6672
If A < 10H (single digit), jump to 667DH to convert just the low nibble.

6674H - Convert Byte to Two Hex ASCII Characters

Converts a byte in A to two hex ASCII characters (high nibble first, then low nibble) and stores them at (HL), advancing HL by 2. On entry: A = byte to convert, HL = destination buffer. On exit: HL = HL + 2.

6674
PUSH AF F5
Save A (the byte to convert) onto the stack.
6675
RRCA 0F
Rotate A right. First of 4 rotations to move high nibble to low position.
6676
RRCA 0F
Rotate A right again.
6677
RRCA 0F
Rotate A right again.
6678
RRCA 0F
Rotate A right a fourth time. High nibble is now in bits 0-3.
6679
Call 667DH to convert the high nibble to ASCII and store at (HL).
667C
POP AF F1
Restore original A. Low nibble is in bits 0-3. Fall through to convert it.

667DH - Convert Nibble to Hex ASCII and Store

Converts the low nibble (bits 0-3) of A to a hex ASCII character ('0'-'9' or 'A'-'F') and stores it at (HL), then increments HL. On entry: A = value with nibble in bits 0-3, HL = destination. On exit: Character stored, HL incremented.

667D
AND 0FHAND 00001111 E6 0F
Mask A with 0FH to isolate the low nibble (bits 0-3). A is now 00H-0FH.
667F
CP 0AH FE 0A
Compare A with 0AH (10). Check if nibble is 0-9 or A-F.
6681
If A < 0AH (0-9), jump to 6685H to skip the letter adjustment.
6683
ADD A,07H C6 07
Add 7 to A. Adjusts for the gap between '9' (39H) and 'A' (41H) in ASCII.
6685
ADD A,30H C6 30
Add 30H ('0') to A. Converts nibble to ASCII hex character ('0'-'9' or 'A'-'F').
6687
LD (HL),A 77
Store the hex ASCII character at (HL).
6688
INC HL 23
Increment HL to point to the next buffer position.
6689
RET C9
Return to caller.

STILL TO COME

668A  7E                LD      A,(HL)          ~
668B  12                LD      (DE),A          .
668C  13                INC     DE              .
668D  23                INC     HL              #
668E  10FA              DJNZ    668AH           ..
6690  C9                RET                     .
6691  7C                LD      A,H             |
6692  BA                CP      D               .
6693  C0                RET     NZ              .
6694  7D                LD      A,L             }
6695  BB                CP      E               .
6696  C9                RET                     .
6697  7C                LD      A,H             |
6698  B8                CP      B               .
6699  C0                RET     NZ              .
669A  BD                CP      L               .
669B  D8                RET     C               .
669C  7A                LD      A,D             z
669D  BC                CP      H               .
669E  C0                RET     NZ              .
669F  7B                LD      A,E             {
66A0  BD                CP      L               .
66A1  C9                RET                     .
66A2  7A                LD      A,D             z
66A3  B8                CP      B               .
66A4  C0                RET     NZ              .
66A5  BB                CP      E               .
66A6  D8                RET     C               .
66A7  78                LD      A,B             x
66A8  BC                CP      H               .
66A9  C0                RET     NZ              .
66AA  79                LD      A,C             y
66AB  BD                CP      L               .
66AC  C9                RET                     .
66AD  78                LD      A,B             x
66AE  BA                CP      D               .
66AF  C0                RET     NZ              .
66B0  79                LD      A,C             y
66B1  BB                CP      E               .
66B2  C9                RET                     .
66B3  1A                LD      A,(DE)          .
66B4  BE                CP      (HL)            .
66B5  13                INC     DE              .
66B6  23                INC     HL              #
66B7  C0                RET     NZ              .
66B8  10F9              DJNZ    66B3H           ..
66BA  C9                RET                     .
66BB  7E                LD      A,(HL)          ~
66BC  FE41              CP      41H             .A
66BE  3F                CCF                     ?
66BF  D0                RET     NC              .
66C0  FE5B              CP      5BH             .[
66C2  C9                RET                     .
66C3  7E                LD      A,(HL)          ~
66C4  FE41              CP      41H             .A
66C6  380D              JR      C,66D5H         8.
66C8  FE5B              CP      5BH             .[
66CA  C9                RET                     .
66CB  FE47              CP      47H             .G
66CD  D0                RET     NC              .
66CE  FE41              CP      41H             .A
66D0  3F                CCF                     ?
66D1  D8                RET     C               .
66D2  1801              JR      66D5H           ..
66D4  7E                LD      A,(HL)          ~
66D5  FE3A              CP      3AH             .:
66D7  D0                RET     NC              .
66D8  FE30              CP      30H             .0
66DA  3F                CCF                     ?
66DB  C9                RET                     .
66DC  216D6D            LD      HL,6D6DH        !mm
66DF  1803              JR      66E4H           ..
66E1  21716D            LD      HL,6D71H        !qm
66E4  E5                PUSH    HL              .
66E5  CD4E63            CALL    634EH           .Nc
66E8  CD7B67            CALL    677BH           .{g
66EB  E1                POP     HL              .
66EC  38F6              JR      C,66E4H         8.
66EE  C9                RET                     .
66EF  21756D            LD      HL,6D75H        !um
66F2  CD4E63            CALL    634EH           .Nc
66F5  CDFB66            CALL    66FBH           ..f
66F8  38F5              JR      C,66EFH         8.
66FA  C9                RET                     .
66FB  CDE567            CALL    67E5H           ..g
66FE  E5                PUSH    HL              .
66FF  F5                PUSH    AF              .
6700  3808              JR      C,670AH         8.
6702  7B                LD      A,E             {
6703  32AE54            LD      (54AEH),A       2.T
6706  7A                LD      A,D             z
6707  B7                OR      A               .
6708  281B              JR      Z,6725H         (.
670A  21046E            LD      HL,6E04H        !.n
670D  181C              JR      672BH           ..
670F  CDED67            CALL    67EDH           ..g
6712  E5                PUSH    HL              .
6713  F5                PUSH    AF              .
6714  3812              JR      C,6728H         8.
6716  7A                LD      A,D             z
6717  B7                OR      A               .
6718  200E              JR      NZ,6728H         .
671A  7B                LD      A,E             {
671B  320654            LD      (5406H),A       2.T
671E  7B                LD      A,E             {
671F  329954            LD      (5499H),A       2.T
6722  CDB567            CALL    67B5H           ..g
6725  F1                POP     AF              .
6726  E1                POP     HL              .
6727  C9                RET                     .
6728  21EB6D            LD      HL,6DEBH        !.m
672B  CD4562            CALL    6245H           .Eb
672E  F1                POP     AF              .
672F  E1                POP     HL              .
6730  37                SCF                     7
6731  C9                RET                     .
6732  CDED67            CALL    67EDH           ..g
6735  E5                PUSH    HL              .
6736  F5                PUSH    AF              .
6737  3813              JR      C,674CH         8.
6739  7A                LD      A,D             z
673A  B7                OR      A               .
673B  200F              JR      NZ,674CH         .
673D  CDB567            CALL    67B5H           ..g
6740  210D43            LD      HL,430DH        !.C
6743  7B                LD      A,E             {
6744  BE                CP      (HL)            .
6745  3005              JR      NC,674CH        0.
6747  329E54            LD      (549EH),A       2.T
674A  18D9              JR      6725H           ..
674C  21EF6D            LD      HL,6DEFH        !.m
674F  18DA              JR      672BH           ..
6751  CDE567            CALL    67E5H           ..g
6754  E5                PUSH    HL              .
6755  F5                PUSH    AF              .
6756  3813              JR      C,676BH         8.
6758  7A                LD      A,D             z
6759  B7                OR      A               .
675A  200F              JR      NZ,676BH         .
675C  CDB567            CALL    67B5H           ..g
675F  219B54            LD      HL,549BH        !.T
6762  7B                LD      A,E             {
6763  BE                CP      (HL)            .
6764  3005              JR      NC,676BH        0.
6766  32A054            LD      (54A0H),A       2.T
6769  18BA              JR      6725H           ..
676B  21F36D            LD      HL,6DF3H        !.m
676E  18BB              JR      672BH           ..
6770  CDE567            CALL    67E5H           ..g
6773  D0                RET     NC              .
6774  E5                PUSH    HL              .
6775  F5                PUSH    AF              .
6776  21FF6D            LD      HL,6DFFH        !.m
6779  18B0              JR      672BH           ..
677B  CDE567            CALL    67E5H           ..g
677E  E5                PUSH    HL              .
677F  F5                PUSH    AF              .
6780  3808              JR      C,678AH         8.
6782  ED53AC54          LD      (54ACH),DE      .S.T
6786  7A                LD      A,D             z
6787  B3                OR      E               .
6788  209B              JR      NZ,6725H         .
678A  21FC6D            LD      HL,6DFCH        !.m
678D  189C              JR      672BH           ..
678F  CD5562            CALL    6255H           .Ub
6792  21506D            LD      HL,6D50H        !Pm
6795  CD4E63            CALL    634EH           .Nc
6798  37                SCF                     7
6799  C8                RET     Z               .
679A  CD0F67            CALL    670FH           ..g
679D  D8                RET     C               .
679E  CDE567            CALL    67E5H           ..g
67A1  E5                PUSH    HL              .
67A2  F5                PUSH    AF              .
67A3  380A              JR      C,67AFH         8.
67A5  ED53A254          LD      (54A2H),DE      .S.T
67A9  CDB567            CALL    67B5H           ..g
67AC  C32567            JP      6725H           .%g
67AF  21F76D            LD      HL,6DF7H        !.m
67B2  C32B67            JP      672BH           .+g
67B5  F5                PUSH    AF              .
67B6  E5                PUSH    HL              .
67B7  D5                PUSH    DE              .
67B8  C5                PUSH    BC              .
67B9  3A0654            LD      A,(5406H)       :.T
67BC  110054            LD      DE,5400H        ..T
67BF  CD5E44            CALL    445EH           .^D
67C2  C27865            JP      NZ,6578H        .xe
67C5  3A0E43            LD      A,(430EH)       :.C
67C8  329B54            LD      (549BH),A       2.T
67CB  3A0F43            LD      A,(430FH)       :.C
67CE  329C54            LD      (549CH),A       2.T
67D1  3A0D43            LD      A,(430DH)       :.C
67D4  6F                LD      L,A             o
67D5  2600              LD      H,00H           &.
67D7  3A9B54            LD      A,(549BH)       :.T
67DA  CD7D68            CALL    687DH           .}h
67DD  22A854            LD      (54A8H),HL      ".T
67E0  C1                POP     BC              .
67E1  D1                POP     DE              .
67E2  E1                POP     HL              .
67E3  F1                POP     AF              .
67E4  C9                RET                     .
67E5  CDED67            CALL    67EDH           ..g
67E8  D8                RET     C               .
67E9  C2A065            JP      NZ,65A0H        ..e
67EC  C9                RET                     .
67ED  7E                LD      A,(HL)          ~
67EE  FE0D              CP      0DH             ..
67F0  CA9865            JP      Z,6598H         ..e
67F3  FE2C              CP      2CH             .,
67F5  CAA565            JP      Z,65A5H         ..e
67F8  E5                PUSH    HL              .
67F9  CD2268            CALL    6822H           ."h
67FC  C1                POP     BC              .
67FD  7E                LD      A,(HL)          ~
67FE  D641              SUB     41H             .A
6800  FE08              CP      08H             ..
6802  300B              JR      NC,680FH        0.
6804  60                LD      H,B             @
6805  69                LD      L,C             i
6806  CD4F68            CALL    684FH           .Oh
6809  7E                LD      A,(HL)          ~
680A  FE48              CP      48H             .H
680C  23                INC     HL              #
680D  2011              JR      NZ,6820H         .
680F  7E                LD      A,(HL)          ~
6810  FE0D              CP      0DH             ..
6812  C8                RET     Z               .
6813  FE2C              CP      2CH             .,
6815  C21B68            JP      NZ,681BH        ..h
6818  23                INC     HL              #
6819  B7                OR      A               .
681A  C9                RET                     .
681B  FE58              CP      58H             .X
681D  CAC554            JP      Z,54C5H         ..T
6820  37                SCF                     7
6821  C9                RET                     .
6822  110000            LD      DE,0000H        ...
6825  CD2C68            CALL    682CH           .,h
6828  D8                RET     C               .
6829  23                INC     HL              #
682A  18F9              JR      6825H           ..
682C  7E                LD      A,(HL)          ~
682D  CDD566            CALL    66D5H           ..f
6830  3F                CCF                     ?
6831  D8                RET     C               .
6832  D630              SUB     30H             .0
6834  E5                PUSH    HL              .
6835  62                LD      H,D             b
6836  6B                LD      L,E             k
6837  08                EX      AF,AF'          .
6838  3E1F              LD      A,1FH           >.
683A  BA                CP      D               .
683B  3810              JR      C,684DH         8.
683D  08                EX      AF,AF'          .
683E  29                ADD     HL,HL           )
683F  29                ADD     HL,HL           )
6840  19                ADD     HL,DE           .
6841  29                ADD     HL,HL           )
6842  3809              JR      C,684DH         8.
6844  5F                LD      E,A             _
6845  1600              LD      D,00H           ..
6847  19                ADD     HL,DE           .
6848  3803              JR      C,684DH         8.
684A  EB                EX      DE,HL           .
684B  7A                LD      A,D             z
684C  B3                OR      E               .
684D  E1                POP     HL              .
684E  C9                RET                     .
684F  110000            LD      DE,0000H        ...
6852  CD5968            CALL    6859H           .Yh
6855  D8                RET     C               .
6856  23                INC     HL              #
6857  18F9              JR      6852H           ..
6859  7E                LD      A,(HL)          ~
685A  CD6D68            CALL    686DH           .mh
685D  3F                CCF                     ?
685E  D8                RET     C               .
685F  E5                PUSH    HL              .
6860  EB                EX      DE,HL           .
6861  08                EX      AF,AF'          .
6862  7C                LD      A,H             |
6863  C6F0              ADD     F0H             ..
6865  38E6              JR      C,684DH         8.
6867  08                EX      AF,AF'          .
6868  29                ADD     HL,HL           )
6869  29                ADD     HL,HL           )
686A  29                ADD     HL,HL           )
686B  18D4              JR      6841H           ..
686D  D630              SUB     30H             .0
686F  FE0A              CP      0AH             ..
6871  D8                RET     C               .
6872  D611              SUB     11H             ..
6874  FE06              CP      06H             ..
6876  D0                RET     NC              .
6877  C60A              ADD     0AH             ..
6879  37                SCF                     7
687A  C9                RET                     .
687B  2600              LD      H,00H           &.
687D  D5                PUSH    DE              .
687E  C5                PUSH    BC              .
687F  EB                EX      DE,HL           .
6880  0E80              LD      C,80H           ..
6882  210000            LD      HL,0000H        !..
6885  0F                RRCA                    .
6886  3001              JR      NC,6889H        0.
6888  19                ADD     HL,DE           .
6889  CB3C              SRL     H               .<
688B  CB1D              RR      L               ..
688D  CB19              RR      C               ..
688F  30F4              JR      NC,6885H        0.
6891  65                LD      H,L             e
6892  69                LD      L,C             i
6893  C1                POP     BC              .
6894  D1                POP     DE              .
6895  C9                RET                     .
6896  4F                LD      C,A             O
6897  0610              LD      B,10H           ..
6899  AF                XOR     A               .
689A  29                ADD     HL,HL           )
689B  17                RLA                     .
689C  3803              JR      C,68A1H         8.
689E  B9                CP      C               .
689F  3802              JR      C,68A3H         8.
68A1  91                SUB     C               .
68A2  2C                INC     L               ,
68A3  10F5              DJNZ    689AH           ..
68A5  C9                RET                     .
68A6  5F                LD      E,A             _
68A7  1600              LD      D,00H           ..
68A9  1804              JR      68AFH           ..
68AB  5E                LD      E,(HL)          ^
68AC  23                INC     HL              #
68AD  56                LD      D,(HL)          V
68AE  23                INC     HL              #
68AF  E5                PUSH    HL              .
68B0  CDD168            CALL    68D1H           ..h
68B3  0604              LD      B,04H           ..
68B5  218754            LD      HL,5487H        !.T
68B8  3E30              LD      A,30H           >0
68BA  BE                CP      (HL)            .
68BB  2005              JR      NZ,68C2H         .
68BD  3620              LD      (HL),20H        6
68BF  23                INC     HL              #
68C0  10F8              DJNZ    68BAH           ..
68C2  04                INC     B               .
68C3  D1                POP     DE              .
68C4  C9                RET                     .
68C5  CDD168            CALL    68D1H           ..h
68C8  0605              LD      B,05H           ..
68CA  218754            LD      HL,5487H        !.T
68CD  C3BA62            JP      62BAH           ..b
68D0  EB                EX      DE,HL           .
68D1  018754            LD      BC,5487H        ..T
68D4  21F668            LD      HL,68F6H        !.h
68D7  3E04              LD      A,04H           >.
68D9  08                EX      AF,AF'          .
68DA  C5                PUSH    BC              .
68DB  4E                LD      C,(HL)          N
68DC  23                INC     HL              #
68DD  46                LD      B,(HL)          F
68DE  23                INC     HL              #
68DF  EB                EX      DE,HL           .
68E0  3E2F              LD      A,2FH           >/
68E2  3C                INC     A               <
68E3  09                ADD     HL,BC           .
68E4  DAE268            JP      C,68E2H         ..h
68E7  ED42              SBC     HL,BC           .B
68E9  EB                EX      DE,HL           .
68EA  C1                POP     BC              .
68EB  02                LD      (BC),A          .
68EC  03                INC     BC              .
68ED  08                EX      AF,AF'          .
68EE  3D                DEC     A               =
68EF  20E8              JR      NZ,68D9H         .
68F1  7B                LD      A,E             {
68F2  C630              ADD     30H             .0
68F4  02                LD      (BC),A          .
68F5  C9                RET                     .
68F6  F0                RET     P               .
68F7  D8                RET     C               .
68F8  18FC              JR      68F6H           ..
68FA  9C                SBC     A,H             .
68FB  FF                RST     38H             .
68FC  F6FF              OR      FFH             ..
68FE  44                LD      B,H             D
68FF  52                LD      D,D             R
6900  56                LD      D,(HL)          V
6901  54                LD      D,H             T
6902  52                LD      D,D             R
6903  4B                LD      C,E             K
6904  54                LD      D,H             T
6905  52                LD      D,D             R
6906  53                LD      D,E             S
6907  44                LD      B,H             D
6908  52                LD      D,D             R
6909  53                LD      D,E             S
690A  46                LD      B,(HL)          F
690B  52                LD      D,D             R
690C  53                LD      D,E             S
690D  44                LD      B,H             D
690E  44                LD      B,H             D
690F  81                ADD     A,C             .
6910  00                NOP                     .
6911  84                ADD     A,H             .
6912  55                LD      D,L             U
6913  44                LD      B,H             D
6914  4D                LD      C,L             M
6915  A1                AND     C               .
6916  00                NOP                     .
6917  4F                LD      C,A             O
6918  56                LD      D,(HL)          V
6919  44                LD      B,H             D
691A  46                LD      B,(HL)          F
691B  53                LD      D,E             S
691C  C1                POP     BC              .
691D  00                NOP                     .
691E  CA5544            JP      Z,4455H         .UD
6921  54                LD      D,H             T
6922  53                LD      D,E             S
6923  91                SUB     C               .
6924  00                NOP                     .
6925  45                LD      B,L             E
6926  55                LD      D,L             U
6927  44                LD      B,H             D
6928  4D                LD      C,L             M
6929  44                LD      B,H             D
692A  42                LD      B,D             B
692B  89                ADC     A,C             .
692C  00                NOP                     .
692D  CA5556            JP      Z,5655H         .UV
6930  44                LD      B,H             D
6931  53                LD      D,E             S
6932  80                ADD     A,B             .
6933  80                ADD     A,B             .
6934  A6                AND     (HL)            .
6935  5B                LD      E,E             [
6936  5A                LD      E,D             Z
6937  44                LD      B,H             D
6938  53                LD      D,E             S
6939  80                ADD     A,B             .
693A  40                LD      B,B             @
693B  9E                SBC     A,(HL)          .
693C  5B                LD      E,E             [
693D  43                LD      B,E             C
693E  44                LD      B,H             D
693F  53                LD      D,E             S
6940  80                ADD     A,B             .
6941  204D              JR      NZ,6990H         M
6943  5B                LD      E,E             [
6944  43                LD      B,E             C
6945  44                LD      B,H             D
6946  44                LD      B,H             D
6947  80                ADD     A,B             .
6948  10E0              DJNZ    692AH           ..
694A  59                LD      E,C             Y
694B  44                LD      B,H             D
694C  50                LD      D,B             P
694D  57                LD      D,A             W
694E  45                LD      B,L             E
694F  80                ADD     A,B             .
6950  00                NOP                     .
6951  49                LD      C,C             I
6952  5E                LD      E,(HL)          ^
6953  44                LD      B,H             D
6954  4E                LD      C,(HL)          N
6955  54                LD      D,H             T
6956  48                LD      C,B             H
6957  80                ADD     A,B             .
6958  00                NOP                     .
6959  A0                AND     B               .
695A  5E                LD      E,(HL)          ^
695B  52                LD      D,D             R
695C  52                LD      D,D             R
695D  54                LD      D,H             T
695E  80                ADD     A,B             .
695F  08                EX      AF,AF'          .
6960  DF                RST     18H             .
6961  5E                LD      E,(HL)          ^
6962  45                LD      B,L             E
6963  58                LD      E,B             X
6964  49                LD      C,C             I
6965  54                LD      D,H             T
6966  80                ADD     A,B             .
6967  00                NOP                     .
6968  1B                DEC     DE              .
6969  58                LD      E,B             X
696A  00                NOP                     .
696B  80                ADD     A,B             .
696C  202D              JR      NZ,699BH         -
696E  A0                AND     B               .
696F  27                DAA                     '
6970  2AA727            LD      HL,(27A7H)      *.'
6973  52                LD      D,D             R
6974  A7                AND     A               .
6975  27                DAA                     '
6976  53                LD      D,E             S
6977  A7                AND     A               .
6978  27                DAA                     '
6979  58                LD      E,B             X
697A  A7                AND     A               .
697B  27                DAA                     '
697C  59                LD      E,C             Y
697D  A7                AND     A               .
697E  2859              JR      Z,69D9H         (Y
6980  204F              JR      NZ,69D1H         O
6982  52                LD      D,D             R
6983  204E              JR      NZ,69D3H         N
6985  29                ADD     HL,HL           )
6986  A0                AND     B               .
6987  08                EX      AF,AF'          .
6988  3F                CCF                     ?
6989  3F                CCF                     ?
698A  3F                CCF                     ?
698B  A0                AND     B               .
698C  2A2A2A            LD      HL,(2A2AH)      ***
698F  2A2A2A            LD      HL,(2A2AH)      ***
6992  AA                XOR     D               .
6993  27                DAA                     '
6994  45                LD      B,L             E
6995  4E                LD      C,(HL)          N
6996  54                LD      D,H             T
6997  45                LD      B,L             E
6998  52                LD      D,D             R
6999  A7                AND     A               .
699A  08                EX      AF,AF'          .
699B  2EA0              LD      L,A0H           ..
699D  08                EX      AF,AF'          .
699E  27                DAA                     '
699F  D308              OUT     (08H),A         ..
69A1  27                DAA                     '
69A2  2020              JR      NZ,69C4H
69A4  2D                DEC     L               -
69A5  A0                AND     B               .
69A6  A0                AND     B               .
69A7  08                EX      AF,AF'          .
69A8  3F                CCF                     ?
69A9  A0                AND     B               .
69AA  08                EX      AF,AF'          .
69AB  3F                CCF                     ?
69AC  20A0              JR      NZ,694EH         .
69AE  2888              JR      Z,6938H         (.
69B0  08                EX      AF,AF'          .
69B1  A9                XOR     C               .
69B2  1C                INC     E               .
69B3  1F                RRA                     .
69B4  88                ADC     A,B             .
69B5  08                EX      AF,AF'          .
69B6  2853              JR      Z,6A0BH         (S
69B8  A9                XOR     C               .
69B9  08                EX      AF,AF'          .
69BA  2F                CPL                     /
69BB  88                ADC     A,B             .
69BC  A3                AND     E               .
69BD  41                LD      B,C             A
69BE  D442C5            CALL    NC,C542H        .B.
69C1  44                LD      B,H             D
69C2  CF                RST     08H             .
69C3  49                LD      C,C             I
69C4  C649              ADD     49H             .I
69C6  D34F              OUT     (4FH),A         .O
69C8  C64F              ADD     4FH             .O
69CA  CB4F              BIT     1,A             .O
69CC  D254CF            JP      NC,CF54H        .T.
69CF  41                LD      B,C             A
69D0  4C                LD      C,H             L
69D1  CC414E            CALL    Z,4E41H         .AN
69D4  C44241            CALL    NZ,4142H        .BA
69D7  C4454E            CALL    NZ,4E45H        .EN
69DA  C4454F            CALL    NZ,4F45H        .EO
69DD  C646              ADD     46H             .F
69DF  45                LD      B,L             E
69E0  D7                RST     10H             .
69E1  46                LD      B,(HL)          F
69E2  4F                LD      C,A             O
69E3  D24D41            JP      NC,414DH        .MA
69E6  D9                EXX                     .
69E7  4E                LD      C,(HL)          N
69E8  4F                LD      C,A             O
69E9  D44F55            CALL    NC,554FH        .OU
69EC  D45448            CALL    NC,4854H        .TH
69EF  C5                PUSH    BC              .
69F0  54                LD      D,H             T
69F1  4F                LD      C,A             O
69F2  CF                RST     08H             .
69F3  59                LD      E,C             Y
69F4  4F                LD      C,A             O
69F5  D5                PUSH    DE              .
69F6  42                LD      B,D             B
69F7  41                LD      B,C             A
69F8  53                LD      D,E             S
69F9  C5                PUSH    BC              .
69FA  42                LD      B,D             B
69FB  59                LD      E,C             Y
69FC  54                LD      D,H             T
69FD  C5                PUSH    BC              .
69FE  43                LD      B,E             C
69FF  48                LD      C,B             H
6A00  41                LD      B,C             A
6A01  D2434F            JP      NC,4F43H        .CO
6A04  44                LD      B,H             D
6A05  C5                PUSH    BC              .
6A06  43                LD      B,E             C
6A07  4F                LD      C,A             O
6A08  50                LD      D,B             P
6A09  D9                EXX                     .
6A0A  44                LD      B,H             D
6A0B  41                LD      B,C             A
6A0C  54                LD      D,H             T
6A0D  C1                POP     BC              .
6A0E  44                LD      B,H             D
6A0F  49                LD      C,C             I
6A10  53                LD      D,E             S
6A11  CB44              BIT     0,H             .D
6A13  55                LD      D,L             U
6A14  4D                LD      C,L             M
6A15  D0                RET     NC              .
6A16  45                LD      B,L             E
6A17  58                LD      E,B             X
6A18  49                LD      C,C             I
6A19  D44649            CALL    NC,4946H        .FI
6A1C  4C                LD      C,H             L
6A1D  C5                PUSH    BC              .
6A1E  4C                LD      C,H             L
6A1F  4F                LD      C,A             O
6A20  53                LD      D,E             S
6A21  D40080            CALL    NC,8000H        ...
6A24  4D                LD      C,L             M
6A25  41                LD      B,C             A
6A26  49                LD      C,C             I
6A27  CE4D              ADC     4DH             .M
6A29  41                LD      B,C             A
6A2A  4E                LD      C,(HL)          N
6A2B  D9                EXX                     .
6A2C  4D                LD      C,L             M
6A2D  45                LD      B,L             E
6A2E  4E                LD      C,(HL)          N
6A2F  D5                PUSH    DE              .
6A30  4D                LD      C,L             M
6A31  4F                LD      C,A             O
6A32  44                LD      B,H             D
6A33  C5                PUSH    BC              .
6A34  4E                LD      C,(HL)          N
6A35  41                LD      B,C             A
6A36  4D                LD      C,L             M
6A37  C5                PUSH    BC              .
6A38  52                LD      D,D             R
6A39  45                LD      B,L             E
6A3A  41                LD      B,C             A
6A3B  C45345            CALL    NZ,4553H        .SE
6A3E  45                LD      B,L             E
6A3F  CB53              BIT     2,E             .S
6A41  4B                LD      C,E             K
6A42  49                LD      C,C             I
6A43  D0                RET     NC              .
6A44  53                LD      D,E             S
6A45  4F                LD      C,A             O
6A46  4D                LD      C,L             M
6A47  C5                PUSH    BC              .
6A48  53                LD      D,E             S
6A49  55                LD      D,L             U
6A4A  52                LD      D,D             R
6A4B  C5                PUSH    BC              .
6A4C  54                LD      D,H             T
6A4D  48                LD      C,B             H
6A4E  49                LD      C,C             I
6A4F  D354              OUT     (54H),A         .T
6A51  59                LD      E,C             Y
6A52  50                LD      D,B             P
6A53  C5                PUSH    BC              .
6A54  57                LD      D,A             W
6A55  41                LD      B,C             A
6A56  4E                LD      C,(HL)          N
6A57  D45748            CALL    NC,4857H        .WH
6A5A  45                LD      B,L             E
6A5B  CE5A              ADC     5AH             .Z
6A5D  45                LD      B,L             E
6A5E  52                LD      D,D             R
6A5F  CF                RST     08H             .
6A60  42                LD      B,D             B
6A61  4C                LD      C,H             L
6A62  4F                LD      C,A             O
6A63  43                LD      B,E             C
6A64  CB43              BIT     0,E             .C
6A66  4F                LD      C,A             O
6A67  55                LD      D,L             U
6A68  4E                LD      C,(HL)          N
6A69  D44452            CALL    NC,5244H        .DR
6A6C  49                LD      C,C             I
6A6D  56                LD      D,(HL)          V
6A6E  C5                PUSH    BC              .
6A6F  45                LD      B,L             E
6A70  52                LD      D,D             R
6A71  52                LD      D,D             R
6A72  4F                LD      C,A             O
6A73  D24558            JP      NC,5845H        .EX
6A76  54                LD      D,H             T
6A77  52                LD      D,D             R
6A78  C1                POP     BC              .
6A79  46                LD      B,(HL)          F
6A7A  41                LD      B,C             A
6A7B  55                LD      D,L             U
6A7C  4C                LD      C,H             L
6A7D  D4464F            CALL    NC,4F46H        .FO
6A80  55                LD      D,L             U
6A81  4E                LD      C,(HL)          N
6A82  C4494E            CALL    NZ,4E49H        .IN
6A85  50                LD      D,B             P
6A86  55                LD      D,L             U
6A87  D45041            CALL    NC,4150H        .PA
6A8A  55                LD      D,L             U
6A8B  53                LD      D,E             S
6A8C  C5                PUSH    BC              .
6A8D  50                LD      D,B             P
6A8E  52                LD      D,D             R
6A8F  45                LD      B,L             E
6A90  53                LD      D,E             S
6A91  D352              OUT     (52H),A         .R
6A93  41                LD      B,C             A
6A94  4E                LD      C,(HL)          N
6A95  47                LD      B,A             G
6A96  C5                PUSH    BC              .
6A97  52                LD      D,D             R
6A98  45                LD      B,L             E
6A99  50                LD      D,B             P
6A9A  4C                LD      C,H             L
6A9B  D9                EXX                     .
6A9C  52                LD      D,D             R
6A9D  45                LD      B,L             E
6A9E  54                LD      D,H             T
6A9F  52                LD      D,D             R
6AA0  D9                EXX                     .
6AA1  54                LD      D,H             T
6AA2  52                LD      D,D             R
6AA3  41                LD      B,C             A
6AA4  43                LD      B,E             C
6AA5  CB56              BIT     2,(HL)          .V
6AA7  41                LD      B,C             A
6AA8  4C                LD      C,H             L
6AA9  55                LD      D,L             U
6AAA  C5                PUSH    BC              .
6AAB  57                LD      D,A             W
6AAC  52                LD      D,D             R
6AAD  49                LD      C,C             I
6AAE  54                LD      D,H             T
6AAF  C5                PUSH    BC              .
6AB0  42                LD      B,D             B
6AB1  45                LD      B,L             E
6AB2  59                LD      E,C             Y
6AB3  4F                LD      C,A             O
6AB4  4E                LD      C,(HL)          N
6AB5  C44255            CALL    NZ,5542H        .BU
6AB8  46                LD      B,(HL)          F
6AB9  46                LD      B,(HL)          F
6ABA  45                LD      B,L             E
6ABB  D24445            JP      NC,4544H        .DE
6ABE  56                LD      D,(HL)          V
6ABF  49                LD      C,C             I
6AC0  43                LD      B,E             C
6AC1  C5                PUSH    BC              .
6AC2  4D                LD      C,L             M
6AC3  45                LD      B,L             E
6AC4  4D                LD      C,L             M
6AC5  4F                LD      C,A             O
6AC6  52                LD      D,D             R
6AC7  D9                EXX                     .
6AC8  4F                LD      C,A             O
6AC9  46                LD      B,(HL)          F
6ACA  46                LD      B,(HL)          F
6ACB  53                LD      D,E             S
6ACC  45                LD      B,L             E
6ACD  D45041            CALL    NC,4150H        .PA
6AD0  52                LD      D,D             R
6AD1  49                LD      C,C             I
6AD2  54                LD      D,H             T
6AD3  D9                EXX                     .
6AD4  52                LD      D,D             R
6AD5  45                LD      B,L             E
6AD6  43                LD      B,E             C
6AD7  4F                LD      C,A             O
6AD8  52                LD      D,D             R
6AD9  C45245            CALL    NZ,4552H        .RE
6ADC  54                LD      D,H             T
6ADD  55                LD      D,L             U
6ADE  52                LD      D,D             R
6ADF  CE53              ADC     53H             .S
6AE1  45                LD      B,L             E
6AE2  43                LD      B,E             C
6AE3  54                LD      D,H             T
6AE4  4F                LD      C,A             O
6AE5  D2534F            JP      NC,4F53H        .SO
6AE8  55                LD      D,L             U
6AE9  52                LD      D,D             R
6AEA  43                LD      B,E             C
6AEB  C5                PUSH    BC              .
6AEC  53                LD      D,E             S
6AED  59                LD      E,C             Y
6AEE  53                LD      D,E             S
6AEF  54                LD      D,H             T
6AF0  45                LD      B,L             E
6AF1  CD5645            CALL    4556H           .VE
6AF4  52                LD      D,D             R
6AF5  49                LD      C,C             I
6AF6  46                LD      B,(HL)          F
6AF7  D9                EXX                     .
6AF8  57                LD      D,A             W
6AF9  49                LD      C,C             I
6AFA  54                LD      D,H             T
6AFB  48                LD      C,B             H
6AFC  49                LD      C,C             I
6AFD  CE41              ADC     41H             .A
6AFF  44                LD      B,H             D
6B00  44                LD      B,H             D
6B01  52                LD      D,D             R
6B02  45                LD      B,L             E
6B03  53                LD      D,E             S
6B04  D343              OUT     (43H),A         .C
6B06  4F                LD      C,A             O
6B07  4E                LD      C,(HL)          N
6B08  54                LD      D,H             T
6B09  41                LD      B,C             A
6B0A  49                LD      C,C             I
6B0B  CE44              ADC     44H             .D
6B0D  49                LD      C,C             I
6B0E  53                LD      D,E             S
6B0F  50                LD      D,B             P
6B10  4C                LD      C,H             L
6B11  41                LD      B,C             A
6B12  D9                EXX                     .
6B13  49                LD      C,C             I
6B14  4C                LD      C,H             L
6B15  4C                LD      C,H             L
6B16  45                LD      B,L             E
6B17  47                LD      B,A             G
6B18  41                LD      B,C             A
6B19  CC494E            CALL    Z,4E49H         .IN
6B1C  56                LD      D,(HL)          V
6B1D  41                LD      B,C             A
6B1E  4C                LD      C,H             L
6B1F  49                LD      C,C             I
6B20  C44D49            CALL    NZ,494DH        .MI
6B23  53                LD      D,E             S
6B24  53                LD      D,E             S
6B25  49                LD      C,C             I
6B26  4E                LD      C,(HL)          N
6B27  C7                RST     00H             .
6B28  4E                LD      C,(HL)          N
6B29  55                LD      D,L             U
6B2A  4D                LD      C,L             M
6B2B  45                LD      B,L             E
6B2C  52                LD      D,D             R
6B2D  49                LD      C,C             I
6B2E  C35052            JP      5250H           .PR
6B31  49                LD      C,C             I
6B32  4E                LD      C,(HL)          N
6B33  54                LD      D,H             T
6B34  45                LD      B,L             E
6B35  D25245            JP      NC,4552H        .RE
6B38  51                LD      D,C             Q
6B39  55                LD      D,L             U
6B3A  45                LD      B,L             E
6B3B  53                LD      D,E             S
6B3C  D4434F            CALL    NC,4F43H        .CO
6B3F  4E                LD      C,(HL)          N
6B40  54                LD      D,H             T
6B41  45                LD      B,L             E
6B42  4E                LD      C,(HL)          N
6B43  54                LD      D,H             T
6B44  D343              OUT     (43H),A         .C
6B46  4F                LD      C,A             O
6B47  4E                LD      C,(HL)          N
6B48  54                LD      D,H             T
6B49  49                LD      C,C             I
6B4A  4E                LD      C,(HL)          N
6B4B  55                LD      D,L             U
6B4C  C5                PUSH    BC              .
6B4D  44                LD      B,H             D
6B4E  49                LD      C,C             I
6B4F  53                LD      D,E             S
6B50  4B                LD      C,E             K
6B51  45                LD      B,L             E
6B52  54                LD      D,H             T
6B53  54                LD      D,H             T
6B54  C5                PUSH    BC              .
6B55  46                LD      B,(HL)          F
6B56  49                LD      C,C             I
6B57  4C                LD      C,H             L
6B58  45                LD      B,L             E
6B59  53                LD      D,E             S
6B5A  50                LD      D,B             P
6B5B  45                LD      B,L             E
6B5C  C34655            JP      5546H           .FU
6B5F  4E                LD      C,(HL)          N
6B60  43                LD      B,E             C
6B61  54                LD      D,H             T
6B62  49                LD      C,C             I
6B63  4F                LD      C,A             O
6B64  CE4F              ADC     4FH             .O
6B66  50                LD      D,B             P
6B67  45                LD      B,L             E
6B68  52                LD      D,D             R
6B69  41                LD      B,C             A
6B6A  54                LD      D,H             T
6B6B  4F                LD      C,A             O
6B6C  D25041            JP      NC,4150H        .PA
6B6F  53                LD      D,E             S
6B70  53                LD      D,E             S
6B71  57                LD      D,A             W
6B72  4F                LD      C,A             O
6B73  52                LD      D,D             R
6B74  C45245            CALL    NZ,4552H        .RE
6B77  4C                LD      C,H             L
6B78  41                LD      B,C             A
6B79  54                LD      D,H             T
6B7A  49                LD      C,C             I
6B7B  56                LD      D,(HL)          V
6B7C  C5                PUSH    BC              .
6B7D  53                LD      D,E             S
6B7E  55                LD      D,L             U
6B7F  50                LD      D,B             P
6B80  45                LD      B,L             E
6B81  52                LD      D,D             R
6B82  5A                LD      E,D             Z
6B83  41                LD      B,C             A
6B84  D0                RET     NC              .
6B85  41                LD      B,C             A
6B86  56                LD      D,(HL)          V
6B87  41                LD      B,C             A
6B88  49                LD      C,C             I
6B89  4C                LD      C,H             L
6B8A  41                LD      B,C             A
6B8B  42                LD      B,D             B
6B8C  4C                LD      C,H             L
6B8D  C5                PUSH    BC              .
6B8E  43                LD      B,E             C
6B8F  4F                LD      C,A             O
6B90  4D                LD      C,L             M
6B91  50                LD      D,B             P
6B92  4C                LD      C,H             L
6B93  45                LD      B,L             E
6B94  54                LD      D,H             T
6B95  45                LD      B,L             E
6B96  C45041            CALL    NZ,4150H        .PA
6B99  52                LD      D,D             R
6B9A  41                LD      B,C             A
6B9B  4D                LD      C,L             M
6B9C  45                LD      B,L             E
6B9D  54                LD      D,H             T
6B9E  45                LD      B,L             E
6B9F  D25052            JP      NC,5250H        .PR
6BA2  4F                LD      C,A             O
6BA3  54                LD      D,H             T
6BA4  45                LD      B,L             E
6BA5  43                LD      B,E             C
6BA6  54                LD      D,H             T
6BA7  45                LD      B,L             E
6BA8  C45445            CALL    NZ,4554H        .TE
6BAB  52                LD      D,D             R
6BAC  4D                LD      C,L             M
6BAD  49                LD      C,C             I
6BAE  4E                LD      C,(HL)          N
6BAF  41                LD      B,C             A
6BB0  54                LD      D,H             T
6BB1  C5                PUSH    BC              .
6BB2  42                LD      B,D             B
6BB3  41                LD      B,C             A
6BB4  44                LD      B,H             D
6BB5  2F                CPL                     /
6BB6  49                LD      C,C             I
6BB7  4C                LD      C,H             L
6BB8  4C                LD      C,H             L
6BB9  45                LD      B,L             E
6BBA  47                LD      B,A             G
6BBB  41                LD      B,C             A
6BBC  CC4445            CALL    Z,4544H         .DE
6BBF  53                LD      D,E             S
6BC0  54                LD      D,H             T
6BC1  49                LD      C,C             I
6BC2  4E                LD      C,(HL)          N
6BC3  41                LD      B,C             A
6BC4  54                LD      D,H             T
6BC5  49                LD      C,C             I
6BC6  4F                LD      C,A             O
6BC7  CE4D              ADC     4DH             .M
6BC9  4F                LD      C,A             O
6BCA  44                LD      B,H             D
6BCB  49                LD      C,C             I
6BCC  46                LD      B,(HL)          F
6BCD  49                LD      C,C             I
6BCE  43                LD      B,E             C
6BCF  41                LD      B,C             A
6BD0  54                LD      D,H             T
6BD1  49                LD      C,C             I
6BD2  4F                LD      C,A             O
6BD3  CE52              ADC     52H             .R
6BD5  45                LD      B,L             E
6BD6  4C                LD      C,H             L
6BD7  41                LD      B,C             A
6BD8  54                LD      D,H             T
6BD9  49                LD      C,C             I
6BDA  56                LD      D,(HL)          V
6BDB  45                LD      B,L             E
6BDC  2D                DEC     L               -
6BDD  53                LD      D,E             S
6BDE  45                LD      B,L             E
6BDF  43                LD      B,E             C
6BE0  54                LD      D,H             T
6BE1  4F                LD      C,A             O
6BE2  52                LD      D,D             R
6BE3  2D                DEC     L               -
6BE4  57                LD      D,A             W
6BE5  49                LD      C,C             I
6BE6  54                LD      D,H             T
6BE7  48                LD      C,B             H
6BE8  49                LD      C,C             I
6BE9  4E                LD      C,(HL)          N
6BEA  2D                DEC     L               -
6BEB  88                ADC     A,B             .
6BEC  00                NOP                     .
6BED  02                LD      (BC),A          .
6BEE  0A                LD      A,(BC)          .
6BEF  00                NOP                     .
6BF0  9D                SBC     A,L             .
6BF1  A9                XOR     C               .
6BF2  03                INC     BC              .
6BF3  03                INC     BC              .
6BF4  0B                DEC     BC              .
6BF5  00                NOP                     .
6BF6  96                SUB     (HL)            .
6BF7  91                SUB     C               .
6BF8  03                INC     BC              .
6BF9  04                INC     B               .
6BFA  0C                INC     C               .
6BFB  00                NOP                     .
6BFC  BB                CP      E               .
6BFD  A9                XOR     C               .
6BFE  03                INC     BC              .
6BFF  05                DEC     B               .
6C00  0D                DEC     C               .
6C01  00                NOP                     .
6C02  91                SUB     C               .
6C03  BC                CP      H               .
6C04  87                ADD     A,A             .
6C05  AC                XOR     H               .
6C06  03                INC     BC              .
6C07  08                EX      AF,AF'          .
6C08  1000              DJNZ    6C0AH           ..
6C0A  B8                CP      B               .
6C0B  87                ADD     A,A             .
6C0C  D5                PUSH    DE              .
6C0D  03                INC     BC              .
6C0E  0E00              LD      C,00H           ..
6C10  A8                XOR     B               .
6C11  B5                OR      L               .
6C12  AB                XOR     E               .
6C13  03                INC     BC              .
6C14  0F                RRCA                    .
6C15  00                NOP                     .
6C16  B5                OR      L               .
6C17  D8                RET     C               .
6C18  CE03              ADC     03H             ..
6C1A  1C                INC     E               .
6C1B  1D                DEC     E               .
6C1C  00                NOP                     .
6C1D  76                HALT                    v
6C1E  74                LD      (HL),H          t
6C1F  B6                OR      (HL)            .
6C20  82                ADD     A,D             .
6C21  7B                LD      A,E             {
6C22  CE74              ADC     74H             .t
6C24  95                SUB     L               .
6C25  03                INC     BC              .
6C26  2000              JR      NZ,6C28H         .
6C28  C6A8              ADD     A8H             ..
6C2A  75                LD      (HL),L          u
6C2B  03                INC     BC              .
6C2C  00                NOP                     .
6C2D  D0                RET     NC              .
6C2E  D603              SUB     03H             ..
6C30  72                LD      (HL),D          r
6C31  41                LD      B,C             A
6C32  50                LD      D,B             P
6C33  50                LD      D,B             P
6C34  41                LD      B,C             A
6C35  52                LD      D,D             R
6C36  41                LD      B,C             A
6C37  54                LD      D,H             T
6C38  6B                LD      L,E             k
6C39  D42F38            CALL    NC,382FH        ./8
6C3C  306A              JR      NC,6CA8H        0j
6C3E  AD                XOR     L               .
6C3F  204F              JR      NZ,6C90H         O
6C41  4E                LD      C,(HL)          N
6C42  45                LD      B,L             E
6C43  7B                LD      A,E             {
6C44  89                ADC     A,C             .
6C45  2046              JR      NZ,6C8DH         F
6C47  4F                LD      C,A             O
6C48  4C                LD      C,H             L
6C49  4C                LD      C,H             L
6C4A  4F                LD      C,A             O
6C4B  57                LD      D,A             W
6C4C  49                LD      C,C             I
6C4D  4E                LD      C,(HL)          N
6C4E  47                LD      B,A             G
6C4F  D0                RET     NC              .
6C50  53                LD      D,E             S
6C51  3A0D27            LD      A,(270DH)       :.'
6C54  44                LD      B,H             D
6C55  44                LD      B,H             D
6C56  6C                LD      L,H             l
6C57  7D                LD      A,L             }
6C58  204E              JR      NZ,6CA8H         N
6C5A  55                LD      D,L             U
6C5B  4C                LD      C,H             L
6C5C  4C                LD      C,H             L
6C5D  60                LD      H,B             @
6C5E  C5                PUSH    BC              .
6C5F  92                SUB     D               .
6C60  BE                CP      (HL)            .
6C61  0D                DEC     C               .
6C62  27                DAA                     '
6C63  44                LD      B,H             D
6C64  4D                LD      C,L             M
6C65  6C                LD      L,H             l
6C66  C5                PUSH    BC              .
6C67  97                SUB     A               .
6C68  B9                CP      C               .
6C69  0D                DEC     C               .
6C6A  27                DAA                     '
6C6B  44                LD      B,H             D
6C6C  46                LD      B,(HL)          F
6C6D  53                LD      D,E             S
6C6E  6C                LD      L,H             l
6C6F  C5                PUSH    BC              .
6C70  95                SUB     L               .
6C71  6B                LD      L,E             k
6C72  BE                CP      (HL)            .
6C73  0D                DEC     C               .
6C74  27                DAA                     '
6C75  44                LD      B,H             D
6C76  54                LD      D,H             T
6C77  53                LD      D,E             S
6C78  6C                LD      L,H             l
6C79  C5                PUSH    BC              .
6C7A  B3                OR      E               .
6C7B  6B                LD      L,E             k
6C7C  BE                CP      (HL)            .
6C7D  0D                DEC     C               .
6C7E  27                DAA                     '
6C7F  44                LD      B,H             D
6C80  4D                LD      C,L             M
6C81  44                LD      B,H             D
6C82  42                LD      B,D             B
6C83  6C                LD      L,H             l
6C84  C5                PUSH    BC              .
6C85  B9                CP      C               .
6C86  93                SUB     E               .
6C87  A6                AND     (HL)            .
6C88  0D                DEC     C               .
6C89  27                DAA                     '
6C8A  56                LD      D,(HL)          V
6C8B  44                LD      B,H             D
6C8C  53                LD      D,E             S
6C8D  6C                LD      L,H             l
6C8E  C1                POP     BC              .
6C8F  92                SUB     D               .
6C90  BE                CP      (HL)            .
6C91  53                LD      D,E             S
6C92  0D                DEC     C               .
6C93  27                DAA                     '
6C94  5A                LD      E,D             Z
6C95  44                LD      B,H             D
6C96  53                LD      D,E             S
6C97  6C                LD      L,H             l
6C98  A5                AND     L               .
6C99  92                SUB     D               .
6C9A  BE                CP      (HL)            .
6C9B  53                LD      D,E             S
6C9C  0D                DEC     C               .
6C9D  27                DAA                     '
6C9E  43                LD      B,E             C
6C9F  44                LD      B,H             D
6CA0  53                LD      D,E             S
6CA1  6C                LD      L,H             l
6CA2  90                SUB     B               .
6CA3  92                SUB     D               .
6CA4  BE                CP      (HL)            .
6CA5  53                LD      D,E             S
6CA6  0D                DEC     C               .
6CA7  27                DAA                     '
6CA8  43                LD      B,E             C
6CA9  44                LD      B,H             D
6CAA  44                LD      B,H             D
6CAB  6C                LD      L,H             l
6CAC  90                SUB     B               .
6CAD  92                SUB     D               .
6CAE  91                SUB     C               .
6CAF  0D                DEC     C               .
6CB0  27                DAA                     '
6CB1  44                LD      B,H             D
6CB2  50                LD      D,B             P
6CB3  57                LD      D,A             W
6CB4  45                LD      B,L             E
6CB5  6C                LD      L,H             l
6CB6  C5                PUSH    BC              .
6CB7  D22045            JP      NC,4520H        . E
6CBA  4E                LD      C,(HL)          N
6CBB  08                EX      AF,AF'          .
6CBC  8F                ADC     A,A             .
6CBD  0D                DEC     C               .
6CBE  27                DAA                     '
6CBF  44                LD      B,H             D
6CC0  4E                LD      C,(HL)          N
6CC1  54                LD      D,H             T
6CC2  48                LD      C,B             H
6CC3  6C                LD      L,H             l
6CC4  C5                PUSH    BC              .
6CC5  9B                SBC     A,E             .
6CC6  74                LD      (HL),H          t
6CC7  A2                AND     D               .
6CC8  2048              JR      NZ,6D12H         H
6CCA  41                LD      B,C             A
6CCB  53                LD      D,E             S
6CCC  48                LD      C,B             H
6CCD  8F                ADC     A,A             .
6CCE  0D                DEC     C               .
6CCF  27                DAA                     '
6CD0  08                EX      AF,AF'          .
6CD1  94                SUB     H               .
6CD2  6C                LD      L,H             l
6CD3  82                ADD     A,D             .
6CD4  D42C94            CALL    NC,942CH        .,.
6CD7  7E                LD      A,(HL)          ~
6CD8  2044              JR      NZ,6D1EH         D
6CDA  4F                LD      C,A             O
6CDB  53                LD      D,E             S
6CDC  0D                DEC     C               .
6CDD  08                EX      AF,AF'          .
6CDE  CA204F            JP      Z,4F20H         . O
6CE1  55                LD      D,L             U
6CE2  54                LD      D,H             T
6CE3  50                LD      D,B             P
6CE4  55                LD      D,L             U
6CE5  54                LD      D,H             T
6CE6  6A                LD      L,D             j
6CE7  2041              JR      NZ,6D2AH         A
6CE9  50                LD      D,B             P
6CEA  50                LD      D,B             P
6CEB  45                LD      B,L             E
6CEC  4E                LD      C,(HL)          N
6CED  44                LD      B,H             D
6CEE  202C              JR      NZ,6D1CH         ,
6CF0  50                LD      D,B             P
6CF1  7E                LD      A,(HL)          ~
6CF2  2044              JR      NZ,6D38H         D
6CF4  44                LD      B,H             D
6CF5  2C                INC     L               ,
6CF6  2044              JR      NZ,6D3CH         D
6CF8  4D                LD      C,L             M
6CF9  2C                INC     L               ,
6CFA  2044              JR      NZ,6D40H         D
6CFC  46                LD      B,(HL)          F
6CFD  53                LD      D,E             S
6CFE  2C                INC     L               ,
6CFF  2044              JR      NZ,6D45H         D
6D01  54                LD      D,H             T
6D02  53                LD      D,E             S
6D03  7D                LD      A,L             }
6D04  2044              JR      NZ,6D4AH         D
6D06  4D                LD      C,L             M
6D07  44                LD      B,H             D
6D08  42                LD      B,D             B
6D09  0D                DEC     C               .
6D0A  03                INC     BC              .
6D0B  BF                CP      A               .
6D0C  2003              JR      NZ,6D11H         .
6D0E  DB20              IN      A,(20H)         .
6D10  03                INC     BC              .
6D11  A0                AND     B               .
6D12  8B                ADC     A,E             .
6D13  A3                AND     E               .
6D14  7E                LD      A,(HL)          ~
6D15  78                LD      A,B             x
6D16  A1                AND     C               .
6D17  67                LD      H,A             g
6D18  66                LD      H,(HL)          f
6D19  03                INC     BC              .
6D1A  68                LD      L,B             h
6D1B  A5                AND     L               .
6D1C  92                SUB     D               .
6D1D  BE                CP      (HL)            .
6D1E  53                LD      D,E             S
6D1F  67                LD      H,A             g
6D20  03                INC     BC              .
6D21  68                LD      L,B             h
6D22  90                SUB     B               .
6D23  92                SUB     D               .
6D24  BE                CP      (HL)            .
6D25  53                LD      D,E             S
6D26  67                LD      H,A             g
6D27  03                INC     BC              .
6D28  68                LD      L,B             h
6D29  90                SUB     B               .
6D2A  92                SUB     D               .
6D2B  91                SUB     C               .
6D2C  03                INC     BC              .
6D2D  203D              JR      NZ,6D6CH         =
6D2F  2093              JR      NZ,6CC4H         .
6D31  6B                LD      L,E             k
6D32  8C                ADC     A,H             .
6D33  B9                CP      C               .
6D34  C30397            JP      9703H           ...
6D37  B9                CP      C               .
6D38  C36F03            JP      036FH           .o.
6D3B  A8                XOR     B               .
6D3C  2C                INC     L               ,
6D3D  B3                OR      E               .
6D3E  80                ADD     A,B             .
6D3F  BE                CP      (HL)            .
6D40  75                LD      (HL),L          u
6D41  6B                LD      L,E             k
6D42  6F                LD      L,A             o
6D43  03                INC     BC              .
6D44  B3                OR      E               .
6D45  80                ADD     A,B             .
6D46  BE                CP      (HL)            .
6D47  75                LD      (HL),L          u
6D48  6B                LD      L,E             k
6D49  6F                LD      L,A             o
6D4A  03                INC     BC              .
6D4B  DD                DEFB    DDH             .
6D4C  B3                OR      E               .
6D4D  75                LD      (HL),L          u
6D4E  6F                LD      L,A             o
6D4F  03                INC     BC              .
6D50  A8                XOR     B               .
6D51  80                ADD     A,B             .
6D52  DD                DEFB    DDH             .
6D53  A8                XOR     B               .
6D54  75                LD      (HL),L          u
6D55  6B                LD      L,E             k
6D56  6F                LD      L,A             o
6D57  03                INC     BC              .
6D58  DD                DEFB    DDH             .
6D59  A8                XOR     B               .
6D5A  75                LD      (HL),L          u
6D5B  6F                LD      L,A             o
6D5C  03                INC     BC              .
6D5D  CF                RST     08H             .
6D5E  6F                LD      L,A             o
6D5F  03                INC     BC              .
6D60  95                SUB     L               .
6D61  9B                SBC     A,E             .
6D62  6F                LD      L,A             o
6D63  03                INC     BC              .
6D64  95                SUB     L               .
6D65  A2                AND     D               .
6D66  6F                LD      L,A             o
6D67  03                INC     BC              .
6D68  DD95              SUB     IXL             ..
6D6A  75                LD      (HL),L          u
6D6B  6F                LD      L,A             o
6D6C  03                INC     BC              .
6D6D  BE                CP      (HL)            .
6D6E  A7                AND     A               .
6D6F  6F                LD      L,A             o
6D70  03                INC     BC              .
6D71  8D                ADC     A,L             .
6D72  A7                AND     A               .
6D73  6F                LD      L,A             o
6D74  03                INC     BC              .
6D75  8D                ADC     A,L             .
6D76  BA                CP      D               .
6D77  C2BE6F            JP      NZ,6FBEH        ..o
6D7A  03                INC     BC              .
6D7B  93                SUB     E               .
6D7C  97                SUB     A               .
6D7D  B9                CP      C               .
6D7E  C36F03            JP      036FH           .o.
6D81  AE                XOR     (HL)            .
6D82  A4                AND     H               .
6D83  BE                CP      (HL)            .
6D84  9C                SBC     A,H             .
6D85  D8                RET     C               .
6D86  67                LD      H,A             g
6D87  66                LD      H,(HL)          f
6D88  03                INC     BC              .
6D89  AF                XOR     A               .
6D8A  69                LD      L,C             i
6D8B  7E                LD      A,(HL)          ~
6D8C  BD                CP      L               .
6D8D  7E                LD      A,(HL)          ~
6D8E  99                SBC     A,C             .
6D8F  03                INC     BC              .
6D90  B7                OR      A               .
6D91  86                ADD     A,(HL)          .
6D92  C49F7D            CALL    NZ,7D9FH        ..}
6D95  7F                LD      A,A             
6D96  7B                LD      A,E             {
6D97  BE                CP      (HL)            .
6D98  91                SUB     C               .
6D99  0D                DEC     C               .
6D9A  08                EX      AF,AF'          .
6D9B  AF                XOR     A               .
6D9C  69                LD      L,C             i
6D9D  7E                LD      A,(HL)          ~
6D9E  C5                PUSH    BC              .
6D9F  B7                OR      A               .
6DA0  CC0372            CALL    Z,7203H         ..r
6DA3  B1                OR      C               .
6DA4  65                LD      H,L             e
6DA5  79                LD      A,C             y
6DA6  7C                LD      A,H             |
6DA7  7E                LD      A,(HL)          ~
6DA8  B5                OR      L               .
6DA9  204D              JR      NZ,6DF8H         M
6DAB  4F                LD      C,A             O
6DAC  44                LD      B,H             D
6DAD  49                LD      C,C             I
6DAE  46                LD      B,(HL)          F
6DAF  49                LD      C,C             I
6DB0  45                LD      B,L             E
6DB1  44                LD      B,H             D
6DB2  BE                CP      (HL)            .
6DB3  7E                LD      A,(HL)          ~
6DB4  92                SUB     D               .
6DB5  6D                LD      L,L             m
6DB6  03                INC     BC              .
6DB7  7A                LD      A,D             z
6DB8  7E                LD      A,(HL)          ~
6DB9  77                LD      (HL),A          w
6DBA  2043              JR      NZ,6DFFH         C
6DBC  4F                LD      C,A             O
6DBD  50                LD      D,B             P
6DBE  49                LD      C,C             I
6DBF  45                LD      B,L             E
6DC0  44                LD      B,H             D
6DC1  7E                LD      A,(HL)          ~
6DC2  0D                DEC     C               .
6DC3  03                INC     BC              .
6DC4  72                LD      (HL),D          r
6DC5  DCD603            CALL    C,03D6H         ...
6DC8  72                LD      (HL),D          r
6DC9  DC2043            CALL    C,4320H         . C
6DCC  41                LD      B,C             A
6DCD  4E                LD      C,(HL)          N
6DCE  43                LD      B,E             C
6DCF  45                LD      B,L             E
6DD0  4C                LD      C,H             L
6DD1  4C                LD      C,H             L
6DD2  45                LD      B,L             E
6DD3  44                LD      B,H             D
6DD4  03                INC     BC              .
6DD5  AF                XOR     A               .
6DD6  69                LD      L,C             i
6DD7  7E                LD      A,(HL)          ~
6DD8  CD6D03            CALL    036DH           .m.
6DDB  72                LD      (HL),D          r
6DDC  C7                RST     00H             .
6DDD  DC9A8E            CALL    C,8E9AH         ...
6DE0  6A                LD      L,D             j
6DE1  B1                OR      C               .
6DE2  61                LD      H,C             a
6DE3  7E                LD      A,(HL)          ~
6DE4  CD6D03            CALL    036DH           .m.
6DE7  C6CA              ADD     CAH             ..
6DE9  CB03              RLC     E               ..
6DEB  DAA875            JP      C,75A8H         ..u
6DEE  03                INC     BC              .
6DEF  DAB375            JP      C,75B3H         ..u
6DF2  03                INC     BC              .
6DF3  DABE75            JP      C,75BEH         ..u
6DF6  03                INC     BC              .
6DF7  DAD3BE            JP      C,BED3H         ...
6DFA  75                LD      (HL),L          u
6DFB  03                INC     BC              .
6DFC  DAA703            JP      C,03A7H         ...
6DFF  DA97B9            JP      C,B997H         ...
6E02  C303DA            JP      DA03H           ...
6E05  BA                CP      D               .
6E06  C2BEB4            JP      NZ,B4BEH        ...
6E09  03                INC     BC              .
6E0A  8A                ADC     A,D             .
6E0B  84                ADD     A,H             .
6E0C  D7                RST     10H             .
6E0D  53                LD      D,E             S
6E0E  03                INC     BC              .
6E0F  8A                ADC     A,D             .
6E10  98                SBC     A,B             .
6E11  D7                RST     10H             .
6E12  53                LD      D,E             S
6E13  03                INC     BC              .
6E14  C8                RET     Z               .
6E15  2049              JR      NZ,6E60H         I
6E17  4D                LD      C,L             M
6E18  42                LD      B,D             B
6E19  45                LD      B,L             E
6E1A  44                LD      B,H             D
6E1B  44                LD      B,H             D
6E1C  45                LD      B,L             E
6E1D  44                LD      B,H             D
6E1E  D7                RST     10H             .
6E1F  03                INC     BC              .
6E20  BF                CP      A               .
6E21  BE                CP      (HL)            .
6E22  88                ADC     A,B             .
6E23  7B                LD      A,E             {
6E24  B0                OR      B               .
6E25  03                INC     BC              .
6E26  DBBE              IN      A,(BEH)         ..
6E28  88                ADC     A,B             .
6E29  7B                LD      A,E             {
6E2A  B0                OR      B               .
6E2B  03                INC     BC              .
6E2C  BE                CP      (HL)            .
6E2D  9C                SBC     A,H             .
6E2E  A9                XOR     C               .
6E2F  03                INC     BC              .
6E30  BE                CP      (HL)            .
6E31  B5                OR      L               .
6E32  A9                XOR     C               .
6E33  03                INC     BC              .
6E34  BE                CP      (HL)            .
6E35  C1                POP     BC              .
6E36  A9                XOR     C               .
6E37  03                INC     BC              .
6E38  C0                RET     NZ              .
6E39  A9                XOR     C               .
6E3A  8F                ADC     A,A             .
6E3B  2003              JR      NZ,6E40H         .
6E3D  BE                CP      (HL)            .
6E3E  87                ADD     A,A             .
6E3F  2050              JR      NZ,6E91H         P
6E41  52                LD      D,D             R
6E42  45                LD      B,L             E
6E43  56                LD      D,(HL)          V
6E44  49                LD      C,C             I
6E45  4F                LD      C,A             O
6E46  55                LD      D,L             U
6E47  53                LD      D,E             S
6E48  4C                LD      C,H             L
6E49  59                LD      E,C             Y
6E4A  2053              JR      NZ,6E9FH         S
6E4C  55                LD      D,L             U
6E4D  43                LD      B,E             C
6E4E  43                LD      B,E             C
6E4F  45                LD      B,L             E
6E50  53                LD      D,E             S
6E51  53                LD      D,E             S
6E52  46                LD      B,(HL)          F
6E53  55                LD      D,L             U
6E54  4C                LD      C,H             L
6E55  4C                LD      C,H             L
6E56  59                LD      E,C             Y
6E57  9C                SBC     A,H             .
6E58  03                INC     BC              .
6E59  D42049            CALL    NC,4920H        . I
6E5C  4E                LD      C,(HL)          N
6E5D  54                LD      D,H             T
6E5E  45                LD      B,L             E
6E5F  52                LD      D,D             R
6E60  4E                LD      C,(HL)          N
6E61  41                LD      B,C             A
6E62  4C                LD      C,H             L
6E63  2050              JR      NZ,6EB5H         P
6E65  52                LD      D,D             R
6E66  4F                LD      C,A             O
6E67  47                LD      B,A             G
6E68  52                LD      D,D             R
6E69  41                LD      B,C             A
6E6A  4D                LD      C,L             M
6E6B  4D                LD      C,L             M
6E6C  49                LD      C,C             I
6E6D  4E                LD      C,(HL)          N
6E6E  47                LD      B,A             G
6E6F  A9                XOR     C               .
6E70  03                INC     BC              .
6E71  B1                OR      C               .
6E72  62                LD      H,D             b
6E73  85                ADD     A,L             .
6E74  B2                OR      D               .
6E75  2C                INC     L               ,
6E76  63                LD      H,E             c
6E77  85                ADD     A,L             .
6E78  9E                SBC     A,(HL)          .
6E79  A9                XOR     C               .
6E7A  BE                CP      (HL)            .
6E7B  2C                INC     L               ,
6E7C  7D                LD      A,L             }
6E7D  64                LD      H,H             d
6E7E  7E                LD      A,(HL)          ~
6E7F  0D                DEC     C               .
6E80  08                EX      AF,AF'          .
6E81  D9                EXX                     .
6E82  D0                RET     NC              .
6E83  6D                LD      L,L             m
6E84  03                INC     BC              .
6E85  D0                RET     NC              .
6E86  D9                EXX                     .
6E87  44                LD      B,H             D
6E88  2042              JR      NZ,6ECCH         B
6E8A  59                LD      E,C             Y
6E8B  D1                POP     DE              .
6E8C  03                INC     BC              .
6E8D  A8                XOR     B               .
6E8E  2003              JR      NZ,6E93H         .
6E90  B3                OR      E               .
6E91  2003              JR      NZ,6E96H         .
6E93  BE                CP      (HL)            .
6E94  2003              JR      NZ,6E99H         .
6E96  44                LD      B,H             D
6E97  52                LD      D,D             R
6E98  53                LD      D,E             S
6E99  2003              JR      NZ,6E9EH         .
6E9B  46                LD      B,(HL)          F
6E9C  52                LD      D,D             R
6E9D  53                LD      D,E             S
6E9E  2003              JR      NZ,6EA3H         .
6EA0  2C                INC     L               ,
6EA1  2003              JR      NZ,6EA6H         .
6EA3  48                LD      C,B             H
6EA4  2020              JR      NZ,6EC6H
6EA6  03                INC     BC              .
6EA7  2D                DEC     L               -
6EA8  2020              JR      NZ,6ECAH
6EAA  03                INC     BC              .
6EAB  BE                CP      (HL)            .
6EAC  87                ADD     A,A             .
6EAD  9C                SBC     A,H             .
6EAE  41                LD      B,C             A
6EAF  42                LD      B,D             B
6EB0  4C                LD      C,H             L
6EB1  45                LD      B,L             E
6EB2  03                INC     BC              .
6EB3  BE                CP      (HL)            .
6EB4  87                ADD     A,A             .
6EB5  9C                SBC     A,H             .
6EB6  D8                RET     C               .
6EB7  03                INC     BC              .
6EB8  BE                CP      (HL)            .
6EB9  9C                SBC     A,H             .
6EBA  D8                RET     C               .
6EBB  03                INC     BC              .
6EBC  53                LD      D,E             S
6EBD  48                LD      C,B             H
6EBE  41                LD      B,C             A
6EBF  4C                LD      C,H             L
6EC0  4C                LD      C,H             L
6EC1  2049              JR      NZ,6F0CH         I
6EC3  54                LD      D,H             T
6EC4  2077              JR      NZ,6F3DH         w
6EC6  9C                SBC     A,H             .
6EC7  D8                RET     C               .
6EC8  67                LD      H,A             g
6EC9  66                LD      H,(HL)          f
6ECA  03                INC     BC              .
6ECB  50                LD      D,B             P
6ECC  41                LD      B,C             A
6ECD  52                LD      D,D             R
6ECE  54                LD      D,H             T
6ECF  49                LD      C,C             I
6ED0  41                LD      B,C             A
6ED1  4C                LD      C,H             L
6ED2  20A6              JR      NZ,6E7AH         .
6ED4  2044              JR      NZ,6F1AH         D
6ED6  55                LD      D,L             U
6ED7  45                LD      B,L             E
6ED8  7E                LD      A,(HL)          ~
6ED9  83                ADD     A,E             .
6EDA  03                INC     BC              .
6EDB  72                LD      (HL),D          r
6EDC  4E                LD      C,(HL)          N
6EDD  4F                LD      C,A             O
6EDE  204D              JR      NZ,6F2DH         M
6EE0  41                LD      B,C             A
6EE1  54                LD      D,H             T
6EE2  43                LD      B,E             C
6EE3  48                LD      C,B             H
6EE4  0D                DEC     C               .
6EE5  03                INC     BC              .
6EE6  D26F03            JP      NC,036FH        .o.
6EE9  D0                RET     NC              .
6EEA  C620              ADD     20H             .
6EEC  55                LD      D,L             U
6EED  4E                LD      C,(HL)          N
6EEE  44                LD      B,H             D
6EEF  45                LD      B,L             E
6EF0  52                LD      D,D             R
6EF1  2044              JR      NZ,6F37H         D
6EF3  4F                LD      C,A             O
6EF4  53                LD      D,E             S
6EF5  2D                DEC     L               -
6EF6  43                LD      B,E             C
6EF7  41                LD      B,C             A
6EF8  4C                LD      C,H             L
6EF9  4C                LD      C,H             L
6EFA  03                INC     BC              .
6EFB  97                SUB     A               .
6EFC  B9                CP      C               .
6EFD  B0                OR      B               .
6EFE  6D                LD      L,L             m
6EFF  03                INC     BC              .
6F00  00                NOP                     .
6F01  00                NOP                     .
6F02  00                NOP                     .
6F03  00                NOP                     .
6F04  00                NOP                     .
6F05  00                NOP                     .
6F06  00                NOP                     .
6F07  00                NOP                     .
6F08  00                NOP                     .
6F09  00                NOP                     .
6F0A  00                NOP                     .
6F0B  00                NOP                     .
6F0C  00                NOP                     .
6F0D  00                NOP                     .
6F0E  00                NOP                     .
6F0F  00                NOP                     .
6F10  00                NOP                     .
6F11  00                NOP                     .
6F12  00                NOP                     .
6F13  00                NOP                     .
6F14  00                NOP                     .
6F15  00                NOP                     .
6F16  00                NOP                     .
6F17  00                NOP                     .
6F18  00                NOP                     .
6F19  00                NOP                     .
6F1A  00                NOP                     .
6F1B  00                NOP                     .
6F1C  00                NOP                     .
6F1D  00                NOP                     .
6F1E  00                NOP                     .
6F1F  00                NOP                     .
6F20  00                NOP                     .
6F21  00                NOP                     .
6F22  00                NOP                     .
6F23  00                NOP                     .
6F24  00                NOP                     .
6F25  00                NOP                     .
6F26  00                NOP                     .
6F27  00                NOP                     .
6F28  00                NOP                     .
6F29  00                NOP                     .
6F2A  00                NOP                     .
6F2B  00                NOP                     .
6F2C  00                NOP                     .
6F2D  00                NOP                     .
6F2E  00                NOP                     .
6F2F  00                NOP                     .
6F30  00                NOP                     .
6F31  00                NOP                     .
6F32  00                NOP                     .
6F33  00                NOP                     .
6F34  00                NOP                     .
6F35  00                NOP                     .
6F36  00                NOP                     .
6F37  00                NOP                     .
6F38  00                NOP                     .
6F39  00                NOP                     .
6F3A  00                NOP                     .
6F3B  00                NOP                     .
6F3C  00                NOP                     .
6F3D  00                NOP                     .
6F3E  00                NOP                     .
6F3F  00                NOP                     .
6F40  00                NOP                     .
6F41  00                NOP                     .
6F42  00                NOP                     .
6F43  00                NOP                     .
6F44  00                NOP                     .
6F45  00                NOP                     .
6F46  00                NOP                     .
6F47  00                NOP                     .
6F48  00                NOP                     .
6F49  00                NOP                     .
6F4A  00                NOP                     .
6F4B  00                NOP                     .
6F4C  00                NOP                     .
6F4D  00                NOP                     .
6F4E  00                NOP                     .
6F4F  00                NOP                     .
6F50  00                NOP                     .
6F51  00                NOP                     .
6F52  00                NOP                     .
6F53  00                NOP                     .
6F54  00                NOP                     .
6F55  00                NOP                     .
6F56  00                NOP                     .
6F57  00                NOP                     .
6F58  00                NOP                     .
6F59  00                NOP                     .
6F5A  00                NOP                     .
6F5B  00                NOP                     .
6F5C  00                NOP                     .
6F5D  00                NOP                     .
6F5E  00                NOP                     .
6F5F  00                NOP                     .
6F60  00                NOP                     .
6F61  00                NOP                     .
6F62  00                NOP                     .
6F63  00                NOP                     .
6F64  00                NOP                     .
6F65  00                NOP                     .
6F66  00                NOP                     .
6F67  00                NOP                     .
6F68  00                NOP                     .
6F69  00                NOP                     .
6F6A  00                NOP                     .
6F6B  00                NOP                     .
6F6C  00                NOP                     .
6F6D  00                NOP                     .
6F6E  00                NOP                     .
6F6F  00                NOP                     .
6F70  00                NOP                     .
6F71  00                NOP                     .
6F72  00                NOP                     .
6F73  00                NOP                     .
6F74  00                NOP                     .
6F75  00                NOP                     .
6F76  00                NOP                     .
6F77  00                NOP                     .
6F78  00                NOP                     .
6F79  00                NOP                     .
6F7A  00                NOP                     .
6F7B  00                NOP                     .
6F7C  00                NOP                     .
6F7D  00                NOP                     .
6F7E  00                NOP                     .
6F7F  00                NOP                     .
6F80  00                NOP                     .
6F81  00                NOP                     .
6F82  00                NOP                     .
6F83  00                NOP                     .
6F84  00                NOP                     .
6F85  00                NOP                     .
6F86  00                NOP                     .
6F87  00                NOP                     .
6F88  00                NOP                     .
6F89  00                NOP                     .
6F8A  00                NOP                     .
6F8B  00                NOP                     .
6F8C  00                NOP                     .
6F8D  00                NOP                     .
6F8E  00                NOP                     .
6F8F  00                NOP                     .
6F90  00                NOP                     .
6F91  00                NOP                     .
6F92  00                NOP                     .
6F93  00                NOP                     .
6F94  00                NOP                     .
6F95  00                NOP                     .
6F96  00                NOP                     .
6F97  00                NOP                     .
6F98  00                NOP                     .
6F99  00                NOP                     .
6F9A  00                NOP                     .
6F9B  00                NOP                     .
6F9C  00                NOP                     .
6F9D  00                NOP                     .
6F9E  00                NOP                     .
6F9F  00                NOP                     .
6FA0  00                NOP                     .
6FA1  00                NOP                     .
6FA2  00                NOP                     .
6FA3  00                NOP                     .
6FA4  00                NOP                     .
6FA5  00                NOP                     .
6FA6  00                NOP                     .
6FA7  00                NOP                     .
6FA8  00                NOP                     .
6FA9  00                NOP                     .
6FAA  00                NOP                     .
6FAB  00                NOP                     .
6FAC  00                NOP                     .
6FAD  00                NOP                     .
6FAE  00                NOP                     .
6FAF  00                NOP                     .
6FB0  00                NOP                     .
6FB1  00                NOP                     .
6FB2  00                NOP                     .
6FB3  00                NOP                     .
6FB4  00                NOP                     .
6FB5  00                NOP                     .
6FB6  00                NOP                     .
6FB7  00                NOP                     .
6FB8  00                NOP                     .
6FB9  00                NOP                     .
6FBA  00                NOP                     .
6FBB  00                NOP                     .
6FBC  00                NOP                     .
6FBD  00                NOP                     .
6FBE  00                NOP                     .
6FBF  00                NOP                     .
6FC0  00                NOP                     .
6FC1  00                NOP                     .
6FC2  00                NOP                     .
6FC3  00                NOP                     .
6FC4  00                NOP                     .
6FC5  00                NOP                     .
6FC6  00                NOP                     .
6FC7  00                NOP                     .
6FC8  00                NOP                     .
6FC9  00                NOP                     .
6FCA  00                NOP                     .
6FCB  00                NOP                     .
6FCC  00                NOP                     .
6FCD  00                NOP                     .
6FCE  00                NOP                     .
6FCF  00                NOP                     .
6FD0  00                NOP                     .
6FD1  00                NOP                     .
6FD2  00                NOP                     .
6FD3  00                NOP                     .
6FD4  00                NOP                     .
6FD5  00                NOP                     .
6FD6  00                NOP                     .
6FD7  00                NOP                     .
6FD8  00                NOP                     .
6FD9  00                NOP                     .
6FDA  00                NOP                     .
6FDB  00                NOP                     .
6FDC  00                NOP                     .
6FDD  00                NOP                     .
6FDE  00                NOP                     .
6FDF  00                NOP                     .
6FE0  00                NOP                     .
6FE1  00                NOP                     .
6FE2  00                NOP                     .
6FE3  00                NOP                     .
6FE4  00                NOP                     .
6FE5  00                NOP                     .
6FE6  00                NOP                     .
6FE7  00                NOP                     .
6FE8  00                NOP                     .
6FE9  00                NOP                     .
6FEA  00                NOP                     .
6FEB  00                NOP                     .
6FEC  00                NOP                     .
6FED  00                NOP                     .
6FEE  00                NOP                     .
6FEF  00                NOP                     .
6FF0  00                NOP                     .
6FF1  00                NOP                     .
6FF2  00                NOP                     .
6FF3  00                NOP                     .
6FF4  00                NOP                     .
6FF5  00                NOP                     .
6FF6  00                NOP                     .
6FF7  00                NOP                     .
6FF8  00                NOP                     .
6FF9  00                NOP                     .
6FFA  00                NOP                     .
6FFB  00                NOP                     .
6FFC  00                NOP                     .
6FFD  00                NOP                     .