5200H - Symbol Table Handler Entry Point
This is the main entry point for symbol table operations. It initializes pass control variables from configuration data, sets up buffer pointers for symbol name storage, checks for user break request, and prepares for symbol table searching. The code at 5200H-5210H runs at the beginning of each assembly pass.
5200
LD HL,(5315H) 2A 15 53
Load HL with the pass configuration word from 5315H. This 16-bit value controls assembly pass behavior - the high byte indicates which pass (1 or 2), the low byte contains additional flags.
5203
LD A,H 7C
Copy the high byte (pass number) into Register A for storage.
5204
LD (550EH),A 32 0E 55
Store the pass number at 550EH. This variable is checked throughout the assembler to determine if we're in Pass 1 (symbol collection) or Pass 2 (code generation).
5207
LD A,L 7D
Copy the low byte (configuration flags) into Register A.
5208
LD (5513H),A 32 13 55
Store the configuration flags at 5513H. These flags control various assembly options.
520B
Load HL with the address of the input buffer at 7655H. This is where source line text is stored for parsing.
520E
LD (7650H),HL 22 50 76
Store the input buffer address at 7650H. This pointer (7650H) is used throughout the code to access the current symbol name being searched for.
5211
Call the I/O initialization routine at 5937H. This sets up buffers, opens files, and prepares for source input.
5214
LD A,(3840H) 3A 40 38
Read the keyboard matrix at 3840H. This memory-mapped I/O location returns the state of keyboard row containing the BREAK key.
5217
AND 04H E6 04
Mask for bit 2 which corresponds to the BREAK key. If bit 2 is set, the user has pressed BREAK to abort assembly.
5219
If the NZ FLAG is set (BREAK pressed), JUMP to the abort handler at 58DAH which terminates assembly and returns to the command prompt.
521CH - Source Symbol Extraction
This section extracts the symbol name from the source line and prepares comparison parameters. It reads the symbol's first character and length, then stores these as self-modifying operands for the fast comparison loop that follows.
521C
LD HL,(7650H) 2A 50 76
Load HL with the source symbol pointer from 7650H. This points to the symbol name we're searching for in the source code.
521F
LD (764EH),HL 22 4E 76
Save this pointer at 764EH for later reference during the comparison loop. 764EH serves as a backup of the source symbol position.
5222
LD A,(HL) 7E
Load Register A with the first character of the source symbol name. This is used for quick first-character comparison to reject non-matches early.
5223
LD (5252H),A 32 52 52
SELF-MODIFYING: Store the first character at 5252H. This modifies the immediate operand of the CP instruction at 5251H, allowing fast comparison without reloading.
5226
DEC HL 2B
Decrement HL to point to the length/flags byte which precedes the symbol name. Symbol format: [length/flags][char1][char2]...
5227
LD A,(HL) 7E
Load Register A with the length/flags byte. Bits 0-2 contain (length-1), other bits contain symbol type flags.
5228
AND 07H E6 07
Mask to isolate bits 0-2 which contain the symbol length minus one. Maximum symbol length is 7 characters (value 6 in this field, plus 1).
522A
ADD A,L 85
Add the length value to the low byte of HL. This computes the end position of the symbol name for bounds checking.
522B
LD (526DH),A 32 6D 52
SELF-MODIFYING: Store the computed end position at 526DH. This modifies the CP instruction operand at 526CH to check when we've compared all characters.
522EH - Table Symbol Setup and Search Loop Entry
This section initializes the table symbol comparison parameters similar to how the source symbol was set up. It then enters the main search loop that iterates through all symbol table entries looking for a match.
522E
Load HL with the address 7657H, which is the symbol name buffer where the current table entry's name is stored for comparison.
5231
LD DE,(53C3H) ED 5B C3 53
Load DE with the current symbol table entry pointer from 53C3H. This points to the entry being examined in the symbol table.
[MAIN SEARCH LOOP START] - The following code iterates through symbol table entries. DE points to the current entry, HL is used for name comparison. The loop continues until a match is found or end-of-table is reached.
5235
LD (7650H),HL 22 50 76
Store HL at 7650H, updating the comparison buffer pointer. This is the table symbol's name position for the current comparison.
5238
LD A,(HL) 7E
Load Register A with the first character of the table symbol name for first-character comparison.
5239
LD (5280H),A 32 80 52
SELF-MODIFYING: Store the table symbol's first character at 5280H. This modifies the CP operand at 527FH for quick rejection of non-matching entries.
523C
DEC HL 2B
Decrement HL to point to the table entry's length/flags byte.
523D
LD A,(HL) 7E
Load Register A with the table entry's length/flags byte.
523E
AND 07H E6 07
Mask to isolate bits 0-2 containing (table symbol length - 1).
5240
ADD A,L 85
Add length to low byte of HL to compute the end position for this table symbol.
5241
LD (5292H),A 32 92 52
SELF-MODIFYING: Store the table symbol end position at 5292H. This modifies the CP operand at 5291H.
5244H - Symbol Entry Length Check
This section reads the symbol table entry's length byte to determine entry size and check for end-of-table. A length of zero indicates the end of the symbol table has been reached.
5244
LD A,(DE) 1A
Load Register A with the byte at (DE), which is the length/flags byte of the current symbol table entry.
5245
AND 07H E6 07
Mask to isolate bits 0-2, extracting the symbol name length (minus 1). A value of 0 after masking indicates end-of-table.
5247
If the Z FLAG is set (length field = 0), JUMP to 52A7H which handles the end-of-table / symbol not found condition.
5249
LD B,A 47
Copy the symbol length to Register B. B will be used as the character counter for the comparison loop.
524A
LD C,A 4F
Also save the length in Register C. C preserves the original count for restoration after partial comparisons.
524B
INC DE 13
Increment DE to point to the first character of the symbol name in the table entry (skipping past the length/flags byte).
524C
LD (7634H),DE ED 53 34 76
Save DE at 7634H. This preserves the name start position for later use if we need to restart comparison or access the symbol value.
5250H - First Character Quick Comparison
This section performs a quick first-character comparison between the source symbol and table symbol. This optimization avoids full name comparison for entries that cannot possibly match.
5250
LD A,(DE) 1A
Load Register A with the first character of the table symbol name at (DE).
5251
CP 00H FE 00
SELF-MODIFIED at 5252H: Compare Register A with the source symbol's first character. The 00H operand is overwritten at runtime by code at 5223H with the actual first character to match.
5253
If the C FLAG is set (table char < source char), JUMP to 5260H to advance to next entry. This table entry cannot match.
5255
If the NZ FLAG is set (table char > source char), JUMP to 527FH. First characters don't match, try alternate comparison path.
5257
LD HL,(764EH) 2A 4E 76
First characters match! Load HL with the saved source symbol pointer from 764EH to prepare for full name comparison.
525A
JUMP to 526BH to begin the character-by-character comparison loop.
525CH - Character Comparison Loop
This is the main character-by-character comparison loop. It compares each character of the source symbol against the table symbol, handling matches and mismatches appropriately.
525C
LD A,(DE) 1A
[COMPARISON LOOP] Load Register A with the current character from the table symbol at (DE).
525D
CP (HL) BE
Compare Register A with the character at (HL) from the source symbol. Sets Z if equal, C if table < source.
525E
If the NC FLAG is set (table char >= source char), JUMP to 5269H to check if this is an exact match or mismatch.
5260
INC B 04
[NEXT ENTRY] Increment B. Together with the next INC B, this adds 2 to B to account for the 2-byte symbol value field.
5261
INC B 04
Increment B again. Now B = original_length + 2, which is the offset to the next symbol table entry.
5262
LD L,B 68
Load L with B (entry offset).
5263
LD H,00H 26 00
Clear H, so HL now contains the offset to skip to the next entry.
5265
ADD HL,DE 19
Add DE (current position) to HL (offset). Result in HL is the address of the next symbol entry.
5266
EX DE,HL EB
Exchange DE and HL. Now DE points to the next symbol table entry.
5267
JUMP back to 5244H to examine the next entry in the symbol table search loop.
5269
If the NZ FLAG is set (characters not equal), JUMP to 5279H to handle the mismatch case.
526BH - End of Symbol Name Check
After matching a character, this section checks if we've reached the end of the source symbol name. If all characters have been compared and matched, we have found the symbol.
526B
LD A,L 7D
Load Register A with the low byte of HL (current source position). This will be compared against the end position.
526C
CP 00H FE 00
SELF-MODIFIED at 526DH: Compare A with the source symbol end position. The 00H operand is overwritten at runtime by code at 522BH with the actual end position.
526E
INC DE 13
Increment DE to point to the next character in the table symbol.
526F
If the Z FLAG is set (reached end of source symbol), JUMP to 5276H. The source symbol has been fully matched so far.
5271
INC HL 23
Increment HL to point to the next character in the source symbol.
5272
Decrement B (remaining count) and if NZ, JUMP back to 525CH to compare the next character.
5274
If B reached zero (all table chars compared), JUMP to 5260H. Source symbol is longer than table symbol, so no match - try next entry.
5276
DEC B 05
Decrement B. If B was already 0, this will set B to FFH and clear the Z flag.
5277
If the Z FLAG is set (B was 1, now 0), both symbols are the same length - this is a MATCH! Continue to process the found symbol. If NZ, no match - advance to next entry.
5279H - Alternate Comparison Path
This section handles cases where the first comparison path found a mismatch. It reloads pointers and attempts comparison from the alternate (table symbol's perspective) to properly determine ordering.
5279
LD DE,(7634H) ED 5B 34 76
Reload DE with the saved table symbol name pointer from 7634H. This restores the position to the start of the current entry's name.
527D
LD B,C 41
Restore B from C, resetting the character counter to the original symbol length.
527E
LD A,(DE) 1A
Load Register A with the first character of the table symbol again.
527F
CP 00H FE 00
SELF-MODIFIED at 5280H: Compare with the table symbol's first character. The 00H operand is overwritten at runtime by code at 5239H.
5281
If the C FLAG is set (source char < table char), JUMP to 529EH to advance to next entry via alternate path.
5283
If the NZ FLAG is set (chars different, source > table), JUMP to 5260H to advance to next entry.
5285
LD HL,(7650H) 2A 50 76
First characters match from this path too. Load HL with the buffer symbol pointer from 7650H.
5288
JUMP to 5290H to enter the alternate comparison loop.
528AH - Alternate Character Comparison Loop
This is the alternate comparison loop that checks symbols from the table entry's perspective. It handles cases where the symbol lengths differ or ordering needs verification.
528A
LD A,(DE) 1A
[ALTERNATE LOOP] Load Register A with the current character from the table symbol.
528B
CP (HL) BE
Compare Register A with the character at (HL) from the buffer symbol.
528C
If the C FLAG is set (table char < buffer char), JUMP to 5299H to reload pointers and advance to next entry.
528E
If the NZ FLAG is set (chars different), JUMP to 5260H to try next table entry.
5290
LD A,L 7D
Load Register A with the low byte of HL (current buffer position).
5291
CP 00H FE 00
SELF-MODIFIED at 5292H: Compare A with the buffer symbol end position. The 00H operand is overwritten by code at 5241H.
5293
If the Z FLAG is set (reached end of buffer symbol), JUMP to 5260H. Buffer symbol ended first, so no exact match - try next entry.
5295
INC DE 13
Increment DE to point to next table symbol character.
5296
INC HL 23
Increment HL to point to next buffer symbol character.
5297
Decrement B and if NZ, JUMP back to 528AH to compare next character.
5299
LD DE,(7634H) ED 5B 34 76
Reload DE with the saved name pointer from 7634H.
529D
LD B,C 41
Restore B from C (original length).
529E
INC B 04
Increment B to account for the value field offset.
529F
INC B 04
Increment B again. B now equals name_length + 2 (total entry size excluding length byte).
52A0
LD L,B 68
Load L with the entry offset.
52A1
LD H,00H 26 00
Clear H. HL now contains the skip offset.
52A3
ADD HL,DE 19
Add DE to HL to compute next entry address.
52A4
EX DE,HL EB
Exchange so DE points to next entry.
52A5
JUMP back to 5235H to continue the search loop with the next symbol table entry.
52A7H - Symbol Not Found / End of Table Handler
This section handles the case where the symbol was not found in the table (end-of-table reached) or processes a found symbol. It checks the result and either adds a new symbol or processes the existing one.
52A7
LD HL,(7650H) 2A 50 76
Load HL with the current symbol pointer from 7650H.
52AA
LD A,(HL) 7E
Load Register A with the byte at (HL). This is either a symbol character or terminator.
52AB
LD C,A 4F
Save the byte in Register C for later use.
52AC
INC A 3C
Increment A. If A was FFH (end marker), it becomes 00H and sets the Z flag.
52AD
If the NZ FLAG is set (not end marker), JUMP to 52B5H to process the symbol.
52AF
End marker found - call I/O handler at 5937H to finalize processing.
52B2
JUMP to 6486H to handle the end-of-source / completion processing.
52B5H - Symbol Processing Setup
When a symbol is found or needs to be added, this section prepares the symbol attributes and initializes self-modifying code locations that control subsequent line processing.
52B5
DEC HL 2B
Decrement HL to point to the length/flags byte of the symbol entry.
52B6
LD A,(HL) 7E
Load Register A with the symbol attributes byte. Contains length (bits 0-2) and type flags (bits 3-7).
52B7
LD (55EAH),A 32 EA 55
Store the attributes at 55EAH. This variable is used by the symbol output and reference routines.
52BA
AND 07H E6 07
Mask to isolate bits 0-2 (symbol length - 1).
52BC
ADD A,L 85
Add length to low byte of HL to compute the symbol end position.
52BD
LD (5689H),A 32 89 56
SELF-MODIFYING: Store the end position at 5689H. This modifies a limit check in the symbol output routine.
52C0
LD A,20H 3E 20
Load Register A with 20H, which is the JR NZ opcode.
52C2
LD (5524H),A 32 24 55
SELF-MODIFYING: Store 20H (JR NZ) at 5524H. This controls whether the scanner processes label fields or skips them.
52C5
LD A,28H 3E 28
Load Register A with 28H, which is the JR Z opcode.
52C7
LD (552FH),A 32 2F 55
SELF-MODIFYING: Store 28H (JR Z) at 552FH. This controls semicolon comment recognition.
52CA
LD (559EH),A 32 9E 55
SELF-MODIFYING: Store 28H at 559EH. This controls the conditional assembly state machine.
52CDH - Cross-Reference Initialization
This section initializes the cross-reference table tracking variables and prepares for adding references to the current symbol.
52CD
XOR A AF
Clear Register A to zero. This will initialize various counters and flags.
52CE
LD (7636H),A 32 36 76
Store 00H at 7636H, clearing the multiply-defined flag. This flag is set if a symbol is defined more than once.
52D1
LD (764DH),A 32 4D 76
Store 00H at 764DH, resetting the cross-reference entry counter. This counts how many references to the current symbol have been recorded.
52D4
Load HL with 763DH, the start address of the cross-reference buffer.
52D7
LD (763BH),HL 22 3B 76
Store the buffer start address at 763BH. This write pointer tracks where the next cross-reference entry will be stored.
52DAH - External Reference Check and Line Processing Entry
This section checks if the symbol is an external reference and, if not, adds it to the cross-reference table. It then transfers control to the main line processing loop.
52DA
LD HL,(7650H) 2A 50 76
Load HL with the symbol pointer from 7650H.
52DD
DEC HL 2B
Decrement HL to point to the attributes byte.
52DE
LD A,(HL) 7E
Load Register A with the symbol attributes byte.
52DF
AND 80H E6 80
Mask for bit 7, the external reference flag. If set, this is an external symbol that shouldn't be cross-referenced locally.
52E1
If the Z FLAG is set (bit 7 clear = local symbol), CALL 559CH to add a cross-reference entry for this symbol usage.
52E4
Load HL with 7700H, the address of the extended work area for line processing.
52E7
JUMP to 550CH to enter the main source line processing loop.
52EAH - Pass Completion Check
This section is reached at the end of processing. It checks if we've completed both passes and either starts Pass 2 or continues to final output.
52EA
LD A,(559EH) 3A 9E 55
Load Register A with the conditional assembly state from 559EH.
52ED
CP 28H FE 28
Compare A with 28H (JR Z opcode, the initial state). This checks if conditional assembly is in its base state.
52EF
If the Z FLAG is set (state is 28H), JUMP to 5211H to start the next pass by re-initializing I/O.
52F2
LD A,28H 3E 28
Load Register A with 28H to reset the conditional state.
52F4
LD (559EH),A 32 9E 55
Store 28H at 559EH, resetting the conditional assembly state machine.
52F7
LD HL,55EAH 21 EA 55
Load HL with the address of the symbol attributes byte at 55EAH.
52FA
RES 6,(HL) CB B6
SELF-MODIFYING: Clear bit 6 of the attributes byte. This clears the external reference pending flag before Pass 2.
52FC
JUMP to 5500H to continue with the main processing loop for Pass 2.
5300H - Data Section: Variables and Working Storage
This memory region (5300H-54FFH) contains no executable code. It is used for variable storage, configuration data, pointers, counters, and the system stack. The disassembler skipped this area because it contains data, not instructions. Below are all identified variables with their purposes, organized by functional group.
System Configuration Block (5300H-5326H)
This area contains configuration values that control assembler behavior, initialized at startup and modified during assembly operations.
5300
DEFB 01H 01
CMDCODE - Current command code. Written at 5DD6H with command identifier. Value 01H = default/initial state. Read at various command dispatch points.
5301
DEFS 16 (16 bytes)
CMDPARAM - Command parameter buffer. Used as destination at 5DC8H (LD DE,5301H) for storing parsed command parameters.
5311
DEFW 0000H 00 00
SRCPTR - Source text pointer (2 bytes). Points to current position in source text buffer. Written at 591AH, 5CB0H, 5E4FH, 5EE7H, 5EFFH, 5F83H, 64DDH. Read at 5D16H, 5D57H, 5DDEH, 5E41H, 5E7AH, 6170H, 6E33H.
5313
DEFW 0000H 00 00
HIMEM - High memory limit pointer (2 bytes). Set from (4049H) at 589FH. Read at 5DABH to determine available memory.
5315
DEFW 0000H 00 00
SYMTAB - Symbol table base/end pointer (2 bytes). Critical variable - controls symbol table operations. High byte = pass number, low byte = flags. Read at 5200H (entry), 590DH, 5C0CH, 5C86H, 5DAEH, 5DEAH, 5E3DH, 5E8CH, 5EEAH, 5F35H, 5F97H, 64D0H, 65B4H, 6F4EH, 7092H. Written at 588DH (init), 5C95H, 5F1BH, 5FA6H, 6F6EH.
5317
DEFW 000AH 0A 00
TABSIZE - Tab size or line spacing (2 bytes). Initialized to 000AH (10 decimal) at 58A5H. Read at 5C2CH, 5C47H. Written at 5CD6H.
5319
DEFW 0000H 00 00
OBJPTR - Object code output pointer (2 bytes). Written at 5CDFH. Read at 5D68H, 5E87H, 5EFCH.
531B
DEFW 0000H 00 00
ORGADDR - Current ORG address (2 bytes). Written at 5D02H. Read at 5E97H, 5EA5H, 5EDBH.
531D
DEFW 0000H 00 00
LOCPTR - Location counter pointer (2 bytes). Written at 5CABH, 5CFBH, 5EDEH, 5F04H, 64EEH. Read at 5C61H, 64D4H, 5E90H, 5EC6H, 5ED7H.
531F
DEFW 0000H 00 00
HEXPTR - Intel HEX output pointer (2 bytes). Read at 6E75H, written at 6E7DH. Used during object code generation.
5321
DEFW 0000H 00 00
RECPTR - HEX record pointer (2 bytes). Written at 6EA1H, 70A9H. Read at 6EB3H.
5323
DEFB 00H 00
CHECKSUM - HEX record checksum byte. Address loaded at 6E8FH, 6ECBH. Used in Intel HEX record generation.
5324
DEFB 00H 00
RECLEN - HEX record length counter. Used as destination at 6EA5H (LD DE,5324H). Read at 6EC5H.
5327
DEFS 129 (129 bytes)
LINEBUF - Source line input buffer (129 bytes, 5327H-53A7H). Address loaded at 5B41H, 5BADH, 5CBEH, 5FDDH. Used with (53A8H) as buffer pointer. Maximum line length accommodated.
53A8H - Buffer Pointers and State Variables
These variables track buffer positions and parsing state during source line processing.
53A8
DEFW 0000H 00 00
BUFPTR - Current buffer pointer (2 bytes). Written at 5B44H, 5BD2H, 5BF9H, 64E7H. Read at 5BCDH, 5BF5H, 61DAH, 6F75H. Tracks position in LINEBUF during parsing.
53AA
DEFB 00H 00
SCANFLG - Scanner state flag (1 byte). Written at 5B76H, 603EH, 64B7H, 64E3H, 6FD7H. Read at 5C8CH, 6F78H, 6FD3H. Address loaded at 5BC2H, 5BFCH. Controls tokenizer behavior.
53AB
DEFW 0000H 00 00
EXPRVAL - Expression evaluation result (2 bytes). Written at 611CH. Read at 5F5DH, 612CH. Holds computed value from expression parser.
53AD
DEFB 00H 00
EXPRFLG - Expression type flags (1 byte). Address loaded at 6107H. Read at 5F60H, 6124H. Indicates expression attributes (relocatable, external, etc.).
53AE
DEFW 0000H 00 00
CODEPTR - Generated code pointer (2 bytes). Written at 64C5H, 6B12H, 6B44H, 6B7CH, 6BA0H, 6BD3H, 6EB0H. Read at 6E7AH, 6B39H. Points to where next generated byte goes.
53B0
DEFB 00H 00
OPCODE - Current opcode byte (1 byte). Written at 64CDH. Address loaded at 66FEH, 6A51H, 6AFAH. Used as source at 6E65H (LD BC,53B0H). Holds instruction opcode being assembled.
53B1
DEFB 00H 00
OPRND1 - Operand byte 1 / working byte (1 byte). Heavily used - written at 6585H, 688AH, 68AEH, 6903H, 6926H, 6957H, 6A18H, 6A68H, 6B30H, 6B60H. Address loaded at 6661H, 668BH, 6696H, 6723H, 6738H, 6757H, 6790H, 67B7H, 67DAH, 6980H. Written as word at 6B6AH. Primary working register for instruction encoding.
53B2
DEFB 00H 00
OPRND2 - Operand byte 2 (1 byte). Address loaded at 67B0H. Second byte of multi-byte operand.
53B4
DEFB 00H 00
INSTLEN - Instruction length counter (1 byte). Written at 688FH, 69F7H, 6720H, 6B07H, 6B4BH. Read at 6E22H, 6E68H, 670BH. Written at 6710H. Address loaded at 64BAH, 66B5H. Tracks bytes generated for current instruction.
53B6
DEFW 0000H 00 00
LSTPTR - Listing output pointer (2 bytes). Read at 62CAH, 65A2H, 6853H, 6B0EH. Written at 64C2H, 6B16H, 6B47H, 6B79H.
53B8
DEFW 0000H 00 00
MACPTR - Macro expansion pointer (2 bytes). Read at 6153H, written at 6157H. Used during macro processing.
53BA
DEFB 00H 00
ERRFLG - Error flag (1 byte). Written at 58B4H (init), 72A2H. Address loaded at 58E5H, 593BH, 5F2DH. Indicates assembly errors detected.
53BB
DEFB FFH FF
LSTFLG - Listing enable flag (1 byte). Written at 5D97H. Address loaded at 5B32H, 5B8FH. FFH = listing enabled.
53BC
DEFB 00H 00
PASSFLAG - Pass indicator flag (1 byte). Written at 58B7H (init), 5E30H, 6199H, 61A4H. Tracks which assembly pass is active.
53BD
DEFB 00H 00
CONDFLG - Conditional assembly flag (1 byte). Address loaded at 651CH. Controls IF/ELSE/ENDIF processing.
53BE
DEFB 00H 00
HEXFLG - HEX output mode flag (1 byte). Read at 6BAFH, 6E80H. Written at 6E99H, 6EDFH. Controls Intel HEX generation.
53BF
DEFB 00H 00
OBJFLG - Object output flag (1 byte). Written at 6178H. Address loaded at 649CH. Controls object code output.
53C0
DEFB 00H 00
OUTMODE - Output mode selector (1 byte). Read at 615CH, 6B3CH, 6B86H, 6BA8H, 7294H. Address loaded at 6DF5H. Selects disk/tape/screen output.
53C1
DEFW 0000H 00 00
SYMPTR - Symbol table working pointer (2 bytes). Written at 62A5H, 631DH. Read at 62B6H. Used during symbol table operations.
53C3
DEFW 0000H 00 00
CURSYM - Current symbol entry pointer (2 bytes). Critical variable. Read at 5231H (main search), 65A8H, 65B8H, 708FH. Written at 65CDH. Points to symbol table entry being processed.
53C5
DEFB 00H 00
RELFLG - Relocation flag (1 byte). Written at 58EEH (init). Read at 5E58H. Address loaded at 5E1CH. Controls relocatable code handling.
53C6H - Reserved/Unused Area
The area from 53C6H to 54FDH appears to be reserved space or used as scratch storage. No direct references were found in the code to specific addresses in this range.
53C6-54FD
DEFS 312 (312 bytes)
RESERVED - Unused/reserved area. May be used as dynamic work space, macro expansion area, or symbol table overflow.
54FEH - System Stack
The top of the data area is used as the system stack. The stack grows downward from 54FEH.
54FE
DEFW 0000H 00 00
STACK - System stack top (2 bytes). Stack pointer set to 54FEH at 58B0H (initialization), 58DAH (error recovery), and 6496H (abort handler). Stack grows downward into the reserved area.
5500H - Source Line Scanner Entry
This is the main entry point for source line scanning. It initializes I/O, loads the symbol table base pointer, and enters the main scanning loop. The scanner processes source lines character by character, identifying labels, opcodes, operands, and comments.
5500
Call the I/O initialization routine at 5937H to prepare for reading source lines.
5503
LD HL,(7652H) 2A 52 76
Load HL with the symbol table base address from 7652H. This is the starting point for symbol table traversal.
5506
JUMP to 550CH to enter the main line scanning loop.
5508
LD E,B 58
[SKIP TO NEXT LINE] Load E with B (remaining character count). This is the entry point when skipping the rest of a line (comment found).
5509
LD D,00H 16 00
Clear D, so DE now contains the number of characters to skip.
550B
ADD HL,DE 19
Add DE to HL, advancing the pointer past the remaining characters on this line.
550CH - Main Line Processing Loop
This section checks if we've reached the end of source and processes each line. It validates the current position, saves it for reference tracking, and begins field parsing.
550C
LD A,H 7C
[MAIN LOOP] Load Register A with the high byte of HL (current position).
550D
CP 00H FE 00
Compare A with 00H. If high byte is non-zero, we're still within valid memory range.
550F
If the NZ FLAG is set (H not zero), JUMP to 5514H to continue processing.
5511
LD A,L 7D
Load Register A with the low byte of HL.
5512
CP 00H FE 00
Compare A with 00H. If HL = 0000H, we've reached end of source.
5514
If the NC FLAG is set (HL >= some threshold), JUMP to 52EAH to handle end of source / pass completion.
5517
LD (7634H),HL 22 34 76
Save the current line position at 7634H. This is used for cross-reference tracking and error reporting.
551A
INC HL 23
Increment HL to skip past the first byte of the line record.
551B
INC HL 23
Increment HL again. Now HL points to the line length byte.
551C
LD B,(HL) 46
Load B with the line length (number of characters in this source line).
551D
INC HL 23
Increment HL to point to the first character of the source line.
551E
INC B 04
Increment B. This and the following DEC test if the line is empty (length was 0).
551F
DEC B 05
Decrement B back. If original B was 0, Z flag is now set indicating an empty line.
5520
If the Z FLAG is set (empty line), JUMP back to 550CH to process the next line.
5522H - Label Field Recognition
This section checks if the current character matches a symbol and processes label definitions. It handles the self-modifying branch that controls whether we're in label or opcode scanning mode.
5522
LD A,(HL) 7E
Load Register A with the current character from the source line.
5523
CP C B9
Compare A with Register C (which holds the first character of the current symbol being searched).
5524
SELF-MODIFIED: If NZ (no match), jump to 552DH. The opcode byte at 5524H is modified between 20H (JR NZ) and 18H (JR) to control label vs opcode scanning.
5526
First characters match! Call symbol comparison routine at 5684H to check if the full symbol matches.
5529
If the Z FLAG is set (symbol matches), CALL 559CH to add a cross-reference entry for this symbol usage.
552C
LD A,(HL) 7E
Reload Register A with the current character (may have changed during comparison).
552DH - Comment and Whitespace Detection
This section checks for comment markers and whitespace to determine field boundaries. It handles semicolons, tabs, and spaces that separate assembly language fields.
552D
CP 3BH FE 3B
Compare A with 3BH (ASCII ; semicolon). Semicolon marks the start of a comment.
552F
SELF-MODIFIED: If semicolon found, jump to 5508H to skip rest of line. The opcode at 552FH is modified between 28H (JR Z) and 18H (JR) to control comment recognition.
5531
CP 09H FE 09
Compare A with 09H (ASCII TAB). Tab is a field separator.
5533
If the Z FLAG is set (TAB found), JUMP to 554DH to skip whitespace and find next field.
5535
CP 20H FE 20
Compare A with 20H (ASCII SPACE). Space is also a field separator.
5537
If the Z FLAG is set (SPACE found), JUMP to 554DH to skip whitespace.
5539
INC HL 23
Increment HL to point to the next character.
553A
Decrement B and if NZ, JUMP back to 552CH to continue scanning this field.
553C
End of line reached. JUMP to 550CH to process the next source line.
553EH - Whitespace Skip Loop
This section skips over whitespace (spaces and tabs) between fields. It continues until it finds a non-whitespace character or reaches end of line.
553E
LD A,(HL) 7E
[WHITESPACE LOOP] Load Register A with the current character.
553F
CP 3BH FE 3B
Compare A with 3BH (semicolon). Check for comment start.
5541
If the Z FLAG is set (semicolon), JUMP to 5508H to skip rest of line.
5543
If the NC FLAG is set (char >= semicolon), JUMP to 555FH. Found a non-whitespace character.
5545
CP 20H FE 20
Compare A with 20H (SPACE).
5547
If the Z FLAG is set (SPACE), JUMP to 554DH to skip this space.
5549
CP 09H FE 09
Compare A with 09H (TAB).
554B
If the NZ FLAG is set (not TAB), JUMP to 555FH. Found non-whitespace content.
554D
INC HL 23
[SKIP WHITESPACE] Increment HL to next character.
554E
Decrement B and if NZ, JUMP back to 553EH to check next character.
5550
End of line. JUMP to 550CH for next line.
5552H - Operand Field Scanner
This section scans the operand field, checking for whitespace that would indicate the end of the operand and start of a comment field.
5552
LD A,(HL) 7E
[OPERAND SCAN] Load Register A with current character.
5553
CP 09H FE 09
Compare A with 09H (TAB).
5555
If the Z FLAG is set (TAB), JUMP to 5596H to advance to comment field.
5557
CP 20H FE 20
Compare A with 20H (SPACE).
5559
If the Z FLAG is set (SPACE), JUMP to 5596H to advance to comment field.
555B
CP 3BH FE 3B
Compare A with 3BH (semicolon).
555D
If the Z FLAG is set (semicolon), JUMP to 5508H to skip rest of line.
555F
INC HL 23
Increment HL to next character.
5560
Decrement B and if NZ, JUMP back to 5552H to continue operand scan.
5562
End of line. JUMP to 550CH for next line.
5564H - Symbol Character Validation
This section validates characters that can appear in symbol names (A-Z, 0-9). It distinguishes between letters, digits, and symbol terminators to properly parse identifiers.
5564
LD A,(HL) 7E
[SYMBOL VALIDATION] Load Register A with current character.
5565
CP 41H FE 41
Compare A with 41H (ASCII A).
5567
If the C FLAG is set (char < 'A'), JUMP to 558CH to check for digit or terminator.
5569
CP 5BH FE 5B
Compare A with 5BH (ASCII '[', one past 'Z').
556B
If the NC FLAG is set (char >= '['), JUMP to 5596H. Character is not a valid letter.
556D
CP C B9
Compare A with Register C (first char of symbol being searched).
556E
If the NZ FLAG is set (no match), JUMP to 557FH to continue scanning.
5570
First characters match! Call full symbol comparison at 5684H.
5573
If the Z FLAG is set (symbol matches), CALL 5646H to record cross-reference for this occurrence.
5576
LD A,(HL) 7E
Reload Register A with current character.
5577
CP 41H FE 41
Compare A with 41H ('A').
5579
If the C FLAG is set (char < 'A'), JUMP to 5584H to check for digit.
557B
CP 5BH FE 5B
Compare A with 5BH ('[').
557D
If the NC FLAG is set (char >= '['), JUMP to 5596H. End of symbol name.
557F
INC HL 23
Increment HL to next character.
5580
Decrement B and if NZ, JUMP back to 5576H to continue symbol scan.
5582
End of line. JUMP to 550CH for next line.
5584H - Digit Check in Symbol Names
This section checks if a character is a digit (0-9), which is valid in symbol names after the first character but cannot start a symbol.
5584
CP 30H FE 30
Compare A with 30H (ASCII 0).
5586
If the C FLAG is set (char < '0'), JUMP to 558CH. Not a digit.
5588
CP 3AH FE 3A
Compare A with 3AH (ASCII ':', one past '9').
558A
If the C FLAG is set (char < ':'), character is a valid digit. JUMP to 557FH to continue.
558C
CP 3BH FE 3B
Compare A with 3BH (semicolon).
558E
If the Z FLAG is set (semicolon), JUMP to 5508H to skip rest of line (comment).
5591
CP 27H FE 27
Compare A with 27H (ASCII ' apostrophe). Apostrophe can also start a comment in some contexts.
5593
If the Z FLAG is set (apostrophe), JUMP to 5508H to skip rest of line.
5596
INC HL 23
Increment HL to next character position.
5597
Decrement B and if NZ, JUMP back to 5564H to continue validation loop.
5599
End of line. JUMP to 550CH for next source line.
559CH - Cross-Reference Entry Handler
This subroutine adds a cross-reference entry for the current symbol occurrence. It preserves registers, checks the current mode, and either prints the reference or records it in the cross-reference table.
559C
PUSH HL E5
Save HL (current source position) on the stack.
559D
PUSH BC C5
Save BC (character counter) on the stack.
559E
SELF-MODIFIED: If Z flag is set, JUMP to 55A9H for first definition handling. The opcode at 559EH is modified to control conditional assembly behavior.
55A0
LD HL,(7634H) 2A 34 76
Load HL with the current line pointer from 7634H.
55A3
Call 56D3H to output the line number reference.
55A6
POP BC C1
Restore BC from stack.
55A7
POP HL E1
Restore HL from stack.
55A8
RET C9
Return to caller.
55A9H - Symbol Definition Output
This section handles the first definition of a symbol, outputting the symbol name, its value, and setting up for cross-reference tracking. It formats the symbol table listing output.
55A9
LD HL,(7634H) 2A 34 76
Load HL with the line pointer from 7634H.
55AC
LD (7652H),HL 22 52 76
Store HL at 7652H, saving the definition line for this symbol.
55AF
LD HL,(7650H) 2A 50 76
Load HL with the symbol name pointer from 7650H.
55B2
LD A,(55EAH) 3A EA 55
Load Register A with the symbol attributes from 55EAH.
55B5
AND 07H E6 07
Mask to get the symbol name length (bits 0-2).
55B7
LD B,A 47
Copy length to B for use as counter.
55B8
PUSH BC C5
Save BC on stack.
55B9
Call 56B6H to output the symbol name (B characters from HL).
55BD
LD A,07H 3E 07
Load A with 07H (maximum symbol length).
55BF
SUB B 90
Subtract actual length from 7. Result is padding spaces needed.
55C0
LD B,A 47
Copy padding count to B.
55C1
Call 56CDH to output B spaces for column alignment.
55C4
INC HL 23
Increment HL past the symbol name.
55C5
Call 6E4EH to output hex digit (high nibble of value).
55C8
DEC HL 2B
Decrement HL to point to next byte of value.
55C9
Call 6E4EH to output hex digit (low nibble of value).
55CC
Call 56C8H to output a space separator.
55CFH - External Symbol Check and Output
This section checks if the symbol is external (bit 7 of attributes set) and outputs appropriate text - either "UNDEF***" for undefined symbols or the symbol's value.
55CF
LD A,(55EAH) 3A EA 55
Load Register A with the symbol attributes.
55D2
AND 80H E6 80
Mask for bit 7 (external/undefined flag).
55D4
If the NZ FLAG is set (external symbol), JUMP to 55DEH for external handling.
55D6
Load HL with address 760DH, pointing to "UNDEF***" message string.
55D9
Call 56BEH to output the "UNDEF" message.
55DC
JUMP to 55E9H to continue with cross-reference output.
55DE
LD HL,(7634H) 2A 34 76
Load HL with the line pointer (external symbol's reference location).
55E1
Call 56E7H to output the symbol value in hex.
55E4
LD B,02H 06 02
Load B with 02H (two spaces for padding).
55E6
Call 56CDH to output 2 spaces.
55E9H - Multiply Defined Check
This section checks if the symbol has been multiply defined and processes the cross-reference list. It outputs all line references for the symbol.
55E9
LD A,00H 3E 00
SELF-MODIFIED at 55EAH: Load A with the attributes byte. The 00H is overwritten by the actual attributes value at runtime.
55EB
AND 40H E6 40
Mask for bit 6 (multiply defined flag).
55ED
If the NZ FLAG is set (multiply defined), JUMP to 562EH to output "MULTIPLY DEFINED" message.
55F0
LD A,07H 3E 07
Load A with 07H (column position for cross-references).
55F2
LD (7633H),A 32 33 76
Store 07H at 7633H, setting the column counter.
55F5
Load HL with 763DH, the cross-reference table start.
55F8
LD A,(764DH) 3A 4D 76
Load A with the cross-reference entry count from 764DH.
55FB
OR A B7
Test if count is zero.
55FC
If the Z FLAG is set (no references), JUMP to 560EH to skip reference output.
55FFH - Cross-Reference Output Loop
This loop iterates through all cross-reference entries for the current symbol and outputs each line number reference.
55FF
PUSH AF F5
[XREF LOOP] Save AF (entry count) on stack.
5600
LD E,(HL) 5E
Load E with the low byte of the line pointer.
5601
INC HL 23
Increment HL to high byte.
5602
LD D,(HL) 56
Load D with the high byte. DE now contains the line reference pointer.
5603
INC HL 23
Increment HL to next cross-reference entry.
5604
PUSH HL E5
Save HL (next entry pointer) on stack.
5605
EX DE,HL EB
Exchange so HL contains the line reference.
5606
Call 56D3H to output the line reference.
5609
POP HL E1
Restore HL (next entry pointer).
560A
POP AF F1
Restore AF (entry count).
560B
DEC A 3D
Decrement the entry count.
560C
If the NZ FLAG is set (more entries), JUMP back to 55FFH for next reference.
560EH - Reset Self-Modifying Code
After processing a symbol's references, this section resets the self-modifying code locations to their default values for the next symbol.
560E
LD A,18H 3E 18
Load A with 18H (JR opcode - unconditional jump).
5610
LD (5524H),A 32 24 55
SELF-MODIFYING: Store 18H at 5524H, setting the branch to unconditional for opcode field processing.
5613
LD A,28H 3E 28
Load A with 28H (JR Z opcode - conditional jump).
5615
LD (552FH),A 32 2F 55
SELF-MODIFYING: Store 28H at 552FH, restoring conditional comment checking.
5618
LD A,(7636H) 3A 36 76
Load A with the multiply-defined flag from 7636H.
561B
OR A B7
Test if any multiply-defined symbols were found.
561C
POP BC C1
Restore BC from stack.
561D
POP HL E1
Restore HL from stack.
561E
RET Z C8
If the Z FLAG is set (no multiply-defined), return normally.
561F
POP HL E1
Pop extra return address (unwinding stack for error path).
5620
LD B,A 47
Copy multiply-defined count to B.
5621
LD HL,(7637H) 2A 37 76
Load HL with the saved source position from 7637H.
5624
LD (7634H),HL 22 34 76
Store at 7634H, restoring the line pointer.
5627
LD HL,(7639H) 2A 39 76
Load HL with the saved symbol pointer from 7639H.
562A
XOR A AF
Clear A to zero.
562B
JUMP to 5573H to continue processing the multiply-defined symbol.
562EH - Multiply Defined Error Output
This section outputs the "MULTIPLY DEFINED AT" error message when a symbol has been defined more than once.
562E
Load HL with 75F8H, pointing to "MULTIPLY DEFINED AT" message.
5631
Call 56BEH to output the error message.
5634
LD A,20H 3E 20
Load A with 20H (JR NZ opcode).
5636
LD (559EH),A 32 9E 55
SELF-MODIFYING: Store 20H at 559EH, changing the conditional branch behavior.
5639
LD A,18H 3E 18
Load A with 18H (JR opcode).
563B
LD (552FH),A 32 2F 55
SELF-MODIFYING: Store 18H at 552FH.
563E
LD A,04H 3E 04
Load A with 04H.
5640
LD (7633H),A 32 33 76
Store 04H at 7633H, adjusting the column counter.
5643
JUMP to 55A6H to restore registers and return.
5646H - Add Cross-Reference Entry
This subroutine adds a new cross-reference entry for the current symbol. It checks if there's room in the table and handles overflow conditions.
5646
PUSH HL E5
Save HL on stack.
5647
PUSH BC C5
Save BC on stack.
5648
LD A,(5524H) 3A 24 55
Load A with the self-modified opcode from 5524H.
564B
CP 18H FE 18
Compare A with 18H (JR opcode). If equal, we're in definition mode, not reference mode.
564D
If the Z FLAG is set (definition mode), JUMP to 55A0H - don't add reference for definition.
5650
LD A,(764DH) 3A 4D 76
Load A with the current reference count.
5653
INC A 3C
Increment the count (testing new count).
5654
CP 09H FE 09
Compare with 09H. Maximum is 8 entries (0-8).
5656
If the NC FLAG is set (count >= 9), JUMP to 566CH for overflow handling.
5658
LD (764DH),A 32 4D 76
Store the incremented count at 764DH.
565B
LD HL,(763BH) 2A 3B 76
Load HL with the cross-reference write pointer.
565E
LD DE,(7634H) ED 5B 34 76
Load DE with the current line pointer.
5662
LD (HL),E 73
Store low byte of line pointer.
5663
INC HL 23
Increment write pointer.
5664
LD (HL),D 72
Store high byte of line pointer.
5665
INC HL 23
Increment write pointer.
5666
LD (763BH),HL 22 3B 76
Save the updated write pointer.
5669
JUMP to 55A6H to restore registers and return.
566CH - Cross-Reference Overflow Handler
When the cross-reference table for a symbol is full (8 entries), this section saves the overflow information for later output on a continuation line.
566C
LD (7639H),HL 22 39 76
Save HL at 7639H for overflow continuation.
566F
LD HL,(7634H) 2A 34 76
Load HL with the current line pointer.
5672
LD (7637H),HL 22 37 76
Save at 7637H as the overflow start pointer.
5675
LD A,B 78
Load A with B (character counter).
5676
LD (7636H),A 32 36 76
Store at 7636H as the overflow flag/count.
5679
LD A,18H 3E 18
Load A with 18H (JR opcode).
567B
LD (552FH),A 32 2F 55
SELF-MODIFYING: Store 18H at 552FH to change branch behavior.
5680
POP AF F1
Pop return address (discarding it).
5681
JUMP to 5508H to skip rest of line and continue with overflow handling later.
5684H - Symbol Name Comparison
This subroutine compares a symbol name in the source with the current symbol being searched. It performs character-by-character comparison and validates that names match completely.
5684
LD DE,(7650H) ED 5B 50 76
Load DE with the search symbol pointer from 7650H.
5688
LD A,00H 3E 00
SELF-MODIFIED at 5689H: Load A with the symbol end position. The 00H is overwritten at runtime.
568A
CP E BB
Compare A with E (low byte of current position). Checks if we've reached end of symbol.
568B
If the Z FLAG is set (at end), JUMP to 5699H for end-of-symbol handling.
568D
INC DE 13
Increment DE to next character in search symbol.
568E
INC HL 23
Increment HL to next character in source.
568F
DEC B 05
Decrement B (remaining source characters).
5690
If the Z FLAG is set (no more source chars), JUMP to 56B2H to handle partial match.
5693
LD A,(DE) 1A
Load A with character from search symbol.
5694
CP (HL) BE
Compare with character from source.
5695
If the Z FLAG is set (match), JUMP back to 5688H for next character.
5698
RET C9
Characters don't match - return with NZ flag set.
5699H - End of Symbol Validation
When we've matched all characters of the search symbol, this section validates that the source symbol also ends (isn't longer than the search symbol).
5699
LD A,B 78
Load A with B (remaining source character count).
569A
DEC A 3D
Decrement A. If B was 1, we're at the last character.
569B
RET Z C8
If the Z FLAG is set (exact match at end), return with Z set = match found.
569C
INC HL 23
Increment HL to next source character.
569D
DEC B 05
Decrement remaining count.
569E
LD A,(HL) 7E
Load A with the next source character.
569F
CP 5BH FE 5B
Compare with 5BH ('['). Check if it's past 'Z'.
56A1
If the NC FLAG is set (char >= '['), JUMP to 56AFH - not alphanumeric.
56A3
CP 41H FE 41
Compare with 41H ('A').
56A5
If the NC FLAG is set (char >= 'A'), JUMP to 56B0H - letter found, source is longer.
56A7
CP 3AH FE 3A
Compare with 3AH (':').
56A9
If the NC FLAG is set (char >= ':'), JUMP to 56AFH - not a digit.
56AB
CP 30H FE 30
Compare with 30H ('0').
56AD
If the NC FLAG is set (char >= '0'), JUMP to 56B0H - digit found, source is longer.
56AF
XOR A AF
Clear A and set Z flag = match found (source symbol ended).
56B0
OR A B7
Set flags based on A. If A is non-zero, NZ = no match.
56B1
RET C9
Return with Z/NZ indicating match result.
56B2
POP AF F1
Pop return address (discarding - stack unwind).
56B3
JUMP to 550CH to continue with next line processing.
56B6H - Output Symbol Name
This subroutine outputs a symbol name character by character. It outputs B characters starting at address HL.
56B6
LD A,(HL) 7E
[OUTPUT LOOP] Load A with character at (HL).
56B7
Call 5939H to output the character.
56BA
INC HL 23
Increment HL to next character.
56BB
Decrement B and if NZ, JUMP back to 56B6H for next character.
56BD
RET C9
Return when all characters output.
56BEH - Output Message String
This subroutine outputs a null-terminated (03H) message string starting at address HL.
56BE
LD A,(HL) 7E
[MESSAGE LOOP] Load A with character at (HL).
56BF
CP 03H FE 03
Compare with 03H (ETX - end of text terminator).
56C1
RET Z C8
If the Z FLAG is set (terminator found), return.
56C2
Call 5939H to output the character.
56C5
INC HL 23
Increment HL to next character.
56C6
JUMP back to 56BEH for next character.
56C8H - Output Spaces
These subroutines output one or more space characters for formatting purposes.
56C8
LD A,20H 3E 20
Load A with 20H (ASCII SPACE).
56CA
JUMP to 5939H to output one space and return.
56CD
[MULTIPLE SPACES] Call 56C8H to output one space.
56D0
Decrement B and if NZ, JUMP back to 56CDH for more spaces.
56D2
RET C9
Return when B spaces have been output.
56D3H - Output Line Reference
This subroutine outputs a cross-reference line number with proper column tracking and line wrapping.
56D3
LD A,(7633H) 3A 33 76
Load A with the column counter from 7633H.
56D6
OR A B7
Test if column counter is zero.
56D7
If the NZ FLAG is set (not at column 0), JUMP to 56E3H to output normally.
56D9
At column 0 - call 5937H to start new line.
56DC
LD B,14H 06 14
Load B with 14H (20 decimal) spaces for indentation.
56DE
Call 56CDH to output 20 spaces for indent.
56E1
LD A,07H 3E 07
Load A with 07H (reset column counter to 7).
56E3
DEC A 3D
Decrement the column counter.
56E4
LD (7633H),A 32 33 76
Store updated counter at 7633H.
56E7H - Output 16-bit Value in Hex
This subroutine loads a 16-bit value from memory and outputs it in hexadecimal format.
56E7
LD E,(HL) 5E
Load E with the low byte of value.
56E8
INC HL 23
Increment HL to high byte.
56E9
LD D,(HL) 56
Load D with the high byte. DE now contains the 16-bit value.
56EA
EX DE,HL EB
Exchange so HL contains the value to output.
56EB
JUMP to 5D75H to output HL as 4 hex digits.
56EEH - Offset Calculation Helper
This helper routine calculates an offset by adding 80H to DE and returning the high byte result.
56EE
PUSH HL E5
Save HL on stack.
56EF
LD HL,0080H 21 80 00
Load HL with 0080H (128 bytes offset).
56F2
ADD HL,DE 19
Add DE to HL.
56F3
LD A,H 7C
Load A with the high byte of result.
56F5
JUMP to 6672H for further processing.
56F8H - DOS Vector Patching
This section patches the NEWDOS/80 jump vector to intercept system calls and redirect to the assembler's command processor.
56F8
LD A,C3H 3E C3
Load A with C3H (JP opcode).
56FA
LD (4312H),A 32 12 43
Store JP opcode at 4312H, patching the DOS vector.
56FD
JUMP to 402DH (NEWDOS/80 command processor entry).
5700H - Character Output Wrapper
This section contains character output routines that handle special control characters and formatting. It outputs a character followed by an optional control code for cursor positioning or formatting.
5700
Call 5939H to output the character in Register A.
5703
LD A,0EH 3E 0E
Load A with 0EH (Shift Out control code - enables alternate character set).
5705
JUMP to 5939H to output the control code and return.
5708H - Exit to NEWDOS/80
This routine clears the error flag and returns control to the NEWDOS/80 operating system via the warm start vector.
5708
XOR A AF
Clear Register A to zero.
5709
LD (762EH),A 32 2E 76
Store 00H at 762EH, clearing the error flag.
570C
JUMP to 01F8H, the NEWDOS/80 warm start entry point. This returns to DOS.
570FH - Display Control and Memory Banking
This section handles Model III memory banking via port FFH and cursor position calculations for screen output.
570F
If the Z FLAG is set, JUMP to 5763H for alternate screen handling.
5711
OUT (FFH),A D3 FF
Output Register A to port FFH (Model III memory/video banking register).
5713
INC HL 23
Increment HL (screen position pointer).
5714
LD A,L 7D
Load A with the low byte of screen position.
5715
AND FEH E6 FE
Mask off bit 0, aligning to even address.
5717
LD L,A 6F
Store aligned value back in L.
5718
RET C9
Return with HL pointing to aligned screen position.
5719H - Control Character Dispatcher
This routine dispatches control characters to their appropriate handlers. It checks for various control codes (backspace, linefeed, carriage return, cursor controls) and jumps to the corresponding handler routine.
5719
OR A B7
Test Register A (control character code).
571A
RET Z C8
If A is zero (NUL), return immediately - no action needed.
571B
CP 05H FE 05
Compare A with 05H (ENQ - Enquiry).
571D
If equal, JUMP to 56A9H for ENQ handling.
571F
LD DE,5688H 11 88 56
Load DE with return address 5688H. This sets up a common return point for all control handlers.
5722
PUSH DE D5
Push return address onto stack.
5723
CP 08H FE 08
Compare A with 08H (BS - Backspace).
5725
If equal, JUMP to 56E1H for backspace handling.
5727
CP 0AH FE 0A
Compare A with 0AH (LF - Line Feed).
5729
If equal, JUMP to 5781H for line feed handling.
572C
CP 0DH FE 0D
Compare A with 0DH (CR - Carriage Return).
572E
If equal, JUMP to 5781H for carriage return handling.
5731
CP 0EH FE 0E
Compare A with 0EH (SO - Shift Out).
5733
If equal, JUMP to 56C7H for shift out handling.
5735
CP 0FH FE 0F
Compare A with 0FH (SI - Shift In).
5737
If equal, JUMP to 56CEH for shift in handling.
5739
CP 17H FE 17
Compare A with 17H (ETB - End Transmission Block).
573B
If equal, JUMP to 5709H for exit to DOS.
573D
CP 18H FE 18
Compare A with 18H (CAN - Cancel).
573F
If equal, JUMP to 56EDH for cancel handling.
5741
CP 19H FE 19
Compare A with 19H (EM - End of Medium).
5743
If equal, JUMP to 56FFH for end of medium handling.
5745
CP 1AH FE 1A
Compare A with 1AH (SUB - Substitute / EOF).
5747
If equal, JUMP to 56FAH for EOF handling.
5749
CP 1BH FE 1B
Compare A with 1BH (ESC - Escape).
574B
If equal, JUMP to 5704H for escape sequence handling.
574D
CP 1CH FE 1C
Compare A with 1CH (FS - File Separator / Cursor Right).
574F
If equal, JUMP to 56D3H for cursor right.
5751
CP 1DH FE 1D
Compare A with 1DH (GS - Group Separator / Cursor Left).
5753
If equal, JUMP to 5770H for cursor left / scroll up.
5755
CP 1EH FE 1E
Compare A with 1EH (RS - Record Separator / Home).
5757
If equal, JUMP to 5790H for clear to end of line.
5759
CP 1FH FE 1F
Compare A with 1FH (US - Unit Separator / Clear).
575B
If equal, JUMP to 5799H for clear screen.
575D
RET C9
Unknown control code - return without action.
575EH - Write Character to Video RAM
This routine writes a character to video RAM at the current cursor position and advances the cursor, handling screen wrap and scrolling.
575E
LD (HL),A 77
Store the character (in A) at video RAM position (HL).
575F
INC HL 23
Increment HL to next screen position.
5760
LD A,(5228H) 3A 28 52
Load A with the display mode flag from 5228H.
5763
AND 08H E6 08
Mask for bit 3 (double-width mode flag).
5765
If the Z FLAG is set (normal width), JUMP to 5768H.
5767
INC HL 23
Double-width mode - skip extra position.
5768
LD A,H 7C
Load A with high byte of screen position.
5769
CP 40H FE 40
Compare with 40H. Video RAM ends at 3FFFH, so H >= 40H means past end of screen.
576B
RET NZ C0
If still within screen, return normally.
576C
LD DE,FFC0H 11 C0 FF
Load DE with FFC0H (-64 decimal). This wraps back one line (64 columns).
576F
ADD HL,DE 19
Add offset to wrap cursor back to last line.
5770H - Screen Scroll Up
This routine scrolls the screen up by one line using the LDIR block move instruction to copy video memory upward.
5770
PUSH HL E5
Save HL (cursor position) on stack.
5771
LD DE,3C00H 11 00 3C
Load DE with 3C00H, the start of video RAM.
5774
LD HL,3C40H 21 40 3C
Load HL with 3C40H, second line of video RAM (64 bytes past start).
5777
PUSH BC C5
Save BC on stack.
5778
LD BC,03C0H 01 C0 03
Load BC with 03C0H (960 bytes = 15 lines × 64 columns).
577B
LDIR ED B0
Block move - copy (HL) to (DE), incrementing both, BC times. This scrolls the screen up.
577E
EX DE,HL EB
Exchange - HL now points to last line (to be cleared).
577F
JUMP to 579AH to clear the bottom line.
5781H - Line Feed / Carriage Return Handler
This routine handles line feed (0AH) and carriage return (0DH) by moving the cursor to the start of the next line, scrolling if necessary.
5781
LD A,L 7D
Load A with low byte of cursor position.
5782
AND C0H E6 C0
Mask with C0H to get start of current line (clear lower 6 bits).
5784
LD L,A 6F
Store back in L - HL now points to start of line.
5785
PUSH HL E5
Save current line start.
5786
LD DE,0040H 11 40 00
Load DE with 0040H (64 - one line length).
5789
ADD HL,DE 19
Add to get start of next line.
578A
LD A,H 7C
Load A with high byte.
578B
CP 40H FE 40
Compare with 40H (past end of video RAM).
578D
If past end, JUMP to 5771H to scroll screen up.
578F
POP DE D1
Pop saved line start (discard - no scroll needed).
5790H - Clear to End of Line
This routine clears from the current cursor position to the end of the current line by filling with spaces.
5790
PUSH HL E5
Save cursor position on stack.
5791
LD D,H 54
Copy H to D.
5792
LD A,L 7D
Load A with L.
5793
OR 3FH F6 3F
OR with 3FH to set bits 0-5, giving end of current line.
5795
LD E,A 5F
Store in E. DE now points to end of line.
5796
INC DE 13
Increment DE to point past last character.
5797
JUMP to 579DH to start filling with spaces.
5799H - Clear Screen
This routine clears the entire screen by filling video RAM with spaces (20H).
5799
PUSH HL E5
Save cursor position.
579A
LD DE,4000H 11 00 40
Load DE with 4000H (end of video RAM + 1).
579D
LD (HL),20H 36 20
[CLEAR LOOP] Store 20H (space) at current position.
579F
INC HL 23
Increment to next position.
57A0
LD A,H 7C
Load A with high byte.
57A1
CP D BA
Compare with D (high byte of end).
57A2
If not equal, JUMP back to continue clearing.
57A4
LD A,L 7D
Load A with low byte.
57A5
CP E BB
Compare with E (low byte of end).
57A6
If not equal, continue clearing.
57A8
POP HL E1
Restore original cursor position.
57A9
RET C9
Return with screen cleared.
57AAH - Printer Output Handler
This section handles output to the printer, including form feed detection and page formatting.
57AA
LD A,C 79
Load A with C (character to print).
57AB
OR A B7
Test if character is zero.
57AC
If zero, JUMP to 57EEH to check printer ready.
57AE
CP 0BH FE 0B
Compare with 0BH (VT - Vertical Tab).
57B0
If equal, JUMP to 57BCH for vertical tab handling.
57B2
CP 0CH FE 0C
Compare with 0CH (FF - Form Feed).
57B4
If not form feed, JUMP to 57D1H for normal character.
57B7
OR (IX+03H) DD B6 03
OR with page length from FCB at IX+03H.
57BA
If page length is zero (continuous), JUMP to 57D1H.
57BC
LD A,(IX+03H) DD 7E 03
Load A with page length from FCB.
57BF
SUB (IX+04H) DD 96 04
Subtract current line (IX+04H). Result is lines remaining on page.
57C2
LD B,A 47
Copy to B for loop counter.
57C3
[LINE FEED LOOP] Call 57EEH to check printer ready.
57C6
If printer not ready, wait and retry.
57C8
LD A,0AH 3E 0A
Load A with 0AH (Line Feed).
57CA
LD (37E8H),A 32 E8 37
Store at 37E8H (printer output port).
57CD
Decrement B and if NZ, output more line feeds.
57CF
JUMP to 57E9H to reset line counter.
57D1H - Normal Printer Character Output
This routine outputs a normal character to the printer and tracks line position for page formatting.
57D1
PUSH AF F5
Save character on stack.
57D2
[WAIT LOOP] Call 57EEH to check printer ready.
57D5
If not ready, keep waiting.
57D7
POP AF F1
Restore character.
57D8
LD (37E8H),A 32 E8 37
Output character to printer port.
57DB
CP 0DH FE 0D
Compare with 0DH (Carriage Return).
57DD
RET NZ C0
If not CR, return.
57DE
INC (IX+04H) DD 34 04
Increment line counter in FCB.
57E1
LD A,(IX+04H) DD 7E 04
Load current line count.
57E4
CP (IX+03H) DD BE 03
Compare with page length.
57E7
LD A,C 79
Load A with original character code.
57E8
RET NZ C0
If not at end of page, return.
57E9
LD (IX+04H),04H DD 36 04 00
Reset line counter to start of new page.
57EEH - Check Printer Ready
This routine checks if the printer is ready to receive data by reading the printer status port.
57EE
LD A,(37E8H) 3A E8 37
Read printer status from memory-mapped port 37E8H.
57F1
AND F0H E6 F0
Mask upper nibble (status bits).
57F3
CP 30H FE 30
Compare with 30H (ready status). Sets Z if ready.
57F5
RET C9
Return with Z flag indicating ready status.
57F6H - File Output Setup Routines
These routines set up different output destinations (disk files) with varying buffer sizes.
57F6
PUSH BC C5
Save BC on stack.
57F7
LD B,01H 06 01
Load B with 01H (single sector buffer).
57F9
JUMP to 5814H to continue setup.
57FC
LD B,02H 06 02
Load B with 02H (two sector buffer).
5801
LD B,04H 06 04
Load B with 04H (four sector buffer).
5805
LD DE,5500H 11 00 55
Load DE with buffer address 5500H.
5808
JUMP to 57F6H with single-sector setup.
580A
LD DE,5508H 11 08 55
Load DE with buffer address 5508H.
580D
JUMP to 57FBH with two-sector setup.
580F
LD DE,5510H 11 10 55
Load DE with buffer address 5510H.
5814
JUMP to 55CEH to complete file setup.
58DAH - Error/Abort Handler Entry
This is the main error and abort handling entry point. It resets the stack, performs cleanup, and prepares for new user input.
58DA
LD SP,54FEH 31 FE 54
Reset stack pointer to 54FEH, clearing any pending operations.
58DD
Call 71D5H to perform I/O cleanup.
58E0
LD BC,58DAH 01 DA 58
Load BC with 58DAH (this routine's address for error return).
58E3
PUSH BC C5
Push as return address - errors will come back here.
58E5
LD HL,53BAH 21 BA 53
Load HL with address of status variables.
58E8
LD (HL),A 77
Clear first status byte.
58EA
LD (HL),FFH 36 FF
Set to FFH.
58EE
LD (53C5H),A 32 C5 53
Clear variable at 53C5H.
58F1
LD A,2AH 3E 2A
Load A with 2AH (ASCII * asterisk - prompt character).
58F3
Call 5700H to display the prompt.
58F6
LD C,01H 0E 01
Load C with 01H (command mode flag).
58F8
GOSUB to 5B41H to get command line input from user
58FB
GOSUB to 5BBBH to parse the command line
58FE
RET Z C8
If the Z FLAG is set (empty command), RETURN to 58DAH to redisplay prompt
58FF
LD HL,5B05H 21 05 5B
Point Register Pair HL to 5B05H (command dispatch table)
5902
LD B,0FH 06 0F
Load Register B with 0FH (15 commands in the table)
[LOOP START] - Search command dispatch table for matching command character
5904
CP (HL) BE
Compare Register A (command character) against the table entry at (HL)
5905
INC HL 23
INCrement HL to point to the low byte of the handler address
5906
LD E,(HL) 5E
Load Register E with the low byte of the handler address
5907
INC HL 23
INCrement HL to point to the high byte of the handler address
5908
LD D,(HL) 56
Load Register D with the high byte of the handler address
5909
INC HL 23
INCrement HL to point to the next command entry
590A
If the NZ FLAG is set (no match), JUMP to 5926H to check next entry
590C
PUSH DE D5
Save the handler address (DE) onto the stack
590D
LD HL,(5315H) 2A 15 53
Load Register Pair HL with the contents of 5315H (text buffer end pointer)
5910
LD DE,7700H 11 00 77
Load Register Pair DE with 7700H (work buffer address)
5913
GOSUB to 5DC2H to compare HL and DE (check if text exists)
5916
RET NZ C0
If the NZ FLAG is set (text exists), RETURN to the handler address on stack
5917
LD HL,5888H 21 88 58
Point Register Pair HL to 5888H (alternate handler for empty buffer)
591A
LD (5311H),HL 22 11 53
Store HL into 5311H (current line pointer)
591D
LD A,B 78
Load Register A with the current loop counter (B)
591E
CP 04H FE 04
Compare Register A against 04H. Commands 0-3 require text in buffer
5920
RET C D8
If the CARRY FLAG is set (command index < 4), RETURN to handler (allowed with empty buffer)
5921
Point Register Pair HL to 59C6H ("NOT TEXT IN BUFFER" error message)
5924
JUMP to 592BH to display error message and return to main loop
5926
DECrement B and Jump if Not Zero back to 5904H to check next command
5928
Point Register Pair HL to 59A2H ("ILLEGAL COMMAND" error message)
592B
LD BC,58DAH 01 DA 58
Load Register Pair BC with 58DAH (main loop address)
592E
PUSH BC C5
Save return address onto the stack
592FH - Display Message with High-Bit Terminator
This routine displays a message string pointed to by HL. The string is terminated by a character with its high bit set. Entry: HL points to the start of the message string. Exit: Message is displayed, HL points past the terminator.
592F
LD A,(HL) 7E
Load Register A with the character at (HL)
5930
INC HL 23
INCrement HL to point to the next character
5931
GOSUB to 5939H to display the character
5934
RLCA 07
Rotate Left Circular Accumulator - move bit 7 into carry flag
5935
If the NC FLAG is set (high bit was 0), LOOP BACK to 592FH for next character
5937
LD A,0DH 3E 0D
Load Register A with 0DH (ASCII: Carriage Return)
5939H - Character Output with Column Tracking
This routine outputs a character to the display while tracking column position and handling special characters like TAB (09H). Entry: A contains the character to display. Exit: Character is displayed, column counter updated.
5939
PUSH AF F5
Save the character and flags onto the stack
593A
PUSH HL E5
Save HL onto the stack
593B
LD HL,53BAH 21 BA 53
Point Register Pair HL to 53BAH (output column counter)
593E
INC (HL) 34
INCrement the column counter
593F
DEC (HL) 35
DECrement the column counter (test if it was zero)
5940
INC HL 23
INCrement HL to point to 53BBH (output line counter)
5941
PUSH AF F5
Save AF again for the conditional call
5942
If the NZ FLAG is set, GOSUB to 710CH (handle line wrap or scroll)
5945
POP AF F1
Restore AF from the stack
5946
If the NZ FLAG is set, JUMP to 595CH to restore and return
5948
CP 09H FE 09
Compare Register A against 09H (ASCII: TAB character)
594A
If the Z FLAG is set (character is TAB), JUMP to 595FH to handle TAB expansion
594C
INC (HL) 34
INCrement the value at 53BBH
594D
AND 7FH E6 7F
Mask off the high bit of the character (convert to standard ASCII)
594F
INC HL 23
INCrement HL to point to 53BCH
5950
INC (HL) 34
INCrement the value at 53BCH
5951
DEC (HL) 35
DECrement the value at 53BCH (test if it was zero)
5952
PUSH DE D5
Save DE onto the stack
5953
PUSH AF F5
Save AF onto the stack
5954
If the NZ FLAG is set, GOSUB to ROM routine at 003BH (printer output)
5957
POP AF F1
Restore AF from the stack
5958
If the Z FLAG is set, GOSUB to ROM routine at 0033H (display character)
595B
POP DE D1
Restore DE from the stack
595C
POP HL E1
Restore HL from the stack
595D
POP AF F1
Restore AF (original character) from the stack
595E
RET C9
RETURN to the caller
[TAB HANDLER] - Expand TAB character to spaces (next multiple of 8)
595F
LD A,20H 3E 20
Load Register A with 20H (ASCII: Space character)
5961
GOSUB to 5939H to output a space character
5964
LD A,(HL) 7E
Load Register A with the current column count from (HL)
5965
AND 07H E6 07
Mask to get column modulo 8 (check if at TAB stop)
5967
If the NZ FLAG is set (not at TAB stop), LOOP BACK to 595FH to output another space
5969
JUMP to 595CH to restore registers and return
596BH - Editor Error and Status Messages
This section contains the error and status messages used by the editor. Each message is terminated by a character with its high bit set (bit 7 = 1), which signals the end of the string to the display routine at 592FH.
596B-597AH
DEFM "STRING NOT FOUND" 53 54 52 49 4E 47 20 4E 4F 54 20 46 4F 55 4E C4
The D has the high bit set. The hex is C4 which is 11000100 in binary. If you turn off the high bit, you get 01000100 which is 44H, which is hex for D
597B-598AH
DEFM "BAD PARAMETER(S)" 42 41 44 20 50 41 52 41 4D 45 54 45 52 28 53 A9
The ) has the high bit set. The hex is A9 which is 10101001 in binary. If you turn off the high bit, you get 00101001 which is 29H, which is hex for )
598B-5996H
DEFM "NO SUCH LINE" 4E 4F 20 53 55 43 48 20 4C 49 4E C5
The E has the high bit set. The hex is C5 which is 11000101 in binary. If you turn off the high bit, you get 01000101 which is 45H, which is hex for E
5997-59A1H
DEFM "BUFFER FULL" 42 55 46 46 45 52 20 46 55 4C CC
The L has the high bit set. The hex is CC which is 11001100 in binary. If you turn off the high bit, you get 01001100 which is 4CH, which is hex for L
59A2-59B0H
DEFM "ILLEGAL COMMAND" 49 4C 4C 45 47 41 4C 20 43 4F 4D 4D 41 4E C4
The D has the high bit set. The hex is C4 which is 11000100 in binary. If you turn off the high bit, you get 01000100 which is 44H, which is hex for D
59B1-59C5H
DEFM "LINE NUMBER TOO LARGE" 4C 49 4E 45 20 4E 55 4D 42 45 52 20 54 4F 4F 20 4C 41 52 47 C5
The E has the high bit set. The hex is C5 which is 11000101 in binary. If you turn off the high bit, you get 01000101 which is 45H, which is hex for E
59C6-59D6H
DEFM "NOT TEXT IN BUFFER" 4E 4F 54 20 54 45 58 54 20 49 4E 20 42 55 46 46 45 D2
The R has the high bit set. The hex is D2 which is 11010010 in binary. If you turn off the high bit, you get 01010010 which is 52H, which is hex for R
59D7-59DFH
DEFM "BAD LABEL" 42 41 44 20 4C 41 42 45 CC
The L has the high bit set. The hex is CC which is 11001100 in binary. If you turn off the high bit, you get 01001100 which is 4CH, which is hex for L
59E0-59F2H
DEFM "BRANCH OUT OF RANGE" 42 52 41 4E 43 48 20 4F 55 54 20 4F 46 20 52 41 4E 47 C5
The E has the high bit set. The hex is C5 which is 11000101 in binary. If you turn off the high bit, you get 01000101 which is 45H, which is hex for E
59F3-5A09H
DEFM "ILLEGAL ADDRESSING MODE" 49 4C 4C 45 47 41 4C 20 41 44 44 52 45 53 53 49 4E 47 20 4D 4F 44 C5
The E has the high bit set. The hex is C5 which is 11000101 in binary. If you turn off the high bit, you get 01000101 which is 45H, which is hex for E
5A0A-5A17H
DEFM "ILLEGAL OPCODE" 49 4C 4C 45 47 41 4C 20 4F 50 43 4F 44 C5
The E has the high bit set. The hex is C5 which is 11000101 in binary. If you turn off the high bit, you get 01000101 which is 45H, which is hex for E
5A18-5A2AH
DEFM "MISSING INFORMATION" 4D 49 53 53 49 4E 47 20 49 4E 46 4F 52 4D 41 54 49 4F CE
The N has the high bit set. The hex is CE which is 11001110 in binary. If you turn off the high bit, you get 01001110 which is 4EH, which is hex for N
5A2B-5A3AH
DEFM "NO END STATEMENT" 4E 4F 20 45 4E 44 20 53 54 41 54 45 4D 45 4E D4
The T has the high bit set. The hex is D4 which is 11010100 in binary. If you turn off the high bit, you get 01010100 which is 54H, which is hex for T
5A3B-5A4DH
DEFM "MULTIPLE DEFINITION" 4D 55 4C 54 49 50 4C 45 20 44 45 46 49 4E 49 54 49 4F CE
The N has the high bit set. The hex is CE which is 11001110 in binary. If you turn off the high bit, you get 01001110 which is 4EH, which is hex for N
5A4E-5A5BH
DEFM "FIELD OVERFLOW" 46 49 45 4C 44 20 4F 56 45 52 46 4C 4F D7
The W has the high bit set. The hex is D7 which is 11010111 in binary. If you turn off the high bit, you get 01010111 which is 57H, which is hex for W
5A5C-5A72H
DEFM "MULTIPLY DEFINED SYMBOL" 4D 55 4C 54 49 50 4C 59 20 44 45 46 49 4E 45 44 20 53 59 4D 42 4F CC
The L has the high bit set. The hex is CC which is 11001100 in binary. If you turn off the high bit, you get 01001100 which is 4CH, which is hex for L
5A73-5A87H
DEFM "SYMBOL TABLE OVERFLOW" 53 59 4D 42 4F 4C 20 54 41 42 4C 45 20 4F 56 45 52 46 4C 4F D7
The W has the high bit set. The hex is D7 which is 11010111 in binary. If you turn off the high bit, you get 01010111 which is 57H, which is hex for W
5A88-5A93H
DEFM "TOTAL ERRORS" 54 4F 54 41 4C 20 45 52 52 4F 52 D3
The S has the high bit set. The hex is D3 which is 11010011 in binary. If you turn off the high bit, you get 01010011 which is 53H, which is hex for S
5A94-5AA3H
DEFM "UNDEFINED SYMBOL" 55 4E 44 45 46 49 4E 45 44 20 53 59 4D 42 4F CC
The L has the high bit set. The hex is CC which is 11001100 in binary. If you turn off the high bit, you get 01001100 which is 4CH, which is hex for L
5AA4-5AB3H
DEFM "EXPRESSION ERROR" 45 58 50 52 45 53 53 49 4F 4E 20 45 52 52 4F D2
The R has the high bit set. The hex is D2 which is 11010010 in binary. If you turn off the high bit, you get 01010010 which is 52H, which is hex for R
5AB4-5AC8H
DEFM "NO ROOM BETWEEN LINES" 4E 4F 20 52 4F 4F 4D 20 42 45 54 57 45 45 4E 20 4C 49 4E 45 D3
The S has the high bit set. The hex is D3 which is 11010011 in binary. If you turn off the high bit, you get 01010011 which is 53H, which is hex for S
5AC9-5AE3H
DEFM "TRS-80 EDITOR/ASSEMBLER 1.1" 54 52 53 2D 38 30 20 45 44 49 54 4F 52 2F 41 53 53 45 4D 42 4C 45 52 20 31 2E B1
The 1 has the high bit set. The hex is B1 which is 10110001 in binary. If you turn off the high bit, you get 00101110 which is 31H, which is hex for 1
5AE3-5AF1H
DEFM "READY CASSETTE" 52 45 41 44 59 20 43 41 53 53 45 54 54 C5
The E has the high bit set. The hex is C5 which is 11000101 in binary. If you turn off the high bit, you get 01000101 which is 45H, which is hex for E
5AF2-5AFEH
DEFM "READY PRINTER" 52 45 41 44 59 20 50 52 49 4E 54 45 D2
The R has the high bit set. The hex is D2 which is 11010010 in binary. If you turn off the high bit, you get 01010010 which is 52H, which is hex for R
5AFF-5B04H
DEFM "NONAME" 4E 4F 4E 4E 41 4D 45
5B05H - Command Dispatch Table
This is a command dispatch table used by the command parser at 58FEH. Each entry consists of a single ASCII command letter followed by a 2-byte jump address (little-endian). The parser searches this table for matching commands and jumps to the corresponding handler routine. The table contains 15 entries (0FH entries as indicated by the LD B,0FH at 5902H).
5B05-5B07
Command 'P' (Print) - Handler at 5E2AH
5B08-5B0A
Command 'H' (Hardcopy) - Handler at 5E20H
5B0B-5B0D
Command 'T' (Tab) - Handler at 5E1CH
5B0E-5B10
Command 'D' (Delete) - Handler at 5EE3H
5B11-5B13
Command 'R' (Renumber?) - Handler at 5ECDH
5B14-5B16
Command 'N' (New) - Handler at 5C02H
5B17-5B19
Command 'A' (Assemble) - Handler at 63E3H
5B1A-5B1C
Command 'W' (Write) - Handler at 6F14H
5B1D-5B1F
Command 'F' (Find) - Handler at 5DC8H
5B20-5B22
Command '[' (Block start) - Handler at 5E72H
5B23-5B25
Command 'Z' - Handler at 7070H
5B26-5B28
Command 'E' (Edit) - Handler at 5FC1H
5B29-5B2B
Command 'L' (Load) - Handler at 6F08H
5B2C-5B2E
Command 'I' (Insert) - Handler at 5C41H
5B2F-5B31
Command 'B' (Break?) - Handler at 56F8H
5B32H - Command Input Handler
This routine handles command line input from the user. It initializes the input buffer, processes keystrokes including special keys (backspace, enter, break), and manages cursor position. The routine uses 53BBH as a tab/column counter, 53A8H as the buffer pointer, and 53AAH to store the final character count.
5B32
LD HL,53BBH 21 BB 53
Point HL to the tab/column counter variable at 53BBH
5B35
LD B,(HL) 46
Load B with the current tab/column count
5B36
LD A,08H 3E 08
Load A with 08H (ASCII backspace character)
5B38
DEC B 05
[LOOP] Decrement the column counter
5B39
If B is still positive (P flag set), GOSUB to 5939H to output backspace character - erasing characters on screen
5B3C
If B is still positive, LOOP BACK to 5B38H to continue erasing
5B3F
LD (HL),00H 36 00
Reset the tab/column counter at 53BBH to zero
5B41
LD HL,5327H 21 27 53
Point HL to the input buffer at 5327H
5B44
LD (53A8H),HL 22 A8 53
Store HL as the current buffer pointer at 53A8H
5B47
LD D,00H 16 00
Clear D to use as character count (number of characters entered)
5B49
[MAIN INPUT LOOP] GOSUB to 5834H to get a keystroke from the user
5B4C
CP 18H FE 18
Compare A against 18H (CTRL-X or clear line command). If equal, Z FLAG is set
5B4E
If Z FLAG set (CTRL-X pressed), JUMP BACK to 5B32H to clear line and restart input
5B50
CP 08H FE 08
Compare A against 08H (backspace). If equal, Z FLAG is set
5B52
If NZ FLAG set (not backspace), JUMP to 5B59H to check other keys
5B54
GOSUB to 5B89H to handle backspace - erase one character
5B57
JUMP BACK to 5B49H to continue input loop
5B59
CP 01H FE 01
Compare A against 01H (BREAK key code). If equal, Z FLAG is set
5B5B
If Z FLAG set (BREAK pressed), JUMP to 58D7H to abort input and return to command mode
5B5E
CP 0DH FE 0D
Compare A against 0DH (ASCII carriage return/ENTER). If equal, Z FLAG is set
5B60
If Z FLAG set (ENTER pressed), JUMP to 5B75H to finalize input
5B62
LD (HL),A 77
Store the character in A into the buffer at current position (HL)
5B63
CP 5BH FE 5B
Compare A against 5BH (ASCII [ left bracket). If equal, Z FLAG is set
5B65
If Z FLAG set (left bracket), JUMP to 5B6BH to handle special bracket processing
5B67
CP 0AH FE 0A
Compare A against 0AH (ASCII line feed). If equal, Z FLAG is set
5B69
If NZ FLAG set (not line feed), JUMP to 5B7CH to process as normal character
5B6B
INC C 0C
Increment C (bracket nesting counter)
5B6C
DEC C 0D
Decrement C immediately - this tests if C was zero before INC
5B6D
If Z FLAG set (C was zero, meaning special mode not active), JUMP BACK to 5B49H ignoring this character
5B6F
LD A,D 7A
Load A with D (current character count)
5B70
DEC A 3D
Decrement A to check if we have at least one character
5B71
If P FLAG set (A >= 0, meaning we have characters), JUMP BACK to 5B49H for more input
5B74
INC D 14
Increment D to compensate for the DEC A test
5B75
LD A,D 7A
Load A with D (final character count)
5B76
LD (53AAH),A 32 AA 53
Store the character count at 53AAH for later use
5B79
JUMP to 5937H to output carriage return and complete input
5B7C
LD A,D 7A
Load A with D (current character count)
5B7D
CP 80H FE 80
Compare A against 80H (128 decimal - maximum buffer size). If equal, Z FLAG is set
5B7F
If Z FLAG set (buffer full), JUMP BACK to 5B49H ignoring this character
5B81
LD A,(HL) 7E
Load A with the character from the buffer (was stored at 5B62H)
5B82
INC HL 23
Increment HL to point to next buffer position
5B83
INC D 14
Increment D (character count)
5B84
GOSUB to 5939H to echo the character to the display
5B87
JUMP BACK to 5B49H to continue input loop
5B89H - Backspace Handler
This routine handles the backspace key during input. It decrements the buffer position, erases the character from the display, and handles tab characters specially by erasing multiple spaces. Register D contains the character count, HL points to the current buffer position.
5B89
INC D 14
Increment D then decrement to test if D is zero (no characters to delete)
5B8A
DEC D 15
Decrement D back - Z FLAG set if D was zero
5B8B
RET Z C8
If Z FLAG set (no characters in buffer), RETURN - nothing to delete
5B8C
DEC HL 2B
Decrement HL to point to previous character in buffer
5B8D
PUSH HL E5
Save the buffer pointer on the stack
5B8E
LD A,(HL) 7E
Load A with the character being deleted
5B8F
LD HL,53BBH 21 BB 53
Point HL to the tab/column counter at 53BBH
5B92
CP 09H FE 09
Compare A against 09H (ASCII tab character). If equal, Z FLAG is set
5B94
If Z FLAG set (deleting a tab), JUMP to 5BA0H for special tab handling
5B96
LD A,08H 3E 08
Load A with 08H (ASCII backspace)
5B98
GOSUB to 5939H to output backspace (move cursor left)
5B9B
DEC (HL) 35
Decrement the tab/column counter (first of two decrements)
5B9C
DEC (HL) 35
Decrement the tab/column counter again (accounts for backspace output)
5B9D
DEC D 15
Decrement D (character count)
5B9E
POP HL E1
Restore the buffer pointer from the stack
5B9F
RET C9
RETURN to caller
5BA0
PUSH BC C5
Save BC on the stack (preserving other counters)
5BA1
LD B,(HL) 46
Load B with the tab/column counter value
5BA2
LD A,08H 3E 08
[TAB ERASE LOOP] Load A with 08H (ASCII backspace)
5BA4
GOSUB to 5939H to output backspace
5BA7
Decrement B and LOOP BACK to 5BA4H if not zero - erase all spaces from tab
5BA9
LD (HL),B 70
Store B (now zero) into the tab/column counter
5BAA
DEC D 15
Decrement D (character count)
5BAB
If Z FLAG set (no more characters), JUMP to 5BB8H to finish
5BAD
LD HL,5327H 21 27 53
Point HL to the start of input buffer at 5327H
5BB0
LD B,D 42
Load B with D (remaining character count for re-display)
5BB1
LD A,(HL) 7E
[RE-DISPLAY LOOP] Load A with character from buffer
5BB2
INC HL 23
Increment HL to next buffer position
5BB3
GOSUB to 5939H to output the character
5BB6
Decrement B and LOOP BACK to 5BB1H if not zero - re-display remaining chars
5BB8
POP BC C1
Restore BC from the stack
5BB9
POP HL E1
Restore the buffer pointer from the stack
5BBA
RET C9
RETURN to caller
5BBBH - Skip Spaces / Get Next Non-Space Character
This routine skips over space characters (20H) in the input buffer and returns the next non-space character. Entry at 5BBBH sets A=20H as the delimiter, entry at 5BBDH uses the existing value in A. Entry at 5BBEH (the main entry point) is used by most callers. Register B is set to the delimiter character, and the routine returns with A containing the next non-space character, Z flag set if end of line (0DH) reached.
5BBB
LD A,20H 3E 20
Load A with 20H (ASCII space) as the delimiter to skip
5BBD
CP AFH FE AF
Compare A against AFH - this is a trick to reset carry flag and set NZ (AFH is XOR A opcode but used here as comparison target)
5BBE
PUSH BC C5
Save BC on the stack
5BBF
PUSH HL E5
Save HL on the stack
5BC0
LD B,A 47
Load B with the delimiter character (space or custom)
5BC1
LD HL,53AAH 21 AA 53
Point HL to the remaining character count at 53AAH
5BC4
INC (HL) 34
[SKIP LOOP] Increment count then decrement to test for zero
5BC5
DEC (HL) 35
Decrement count back - Z FLAG set if count was zero
5BC6
LD A,0DH 3E 0D
Load A with 0DH (carriage return) as default end-of-line indicator
5BC8
SCF 37
Set Carry Flag to indicate end of input
5BC9
If Z FLAG set (no more characters), JUMP to 5BE1H to return with CR
5BCB
DEC (HL) 35
Actually decrement the remaining character count
5BCC
LD HL,(53A8H) 2A A8 53
Load HL with the current buffer pointer from 53A8H
5BCF
LD A,(HL) 7E
Load A with the character at current buffer position
5BD0
INC HL 23
Increment HL to point to next character
5BD1
LD (53A8H),HL 22 A8 53
Store updated buffer pointer back to 53A8H
5BD4
CP 09H FE 09
Compare A against 09H (ASCII tab). If equal, Z FLAG is set
5BD6
If NZ FLAG set (not a tab), JUMP to 5BDBH
5BD8
LD A,20H 3E 20
Convert tab to space (treat tabs as spaces for comparison)
5BDA
NOP 00
No operation (alignment or patch space)
5BDB
CP B B8
Compare A against B (the delimiter character)
5BDC
If Z FLAG set (character matches delimiter), LOOP BACK to 5BC4H to skip it
5BDE
GOSUB to 5BE4H to validate if character is alphanumeric
5BE1
POP HL E1
Restore HL from the stack
5BE2
POP BC C1
Restore BC from the stack
5BE3
RET C9
RETURN to caller with character in A, flags set appropriately
5BE4H - Validate Alphanumeric Character
This routine checks if the character in Register A is alphanumeric (0-9 or A-Z). Entry: A = character to test. Exit: Carry flag set if character is alphanumeric (digit or uppercase letter), Carry flag clear if not alphanumeric. The Z flag is affected but secondary to the Carry flag result.
5BE4
CP 30H FE 30
Compare Register A against 30H (ASCII '0'). If A < 30H, the CARRY FLAG will be set indicating character is below digit range.
5BE6
RET C D8
If CARRY FLAG is set (character < '0'), RETURN immediately. Character is not alphanumeric.
5BE7
CP 3AH FE 3A
Compare Register A against 3AH (one past ASCII '9'). If A < 3AH, character is a digit '0'-'9'.
5BE9
CCF 3F
Complement Carry Flag. If character was a digit (Carry was clear from CP 3AH), Carry is now SET indicating valid alphanumeric. If character was >= 3AH, Carry was clear and is now set (but we continue checking for letters).
5BEA
INC A 3C
INCrement Register A by 1. This instruction does NOT affect the Carry flag, preserving the result from CCF.
5BEB
DEC A 3D
DECrement Register A by 1, restoring original value. This sequence (INC/DEC) sets the Z flag based on whether A is zero without affecting Carry.
5BEC
RET C9
RETURN to caller. Carry flag indicates: SET = alphanumeric character, CLEAR = not alphanumeric.
5BEDH - Validate Uppercase Letter
This routine checks if the character in Register A is an uppercase letter (A-Z). Entry: A = character to test. Exit: Carry flag set if character is uppercase letter, Carry flag clear if not. Falls through to 5BE9H for final flag manipulation.
5BED
CP 41H FE 41
Compare Register A against 41H (ASCII 'A'). If A < 41H, CARRY FLAG is set indicating character is below letter range.
5BEF
RET C D8
If CARRY FLAG is set (character < 'A'), RETURN immediately. Character is not an uppercase letter.
5BF0
CP 5BH FE 5B
Compare Register A against 5BH (one past ASCII 'Z'). If A < 5BH, character is an uppercase letter 'A'-'Z'.
5BF2
JUMP to 5BE9H to complement carry and return. This sets Carry if character was a valid letter (A-Z).
5BF4H - Unget Character (Push Back to Input Buffer)
This routine "pushes back" one character to the input buffer by decrementing the buffer pointer and incrementing the remaining character count. This allows re-reading the last character consumed. Entry: None required. Exit: HL preserved, buffer pointer (53A8H) decremented, character count (53AAH) incremented.
5BF4
PUSH HL E5
Save Register Pair HL onto the stack to preserve caller's value.
5BF5
LD HL,(53A8H) 2A A8 53
Load HL with the current input buffer pointer from 53A8H. This points to the next character to be read.
5BF8
DEC HL 2B
DECrement HL to point back to the previously read character.
5BF9
LD (53A8H),HL 22 A8 53
Store the decremented pointer back to 53A8H, effectively "unreading" the last character.
5BFC
LD HL,53AAH 21 AA 53
Point HL to 53AAH, the remaining character count variable.
5BFF
INC (HL) 34
INCrement the character count at 53AAH to reflect one more character available to read.
5C00
POP HL E1
Restore Register Pair HL from the stack.
5C01
RET C9
RETURN to caller.
5C02H - Edit Line with Line Number Range
This routine handles editing operations with a line number range specified. It parses line number parameters, validates memory bounds, and iterates through source lines. Entry: Command line parsed with potential line number range. Exit: Lines processed according to edit operation, or error displayed if bounds exceeded.
5C02
GOSUB to 5CC7H to parse line number range parameters from command line. Returns with line numbers parsed into appropriate variables.
5C05
SCF 37
Set Carry Flag to indicate initial entry into the edit loop (first iteration flag).
5C06
PUSH HL E5
Save Register Pair HL (current line pointer) onto the stack.
5C07
LD DE,7700H 11 00 77
Load DE with 7700H, the start of the source text buffer area.
5C0A
PUSH AF F5
Save AF (including Carry flag state) onto the stack.
5C0B
PUSH HL E5
Save current HL onto the stack for comparison.
5C0C
LD HL,(5315H) 2A 15 53
Load HL with the end of source text pointer from 5315H.
5C0F
GOSUB to 5DC2H to compare HL with DE. This checks if we've reached the end of source text.
5C12
EX DE,HL EB
Exchange DE and HL. DE now holds end pointer, HL ready for next operation.
5C13
POP DE D1
Restore DE from stack (was the saved HL - current position).
5C14
If NOT ZERO (not at end of source), JUMP to 5C1CH to continue processing.
5C16
POP AF F1
Restore AF from stack.
5C17
CCF 3F
Complement Carry Flag. If was set (first iteration), now clear.
5C18
POP HL E1
Restore HL from stack.
5C19
If NO CARRY (more iterations needed), LOOP BACK to 5C06H to continue.
5C1B
RET C9
RETURN to caller when edit operation is complete.
5C1C
POP AF F1
Restore AF from stack.
5C1D
PUSH AF F5
Save AF back onto stack for later use.
5C1E
INC HL 23
INCrement HL to point past current position.
5C1F
If CARRY FLAG is set (special mode), JUMP to 5C25H to skip line number update.
5C21
DEC HL 2B
DECrement HL back to original position.
5C22
LD (HL),E 73
Store low byte of DE into memory at (HL). This updates the line number link.
5C23
INC HL 23
INCrement HL to point to high byte location.
5C24
LD (HL),D 72
Store high byte of DE into memory at (HL).
5C25
INC HL 23
INCrement HL to point to line length byte.
5C26
LD C,(HL) 4E
Load Register C with the line length from (HL).
5C27
LD B,00H 06 00
Load Register B with 00H. BC now contains the line length as a 16-bit value.
5C29
INC BC 03
INCrement BC to include the length byte itself in the skip count.
5C2A
ADD HL,BC 09
ADD BC to HL to skip past this line to the next line entry.
5C2B
PUSH HL E5
Save HL (now pointing to next line) onto the stack.
5C2C
LD HL,(5317H) 2A 17 53
Load HL with the memory limit value from 5317H.
5C2F
ADD HL,DE 19
ADD DE to HL to calculate potential new position.
5C30
If CARRY FLAG is set (overflow occurred), JUMP to 5C3BH to display memory overflow error.
5C32
LD DE,FFFAH 11 FA FF
Load DE with FFFAH (-6 in two's complement) as safety margin.
5C35
GOSUB to 5DC2H to compare HL with DE for boundary check.
5C38
POP DE D1
Restore DE from stack.
5C39
If CARRY FLAG is set (within bounds), LOOP BACK to 5C0BH to continue processing.
5C3B
Point HL to error message at 59B1H ("MEMORY OVERFLOW" or similar).
5C3E
JUMP to 592BH to display the error message and return to command mode.
5C41H - Delete Lines in Range
This routine deletes source lines within a specified line number range. It validates memory bounds and repeatedly calls the line deletion routine until all lines in range are removed. Entry: Command line with line number range parsed. Exit: Lines deleted from source buffer, memory compacted.
5C41
GOSUB to 5CC7H to parse line number range from command line.
5C44
If NOT ZERO (line found), JUMP to 5C55H to delete it.
5C46
EX DE,HL EB
Exchange DE and HL registers.
5C47
LD HL,(5317H) 2A 17 53
Load HL with the memory limit from 5317H.
5C4A
ADD HL,DE 19
ADD DE to HL to check memory bounds.
5C4B
If CARRY FLAG is set (overflow), JUMP to 5C3BH to display memory overflow error.
5C4D
LD DE,FFFAH 11 FA FF
Load DE with FFFAH (-6) as safety margin for bounds check.
5C50
GOSUB to 5DC2H to compare HL with DE.
5C53
If NO CARRY (out of bounds), JUMP to 5C3BH to display error.
5C55
PUSH HL E5
Save HL (current line pointer) onto the stack.
5C56
GOSUB to 5C5CH to delete the current line from source buffer.
5C59
POP HL E1
Restore HL from stack.
5C5A
LOOP BACK to 5C46H to check for more lines to delete.
5C5CH - Delete Single Source Line
This routine deletes a single line from the source buffer by moving all subsequent lines up to fill the gap. It updates memory pointers and validates that sufficient memory remains. Entry: Line to delete identified via 531DH pointer. Exit: Line removed, source buffer compacted, pointers updated.
5C5C
POP HL E1
Pop return address into HL (will be used for stack manipulation).
5C5D
EX (SP),HL E3
Exchange HL with top of stack. This swaps the return address with the value on stack.
5C5E
PUSH HL E5
Push the exchanged value back onto stack.
5C5F
LD B,B7H 06 B7
Load Register B with B7H. This may be a flag or counter value for the delete operation.
5C61
LD HL,(531DH) 2A 1D 53
Load HL with the current line pointer from 531DH. This points to the line to be deleted.
5C64
LD E,(HL) 5E
Load Register E with low byte of next line pointer from (HL).
5C65
INC HL 23
INCrement HL to point to high byte.
5C66
LD D,(HL) 56
Load Register D with high byte of next line pointer. DE now contains the link to next line.
5C67
DEC HL 2B
DECrement HL back to start of line entry.
5C68
EX (SP),HL E3
Exchange HL with top of stack.
5C69
PUSH AF F5
Save AF onto the stack.
5C6A
GOSUB to 5DC2H to compare HL with DE for boundary validation.
5C6D
If CARRY FLAG is set (valid bounds), JUMP to 5C75H to continue deletion.
5C6F
Point HL to error message at 5AB4H ("LINE NOT FOUND" or similar error).
5C72
JUMP to 592BH to display error message and return to command mode.
5C75
GOSUB to 5DA9H to check memory limits before deletion operation.
5C78
POP AF F1
Restore AF from stack.
5C79
PUSH AF F5
Save AF back onto stack (preserving for later).
5C7A
If CARRY FLAG is set, GOSUB to 5D75H to display line number being deleted.
5C7D
POP AF F1
Restore AF from stack.
5C7E
EX (SP),HL E3
Exchange HL with top of stack.
5C7F
PUSH HL E5
Push HL onto stack.
5C80
LD C,00H 0E 00
Load Register C with 00H as initialization parameter.
5C82
If CARRY FLAG is set, GOSUB to 5B41H to initialize input buffer.
5C85
POP DE D1
Restore DE from stack.
5C86
LD HL,(5315H) 2A 15 53
Load HL with the end of source text pointer from 5315H.
5C89
INC HL 23
INCrement HL past end marker.
5C8A
LD B,00H 06 00
Load Register B with 00H.
5C8C
LD A,(53AAH) 3A AA 53
Load Register A with the character count from 53AAH.
5C8F
LD C,A 4F
Copy A to C. BC now contains the byte count to move.
5C90
PUSH BC C5
Save BC (byte count) onto stack.
5C91
PUSH HL E5
Save HL (end pointer) onto stack.
5C92
ADD HL,BC 09
ADD BC to HL to calculate new end position.
5C93
INC HL 23
INCrement HL.
5C94
INC HL 23
INCrement HL again for header bytes.
5C95
LD (5315H),HL 22 15 53
Store the new end of source pointer to 5315H.
5C98
INC HL 23
INCrement HL for block move setup.
5C99
EX DE,HL EB
Exchange DE and HL. DE = destination, HL will be source.
5C9A
XOR A AF
Set Register A to ZERO and clear all flags.
5C9B
SUB L 95
SUBtract L from A (0 - L = -L = two's complement of L).
5C9C
LD L,A 6F
Store negated low byte in L.
5C9D
SBC A,H 9C
SUBtract H from A with carry (continuing two's complement negation).
5C9E
SUB L 95
SUBtract L to complete the high byte negation.
5C9F
LD H,A 67
Store negated high byte in H. HL now contains -DE (negative offset).
5CA0
POP BC C1
Restore BC from stack.
5CA1
PUSH BC C5
Save BC back onto stack.
5CA2
ADD HL,BC 09
ADD BC to HL to calculate total bytes to move.
5CA3
INC HL 23
INCrement HL for adjustment.
5CA4
LD B,H 44
Copy H to B.
5CA5
LD C,L 4D
Copy L to C. BC now contains the byte count for LDDR.
5CA6
POP HL E1
Restore HL (source address for block move).
5CA7
LDDR ED B8
Block move BC bytes from (HL) to (DE), decrementing both pointers. This compacts the source buffer.
5CA9
EX DE,HL EB
Exchange DE and HL after block move.
5CAA
INC HL 23
INCrement HL to correct position.
5CAB
LD (531DH),HL 22 1D 53
Store HL as new current line pointer to 531DH.
5CAE
EX DE,HL EB
Exchange DE and HL.
5CAF
INC HL 23
INCrement HL.
5CB0
LD (5311H),HL 22 11 53
Store HL as new source text start to 5311H.
5CB3
POP BC C1
Restore BC (byte count) from stack.
5CB4
POP DE D1
Restore DE from stack.
5CB5
LD (HL),E 73
Store low byte of DE at (HL).
5CB6
INC HL 23
INCrement HL.
5CB7
LD (HL),D 72
Store high byte of DE at (HL).
5CB8
INC HL 23
INCrement HL to line length field.
5CB9
LD (HL),C 71
Store line length byte C at (HL).
5CBA
INC HL 23
INCrement HL past length byte.
5CBB
EX DE,HL EB
Exchange DE and HL.
5CBC
EX (SP),HL E3
Exchange HL with top of stack.
5CBD
PUSH HL E5
Push HL onto stack.
5CBE
LD HL,5327H 21 27 53
Point HL to the input buffer at 5327H.
5CC1
LD A,B 78
Load Register A with B.
5CC2
OR C B1
OR A with C. If BC = 0, Z flag is set.
5CC3
RET Z C8
If ZERO (no bytes to copy), RETURN immediately.
5CC4
LDIR ED B0
Block move BC bytes from (HL) to (DE). Copies input buffer content to line storage.
5CC6
RET C9
RETURN to caller.
5CC7H - Parse Line Number Range
This routine parses a line number range from the command line in the format "start,end" or just "start". It handles special symbols like # (end of file), . (current line), and * (all lines). Entry: Command line in input buffer. Exit: 5317H = end line number, 5319H = current search position, 531BH/531DH = line pointers.
5CC7
LD B,2CH 06 2C
Load Register B with 2CH (ASCII ','). This is the delimiter between start and end line numbers.
5CC9
GOSUB to 5D09H to parse the first number with comma as delimiter. Returns parsed value in HL.
5CCC
PUSH HL E5
Save the first line number (start) onto the stack.
5CCD
GOSUB to 5D07H to parse the second number (end line). Uses carriage return as default delimiter.
5CD0
If ZERO (no second number specified), JUMP to 5CD9H to use defaults.
5CD2
LD A,H 7C
Load Register A with high byte of second line number.
5CD3
OR L B5
OR A with low byte. If HL = 0, Z flag is set.
5CD4
If ZERO (invalid line number 0), JUMP to 5D24H to display error.
5CD6
LD (5317H),HL 22 17 53
Store the end line number to 5317H.
5CD9
POP HL E1
Restore the start line number from stack into HL.
5CDA
PUSH HL E5
Save start line number back onto stack.
5CDB
Load HL with 7700H, the start of source text buffer.
5CDE
PUSH HL E5
Save source start address onto stack.
5CDF
LD (5319H),HL 22 19 53
Store current search position to 5319H.
5CE2
POP HL E1
Restore HL from stack.
5CE3
LD B,H 44
Copy H to B.
5CE4
LD C,L 4D
Copy L to C. BC now holds the current position.
5CE5
LD E,(HL) 5E
Load Register E with low byte of line number from (HL).
5CE6
INC HL 23
INCrement HL to high byte.
5CE7
LD D,(HL) 56
Load Register D with high byte of line number. DE = line number.
5CE8
INC HL 23
INCrement HL to line length byte.
5CE9
PUSH DE D5
Save line number DE onto stack.
5CEA
LD E,(HL) 5E
Load Register E with line length from (HL).
5CEB
INC HL 23
INCrement HL past length byte.
5CEC
LD D,00H 16 00
Load Register D with 00H. DE = line length as 16-bit value.
5CEE
ADD HL,DE 19
ADD DE to HL to skip past line content to next line.
5CEF
POP DE D1
Restore line number from stack into DE.
5CF0
EX (SP),HL E3
Exchange HL (next line ptr) with stack (start line number).
5CF1
GOSUB to 5DC2H to compare HL (start line#) with DE (current line#).
5CF4
EX (SP),HL E3
Exchange back - HL = next line ptr, start line# back on stack.
5CF5
If ZERO (found exact match), JUMP to 5CFDH to store result.
5CF7
PUSH HL E5
Save next line pointer onto stack.
5CF8
LD H,B 60
Copy B to H.
5CF9
LD L,C 69
Copy C to L. HL = BC (previous position).
5CFA
If NO CARRY (current line < start line), LOOP BACK to 5CDFH to continue searching.
5CFC
POP DE D1
Restore DE from stack (discard saved value when search complete).
5CFD
LD (531DH),HL 22 1D 53
Store HL (found line position) to 531DH as current line pointer.
5D00
LD H,B 60
Copy B to H.
5D01
LD L,C 69
Copy C to L. HL = BC (position before found line).
5D02
LD (531BH),HL 22 1B 53
Store HL to 531BH as previous line pointer.
5D05
POP HL E1
Restore HL from stack (clean up).
5D06
RET C9
RETURN to caller with line pointers set.
5D07H - Parse Number with CR Delimiter / 5D09H - Parse Number with Custom Delimiter
These routines parse a decimal number or special symbol from the input buffer. 5D07H uses carriage return (0DH) as delimiter, 5D09H uses the delimiter specified in Register B. Entry: B = delimiter character (5D09H only), input buffer set up. Exit: HL = parsed value, DE indicates if value was found (D non-zero = found), Z flag set if no number found.
5D07
LD B,0DH 06 0D
Load Register B with 0DH (carriage return) as the default delimiter.
5D09
LD DE,0000H 11 00 00
Initialize DE to 0000H. D will track if a number was found, E tracks symbol state.
5D0C
LD H,D 62
Copy D (00H) to H.
5D0D
LD L,D 6A
Copy D (00H) to L. HL = 0000H as initial accumulator.
5D0E
GOSUB to 5BBBH to skip spaces and get next non-space character in A.
5D11
If NOT ZERO (character found, not end of input), JUMP to 5D1EH to process it.
5D14
DEC D 15
DECrement D. This tests if D is zero without changing it. Sets Z if D=0.
5D15
RET NZ C0
If NOT ZERO (D != 0, number was found), RETURN with result in HL.
5D16
LD HL,(5311H) 2A 11 53
No number found, load HL with current line pointer from 5311H as default.
5D19
LD A,(HL) 7E
Load Register A with low byte from (HL).
5D1A
INC HL 23
INCrement HL to high byte.
5D1B
LD H,(HL) 66
Load H with high byte from (HL).
5D1C
LD L,A 6F
Load L with low byte from A. HL = default line number.
5D1D
RET C9
RETURN with default value in HL.
5D1E
INC E 1C
INCrement E (symbol state counter).
5D1F
DEC E 1D
DECrement E. Tests if E was zero. Sets Z if E=0.
5D20
If ZERO (first character of token), JUMP to 5D2AH to check for special symbols.
5D22
CP B B8
Compare A with B (delimiter character).
5D23
RET Z C8
If ZERO (found delimiter), RETURN with parsed number in HL.
5D24
Point HL to error message at 597BH ("BAD LINE NUMBER" or similar).
5D27
JUMP to 592BH to display error and return to command mode.
5D2A
If CARRY (character < '0'), JUMP to 5D4AH to check for special symbols.
5D2C
PUSH HL E5
Save HL (current accumulator) onto stack.
5D2D
LD HL,5D72H 21 72 5D
Load HL with 5D72H as return address for digit accumulation loop.
5D30
EX (SP),HL E3
Exchange HL with stack. Sets up pseudo-return address at 5D72H.
5D31
SUB 30H D6 30
SUBtract 30H from A to convert ASCII digit to binary value (0-9).
5D33
PUSH DE D5
Save DE onto stack.
5D34
LD DE,1999H 11 99 19
Load DE with 1999H (6553 decimal). This is max value / 10 for overflow check.
5D37
PUSH AF F5
Save AF (digit value) onto stack.
5D38
GOSUB to 5DC2H to compare HL with DE for overflow check.
5D3B
If NO CARRY (HL >= 6553, would overflow), JUMP to 5D24H to display error.
5D3D
POP AF F1
Restore AF (digit value) from stack.
5D3E
LD D,H 54
Copy H to D.
5D3F
LD E,L 5D
Copy L to E. DE = HL (save original value).
5D40
ADD HL,HL 29
HL = HL * 2.
5D41
ADD HL,HL 29
HL = HL * 4.
5D42
ADD HL,DE 19
HL = HL * 4 + HL = HL * 5.
5D43
ADD HL,HL 29
HL = HL * 10. Accumulator multiplied by 10.
5D44
LD D,00H 16 00
Load D with 00H.
5D46
LD E,A 5F
Copy digit value A to E. DE = digit as 16-bit value.
5D47
ADD HL,DE 19
ADD digit to accumulator. HL = HL * 10 + digit.
5D48
POP DE D1
Restore DE from stack.
5D49
RET C9
RETURN (to 5D72H pseudo-return to continue loop).
5D4B
DEC D 15
DECrement D. Tests if D is zero.
5D4C
If NOT ZERO (already have a number), JUMP to 5D22H to check for delimiter.
5D4E
CP 23H FE 23
Compare A with 23H (ASCII '#'). # means end of file.
5D50
Load HL with 7700H (start of source buffer) as default for '#'.
5D53
If ZERO (character is '#'), JUMP to 5D6DH to get end address.
5D55
CP 2EH FE 2E
Compare A with 2EH (ASCII '.'). Period means current line.
5D57
LD HL,(5311H) 2A 11 53
Load HL with current line pointer from 5311H
5D5A
If Z FLAG ('.' symbol), JUMP to 5D6DH to return current line address
5D5C
CP 2AH FE 2A
Compare A against 2AH (ASCII '*')
5D5E
If NZ FLAG (not '*'), JUMP to 5D24H for "HOW?" error
5D60
LD HL,FFFFH 21 FF FF
Load HL with FFFFH - search to end of program flag
5D63
PUSH DE D5
Save DE (flags) onto stack
5D64
PUSH BC C5
Save BC (delimiter) onto stack
5D65
GOSUB to 5CDAH to perform search operation with '*' wildcard
5D68
LD HL,(5319H) 2A 19 53
Load HL with search result address from 5319H
5D6B
POP BC C1
Restore BC (delimiter) from stack
5D6C
POP DE D1
Restore DE (flags) from stack
5D6D
LD A,(HL) 7E
Fetch low byte of address/line number from memory
5D6E
INC HL 23
Advance HL to high byte
5D6F
LD H,(HL) 66
Fetch high byte into H
5D70
LD L,A 6F
Move low byte from A to L - HL now contains the value
5D71
INC E 1C
INCrement E to mark input was processed
5D72
INC D 14
INCrement D to mark a number/value was found
5D73
JUMP back to 5D0EH to continue parsing (look for more digits or delimiter)
5D75H - Display Line Number
This routine displays a line number in decimal format. It uses a powers-of-10 table at 5D9FH to convert the binary value in HL to ASCII digits. Each digit is output via the character output routine at 5939H. After output, the tab counter at 53BBH is set to FFH and a trailing space is printed.
5D75
PUSH HL E5
Save HL (line number to display) onto stack
5D76
PUSH DE D5
Save DE onto stack
5D77
PUSH BC C5
Save BC onto stack
5D78
LD DE,5D9FH 11 9F 5D
Point DE to powers-of-10 table at 5D9FH (10000, 1000, 100, 10, 1)
5D7B
LD A,(DE) 1A
[LOOP] Fetch low byte of current power-of-10 from table
5D7C
LD C,A 4F
Store low byte in C
5D7D
INC DE 13
Advance DE to high byte
5D7E
LD A,(DE) 1A
Fetch high byte of current power-of-10
5D7F
LD B,A 47
Store high byte in B - BC now contains power-of-10
5D80
INC DE 13
Advance DE to next table entry
5D81
PUSH DE D5
Save table pointer onto stack
5D82
LD A,AFH 3E AF
Load A with AFH - will become '0' (30H) after first INC A
5D84
INC A 3C
[DIGIT LOOP] INCrement digit counter (starts at B0H, then 31H='1', etc.)
5D85
LD D,H 54
Copy H to D - save HL in DE before subtraction
5D86
LD E,L 5D
Copy L to E - DE now equals HL
5D87
ADD HL,BC 09
Add BC (negative power-of-10) to HL - effectively subtracting
5D88
If CARRY (no borrow, subtraction successful), LOOP back to count another digit
5D8A
EX DE,HL EB
Restore HL from DE (value before last subtraction)
5D8B
POP DE D1
Restore table pointer from stack
5D8C
GOSUB to output digit character in A to display
5D8F
INC C 0C
INCrement C (low byte of power) - test if table exhausted
5D90
If NZ FLAG (more entries in table), LOOP back to process next power-of-10
5D92
POP BC C1
Restore BC from stack
5D93
POP DE D1
Restore DE from stack
5D94
POP HL E1
Restore HL from stack
5D95
LD A,FFH 3E FF
Load A with FFH for tab counter reset
5D97
LD (53BBH),A 32 BB 53
Store FFH to tab/column counter at 53BBH - reset column tracking
5D9A
LD A,20H 3E 20
Load A with 20H (ASCII space)
5D9C
JUMP to output space character and return to caller
5D9FH - Powers of 10 Table (Negated)
This table contains negated powers of 10 in little-endian format, used by the line number display routine. The values are stored as two's complement negatives so ADD can be used for subtraction. Table entries: -10000 (D8F0H), -1000 (FC18H), -100 (FF9CH), -10 (FFF6H), -1 (FFFFH), terminator (FFH).
5D9F-5DA0
DEFW 0D8F0H ; -10000 (D8F0H = 55536 unsigned, or -10000 signed) F0 D8
5DA1-5DA2
DEFW 0FC18H ; -1000 (FC18H = 64536 unsigned, or -1000 signed) 18 FC
5DA3-5DA4
DEFW 0FF9CH ; -100 (FF9CH = 65436 unsigned, or -100 signed) 9C FF
5DA5-5DA6
DEFW 0FFF6H ; -10 (FFF6H = 65526 unsigned, or -10 signed) F6 FF
5DA7-5DA8
DEFW 0FFFFH ; -1 (FFFFH = 65535 unsigned, or -1 signed) FF FF
5DA9H - Check Memory Full
This routine checks if memory is full by comparing the symbol table top (5313H) minus 100H against the program text end (5315H). If there is insufficient space, it displays a "FULL" error message. Returns with CARRY clear if OK, displays error if full.
5DA9
PUSH HL E5
Save HL onto stack
5DAA
PUSH DE D5
Save DE onto stack
5DAB
LD HL,(5313H) 2A 13 53
Load HL with symbol table top address from 5313H
5DAE
LD DE,(5315H) ED 5B 15 53
Load DE with program text end address from 5315H
5DB2
DEC H 25
DECrement H - subtract 100H from symbol table top for safety margin
5DB3
NOP 00
No operation (placeholder or patched code)
5DB4
NOP 00
No operation (placeholder or patched code)
5DB5
NOP 00
No operation (placeholder or patched code)
5DB6
GOSUB to compare HL with DE - check if symbol table would collide with program
5DB9
POP DE D1
Restore DE from stack
5DBA
POP HL E1
Restore HL from stack
5DBB
RET NC D0
If NO CARRY (HL >= DE, sufficient space), RETURN normally
5DBC
Point HL to error message "FULL" at 5997H
5DBF
JUMP to error display routine - show "FULL" error and abort
5DC2H - Compare HL with DE
This utility routine compares the 16-bit value in HL against DE. Returns: Z flag set if HL equals DE. CARRY flag set if HL is less than DE. This is used extensively for bounds checking and address comparisons throughout the editor.
5DC2
LD A,H 7C
Load A with high byte of HL
5DC3
SUB D 92
SUBtract high byte of DE from A - sets flags
5DC4
RET NZ C0
If NZ FLAG (high bytes differ), RETURN - Z clear, CARRY indicates H < D
5DC5
LD A,L 7D
High bytes equal - load A with low byte of HL
5DC6
SUB E 93
SUBtract low byte of DE from A - final comparison
5DC7
RET C9
RETURN with Z flag set if equal, CARRY set if HL < DE
5DC8H - Collect Search String
This routine collects a search string from the input buffer into the search buffer at 5301H. The string length is stored at 5300H. Maximum string length is 16 characters. After collection, it initiates a search through the program text to find matching lines.
5DC8
LD DE,5301H 11 01 53
Point DE to search string buffer at 5301H
5DCB
LD B,00H 06 00
Initialize B to 00H as character counter
5DCD
[LOOP] GOSUB to get next character from input, Z flag set if end of input
5DD0
If Z FLAG (end of input), JUMP to 5DDDH to start search
5DD2
LD (DE),A 12
Store character in search buffer
5DD3
INC DE 13
Advance buffer pointer
5DD4
INC B 04
INCrement character counter
5DD5
LD A,B 78
Copy counter to A for comparison
5DD6
LD (5300H),A 32 00 53
Store current string length at 5300H
5DD9
CP 10H FE 10
Compare counter against 10H (16) - maximum search string length
5DDB
If NZ FLAG (not at maximum), LOOP back to get more characters
5DDD
LD HL,(5311H) 2A 11 53
Load HL with current line pointer from 5311H - start search from here
5DE0
PUSH HL E5
Save starting position onto stack (unused, seems like dead code)
5DE1
POP HL E1
[SEARCH LOOP] Restore/update current search position
5DE2
INC HL 23
Skip past line number low byte
5DE3
INC HL 23
Skip past line number high byte
5DE4
LD E,(HL) 5E
Fetch line length byte into E
5DE5
INC HL 23
Advance past length byte to line text
5DE6
LD D,00H 16 00
Clear D - DE now contains line length
5DE8
ADD HL,DE 19
Add line length to HL - point to next line
5DE9
EX DE,HL EB
DE = next line address, HL = line length (will be overwritten)
5DEA
LD HL,(5315H) 2A 15 53
Load HL with program text end from 5315H
5DED
DEC HL 2B
DECrement to get last valid address
5DEE
GOSUB to compare HL (end) with DE (next line) - check if past end
5DF1
If NO CARRY (not past end), JUMP to 5DF9H to continue search
5DF3
Point HL to "NOT FOUND" error message at 596BH
5DF6
JUMP to error display routine - string not found
5DF9
EX DE,HL EB
HL = next line address
5DFA
PUSH HL E5
Save next line address for loop continuation
5DFB
INC HL 23
Skip line number low byte
5DFC
INC HL 23
Skip line number high byte
5DFD
LD C,(HL) 4E
Fetch line length into C
5DFE
PUSH HL E5
Save position (unused, dead code pattern)
5DFF
POP HL E1
[COMPARE POSITION LOOP] Restore position
5E00
INC HL 23
Advance to next comparison start position in line
5E01
LD DE,5300H 11 00 53
Point DE to search string length at 5300H
5E04
LD A,(DE) 1A
Fetch search string length
5E05
LD B,A 47
Store search string length in B as comparison counter
5E06
INC DE 13
Advance DE to first character of search string
5E07
LD A,C 79
Load remaining line length into A
5E08
CP B B8
Compare remaining line length against search string length
5E09
If CARRY (line shorter than search string), JUMP to next line
5E0B
PUSH HL E5
Save current comparison position
5E0C
DEC C 0D
DECrement remaining line length counter
5E0D
LD A,(DE) 1A
[COMPARE CHAR LOOP] Fetch character from search string
5E0E
CP (HL) BE
Compare with character in line text
5E0F
INC HL 23
Advance line pointer
5E10
INC DE 13
Advance search string pointer
5E11
If NZ FLAG (mismatch), JUMP to try next position in line
5E13
DECrement B and loop if more chars to compare - continue matching
5E15
POP HL E1
Match found! Discard saved comparison position
5E16
POP HL E1
Discard saved next line address
5E17
LD BC,0001H 01 01 00
Load BC with 0001H - display one matching line
5E1A
JUMP to 5E4FH to display the matching line
5E1CH - List Command Handler
This routine implements the LIST command, displaying program lines. It prompts for parameters, then lists lines starting from the specified line number. The listing can be limited to a count or continue to the end. Uses print flag at 53C5H to control output destination.
5E1C
LD HL,53C5H 21 C5 53
Point HL to print flag at 53C5H
5E1F
INC (HL) 34
INCrement print flag - enable listing output mode
5E20
Point HL to "LIST:" prompt string at 5AF2H
5E23
GOSUB to display prompt string
5E26
GOSUB to get user input line
5E29
LD B,AFH 06 AF
Load B with AFH - parameter for parse routine (delimiter/flag)
5E2B
PUSH AF F5
Save flags from input routine
5E2C
GOSUB to parse line range parameters
5E2F
POP AF F1
Restore saved flags
5E30
LD (53BCH),A 32 BC 53
Store input state to 53BCH
5E33
INC B 04
Test if B is zero (INC then DEC pattern)
5E34
DEC B 05
Restore B - Z flag set if B was zero
5E35
LD BC,FFFFH 01 FF FF
Default: list all lines (FFFFH = maximum count)
5E38
If NZ FLAG (B was non-zero), JUMP to 5E44H with default count
5E3A
LD BC,0010H 01 10 00
No parameters - default to listing 16 lines
5E3D
LD HL,(5315H) 2A 15 53
Load HL with program end address from 5315H
5E40
EX DE,HL EB
DE = program end (for range checking)
5E41
LD HL,(5311H) 2A 11 53
Load HL with current line pointer from 5311H
5E44
[LIST LOOP] GOSUB to compare HL with DE - check if at end
5E47
RET Z C8
If Z FLAG (reached end), RETURN - listing complete
5E48
GOSUB to check for BREAK key press
5E4B
DEC BC 0B
DECrement line count remaining
5E4C
LD A,B 78
Load B into A
5E4D
OR C B1
OR with C - test if BC is now zero
5E4E
RET Z C8
If Z FLAG (count exhausted), RETURN
5E4F
LD (5311H),HL 22 11 53
Update current line pointer at 5311H
5E52
PUSH DE D5
Save end address onto stack
5E53
LD E,(HL) 5E
Fetch line number low byte
5E54
INC HL 23
Advance to high byte
5E55
LD D,(HL) 56
Fetch line number high byte - DE = line number
5E56
INC HL 23
Advance past line number to length byte
5E57
EX DE,HL EB
HL = line number, DE = pointer to length
5E58
LD A,(53C5H) 3A C5 53
Fetch print flag from 53C5H
5E5B
OR A B7
Test if print flag is zero (display to screen)
5E5C
If Z FLAG (screen output), GOSUB to display line number
5E5F
EX DE,HL EB
HL = pointer to length byte
5E60
LD E,(HL) 5E
Fetch line length into E
5E61
INC HL 23
[PRINT CHAR LOOP] Advance to next character
5E62
DEC E 1D
DECrement character count remaining
5E63
If POSITIVE (more characters), JUMP to 5E6CH to print next char
5E66
Line complete - GOSUB to output carriage return
5E69
POP DE D1
Restore end address from stack
5E6A
LOOP back to list next line
5E6C
LD A,(HL) 7E
Fetch character from line text
5E6D
GOSUB to output character to display
5E70
LOOP back to print next character
5E72H - Symbol Value Retrieval Entry Point (Alternate)
This is an alternate entry point for symbol value retrieval. It sets the carry flag before falling through to the main routine at 5E75H. The carry flag indicates a specific retrieval mode. Entry: None explicit. Exit: BC=0001H, HL=value from 5319H or 531BH depending on carry state.
5E72
SCF 37
Set Carry Flag to indicate alternate retrieval mode
5E73
LD B,AFH 06 AF
Load Register B with AFH (175 decimal) - this value is overwritten immediately at 5E75H
5E75
LD BC,5E4FH 01 4F 5E
Load BC with return address 5E4FH - this overwrites the B=AFH from previous instruction
5E78
PUSH BC C5
Push return address 5E4FH onto stack - routine will RET to 5E4FH
5E79
PUSH AF F5
Save Accumulator and Flags (including Carry state) onto stack
5E7A
LD HL,(5311H) 2A 11 53
Load HL with pointer from 5311H (current symbol table position)
5E7D
LD E,(HL) 5E
Load E with low byte of address pointed to by HL
5E7E
INC HL 23
Advance HL to next byte
5E7F
LD D,(HL) 56
Load D with high byte - DE now contains 16-bit value from (5311H)
5E80
EX DE,HL EB
Exchange DE and HL - HL now contains the retrieved value
5E81
GOSUB to 5CDAH to process/validate the symbol value
5E84
LD BC,0001H 01 01 00
Load BC with 0001H - indicates single value retrieved
5E87
LD HL,(5319H) 2A 19 53
Load HL with value from 5319H (symbol value storage)
5E8A
POP AF F1
Restore Accumulator and Flags from stack
5E8B
RET C D8
If Carry Flag was set (from 5E72H entry), return with HL=(5319H)
5E8C
LD HL,(5315H) 2A 15 53
Load HL with pointer from 5315H (alternate symbol pointer)
5E8F
EX DE,HL EB
Exchange DE and HL - DE now has pointer from 5315H
5E90
LD HL,(531DH) 2A 1D 53
Load HL with value from 531DH (comparison value)
5E93
GOSUB to 5DC2H to compare HL and DE
5E96
RET NZ C0
If comparison result is Not Zero (not equal), return
5E97
LD HL,(531BH) 2A 1B 53
Load HL with value from 531BH (final result value)
5E9A
RET C9
Return to caller (via pushed 5E4FH address)
5E9BH - Symbol Lookup with Colon Delimiter
This routine searches for a symbol name followed by a colon character (3AH). It is used for label definitions in the assembler. If the symbol is not found or is undefined, an error is generated. Entry: Symbol name in input buffer. Exit: HL=symbol table entry address, DE=end pointer, BC=length.
5E9B
LD B,3AH 06 3A
Load B with 3AH (ASCII colon ':') - delimiter to search for
5E9D
GOSUB to 5D09H to search for symbol with delimiter in B
5EA0
PUSH DE D5
Save DE (end position after symbol) onto stack
5EA1
GOSUB to 5CDAH to validate/process symbol
5EA4
EX DE,HL EB
Exchange DE and HL
5EA5
LD HL,(531BH) 2A 1B 53
Load HL with symbol value from 531BH
5EA8
PUSH HL E5
Save symbol value onto stack
5EA9
PUSH DE D5
Save DE onto stack
5EAA
PUSH AF F5
Save Accumulator and Flags onto stack
5EAB
GOSUB to 5D07H for additional symbol processing
5EAE
POP AF F1
Restore Accumulator and Flags from stack
5EAF
INC D 14
Increment D (test for D=FFH becoming 00H)
5EB0
DEC D 15
Decrement D back - sets Z flag if D was 00H
5EB1
POP DE D1
Restore DE from stack
5EB2
If D was not zero (symbol found), jump to 5EBDH to continue
5EB4
OR A B7
Test Accumulator - clear carry, set Z flag if A=0
5EB5
If A=0, jump to 5EC6H (skip error)
5EB7
Load HL with address 598BH - "UNDEF" error message
5EBA
JUMP to 592BH to display error message and abort
5EBD
GOSUB to 5DC2H to compare values
5EC0
If Carry set (comparison failed), jump to 5D24H for error handling
5EC3
GOSUB to 5CDAH for symbol processing
5EC6
LD HL,(531DH) 2A 1D 53
Load HL with value from 531DH
5EC9
EX DE,HL EB
Exchange DE and HL
5ECA
POP HL E1
Restore HL (symbol value) from stack
5ECB
POP BC C1
Restore BC (end position) from stack
5ECC
RET C9
Return to caller with results
5ECDH - Symbol Table Entry Creation/Update
This routine creates or updates a symbol table entry. It first validates the symbol via 5CC7H, then manages memory allocation by moving existing entries to make room for new data. Uses pointers at 531DH, 531BH, 5311H, 5315H, and 5319H. Entry: Symbol information set up by previous calls. Exit: Memory reorganized, pointers updated.
5ECD
GOSUB to 5CC7H to validate symbol entry
5ED0
If validation failed (NZ), jump to 5EB7H to display "UNDEF" error
5ED2
LD BC,5C56H 01 56 5C
Load BC with return address 5C56H
5ED5
PUSH HL E5
Save HL onto stack
5ED6
PUSH BC C5
Push return address 5C56H onto stack
5ED7
LD HL,(531DH) 2A 1D 53
Load HL with end pointer from 531DH
5EDA
EX DE,HL EB
Move end pointer to DE
5EDB
LD HL,(531BH) 2A 1B 53
Load HL with start pointer from 531BH
5EDE
LD (531DH),HL 22 1D 53
Update 531DH with value from 531BH
5EE1
Jump forward to 5EE6H to continue processing
5EE3
GOSUB to 5E9BH for symbol lookup with colon delimiter
5EE6
PUSH HL E5
Save HL (current position) onto stack
5EE7
LD (5311H),HL 22 11 53
Store current position into 5311H (symbol table pointer)
5EEA
LD HL,(5315H) 2A 15 53
Load HL with pointer from 5315H
5EED
GOSUB to 5DC2H to compare pointers
5EF0
If pointers not equal, jump to 5F08H
5EF2
EX (SP),HL E3
Exchange HL with top of stack
5EF3
PUSH HL E5
Save exchanged value onto stack
5EF4
PUSH DE D5
Save DE onto stack
5EF5
LD A,(HL) 7E
Load A with byte at (HL) - low byte of address
5EF6
INC HL 23
Advance HL to next byte
5EF7
LD H,(HL) 66
Load H with high byte of address
5EF8
LD L,A 6F
Load L with low byte - HL now contains the address
5EF9
GOSUB to 5CDAH to process the address
5EFC
LD HL,(5319H) 2A 19 53
Load HL with value from 5319H
5EFF
LD (5311H),HL 22 11 53
Store into 5311H (update symbol table pointer)
5F02
POP DE D1
Restore DE from stack
5F03
POP HL E1
Restore HL from stack
5F04
LD (531DH),HL 22 1D 53
Store HL into 531DH (update end pointer)
5F07
EX (SP),HL E3
Exchange HL with top of stack
5F08
PUSH DE D5
Save DE (source address for block move) onto stack
5F09
XOR A AF
Clear A to zero
5F0A
SUB E 93
A = 0 - E (negate E)
5F0B
LD E,A 5F
Store negated low byte in E
5F0C
SBC A,D 9A
A = A - D - Carry (continue negation)
5F0D
SUB E 93
A = A - E (complete two's complement of DE)
5F0E
LD D,A 57
Store negated high byte in D - DE now contains -DE
5F0F
ADD HL,DE 19
HL = HL + (-DE) = HL - DE (calculate byte count)
5F10
INC HL 23
Increment byte count by 1
5F11
INC HL 23
Increment byte count by 1 more (adjust for boundary)
5F12
LD B,H 44
Copy H to B (high byte of count)
5F13
LD C,L 4D
Copy L to C - BC now contains byte count for LDIR
5F14
POP HL E1
Restore HL (source address) from stack
5F15
POP DE D1
Restore DE (destination address) from stack
5F16
LDIR ED B0
Block move BC bytes from (HL) to (DE), incrementing
5F18
DEC DE 1B
Decrement DE (adjust end pointer)
5F19
DEC DE 1B
Decrement DE again (point to last valid byte)
5F1A
EX DE,HL EB
Exchange DE and HL
5F1B
LD (5315H),HL 22 15 53
Store new end pointer into 5315H
5F1E
RET C9
Return to caller (via pushed 5C56H address)
5F1FH - File Write Command Handler
This routine handles writing the source file to disk. It initializes file I/O via 6107H, skips any parameters via 5BBEH, sends a D3H marker byte, then outputs all source lines from memory starting at 5315H to address 7700H. The file is terminated with a 1AH (EOF) character. Entry: Command line parsed. Exit: File written to disk, 53BAH flag cleared.
5F1F
GOSUB to 6107H to initialize file output operations
5F22
GOSUB to 5BBEH to skip spaces and get next non-space character
5F25
If character found (NZ), jump to 5D24H for syntax error
5F28
LD C,D3H 0E D3
Load C with D3H - file format marker byte
5F2A
GOSUB to 6121H to write marker byte to file
5F2D
LD HL,53BAH 21 BA 53
Load HL with address of file operation flag at 53BAH
5F30
INC (HL) 34
Increment flag to indicate file write in progress
5F31
PUSH HL E5
Save flag address onto stack for later restoration
5F32
LD BC,0000H 01 00 00
Load BC with 0000H - starting line number parameter
5F35
LD HL,(5315H) 2A 15 53
Load HL with source text start pointer from 5315H
5F38
EX DE,HL EB
Move source start to DE
5F39
Load HL with 7700H - end of source text area
5F3C
GOSUB to 5E4FH to output source lines to file
5F3F
LD A,1AH 3E 1A
Load A with 1AH - CP/M EOF marker character
5F41
GOSUB to 710CH to write EOF character to file
5F44
POP HL E1
Restore flag address (53BAH) from stack
5F45
DEC (HL) 35
Decrement flag to indicate file write complete
5F46
RET C9
Return to command handler
5F47H - File Load Command Handler (Entry)
This routine handles loading a source file from disk. It initializes file I/O, reads the D3H format marker, then parses the file content including 5-digit line numbers and source text. Lines are stored in memory with a 2-byte line number followed by a length byte and text. Entry: Filename parsed from command line. Exit: Source file loaded into memory at 7700H and below, pointers updated.
5F47
GOSUB to 6107H to initialize file input operations
5F4A
GOSUB to 5BBEH to skip spaces and get next character
5F4D
If extra parameters found (NZ), jump to 5D24H for syntax error
5F50
GOSUB to 586BH to open file for reading
5F53
GOSUB to 706DH to initialize file read buffer
5F56
GOSUB to 70B6H to read next byte from file
5F59
CP D3H FE D3
Compare A with D3H - check for file format marker
5F5B
If not D3H marker, loop back to 5F56H to keep searching
5F5D
LD HL,(53ABH) 2A AB 53
Load HL with value from 53ABH (line number search parameter)
5F60
LD A,(53ADH) 3A AD 53
Load A with high byte from 53ADH
5F63
GOSUB to 704FH to set up line number comparison
5F66
DEC C 0D
Decrement C (line number digit counter)
5F67
If C went negative (all digits read), jump to 5F74H
5F6A
DEC B 05
Decrement B (match counter)
5F6B
GOSUB to 70C6H to read next character from file
5F6E
CP (HL) BE
Compare read character with expected digit at (HL)
5F6F
INC HL 23
Advance HL to next expected digit
5F70
If no match, jump back to 5F56H to restart search
5F72
Jump back to 5F66H to check next digit
5F74
GOSUB to 70C6H to read next character (skip remaining)
5F77
Decrement B and loop until all skip characters read
5F79
CP 1AH FE 1A
Compare A with 1AH - check for EOF marker
5F7B
RET Z C8
If EOF reached, return to caller
5F7C
LD B,A 47
Save first character of line number in B
5F7D
GOSUB to 5DA9H to prepare for new line entry
5F80
Load HL with 7700H - source text storage area
5F83
LD (5311H),HL 22 11 53
Store 7700H into 5311H (current position pointer)
5F86
LD A,B 78
Restore first character from B
5F87
LD HL,0000H 21 00 00
Initialize HL to 0000H for line number accumulation
5F8A
LD B,05H 06 05
Load B with 05H - 5 digits in line number
5F8C
AND 7FH E6 7F
Mask off high bit of character (strip potential flag bit)
5F8E
GOSUB to 5D31H to accumulate digit into line number in HL
5F91
GOSUB to 70C6H to read next character from file
5F94
Decrement B and loop until all 5 digits processed
5F96
EX DE,HL EB
Move accumulated line number to DE
5F97
LD HL,(5315H) 2A 15 53
Load HL with current text pointer from 5315H
5F9A
LD (HL),E 73
Store low byte of line number at (HL)
5F9C
LD (HL),D 72
Store high byte of line number at (HL)
5F9E
LD (HL),00H 36 00
Store 00H as initial line length
5FA1
LD E,L 5D
Copy L to E - DE now points to length byte
5FA2
GOSUB to 7086H for additional line setup
5FA5
INC HL 23
Advance HL to next character position
5FA6
LD (5315H),HL 22 15 53
Update text pointer at 5315H
5FA9
LD (HL),FFH 36 FF
Store FFH as end-of-text marker
5FAC
LD (HL),FFH 36 FF
Store second FFH marker (FFFFH = end of source)
5FAE
DEC HL 2B
Back up HL to first FFH
5FAF
GOSUB to 70C6H to read next character from file
5FB2
CP 0DH FE 0D
Compare A with 0DH - check for carriage return (end of line)
5FB4
If not CR, jump to 5FBBH to store character
5FB6
GOSUB to 70C6H to read character after CR (likely LF)
5FB9
Jump back to 5F79H to check for EOF or start next line
5FBB
EX DE,HL EB
Exchange DE and HL - HL now points to length byte
5FBC
INC (HL) 34
Increment line length counter
5FBD
EX DE,HL EB
Exchange back - HL points to text position
5FBE
LD (HL),A 77
Store character at current text position
5FBF
Jump back to 5FA5H to process next character
5FC1H - Interactive Line Editor Entry
This routine provides interactive editing of source lines. It validates the line exists via 5D07H and 5CDAH, then displays the line and accepts keyboard input. Supports commands: 'A' (abort edit), 'L' (list remaining), SPACE (advance cursor), ENTER (accept changes). The edit buffer is at 5327H with a maximum of 128 characters. Entry: Line number or context from previous operation. Exit: Line updated in source buffer or edit aborted.
5FC1
GOSUB to 5D07H to get/validate line reference
5FC4
GOSUB to 5CDAH to process line data
5FC7
If line not found (NZ), jump to 5EB7H for "UNDEF" error
5FCA
PUSH HL E5
Save HL (line address) onto stack
5FCB
LD H,B 60
Copy B to H (note: instruction shows as 60H which is LD H,B)
5FCC
LD L,C 69
Copy C to L - HL now contains BC value
5FCD
INC HL 23
Advance past line number low byte
5FCE
INC HL 23
Advance past line number high byte
5FCF
LD C,(HL) 4E
Load C with line length from (HL)
5FD0
LD B,00H 06 00
Clear B - BC now contains line length
5FD2
PUSH BC C5
Save line length onto stack
5FD3
INC HL 23
Advance HL past length byte to start of text
5FD4
LD DE,5327H 11 27 53
Load DE with 5327H - address of edit buffer
5FD7
GOSUB to 5CC1H to copy line text to edit buffer
5FDA
XOR A AF
Clear A to zero
5FDB
LD (DE),A 12
Store null terminator at end of copied text
5FDC
POP DE D1
Restore line length into DE
5FDD
LD HL,5327H 21 27 53
Load HL with edit buffer address 5327H
5FE0
EX (SP),HL E3
Exchange HL with stack - save buffer addr, get line addr
5FE1
GOSUB to 5D75H to display line number
5FE4
EX (SP),HL E3
Exchange back - HL has buffer addr, line addr on stack
5FE5
LD B,00H 06 00
Clear B (character position counter)
5FE7
GOSUB to 5834H to get keystroke from user
5FEA
GOSUB to 5BE4H to validate alphanumeric character
5FED
If Carry set (not alphanumeric), jump to 5FFBH for command check
5FEF
SUB 30H D6 30
Subtract 30H - convert ASCII digit to binary value
5FF1
LD C,A 4F
Save digit value in C
5FF2
LD A,B 78
Load A with current accumulated value from B
5FF3
RLCA 07
Rotate left (multiply by 2)
5FF4
RLCA 07
Rotate left again (now multiplied by 4)
5FF5
ADD A,B 80
Add original B (now multiplied by 5)
5FF6
RLCA 07
Rotate left (now multiplied by 10)
5FF7
ADD A,C 81
Add new digit - A = B*10 + digit
5FF8
LD B,A 47
Store new accumulated value in B
5FF9
Loop back to 5FE7H to get next keystroke
5FFB
PUSH HL E5
Save HL (buffer position) onto stack
5FFC
LD HL,5FE5H 21 E5 5F
Load HL with return address 5FE5H (loop back point)
5FFF
EX (SP),HL E3
Exchange - push return addr, restore buffer position
6000
DEC B 05
Decrement B (test for zero)
6001
INC B 04
Increment B back - Z flag set if B was 0
6002
If B not zero, skip next instruction
6004
INC B 04
If B was zero, set B=1 (minimum value)
6005
CP 41H FE 41
Compare A with 41H (ASCII 'A') - Abort command
6007
If not 'A', jump to 6010H to check next command
6009
POP BC C1
Discard return address from stack
600A
GOSUB to 5937H to output carriage return
600D
POP HL E1
Restore original HL from stack
600E
Jump back to 5FC4H to restart edit (abort current changes)
6010
CP 4CH FE 4C
Compare A with 4CH (ASCII 'L') - List command
6012
If not 'L', jump to 6021H to check next command
6014
LD B,80H 06 80
Load B with 80H (128) - maximum characters to display
6016
GOSUB to 6025H to display remaining line content
6019
GOSUB to 5937H to output carriage return
601C
POP BC C1
Discard return address from stack
601D
LD D,00H 16 00
Clear D (reset display position)
601F
Jump back to 5FDDH to redisplay from start
6021
CP 20H FE 20
Compare A with 20H (ASCII space) - advance command
6023
If not space, jump to 6030H to check next command
6025
LD A,(HL) 7E
[LOOP] Load A with character at current position
6026
OR A B7
Test A - check for null terminator
6027
RET Z C8
If null terminator, return (end of text)
6028
INC D 14
Increment display position counter
6029
GOSUB to 5939H to output character to display
602C
INC HL 23
Advance to next character
602D
Decrement B and loop back to 6025H until count exhausted
602F
RET C9
Return to caller
6030H - Space Command Handler / Character Display Loop
This section handles the SPACE command in the line editor, which advances the cursor through the line displaying characters. It also contains the ENTER command handler (0DH) which commits the edited line, and the backspace handler (08H) which moves back one character. Entry: B=count of characters to advance, HL=current position in edit buffer, D=display position. Exit: Characters displayed, HL advanced, or line committed.
6030
CP 0DH FE 0D
Compare A with 0DH (ASCII carriage return) - Enter key
6032
If Enter key pressed, jump to 6039H to accept line
6034
LD B,80H 06 80
Load B with 80H (128 decimal) - maximum line length
6036
GOSUB to 6025H to display characters from current position
6039
POP BC C1
Remove return address from stack (discard 5FE5H loop return)
603A
POP HL E1
Restore HL (original line address) from stack
603B
LD DE,5327H 11 27 53
Load DE with 5327H - address of edit buffer containing modified text
603E
JUMP to 5ED6H to store edited line back to source
6041H - Edit Command Dispatcher
This routine dispatches edit subcommands based on the character in A. It checks for 'E' (edit), 'C' (change), 'D' (delete), 'Q' (quit), 'I' (insert), 'X' (exit), 'H' (help or home), 'S' (search), 'K' (kill), and backspace (08H). Entry: A=command character, HL=buffer position, B=count, D=display position, E=buffer offset. Exit: Varies by command.
6041
CP 45H FE 45
Compare A with 45H (ASCII 'E') - Edit subcommand
6043
JUMP to 5ED6H to handle edit operation
6046H - Additional Edit Command Checks
Continuation of edit command dispatcher checking for additional commands.
6046
NOP 00
No operation - placeholder or alignment byte
6047
CP 45H FE 45
Compare A with 45H (ASCII 'E') - check for Edit command
6049
If 'E' pressed, jump to 6039H to accept and store line
604B
CP 43H FE 43
Compare A with 43H (ASCII 'C') - Change subcommand
604D
If not 'C', jump to 6066H to check next command
604F
LD A,(HL) 7E
[CHANGE LOOP] Load character at current buffer position
6050
OR A B7
Test A - check for null terminator (end of line)
6051
RET Z C8
If at end of line, return (nothing more to change)
6052
GOSUB to 5834H to get keystroke from user
6055
CP 09H FE 09
Compare A with 09H (TAB key)
6057
If TAB, jump to 605DH to store and advance
6059
CP 1AH FE 1A
Compare A with 1AH (Ctrl-Z / end of input)
605B
If less than 1AH (control char), loop back to get another key
605D
LD (HL),A 77
Store new character at current buffer position
605E
GOSUB to 5939H to echo character to display
6061
INC HL 23
Advance buffer pointer to next position
6062
INC D 14
Increment display position counter
6063
Decrement B (repeat count) and loop if not zero
6065
RET C9
Return when count exhausted
6066
CP 44H FE 44
Compare A with 44H (ASCII 'D') - Delete subcommand
6068
If not 'D', jump to 6073H to check next command
606A
LD A,(HL) 7E
[DELETE LOOP] Load character at current position
606B
OR A B7
Test A - check for end of line
606C
RET Z C8
If at end, return (nothing to delete)
606D
GOSUB to 60A1H to delete character at current position
6070
Decrement B and loop until count exhausted
6072
RET C9
Return after deletions complete
6073
CP 51H FE 51
Compare A with 51H (ASCII 'Q') - Quit command
6075
If 'Q', JUMP to 58D7H to quit editor and return to command mode
6078
CP 49H FE 49
Compare A with 49H (ASCII 'I') - Insert subcommand
607A
If 'I', jump to 608CH for insert mode
607C
CP 58H FE 58
Compare A with 58H (ASCII 'X') - eXtend/exit subcommand
607E
If 'X', jump to 6087H
6080
CP 48H FE 48
Compare A with 48H (ASCII 'H') - Home/beginning subcommand
6082
If not 'H', jump to 60DAH to check more commands
6084
LD (HL),00H 36 00
Store null terminator at current position (truncate line)
6086
LD E,D 5A
Copy display position D to E
6087
LD B,80H 06 80
Load B with 80H (128) - maximum buffer size
6089
GOSUB to 6025H to display remaining text
608C
[INSERT MODE] Get keystroke from user
608F
CP 0DH FE 0D
Compare A with 0DH (carriage return)
6091
If Enter, jump to 6034H to finish and display rest of line
6093
CP 1BH FE 1B
Compare A with 1BH (ESC key)
6095
RET Z C8
If ESC, return (exit insert mode)
6096
CP 08H FE 08
Compare A with 08H (backspace)
6098
If not backspace, jump to 60B1H to insert character
609A
GOSUB to 5B89H to handle backspace
609D
LD BC,608CH 01 8C 60
Load BC with return address 608CH (insert mode loop)
60A0
PUSH BC C5
Push return address onto stack
60A1
PUSH HL E5
[DELETE CHAR] Save current buffer position
60A2
DEC E 1D
Decrement buffer offset counter
60A3
LD A,(HL) 7E
[SHIFT LOOP] Load character at current position
60A4
OR A B7
Test A - check for null terminator
60A5
SCF 37
Set Carry flag (indicates end of string found)
60A6
If at end of string, jump to 60AFH to finish
60A8
INC HL 23
Advance to next character
60A9
LD A,(HL) 7E
Load next character
60AA
DEC HL 2B
Back up to current position
60AB
LD (HL),A 77
Store next char at current position (shift left)
60AC
INC HL 23
Advance to next position
60AD
Loop back to continue shifting
60AF
POP HL E1
Restore original buffer position
60B0
RET C9
Return with Carry set if at end, clear otherwise
60B1
CP 09H FE 09
Compare A with 09H (TAB)
60B3
If TAB, jump to 60B9H to insert it
60B5
CP 1AH FE 1A
Compare A with 1AH (control character limit)
60B7
If control char (below 1AH), ignore and get next key
60B9
PUSH AF F5
Save character to insert
60BA
LD A,E 7B
Load A with current buffer offset
60BB
CP 80H FE 80
Compare with 80H (128) - maximum line length
60BD
If room available (less than 128), jump to insert
60BF
POP AF F1
Discard character (line full)
60C0
Jump back to insert mode loop (ignore char)
60C2
SUB D 92
A = E - D (bytes remaining after cursor)
60C3
LD C,A 4F
Store count in C
60C4
INC C 0C
Increment count (include null terminator)
60C5
LD B,00H 06 00
Clear B - BC is byte count for block move
60C7
ADD HL,BC 09
HL = HL + BC (point to end of text)
60C8
PUSH DE D5
Save DE (display position and offset)
60CA
LD E,L 5D
Copy L to E - DE = end of text
60CB
DEC HL 2B
Back up HL by one (source for LDDR)
60CC
LDDR ED B8
Block move BC bytes from (HL) to (DE), decrementing - shifts text right
60CE
POP DE D1
Restore DE (display position and offset)
60CF
INC D 14
Increment display position
60D0
INC E 1C
Increment buffer offset
60D1
POP AF F1
Restore character to insert
60D2
INC HL 23
Advance HL to insertion point
60D3
LD (HL),A 77
Store inserted character
60D4
INC HL 23
Advance past inserted character
60D5
GOSUB to 5939H to echo character to display
60D8
Jump back to insert mode loop
60DA
CP 53H FE 53
Compare A with 53H (ASCII 'S') - Search subcommand
60DC
If 'S', jump to 60E3H for search mode
60DE
CP 4BH FE 4B
Compare A with 4BH (ASCII 'K') - Kill/search-and-delete
60E0
If not 'K', jump to 6101H for backspace check
60E2
SCF 37
Set Carry flag (indicates delete-after-find mode)
60E3
PUSH AF F5
[SEARCH] Save flags (Carry = delete mode)
60E4
GOSUB to 5834H to get search character
60E7
LD C,A 4F
Store search character in C
60E8
LD A,(HL) 7E
[SEARCH LOOP] Load character at current position
60E9
OR A B7
Test A - check for end of line
60EA
If at end, jump to 60FFH (not found)
60EC
POP AF F1
Restore flags
60ED
PUSH AF F5
Save flags again
60EE
LD A,(HL) 7E
Reload current character
60EF
If Carry clear (search mode), echo character to display
60F2
If Carry set (kill mode), delete character
60F5
If in kill mode, skip position advance
60F7
INC HL 23
Advance to next character
60F8
INC D 14
Increment display position
60F9
LD A,(HL) 7E
Load current character
60FA
CP C B9
Compare with search character
60FB
If no match, continue searching
60FD
Decrement match count, continue if more to find
60FF
POP AF F1
Restore flags (cleanup stack)
6100
RET C9
Return to caller
6101
CP 08H FE 08
Compare A with 08H (backspace)
6103
RET NZ C0
If not backspace, return (unrecognized command)
6104
JUMP to 5B89H to handle backspace operation
6107H - File I/O Initialization
This routine initializes file I/O operations. It clears the file flag at 53ADH, then calls 61A8H to parse the filename and set up the FCB. On return, it validates the result and checks for valid drive specification (0-7). The filename is stored at 53ABH. Entry: Command line contains filename. Exit: A=result code, HL=53ABH if successful, or jumps to error handler.
6107
LD HL,53ADH 21 AD 53
Load HL with address 53ADH (file operation flag byte)
610A
LD (HL),00H 36 00
Clear file flag to 00H (no file operation active)
610C
GOSUB to 61A8H to parse filename from command line
610F
RET Z C8
If Z flag set (successful parse), return
6110
OR A B7
Test A - set flags based on result code
6111
If result non-zero (error), jump to 5BF4H error handler
6114
LD A,C 79
Load A with drive number from C
6115
CP 07H FE 07
Compare with 07H (maximum drive number)
6117
If drive >= 7 (invalid), jump to 5D24H syntax error
611A
LD (HL),A 77
Store drive number at (HL) which is 53ADH
611B
EX DE,HL EB
Exchange DE and HL
611C
LD (53ABH),HL 22 AB 53
Store filename pointer at 53ABH
611F
EX DE,HL EB
Exchange DE and HL - restore original register state
6120
RET C9
Return to caller with file parameters set up
6121H - File Output Byte Handler
This routine outputs a byte to the file. It calls 586BH to handle the actual I/O, retrieves the file column count from 53ADH, calculates remaining space (6 - column), then formats and outputs the data through 7079H. Entry: C=byte to output. Exit: Byte written to file output stream.
6121
GOSUB to 586BH to initialize file output operation
6124
LD A,(53ADH) 3A AD 53
Load A with current column position from 53ADH
6127
LD E,A 5F
Copy column position to E
6128
LD A,06H 3E 06
Load A with 06H (maximum columns)
612A
SUB E 93
A = 6 - column (remaining space)
612B
LD B,A 47
Store remaining count in B
612C
LD HL,(53ABH) 2A AB 53
Load HL with filename/data pointer from 53ABH
612F
PUSH BC C5
Save BC (remaining count and byte to output)
6130
GOSUB to 7079H to perform formatted output
6134
LD A,C 79
Load A with byte to output from C
6135
GOSUB to 710CH to output the byte
6138
DEC E 1D
Decrement column counter E
6139
LD A,(HL) 7E
[OUTPUT LOOP] Load next byte from buffer
613A
INC HL 23
Advance buffer pointer
613B
If Sign flag positive (E >= 0), output byte via 710CH
613E
If Sign flag positive, loop back to 6138H
6141
LD A,20H 3E 20
Load A with 20H (ASCII space)
6143
DEC B 05
Decrement remaining space counter B
6144
If B >= 0, output space character
6147
If B >= 0, loop back to output more spaces
614A
RET C9
Return when padding complete
614BH - Error Message Output Setup
This routine sets up for error message output. It pushes return address 6496H onto the stack twice, then loads A with AFH (XOR A opcode) before continuing. This creates a chain that will execute cleanup code after the error is displayed. Entry: DE=error message address. Exit: Jumps to error display routine.
614B
LD BC,6496H 01 96 64
Load BC with return address 6496H
614E
PUSH BC C5
Push first return address onto stack
614F
LD A,AFH 3E AF
Load A with AFH (opcode for XOR A)
6151
PUSH BC C5
Push second copy of return address
6152
PUSH HL E5
Save HL onto stack
6153
LD HL,(53B8H) 2A B8 53
Load HL with error count from 53B8H
6156
INC HL 23
Increment error count
6157
LD (53B8H),HL 22 B8 53
Store updated error count back to 53B8H
615A
EX DE,HL EB
Exchange DE and HL - HL now has error message address
615B
LD B,A 47
Save A (AFH) in B
615C
LD A,(53C0H) 3A C0 53
Load A with pass number from 53C0H
615F
CP 02H FE 02
Compare with 02H - is this pass 2?
6161
If not pass 2, jump to 617BH to skip error display
6163
GOSUB to 617FH to display error message
6166
LD A,B 78
Restore A from B
6167
OR A B7
Test A - set flags
6168
If A=0, jump to 6176H
616A
LD BC,0001H 01 01 00
Load BC with 0001H
616D
LD DE,5E4FH 11 4F 5E
Load DE with address 5E4FH
6170
LD HL,(5311H) 2A 11 53
Load HL with pointer from 5311H
6173
GOSUB to 6182H to output additional info
6176
LD A,01H 3E 01
Load A with 01H (error flag)
6178
LD (53BFH),A 32 BF 53
Store error flag at 53BFH
617B
EX DE,HL EB
Exchange DE and HL
617C
POP HL E1
Restore HL from stack
617D
POP BC C1
Restore BC from stack
617E
RET C9
Return to caller
617FH - Error Message Display Routine
This routine displays an error message. It sets up the stack to return through 618CH for cleanup, then calls the message output routine at (DE). Uses a trampoline technique with stack manipulation. Entry: DE=message output routine address, HL=error message. Exit: Message displayed, returns through cleanup code.
617F
LD DE,592FH 11 2F 59
Load DE with address 592FH (message output routine)
6182
PUSH DE D5
Push routine address onto stack
6183
PUSH BC C5
Save BC onto stack
6184
PUSH HL E5
Save HL onto stack
6185
PUSH HL E5
Push HL again (will be replaced)
6186
LD HL,618CH 21 8C 61
Load HL with cleanup return address 618CH
6189
EX (SP),HL E3
Exchange - push 618CH, get original HL back
618A
PUSH DE D5
Push routine address (592FH) onto stack
618B
RET C9
RET to 592FH (trampoline jump via stack)
618C
POP HL E1
[CLEANUP] Restore HL from stack
618D
POP BC C1
Restore BC from stack
618E
POP DE D1
Restore DE from stack
618F
LD A,(5876H) 3A 76 58
Load A with flag from 5876H
6193
RET NZ C0
If flag non-zero, return immediately
6194
LD A,(587EH) 3A 7E 58
Load A with print flag from 587EH
6197
OR A B7
Test print flag
6198
RET Z C8
If print flag zero, return
6199
LD (53BCH),A 32 BC 53
Store print flag at 53BCH
619D
LD HL,61A3H 21 A3 61
Load HL with return address 61A3H
61A0
EX (SP),HL E3
Exchange - push 61A3H as return, restore original HL
61A1
PUSH DE D5
Push DE (routine address) onto stack
61A2
RET C9
RET to (DE) - another trampoline call
61A3
XOR A AF
Clear A to zero
61A4
LD (53BCH),A 32 BC 53
Clear print flag at 53BCH
61A7
RET C9
Return to caller
61A8H - Filename Parser Entry
This routine parses a filename from the command line. It skips leading spaces via 5BBBH, then calls 5BBEH to parse the filename. Returns the parsed position in DE and validates the result. Entry: Command line at input buffer. Exit: DE=position after filename, A=result code, Z flag set if successful.
61A8
GOSUB to 5BBBH to skip spaces, get next non-space character
61AB
Jump to 61D9H to continue parsing
61ADH - Register Operand Parser (Register A = 05H)
Entry points for parsing register operands with different register codes loaded into A. These are used by the assembler to validate and encode register references in instructions.
61AD
LD A,05H 3E 05
Load A with 05H - register code for L
61AF
LD BC,043EH 01 3E 04
Load BC with 043EH - parameter for register parsing
61B2
LD BC,033EH 01 3E 03
Load BC with 033EH - alternate parameter
61B5
PUSH HL E5
Save HL onto stack
61B6
LD L,A 6F
Copy register code from A to L
61B7
GOSUB to 61D6H to parse and validate
61BA
If Z flag set (end of input), jump to 61D0H
61BD
LD B,A 47
Save current character in B
61BE
LD A,(DE) 1A
Load next character from input at (DE)
61BF
CP 3BH FE 3B
Compare with 3BH (ASCII ';') - comment delimiter
61C1
If semicolon, jump to 61D0H (end of operand)
61C3
CP 09H FE 09
Compare with 09H (TAB)
61C5
If TAB, jump to 61D0H (end of operand)
61C7
CP 20H FE 20
Compare with 20H (space)
61C9
LD A,B 78
Restore character from B to A
61CB
If space, jump to 61D0H (end of operand)
61CD
CP L BD
Compare A with expected register code in L
61CE
POP HL E1
Restore HL from stack
61CF
RET C9
Return with Z flag set if match
61D0
LD DE,5A18H 11 18 5A
Load DE with error message address 5A18H
61D3
JUMP to 614BH to display error and cleanup
61D6H - Skip Delimiter and Parse
This routine skips delimiters and parses the next token. It calls 5BBEH to skip the delimiter, then returns the parsed position. Entry: Input buffer positioned at delimiter. Exit: DE=position after token, A=first character, Z flag set if end of input.
61D6
GOSUB to 5BBEH to skip delimiter and get next token
61D9
PUSH HL E5
Save HL onto stack
61DA
LD HL,(53A8H) 2A A8 53
Load HL with input buffer pointer from 53A8H
61DD
DEC HL 2B
Back up one position (to current character)
61DE
EX DE,HL EB
Move position to DE
61DF
POP HL E1
Restore HL from stack
61E0
LD C,01H 0E 01
Load C with 01H (single character parsed)
61E2
RET Z C8
If Z flag set (end of input), return
61E3
If no carry (not special), jump to 6206H
61E5
GOSUB to 5BEDH for additional parsing
61E8
LD A,02H 3E 02
Load A with 02H (two characters parsed)
61EA
RET C D8
If Carry set, return with result
61EB
GOSUB to 6206H for expression evaluation
61EF
LD HL,621AH 21 1A 62
Load HL with address 621AH (lookup table)
61F2
LD B,01H 06 01
Load B with 01H (search count)
61F4
GOSUB to 627CH to search table
61F7
LD A,(HL) 7E
Load A with table entry
61F8
AND 0FH E6 0F
Mask to lower nibble
61FB
LD A,(HL) 7E
Reload table entry
61FC
RRCA 0F
Rotate right (divide by 2)
61FD
RRCA 0F
Rotate right again (divide by 4)
61FE
RRCA 0F
Rotate right (divide by 8)
61FF
RRCA 0F
Rotate right (divide by 16) - upper nibble now in lower
6200
AND 0FH E6 0F
Mask to get upper nibble value
6203
CP 10H FE 10
Compare with 10H
6205
RET C9
Return with flags set from comparison
6206H - Token Length Counter
This routine counts the length of a token (identifier or keyword) by scanning characters until a delimiter is found. It increments C for each valid character and calls 5BBEH to get the next character. Entry: DE=input position, C=initial count. Exit: C=token length, A=01H, Z flag clear.
6206
INC C 0C
[TOKEN SCAN] Increment character count in C
6207
GOSUB to 5BBEH to get next character from input
620A
If Z flag set (end of input), jump to 6216H to finish
620C
If no carry (alphanumeric), loop back to count next char
620E
GOSUB to 5BEDH to check for special character
6211
If no carry (valid in identifier), loop back
6213
GOSUB to 5BF4H to back up input pointer
6216
DEC C 0D
Decrement C (adjust for off-by-one)
6217
LD A,01H 3E 01
Load A with 01H (success code)
6219
RET C9
Return with token length in C
621AH - Register Name Lookup Table
This is a lookup table for Z80 register names used by the assembler. Each entry consists of a length byte (in low 5 bits), the register name characters, and a code byte. The table includes single registers (A, B, C, D, E, H, L), register pairs (BC, DE, HL, SP, IX, IY), and condition codes (NZ, Z, NC, C, PO, PE, P, M). Format: [length+flags] [char1] [char2...] [code]
621A-621C
DEFB 01H, 41H, 37H 01 41 37 ; "A" register, code 37H
621D-621F
DEFB 01H, 42H, 30H 01 42 30 ; "B" register, code 30H
6220-6222
DEFB 01H, 43H, 31H 01 43 31 ; "C" register, code 31H
6223-6225
DEFB 01H, 44H, 32H 01 44 32 ; "D" register, code 32H
6226-6228
DEFB 01H, 45H, 33H 01 45 33 ; "E" register, code 33H
6229-622B
DEFB 01H, 48H, 34H 01 48 34 ; "H" register, code 34H
622C-622E
DEFB 01H, 4CH, 35H 01 4C 35 ; "L" register, code 35H
622F-6232
DEFB 02H, 42H, 43H, 40H 02 42 43 40 ; "BC" pair, code 40H
6233-6236
DEFB 02H, 44H, 45H, 41H 02 44 45 41 ; "DE" pair, code 41H
6237-623A
DEFB 02H, 48H, 4CH, 42H 02 48 4C 42 ; "HL" pair, code 42H
623B-623E
DEFB 02H, 53H, 50H, 43H 02 53 50 43 ; "SP" pair, code 43H
623F-6242
DEFB 02H, 49H, 58H, 50H 02 49 58 50 ; "IX" index, code 50H
6243-6246
DEFB 02H, 49H, 59H, 51H 02 49 59 51 ; "IY" index, code 51H
6247-624A
DEFB 02H, 4EH, 5AH, 60H 02 4E 5A 60 ; "NZ" condition, code 60H
624B-624D
DEFB 01H, 5AH, 61H 01 5A 61 ; "Z" condition, code 61H
624E-6251
DEFB 02H, 4EH, 43H, 62H 02 4E 43 62 ; "NC" condition, code 62H
6252-6255
DEFB 02H, 50H, 4FH, 64H 02 50 4F 64 ; "PO" condition, code 64H
6256-6259
DEFB 02H, 50H, 45H, 65H 02 50 45 65 ; "PE" condition, code 65H
625A-625C
DEFB 01H, 50H, 66H 01 50 66 ; "P" condition, code 66H
625D-625F
DEFB 01H, 4DH, 67H 01 4D 67 ; "M" condition, code 67H
6260-6263
DEFB 02H, 41H, 46H, 73H 02 41 46 73 ; "AF" pair, code 73H
6264-6266
DEFB 01H, 49H, 80H 01 49 80 ; "I" register, code 80H
6267-6269
DEFB 01H, 52H, 88H 01 52 88 ; "R" register, code 88H
626A-626D
DEFB 02H, 4FH, 4EH, 90H 02 4F 4E 90 ; "ON" (pseudo), code 90H
626E-6272
DEFB 03H, 4FH, 46H, 46H, 91H 03 4F 46 46 91 ; "OFF" (pseudo), code 91H
6273
DEFB 00H 00 ; End of table marker
6274H - Table Search Mismatch Handler
This routine handles a mismatch during table search. It calculates the skip distance to move to the next table entry by adding the entry length to HL, then continues the search. Entry: HL=current table position, A=entry length, C=search length. Exit: HL advanced to next entry.
6274
LD A,C 79
Load A with remaining character count from C
6275
ADD A,B 80
Add B (skip count) to A
6276
LD C,A 4F
Store total skip in C
6277
LD B,00H 06 00
Clear B - BC now contains skip distance
6279
ADD HL,BC 09
Add skip distance to table pointer HL
627A
POP DE D1
Restore DE (input position) from stack
627B
POP BC C1
Restore BC (search parameters) from stack
627CH - Table Search Main Loop
This is the main table search routine. It scans a table looking for a match against the string at (DE) with length C. Each table entry has a length byte (in bits 0-4), followed by the characters, followed by a code byte. Returns with Carry set if no match found (end of table). Entry: HL=table start, DE=search string, C=string length, B=entry count. Exit: HL=matching entry (or past end), Carry set if not found.
627C
LD A,(HL) 7E
[SEARCH LOOP] Load table entry header byte
627D
AND 1FH E6 1F
Mask to get entry length (bits 0-4)
627F
SCF 37
Set Carry flag (assume no match / end of table)
6280
RET Z C8
If length=0 (end marker), return with Carry set
6281
INC HL 23
Advance HL past header to first character
6282
PUSH BC C5
Save search parameters
6283
PUSH DE D5
Save input position
6284
CP C B9
Compare entry length with search length
6285
If lengths differ, jump to 6275H to skip entry
6287
LD A,(DE) 1A
[COMPARE LOOP] Load character from search string
6288
INC DE 13
Advance search string pointer
6289
CP (HL) BE
Compare with table entry character
628A
If mismatch, jump to 6274H to try next entry
628C
INC HL 23
Advance table pointer
628D
DEC C 0D
Decrement remaining characters to compare
628E
If more characters, loop back to compare next
6290
POP DE D1
Restore DE (discard saved input position)
6291
POP BC C1
Restore BC (discard saved search params)
6292
RET C9
Return with Carry clear - match found, HL points to code byte
6293H - Expression Evaluator Entry (with CR check)
This routine initializes expression evaluation with a check for carriage return. It saves registers, initializes HL to 0000H as the accumulator, pushes it, then checks if the current character is CR (0DH). Entry: A=expression type, DE=input position. Exit: Jumps to 62AEH for main evaluation.
6293
PUSH BC C5
Save BC onto stack
6294
PUSH HL E5
Save HL onto stack
6295
LD HL,0000H 21 00 00
Initialize HL to 0000H (expression accumulator)
6298
PUSH HL E5
Push initial value onto stack
6299
LD B,A 47
Save expression type in B
629A
LD A,(DE) 1A
Load current character from input
629B
CP 0DH FE 0D
Compare with 0DH (carriage return)
629D
LD A,B 78
Restore expression type to A
629E
Jump to 62AEH to continue expression evaluation
62A0H - Expression Evaluator Main Entry
This is the main entry point for expression evaluation. It initializes the accumulator at 53C1H to 0000H, sets up registers, and begins parsing the expression. Used for assembly-time expression calculation. Entry: None specific. Exit: Result in HL and at 53C1H.
62A0
PUSH BC C5
Save BC onto stack
62A1
PUSH HL E5
Save HL onto stack
62A2
LD HL,0000H 21 00 00
Initialize HL to 0000H
62A5
LD (53C1H),HL 22 C1 53
Store 0000H at expression accumulator 53C1H
62A8
LD B,H 44
Set B = 00H (operator code - none)
62A9
LD C,H 4C
Set C = 00H (flags/state)
62AA
PUSH BC C5
[PARSE LOOP] Save operator and flags
62AB
GOSUB to 61D6H to parse next token
62AE
If token found (NZ), jump to 62BDH to process it
62B0
POP BC C1
Restore operator and flags
62B1
INC B 04
Test B (operator code) by incrementing
62B2
DEC B 05
Restore B - Z flag set if B was 00H
62B3
If no pending operator (B=0), jump to 61D0H error
62B6
LD HL,(53C1H) 2A C1 53
Load HL with expression result from 53C1H
62B9
EX DE,HL EB
Move result to DE
62BA
POP HL E1
Restore original HL
62BB
POP BC C1
Restore original BC
62BC
RET C9
Return with result in DE
62BD
OR A B7
Test A (token type)
62BE
If A=0 (symbol reference), jump to 6305H
62C0
DEC A 3D
Decrement A - test for type 1
62C1
If A was 1 (numeric), jump to 635AH
62C4
LD A,(DE) 1A
Load character at current position
62C5
CP 27H FE 27
Compare with 27H (ASCII single quote)
62C7
If quote, jump to 63A0H for character constant
62CA
LD HL,(53B6H) 2A B6 53
Load HL with current location counter from 53B6H
62CD
CP 24H FE 24
Compare with 24H (ASCII '$' - current address)
62CF
If '$', jump to 6308H to use location counter
62D1
GOSUB to 62E8H to check for operator
62D4
CP 2BH FE 2B
Compare with 2BH (ASCII '+' - addition)
62D6
If '+', loop back to 62AAH for next operand
62D8
CP 2DH FE 2D
Compare with 2DH (ASCII '-' - subtraction)
62DA
If not '-', jump to 62E2H error handler
62DC
LD A,C 79
Load A with flags from C
62DD
CPL 2F
Complement A (toggle sign flag)
62DE
OR A B7
Set flags based on result
62DF
LD C,A 4F
Store updated flags in C
62E0
If flags non-zero, loop back to parse next
62E2
LD DE,5AA4H 11 A4 5A
Load DE with error message address 5AA4H
62E5
JUMP to 614BH to display error
62E8H - Operator/Delimiter Check
This routine checks if the current character is an operator or delimiter. It pops the return address, checks for space (20H), TAB (09H), semicolon (3BH), comma (2CH), or close parenthesis (29H). If a delimiter is found, it backs up the input pointer and returns to the expression end handler. Entry: Stack has return address. Exit: A=character, or jumps to delimiter handler.
62E8
POP DE D1
Pop return address into DE (will be discarded or used)
62E9
CP 20H FE 20
Compare A with 20H (space)
62EB
If space, jump to 62B0H to end expression
62ED
CP 09H FE 09
Compare A with 09H (TAB)
62EF
If TAB, jump to 62B0H to end expression
62F1
POP BC C1
Pop saved BC (operator/flags)
62F2
CP 3BH FE 3B
Compare A with 3BH (semicolon - comment)
62F4
If semicolon, jump to 6300H
62F6
CP 2CH FE 2C
Compare A with 2CH (comma)
62F8
If comma, jump to 6300H
62FA
CP 29H FE 29
Compare A with 29H (close parenthesis)
62FC
If close paren, jump to 6300H
62FE
PUSH DE D5
Push DE back (restore return address)
62FF
RET C9
Return to caller with A=character
6300
GOSUB to 5BF4H to back up input pointer
6303
Jump to 62B6H to return expression result
6305H - Symbol Reference Handler
This routine handles symbol references in expressions. It calls 65A6H to look up the symbol value, then continues expression processing. Entry: DE=symbol name position. Exit: HL=symbol value.
6305
GOSUB to 65A6H to look up symbol in symbol table
6308
POP BC C1
Pop operator and flags from stack
6309
INC C 0C
Increment C (operand count)
630A
LD C,00H 0E 00
Reset C to 00H
630C
If operand count was non-zero, jump to 6314H
630F
SUB L 95
A = 0 - L (negate low byte)
6310
LD L,A 6F
Store negated low byte in L
6311
SBC A,H 9C
A = 0 - H - Carry (negate high byte with borrow)
6312
SUB L 95
A = A - L (complete two's complement)
6313
LD H,A 67
Store in H - HL is now negated
6314
PUSH BC C5
Save operator/flags
6315
LD DE,63D4H 11 D4 63
Load DE with return address 63D4H
6318
PUSH DE D5
Push return address onto stack
6319
LD A,B 78
Load A with operator code from B
631A
OR A B7
Test operator code
631B
If operator pending, jump to 6321H
631D
LD (53C1H),HL 22 C1 53
Store HL as first operand at 53C1H
6320
RET C9
Return (to 63D4H)
6321
CP 2BH FE 2B
Compare operator with 2BH ('+' addition)
6323
If '+', jump to 63C0H for addition
6326
CP 2DH FE 2D
Compare operator with 2DH ('-' subtraction)
6328
If '-', jump to 63BAH for subtraction
632B
CP 26H FE 26
Compare operator with 26H ('&' AND)
632D
If '&', jump to 63C9H for bitwise AND
6330
CP 3CH FE 3C
Compare operator with 3CH ('<' shift/multiply)
6332
If unknown operator, jump to 62E2H error
6334
EX DE,HL EB
Exchange DE and HL - DE = new operand
6335
LD HL,(53C1H) 2A C1 53
Load HL with accumulator from 53C1H
6338
LD A,D 7A
Load A with high byte of operand
6339
RLA 17
Rotate left through carry - test sign bit
633A
If negative (shift right), jump to 6349H
633C
INC DE 13
[SHIFT LEFT LOOP] Increment shift counter
633D
LD (53C1H),HL 22 C1 53
Store current value
6341
LD C,L 4D
Copy L to C - BC = HL
6342
ADD HL,BC 09
HL = HL + BC (double HL = shift left)
6343
DEC DE 1B
Decrement shift counter
6344
LD A,D 7A
Load high byte of counter
6345
OR E B3
OR with low byte - test if zero
6346
If more shifts needed, loop back
6348
RET C9
Return with shifted result in HL
6349
DEC DE 1B
[SHIFT RIGHT LOOP] Decrement (make positive)
634A
LD (53C1H),HL 22 C1 53
Store current value
634D
XOR A AF
Clear A and Carry
634E
LD A,H 7C
Load high byte
634F
RRA 1F
Rotate right through carry (shift right)
6350
LD H,A 67
Store shifted high byte
6351
LD A,L 7D
Load low byte
6352
RRA 1F
Rotate right through carry
6353
LD L,A 6F
Store shifted low byte
6354
INC DE 13
Increment counter (toward zero)
6355
LD A,D 7A
Load high byte of counter
6356
OR E B3
OR with low byte
6357
If more shifts needed, loop back
6359
RET C9
Return with shifted result in HL
635AH - Numeric Constant Parser
This routine parses a numeric constant from the input. It handles decimal (default), hexadecimal (H suffix), octal (O or Q suffix), and binary (B suffix, but 'B' also checked for hex). Initializes HL to 0, sets default base to 10, then scans digits. Entry: DE=input position. Exit: HL=parsed value, continues at 6308H.
635A
LD HL,0000H 21 00 00
Initialize HL to zero. This will accumulate the parsed numeric value.
635D
LD B,0AH 06 0A
Set default numeric base to 10 (decimal). B holds the radix for conversion.
635F
GOSUB to 5BF4H to classify the current character and set up digit count in C.
6362
GOSUB to 5BBEH to skip delimiters and get next significant character into A.
6365
If CARRY not set (character is a digit), JUMP to 637DH to begin digit parsing loop.
Character is not a digit - check for base suffix (H, O, Q, D)
6367
DEC C 0D
Decrement digit counter C. Adjusts for the suffix character just read.
6368
CP 44H FE 44
Compare A against 44H (ASCII D). Check for explicit decimal suffix.
636A
If Z FLAG set (suffix is D for decimal), JUMP to 637DH. Base remains 10.
636C
LD B,08H 06 08
Set base to 8 (octal) in anticipation of O or Q suffix.
636E
CP 4FH FE 4F
Compare A against 4FH (ASCII O). Check for octal suffix.
6370
If Z FLAG set (suffix is O for octal), JUMP to 637DH with base=8.
6372
CP 51H FE 51
Compare A against 51H (ASCII Q). Check for alternate octal suffix.
6374
If Z FLAG set (suffix is Q for octal), JUMP to 637DH with base=8.
6376
LD B,10H 06 10
Set base to 16 (hexadecimal). Only remaining valid suffix is H.
6378
CP 48H FE 48
Compare A against 48H (ASCII H). Check for hexadecimal suffix.
637A
If NZ FLAG set (not H), JUMP to 62E2H - expression syntax error.
[DIGIT PARSING LOOP] - Process each digit and accumulate value in HL
637D
LD A,(DE) 1A
Fetch the next character from source at (DE) into Register A.
637E
INC DE 13
Advance source pointer DE to next character position.
637F
GOSUB to 5BE4H to check if character in A is alphanumeric. Sets CARRY if A-F.
6382
If CARRY not set (digit 0-9), JUMP to 6386H to skip hex adjustment.
6384
SUB 07H D6 07
Subtract 07H from A. Adjusts A-F (41H-46H) down to continue sequence after 9.
6386
SUB 30H D6 30
Subtract 30H (ASCII '0') from A. Converts ASCII digit to binary value 0-15.
6388
CP B B8
Compare digit value in A against base in B. Validates digit is within radix.
6389
If CARRY not set (digit >= base), JUMP to 62E2H - invalid digit for this base.
Multiply accumulator HL by base B, then add new digit
638C
PUSH BC C5
Save BC (B=base, C=digit count) onto stack.
638D
PUSH DE D5
Save source pointer DE onto stack.
638E
LD D,H 54
Copy H to D. DE will hold copy of HL for multiplication.
638F
LD E,L 5D
Copy L to E. Now DE = HL (original accumulator value).
6390
DEC B 05
Decrement B. Prepare for multiply loop (will add HL to itself B-1 times).
6391
ADD HL,DE 19
[MULTIPLY LOOP] Add DE to HL. Accumulates HL = HL * base.
6392
Decrement B and JUMP to 6391H if not zero. Repeats addition base-1 times.
6394
LD E,A 5F
Load the digit value from A into E.
6395
LD D,00H 16 00
Clear D. DE now holds the single digit value (0-15).
6397
ADD HL,DE 19
Add digit value DE to accumulator HL. HL = (HL * base) + digit.
6398
POP DE D1
Restore source pointer DE from stack.
6399
POP BC C1
Restore BC (base and digit count) from stack.
639A
DEC C 0D
Decrement digit counter C.
639B
If NZ FLAG set (more digits remain), LOOP back to 637DH to process next digit.
639D
JUMP to 6308H to continue expression evaluation with parsed value in HL.
63A0H - Character Constant Parser
This routine parses a single-quoted character constant (e.g., 'A'). It extracts the ASCII value of the character between quotes and returns it in HL. Entry: DE points to opening quote. Exit: HL contains character value, continues at 6308H.
63A0
GOSUB to 61D6H to skip delimiter and parse next token. Returns character count in C.
63A3
If Z FLAG set (empty or invalid), JUMP to 62E2H - expression syntax error.
63A6
DEC C 0D
Decrement character count C. Should be exactly 1 for valid char constant.
63A7
If NZ FLAG set (more than one character), JUMP to 62E2H - syntax error.
63AA
LD A,(DE) 1A
Fetch the character value from source at (DE) into Register A.
63AB
LD L,A 6F
Store character ASCII value in L (low byte of result).
63AC
LD H,00H 26 00
Clear H. HL now contains the character value as 16-bit integer.
63AE
GOSUB to 61B5H to advance past the character in the source.
63B1
LD A,(DE) 1A
Fetch next character from source (should be closing quote).
63B2
CP 27H FE 27
Compare A against 27H (ASCII single quote '). Check for closing quote.
63B4
If NZ FLAG set (no closing quote), JUMP to 62E2H - syntax error.
63B7
JUMP to 6308H to continue expression evaluation with character value in HL.
63BAH - Subtraction Operator Handler
This routine handles the subtraction operator (-). It negates the value in HL (two's complement), then falls through to the addition handler to subtract by adding the negative. Entry: HL=right operand. Exit: Result stored in accumulator at 53C1H.
63BA
XOR A AF
Clear Register A to zero and clear all flags.
63BB
SUB L 95
Subtract L from A (0 - L). Begin two's complement negation of HL.
63BC
LD L,A 6F
Store negated low byte back in L.
63BD
SBC A,H 9C
Subtract H from A with borrow (0 - H - carry from low byte).
63BE
SUB L 95
Subtract L to complete high byte negation. A = -H adjusted.
63BF
LD H,A 67
Store negated high byte in H. HL now contains -HL (two's complement).
63C0H - Addition Operator Handler
This routine handles the addition operator (+). It adds the value in HL to the accumulator at 53C1H and stores the result. Also serves as entry point for subtraction (after negation). Entry: HL=operand to add. Exit: Sum stored at 53C1H.
63C0
EX DE,HL EB
Exchange DE and HL. DE now holds the operand to add.
63C1
LD HL,(53C1H) 2A C1 53
Load HL with current accumulator value from 53C1H (Expression Accumulator).
63C4
ADD HL,DE 19
Add operand DE to accumulator HL. HL = accumulator + operand.
63C5
LD (53C1H),HL 22 C1 53
Store the sum back to accumulator at 53C1H.
63C8
RET C9
RETURN to caller with result in accumulator.
63C9H - Bitwise AND Operator Handler
This routine handles the bitwise AND operator (&). It ANDs the value in HL with the accumulator at 53C1H byte-by-byte and stores the result. Entry: HL=mask operand. Exit: Result stored at 53C1H.
63C9
LD DE,53C1H 11 C1 53
Point DE to 53C1H (Expression Accumulator low byte).
63CC
LD A,(DE) 1A
Fetch low byte of accumulator into A.
63CD
AND L A5
AND accumulator low byte with mask low byte L.
63CE
LD (DE),A 12
Store ANDed low byte back to accumulator.
63CF
INC DE 13
Advance DE to point to high byte at 53C2H.
63D0
LD A,(DE) 1A
Fetch high byte of accumulator into A.
63D1
AND H A4
AND accumulator high byte with mask high byte H.
63D2
LD (DE),A 12
Store ANDed high byte back to accumulator.
63D3
RET C9
RETURN to caller with result in accumulator at 53C1H.
63D4H - Expression Continuation Handler
This routine continues expression parsing after an operand has been processed. It checks for additional operators and either continues parsing or returns the result. Entry: After operand processing. Exit: Either continues with next operator or returns to caller.
63D4
GOSUB to 5BBEH to skip delimiters and get next character into A.
63D7
POP BC C1
Restore BC from stack (operator context from expression parser).
63D8
LD B,A 47
Save the next character (potential operator) in B.
63D9
If Z FLAG set (end of expression), JUMP to 62B1H to complete evaluation.
63DC
PUSH BC C5
Save operator context back onto stack for recursive parsing.
63DD
GOSUB to 62E8H to check operator/delimiter and get precedence.
63E0
JUMP to 62AAH to continue expression parsing with next operator.
63E3H - Assembly Initialization
This routine initializes the assembler for a new assembly operation. It clears working variables, resets file flags, and prepares the symbol table pointer. Called at the start of assembly to ensure clean state.
63E3
LD HL,(5313H) 2A 13 53
Load HL with symbol table current pointer from 5313H.
63E6
LD (53C3H),HL 22 C3 53
Store to 53C3H (Symbol Lookup Working Pointer). Initialize search position.
63E9
XOR A AF
Clear Register A to zero.
63EA
LD (HL),A 77
Store zero at symbol table position. Marks end of table.
63EB
LD (53C0H),A 32 C0 53
Clear 53C0H (Current Assembly Pass Number). Reset pass counter.
63EE
LD (587AH),A 32 7A 58
Clear 587AH (Assembly In Progress Flag). Mark assembly not active.
63F1
LD (5876H),A 32 76 58
Clear 5876H (File State Flag). Reset file operation state.
63F4
LD (587EH),A 32 7E 58
Clear 587EH (File Mode Flag). Reset file mode.
63F7
LD (5882H),A 32 82 58
Clear 5882H (File Status Flag). Reset file status.
63FA
LD (5886H),A 32 86 58
Clear 5886H (Additional File Flag). Reset auxiliary file flag.
63FD
GOSUB to 6107H (File I/O Initialization) to set up file buffers.
6400H - Assembly Pass Setup
This routine handles pass initialization and the main assembly loop entry. It checks and initializes pass-related variables, sets up buffer pointers, and begins processing source lines.
6400
INC (HL) 34
Increment value at (HL). Tests if location contains FFH (will wrap to 00H).
6401
DEC (HL) 35
Decrement value back. If was FFH, now 00H and Z flag set.
6402
If NZ FLAG set (value was not FFH), JUMP to 640CH to continue.
6404
LD (HL),06H 36 06
Store 06H at (HL). Initialize counter/flag to 6.
6406
Load HL with 5AFFH. This is a buffer boundary address.
6409
LD (53ABH),HL 22 AB 53
Store 5AFFH to 53ABH (Buffer-related Pointer).
640C
GOSUB to 5BBBH to skip spaces and get next non-space character.
640F
NOP 00
No operation. Placeholder or timing adjustment.
6410
GOSUB to 6F22H to get next source line or command input.
6413
If NZ FLAG set (input received), JUMP to 5D24H to process line.
6416
GOSUB to 61A8H (Filename Parser Entry) to parse any filename.
6419
LD HL,5873H 21 73 58
Point HL to 5873H (File Operation Counter).
641C
LD B,01H 06 01
Load B with 01H. Parameter for table search.
641E
GOSUB to 627CH (Table Search Main Loop) to look up command/directive.
6421
If CARRY set (not found), JUMP to 5D24H to handle as source line.
6424
INC (HL) 34
Increment file operation counter at 5873H.
6425
JUMP back to 640CH to continue main loop.
6427H - Working Variable Initialization
This routine initializes the working variable block at 53B4H-53BFH (12 bytes) to zero, sets up memory pointers, and prepares for assembly pass execution. Called when starting a new assembly pass.
6427
Load HL with 7700H (Extended Work Area base address).
642A
LD (531DH),HL 22 1D 53
Store 7700H to 531DH (Work area pointer).
642D
LD HL,(53B8H) 2A B8 53
Load HL with buffer pointer from 53B8H.
6430
EX DE,HL EB
Exchange DE and HL. DE now holds buffer pointer.
6431
LD B,0CH 06 0C
Load B with 0CH (12 decimal). Count of bytes to clear.
6433
XOR A AF
Clear Register A to zero.
6434
LD HL,53B4H 21 B4 53
Point HL to 53B4H (start of working variable block).
6437
LD (HL),A 77
[CLEAR LOOP] Store zero at (HL).
6438
INC HL 23
Advance HL to next byte.
6439
Decrement B and LOOP to 6437H if not zero. Clears 12 bytes.
643B
INC (HL) 34
Increment byte at 53C0H (HL now points here after loop).
643C
LD A,(HL) 7E
Load the incremented pass counter into A.
643D
CP 03H FE 03
Compare pass counter against 03H. Check if pass 3 (beyond normal).
643F
If NZ FLAG set (pass 1 or 2), JUMP to 6496H to continue assembly.
Pass counter reached 3 - assembly complete, output symbol table
6441
EX DE,HL EB
Exchange DE and HL. Restore buffer pointer to HL.
6442
LD DE,5D75H 11 75 5D
Load DE with 5D75H (address of completion message or routine).
6445
GOSUB to 6182H to perform file operation with DE parameter.
6448
Point HL to 5A88H (message string address).
644B
GOSUB to 617FH (Error Message Display) to show completion message.
644E
GOSUB to 708DH for post-assembly processing.
6451
OR A B7
Test Register A (result from 708DH). Sets Z if zero.
6452
If NZ FLAG set (error or special condition), JUMP to 6486H.
6454
LD A,(587EH) 3A 7E 58
Load A with file mode flag from 587EH.
6457
LD (53BCH),A 32 BC 53
Store to 53BCH (Print/Output Flag).
645A
LD HL,(53C3H) 2A C3 53
Load HL with symbol table pointer from 53C3H.
645D
GOSUB to 5937H to output carriage return.
6460
JUMP to 5200H (Symbol Table Search Entry) to begin symbol table output.
6463H - Symbol Table Output Loop
This routine outputs the symbol table after assembly is complete. It iterates through symbols, displaying each name and value. Part of the post-assembly symbol listing.
6463
LD D,E 53
Copy E to D. Preserves value for later use.
6464
GOSUB to 5856H (File Operation Routine) to set up output.
6467
LD A,(HL) 7E
Fetch symbol entry flags/length byte from (HL).
6468
AND 1FH E6 1F
Mask to get symbol name length (bits 0-4). Max 31 chars.
646A
If Z FLAG set (length=0, end of table), JUMP to 6486H to finish.
646C
LD B,A 47
Copy symbol name length to B as loop counter.
646D
INC HL 23
[OUTPUT NAME LOOP] Advance to next character of symbol name.
646E
LD A,(HL) 7E
Fetch character from symbol name.
646F
GOSUB to 5939H to output character in A to display.
6472
Decrement B and LOOP to 646DH if more characters remain.
6474
LD A,09H 3E 09
Load A with 09H (ASCII Tab character).
6476
GOSUB to 5939H to output tab separator.
6479
INC HL 23
Advance past symbol name to value field.
647A
INC HL 23
Advance to high byte of symbol value.
647B
GOSUB to 6E4EH to output hex byte at (HL) - high byte of value.
647E
DEC HL 2B
Move back to low byte of symbol value.
647F
GOSUB to 6E4EH to output hex byte - low byte of value.
6482
INC HL 23
Advance past low byte.
6483
INC HL 23
Advance to next symbol entry.
6484
LOOP back to 645DH to output next symbol.
6486H - Assembly Completion Handler
This routine handles assembly completion. It clears the output flag, checks if assembly was in progress, and either returns to command mode or outputs the final status byte. Called when assembly finishes or encounters an unrecoverable error.
6486
XOR A AF
Clear Register A to zero.
6487
LD (53BCH),A 32 BC 53
Clear 53BCH (Print/Output Flag). Disable listing output.
648A
LD A,(587AH) 3A 7A 58
Load A with assembly in progress flag from 587AH.
648D
OR A B7
Test if assembly was in progress. Sets Z if not.
648E
If NZ FLAG set (assembly was active), JUMP to 58D7H to return to command mode.
6491
LD C,55H 0E 55
Load C with 55H (ASCII U). Status code for "Undefined" or completion.
6493
GOSUB to 6121H (File Output Byte Handler) to output status byte.
6496H - Main Assembly Loop Entry
This is the main entry point for processing source lines during assembly. It resets the stack, calls file handling, and manages the pass counter. This routine is called repeatedly for each source line.
6496
LD SP,54FEH 31 FE 54
Reset Stack Pointer to 54FEH. Ensures consistent stack for each line.
6499
GOSUB to 5856H (File Operation Routine) for I/O handling.
649C
LD HL,53BFH 21 BF 53
Point HL to 53BFH (Pass Counter location).
649F
DEC (HL) 35
Decrement pass counter at 53BFH.
64A0
If NZ FLAG set (counter not zero), JUMP to 64B0H to continue.
64A2
LD A,(5886H) 3A 86 58
Load A with additional file flag from 5886H.
64A5
OR A B7
Test if flag is set.
64A6
If Z FLAG set (flag clear), JUMP to 64B0H.
64A8
GOSUB to 5866H for file status update.
64AB
SUB 43H D6 43
Subtract 43H from A. Adjust flag value.
64AD
LD (5886H),A 32 86 58
Store adjusted value back to 5886H.
64B0
LD (HL),00H 36 00
Clear the pass counter at (HL).
64B2
LD HL,6496H 21 96 64
Load HL with 6496H (this routine's address).
64B5
PUSH HL E5
Push return address onto stack. Sets up return to main loop.
64B6
XOR A AF
Clear Register A to zero.
64B7
LD (53AAH),A 32 AA 53
Clear 53AAH (Remaining Character Count). Reset input buffer.
64BA
LD HL,(53B4H) 2A B4 53
Load HL with value from 53B4H (line counter or offset).
64BD
EX DE,HL EB
Exchange DE and HL. DE = line counter.
64BE
LD HL,(53B6H) 2A B6 53
Load HL with current address from 53B6H.
64C1
ADD HL,DE 19
Add line counter to current address.
64C2
LD (53B6H),HL 22 B6 53
Store updated address back to 53B6H.
64C5
LD (53AEH),HL 22 AE 53
Also store to 53AEH (backup/secondary pointer).
64C8
LD H,A 67
Clear H (A is still zero).
64C9
LD L,A 6F
Clear L. HL = 0000H.
64CA
LD (53B4H),HL 22 B4 53
Clear 53B4H (reset line counter).
64CD
LD (53B0H),A 32 B0 53
Clear 53B0H (additional working variable).
64D0H - Source Line Fetch and Parse
This routine fetches the next source line from memory and parses its structure. It compares memory boundaries, extracts line length, and sets up pointers for line processing.
64D0
LD HL,(5315H) 2A 15 53
Load HL with symbol table base pointer from 5315H.
64D3
EX DE,HL EB
Exchange DE and HL. DE = symbol table base.
64D4
LD HL,(531DH) 2A 1D 53
Load HL with current source position from 531DH.
64D7
GOSUB to 5DC2H (Compare HL with DE) to check if past symbol table.
64DA
If Z FLAG set (reached end), JUMP to 6B80H to end current pass.
64DD
LD (5311H),HL 22 11 53
Store current position to 5311H (line start pointer).
64E0
INC HL 23
Advance past first byte of line record.
64E1
INC HL 23
Advance to line length byte.
64E2
LD A,(HL) 7E
Fetch line length from (HL) into A.
64E3
LD (53AAH),A 32 AA 53
Store line length to 53AAH (Remaining Character Count).
64E6
INC HL 23
Advance to start of line text.
64E7
LD (53A8H),HL 22 A8 53
Store line text pointer to 53A8H (Input Buffer Pointer).
64EA
LD D,00H 16 00
Clear D.
64EC
LD E,A 5F
Copy line length to E. DE = line length.
64ED
ADD HL,DE 19
Add line length to get pointer to next line.
64EE
LD (531DH),HL 22 1D 53
Store next line position to 531DH for next iteration.
64F1
GOSUB to 61D6H to skip delimiter and begin parsing line.
64F4
PUSH DE D5
Save source pointer DE onto stack.
64F5
If Z FLAG set (empty line or comment), JUMP to 652FH.
64F7
OR A B7
Test A register. Check if first character is significant.
64F8
If Z FLAG set (A=0), JUMP to 6539H.
64FA
LD A,(DE) 1A
Fetch first character of line from (DE).
64FB
DEC C 0D
Decrement character count C.
64FC
CP 20H FE 20
Compare against 20H (space). Check if line starts with space.
64FE
If Z FLAG set (starts with space), JUMP to 654CH - no label field.
6500
CP 09H FE 09
Compare against 09H (tab). Check if line starts with tab.
6502
If Z FLAG set (starts with tab), JUMP to 654CH - no label field.
6504
CP 2AH FE 2A
Compare against 2AH (asterisk *). Check for comment line.
6506
If NZ FLAG set (not asterisk), JUMP to 652DH to check for label.
6508H - Comment/Directive Line Handler
This routine handles lines beginning with asterisk (*) which may be comments or special directives like *LIST. It parses the directive and takes appropriate action.
6508
POP HL E1
Restore saved pointer from stack into HL.
6509
GOSUB to 61B5H to advance past the asterisk character.
650C
LD A,(DE) 1A
Fetch next character after asterisk from (DE).
650D
CP 4CH FE 4C
Compare against 4CH (ASCII L). Check for *LIST directive.
650F
If NZ FLAG set (not *L), JUMP to 6569H to treat as comment.
6511
GOSUB to 61A8H (Filename Parser) to parse *LIST parameters.
6514
If Z FLAG set (parse complete), JUMP to 61D0H.
6517
CP 09H FE 09
Compare result against 09H. Check parse status.
6519
If NZ FLAG set (parse error), JUMP to 66E2H for error handling.
651C
LD HL,53BDH 21 BD 53
Point HL to 53BDH (listing control variable).
651F
PUSH HL E5
Save HL on stack.
6520
PUSH BC C5
Save BC on stack.
6522
DEC B 05
Decrement B. Test if B was zero.
6523
If NZ FLAG set (B was not zero), JUMP to 6526H.
6525
LD (HL),B 70
Store B (now 0) at 53BDH. Disable listing.
6526
GOSUB to 6DF1H for listing output processing.
6529
POP BC C1
Restore BC from stack.
652A
POP HL E1
Restore HL from stack.
652B
LD (HL),B 70
Store B at (HL). Update listing control.
652C
RET C9
RETURN to main assembly loop.
652DH - Label/Comment Line Check
This routine checks if the current line is a comment (beginning with semicolon) or continues to process the label. Also handles label error reporting when an invalid label is detected.
652D
CP 3BH FE 3B
Compare A against 3BH (ASCII semicolon ;). Check for comment line.
652F
POP DE D1
Restore source pointer DE from stack.
6530
If Z FLAG set (line is comment), JUMP to 6DF1H for listing output only.
6533
LD DE,59D7H 11 D7 59
Load DE with 59D7H (address of "LABEL" error message).
6536
JUMP to 614BH (Error Message Output Setup) to report label error.
6539H - Short Label Validation
This routine validates labels that are 6 characters or shorter. It checks for proper delimiters (space or colon) after the label and handles the transition to opcode field parsing.
6539
LD A,C 79
Load character count C into Register A.
653A
CP 07H FE 07
Compare against 07H. Check if label exceeds 6 characters.
653C
If CARRY not set (7+ chars), JUMP to 6533H to report label error.
653E
GOSUB to 5BBEH to skip delimiters and get next character.
6541
If Z FLAG set (end of significant content), JUMP to 61D0H.
6544
CP 20H FE 20
Compare against 20H (space). Check for space after label.
6546
If Z FLAG set (space found), JUMP to 654CH to process opcode field.
6548
CP 3AH FE 3A
Compare against 3AH (colon :). Check for label terminator.
654A
If NZ FLAG set (neither space nor colon), JUMP to 6533H - label error.
654CH - Opcode Field Parser Entry
This routine begins parsing the opcode/mnemonic field after the label. It saves the label length, parses the opcode mnemonic, checks for empty opcodes (label-only lines), and dispatches to the instruction lookup table at 6BD9H.
654C
LD L,C 69
Copy character count C to L. Saves label length for later use.
654D
GOSUB to 61A8H (Filename Parser) to parse the opcode mnemonic.
6550
INC L 2C
Increment L. Tests if L was FFH (wraps to 00H).
6551
DEC L 2D
Decrement L back. Z flag set if L was zero (no opcode).
6552
If NZ FLAG set (opcode found), JUMP to 655DH to look it up.
No opcode found - check if line ends with comment or CR
6554
LD A,(DE) 1A
Fetch current character from source at (DE).
6555
CP 3BH FE 3B
Compare against 3BH (semicolon). Check for comment.
6557
If Z FLAG set (comment), JUMP to 652FH - label-only line with comment.
6559
CP 0DH FE 0D
Compare against 0DH (carriage return). Check for end of line.
655B
If Z FLAG set (CR), JUMP to 652FH - label-only line.
655D
PUSH HL E5
Save HL (contains label info) onto stack.
655E
LD HL,6BD9H 21 D9 6B
Point HL to 6BD9H (Opcode/Directive Lookup Table).
6561
LD B,02H 06 02
Load B with 02H. Parameter for table search (2 bytes per entry pointer).
6563
GOSUB to 627CH (Table Search) to look up opcode in table.
6566
POP BC C1
Restore saved value into BC (was HL with label info).
6567
If CARRY not set (opcode found), JUMP to 656FH to process it.
6569H - Opcode Not Found Error
This routine handles the case when an opcode mnemonic is not found in the lookup table. It reports an "OPCODE" error and returns to the error handler.
6569
LD DE,5A0AH 11 0A 5A
Load DE with 5A0AH (address of "OPCODE" error message).
656C
JUMP to 614BH (Error Message Output Setup) to report opcode error.
656FH - Opcode Found - Operand Check
This routine is called after a valid opcode is found. It checks for operand delimiters and prepares for operand parsing. Validates that operands follow proper syntax.
656F
GOSUB to 5BBEH to skip delimiters and get next character.
6572
If Z FLAG set (end of operands), JUMP to 657CH.
6574
CP 3BH FE 3B
Compare against 3BH (semicolon). Check for comment.
6576
If Z FLAG set (comment follows), JUMP to 657CH.
6578
CP 20H FE 20
Compare against 20H (space). Check for space before operand.
657A
If NZ FLAG set (unexpected char), JUMP to 6569H - opcode error.
657CH - Opcode Dispatch Setup
This routine sets up for opcode dispatch. It skips spaces, classifies operands, loads the dispatch table entry, and prepares for instruction encoding. The opcode handler address is loaded from table at 6DA7H. Uses a PUSH/RET trick to call the handler.
657C
GOSUB to 5BBBH to skip spaces and get first operand character.
657F
If NZ FLAG (operand exists), GOSUB to 5BF4H to classify character.
6582
LD E,(HL) 5E
Load E with low byte from table entry at (HL). Opcode handler index.
6583
INC HL 23
Advance HL to high byte of table entry.
6584
LD A,(HL) 7E
Load A with high byte (opcode type/flags).
6585
LD (53B1H),A 32 B1 53
Store opcode type to 53B1H (Opcode Type Storage).
6588
LD HL,6DA7H 21 A7 6D
Point HL to 6DA7H (Opcode Handler Dispatch Table).
658B
LD D,00H 16 00
Clear D. DE now contains handler index as 16-bit value.
658D
ADD HL,DE 19
Add index to table base (first addition for word offset).
658E
ADD HL,DE 19
Add index again (2 bytes per entry). HL points to handler address.
658F
LD A,(HL) 7E
Load low byte of handler address.
6590
INC HL 23
Advance to high byte of handler address.
6591
LD H,(HL) 66
Load high byte of handler address into H.
6592
LD L,A 6F
Load low byte into L. HL now contains handler address.
6593
LD A,E 7B
Load handler index back into A for later use.
6594
LD DE,6DDFH 11 DF 6D
Load DE with 6DDFH (common return address after opcode handling).
6597
EX DE,HL EB
Exchange DE and HL. DE=handler addr, HL=return addr.
6598
EX (SP),HL E3
Exchange HL with top of stack. Sets up return to 6DDFH.
6599
EX DE,HL EB
Exchange back. HL=handler address for the PUSH/RET dispatch.
659A
PUSH HL E5
Push handler address onto stack.
659B
INC C 0C
Increment C. Test if C was FFH (no operands marker).
659C
DEC C 0D
Decrement C back. Z flag set if no operands present.
659D
RET Z C8
If Z FLAG set (no operands), RETURN to handler via pushed address.
659E
CP 18H FE 18
Compare handler index against 18H. Check opcode category.
65A0
LD A,01H 3E 01
Load A with 01H (default operand count/flag).
65A2
LD HL,(53B6H) 2A B6 53
Load HL with current assembly address from 53B6H.
65A5
RET NC D0
If CARRY not set (index >= 18H), RETURN to handler.
65A6H - Symbol Table Lookup for Label
This routine looks up a label in the symbol table. If the symbol exists, it retrieves its value. If not found and this is Pass 1, it creates a new symbol table entry. Handles forward references and multiple definition detection.
65A6
PUSH HL E5
Save current assembly address onto stack.
65A7
PUSH AF F5
Save A (operand flag) and flags onto stack.
65A8
LD HL,(53C3H) 2A C3 53
Load HL with symbol table pointer from 53C3H.
65AB
LD B,02H 06 02
Load B with 02H. Parameter for symbol table search.
65AD
GOSUB to 627CH (Table Search) to look up symbol by name.
65B0
If CARRY not set (symbol found), JUMP to 65E0H to use existing entry.
Symbol not found - create new entry in symbol table
65B2
PUSH DE D5
Save source pointer DE onto stack.
65B3
PUSH BC C5
Save BC (B=search param, C=symbol name length).
65B4
LD HL,(5315H) 2A 15 53
Load HL with symbol table base address from 5315H.
65B7
EX DE,HL EB
Exchange. DE = symbol table base (lower boundary).
65B8
LD HL,(53C3H) 2A C3 53
Load HL with current symbol table end pointer.
65BB
LD A,C 79
Load symbol name length into A.
65BC
ADD A,B 80
Add B (=2) to A. Calculate total entry size (name + 2 byte value + 1 length).
65BD
CPL 2F
Complement A. Prepare for subtraction via addition of negative.
65BE
LD C,A 4F
Store complemented size in C.
65BF
LD B,FFH 06 FF
Load B with FFH. BC is now two's complement of entry size.
65C1
ADD HL,BC 09
Subtract entry size from pointer. HL = new entry start position.
65C2
GOSUB to 5DC2H (Compare HL with DE) to check for table overflow.
65C5
If CARRY not set (room available), JUMP to 65CDH to create entry.
Symbol table overflow - report fatal error
65C7
Load HL with 5A73H (address of "SYMBOL TABLE FULL" error message).
65CA
JUMP to 592BH to display fatal error and abort assembly.
65CD
LD (53C3H),HL 22 C3 53
Store new symbol table pointer to 53C3H. Table grows downward.
65D0
POP BC C1
Restore BC (C=symbol name length).
65D1
POP DE D1
Restore source pointer DE (points to symbol name).
65D2
PUSH BC C5
Save BC again for use after copy.
65D3
LD (HL),C 71
Store symbol length byte at start of new entry.
65D4
EX DE,HL EB
Exchange. HL=source (symbol name), DE=table entry.
65D5
INC DE 13
Advance DE past length byte to name field.
65D6
LD B,00H 06 00
Clear B. BC=symbol length for block copy.
65D8
LDIR ED B0
Block copy symbol name from (HL) to (DE), length BC bytes.
65DA
EX DE,HL EB
Exchange. HL now points past symbol name in table entry.
65DB
LD (HL),B 70
Store 00H as low byte of initial symbol value.
65DC
INC HL 23
Advance to high byte of value field.
65DD
LD (HL),B 70
Store 00H as high byte. Symbol initialized to 0000H.
65DE
DEC HL 2B
Back up to low byte of value (entry's value field).
65DF
POP BC C1
Restore BC from stack.
65E0H - Symbol Entry Processing
This routine processes a symbol table entry after lookup. It calculates the position of the flags byte, checks for multiple definition warnings, and handles symbol attribute flags for external references and phase errors.
65E0
POP DE D1
Restore saved value into DE (was AF with operand flag).
65E1
PUSH HL E5
Save HL (points to symbol value field).
65E2
LD A,C 79
Load symbol name length into A.
65E3
CPL 2F
Complement A (negate length).
65E5
LD B,FFH 06 FF
Load B with FFH. BC = negative length.
65E7
ADD HL,BC 09
Subtract length from HL. HL points to flags/length byte.
65E8
INC D 14
Increment D. Test if D was FFH.
65E9
DEC D 15
Decrement D back. Z flag indicates first definition.
65EA
If NZ FLAG set (not first definition), JUMP to 6605H.
First definition of symbol - check for warnings
65EC
LD A,(HL) 7E
Load flags byte from symbol entry.
65ED
AND 80H E6 80
Mask bit 7 (external/undefined flag).
65EF
LD DE,5A94H 11 94 5A
Load DE with 5A94H (address of warning message).
65F2
If Z FLAG set (bit 7 clear), GOSUB to 6150H - possible warning.
65F5
LD A,(HL) 7E
Load flags byte again.
65F6
AND 40H E6 40
Mask bit 6 (multiple definition flag).
65F8
LD DE,5A5CH 11 5C 5A
Load DE with 5A5CH (address of "MULT DEF" warning message).
65FB
If NZ FLAG set (bit 6 set), GOSUB to 6150H - multiple definition warning.
65FE
POP HL E1
Restore HL (points to symbol value).
65FF
LD A,(HL) 7E
Load low byte of symbol value.
6600
INC HL 23
Advance to high byte.
6601
LD H,(HL) 66
Load high byte of symbol value into H.
6602
LD L,A 6F
Load low byte into L. HL = symbol value.
6603
POP DE D1
Restore assembly address from stack into DE.
6604
RET C9
RETURN with HL=symbol value, DE=assembly address.
6605H - Symbol Redefinition Handler
This routine handles symbol redefinition cases. It checks if this is a legitimate redefinition (like EQU) or an error, manages the external and phase flags, and either updates the symbol value or reports an error.
6605
LD A,(HL) 7E
Load flags byte from symbol entry at (HL).
6606
OR A B7
Test flags byte. Check sign bit (bit 7).
6607
If P FLAG set (bit 7 clear, positive), JUMP to 662FH - new definition.
Symbol already defined - check for phase error or update
660A
LD A,D 7A
Load D (high byte of saved value) into A.
660B
EX (SP),HL E3
Exchange HL with stack top. HL=assembly address, stack=flags ptr.
660C
POP BC C1
Pop flags pointer into BC.
660D
POP DE D1
Pop saved DE from stack.
660E
PUSH DE D5
Push DE back onto stack.
660F
PUSH HL E5
Push assembly address.
6610
PUSH AF F5
Push A (D value) and flags.
6611
LD A,(HL) 7E
Load low byte of assembly address.
6612
INC HL 23
Advance to high byte.
6613
LD H,(HL) 66
Load high byte into H.
6614
LD L,A 6F
Load low byte into L. HL = address value.
6615
GOSUB to 5DC2H to compare HL with DE (new vs old value).
6618
POP DE D1
Pop saved AF into DE (D=original A).
6619
If Z FLAG set (values match), JUMP to 6637H - no phase error.
Values don't match - check if phase error should be reported
661B
LD A,(BC) 0A
Load flags byte from (BC).
661C
AND 20H E6 20
Mask bit 5 (phase error already reported flag).
661E
If Z FLAG set (not yet reported), JUMP to 6623H.
6620
DEC D 15
Decrement D. Check pass number.
6621
If NZ FLAG set (Pass 2), JUMP to 6637H - skip duplicate warning.
6623
LD A,(BC) 0A
Load flags byte again.
6624
OR 40H F6 40
Set bit 6 (multiple/phase error flag).
6626
LD (BC),A 02
Store updated flags back to symbol entry.
6627
POP HL E1
Pop value from stack.
6628
POP HL E1
Pop another value (cleanup stack).
6629
LD DE,5A3BH 11 3B 5A
Load DE with 5A3BH (address of "PHASE" error message).
662C
JUMP to 6150H to display phase error message.
662FH - Set Symbol Definition Flags
This routine sets the appropriate flags for a new symbol definition. It marks the symbol as defined (bit 7) and optionally sets the external flag (bit 5) based on the definition context.
662F
OR 80H F6 80
Set bit 7 in A (symbol defined flag).
6631
DEC D 15
Decrement D. Check definition type.
6632
If Z FLAG set (D was 1), JUMP to 6636H - normal definition.
6634
OR 20H F6 20
Set bit 5 (external/special flag).
6636
LD (HL),A 77
Store updated flags byte to symbol entry.
6637H - Store Symbol Value
This routine stores a 16-bit value to a symbol table entry. It handles the final step of symbol definition by writing the low and high bytes of the value.
6637
POP HL E1
Pop symbol value pointer from stack.
6638
POP DE D1
Pop value to store into DE.
6639
LD (HL),E 73
Store low byte of value to symbol entry.
663A
INC HL 23
Advance to high byte position.
663B
LD (HL),D 72
Store high byte of value.
663C
RET C9
RETURN to caller.
663DH - Parse Comma-Separated Operand
This routine advances past the current operand, checks for a comma separator, and validates the operand type. Used for instructions with multiple operands like LD r,r or ADD A,n.
663D
GOSUB to 61B5H to advance past current operand.
6640
PUSH AF F5
Save A (operand type) and flags.
6641
GOSUB to 5BBEH to skip delimiters and get next char.
6644
CP 2CH FE 2C
Compare against 2CH (comma). Check for operand separator.
6646
If NZ FLAG set (no comma), JUMP to 66E2H - syntax error.
6649
POP AF F1
Restore A (first operand type).
664A
CP 03H FE 03
Compare operand type against 03H.
664C
RET NZ C0
If NZ FLAG set (type != 3), RETURN normally.
664D
LD A,B 78
Load register code from B.
664E
CP 07H FE 07
Compare against 07H (register A code).
6650
If NZ FLAG set (not register A), JUMP to 66E2H - error.
6653
POP HL E1
Pop return address (discard it).
6654
GOSUB to 61B5H to advance to second operand.
6657
CP 03H FE 03
Compare second operand type against 03H (register).
6659
If Z FLAG set (register), JUMP to 66A4H for reg-reg operation.
665B
GOSUB to 6804H to check for indexed addressing mode.
665E
If Z FLAG set (indexed), JUMP to 66A4H.
6660H - Immediate Operand Handler
This routine handles immediate operand encoding. It toggles the opcode type flag, evaluates the expression, and sets up the instruction bytes for immediate mode operations.
6660
PUSH AF F5
Save A and flags.
6661
LD HL,53B1H 21 B1 53
Point HL to 53B1H (Opcode Type Storage).
6664
LD A,(HL) 7E
Load current opcode type.
6665
XOR 46H EE 46
XOR with 46H. Toggle immediate mode flag bits.
6667
LD (HL),A 77
Store modified opcode type.
6668
POP AF F1
Restore A and flags.
6669
GOSUB to 6293H (Expression Evaluator) to parse immediate value.
666C
INC HL 23
Advance past expression result.
666D
LD (HL),E 73
Store low byte of immediate value.
666E
GOSUB to 670BH to update instruction length.
6671
LD A,D 7A
Load high byte of expression result.
6672
OR A B7
Test if high byte is zero.
6673
PUSH DE D5
Save DE (expression result).
6674
LD DE,5A4EH 11 4E 5A
Load DE with 5A4EH (address of "RANGE" warning message).
6677
If NZ FLAG set (value > 255), GOSUB to 6150H - range warning.
667B
RET C9
RETURN to caller.
667CH - Bit Operation Handler
This routine handles bit manipulation instructions (BIT, SET, RES). It evaluates the bit number expression, validates the range (0-7), encodes the bit position, and processes the register operand.
667C
GOSUB to 62A0H (Expression Evaluator) to get bit number.
667F
LD A,E 7B
Load bit number (low byte) into A.
6680
CP 08H FE 08
Compare against 08H. Check if bit number valid (0-7).
6682
If CARRY set (bit < 8), JUMP to 6686H - valid.
6684
LD D,01H 16 01
Set D=01H to indicate range error flag.
6686
RLCA 07
Rotate A left. Begin encoding bit position.
6687
RLCA 07
Rotate left again.
6688
RLCA 07
Rotate left third time. Bit number now in bits 3-5.
6689
AND 38H E6 38
Mask bits 3-5. Isolate encoded bit position.
668B
LD HL,53B1H 21 B1 53
Point HL to 53B1H (Opcode Type Storage).
668E
OR (HL) B6
OR encoded bit with existing opcode.
668F
LD (HL),A 77
Store updated opcode byte.
6690
GOSUB to 6671H to check for range warning.
6693
GOSUB to 67F8H to parse register operand.
6696
LD HL,53B1H 21 B1 53
Point HL to opcode storage again.
6699
LD A,(HL) 7E
Load current opcode byte.
669A
LD (HL),CBH 36 CB
Store CBH prefix (CB prefix for bit operations).
669C
INC HL 23
Advance to next byte position.
669D
LD (HL),A 77
Store the encoded operation byte.
669E
INC HL 23
Advance past operation byte.
669F
INC HL 23
Advance to length counter.
66A0
INC (HL) 34
Increment instruction length.
66A1
GOSUB to 61B5H to advance source pointer.
66A4H - Register Operand Encoder
This routine encodes register operands into instruction bytes. It handles both source and destination register encoding, with special handling for rotated positions in the opcode byte.
66A4
OR A B7
Test A (operand type). Set flags.
66A5
PUSH AF F5
Save A and flags.
66A6
CP 03H FE 03
Compare operand type against 03H (register type).
66A8
If Z FLAG set (register), JUMP to 66ACH.
66AA
LD B,06H 06 06
Load B with 06H (code for (HL) indirect).
66AC
POP AF F1
Restore A and flags.
66AD
PUSH AF F5
Save again for later use.
66AE
If CARRY not set, JUMP to 66B5H.
66B0
LD A,B 78
Load register code into A.
66B1
RLCA 07
Rotate left to position for destination field.
66B2
RLCA 07
Rotate left again.
66B3
RLCA 07
Third rotation. Register code now in bits 3-5.
66B4
LD B,A 47
Store rotated code back in B.
66B5
LD HL,53B4H 21 B4 53
Point HL to 53B4H (instruction length counter).
66B8
INC (HL) 34
Increment instruction length.
66B9
LD A,04H 3E 04
Load A with 04H.
66BB
SUB (HL) 96
Subtract current length from 4.
66BC
DEC HL 2B
[POSITION LOOP] Move backward through instruction bytes.
66BD
DEC A 3D
Decrement position counter.
66BE
If NZ FLAG set, LOOP back to position correctly.
66C0
LD A,B 78
Load register code from B.
66C1
OR (HL) B6
OR with existing opcode byte.
66C2
LD (HL),A 77
Store combined opcode byte.
66C3
POP AF F1
Restore A (operand type).
66C4
CP 03H FE 03
Compare against 03H (register type).
66C6
RET Z C8
If Z FLAG set (simple register), RETURN.
66C7
GOSUB to 6804H to handle indexed mode.
66CA
If NZ FLAG set (error), JUMP to 66E2H.
66CC
GOSUB to 61B5H to advance source pointer.
66CF
CP 05H FE 05
Compare operand type against 05H.
66D1
If Z FLAG set (type 5), JUMP to 66E8H for indexed offset.
66D3
CP 04H FE 04
Compare against 04H.
66D5
If NZ FLAG set (not type 4), JUMP to 66E2H - error.
66D7
LD A,B 78
Load B into A.
66D8
CP 02H FE 02
Compare against 02H.
66DA
If NZ FLAG set, JUMP to 66E2H - error.
66DC
GOSUB to 5BBEH to get next character.
66DF
CP 29H FE 29
Compare against 29H (closing parenthesis).
66E1
RET Z C8
If Z FLAG set (valid close paren), RETURN.
66E2H - Operand Syntax Error Handler
This routine handles operand syntax errors. It loads the address of the "OPERAND" error message and jumps to the error display routine.
66E2
LD DE,59F3H 11 F3 59
Load DE with 59F3H (address of "OPERAND" error message).
66E5
JUMP to 614BH (Error Message Output Setup) to report error.
66E8H - Indexed Addressing Offset Handler
This routine handles the offset portion of indexed addressing modes (IX+d, IY+d). It sets up the index prefix, evaluates the displacement expression, and encodes the offset byte.
66E8
GOSUB to 66FEH to set up index register prefix (DD or FD).
66EB
INC HL 23
Advance past prefix byte.
66EC
INC HL 23
Advance to offset position.
66ED
CP 04H FE 04
Compare operand type against 04H.
66EF
If NZ FLAG set (not type 4), JUMP to 66F5H.
66F1
LD B,(HL) 46
Load current byte at (HL) into B.
66F3
LD (HL),B 70
Store B at new position (shift byte).
66F4
DEC HL 2B
Back up to offset position.
66F5
GOSUB to 62A0H (Expression Evaluator) to get offset value.
66F8
LD (HL),E 73
Store offset low byte.
66F9
GOSUB to 56EEH to validate offset range.
66FC
JUMP to 66DCH to check for closing parenthesis.
66FEH - Index Register Prefix Setup
This routine sets up the prefix byte for IX or IY indexed addressing. It stores DDH for IX or FDH for IY at 53B0H and updates the instruction length.
66FE
LD HL,53B0H 21 B0 53
Point HL to 53B0H (prefix byte storage).
6701
LD (HL),DDH 36 DD
Store DDH (IX prefix) as default.
6703
DEC B 05
Decrement B. Test index register type.
6704
INC B 04
Increment B back. Z flag set if B was 0 (IX).
6705
LD B,02H 06 02
Load B with 02H (2 extra bytes for indexed mode).
6707
If Z FLAG set (IX), JUMP to 670BH - prefix already set.
6709
LD (HL),FDH 36 FD
Store FDH (IY prefix) instead.
670BH - Add Bytes to Instruction Length
This routine adds additional bytes to the instruction length counter at 53B4H. Used when encoding multi-byte instructions with prefixes or immediate values.
670B
LD A,(53B4H) 3A B4 53
Load current instruction length from 53B4H.
670E
ADD 02H C6 02
Add 2 to length (for prefix + offset or 16-bit value).
6710
LD (53B4H),A 32 B4 53
Store updated length back to 53B4H.
6713
RET C9
RETURN to caller.
6714H - EX Instruction Handler
This routine handles the EX (exchange) instruction encoding. It validates the operand combination and generates the appropriate opcode for EX DE,HL, EX AF,AF', or EX (SP),HL/IX/IY.
6714
GOSUB to 663DH to parse first operand and check for comma.
6717
CP 04H FE 04
Compare operand type against 04H.
6719
If NZ FLAG set (not type 4), JUMP to 66E2H - operand error.
671B
LD A,B 78
Load register code from B.
671C
CP 02H FE 02
Compare against 02H (HL register pair code).
671E
If NZ FLAG set (not HL), JUMP to 66E2H - operand error.
6720
LD (53B4H),A 32 B4 53
Store 02H to 53B4H (instruction length = 2).
6723
LD HL,53B1H 21 B1 53
Point HL to 53B1H (Opcode Type Storage).
6726
LD A,(HL) 7E
Load current opcode type.
6727
RRCA 0F
Rotate right. Reposition bits.
6728
AND 08H E6 08
Mask bit 3.
672A
XOR 4AH EE 4A
XOR with 4AH. Generate proper EX opcode (E3H or EBH).
672C
LD (HL),A 77
Store computed opcode.
672D
GOSUB to 674DH to parse and validate second register pair operand.
6730
LD (HL),EDH 36 ED
Store EDH prefix byte at current instruction position.
6732
INC HL 23
Advance to next byte position.
6733
LD (HL),A 77
Store the computed opcode byte (from 674DH).
6734
RET C9
RETURN to caller.
6735H - ADD/ADC/SBC Register Pair Handler
This routine handles ADD, ADC, and SBC instructions with register pair operands (e.g., ADD HL,BC or ADC HL,DE). It validates operand types and encodes the appropriate opcode with register pair bits.
6735
GOSUB to 663DH to parse first operand and require comma.
6738
LD HL,53B1H 21 B1 53
Point HL to 53B1H (Opcode Type Storage).
673B
LD (HL),09H 36 09
Store 09H as base opcode (ADD HL,rr base).
673D
CP 05H FE 05
Compare operand type against 05H (index register).
673F
If Z FLAG set (index reg), JUMP to 675DH for IX/IY handling.
6741
CP 04H FE 04
Compare against 04H (register pair type).
6743
If NZ FLAG set (not reg pair), JUMP to 66E2H - operand error.
6745
LD A,B 78
Load register pair code into A.
6746
CP 02H FE 02
Compare against 02H (HL register pair code).
6748
If NZ FLAG set (not HL), JUMP to 66E2H - must be HL for ADD.
674A
GOSUB to 688DH to set instruction length to 1.
674DH - Register Pair Operand Parser
This routine parses the second register pair operand and encodes its bits into the opcode. It rotates the register code into position and ORs it with the base opcode. Used by ADD HL,rr and similar instructions.
674D
GOSUB to 61B0H to parse register pair operand.
6750
If NZ FLAG set (invalid), JUMP to 66E2H - operand error.
6752
LD A,B 78
Load register pair code into A.
6753
RRCA 0F
Rotate right to position register pair bits.
6754
RRCA 0F
Rotate right again.
6755
RRCA 0F
Rotate right third time.
6756
RRCA 0F
Rotate right fourth time. Bits now in position 4-5.
6757
LD HL,53B1H 21 B1 53
Point HL to opcode storage.
675A
OR (HL) B6
OR register bits with base opcode.
675B
LD (HL),A 77
Store combined opcode.
675C
RET C9
RETURN to caller with opcode in A.
675DH - Index Register Pair ADD Handler
This routine handles ADD IX,rr and ADD IY,rr instructions. It sets up the index prefix, validates that the second operand matches the first (can't mix IX and IY), and encodes the instruction.
675D
LD C,B 48
Save index register code (0=IX, 1=IY) in C.
675E
GOSUB to 66FEH to set up DD/FD prefix based on B.
6761
LD L,C 69
Copy saved index code to L for later comparison.
6762
GOSUB to 61B0H to parse second register pair operand.
6765
If NZ FLAG set (not simple reg pair), JUMP to 676FH.
6767
LD A,B 78
Load register pair code.
6768
CP 02H FE 02
Compare against 02H (HL code).
676A
If Z FLAG set (HL specified), JUMP to 66E2H - can't use HL with IX/IY.
676D
JUMP to 6752H to encode register pair bits.
676F
CP 05H FE 05
Compare operand type against 05H (index register).
6771
If NZ FLAG set (not index reg), JUMP to 66E2H - error.
6774
LD A,B 78
Load second index register code.
6775
CP L BD
Compare with first index register code in L.
6776
If NZ FLAG set (IX vs IY mismatch), JUMP to 66E2H - error.
6779
LD B,02H 06 02
Set B to 02H (HL position code for encoding).
677B
JUMP to 6752H to encode as ADD IX,IX or ADD IY,IY.
677DH - INC/DEC Register Pair Handler
This routine handles INC and DEC instructions with register pair operands. It checks for both simple register pairs (BC, DE, HL, SP) and index registers (IX, IY), setting appropriate prefixes.
677D
GOSUB to 61B0H to parse register pair operand.
6780
If NZ FLAG set (not simple reg pair), JUMP to 6787H.
6782
GOSUB to 688DH to set instruction length to 1.
6785
JUMP to 6790H to encode opcode.
6787
CP 05H FE 05
Compare operand type against 05H (index register).
6789
SCF 37
Set Carry Flag (for 66A5H entry with carry set).
678A
If NZ FLAG set (not index), JUMP to 66A5H for single reg INC/DEC.
678D
GOSUB to 66FEH to set up DD/FD prefix for IX/IY.
6790
LD HL,53B1H 21 B1 53
Point HL to opcode storage.
6793
LD A,(HL) 7E
Load base opcode.
6794
RLCA 07
Rotate left to reposition bits.
6795
RLCA 07
Rotate left again.
6796
RLCA 07
Rotate left third time.
6797
AND 08H E6 08
Mask to keep only bit 3 (INC vs DEC distinction).
6799
OR 03H F6 03
OR with 03H to form INC rr (03H) or DEC rr (0BH) base.
679B
LD (HL),A 77
Store modified opcode.
679C
JUMP to 6752H to add register pair bits.
679EH - RST Instruction Handler
This routine handles the RST (restart) instruction. It evaluates the restart address expression, validates it's a valid RST vector (0, 8, 10H, 18H, 20H, 28H, 30H, 38H), and encodes the opcode.
679E
GOSUB to 62A0H to evaluate restart address expression.
67A1
LD A,E 7B
Load low byte of result into A.
67A2
CP 03H FE 03
Compare against 03H. Check if valid RST number (0-2 range initially).
67A4
If CARRY not set (>=3), JUMP to 66E2H. Actually checks against restart modes.
67A7
OR A B7
Test if A is zero (RST 0).
67A8
If Z FLAG set (RST 0), JUMP to 67AEH.
67AB
RLCA 07
Rotate left to position restart vector.
67AC
RLCA 07
Rotate left again.
67AD
RLCA 07
Rotate left third time. Vector now in bits 3-5.
67AE
OR 46H F6 46
OR with 46H. Note: This seems to be C7H base for RST, adjusted.
67B0H - Store Opcode Byte 2 and Update Length
This routine stores a computed opcode byte at 53B2H and jumps to update the instruction length. Used as a common endpoint for many instruction encoders.
67B0
LD HL,53B2H 21 B2 53
Point HL to 53B2H (instruction byte 2 storage).
67B3
LD (HL),A 77
Store opcode byte at 53B2H.
67B4
JUMP to 670BH to add 2 to instruction length.
67B7H - ED-Prefixed Instruction Setup
This routine sets up ED-prefixed instructions. It moves the current opcode to byte 2 and stores EDH in byte 1, then continues with length update.
67B7
LD HL,53B1H 21 B1 53
Point HL to 53B1H (opcode storage byte 1).
67BA
LD A,(HL) 7E
Load current opcode into A.
67BB
LD (HL),EDH 36 ED
Store EDH prefix in byte 1.
67BD
JUMP to 67B0H to store opcode in byte 2 and update length.
67BFH - JP/CALL Instruction Handler
This routine handles JP and CALL instructions. It determines if this is a conditional or unconditional jump, handles register indirect forms (JP (HL), JP (IX), JP (IY)), and encodes the 16-bit target address.
67BF
GOSUB to 67D7H to check operand type and handle conditions.
67C2
PUSH AF F5
Save A (operand type) and flags.
67C3
If Z FLAG set (condition code found), GOSUB to 67F8H to require comma.
67C6
POP AF F1
Restore A and flags.
67C7
PUSH AF F5
Save again for later use.
67C8
If Z FLAG set (conditional), GOSUB to 62A0H to evaluate address.
67CC
If NZ FLAG set (unconditional), GOSUB to 6293H for expression.
67CF
INC HL 23
Advance past opcode byte.
67D0
LD (HL),E 73
Store low byte of target address.
67D1
INC HL 23
Advance to high byte position.
67D2
LD (HL),D 72
Store high byte of target address.
67D3
INC HL 23
Advance to length position.
67D4
LD (HL),03H 36 03
Store 03H as instruction length (opcode + 2 address bytes).
67D6
RET C9
RETURN to caller.
67D7H - Condition Code / Operand Type Check
This routine checks the operand type and handles condition codes for conditional JP/CALL/RET instructions. It identifies condition codes (NZ, Z, NC, C, PO, PE, P, M) and encodes them into the opcode.
67D7
GOSUB to 61B5H to advance source and get operand type in A.
67DA
LD HL,53B1H 21 B1 53
Point HL to opcode storage.
67DD
CP 03H FE 03
Compare operand type against 03H (register).
67DF
If NZ FLAG set (not register), JUMP to 67E8H.
67E1
LD A,B 78
Load register code into A.
67E2
DEC A 3D
Decrement A. Check if register code was 1 (C register = Carry condition).
67E3
RET NZ C0
If NZ FLAG set (not C), RETURN - not a condition code.
67E4
LD B,03H 06 03
Set B to 03H (Carry condition code).
67E6
LD A,06H 3E 06
Set A to 06H (type indicator for condition).
67E8
CP 06H FE 06
Compare operand type against 06H (condition code type).
67EA
RET NZ C0
If NZ FLAG set (not condition), RETURN with NZ.
Operand is a condition code - encode it into opcode
67EB
PUSH AF F5
Save A (type=06H) and flags (Z set).
67EC
LD A,B 78
Load condition code into A.
67ED
RLCA 07
Rotate left to position in bits 3-5.
67EE
RLCA 07
Rotate left again.
67EF
RLCA 07
Rotate left third time.
67F0
LD C,A 4F
Save positioned condition code in C.
67F1
LD A,C6H 3E C6
Load C6H mask (11000110 - preserves bits 7,6,2,1).
67F3
AND (HL) A6
AND with current opcode to clear condition bits.
67F4
OR C B1
OR in the condition code bits.
67F5
LD (HL),A 77
Store updated opcode with condition code.
67F6
POP AF F1
Restore A and flags (Z still set).
67F7
RET C9
RETURN with Z flag set indicating condition found.
67F8H - Require Comma Separator
This routine checks that the next character is a comma and reports an operand error if not. Used to enforce proper syntax between operands.
67F8
GOSUB to 5BBEH to skip delimiters and get next character.
67FB
CP 2CH FE 2C
Compare against 2CH (comma).
67FD
If NZ FLAG set (no comma), JUMP to 66E2H - operand error.
6800
RET C9
RETURN if comma found.
6801H - Advance and Get Operand Type
This routine advances the source pointer, then checks if the next character is an open parenthesis (for indirect addressing). Returns with Z flag reflecting the parenthesis check.
6801
GOSUB to 61B5H to advance source and get operand type.
6805
LD B,A 47
Save operand type in B temporarily.
6806
LD A,(DE) 1A
Fetch current character from source.
6807
CP 28H FE 28
Compare against 28H (open parenthesis).
6809
LD A,B 78
Restore operand type to A.
680B
RET C9
RETURN with Z set if '(' found, NZ otherwise.
680CH - DEFB/DEFM Directive Handler
This routine handles DEFB (define byte) and DEFM (define message) directives. It sets up for byte definition, parses the content, and handles both numeric values and string literals.
680C
GOSUB to 688DH to set instruction length to 1.
680F
GOSUB to 61D6H to skip delimiter and start parsing.
6812
RET Z C8
If Z FLAG set (empty), RETURN.
6813
GOSUB to 67DAH to check operand type.
6816
RET Z C8
If Z FLAG set (condition code - unusual for DEFB), RETURN.
6817
JUMP to 5BF4H to classify and process byte value.
681AH - JP (HL)/(IX)/(IY) Handler
This routine handles JP with register indirect addressing: JP (HL), JP (IX), and JP (IY). It checks for the indirect form and encodes the appropriate opcode with any needed prefix.
681A
GOSUB to 67D7H to check operand type.
681D
If Z FLAG set (condition), JUMP to 67C2H for conditional JP.
681F
PUSH AF F5
Save A and flags.
6820
LD A,(DE) 1A
Fetch current character from source.
6821
CP 28H FE 28
Compare against 28H (open parenthesis).
6823
If NZ FLAG set (no paren), JUMP to 67CBH for direct JP.
JP (register) form detected
6825
POP AF F1
Restore A (discard - we have parenthesis).
6826
LD (HL),E9H 36 E9
Store E9H opcode (JP (HL) base opcode).
6828
GOSUB to 61ADH to parse register inside parentheses.
682B
PUSH AF F5
Save parse result.
682C
If NZ FLAG set (valid reg), GOSUB to 688DH to set length.
682F
POP AF F1
Restore parse result.
6830
If NZ FLAG set (not index), JUMP to 66D3H to check closing paren.
6833
GOSUB to 66FEH to set up DD/FD prefix for JP (IX)/(IY).
6836
JUMP to 66DCH to check closing parenthesis.
6839H - JR Instruction Handler
This routine handles JR (jump relative) instructions, both conditional (JR Z, JR NZ, JR C, JR NC) and unconditional. It evaluates the target address, calculates the relative offset, and checks for range errors.
6839
GOSUB to 67D7H to check for condition code.
683C
PUSH AF F5
Save A and flags (Z if condition found).
683D
If NZ FLAG set (no condition), GOSUB to 6293H for expression.
6840
POP AF F1
Restore A and flags.
6841
If NZ FLAG set (unconditional), JUMP to 6853H for offset calc.
Conditional JR - validate condition code (only Z, NZ, C, NC allowed)
6843
LD A,B 78
Load condition code into A.
6844
CP 04H FE 04
Compare against 04H. Only conditions 0-3 valid for JR.
6846
If CARRY not set (condition >= 4), JUMP to 66E2H - PO/PE/P/M not allowed.
6849
LD A,(HL) 7E
Load opcode from storage.
684A
OR 20H F6 20
OR with 20H to set conditional JR bit pattern.
684C
LD (HL),A 77
Store modified opcode.
684D
GOSUB to 67F8H to require comma separator.
6850
GOSUB to 62A0H to evaluate target address expression.
6853H - JR Relative Offset Calculator
This routine calculates the relative offset for JR and DJNZ instructions. It subtracts the current PC from the target, adjusts for the instruction length, validates the range (-128 to +127), and reports errors if out of range.
6853
LD HL,(53B6H) 2A B6 53
Load current assembly address (PC) into HL.
6856
EX DE,HL EB
Exchange. DE=PC, HL=target address.
6857
OR A B7
Clear carry for subtraction.
6858
SBC HL,DE ED 52
Subtract PC from target. HL = target - PC.
685A
LD DE,007EH 11 7E 00
Load 007EH (126 decimal + adjustment).
685D
ADD HL,DE 19
Add 126 to normalize range check.
685E
INC H 24
Increment H. Test if result fits in one byte.
685F
DEC H 25
Decrement H back. Z if H was 00H (in range).
6860
If NZ FLAG set (out of range), JUMP to 686EH for error.
6862
LD A,L 7D
Load normalized offset into A.
6863
SUB 80H D6 80
Subtract 80H to convert to signed offset (-128 to +127).
6865
JUMP to 6876H to store offset.
NOP padding area (possibly for patch space or alignment)
686E
LD DE,59E0H 11 E0 59
Load DE with 59E0H (address of "BRANCH" range error message).
6871
GOSUB to 6150H to display range error warning.
6874
LD A,FEH 3E FE
Load FEH as placeholder offset (points to self - tight loop).
6876
JUMP to 67B0H to store offset and update length.
6879H - RST Instruction Handler
Encodes the RST (Restart) instruction. RST takes a single operand that must be a multiple of 8 (00H, 08H, 10H, 18H, 20H, 28H, 30H, 38H) and encodes it into a single-byte opcode C7H + (n*8).
6879
Call expression evaluator to get the RST vector number
687C
LD A,D 7A
Load high byte of expression result into A
687D
OR A B7
Test if high byte is zero (RST values must be 00H-38H)
687E
If high byte non-zero, jump to operand syntax error - value out of range
6881
LD A,E 7B
Load low byte of expression result (the RST vector) into A
6882
AND C7H E6 C7
Mask with C7H - valid RST values (00,08,10,18,20,28,30,38) AND C7H = 0
6884
If any bits remain set, not a valid RST vector - operand error
The RST instruction encodes as C7H OR (vector). Since valid vectors are multiples of 8 (bits 3-5 set), ORing with C7H produces the correct opcode: RST 00H=C7H, RST 08H=CFH, RST 10H=D7H, etc.
6887
LD A,C7H 3E C7
Load base RST opcode C7H into A
6889
OR E B3
OR with the vector value to form complete opcode
688A
LD (53B1H),A 32 B1 53
Store the encoded opcode in instruction byte 1 buffer
688D
LD A,01H 3E 01
Set instruction length to 1 byte
688F
LD (53B4H),A 32 B4 53
Store instruction length in length counter variable
6892
RET C9
Return to main assembly loop
6893H - IN Instruction Handler
Handles the IN instruction which reads from an I/O port. Supports both IN A,(n) (port in immediate) and IN r,(C) (port in register C) forms.
6893
Parse register operand - get destination register
6896
If not a register, jump to operand syntax error
6899
Require and skip comma separator between operands
689C
PUSH BC C5
Save register code (B=register number) on stack
689D
Advance source pointer and get operand type
68A0
If not a parenthesized operand, error (IN requires parentheses)
68A3
Parse what's inside the parentheses
68A6
If not a register (immediate port), jump to handle IN A,(n)
The Z80 IN r,(C) instruction uses the ED prefix. The second byte encodes the destination register in bits 3-5, with base opcode 40H.
68A8
DEC B 05
Decrement register number to check if it's register C (code 01H)
68A9
If not C register, operand error - IN r,(C) requires C as port source
68AC
LD A,EDH 3E ED
Load ED prefix byte for extended instructions
68AE
LD (53B1H),A 32 B1 53
Store ED prefix in instruction byte 1
68B1
POP AF F1
Restore destination register code from stack into A
68B2
RLCA 07
Rotate left to shift register into bits 3-5 position (step 1 of 3)
68B3
RLCA 07
Rotate left (step 2 of 3)
68B4
RLCA 07
Rotate left (step 3 of 3) - register now in bits 3-5
68B5
OR 40H F6 40
OR with base opcode 40H to form IN r,(C) second byte
68B7
Store opcode byte and update instruction length
68BA
Jump to require closing parenthesis and complete instruction
Handle IN A,(n) form - immediate port address in parentheses.
68BD
LD H,A 67
Save operand type/value in H temporarily
68BE
POP AF F1
Restore destination register code
68BF
CP 07H FE 07
Check if destination is A register (code 07H)
68C1
LD A,H 7C
Restore operand value from H
68C2
If not A register, error - IN (n) only works with A as destination
68C5
Evaluate port number expression (with CR check)
68C8
Validate expression result is 8-bit value
68CB
LD A,E 7B
Load port number (low byte of expression) into A
68CC
Jump to store opcode (DBH for IN A,(n)) and complete
68CEH - OUT Instruction Handler
Handles the OUT instruction which writes to an I/O port. Supports both OUT (n),A (port out immediate) and OUT (C),r (port out to register C address) forms.
68CE
Advance source and get first operand type (should be parenthesized)
68D1
If not parenthesized operand, error - OUT requires parentheses
68D4
Parse what's inside the parentheses
68D7
PUSH AF F5
Save operand type/register code
68D8
If not a register, evaluate as expression (port number)
68DB
POP AF F1
Restore operand type
68DC
PUSH AF F5
Save it again for later check
68DD
If was expression (not register), skip register validation
68DF
DEC B 05
Check if register is C (code 01H, after DEC becomes 0)
68E0
If not C register, error - OUT (C),r requires C
68E3
Require and skip closing parenthesis
68E6
Require and skip comma separator
68E9
PUSH DE D5
Save expression result (port number if immediate form)
68EA
Parse source register operand
68ED
POP DE D1
Restore port number
68EE
If not a register, operand error
68F1
POP AF F1
Restore first operand type (Z=register C, NZ=immediate)
68F2
If first operand was C register, jump to OUT (C),r encoding
Handle OUT (n),A - immediate port form. Only A register allowed as source.
68F4
LD A,B 78
Load source register code into A
68F5
CP 07H FE 07
Check if source is A register (code 07H)
68F7
If not A register, error - OUT (n),r only works with A
68FA
Validate port number is 8-bit value
68FD
LD A,E 7B
Load port number into A
68FE
Jump to store opcode (D3H for OUT (n),A) and port byte
Handle OUT (C),r - register port form. Uses ED prefix.
6901
LD A,EDH 3E ED
Load ED prefix byte
6903
LD (53B1H),A 32 B1 53
Store ED prefix in instruction byte 1
6906
LD A,B 78
Load source register code
6907
RLCA 07
Rotate left to position register in bits 3-5 (step 1)
6908
RLCA 07
Rotate left (step 2)
6909
RLCA 07
Rotate left (step 3)
690A
OR 41H F6 41
OR with 41H to form OUT (C),r second byte (base 41H)
690C
Jump to store opcode and complete instruction
690FH - JP Instruction Handler
Handles the JP (jump) instruction. Supports unconditional JP nn, conditional JP cc,nn, and indirect JP (HL)/(IX)/(IY) forms.
690F
Advance source and check for parenthesized operand
6912
If not parenthesized, jump to handle JP nn or JP cc,nn
Handle indirect jump forms: JP (HL), JP (IX), JP (IY).
6914
Parse register inside parentheses
6917
If not a register, jump to operand error
6919
LD A,B 78
Load register code into A
691A
CP 03H FE 03
Check if register is HL (code 03H for register pair)
691C
If not HL, jump to operand error
691E
Require closing parenthesis
6921
Check for comma (should not be present for JP (HL))
6924
LD A,E9H 3E E9
Load opcode E9H for JP (HL)
6926
LD (53B1H),A 32 B1 53
Store opcode in instruction byte 1
6929
Check for index register (IX/IY)
692C
If index register detected, jump to add DD/FD prefix
692F
CP 04H FE 04
Check operand type code
6931
If not expected type, jump to error
6933
LD A,B 78
Load register code
6934
CP 02H FE 02
Check register pair code
6936
Jump to continue validation
Handle JP nn or JP cc,nn forms (not parenthesized).
6938
CP 04H FE 04
Check if operand type is condition code
693A
If not condition code, jump to handle unconditional JP
693C
DEC B 05
Adjust condition code
693D
If not valid condition, error
693F
Require comma after condition code
6942
Advance to target address operand
6945
Jump back to continue processing
6947
CP 07H FE 07
Check operand type
6949
If not expected type, error
694E
Advance source pointer
6951
CP 07H FE 07
Check next operand type
6953
If not expected, error
6955
LD A,08H 3E 08
Load value 08H
6957
LD (53B1H),A 32 B1 53
Store in instruction byte 1
695D
CP 27H FE 27
Check for single quote character
695F
If not quote, jump to error
6961
Jump to set instruction length to 1 and return
6964H - CALL Instruction Handler
Handles the CALL instruction. Supports unconditional CALL nn and conditional CALL cc,nn forms.
6964
LD BC,6752H 01 52 67
Load return address 6752H into BC (for register pair storage)
6967
PUSH BC C5
Push return address - will RET to 6752H after handler
6968
Parse operand - check for index register or other type
696B
If index register detected, jump to add prefix
696E
CP 07H FE 07
Check if simple operand type
6970
If simple operand, set length to 1 and return
6973
CP 04H FE 04
Check if condition code operand
6975
If not condition code, jump to error
6977
LD A,B 78
Load condition code into A
6978
CP 03H FE 03
Check condition code validity
697A
If valid condition, set length and return
697D
Jump to operand syntax error handler
6980H - LD Instruction Handler (Main Entry)
Main handler for the LD (load) instruction. This is the most complex handler as LD has many forms: register-to-register, immediate, memory access, 16-bit loads, special registers (I, R), and indexed addressing.
6980
LD HL,53B1H 21 B1 53
Point HL to instruction opcode buffer
6983
Parse first operand (destination)
6986
If not a register, jump to handle memory/special forms
Destination is a register. Build the base opcode with destination in bits 3-5.
6988
PUSH BC C5
Save destination register code
6989
LD C,A 4F
Save operand type in C
698A
LD A,B 78
Load destination register code into A
698B
RLCA 07
Rotate left to put register in bits 3-5 (step 1)
698C
RLCA 07
Rotate left (step 2)
698D
RLCA 07
Rotate left (step 3) - register now in bits 3-5
698E
OR (HL) B6
OR with current opcode byte at 53B1H
698F
LD (HL),A 77
Store updated opcode
6990
Require comma separator
6993
LD A,B 78
Reload register code
6994
CP 07H FE 07
Check if destination is A register (code 07H)
6996
LD A,C 79
Load operand type back into A
6997
POP BC C1
Restore register code in B
6998
If dest not A, jump to standard LD r,source handling
Destination is A register - check for special source operands (I, R, memory).
699B
Get source operand type
699E
If parenthesized, jump to handle memory source
69A0
CP 08H FE 08
Check for special register type (I or R)
69A2
If not special reg, jump to standard source handling
Handle LD A,I or LD A,R - uses ED prefix.
69A5
LD A,57H 3E 57
Load base opcode 57H for LD A,I
69A7
OR B B0
OR with register code (I=0, R=1) - gives 57H or 5FH
69A8
LD (HL),A 77
Store opcode
69A9
Jump to add ED prefix and complete
Handle LD A,(nn) or LD A,(BC)/(DE)/(HL) memory forms.
69AC
Parse operand inside parentheses
69AF
If index register, jump to handle indexed
69B2
CP 04H FE 04
Check for register pair operand
69B4
If not register pair, jump to handle direct address
69B6
PUSH BC C5
Save register pair code
69B8
DEC B 05
Adjust code again
69B9
POP BC C1
Restore original code
69BA
If not HL, jump to handle BC/DE
69BD
Character classification
69C0
Character classification again
69C3
XOR A AF
Clear A register
69C4
LD DE,6808H 11 08 68
Load continuation address
69C7
Jump to register operand encoder
Handle LD A,(BC) or LD A,(DE) forms.
69CA
LD A,B 78
Load register pair code
69CB
CP 03H FE 03
Check if SP (not valid for this form)
69CD
If SP, error - LD A,(SP) is invalid
69D0
LD (HL),0AH 36 0A
Store base opcode 0AH for LD A,(BC)
69D2
Process register pair code into opcode
69D5
Set instruction length to 1
69D8
Jump to require closing parenthesis
Handle LD A,(nn) - direct memory address form.
69DB
LD (HL),3AH 36 3A
Store opcode 3AH for LD A,(nn)
69DD
Evaluate and store 16-bit address
69E0
Jump to require closing parenthesis
69E3H - LD Instruction Handler (Memory Destination)
Handles LD instructions where the destination is a memory location: LD (nn),A, LD (nn),HL, LD (BC),A, LD (DE),A, and indexed forms.
69E3
Check for open parenthesis (memory destination)
69E6
If not parenthesized, jump to 16-bit register loads
69E9
LD (HL),70H 36 70
Store base opcode 70H for LD (HL),r
69EB
Parse operand inside parentheses
69EE
If not index register, jump to check register pair
Handle LD (IX+d),r or LD (IY+d),r indexed forms.
69F0
Parse indexed offset (+d)
69F7
LD (53B4H),A 32 B4 53
Clear instruction length (will be set properly later)
69FA
Continue indexed LD processing
69FD
Jump to add bytes to instruction length
Handle LD (rr),source where rr is a register pair.
6A00
CP 04H FE 04
Check for register pair operand type
6A02
If not register pair, jump to handle direct address
6A04
Require closing parenthesis
6A07
Require comma separator
6A0A
LD A,B 78
Load register pair code
6A0B
CP 02H FE 02
Check if HL (code 02H)
6A0D
If not HL, jump to handle BC/DE
Handle LD (HL),n immediate or LD (HL),r register forms.
6A12
If register, jump to encode register in opcode
6A15
PUSH AF F5
Save operand type
6A16
LD A,36H 3E 36
Load opcode 36H for LD (HL),n
6A18
LD (53B1H),A 32 B1 53
Store opcode
6A1B
POP AF F1
Restore operand type
6A1C
Jump to process immediate operand
Handle LD (BC),A or LD (DE),A forms - only A register allowed.
6A1F
CP 03H FE 03
Check if SP (invalid for this form)
6A21
If SP, error - LD (SP),r is invalid
6A24
PUSH BC C5
Save register pair code
6A25
Parse source register
6A28
If not a register, error
6A2B
LD A,B 78
Load source register code
6A2C
CP 07H FE 07
Check if A register
6A2E
If not A, error - only LD (BC),A and LD (DE),A valid
6A31
LD (HL),02H 36 02
Store base opcode 02H for LD (BC),A
6A33
POP BC C1
Restore register pair code
6A34
Encode register pair into opcode
6A37
Set instruction length to 1 and return
6A3AH - LD (nn),source Handler
Handles LD instructions with direct memory address destination: LD (nn),A, LD (nn),HL, LD (nn),rr forms.
6A3A
LD (HL),02H 36 02
Store temporary opcode value
6A3C
Evaluate and store 16-bit address from expression
6A3F
Require closing parenthesis
6A42
Require comma separator
6A48
If not a register, jump to check other forms
6A4A
LD A,B 78
Load source register/pair code
6A4B
CP 02H FE 02
Check if HL pair
6A4D
If HL, jump to complete LD (nn),HL encoding
Handle LD (nn),rr with ED prefix for BC, DE, SP register pairs.
6A50
INC (HL) 34
Increment opcode byte
6A51
LD HL,53B0H 21 B0 53
Point to prefix byte storage
6A54
LD (HL),EDH 36 ED
Store ED prefix
6A56
INC HL 23
Point to opcode byte
6A57
LD (HL),43H 36 43
Store base opcode 43H for LD (nn),rr
6A59
Jump to encode register pair and complete
Handle other source types for LD (nn),source.
6A5C
CP 03H FE 03
Check operand type
6A5E
If not expected type, check further
6A60
LD A,B 78
Load register code
6A61
CP 07H FE 07
Check if A register
6A66
LD A,32H 3E 32
Load opcode 32H for LD (nn),A
6A68
LD (53B1H),A 32 B1 53
Store opcode
6A6B
RET C9
Return to main loop
6A6C
CP 05H FE 05
Check for index register type
6A6E
If not index register, error
6A71
DEC (HL) 35
Decrement opcode byte
6A72
Add DD or FD prefix for IX or IY
6A75
Jump to complete instruction
6A78H - LD 16-bit Register Handler
Handles 16-bit register pair loads: LD rr,nn, LD rr,(nn), LD SP,HL/IX/IY forms.
6A78
LD (HL),2AH 36 2A
Store base opcode 2AH for LD HL,(nn)
6A7A
PUSH AF F5
Save operand type
6A7B
Require comma separator
6A7E
POP AF F1
Restore operand type
6A7F
CP 05H FE 05
Check for index register type
6A81
If not index register, jump to check other forms
Handle LD IX,nn or LD IY,nn forms.
6A83
Add DD or FD prefix for IX or IY
6A86
INC HL 23
Point to next opcode byte position
6A87
Get source operand type
6A8A
PUSH AF F5
Save operand type
6A8B
If parenthesized (memory), jump to handle LD IX,(nn)
6A8D
LD (HL),21H 36 21
Store opcode 21H for LD IX,nn immediate
6A8F
Evaluate and store 16-bit immediate value
Handle LD IX,(nn) or LD IY,(nn) forms.
6A94
Evaluate address expression
6A97
Store address in instruction bytes
6A9A
INC (HL) 34
Increment instruction length
6A9B
POP AF F1
Restore operand type
6A9C
If was memory operand, require closing parenthesis
6A9F
RET C9
Return to main loop
Handle LD r,I or LD r,R forms (special registers).
6AA0
CP 08H FE 08
Check for special register type (I or R)
6AA2
If not special register, check other forms
6AA4
LD A,47H 3E 47
Load base opcode 47H for LD I,A
6AA6
OR B B0
OR with register code (I=0 gives 47H, R=1 gives 4FH)
6AA7
LD (HL),A 77
Store opcode
6AA8
Parse source - must be A register
6AAB
If not a register, error
6AAE
LD A,B 78
Load source register code
6AAF
CP 07H FE 07
Check if A register
6AB1
If not A, error - only LD I,A and LD R,A valid
6AB4
Jump to add ED prefix and complete
Handle LD rr,nn or LD rr,(nn) register pair forms.
6AB7
CP 04H FE 04
Check for register pair operand type
6AB9
If not register pair, error
6ABC
LD A,B 78
Load register pair code
6ABD
CP 03H FE 03
Check if SP
6ABF
If not SP, jump to handle BC/DE/HL
Handle LD SP,HL or LD SP,IX/IY form.
6AC1
LD (HL),F9H 36 F9
Store opcode F9H for LD SP,HL
6AC3
Check for index register
6AC6
If index register, add DD/FD prefix
6AC9
CP 04H FE 04
Check for register pair type
6ACC
LD H,03H 26 03
Load expected pair code (HL=02H after adjustment)
6ACE
EX (SP),HL E3
Exchange with stack
6ACF
If not register pair type, check further
6AD1
DEC B 05
Adjust register code
6AD2
DEC B 05
Adjust again - should be 0 for HL
6AD3
If not HL, check further
6AD5
POP BC C1
Clean up stack
6AD6
Set instruction length to 1 and return
6AD9H - LD rr,source Handler (BC/DE/HL)
Handles LD BC/DE/HL with various source operands including immediate values and memory addresses.
6AD9
PUSH BC C5
Save register pair code on stack
6ADA
Advance source pointer to get source operand
6ADD
Check for open parenthesis (memory source)
6AE0
If parenthesized, jump to handle LD rr,(nn)
Handle LD rr,nn immediate form - load 16-bit immediate value into register pair.
6AE2
LD (HL),01H 36 01
Store base opcode 01H for LD BC,nn
6AE4
Evaluate expression and store 16-bit immediate value
6AE7
POP BC C1
Restore register pair code
6AE8
Jump to encode register pair into opcode bits 4-5
Handle LD rr,(nn) memory form - load register pair from memory address. HL uses opcode 2AH directly; BC/DE/SP require ED prefix.
6AEB
LD (HL),2AH 36 2A
Store base opcode 2AH for LD HL,(nn)
6AED
Evaluate address expression
6AF0
Store 16-bit address in instruction bytes
6AF3
Require closing parenthesis
6AF6
POP AF F1
Restore register pair code into A
6AF7
CP 02H FE 02
Check if HL register pair (code 02H)
6AF9
RET Z C8
If HL, return - opcode 2AH is correct for LD HL,(nn)
For BC, DE, or SP register pairs, need ED prefix with opcode 4BH.
6AFA
LD HL,53B0H 21 B0 53
Point to prefix byte storage location
6AFD
LD (HL),EDH 36 ED
Store ED prefix byte
6AFF
INC HL 23
Point to opcode byte location (53B1H)
6B00
LD (HL),4BH 36 4B
Store base opcode 4BH for ED-prefixed LD rr,(nn)
6B02
Encode register pair into opcode bits 4-5
6B05
LD A,04H 3E 04
Set instruction length to 4 bytes (ED + opcode + 2 address bytes)
6B07
LD (53B4H),A 32 B4 53
Store instruction length in counter variable
6B0A
RET C9
Return to main assembly loop
6B0BH - ORG Directive Handler
Handles the ORG (Origin) directive which sets the assembly address counter to a specified value. This directive changes where subsequent code will be assembled without generating any object code bytes.
6B0B
Evaluate expression to get new origin address
6B0E
LD HL,(53B6H) 2A B6 53
Load current assembly address into HL
6B11
EX DE,HL EB
Swap: DE=current addr, HL=new origin from expression
6B12
LD (53AEH),HL 22 AE 53
Store new origin in secondary address pointer
6B15
ADD HL,DE 19
Add current address to new origin (calculate combined value)
6B16
LD (53B6H),HL 22 B6 53
Update current assembly address
6B19
RET C9
Return to main assembly loop
6B1AH - DEFM/DEFB Character String Handler
Handles character string constants within DEFB/DEFM directives. Processes single-quoted strings character by character, outputting each byte to the object code.
6B1A
POP BC C1
Clean up return address from stack (entered via special dispatch)
6B1B
Skip delimiter and get next character
6B1E
CP 27H FE 27
Check for opening single quote character
6B20
If not quote, jump to operand syntax error
6B23
Get first character inside the quotes
6B26
If end of line (empty string), jump to error
6B29
CP 27H FE 27
Check for immediate closing quote (empty string '')
6B2B
If empty string, jump to error - not allowed
6B2E
LD C,00H 0E 00
Initialize string processing flag to 0
[LOOP START] - Process each character in the string constant.
6B30
LD (53B1H),A 32 B1 53
Store current character as byte value in opcode buffer
6B33
Set instruction length to 1 byte
6B36
Output the byte to listing and object code
6B39
LD HL,(53AEH) 2A AE 53
Load secondary address pointer
6B3C
LD A,(53C0H) 3A C0 53
Load current assembly pass number
6B3F
CP 03H FE 03
Check if pass 3 (object code generation)
6B41
If pass 3, skip address increment (already handled)
6B43
INC HL 23
Increment address for next byte
6B44
LD (53AEH),HL 22 AE 53
Update secondary address pointer
6B47
LD (53B6H),HL 22 B6 53
Update current assembly address
6B4A
XOR A AF
Clear A register
6B4B
LD (53B4H),A 32 B4 53
Clear instruction length (byte already output)
6B4E
LD C,01H 0E 01
Set flag indicating string processing active
6B50
Get next character from string
6B53
RET Z C8
If end of line, return (unterminated string OK at EOL)
6B54
CP 27H FE 27
Check for closing single quote
6B56
Jump to string termination handler (checks for '' escape or end)
6B59H - DEFB Numeric Expression Handler
Handles numeric expressions in DEFB directive, evaluating and storing single-byte values.
6B59
Evaluate numeric expression
6B5C
Validate result fits in 8 bits (warn if out of range)
6B5F
LD A,E 7B
Load low byte of expression result into A
6B60
LD (53B1H),A 32 B1 53
Store byte value in opcode buffer
6B63
Jump to set instruction length to 1 and return
6B66H - DEFW Directive Handler
Handles the DEFW (Define Word) directive which stores 16-bit values in standard Z80 low-byte-first order.
6B66
Evaluate 16-bit expression
6B69
EX DE,HL EB
Move result from DE to HL
6B6A
LD (53B1H),HL 22 B1 53
Store 16-bit value (low byte at 53B1H, high byte at 53B2H)
6B6D
Jump to add 2 bytes to instruction length and return
6B70H - DEFS Directive Handler
Handles the DEFS (Define Storage) directive which reserves a specified number of bytes without initializing them. Advances the assembly address counter without generating object code.
6B70
INC C 0C
Increment C register
6B71
DEC C 0D
Decrement C register - tests if C was zero
6B72
If C was non-zero (label present), jump to label error - DEFS cannot have label on same line
6B75
Evaluate expression for number of bytes to reserve
6B78
EX DE,HL EB
Move byte count from DE to HL
6B79
LD (53B6H),HL 22 B6 53
Update current assembly address (skip over reserved space)
6B7C
LD (53AEH),HL 22 AE 53
Update secondary address pointer to match
6B7F
RET C9
Return to main assembly loop
6B80H - END Directive Handler
Handles the END directive which terminates assembly. Optionally accepts an expression specifying the program execution entry point address which is written to the object file.
6B80
LD DE,5A2BH 11 2B 5A
Load pointer to "END" status message
6B83
Display conditional status message
6B86
LD A,(53C0H) 3A C0 53
Load current assembly pass number
6B89
CP 03H FE 03
Check if pass 3 (final object code generation pass)
6B8B
If not pass 3, jump to initialize next pass
Pass 3 - Final pass complete. Process optional entry point and finalize object file.
6B8E
POP HL E1
Remove return address from stack (END terminates assembly)
6B90
DEC C 0D
Test if C was zero (no label on END line)
6B91
If label present on END line, jump to label error
6B94
Skip delimiter and check for operand
6B97
LD HL,0000H 21 00 00
Default entry point address is 0000H
6B9A
If no operand given, use default entry point
6B9C
Evaluate entry point expression (with CR check)
6B9F
EX DE,HL EB
Move entry point address from DE to HL
6BA0
LD (53AEH),HL 22 AE 53
Store entry point address
6BA3
PUSH HL E5
Save entry point on stack
6BA4
Call end-of-line processing routine
6BA7
POP HL E1
Restore entry point address
6BA8
LD A,(53C0H) 3A C0 53
Load pass number again
6BAB
CP 03H FE 03
Verify still in pass 3
6BAD
If pass changed, restart assembly process
6BAF
LD A,(53BEH) 3A BE 53
Load listing control flag
6BB2
OR A B7
Test if listing is enabled
6BB3
If listing enabled, output entry point information
Write transfer address record (type 78H) to object file with entry point.
6BB6
LD A,78H 3E 78
Load transfer address record type marker (78H)
6BB8
Output record type byte to object file
6BBB
LD A,L 7D
Load low byte of entry point address
6BBC
Output low byte of entry address
6BBF
LD A,H 7C
Load high byte of entry point address
6BC0
Output high byte of entry address
6BC3
Jump to assembly completion and cleanup routine
6BC6H - EQU Directive Handler
Handles the EQU (Equate) directive which assigns a constant value to a symbol. The symbol must be defined as a label on the same line. Unlike labels on regular instructions, EQU symbols can be given any value, not just the current address.
6BC6
INC A 3C
Increment A (operand type from dispatch)
6BC7
LD B,A 47
Save incremented operand type in B
6BC8
INC C 0C
Increment C register
6BC9
DEC C 0D
Decrement C - tests if C was zero (no label)
6BCA
If no label present, jump to line complete - EQU requires a label
6BCD
EX DE,HL EB
Swap DE and HL (prepare for expression evaluation)
6BCE
Evaluate expression for value to assign to symbol
6BD1
LD A,B 78
Restore saved operand type
6BD2
EX DE,HL EB
Move expression result (value) from DE to HL
6BD3
LD (53AEH),HL 22 AE 53
Store value in address variable (used as symbol value)
6BD6
Jump to symbol table update routine to assign value to label
6BD9H - Opcode/Directive Mnemonic Lookup Table
This table contains all Z80 mnemonics and assembler directives in a packed format. Each entry consists of: length byte, ASCII mnemonic string, type/flags byte, and handler index or base opcode. The table is searched sequentially by the opcode parser at 627CH. The disassembler incorrectly interprets these data bytes as Z80 instructions.
Entry: ADC - Add with Carry instruction
6BD9
DEFB 03H 03
Length: 3 characters in mnemonic
6BDA
DEFM 'ADC' 41 44 43
Mnemonic: ADC (Add with Carry)
6BDD
DEFB 04H 04
Type code: 04H - arithmetic with carry handler
6BDE
DEFB 88H 88
Base opcode: 88H for ADC A,r
Entry: ADD - Add instruction
6BDF
DEFB 03H 03
Length: 3 characters in mnemonic
6BE0
DEFM 'ADD' 41 44 44
Mnemonic: ADD
6BE3
DEFB 05H 05
Type code: 05H - arithmetic handler
6BE4
DEFB 80H 80
Base opcode: 80H for ADD A,r
Entry: AND - Logical AND instruction
6BE5
DEFB 03H 03
Length: 3 characters in mnemonic
6BE6
DEFM 'AND' 41 4E 44
Mnemonic: AND
6BE9
DEFB 01H 01
Type code: 01H - logical operation handler
6BEA
DEFB A0H A0
Base opcode: A0H for AND r
Entry: BIT - Bit Test instruction
6BEB
DEFB 03H 03
Length: 3 characters in mnemonic
6BEC
DEFM 'BIT' 42 49 54
Mnemonic: BIT
6BEF
DEFB 03H 03
Type code: 03H - bit operation handler
6BF0
DEFB 40H 40
Base opcode: 40H (with CB prefix)
Entry: CALL - Call Subroutine instruction
6BF1
DEFB 04H 04
Length: 4 characters in mnemonic
6BF2
DEFM 'CALL' 43 41 4C 4C
Mnemonic: CALL
6BF6
DEFB 09H 09
Type code: 09H - call instruction handler
6BF7
DEFB CDH CD
Base opcode: CDH for CALL nn
Entry: CCF - Complement Carry Flag instruction
6BF8
DEFB 03H 03
Length: 3 characters in mnemonic
6BF9
DEFM 'CCF' 43 43 46
Mnemonic: CCF
6BFC
DEFB 00H 00
Type code: 00H - simple instruction
6BFD
DEFB 3FH 3F
Opcode: 3FH for CCF
Entry: CP - Compare instruction
6BFE
DEFB 02H 02
Length: 2 characters in mnemonic
6BFF
DEFM 'CP' 43 50
Mnemonic: CP
6C01
DEFB 01H 01
Type code: 01H - logical operation handler
6C02
DEFB B8H B8
Base opcode: B8H for CP r
Entry: CPD - Compare and Decrement instruction
6C03
DEFB 03H 03
Length: 3 characters in mnemonic
6C04
DEFM 'CPD' 43 50 44
Mnemonic: CPD
6C07
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6C08
DEFB A9H A9
Opcode byte 2: A9H (ED A9H = CPD)
Entry: CPDR - Compare, Decrement and Repeat instruction
6C09
DEFB 04H 04
Length: 4 characters in mnemonic
6C0A
DEFM 'CPDR' 43 50 44 52
Mnemonic: CPDR
6C0E
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6C0F
DEFB B9H B9
Opcode byte 2: B9H (ED B9H = CPDR)
Entry: CPI - Compare and Increment instruction
6C10
DEFB 03H 03
Length: 3 characters in mnemonic
6C11
DEFM 'CPI' 43 50 49
Mnemonic: CPI
6C14
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6C15
DEFB A1H A1
Opcode byte 2: A1H (ED A1H = CPI)
Entry: CPIR - Compare, Increment and Repeat instruction
6C16
DEFB 04H 04
Length: 4 characters in mnemonic
6C17
DEFM 'CPIR' 43 50 49 52
Mnemonic: CPIR
6C1B
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6C1C
DEFB B1H B1
Opcode byte 2: B1H (ED B1H = CPIR)
Entry: CPL - Complement Accumulator instruction
6C1D
DEFB 03H 03
Length: 3 characters in mnemonic
6C1E
DEFM 'CPL' 43 50 4C
Mnemonic: CPL
6C21
DEFB 00H 00
Type code: 00H - simple instruction
6C22
DEFB 2FH 2F
Opcode: 2FH for CPL
Entry: DAA - Decimal Adjust Accumulator instruction
6C23
DEFB 03H 03
Length: 3 characters in mnemonic
6C24
DEFM 'DAA' 44 41 41
Mnemonic: DAA
6C27
DEFB 00H 00
Type code: 00H - simple instruction
6C28
DEFB 27H 27
Opcode: 27H for DAA
Entry: DEC - Decrement instruction
6C29
DEFB 03H 03
Length: 3 characters in mnemonic
6C2A
DEFM 'DEC' 44 45 43
Mnemonic: DEC
6C2D
DEFB 06H 06
Type code: 06H - inc/dec handler
6C2E
DEFB 05H 05
Opcode modifier: 05H (DEC r = 05H + r*8)
Entry: DEFB - Define Byte directive
6C2F
DEFB 04H 04
Length: 4 characters in mnemonic
6C30
DEFM 'DEFB' 44 45 46 42
Directive: DEFB (Define Byte)
6C34
DEFB 16H 16
Type code: 16H - DEFB directive handler
6C35
DEFB 00H 00
Handler parameter: 00H
Entry: DEFL - Define Label directive (re-definable)
6C36
DEFB 04H 04
Length: 4 characters in mnemonic
6C37
DEFM 'DEFL' 44 45 46 4C
Directive: DEFL (Define Label)
6C3B
DEFB 1BH 1B
Type code: 1BH - DEFL directive handler
6C3C
DEFB 00H 00
Handler parameter: 00H
Entry: DEFM - Define Message directive
6C3D
DEFB 04H 04
Length: 4 characters in mnemonic
6C3E
DEFM 'DEFM' 44 45 46 4D
Directive: DEFM (Define Message/string)
6C42
DEFB 15H 15
Type code: 15H - DEFM directive handler
6C43
DEFB 00H 00
Handler parameter: 00H
Entry: DEFS - Define Storage directive
6C44
DEFB 04H 04
Length: 4 characters in mnemonic
6C45
DEFM 'DEFS' 44 45 46 53
Directive: DEFS (Define Storage)
6C49
DEFB 14H 14
Type code: 14H - DEFS directive handler
6C4A
DEFB 00H 00
Handler parameter: 00H
Entry: DEFW - Define Word directive
6C4B
DEFB 04H 04
Length: 4 characters in mnemonic
6C4C
DEFM 'DEFW' 44 45 46 57
Directive: DEFW (Define Word)
6C50
DEFB 17H 17
Type code: 17H - DEFW directive handler
6C51
DEFB 00H 00
Handler parameter: 00H
Entry: DI - Disable Interrupts instruction
6C52
DEFB 02H 02
Length: 2 characters in mnemonic
6C53
DEFM 'DI' 44 49
Mnemonic: DI
6C55
DEFB 00H 00
Type code: 00H - simple instruction
6C56
DEFB F3H F3
Opcode: F3H for DI
Entry: DJNZ - Decrement and Jump if Not Zero instruction
6C57
DEFB 04H 04
Length: 4 characters in mnemonic
6C58
DEFM 'DJNZ' 44 4A 4E 5A
Mnemonic: DJNZ
6C5C
DEFB 0DH 0D
Type code: 0DH - relative jump handler
6C5D
DEFB 10H 10
Opcode: 10H for DJNZ
Entry: END - End of Assembly directive
6C5E
DEFB 03H 03
Length: 3 characters in mnemonic
6C5F
DEFM 'END' 45 4E 44
Directive: END
6C62
DEFB 19H 19
Type code: 19H - END directive handler
6C63
DEFB 00H 00
Handler parameter: 00H
Entry: EI - Enable Interrupts instruction
6C64
DEFB 02H 02
Length: 2 characters in mnemonic
6C65
DEFM 'EI' 45 49
Mnemonic: EI
6C67
DEFB 00H 00
Type code: 00H - simple instruction
6C68
DEFB FBH FB
Opcode: FBH for EI
Entry: EQU - Equate directive
6C69
DEFB 03H 03
Length: 3 characters in mnemonic
6C6A
DEFM 'EQU' 45 51 55
Directive: EQU
6C6D
DEFB 1AH 1A
Type code: 1AH - EQU directive handler
6C6E
DEFB 00H 00
Handler parameter: 00H
Entry: EX - Exchange instruction
6C6F
DEFB 02H 02
Length: 2 characters in mnemonic
6C70
DEFM 'EX' 45 58
Mnemonic: EX
6C72
DEFB 11H 11
Type code: 11H - EX instruction handler
6C73
DEFB EBH EB
Base opcode: EBH for EX DE,HL
Entry: EXX - Exchange All instruction
6C74
DEFB 03H 03
Length: 3 characters in mnemonic
6C75
DEFM 'EXX' 45 58 58
Mnemonic: EXX
6C78
DEFB 00H 00
Type code: 00H - simple instruction
6C79
DEFB D9H D9
Opcode: D9H for EXX
Entry: HALT - Halt instruction
6C7A
DEFB 04H 04
Length: 4 characters in mnemonic
6C7B
DEFM 'HALT' 48 41 4C 54
Mnemonic: HALT
6C7F
DEFB 00H 00
Type code: 00H - simple instruction
6C80
DEFB 76H 76
Opcode: 76H for HALT
Entry: IM - Interrupt Mode instruction
6C81
DEFB 02H 02
Length: 2 characters in mnemonic
6C82
DEFM 'IM' 49 4D
Mnemonic: IM
6C84
DEFB 07H 07
Type code: 07H - IM instruction handler
6C85
DEFB EDH ED
Prefix: EDH for IM instructions
Entry: IN - Input instruction
6C86
DEFB 02H 02
Length: 2 characters in mnemonic
6C87
DEFM 'IN' 49 4E
Mnemonic: IN
6C89
DEFB 0FH 0F
Type code: 0FH - IN instruction handler
6C8A
DEFB DBH DB
Base opcode: DBH for IN A,(n)
Entry: INC - Increment instruction
6C8B
DEFB 03H 03
Length: 3 characters in mnemonic
6C8C
DEFM 'INC' 49 4E 43
Mnemonic: INC
6C8F
DEFB 06H 06
Type code: 06H - inc/dec handler
6C90
DEFB 04H 04
Opcode modifier: 04H (INC r = 04H + r*8)
Entry: IND - Input and Decrement instruction
6C91
DEFB 03H 03
Length: 3 characters in mnemonic
6C92
DEFM 'IND' 49 4E 44
Mnemonic: IND
6C95
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6C96
DEFB AAH AA
Opcode byte 2: AAH (ED AAH = IND)
Entry: INDR - Input, Decrement and Repeat instruction
6C97
DEFB 04H 04
Length: 4 characters in mnemonic
6C98
DEFM 'INDR' 49 4E 44 52
Mnemonic: INDR
6C9C
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6C9D
DEFB BAH BA
Opcode byte 2: BAH (ED BAH = INDR)
Entry: INI - Input and Increment instruction
6C9E
DEFB 03H 03
Length: 3 characters in mnemonic
6C9F
DEFM 'INI' 49 4E 49
Mnemonic: INI
6CA2
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CA3
DEFB A2H A2
Opcode byte 2: A2H (ED A2H = INI)
Entry: INIR - Input, Increment and Repeat instruction
6CA4
DEFB 04H 04
Length: 4 characters in mnemonic
6CA5
DEFM 'INIR' 49 4E 49 52
Mnemonic: INIR
6CA9
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CAA
DEFB B2H B2
Opcode byte 2: B2H (ED B2H = INIR)
Entry: JP - Jump instruction
6CAB
DEFB 02H 02
Length: 2 characters in mnemonic
6CAC
DEFM 'JP' 4A 50
Mnemonic: JP
6CAE
DEFB 0BH 0B
Type code: 0BH - JP instruction handler
6CAF
DEFB C3H C3
Base opcode: C3H for JP nn
Entry: JR - Jump Relative instruction
6CB0
DEFB 02H 02
Length: 2 characters in mnemonic
6CB1
DEFM 'JR' 4A 52
Mnemonic: JR
6CB3
DEFB 0CH 0C
Type code: 0CH - JR instruction handler
6CB4
DEFB 18H 18
Base opcode: 18H for JR e
Entry: LD - Load instruction
6CB5
DEFB 02H 02
Length: 2 characters in mnemonic
6CB6
DEFM 'LD' 4C 44
Mnemonic: LD
6CB8
DEFB 13H 13
Type code: 13H - LD instruction handler
6CB9
DEFB 40H 40
Base opcode: 40H for LD r,r'
Entry: LDD - Load and Decrement instruction
6CBA
DEFB 03H 03
Length: 3 characters in mnemonic
6CBB
DEFM 'LDD' 4C 44 44
Mnemonic: LDD
6CBE
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CBF
DEFB A8H A8
Opcode byte 2: A8H (ED A8H = LDD)
Entry: LDDR - Load, Decrement and Repeat instruction
6CC0
DEFB 04H 04
Length: 4 characters in mnemonic
6CC1
DEFM 'LDDR' 4C 44 44 52
Mnemonic: LDDR
6CC5
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CC6
DEFB B8H B8
Opcode byte 2: B8H (ED B8H = LDDR)
Entry: LDI - Load and Increment instruction
6CC7
DEFB 03H 03
Length: 3 characters in mnemonic
6CC8
DEFM 'LDI' 4C 44 49
Mnemonic: LDI
6CCB
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CCC
DEFB A0H A0
Opcode byte 2: A0H (ED A0H = LDI)
Entry: LDIR - Load, Increment and Repeat instruction
6CCD
DEFB 04H 04
Length: 4 characters in mnemonic
6CCE
DEFM 'LDIR' 4C 44 49 52
Mnemonic: LDIR
6CD2
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CD3
DEFB B0H B0
Opcode byte 2: B0H (ED B0H = LDIR)
Entry: NEG - Negate Accumulator instruction
6CD4
DEFB 03H 03
Length: 3 characters in mnemonic
6CD5
DEFM 'NEG' 4E 45 47
Mnemonic: NEG
6CD8
DEFB 08H 08
Type code: 08H - ED-prefixed handler
6CD9
DEFB 44H 44
Opcode byte 2: 44H (ED 44H = NEG)
Entry: NOP - No Operation instruction
6CDA
DEFB 03H 03
Length: 3 characters in mnemonic
6CDB
DEFM 'NOP' 4E 4F 50
Mnemonic: NOP
6CDE
DEFB 00H 00
Type code: 00H - simple instruction
6CDF
DEFB 00H 00
Opcode: 00H for NOP
Entry: OR - Logical OR instruction
6CE0
DEFB 02H 02
Length: 2 characters in mnemonic
6CE1
DEFM 'OR' 4F 52
Mnemonic: OR
6CE3
DEFB 01H 01
Type code: 01H - logical operation handler
6CE4
DEFB B0H B0
Base opcode: B0H for OR r
Entry: ORG - Origin directive
6CE5
DEFB 03H 03
Length: 3 characters in mnemonic
6CE6
DEFM 'ORG' 4F 52 47
Directive: ORG
6CE9
DEFB 18H 18
Type code: 18H - ORG directive handler
6CEA
DEFB 00H 00
Handler parameter: 00H
Entry: OTDR - Output, Decrement and Repeat instruction
6CEB
DEFB 04H 04
Length: 4 characters in mnemonic
6CEC
DEFM 'OTDR' 4F 54 44 52
Mnemonic: OTDR
6CF0
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CF1
DEFB BBH BB
Opcode byte 2: BBH (ED BBH = OTDR)
Entry: OTIR - Output, Increment and Repeat instruction
6CF2
DEFB 04H 04
Length: 4 characters in mnemonic
6CF3
DEFM 'OTIR' 4F 54 49 52
Mnemonic: OTIR
6CF7
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6CF8
DEFB B3H B3
Opcode byte 2: B3H (ED B3H = OTIR)
Entry: OUT - Output instruction
6CF9
DEFB 03H 03
Length: 3 characters in mnemonic
6CFA
DEFM 'OUT' 4F 55 54
Mnemonic: OUT
6CFD
DEFB 10H 10
Type code: 10H - OUT instruction handler
6CFE
DEFB D3H D3
Base opcode: D3H for OUT (n),A
Entry: OUTD - Output and Decrement instruction
6CFF
DEFB 04H 04
Length: 4 characters in mnemonic
6D00
DEFM 'OUTD' 4F 55 54 44
Mnemonic: OUTD
6D04
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6D05
DEFB ABH AB
Opcode byte 2: ABH (ED ABH = OUTD)
Entry: OUTI - Output and Increment instruction
6D06
DEFB 04H 04
Length: 4 characters in mnemonic
6D07
DEFM 'OUTI' 4F 55 54 49
Mnemonic: OUTI
6D0B
DEFB 08H 08
Type code: 08H - ED-prefixed block handler
6D0C
DEFB A3H A3
Opcode byte 2: A3H (ED A3H = OUTI)
Entry: POP - Pop from Stack instruction
6D0D
DEFB 03H 03
Length: 3 characters in mnemonic
6D0E
DEFM 'POP' 50 4F 50
Mnemonic: POP
6D11
DEFB 12H 12
Type code: 12H - PUSH/POP handler
6D12
DEFB C1H C1
Base opcode: C1H for POP BC
Entry: PUSH - Push to Stack instruction
6D13
DEFB 04H 04
Length: 4 characters in mnemonic
6D14
DEFM 'PUSH' 50 55 53 48
Mnemonic: PUSH
6D18
DEFB 12H 12
Type code: 12H - PUSH/POP handler
6D19
DEFB C5H C5
Base opcode: C5H for PUSH BC
Entry: RES - Reset Bit instruction
6D1A
DEFB 03H 03
Length: 3 characters in mnemonic
6D1B
DEFM 'RES' 52 45 53
Mnemonic: RES
6D1E
DEFB 03H 03
Type code: 03H - bit operation handler
6D1F
DEFB 80H 80
Base opcode: 80H (CB prefix + 80H)
Entry: RET - Return instruction
6D20
DEFB 03H 03
Length: 3 characters in mnemonic
6D21
DEFM 'RET' 52 45 54
Mnemonic: RET
6D24
DEFB 0AH 0A
Type code: 0AH - RET instruction handler
6D25
DEFB C9H C9
Opcode: C9H for RET
Entry: RETI - Return from Interrupt instruction
6D26
DEFB 04H 04
Length: 4 characters in mnemonic
6D27
DEFM 'RETI' 52 45 54 49
Mnemonic: RETI
6D2B
DEFB 08H 08
Type code: 08H - ED-prefixed handler
6D2C
DEFB 4DH 4D
Opcode byte 2: 4DH (ED 4DH = RETI)
RETN - Return from Non-Maskable Interrupt
6D2D
DEFB 04H 04
Length: 4 characters
6D2E
DEFM 'RETN' 52 45 54 4E
Mnemonic: RETN
6D32
DEFB 08H 08
Type: 08H - ED-prefixed
6D33
DEFB 45H 45
Opcode byte 2: 45H (ED 45H)
RL - Rotate Left through Carry
6D34
DEFB 02H 02
Length: 2 characters
6D35
DEFM 'RL' 52 4C
Mnemonic: RL
6D37
DEFB 02H 02
Type: 02H - rotate/shift
6D38
DEFB 10H 10
Base opcode: 10H (CB prefix)
RLA - Rotate Left Accumulator through Carry
6D39
DEFB 03H 03
Length: 3 characters
6D3A
DEFM 'RLA' 52 4C 41
Mnemonic: RLA
6D3D
DEFB 00H 00
Type: 00H - simple
6D3E
DEFB 17H 17
Opcode: 17H
RLC - Rotate Left Circular
6D3F
DEFB 03H 03
Length: 3 characters
6D40
DEFM 'RLC' 52 4C 43
Mnemonic: RLC
6D43
DEFB 02H 02
Type: 02H - rotate/shift
6D44
DEFB 00H 00
Base opcode: 00H (CB prefix)
RLCA - Rotate Left Circular Accumulator
6D45
DEFB 04H 04
Length: 4 characters
6D46
DEFM 'RLCA' 52 4C 43 41
Mnemonic: RLCA
6D4A
DEFB 00H 00
Type: 00H - simple
6D4B
DEFB 07H 07
Opcode: 07H
RLD - Rotate Left Digit
6D4C
DEFB 03H 03
Length: 3 characters
6D4D
DEFM 'RLD' 52 4C 44
Mnemonic: RLD
6D50
DEFB 08H 08
Type: 08H - ED-prefixed
6D51
DEFB 6FH 6F
Opcode byte 2: 6FH (ED 6FH)
RR - Rotate Right through Carry
6D52
DEFB 02H 02
Length: 2 characters
6D53
DEFM 'RR' 52 52
Mnemonic: RR
6D55
DEFB 02H 02
Type: 02H - rotate/shift
6D56
DEFB 18H 18
Base opcode: 18H (CB prefix)
RRA - Rotate Right Accumulator through Carry
6D57
DEFB 03H 03
Length: 3 characters
6D58
DEFM 'RRA' 52 52 41
Mnemonic: RRA
6D5B
DEFB 00H 00
Type: 00H - simple
6D5C
DEFB 1FH 1F
Opcode: 1FH
RRC - Rotate Right Circular
6D5D
DEFB 03H 03
Length: 3 characters
6D5E
DEFM 'RRC' 52 52 43
Mnemonic: RRC
6D61
DEFB 02H 02
Type: 02H - rotate/shift
6D62
DEFB 08H 08
Base opcode: 08H (CB prefix)
RRCA - Rotate Right Circular Accumulator
6D63
DEFB 04H 04
Length: 4 characters
6D64
DEFM 'RRCA' 52 52 43 41
Mnemonic: RRCA
6D68
DEFB 00H 00
Type: 00H - simple
6D69
DEFB 0FH 0F
Opcode: 0FH
RRD - Rotate Right Digit
6D6A
DEFB 03H 03
Length: 3 characters
6D6B
DEFM 'RRD' 52 52 44
Mnemonic: RRD
6D6E
DEFB 08H 08
Type: 08H - ED-prefixed
6D6F
DEFB 67H 67
Opcode byte 2: 67H (ED 67H)
RST - Restart
6D70
DEFB 03H 03
Length: 3 characters
6D71
DEFM 'RST' 52 53 54
Mnemonic: RST
6D74
DEFB 0EH 0E
Type: 0EH - RST handler
6D75
DEFB C7H C7
Base opcode: C7H
SBC - Subtract with Carry
6D76
DEFB 03H 03
Length: 3 characters
6D77
DEFM 'SBC' 53 42 43
Mnemonic: SBC
6D7A
DEFB 04H 04
Type: 04H - arithmetic with carry
6D7B
DEFB 98H 98
Base opcode: 98H
SCF - Set Carry Flag
6D7C
DEFB 03H 03
Length: 3 characters
6D7D
DEFM 'SCF' 53 43 46
Mnemonic: SCF
6D80
DEFB 00H 00
Type: 00H - simple
6D81
DEFB 37H 37
Opcode: 37H
SET - Set Bit
6D82
DEFB 03H 03
Length: 3 characters
6D83
DEFM 'SET' 53 45 54
Mnemonic: SET
6D86
DEFB 03H 03
Type: 03H - bit operation
6D87
DEFB C0H C0
Base opcode: C0H (CB prefix)
SLA - Shift Left Arithmetic
6D88
DEFB 03H 03
Length: 3 characters
6D89
DEFM 'SLA' 53 4C 41
Mnemonic: SLA
6D8C
DEFB 02H 02
Type: 02H - rotate/shift
6D8D
DEFB 20H 20
Base opcode: 20H (CB prefix)
SRA - Shift Right Arithmetic
6D8E
DEFB 03H 03
Length: 3 characters
6D8F
DEFM 'SRA' 53 52 41
Mnemonic: SRA
6D92
DEFB 02H 02
Type: 02H - rotate/shift
6D93
DEFB 28H 28
Base opcode: 28H (CB prefix)
SRL - Shift Right Logical
6D94
DEFB 03H 03
Length: 3 characters
6D95
DEFM 'SRL' 53 52 4C
Mnemonic: SRL
6D98
DEFB 02H 02
Type: 02H - rotate/shift
6D99
DEFB 38H 38
Base opcode: 38H (CB prefix)
SUB - Subtract
6D9A
DEFB 03H 03
Length: 3 characters
6D9B
DEFM 'SUB' 53 55 42
Mnemonic: SUB
6D9E
DEFB 01H 01
Type: 01H - logical/arithmetic
6D9F
DEFB 90H 90
Base opcode: 90H
XOR - Exclusive OR
6DA0
DEFB 03H 03
Length: 3 characters
6DA1
DEFM 'XOR' 58 4F 52
Mnemonic: XOR
6DA4
DEFB 01H 01
Type: 01H - logical op
6DA5
DEFB A8H A8
Base opcode: A8H
End of Table
6DA6
DEFB 00H 00
End marker: length=0 terminates table search
6DA7H - Opcode Handler Dispatch Address Table
This table contains 2-byte handler addresses (low-high order) indexed by the type code from the mnemonic table. Used by opcode dispatch at 657CH to jump to the appropriate encoding routine.
6DA7
DEFW 688DH 8D 68
Type 00H: Simple instruction - set length=1
6DA9
DEFW 6654H 54 66
Type 01H: Logical/arithmetic (AND,OR,XOR,CP,SUB)
6DAB
DEFW 6696H 96 66
Type 02H: Rotate/shift operations
6DAD
DEFW 667CH 7C 66
Type 03H: Bit operations (BIT,SET,RES)
6DAF
DEFW 6714H 14 67
Type 04H: ADC/SBC with register pairs
6DB1
DEFW 6735H 35 67
Type 05H: ADD instruction
6DB3
DEFW 677DH 7D 67
Type 06H: INC/DEC instructions
6DB5
DEFW 679EH 9E 67
Type 07H: IM instruction
6DB7
DEFW 67B7H B7 67
Type 08H: ED-prefixed instructions
6DB9
DEFW 67BFH BF 67
Type 09H: CALL instruction
6DBB
DEFW 680CH 0C 68
Type 0AH: RET instruction
6DBD
DEFW 681AH 1A 68
Type 0BH: JP instruction
6DBF
DEFW 6839H 39 68
Type 0CH: JR instruction
6DC1
DEFW 6850H 50 68
Type 0DH: DJNZ instruction
6DC3
DEFW 6879H 79 68
Type 0EH: RST instruction
6DC5
DEFW 6893H 93 68
Type 0FH: IN instruction
6DC7
DEFW 68CEH CE 68
Type 10H: OUT instruction
6DC9
DEFW 690FH 0F 69
Type 11H: EX instruction
6DCB
DEFW 6964H 64 69
Type 12H: PUSH/POP instructions
6DCD
DEFW 6980H 80 69
Type 13H: LD instruction
6DCF
DEFW 6B0BH 0B 6B
Type 14H: DEFS directive
6DD1
DEFW 6B1AH 1A 6B
Type 15H: DEFM directive
6DD3
DEFW 6B59H 59 6B
Type 16H: DEFB directive
6DD5
DEFW 6B66H 66 6B
Type 17H: DEFW directive
6DD7
DEFW 6B70H 70 6B
Type 18H: ORG directive
6DD9
DEFW 6B8EH 8E 6B
Type 19H: END directive
6DDB
DEFW 6BC7H C7 6B
Type 1AH: EQU directive
6DDD
DEFW 6BC6H C6 6B
Type 1BH: DEFL directive
6DDFH - End-of-Line Verification Routine
Called after processing an instruction or directive to verify the source line ends properly. Accepts carriage return (0DH) or semicolon (3BH for comments) as valid terminators. Generates an operand syntax error if unexpected characters remain on the line.
6DDF
Skip any delimiter and get next character from source line
6DE2
CP 20H FE 20
Compare with space character (20H)
6DE4
If space found, call skip-spaces routine to advance past whitespace
6DE7
CP 0DH FE 0D
Compare with carriage return (end of line marker)
6DE9
If CR found, line is complete - jump to set completion flags
6DEB
CP 3BH FE 3B
Compare with semicolon (comment delimiter)
6DED
If not semicolon, unexpected text remains - jump to operand error
6DF0
LD A,AFH 3E AF
Load AFH into A (XOR A opcode byte, used as completion marker)
6DF2
LD C,00H 0E 00
Clear C register - indicates no pending label on this line
6DF4H - Assembly Pass Output Router
Routes output processing based on the current assembly pass number. Pass 1 calculates addresses, Pass 2 generates listing, Pass 3 generates object code. The pass number is stored at 53C0H.
6DF4
LD B,A 47
Save A register (completion flag) in B
6DF5
LD HL,53C0H 21 C0 53
Point HL to pass number variable
6DF8
LD A,(HL) 7E
Load current pass number (1, 2, or 3)
6DF9
DEC A 3D
Decrement to test for pass 1
6DFA
RET Z C8
If pass 1 (now 0), return - no output needed
6DFB
DEC A 3D
Decrement again to test for pass 2
6DFC
If not pass 2 (must be pass 3), jump to object code output
6DFE
Pass 2: Jump to listing output routine
6E01H - Listing Line Output Entry Point
Entry point for listing line generation during pass 2. Formats and outputs the address, object code bytes, and source line to the listing device.
6E01
NOP 00
No operation (padding/alignment)
6E02
NOP 00
No operation (padding/alignment)
6E03
OR (HL) B6
OR A with value at HL - test listing enable flag
6E04
RET NZ C0
If listing disabled (non-zero), return immediately
6E05
LD A,(587EH) 3A 7E 58
Load listing control byte from file state
6E08
DEC HL 2B
Point HL back one byte
6E09
LD (HL),A 77
Store listing control value
6E0A
EX DE,HL EB
Exchange DE and HL
6E0B
LD HL,53AFH 21 AF 53
Point HL to listing format control area
6E0E
INC B 04
Increment B (test if zero)
6E0F
DEC B 05
Decrement B back - sets Z flag if B was 0
6E10
If B non-zero, jump to alternate format handling
Output 5 spaces for address field padding when no address to show.
6E12
LD B,05H 06 05
Set counter for 5 spaces
6E14
Output space character to listing
6E17
[LOOP] Decrement B and repeat until 5 spaces output
6E19
INC HL 23
Advance HL pointer
6E1A
LD A,(HL) 7E
Load byte from listing control area
6E1C
If zero, skip adjustment
6E1E
DEC HL 2B
Back up HL pointer
Output up to 9 hex bytes of object code for this instruction.
6E1F
LD B,09H 06 09
Set counter for max 9 bytes to display
6E21
PUSH BC C5
Save counter on stack
6E22
LD A,(53B4H) 3A B4 53
Load instruction length (number of bytes)
6E25
LD C,A 4F
Copy length to C as byte counter
6E26
INC HL 23
Advance to next byte position
6E27
DEC C 0D
Decrement remaining byte count
6E28
If count went negative (no more bytes), output space
6E2B
If count positive/zero (bytes remain), output hex byte
6E2E
[LOOP] Repeat for up to 9 positions
6E30
LD BC,0001H 01 01 00
Load BC with 1 (single line output)
6E33
LD HL,(5311H) 2A 11 53
Load source line pointer
6E36
POP AF F1
Restore flags from stack
6E37
PUSH AF F5
Save flags again
6E38
If carry clear, output source line text
6E3B
POP AF F1
Restore flags
6E3C
EX DE,HL EB
Exchange DE and HL
6E3D
LD (HL),B 70
Store B value at HL
6E3E
If carry set, call output flush routine
6E41
RET C9
Return to caller
6E42H - Alternate Listing Format Handler
Handles alternate listing format when address field needs to be displayed. Outputs the 4-digit hex address before the object code bytes.
6E42
Output high byte of address as 2 hex digits
6E45
DEC HL 2B
Point to low byte of address
6E46
Output low byte of address as 2 hex digits
6E49
INC HL 23
Restore HL to original position
6E4A
LD B,01H 06 01
Set B=1 for single space
6E4C
Jump back to continue with object bytes output
6E4EH - Output Byte as Two Hex Digits
Converts a byte pointed to by HL to two hexadecimal ASCII characters and outputs them to the listing. Uses standard nibble-to-hex conversion.
6E4E
DEC B 05
Decrement position counter (tracks column)
6E4F
LD A,(HL) 7E
Load byte to convert from memory
6E50
RRCA 0F
Rotate right to get high nibble into low position
6E51
RRCA 0F
Rotate right (step 2 of 4)
6E52
RRCA 0F
Rotate right (step 3 of 4)
6E53
RRCA 0F
Rotate right (step 4 of 4) - high nibble now in bits 0-3
6E54
Convert and output high nibble as hex digit
6E57
LD A,(HL) 7E
Reload original byte for low nibble
Fall through to convert and output low nibble.
6E58
AND 0FH E6 0F
Mask to keep only low nibble (0-15)
6E5A
ADD A,30H C6 30
Add ASCII '0' (30H) to convert to digit
6E5C
CP 3AH FE 3A
Compare with ':' (one past '9')
6E5E
If less than ':', it's 0-9, skip letter adjustment
6E60
ADD A,07H C6 07
Add 7 to convert 10-15 to 'A'-'F'
6E62
Jump to character output routine
6E65H - Object Code Output Routine (Pass 3)
Generates object code output during pass 3. Writes instruction bytes to the object file in the system-specific format with load addresses and checksums.
6E65
LD BC,53B0H 01 B0 53
Point BC to instruction opcode buffer (prefix byte location)
6E68
LD A,(53B4H) 3A B4 53
Load instruction length in bytes
6E6B
PUSH AF F5
Save instruction length on stack
6E6C
LD A,(BC) 0A
Load first byte (prefix or opcode)
6E6D
OR A B7
Test if prefix byte is zero
6E6E
If non-zero prefix, skip increment
6E70
INC BC 03
No prefix - point to actual opcode at 53B1H
6E71
POP AF F1
Restore instruction length
6E72
DEC A 3D
Decrement byte count
6E73
RET M F8
If count went negative (no bytes), return
6E74
PUSH AF F5
Save remaining count
6E75
LD HL,(531FH) 2A 1F 53
Load object file buffer pointer
6E78
INC HL 23
Advance buffer pointer
6E79
EX DE,HL EB
DE = new buffer position
6E7A
LD HL,(53AEH) 2A AE 53
Load current assembly address
6E7D
LD (531FH),HL 22 1F 53
Store as new object file position
6E80
LD A,(53BEH) 3A BE 53
Load object record status flag
6E83
OR A B7
Test if record in progress
6E84
If no record in progress, jump to start new record
6E86
Compare addresses to check continuity
6E89
If addresses continuous, jump to append to record
6E8B
Addresses not continuous - flush current record
Initialize new object code record with load address.
6E8E
EX DE,HL EB
HL = buffer position, DE = assembly address
6E8F
LD HL,5323H 21 23 53
Point to object record header area
6E92
LD A,E 7B
Load low byte of assembly address
6E93
ADD A,D 82
Add high byte (start of checksum calculation)
6E94
LD (HL),A 77
Store initial checksum
6E96
INC HL 23
Point to byte count position
6E97
LD (HL),A 77
Initialize byte count to 0
6E98
CPL 2F
Complement A (now FFH)
6E99
LD (53BEH),A 32 BE 53
Set record-in-progress flag to FFH
6E9C
INC HL 23
Point to address low byte storage
6E9D
LD (HL),E 73
Store low byte of load address
6E9E
INC HL 23
Point to address high byte storage
6E9F
LD (HL),D 72
Store high byte of load address
6EA0
INC HL 23
Point to data area
6EA1
LD (5321H),HL 22 21 53
Store data pointer
6EA4
EX DE,HL EB
Swap back - DE = data pointer
Add byte to current object record.
6EA5
LD DE,5324H 11 24 53
Point DE to byte count in record
6EA8
LD A,(DE) 1A
Load current byte count
6EA9
INC A 3C
Increment byte count
6EAA
CP 81H FE 81
Compare with max record size (128 bytes + 1)
6EAC
If record full, jump to flush and start new
6EAE
LD (DE),A 12
Store updated byte count
6EAF
INC HL 23
Advance assembly address
6EB0
LD (53AEH),HL 22 AE 53
Store updated assembly address
6EB3
LD HL,(5321H) 2A 21 53
Load data pointer
6EB6
LD A,(BC) 0A
Load instruction byte from buffer
6EB7
LD (HL),A 77
Store byte in object record
6EB8
INC HL 23
Advance data pointer
6EB9
Update checksum with this byte
6EBC
INC BC 03
Point to next instruction byte
6EBD
EX DE,HL EB
Swap pointers
6EBE
DEC HL 2B
Adjust pointer
6EBF
ADD A,(HL) 86
Add to running checksum
6EC0
LD (HL),A 77
Store updated checksum
6EC1
Loop back to process next byte
6EC3H - Flush Object Record to File
Writes the current object code record to the output file. Outputs the record type marker (3CH), load address, data bytes, and checksum.
6EC3
PUSH HL E5
Save HL on stack
6EC4
PUSH BC C5
Save BC on stack
6EC5
LD A,(5324H) 3A 24 53
Load byte count from record header
6EC8
ADD A,04H C6 04
Add 4 for header bytes (type + count + addr)
6ECA
LD B,A 47
B = total bytes to output
6ECB
LD HL,5323H 21 23 53
Point to record checksum position
6ECE
LD C,(HL) 4E
Load checksum into C
6ECF
LD A,3CH 3E 3C
Load object record type marker (3CH = data record)
6ED1
Jump to output first byte
6ED3
LD A,(HL) 7E
Load next record byte
6ED4
INC HL 23
Advance record pointer
6ED5
Output byte to object file
6ED8
[LOOP] Repeat for all bytes in record
6EDA
LD A,C 79
Load checksum from C
6EDF
LD (53BEH),A 32 BE 53
Clear record-in-progress flag
6EE4
RET C9
Return to caller
6EE5H - Pass 2 Listing Setup
Entry point for pass 2 listing generation. Adjusts pointers and loads control flags before calling the main listing output routine.
6EE5
DEC HL 2B
Adjust HL pointer back 3 positions
6EE6
DEC HL 2B
Decrement again
6EE7
DEC HL 2B
Decrement again - HL now points to listing control
6EE8
LD A,(5876H) 3A 76 58
Load listing enable/suppress flag from file state
6EEB
Jump to listing output with flag in A
6EEEH - Reserved/Unused Area
Unused memory area, filled with NOPs. May be reserved for future expansion or patch space.
6EF9H - Copyright/Version String (DATA)
Embedded identification string containing version or copyright information.
6EF9
DEFM 'TINE' 54 49 4E 45
Text: "TINE" (part of "ROUTINE" or similar)
6EFD
DEFB 82H 82
Data byte (possibly string terminator with high bit)
6EFE
DEFB 2DH 2D
ASCII '-' character
6EFF
DEFB 0EH 0E
Control byte
6F01
RET C9
Return instruction (may be entry point marker)
6F02H - Store Result and Return to DOS
This short routine stores a value to the DOS filename buffer area (4478H) and jumps to the file close/return routine at 588AH. This appears to be an exit point that saves state before returning control.
6F02
LD (4478H),A 32 78 44
Store Register A into DOS filename buffer area (4478H)
6F05
JUMP to file close/return routine at 588AH
6F08H - Assembly Entry Point (Object File Mode)
Entry point for assembly with object file output. Saves registers via 6F34H, initializes source input via 7293H, prompts for symbol table overflow confirmation via 6F4EH, then jumps to main assembly routine at 5F47H.
6F08
GOSUB to 6F34H to save registers and set up IX for return
6F0B
GOSUB to 7293H to initialize source input
6F0E
GOSUB to 6F4EH to check symbol table overflow and prompt user
6F11
JUMP to main assembly routine at 5F47H
6F14H - Assembly Entry Point (Listing Mode)
Entry point for assembly with listing output. Similar setup to 6F08H but sets A=01H before calling 6F72H to enable listing mode, then jumps to alternate assembly entry at 5F1FH.
6F14
GOSUB to 6F34H to save registers and set up IX for return
6F17
GOSUB to 7293H to initialize source input
6F1A
LD A,01H 3E 01
Load Register A with 01H (listing mode flag)
6F1C
GOSUB to 6F72H to set listing mode
6F1F
JUMP to alternate assembly entry at 5F1FH
6F22H - Source Line End Check
Checks if current character indicates end of source input. If Z flag is set on entry, jumps to 6F27H. Otherwise compares A against 2FH (slash character) and returns with result in flags. This is used to detect end-of-file or special line markers.
6F22
If Z FLAG (end condition) set, JUMP to 6F27H to handle end of source
6F24
CP 2FH FE 2F
Compare Register A against 2FH (ASCII '/') to check for command separator
6F26
RET C9
Return with comparison result in flags
6F27H - End of Source Handler
Handles end of source input. Pops return address (discarding it), saves registers, initializes source, reads next line, then jumps to working variable initialization at 6427H to continue assembly.
6F27
POP AF F1
Discard return address from stack
6F28
GOSUB to 6F34H to save registers and set up IX
6F2B
GOSUB to 7293H to initialize source input
6F2E
GOSUB to 7239H to read next source line
6F31
JUMP to 6427H to initialize working variables and continue assembly
6F34H - Save Registers and Setup Return Context
Saves all main registers (HL, DE, BC, IX) onto the stack and sets IX to point to the return handler at 72A2H. This establishes a clean return context for assembly operations. On entry, the return address is on stack; on exit, IX points to 72A2H and all registers are preserved on stack.
6F34
EX (SP),HL E3
Exchange HL with top of stack (HL now has return address, return address location has old HL)
6F35
PUSH DE D5
Save Register Pair DE onto the stack
6F36
PUSH BC C5
Save Register Pair BC onto the stack
6F37
PUSH IX DD E5
Save Index Register IX onto the stack
6F39
PUSH HL E5
Save HL (which contains original return address) onto the stack
6F3A
LD IX,72A2H DD 21 A2 72
Load Index Register IX with 72A2H (return handler address)
6F3E
RET C9
Return to original caller (via address pushed at 6F39H)
6F3FH - Restore Registers and Return
Restores all registers saved by 6F34H and returns. Stores A temporarily at 75F5H, restores IX, BC, DE, HL from stack, then retrieves A and returns. The Z flag state is preserved based on the stored A value.
6F3F
LD (75F5H),A 32 F5 75
Store Register A temporarily at 75F5H (temp storage in data area)
6F42
POP AF F1
Restore AF from stack (discard, used for stack alignment)
6F43
POP IX DD E1
Restore Index Register IX from the stack
6F45
POP BC C1
Restore Register Pair BC from the stack
6F46
POP DE D1
Restore Register Pair DE from the stack
6F47
POP HL E1
Restore Register Pair HL from the stack
6F48
PUSH AF F5
Save AF temporarily to preserve stack position
6F49
XOR A AF
Clear Register A and all flags
6F4A
LD A,(75F5H) 3A F5 75
Reload Register A from temp storage (sets Z flag if A=0)
6F4D
RET C9
Return to caller with registers restored
6F4EH - Symbol Table Overflow Check and User Prompt
Compares the current symbol table pointer (5315H) against a limit stored at 588BH. If they differ, prompts user with a message at 7520H asking whether to continue. Accepts Y to continue, N to reset the symbol table pointer to the limit value. Any other response re-prompts.
6F4E
LD HL,(5315H) 2A 15 53
Load HL with symbol table current pointer from 5315H
6F51
LD DE,(588BH) ED 5B 8B 58
Load DE with symbol table limit from 588BH
6F55
GOSUB to 5DC2H to compare HL with DE
6F58
If Z FLAG (pointers equal), JUMP to 6F71H - no overflow, continue
6F5A
Load HL with address of overflow prompt message at 7520H
6F5D
LD BC,72A2H 01 A2 72
Load BC with FCB/buffer address 72A2H
6F60
GOSUB to 7266H to display message and get user input character
6F63
CP 59H FE 59
Compare Register A against 59H (ASCII 'Y')
6F65
If Z FLAG (user pressed Y), JUMP to 6F71H to continue
6F67
CP 4EH FE 4E
Compare Register A against 4EH (ASCII 'N')
6F69
If NZ FLAG (not Y or N), LOOP BACK to 6F5AH to re-prompt user
6F6B
LD HL,(588BH) 2A 8B 58
Load HL with symbol table limit from 588BH
6F6E
LD (5315H),HL 22 15 53
Store HL to symbol table pointer at 5315H (reset to limit)
6F71
XOR A AF
Clear Register A and all flags
6F72H - Initialize Listing Mode and Parse Source Line
Stores the listing mode flag to 75F1H, then parses the source line from the input buffer (53A8H). Scans for spaces, handles the 'D=' directive for disk file specification. Copies characters to the output buffer at 72A2H. If the first character after a label is 'D' followed by '=', processes the disk file specification.
6F72
LD (75F1H),A 32 F1 75
Store Register A to listing mode flag at 75F1H
6F75
LD HL,(53A8H) 2A A8 53
Load HL with input buffer pointer from 53A8H
6F78
LD A,(53AAH) 3A AA 53
Load Register A with remaining character count from 53AAH
6F7B
LD B,A 47
Copy character count to Register B for loop counter
6F7C
LD A,(HL) 7E
Load Register A with current character from input buffer
6F7D
CP 20H FE 20
Compare Register A against 20H (ASCII space)
6F7F
If NZ FLAG (not a space), JUMP to 6F86H to process non-space
6F81
INC HL 23
Advance HL to next character in input buffer
6F82
DECrement B and LOOP BACK to 6F7CH if not zero (skip leading spaces)
6F84
JUMP to 6FA6H - line is all spaces, handle as empty
6F86
LD (HL),20H 36 20
Store space (20H) at current position (replace first non-space with space)
6F88
INC HL 23
Advance HL to next character
6F89
LD C,A 4F
Save the first non-space character to Register C
6F8A
DEC B 05
Decrement remaining character count
6F8B
If Z FLAG (no more characters), JUMP to 6FA6H
6F8D
LD A,(HL) 7E
Load Register A with next character
6F8E
CP 3DH FE 3D
Compare Register A against 3DH (ASCII '=')
6F90
If NZ FLAG (not '='), JUMP to 6FA6H - not a D= directive
6F92
LD (HL),20H 36 20
Store space at '=' position (replace with space)
6F94
INC HL 23
Advance HL past the '='
6F95
DEC B 05
Decrement remaining character count
6F96
If Z FLAG (no more characters), JUMP to 6FA6H
6F98
LD A,C 79
Load Register A with saved first character from Register C
6F99
CP 44H FE 44
Compare Register A against 44H (ASCII 'D')
6F9B
If Z FLAG (first char was 'D'), JUMP to 6FACH to process D= directive
6F9D
JUMP to 6FA6H - not D= directive
6F9FH - Copy Character from Source to Destination
Copies a single character from (HL) to (DE), increments both pointers, and checks if the character is a space (20H). Returns with NZ if not a space, Z if space. This is a helper routine for copying filename characters.
6F9F
LD A,(HL) 7E
Load Register A with character from source (HL)
6FA0
INC HL 23
Advance source pointer HL
6FA1
LD (DE),A 12
Store character to destination (DE)
6FA2
INC DE 13
Advance destination pointer DE
6FA3
CP 20H FE 20
Compare Register A against 20H (ASCII space)
6FA5
RET NZ C0
Return if NZ FLAG (not a space) - character was copied
6FA6H - Clear Flags and Return to Line Parser
Clears the 53BAH flag via 728CH, then jumps to 5D24H to continue line parsing. This is the common exit point when source line parsing is complete or when an empty/invalid line is encountered.
6FA6
GOSUB to 728CH to clear the 53BAH flag
6FA9
JUMP to 5D24H to continue line parsing
6FACH - Process D= Disk File Specification
Parses a disk file specification following a D= directive. Copies up to 6 alphanumeric characters for the filename to the buffer at 72A2H, validating that each character is 0-9 or A-Z. If fewer than 6 valid characters, adjusts the count. Then copies up to 15 more characters for extension/path, terminating with CR (0DH).
6FAC
LD DE,72A2H 11 A2 72
Load DE with destination buffer address 72A2H
6FAF
LD C,06H 0E 06
Load Register C with 06H (max 6 characters for filename)
6FB1
GOSUB to 6F9FH to copy character from (HL) to (DE)
6FB4
CP 30H FE 30
Compare Register A against 30H (ASCII '0')
6FB6
If CARRY (char less than '0'), JUMP to 6FCDH - invalid character
6FB8
CP 3AH FE 3A
Compare Register A against 3AH (one past '9')
6FBA
If CARRY (char is '0'-'9'), JUMP to 6FC4H - valid digit
6FBC
CP 41H FE 41
Compare Register A against 41H (ASCII 'A')
6FBE
If CARRY (char less than 'A'), JUMP to 6FCDH - invalid character
6FC0
CP 5BH FE 5B
Compare Register A against 5BH (one past 'Z')
6FC2
If NO CARRY (char greater than 'Z'), JUMP to 6FCDH - invalid
6FC4
DECrement B and JUMP to 6FC8H if not zero (more input chars)
6FC6
JUMP to 6FDDH - input exhausted, terminate with CR
6FC8
DEC C 0D
Decrement filename character counter C
6FC9
If NZ (more filename chars allowed), LOOP BACK to 6FB1H
6FCB
JUMP to 6FCFH - 6 chars copied, continue with extension
6FCD
DEC HL 2B
Back up source pointer (invalid char not consumed)
6FCE
DEC DE 1B
Back up destination pointer (undo copy of invalid char)
6FCF
LD A,(53AAH) 3A AA 53
Load Register A with original character count from 53AAH
6FD2
SUB B 90
Subtract remaining count B to get chars consumed
6FD3
LD (53AAH),A 32 AA 53
Store adjusted character count back to 53AAH
6FD6
LD C,0FH 0E 0F
Load Register C with 0FH (max 15 more chars for extension/path)
6FD8
GOSUB to 6F9FH to copy character from (HL) to (DE)
6FDB
DECrement B and JUMP to 6FE2H if not zero (more input)
6FDD
LD A,0DH 3E 0D
Load Register A with 0DH (carriage return)
6FDF
LD (DE),A 12
Store CR to destination buffer to terminate filename
6FE0
JUMP to 6FF0H to set up file buffers
6FE2
DEC C 0D
Decrement extension character counter C
6FE3
If NZ (more extension chars allowed), LOOP BACK to 6FD8H
6FE5
JUMP to 6FA6H - max chars reached, exit
6FE7H - Confirm File Overwrite
Called when a file already exists. Displays a prompt via 7266H and waits for user response. If user presses 'Y' (59H), jumps to 703AH to proceed with overwrite. Otherwise returns to 6FA6H to abort.
6FE7
GOSUB to 7266H to display message and get user input
6FEA
CP 59H FE 59
Compare Register A against 59H (ASCII 'Y')
6FEC
If Z FLAG (user pressed Y), JUMP to 703AH to confirm overwrite
6FEE
JUMP to 6FA6H to abort operation
6FF0H - Initialize File Buffers for Disk Output
Sets up the file buffers for disk output. Initializes the buffer pointers at 761CH and 761EH to point to 72D4H. If listing mode (75F1H) is non-zero, adjusts the end buffer pointer by adding 200H and attempts to open the file. Handles file exists (error 18H) by prompting user, other errors jump to error handler at 725BH.
6FF0
LD DE,72A2H 11 A2 72
Load DE with filename buffer address 72A2H
6FF3
Load HL with data buffer start address 72D4H
6FF6
LD (761CH),HL 22 1C 76
Store HL to current buffer pointer at 761CH
6FF9
LD (761EH),HL 22 1E 76
Store HL to buffer end pointer at 761EH
6FFC
LD B,00H 06 00
Load Register B with 00H (file mode flags)
6FFE
LD A,(75F1H) 3A F1 75
Load Register A with listing mode flag from 75F1H
7001
OR A B7
Test if listing mode is zero
7002
If Z FLAG (no listing mode), JUMP to 7034H for simple open
7004
INC H 24
Increment H to add 100H to buffer address
7005
INC H 24
Increment H again (total +200H for larger buffer)
7006
LD (761EH),HL 22 1E 76
Store adjusted buffer end pointer to 761EH
7009
Reload HL with buffer start 72D4H
700C
GOSUB to DOS SVC 4424H to open file for write
700F
Load HL with address of prompt message at 7590H
7012
LD BC,72D4H 01 D4 72
Load BC with buffer address 72D4H
7015
If Z FLAG (file exists), JUMP to 6FE7H to prompt for overwrite
7017
CP 18H FE 18
Compare error code A against 18H (file already exists)
7019
If NZ (different error), JUMP to 725BH for error handling
701C
Load HL with address of "overwrite?" prompt at 7555H
701F
GOSUB to 7266H to display message and get user input
7022
CP 43H FE 43
Compare Register A against 43H (ASCII 'C' for Create)
7024
If NZ (not 'C'), JUMP to 6FA6H to abort
7027
LD DE,72A2H 11 A2 72
Load DE with filename buffer address 72A2H
702A
Load HL with data buffer address 72D4H
702D
LD B,00H 06 00
Load Register B with 00H (create new file mode)
702F
GOSUB to DOS SVC 4420H to create new file
7032
JUMP to 7037H to check result
7034
GOSUB to DOS SVC 4424H to open file
7037
If NZ (error), JUMP to 725BH for error handling
703A
Load HL with address of disk file active flag at 75F0H
703D
LD (HL),01H 36 01
Store 01H to flag (disk file now active)
703F
JUMP to 6F3FH to restore registers and return
7042H - Check Disk File Active for Output
Checks if disk file output is active (75F0H). If not active (zero), jumps to 592FH to use standard output. If active, pops AF and returns to caller, allowing disk output to proceed.
7042
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
7045
OR A B7
Test if disk file is active
7046
If Z FLAG (not active), JUMP to 592FH for standard output
7049
POP AF F1
Pop AF from stack (discard return address)
704A
RET C9
Return to caller's caller
704BH - Set Output Column Width
Saves character in C and sets B=07H for column width. If disk file is active (75F0H non-zero), clears C to 00H before returning. This adjusts output formatting based on whether output goes to screen or disk.
704B
LD C,A 4F
Save Register A to Register C
704C
LD B,07H 06 07
Load Register B with 07H (column width constant)
704E
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
7051
OR A B7
Test if disk file is active
7052
RET Z C8
Return if Z FLAG (not active) - keep C as is
7053
LD C,00H 0E 00
Clear Register C to 00H (disk output mode)
7055
RET C9
Return with C=00H
7056H - Send Escape Character to Display
Outputs an escape character (1BH) to the display via ROM routine 0033H, then jumps to 5E74H for further processing. This is used for terminal control sequences.
7056
LD A,1BH 3E 1B
Load Register A with 1BH (ESC character)
7058
GOSUB to ROM 0033H to output character in A to display
705B
JUMP to 5E74H for further processing
705EH - Convert Lowercase to Uppercase
Converts lowercase letter in Register A to uppercase. If A is less than 'a' (61H), returns unchanged. Subtracts 20H to convert to uppercase, then checks if result is less than '[' (5BH). If still lowercase after conversion check, jumps to error handler at 5836H.
705E
CP 61H FE 61
Compare Register A against 61H (ASCII 'a')
7060
RET C D8
Return if CARRY (A less than 'a') - not lowercase
7061
SUB 20H D6 20
Subtract 20H from A to convert lowercase to uppercase
7063
CP 5BH FE 5B
Compare Register A against 5BH (one past 'Z')
7065
RET C D8
Return if CARRY (A is 'A'-'Z') - valid uppercase
7066
JUMP to 5836H for error handling (invalid character)
7069H - Write Cassette Leader (If Not Disk Mode)
Checks if disk file mode is active. If so, returns immediately. Otherwise, calls 7081H for initialization, disables interrupts, and jumps to ROM routine 0296H to write cassette leader tone.
7069
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
706C
OR A B7
Test if disk file is active
706D
RET NZ C0
Return if NZ (disk mode active) - skip cassette output
706E
GOSUB to 7081H for cassette initialization
7071
DI F3
Disable interrupts for cassette timing
7072
JUMP to ROM 0296H to write cassette leader
7075H - Read Cassette Byte (If Not Disk Mode)
Checks if disk file mode is active. If so, returns immediately. Otherwise, calls 7081H for initialization, disables interrupts, and jumps to ROM routine 0287H to read a byte from cassette.
7075
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
7078
OR A B7
Test if disk file is active
7079
RET NZ C0
Return if NZ (disk mode active) - skip cassette input
707A
GOSUB to 7081H for cassette initialization
707D
DI F3
Disable interrupts for cassette timing
707E
JUMP to ROM 0287H to read byte from cassette
7081H - Cassette Motor Control Jump
Jumps to cassette motor control routine at 3042H. This is a relay jump for cassette operations.
7081
JUMP to 3042H for cassette motor control
7084H - Toggle Video Cursor
Toggles bit 1 and bit 3 of the cursor character stored at 3C3FH by XORing with 0AH. This creates a blinking cursor effect by alternating the cursor character appearance.
7084
LD A,(3C3FH) 3A 3F 3C
Load Register A with current cursor character from video RAM 3C3FH
7087
XOR 0AH EE 0A
XOR with 0AH to toggle bits 1 and 3 (cursor blink pattern)
7089
LD (3C3FH),A 32 3F 3C
Store toggled cursor character back to video RAM
708DH - Calculate and Display Symbol Table Size
Calculates the size of the symbol table by subtracting the base pointer (5315H) from the current pointer (53C3H). Converts the result to a displayable format via 6182H and outputs a message at 75DAH via 617FH. Returns the file status from 5882H in Register A.
708D
LD HL,(53C3H) 2A C3 53
Load HL with symbol table current pointer from 53C3H
7090
LD DE,(5315H) ED 5B 15 53
Load DE with symbol table base pointer from 5315H
7094
OR A B7
Clear carry flag for subtraction
7095
SBC HL,DE ED 52
Subtract DE from HL to get symbol table size in bytes
7097
LD DE,5D75H 11 75 5D
Load DE with number conversion buffer address 5D75H
709A
GOSUB to 6182H to convert HL to decimal ASCII at (DE)
709D
Load HL with address of symbol table size message at 75DAH
70A0
GOSUB to 617FH to display message
70A3
LD A,(5882H) 3A 82 58
Load Register A with file status from 5882H
70A6
RET C9
Return with status in A
70A7H - Store HL and Read FDC Status
Stores HL to 5321H, then reads the FDC status register at 37ECH and masks bit 7 (not ready). Returns with result in A.
70A7
LD (5321H),HL 22 21 53
Store HL to address pointer at 5321H
70AA
LD A,(37ECH) 3A EC 37
Load Register A with FDC status register from 37ECH
70AD
AND 80H E6 80
Mask bit 7 (FDC not ready flag)
70AF
RET C9
Return with bit 7 status in A
70B0H - Write to FDC Drive Select Latch
Writes the value in Register A to the FDC drive select latch at 37E1H. Used to select the active disk drive.
70B0
LD (37E1H),A 32 E1 37
Store Register A to FDC drive select latch at 37E1H
70B4H - Cassette Motor Off with Disk Check
If disk file mode is active, calls 70C4H to turn off cassette motor. Checks if result is D3H; if so returns. Otherwise pops BC and jumps to 5F79H for alternate handling.
70B4
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
70B7
OR A B7
Test if disk file is active
70B8
If Z FLAG (not active), JUMP to 70C4H
70BA
GOSUB to 70C4H to handle motor control
70BD
CP D3H FE D3
Compare Register A against D3H (special return code)
70BF
RET Z C8
Return if Z FLAG (result is D3H)
70C0
POP BC C1
Pop BC from stack (discard return address)
70C1
JUMP to 5F79H for alternate handling
70C4H - Cassette Motor Off Handler
If disk file mode is not active, jumps to ROM routine 0235H to turn cassette motor off. If disk mode is active, saves registers via 6F34H, calls 70D2H to read from disk buffer, and returns.
70C4
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
70C7
OR A B7
Test if disk file is active
70C8
If Z FLAG (not active), JUMP to ROM 0235H to turn cassette motor off
70CB
GOSUB to 6F34H to save registers
70CE
GOSUB to 70D2H to read from disk buffer
70D2H - Read Byte from Disk Buffer
Reads the next byte from the disk input buffer. Compares current buffer pointer (761CH) against buffer end (761EH/761FH). If at end of buffer, reads next sector from disk via 4436H. Returns the byte in A and updates the buffer pointer.
70D2
LD HL,(761CH) 2A 1C 76
Load HL with current buffer pointer from 761CH
70D5
LD A,(761EH) 3A 1E 76
Load Register A with buffer end low byte from 761EH
70D8
CP L BD
Compare buffer end low byte against current pointer low byte
70D9
If NZ (not at end), JUMP to 7102H to read byte
70DB
LD A,(761FH) 3A 1F 76
Load Register A with buffer end high byte from 761FH
70DE
CP H BC
Compare buffer end high byte against current pointer high byte
70DF
If NZ (not at end), JUMP to 7102H to read byte
Buffer is exhausted - need to read next sector from disk
70E1
LD DE,72A2H 11 A2 72
Load DE with FCB address 72A2H
70E4
GOSUB to DOS SVC 4436H to read next sector
70E7
If NZ (error), JUMP to 725BH for error handling
70EA
INC (IX+04H) DD 34 04
Increment file position byte at IX+04H
70ED
GOSUB to DOS SVC 4436H to read another sector
70F0
Load HL with second buffer address 74D4H
70F3
If Z FLAG (success), JUMP to 70F9H
70F5
DEC H 25
Decrement H (adjust buffer address on error)
70F6
DEC (IX+0AH) DD 35 0A
Decrement FCB byte at IX+0AH
70F9
LD (761EH),HL 22 1E 76
Store HL to buffer end pointer at 761EH
70FC
DEC (IX+04H) DD 35 04
Decrement file position byte at IX+04H
70FF
Load HL with buffer start address 72D4H
7102
LD A,(HL) 7E
Load Register A with byte from buffer at (HL)
7103
INC HL 23
Increment buffer pointer
7104
LD (761CH),HL 22 1C 76
Store updated buffer pointer to 761CH
7107
JUMP to 6F3FH to restore registers and return
710AH - Write Byte to Cassette or Disk
Writes a byte to cassette or disk depending on mode. If disk file mode is not active, jumps to ROM routine 0264H for cassette output. If disk mode is active, saves registers via 6F34H, calls 711DH to write to disk buffer, and returns.
710A
PUSH AF F5
Save Register A (byte to write) onto stack
710B
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
710E
OR A B7
Test if disk file is active
710F
If NZ (disk active), JUMP to 7115H for disk output
7111
POP AF F1
Restore Register A (byte to write)
7112
JUMP to ROM 0264H to write byte to cassette
7115
POP AF F1
Restore Register A (byte to write)
7116
GOSUB to 6F34H to save registers
7119
GOSUB to 711DH to write byte to disk buffer
711DH - Write Byte to Disk Buffer with Encoding
Writes a byte to the disk output buffer with special encoding for object file format. The byte in A is saved to B. Checks listing mode (75F1H); if less than 2, writes directly. Otherwise implements a state machine using flags at 75F3H to handle Intel HEX record encoding with escape sequences for special bytes (3CH, 78H).
711D
LD B,A 47
Save byte to write in Register B
711E
LD A,(75F1H) 3A F1 75
Load Register A with listing mode flag from 75F1H
7121
CP 02H FE 02
Compare against 02H (object file mode threshold)
7123
If CARRY (mode less than 2), JUMP to 71A0H for direct write
7126
Load HL with address of encoding state flags at 75F3H
7129
LD A,(75F4H) 3A F4 75
Load Register A with encoding counter from 75F4H
712C
BIT 0,(HL) CB 46
Test bit 0 of state flags (first escape state)
712E
If Z (bit 0 clear), JUMP to 713DH to check other states
7130
DEC A 3D
Decrement encoding counter
7131
LD (75F4H),A 32 F4 75
Store updated counter to 75F4H
7134
If NZ (counter not zero), JUMP to 713AH
7136
RES 0,(HL) CB 86
Clear bit 0 of state flags
7138
SET 1,(HL) CB CE
Set bit 1 of state flags (advance to next state)
713A
JUMP to 6F3FH to restore registers and return
713D
BIT 7,(HL) CB 7E
Test bit 7 of state flags (data output state)
713F
If Z (bit 7 clear), JUMP to 714FH to check other states
7141
DEC A 3D
Decrement encoding counter
7142
If NZ (counter not zero), JUMP to 7149H
7144
RES 7,(HL) CB BE
Clear bit 7 of state flags
7146
SET 0,(HL) CB C6
Set bit 0 of state flags
7148
INC A 3C
Increment A back to 1
7149
LD (75F4H),A 32 F4 75
Store updated counter to 75F4H
714C
JUMP to 71A0H to write byte to buffer
714F
BIT 6,(HL) CB 76
Test bit 6 of state flags
7151
If Z (bit 6 clear), JUMP to 715AH
7153
DEC A 3D
Decrement encoding counter
7154
If NZ (counter not zero), JUMP to 7149H
7156
RES 6,(HL) CB B6
Clear bit 6 of state flags
715A
BIT 1,(HL) CB 4E
Test bit 1 of state flags (looking for escape sequence)
715C
If Z (bit 1 clear), JUMP to 7182H
715E
LD A,B 78
Load Register A with original byte from B
715F
CP 3CH FE 3C
Compare against 3CH (ASCII less-than, escape start)
7161
If NZ (not 3CH), JUMP to 716CH
7163
RES 1,(HL) CB 8E
Clear bit 1 of state flags
7165
SET 2,(HL) CB D6
Set bit 2 of state flags (escape detected)
7167
LD B,01H 06 01
Load B with 01H (single byte marker)
7169
JUMP to 71A0H to write marker byte
716C
CP 78H FE 78
Compare against 78H (ASCII 'x', alternate escape)
716E
If NZ (not 78H), JUMP to 7197H for error
7170
LD A,02H 3E 02
Load Register A with 02H (two-byte sequence)
7173
LD (75F4H),A 32 F4 75
Store counter to 75F4H
7176
RES 1,(HL) CB 8E
Clear bit 1 of state flags
7178
SET 6,(HL) CB F6
Set bit 6 of state flags
717A
GOSUB to 71A9H to write byte and check buffer
717D
LD B,02H 06 02
Load B with 02H
717F
JUMP to 71A0H to write second byte
7182
BIT 2,(HL) CB 56
Test bit 2 of state flags (in escape sequence)
7184
If Z (bit 2 clear), JUMP to 7197H for error
7186
LD A,B 78
Load Register A with original byte from B
7187
ADD 02H C6 02
Add 02H to byte (decode escape)
7189
LD B,A 47
Copy result back to B
718A
If Z (result is zero), JUMP to 7191H
718C
CP 03H FE 03
Compare result against 03H
718E
If CARRY (result less than 3), JUMP to 7197H for error
7191
RES 2,(HL) CB 96
Clear bit 2 of state flags
7193
SET 7,(HL) CB FE
Set bit 7 of state flags (data output mode)
7195
JUMP to 7149H to store counter and continue
7197
GOSUB to 728CH to clear flag
719A
Load HL with address of error message at 7511H
719D
JUMP to 592BH to display error and abort
71A0H - Write Byte B to Disk Buffer
Writes the byte in Register B to the disk buffer via 71A9H, then calls 70AAH to check FDC status, and returns via 6F3FH.
71A0
GOSUB to 71A9H to write byte to buffer and check if full
71A3
GOSUB to 70AAH to read FDC status
71A6
JUMP to 6F3FH to restore registers and return
71A9H - Store Byte to Buffer and Flush if Full
Stores the byte in Register B to the current buffer position (761CH), increments the pointer, and checks if buffer is full by comparing against 761EH. If buffer is full, writes buffer to disk via 4439H and resets pointer to 72D4H.
71A9
LD HL,(761CH) 2A 1C 76
Load HL with current buffer pointer from 761CH
71AC
LD (HL),B 70
Store byte B to buffer at (HL)
71AD
INC HL 23
Increment buffer pointer
71AE
LD (761CH),HL 22 1C 76
Store updated buffer pointer to 761CH
71B1
LD DE,(761EH) ED 5B 1E 76
Load DE with buffer end pointer from 761EH
71B5
OR A B7
Clear carry flag for comparison
71B6
SBC HL,DE ED 52
Subtract buffer end from current pointer
71B8
RET NZ C0
Return if NZ (buffer not full)
Buffer is full - write to disk
71B9
LD DE,72A2H 11 A2 72
Load DE with FCB address 72A2H
71BC
GOSUB to DOS SVC 4439H to write buffer to disk
71BF
If NZ (error), JUMP to 725BH for error handling
71C2
INC (IX+04H) DD 34 04
Increment file position at IX+04H
71C5
GOSUB to DOS SVC 4439H to write next buffer
71C8
If NZ (error), JUMP to 725BH for error handling
71CB
DEC (IX+04H) DD 35 04
Decrement file position back at IX+04H
71CE
Load HL with buffer start address 72D4H
71D1
JUMP to 71AEH to store reset pointer
71D3H - Check Keyboard and Close File
Enables interrupts, checks if disk file mode is active. If not active, jumps to 5708H for keyboard check. If disk mode is active, saves registers via 6F34H and calls 71E2H to close the file properly.
71D3
EI FB
Enable interrupts
71D4
LD A,(75F0H) 3A F0 75
Load Register A with disk file active flag from 75F0H
71D7
OR A B7
Test if disk file is active
71D8
If Z FLAG (not active), JUMP to 5708H for keyboard check
71DB
GOSUB to 6F34H to save registers
71DE
GOSUB to 71E2H to close disk file
71E2H - Close Disk Output File
Closes the disk output file. Checks error flag (75F2H) and listing mode (75F1H). If no errors and listing mode active, flushes remaining buffer to disk via 4439H, then closes file via 443FH and waits for completion. Finally clears the disk file active flags and returns.
71E2
LD A,(75F2H) 3A F2 75
Load Register A with error flag from 75F2H
71E5
OR A B7
Test if error flag is set
71E6
If NZ (error occurred), JUMP to 722FH to clear flags and exit
71E8
LD A,(75F1H) 3A F1 75
Load Register A with listing mode flag from 75F1H
71EB
OR A B7
Test if listing mode is active
71EC
If Z FLAG (no listing mode), JUMP to 722FH to clear flags
71EE
LD DE,72A2H 11 A2 72
Load DE with FCB address 72A2H
71F1
LD HL,(761CH) 2A 1C 76
Load HL with current buffer pointer from 761CH
71F4
LD BC,72D4H 01 D4 72
Load BC with buffer start address 72D4H
71F7
OR A B7
Clear carry flag
71F8
SBC HL,BC ED 42
Subtract buffer start from current pointer (get bytes in buffer)
71FA
If Z (buffer empty), JUMP to 7215H to close file
71FC
DEC H 25
Decrement H to check if more than 256 bytes
71FD
If NZ (more than 256 bytes), JUMP to 720CH
7200
INC L 2C
Increment L back (test if L was zero)
7201
If Z (exactly 256 bytes), JUMP to 720CH
7203
GOSUB to DOS SVC 4439H to write first sector
7206
If NZ (error), JUMP to 725BH for error handling
7209
INC (IX+04H) DD 34 04
Increment file position at IX+04H
720C
LD (IX+00H),L DD 75 00
Store L to FCB at IX+00H (partial sector byte count)
720F
GOSUB to DOS SVC 4439H to write final sector
7212
If NZ (error), JUMP to 725BH for error handling
7215
GOSUB to DOS SVC 443FH to close file
7218
If NZ (error), JUMP to 725BH for error handling
721B
GOSUB to DOS SVC 4436H to wait for disk operation
721E
If Z FLAG (still busy), LOOP BACK to 721BH
7220
CP 1CH FE 1C
Compare error code against 1CH (position before start)
7222
If Z (expected EOF error), JUMP to 7229H
7224
CP 1DH FE 1D
Compare error code against 1DH (position past EOF)
7226
If NZ (unexpected error), JUMP to 725BH for error handling
7229
GOSUB to DOS SVC 4428H to finalize close
722C
If NZ (error), JUMP to 725BH for error handling
722F
XOR A AF
Clear Register A
7230
LD (75F0H),A 32 F0 75
Clear disk file active flag at 75F0H
7233
LD (75F2H),A 32 F2 75
Clear error flag at 75F2H
7236
JUMP to 6F3FH to restore registers and return
7239H - Initialize Source File Input
Sets up for reading source from disk file. Sets listing mode to 02H, checks if assembly is in progress (587AH). If not in progress, displays prompt at 74FFH, initializes encoding state, and sets up file buffers via 6FF0H.
7239
LD A,02H 3E 02
Load Register A with 02H (source file input mode)
723B
LD (75F1H),A 32 F1 75
Store mode flag to 75F1H
723E
LD A,(587AH) 3A 7A 58
Load Register A with assembly in progress flag from 587AH
7241
OR A B7
Test if assembly is in progress
7242
If NZ (in progress), JUMP to 6F3FH to return immediately
7245
Load HL with address of source file prompt at 74FFH
7248
LD BC,72A2H 01 A2 72
Load BC with FCB address 72A2H
724B
GOSUB to 7266H to display prompt and get user input
724E
LD A,07H 3E 07
Load Register A with 07H (encoding state counter)
7250
LD (75F4H),A 32 F4 75
Store encoding counter to 75F4H
7253
LD A,01H 3E 01
Load Register A with 01H (initial encoding state)
7255
LD (75F3H),A 32 F3 75
Store encoding state to 75F3H
7258
JUMP to 6FF0H to set up file buffers
725BH - Disk Error Handler
Handles disk errors. Stores error code to 75F2H, ORs with C0H to create DOS error code, calls 4409H to display error, then jumps to 58DAH for cleanup.
725B
LD (75F2H),A 32 F2 75
Store error code to error flag at 75F2H
725E
OR C0H F6 C0
OR with C0H to create DOS error format
7260
GOSUB to DOS SVC 4409H to display error message
7263
JUMP to 58DAH for error cleanup
7266H - Display Message and Get Single Character Input
Displays a message by calling 592FH, then gets single character input via 5B47H. Preserves the original character count at 53AAH. Returns with the input character in Register A.
7266
PUSH BC C5
Save BC onto stack
7267
GOSUB to 592FH to display message at (HL)
726A
POP HL E1
Pop BC value into HL
726B
PUSH HL E5
Push it back for later use
726C
LD A,(53AAH) 3A AA 53
Load Register A with character count from 53AAH
726F
PUSH AF F5
Save character count onto stack
7270
LD C,01H 0E 01
Load C with 01H (single character input mode)
7272
GOSUB to 5B47H to get single character input
7275
POP AF F1
Restore original character count to A
7276
LD (53AAH),A 32 AA 53
Restore character count to 53AAH
7279
LD (HL),00H 36 00
Store 00H at (HL) to terminate input
727B
POP HL E1
Restore original HL value
727C
LD A,(HL) 7E
Load Register A with input character from (HL)
727D
RET C9
Return with character in A
727EH - Conditional Assembly Pass Check
Returns immediately if Z flag is set. Otherwise saves A in B, loads the assembly pass number from 53C0H, and compares against 02H. If pass 2, jumps to 6B39H. Otherwise restores A from B and jumps to 6B30H. This routes processing based on which assembly pass is active.
727E
RET Z C8
Return immediately if Z FLAG is set
727F
LD B,A 47
Copy Register A to Register B (save original value)
7280
LD A,(53C0H) 3A C0 53
Load Register A with assembly pass number from 53C0H (01H=pass 1, 02H=pass 2)
7283
CP 02H FE 02
Compare Register A against 02H (pass 2)
7285
If Z FLAG (pass 2), JUMP to 6B39H for pass 2 processing
7288
LD A,B 78
Restore Register A from Register B
7289
JUMP to 6B30H for pass 1 processing
728CH - Clear Assembly Flag 53BAH
Clears the assembly flag at 53BAH while preserving the value in Register A. This flag controls various assembly state conditions.
728C
PUSH AF F5
Save Register A and flags onto stack
728D
XOR A AF
Clear Register A to zero
728E
LD (53BAH),A 32 BA 53
Store zero to assembly flag at 53BAH
7291
POP AF F1
Restore Register A and flags from stack
7293H - Initialize Source Input (One-Time)
Initializes source input, but only once per assembly session. Checks flag at 75F6H; if already initialized (non-zero), returns immediately. Otherwise sets the flag, points HL to the startup message at 74D4H, and displays it via 592FH.
7293
LD A,(75F6H) 3A F6 75
Load Register A with initialization flag from 75F6H
7296
OR A B7
Test if already initialized
7297
RET NZ C0
Return if NZ (already initialized)
7298
INC A 3C
Increment A to 01H
7299
LD (75F6H),A 32 F6 75
Store 01H to initialization flag at 75F6H (mark as initialized)
729C
Load HL with address of startup message at 74D4H
729F
JUMP to 592FH to display message and return
74D4H - Message Strings Data Area
This section contains ASCII message strings used by EDTASM. Messages are delimited by A0H (high-bit set space) or 0DH (carriage return). Some messages contain embedded control codes (03H).
74D4-74FEH
DEFM 0DH,"APPARAT ASSEMBLER APPENDAGE, VERSION 3.0",0DH,A0H 0D 41 50 50 41 52 41 54 20 41 53 53 45 4D 42 4C 45 52 20 41 50 50 45 4E 44 41 47 45 2C 20 56 45 52 53 49 4F 4E 20 33 2E 30 0D A0
74FF-750FH
DEFM "OBJECT FILESPEC? " 4F 42 4A 45 43 54 20 46 49 4C 45 53 50 45 43 3F 20 A0
7511-751FH
DEFM "INTERNAL ERROR" 49 4E 54 45 52 4E 41 4C 20 45 52 52 4F 52 A0
7520-7553H
DEFM "TEXT IN BUFFER. ARE YOU CONCATENATING???? (Y OR N) " 54 45 58 54 20 49 4E 20 42 55 46 46 45 52 2E 20 41 52 45 20 59 4F 55 20 43 4F 4E 43 41 54 45 4E 41 54 49 4E 47 3F 3F 3F 3F 20 20 28 59 20 4F 52 20 4E 29 20 A0
7555-758EH
DEFM "************** FILE NON-EXISTENT. REPLY ",22H,"C",22H," TO CREATE IT " 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 20 46 49 4C 45 20 4E 4F 4E 2D 45 58 49 53 54 45 4E 54 2E 20 52 45 50 4C 59 20 22 43 22 20 54 4F 20 43 52 45 41 54 45 20 49 54 20 A0
7590-75BAH
DEFM "FILE ALREADY EXISTS. USE IT???? (Y OR N) " 46 49 4C 45 20 41 4C 52 45 41 44 59 20 45 58 49 53 54 53 2E 20 55 53 45 20 49 54 3F 3F 3F 3F 20 20 28 59 20 4F 52 20 4E 29 20 A0
75BC-75D9H
DEFM "MULTIPLY DEFINED AT ",03H,"UNDEF***",03H 4D 55 4C 54 49 50 4C 59 20 44 45 46 49 4E 45 44 20 41 54 20 03 55 4E 44 45 46 2A 2A 2A 03
75DA-75EFH
DEFM " TEXT AREA BYTES LEFT" 20 54 45 58 54 20 41 52 45 41 20 42 59 54 45 53 20 4C 45 46 54 A0
75F0H - Working Variables and Buffers
This section contains working variables used by the disk file I/O routines. These are initialized to zero at load time and are modified during program execution.
75F0
DEFB 00H 00
Disk file active flag (01H=disk output active, 00H=cassette/screen)
75F1
DEFB 00H 00
Listing mode flag (00H=none, 01H=listing, 02H=object file)
75F2
DEFB 00H 00
Disk error flag (stores error code if error occurred)
75F3
DEFB 00H 00
Object file encoding state flags (bits 0-7 control encode state machine)
75F4
DEFB 00H 00
Object file encoding byte counter
75F5
DEFB 00H 00
Reserved/unused
75F6
DEFB 00H 00
Source input initialization flag (01H=already initialized)
75F7-7617H
DEFS 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Reserved/unused (33 bytes)
7618H - FCB Template and Disk Buffers
This section contains an FCB template initialized with default values, followed by buffer pointers and the main disk I/O buffers.
7618-761AH
DEFB 01H,00H,01H 01 00 01
FCB template: drive 1, position 0, file type 1
761B
DEFB FFH FF
FCB template: end marker or default value
761C-761DH
DEFW 0000H 00 00
Current disk buffer pointer (2 bytes)
761E-761FH
DEFW 0000H 00 00
Disk buffer end pointer (2 bytes)
7620-76A1H
DEFS 130 00...
Reserved buffer area (130 bytes)
72A2H - File Control Block (FCB)
The FCB at 72A2H is used for disk file operations. This 50-byte area holds the filename, file attributes, and current file position. Referenced throughout the disk I/O code.
72A2-72D3H
DEFS 50 00...
File Control Block - filename and file state (50 bytes)
72D4H - Primary Disk I/O Buffer
The primary 256-byte disk buffer starting at 72D4H. Used for reading and writing disk sectors. A second 256-byte buffer at 73D4H may be used for double-buffering, and a third at 74D4H overlaps with the message area (which is read-only after loading).
72D4-73D3H
DEFS 256 00...
Primary disk buffer (256 bytes = 1 sector)
73D4-74D3H
DEFS 256 00...
Secondary disk buffer (256 bytes = 1 sector)
76A2H - Extended Buffer Area
Additional buffer space from 76A2H to 76FFH (94 bytes). This may be used as overflow for the FCB or as temporary workspace.
76A2-76FFH
DEFS 94 00...
Extended buffer/workspace area (94 bytes to end of program space)