6000H - Program Entry / Relocator
The program entry point. This code relocates the main program from 6000H to 4300H to place it in low memory, allowing the diagnostic to test higher memory addresses without overwriting itself. After relocation, execution jumps to the relocated code at 4300H.
6000
LD HL,600EH 21 0E 60
Point HL to the source address 600EH (start of actual program code after this relocator)
6003
LD DE,4300H 11 00 43
Point DE to the destination address 4300H where code will be relocated
6006
LD BC,075CH 01 5C 07
Load BC with 1884 bytes to copy (the entire program length)
6009
LDIR ED B0
Block copy: move 1884 bytes from 600EH to 4300H
600B
JUMP to the relocated code at 4300H to begin execution
600EH - Main Initialization (Relocated to 4300H)
System initialization routine. Disables interrupts, clears interrupt latches, sets up the stack, initializes system variables, and calls the main test sequence. After all tests complete, the system reboots via JP 0000H.
600E
DI F3
Disable interrupts to prevent any interference during memory testing
600F
IN A,(ECH) DB EC
Read the current system control register (port ECH) to clear any pending states
6011
XOR A AF
Set A = 00H to clear all interrupt enables
6012
OUT (E0H),A D3 E0
Clear the interrupt latch register (port E0H) - disable all maskable interrupts
6014
OUT (E4H),A D3 E4
Clear the NMI mask register (port E4H) - disable NMI sources
6016
LD SP,4300H 31 00 43
Set stack pointer to 4300H (just below the relocated program)
601A
LD (4A5BH),A 32 5B 4A
Clear the test pass flag at 4A5BH (00H = first pass)
601D
LD A,28H 3E 28
Load A with 28H (system control value: video enabled, 64-column mode)
601F
OUT (ECH),A D3 EC
Write to system control port ECH to enable video display
6021
GOSUB to 4328H (relocated from 6136H) to display program title and intro screen
6024
GOSUB to 4638H (relocated from 6346H) to perform RAM size detection
6027
GOSUB to 4561H (relocated from 626FH) to initialize FDC and run video RAM tests
602A
LD HL,47A3H 21 A3 47
Point HL to message at 47A3H (relocated string address)
602D
GOSUB to ROM routine at 021BH to display the completion message
6030
GOSUB to ROM routine at 0049H to wait for a keypress
6033
JUMP to 0000H to perform a warm reboot of the system
6036H - ROM Checksum Test: Part 1 (0000H-1FFFH)
Calculates and displays the checksum for the first ROM section (0000H-1FFFH, 8K bytes). The expected checksum for a valid Model III ROM is displayed for comparison. Entry: None. Exit: Checksum displayed on screen.
6036
LD DE,0000H 11 00 00
Set DE = 0000H as the starting address for ROM Part 1
6039
LD A,1FH 3E 1F
Load A with 1FH (high byte of ending address 1FFFH)
603B
LD (4412H),A 32 12 44
Store the end page marker 1FH at 4412H for the checksum routine
603E
GOSUB to 4408H (relocated from 6116H) to calculate checksum from DE to page in (4412H)
6041
PUSH HL E5
Save the calculated checksum (in HL) onto the stack
6042
LD HL,47CCH 21 CC 47
Point HL to "ROM 1" label message
6045
GOSUB to 43C3H (relocated from 60D1H) to display the string
6048
LD HL,4800H 21 00 48
Point HL to expected checksum message for ROM Part 1
604B
GOSUB to display the expected checksum value string
604E
POP HL E1
Restore the calculated checksum from the stack into HL
604F
LD E,H 5C
Copy high byte of checksum to E for display
6050
GOSUB to 43A6H (relocated from 60B4H) to display E as two hex digits
6053
LD E,L 5D
Copy low byte of checksum to E for display
6054
GOSUB to display E as two hex digits (completing the 4-digit checksum)
6057
GOSUB to 43D4H (relocated from 60DFH) to output a carriage return
605AH - ROM Checksum Test: Part 2 (2000H-2FFFH)
Calculates and displays the checksum for the second ROM section (2000H-2FFFH, 4K bytes).
605A
LD DE,2000H 11 00 20
Set DE = 2000H as the starting address for ROM Part 2
605D
LD A,0FH 3E 0F
Load A with 0FH (will compare against high byte: 2FH means 2000H-2FFFH range)
605F
LD (4412H),A 32 12 44
Store the end page marker 0FH at 4412H (interpreted as 2FH in context)
6062
GOSUB to calculate checksum from 2000H to 2FFFH
6065
PUSH HL E5
Save the calculated checksum onto the stack
6066
LD HL,4819H 21 19 48
Point HL to "ROM 2" label message
6069
GOSUB to display the string
606C
LD HL,488FH 21 8F 48
Point HL to expected checksum message for ROM Part 2
606F
GOSUB to display the expected checksum value string
6072
POP HL E1
Restore the calculated checksum from the stack into HL
6073
LD E,H 5C
Copy high byte of checksum to E for display
6074
GOSUB to display E as two hex digits
6077
LD E,L 5D
Copy low byte of checksum to E for display
6078
GOSUB to display E as two hex digits
607B
GOSUB to output a carriage return
607EH - ROM Checksum Test: Part 3 (3000H-37E8H)
Calculates and displays the checksum for the third ROM section (3000H-37E8H). This section is smaller and ends before the keyboard/video memory-mapped I/O area.
607E
LD DE,3000H 11 00 30
Set DE = 3000H as the starting address for ROM Part 3
6081
LD A,07H 3E 07
Load A with 07H (high nibble of 37xxH range)
6083
LD (4412H),A 32 12 44
Store the end page marker 07H at 4412H
6086
GOSUB to calculate checksum from 3000H to 37xxH
6089
PUSH HL E5
Save the calculated checksum onto the stack
608A
LD HL,484CH 21 4C 48
Point HL to "ROM 3" label message
608D
GOSUB to display the string
6090
LD HL,48A8H 21 A8 48
Point HL to expected checksum message for ROM Part 3
6093
GOSUB to display the expected checksum value string
6096
POP HL E1
Restore the calculated checksum from the stack into HL
6097
LD A,(37E8H) 3A E8 37
Load A with the byte at 37E8H (last byte of ROM Part 3)
609A
LD C,A 4F
Copy this byte to C for adjustment
609B
XOR B A8
XOR with B (adjustment factor from checksum calculation)
609C
OR A B7
Clear carry flag for SBC operation
609D
SBC HL,BC ED 42
Subtract BC from checksum to adjust for ROM end boundary
609F
OR A B7
Clear carry flag again
60A0
SBC HL,BC ED 42
Subtract BC again (double adjustment for boundary)
60A2
LD E,H 5C
Copy adjusted high byte of checksum to E for display
60A3
GOSUB to display E as two hex digits
60A6
LD E,L 5D
Copy adjusted low byte of checksum to E for display
60A7
GOSUB to display E as two hex digits
60AA
GOSUB to output carriage return (alternate entry point)
60AD
LD HL,4984H 21 84 49
Point HL to ROM checksum completion message
60B0
GOSUB to display the completion message
60B3
RET C9
Return to caller
60B4H - Display Byte as Two Hex Digits
Displays the byte in Register E as two hexadecimal ASCII characters. Entry: E = byte to display. Exit: Two hex characters output to screen.
60B4
PUSH DE D5
Save DE onto the stack
60B5
PUSH AF F5
Save AF onto the stack
60B6
LD A,E 7B
Copy the byte to display from E into A
60B7
RLCA 07
Rotate A left (shift high nibble toward low nibble)
60B8
RLCA 07
Rotate A left again
60B9
RLCA 07
Rotate A left again
60BA
RLCA 07
Rotate A left again - high nibble is now in low nibble position
60BB
GOSUB to 43B7H (relocated from 60C5H) to convert and display high nibble
60BE
LD A,E 7B
Reload the original byte from E into A
60BF
GOSUB to convert and display low nibble
60C2
POP AF F1
Restore AF from the stack
60C3
POP DE D1
Restore DE from the stack
60C4
RET C9
Return to caller
60C5H - Convert Nibble to Hex ASCII and Display
Converts the low nibble of Register A to a hexadecimal ASCII character and displays it. Uses the DAA trick for hex conversion. Entry: A = value (low nibble used). Exit: Hex character displayed.
60C5
AND 0FH E6 0F
Mask off the high nibble, keeping only bits 0-3
60C7
ADD 90H C6 90
Add 90H - this sets up the DAA trick for hex conversion
60C9
DAA 27
Decimal Adjust: if nibble was 0-9, result is 90H-99H; if A-F, result is 00H-05H + carry
60CA
ADC 40H CE 40
Add 40H plus carry: converts to ASCII '0'-'9' or 'A'-'F'
60CC
DAA 27
Final decimal adjust completes the conversion
60CD
GOSUB to 43D6H (relocated from 60E4H) to display the character in A
60D0
RET C9
Return to caller
60D1H - Display String Until ETX
Displays a null-terminated string (terminated by 03H/ETX) starting at the address in HL. Entry: HL = pointer to string. Exit: String displayed, HL points past terminator.
60D1
PUSH AF F5
Save AF onto the stack
60D2
LD A,(HL) 7E
[LOOP START] - Fetch the next character from the string
60D3
CP 03H FE 03
Compare against 03H (ETX - End of Text marker)
60D5
If Z FLAG set (character = ETX), JUMP to 60DDH to exit the loop
60D7
GOSUB to display the character in A
60DA
INC HL 23
Advance HL to the next character in the string
60DB
LOOP BACK to 60D2H to process the next character
60DD
POP AF F1
Restore AF from the stack
60DE
RET C9
Return to caller
60DFH - Output Carriage Return with Tab Handling
Outputs a carriage return character (0DH) and handles cursor position tracking. Also provides a general character output entry point at 60E4H.
60DF
Recursive call - this appears to be a fall-through setup
60E2
LD A,0DH 3E 0D
Load A with 0DH (Carriage Return character)
60E4
PUSH DE D5
Save DE onto the stack
60E5
PUSH IY FD E5
Save IY onto the stack
60E7
PUSH AF F5
Save AF (character to output) onto the stack
60E8
CP 09H FE 09
Compare character against 09H (TAB character)
60EA
If Z FLAG set (character = TAB), JUMP to 6103H for TAB handling
60EC
GOSUB to ROM routine at 0033H to output the character in A
60EF
LD IY,4A4CH FD 21 4C 4A
Point IY to cursor column counter at 4A4CH
60F3
INC (IY+00H) FD 34 00
INCrement the cursor column counter
60F6
CP 0DH FE 0D
Compare output character against 0DH (Carriage Return)
60F8
If NZ FLAG set (not CR), JUMP to 60FEH to skip column reset
60FA
LD (IY+00H),00H FD 36 00 00
Reset cursor column counter to 0 (start of new line)
60FE
POP AF F1
Restore AF from the stack
60FF
POP IY FD E1
Restore IY from the stack
6101
POP DE D1
Restore DE from the stack
6102
RET C9
Return to caller
6103H - TAB Character Handler
Handles TAB character output by emitting spaces to align to the next 8-column boundary.
6103
PUSH BC C5
Save BC onto the stack
6104
LD A,(4A4CH) 3A 4C 4A
Fetch current cursor column position from 4A4CH
6107
CPL 2F
Complement A (invert all bits)
6108
AND 07H E6 07
Mask to get distance to next 8-column boundary (0-7)
610A
INC A 3C
Add 1 to get space count (1-8 spaces needed)
610B
LD B,A 47
Copy space count to B as loop counter
610C
LD A,20H 3E 20
[LOOP START] - Load A with 20H (space character)
610E
GOSUB to output the space character
6111H - TAB Handler Loop End and Checksum Calculation
Continuation of TAB handler and the checksum calculation routine used for ROM verification.
6111
DJNZ 610CH 10 F9
DECrement B and LOOP BACK to 610CH if not zero (output more spaces)
6113
POP BC C1
Restore BC from the stack
6114
JUMP to 60FEH to complete character output cleanup
6116H - Calculate Checksum of Memory Block
This routine calculates a 16-bit checksum of a memory block. Entry: DE points to the start of the block. The routine adds all bytes until DE reaches an address where the high nibble of D and all of E are zero (i.e., a 4K boundary). Exit: HL contains the checksum.
6116
LD HL,0000H 21 00 00
Initialize checksum accumulator HL to zero
6119
LD B,L 45
Set B to zero (L is 00H) to use BC for 16-bit addition
611A
LD A,(DE) 1A
[LOOP START] Fetch byte from memory pointed to by DE
611B
LD C,A 4F
Put the byte value into C (B is already 0, so BC = byte value)
611C
ADD HL,BC 09
Add the byte value to the running checksum in HL
611D
INC DE 13
Advance DE to point to next byte in memory
611E
LD A,D 7A
Get high byte of current address
611F
AND 0FH E6 0F
Mask to keep only low nibble of D (checks for 4K boundary)
6121
OR E B3
Combine with E - result is zero only when DE is at x000H boundary
6122
If not at 4K boundary, loop back to process next byte
6124
RET C9
Return with checksum in HL
6125H - RAM Test: Find Top of Memory
This routine finds the top of available RAM by starting at 0000H, decrementing through memory, and testing each location by complementing its value. When writable RAM is found, the address is stored in 4A54H. The routine then calculates available memory and performs read/write tests on all RAM.
6125
LD HL,0000H 21 00 00
Initialize HL to 0000H (will wrap to FFFFH on first decrement)
6128
DEC HL 2B
[LOOP START] Decrement HL to test next lower memory address
6129
LD A,(HL) 7E
Read current byte from memory location
612A
CPL 2F
Complement the value (invert all bits) to create test pattern
612B
LD (HL),A 77
Write complemented value back to memory
612C
XOR (HL) AE
XOR with stored value - result is 00H if RAM works correctly
612D
If memory test failed (non-writable), loop to try next lower address
612F
LD (4A54H),HL 22 54 4A
Store top of RAM address in 4A54H
6132
GOSUB to display routine to show the top of RAM value
6135
GOSUB to output carriage return
6138
LD HL,(4A54H) 2A 54 4A
Retrieve top of RAM address from 4A54H
613B
LD BC,4A59H 01 59 4A
Load BC with 4A59H (base address of test variables area)
613E
OR A B7
Clear carry flag for subtraction
613F
SBC HL,BC ED 42
Calculate RAM size: HL = Top of RAM - 4A59H
6141
LD (4A56H),HL 22 56 4A
Store calculated RAM size in 4A56H (bytes to test)
6144
LD A,01H 3E 01
Load A with 01H as initial test pattern
6146
LD E,A 5F
Copy test pattern to E
6147
LD (4A59H),A 32 59 4A
Store initial pattern in 4A59H (pattern storage)
614AH - RAM Pattern Test Loop
This section performs the actual RAM pattern test. It writes a pattern to all RAM locations, reads it back to verify, then increments the pattern and repeats until pattern wraps back to 01H.
614A
LD BC,(4A56H) ED 4B 56 4A
[LOOP START] Load BC with number of bytes to test from 4A56H
614E
LD HL,4A59H 21 59 4A
Point HL to start of test area at 4A59H
6151
LD A,(4A59H) 3A 59 4A
Get current test pattern from 4A59H
6154
LD D,A 57
Copy pattern to D for comparison
6155
LD A,01H 3E 01
Load A with 01H (starting pattern value)
6157
LD E,01H 1E 01
Load E with 01H (wrap-around value)
6159
GOSUB to 447AH to write pattern to RAM block
615C
LD A,(4A59H) 3A 59 4A
Reload current test pattern from 4A59H
615F
LD D,A 57
Copy pattern to D for read-back comparison
6160
LD HL,4A59H 21 59 4A
Point HL back to start of test area
6163
LD A,01H 3E 01
Load A with 01H (starting pattern value)
6165
LD BC,(4A56H) ED 4B 56 4A
Reload byte count from 4A56H
6169
LD E,01H 1E 01
Load E with 01H (wrap-around value)
616B
GOSUB to 4491H to verify RAM contents match pattern
616E
LD A,(4A59H) 3A 59 4A
Get current test pattern
6171
LD E,A 5F
Copy to E for display
6172
GOSUB to 43A6H to display current pattern being tested
6175
LD HL,4A59H 21 59 4A
Point HL to pattern storage
6178
INC (HL) 34
Increment the test pattern
6179
LD A,(HL) 7E
Get the incremented pattern
617A
CP 01H FE 01
Compare against 01H - check if pattern wrapped around (00H+1=01H)
617C
If pattern hasn't wrapped to 01H, loop back to test next pattern
617E
GOSUB to output carriage return
6181
LD HL,4A32H 21 32 4A
Point HL to completion message string at 4A32H
6184
GOSUB to print string routine to display completion message
6187
RET C9
Return from RAM test routine
6188H - Write Pattern to Memory Block
This routine writes an incrementing pattern to a block of memory. Entry: HL=start address, BC=byte count, D=starting pattern value, E=wrap value, A=limit value. The pattern in D is written to each location, then incremented. When D equals A, it wraps back to E.
6188
PUSH AF F5
Save A (limit value) on stack
6189
LD (HL),D 72
[LOOP START] Write current pattern value D to memory at HL
618A
POP AF F1
Restore limit value to A
618B
PUSH AF F5
Save limit value again for next iteration
618C
INC D 14
Increment pattern value in D
618D
CP D BA
Compare limit A against current pattern D
618E
If D hasn't reached limit, skip wrap-around
6190
LD D,E 53
Wrap pattern D back to starting value E
6191
INC HL 23
Advance to next memory location
6192
DEC BC 0B
Decrement byte counter
6193
LD A,B 78
Get high byte of counter
6194
AND FFH E6 FF
Test if B is zero (AND FFH sets flags)
6196
If B not zero, continue loop
6198
LD A,C 79
Get low byte of counter
6199
AND FFH E6 FF
Test if C is zero
619B
If C not zero, continue loop
619D
POP AF F1
Clean up stack - restore saved A
619E
RET C9
Return from write routine
619FH - Verify Pattern in Memory Block
This routine verifies that a memory block contains the expected incrementing pattern. Entry: HL=start address, BC=byte count, D=expected starting pattern, E=wrap value, A=limit value. If a mismatch is found, it calls the error handler at 44ACH.
619F
PUSH AF F5
Save A (limit value) on stack
61A0
LD A,(HL) 7E
[LOOP START] Read byte from memory at HL
61A1
CP D BA
Compare read value against expected pattern D
61A2
If mismatch (NZ), GOSUB to error handler at 44ACH to report failure
61A5
POP AF F1
Restore limit value to A
61A6
PUSH AF F5
Save limit value again for next iteration
61A7
INC D 14
Increment expected pattern value in D
61A8
CP D BA
Compare limit A against current pattern D
61A9
If D hasn't reached limit, skip wrap-around
61AB
LD D,E 53
Wrap pattern D back to starting value E
61AC
INC HL 23
Advance to next memory location
61AD
DEC BC 0B
Decrement byte counter
61AE
LD A,B 78
Get high byte of counter
61AF
AND FFH E6 FF
Test if B is zero
61B1
If B not zero, continue loop
61B3
LD A,C 79
Get low byte of counter
61B4
AND FFH E6 FF
Test if C is zero
61B6
If C not zero, continue loop
61B8
POP AF F1
Clean up stack - restore saved A
61B9
RET C9
Return from verify routine
61BAH - Display Memory Error Information
This routine displays detailed information about a memory error. Entry: HL=failing address, D=expected value, A=actual value read. It displays the address, expected value, and actual value, then waits for keypress. If 'H' is pressed, it halts for further inspection.
61BA
PUSH BC C5
Save BC on stack
61BB
PUSH DE D5
Save DE (expected value in D) on stack
61BC
PUSH AF F5
Save AF (actual value read) on stack
61BD
PUSH HL E5
Save HL (failing address) on stack
61BE
LD A,00H 3E 00
Load A with 00H
61C0
LD (4A58H),A 32 58 4A
Clear error counter/flag at 4A58H
61C3
LD HL,48C1H 21 C1 48
Point HL to "Address: " message string
61C6
GOSUB to print string routine
61C9
POP HL E1
Restore failing address to HL
61CA
PUSH HL E5
Save HL again for later
61CB
LD E,H 5C
Copy high byte of address to E
61CC
GOSUB to display E as two hex digits
61CF
LD E,L 5D
Copy low byte of address to E
61D0
GOSUB to display E as two hex digits
61D3
LD HL,48EEH 21 EE 48
Point HL to " Expected: " message string
61D6
GOSUB to print string routine
61D9
LD E,D 5A
Copy expected value from D to E
61DA
GOSUB to display E as two hex digits
61DD
LD HL,48FAH 21 FA 48
Point HL to " Got: " message string
61E0
GOSUB to print string routine
61E3
POP HL E1
Restore failing address to HL
61E4
POP AF F1
Restore actual value read to A
61E5
PUSH AF F5
Save actual value again
61E6
PUSH HL E5
Save failing address again
61E7
LD E,A 5F
Copy actual value to E for display
61E8
GOSUB to display E as two hex digits
61EB
PUSH AF F5
Save A on stack
61EC
GOSUB to output carriage return
61EF
POP AF F1
Restore A from stack
61F0
GOSUB to 450EH for additional error processing
61F3
GOSUB to ROM keyboard scan routine
61F6
OR A B7
Test if a key was pressed (A=0 means no key)
61F7
If no key pressed, jump to restore and return
61F9
CP 48H FE 48
Compare keypress against 'H' (48H = ASCII 'H')
61FB
If not 'H', jump to restore and return
61FD
GOSUB to ROM wait for keypress routine (halt until key pressed)
6200
GOSUB to output carriage return
6203
POP HL E1
Restore HL from stack
6204
POP AF F1
Restore AF from stack
6205
POP DE D1
Restore DE from stack
6206
POP BC C1
Restore BC from stack
6207
RET C9
Return from error display routine
6208H - Display Top of RAM
This routine displays the top of RAM value stored at 4A54H.
6208
LD HL,48D2H 21 D2 48
Point HL to message string at 48D2H
620B
GOSUB to print string routine
620E
LD HL,(4A54H) 2A 54 4A
Load HL with top of RAM address from 4A54H
6211
LD E,H 5C
Copy high byte of address to E
6212
GOSUB to display E as two hex digits
6215
LD E,L 5D
Copy low byte of address to E
6216
GOSUB to display E as two hex digits
6219
Jump to output carriage return and return
621CH - Analyze Memory Address Region
This routine analyzes an address in HL to determine which memory region it belongs to (ROM, Video RAM, or regular RAM) and displays the appropriate region indicator with bit analysis.
621C
PUSH BC C5
Save BC on stack
621D
PUSH AF F5
Save AF on stack
621E
PUSH DE D5
Save DE on stack
621F
PUSH HL E5
Save HL (address to analyze) on stack
6220
BIT 7,H CB 7C
Test bit 7 of H - check if address >= 8000H
6222
If bit 7 clear (address < 8000H), jump to handle low memory
6224
BIT 6,H CB 74
Test bit 6 of H - check if address >= C000H
6226
If bit 6 clear (8000H-BFFFH range), jump to handle mid memory
6228
LD HL,4918H 21 18 49
Point HL to "High RAM" message (C000H-FFFFH region)
622B
LD E,43H 1E 43
Load E with 43H (display column position)
622D
Jump to common display routine
622F
LD HL,4930H 21 30 49
Point HL to "Low Memory/ROM" message (0000H-7FFFH region)
6232
LD E,07H 1E 07
Load E with 07H (display column position)
6234
Jump to common display routine
6236
LD HL,4900H 21 00 49
Point HL to "Mid RAM" message (8000H-BFFFH region)
6239
LD E,25H 1E 25
Load E with 25H (display column position)
623B
GOSUB to print string routine
623E
XOR D AA
XOR A with D to create bit pattern for analysis
623F
LD D,A 57
Store result back in D
6240
LD B,08H 06 08
Set B to 8 for 8 bits to process
6242
RL D CB 12
[LOOP START] Rotate D left through carry - get next bit
6244
If carry set (bit was 1), GOSUB to 4541H to mark bit
6247
INC E 1C
Increment display column position
6248
Decrement B and loop if not zero - process all 8 bits
624A
POP HL E1
Restore HL from stack
624B
POP DE D1
Restore DE from stack
624C
POP AF F1
Restore AF from stack
624D
POP BC C1
Restore BC from stack
624E
RET C9
Return from analyze routine
624FH - Display Address with Bit Indicator
This routine displays a space, 'U', and then the address value with bit adjustment for display positioning.
624F
PUSH AF F5
Save AF on stack
6250
LD A,20H 3E 20
Load A with 20H (ASCII space)
6252
GOSUB to output character
6255
LD A,55H 3E 55
Load A with 55H (ASCII 'U')
6257
GOSUB to output character 'U'
625A
BIT 3,E CB 5B
Test bit 3 of E
625C
If bit 3 clear, jump to display without adjustment
625E
BIT 2,E CB 53
Test bit 2 of E
6260
If bit 2 set, jump to add 6 to E
6262
BIT 1,E CB 4B
Test bit 1 of E
6264
If bit 1 clear, jump to display without adjustment
6267
ADD 06H C6 06
Add 6 to A for column adjustment
6269
LD E,A 5F
Store adjusted value back in E
626A
POP AF F1
Restore AF from stack
626B
GOSUB to display E as two hex digits
626FH - Initialize Hardware
This routine calls hardware initialization routines at 4568H and 45C4H.
626F
GOSUB to 4568H for hardware initialization
6272
GOSUB to 45C4H for additional initialization
6276H - System Reset and Video RAM Test Setup
This routine resets the interrupt system, sets up the system speed, and prepares for video RAM testing with incrementing patterns from 21H to 7EH.
6276
IN A,(ECH) DB EC
Read from port ECH (system status/configuration)
6278
XOR A AF
Clear A to zero
6279
OUT (E0H),A D3 E0
Write 00H to port E0H (reset interrupt latch)
627B
OUT (E4H),A D3 E4
Write 00H to port E4H (disable interrupt mask)
627D
LD A,28H 3E 28
Load A with 28H (system speed setting)
627F
LD (4210H),A 32 10 42
Store speed value at 4210H
6282
OUT (ECH),A D3 EC
Write 28H to port ECH (set system speed)
6284
LD A,21H 3E 21
Load A with 21H (starting pattern - ASCII '!')
6286
LD E,A 5F
Copy starting pattern to E
6287
LD (4A59H),A 32 59 4A
Store starting pattern at 4A59H
628AH - Video RAM Test Loop (Printable Characters)
This loop tests video RAM (3C00H-3FFFH, 1024 bytes) using printable ASCII characters from 21H to 7EH. It writes patterns, reads them back, and verifies correctness.
628A
LD BC,0400H 01 00 04
[LOOP START] Load BC with 0400H (1024 bytes - video RAM size)
628D
LD HL,3C00H 21 00 3C
Point HL to start of video RAM at 3C00H
6290
LD A,03H 3E 03
Load A with 03H (ETX character for cursor home)
6292
GOSUB to output character (home cursor)
6295
LD A,(4A59H) 3A 59 4A
Get current test pattern from 4A59H
6298
LD D,A 57
Copy pattern to D
6299
LD A,7FH 3E 7F
Load A with 7FH (limit value - one past '~')
629B
GOSUB to 447AH to write pattern to video RAM block
629E
LD A,FFH 3E FF
Load A with FFH
62A0
LD (4A58H),A 32 58 4A
Store FFH at 4A58H (error flag - FFH = no error)
62A3
LD A,(4A59H) 3A 59 4A
Reload current test pattern
62A6
LD D,A 57
Copy pattern to D for verification
62A7
LD HL,3C00H 21 00 3C
Point HL back to start of video RAM
62AA
LD BC,0400H 01 00 04
Reload byte count (1024 bytes)
62AD
LD E,21H 1E 21
Load E with 21H (wrap-around value)
62AF
LD A,7FH 3E 7F
Load A with 7FH (limit value)
62B1
GOSUB to 4491H to verify video RAM contents
62B4
LD A,(4A58H) 3A 58 4A
Get error flag from 4A58H
62B7
CP FFH FE FF
Compare against FFH (no error value)
62B9
If error occurred (not FFH), jump to error handler at 462DH
62BC
LD HL,4A59H 21 59 4A
Point HL to pattern storage
62BF
INC (HL) 34
Increment test pattern
62C0
LD A,(HL) 7E
Get incremented pattern
62C1
CP 7FH FE 7F
Compare against 7FH (limit - past printable range)
62C3
If not at limit, loop back to test next pattern
62C5
GOSUB to 46BCH for display update
62C8
LD HL,49BFH 21 BF 49
Point HL to completion message at 49BFH
62CB
GOSUB to print string routine
62CE
GOSUB to output carriage return
62D1
RET C9
Return from video RAM test
62D2H - Video RAM Test (Full Byte Range)
This routine tests video RAM using the full byte range from 81H to FEH (extended characters). Similar structure to the printable character test.
62D2
LD A,81H 3E 81
Load A with 81H (starting pattern - graphics characters)
62D4
LD E,A 5F
Copy starting pattern to E
62D5
LD (4A59H),A 32 59 4A
Store starting pattern at 4A59H
62D8H - Video RAM Test Loop (Graphics Characters)
This loop tests video RAM using graphics character range 81H to FEH.
62D8
LD BC,0400H 01 00 04
[LOOP START] Load BC with 0400H (1024 bytes)
62DB
LD HL,3C00H 21 00 3C
Point HL to start of video RAM
62DE
LD A,03H 3E 03
Load A with 03H (cursor home)
62E0
GOSUB to output character
62E3
LD A,(4A59H) 3A 59 4A
Get current test pattern
62E6
LD D,A 57
Copy pattern to D
62E7
LD A,FFH 3E FF
Load A with FFH (limit value)
62E9
GOSUB to write pattern to video RAM
62EC
LD A,FFH 3E FF
Load A with FFH
62EE
LD (4A58H),A 32 58 4A
Store FFH at 4A58H (no error flag)
62F1
LD A,(4A59H) 3A 59 4A
Reload current test pattern
62F4
LD D,A 57
Copy pattern to D
62F5
LD HL,3C00H 21 00 3C
Point HL to start of video RAM
62F8
LD BC,0400H 01 00 04
Reload byte count
62FB
LD E,81H 1E 81
Load E with 81H (wrap-around value)
62FD
LD A,FFH 3E FF
Load A with FFH (limit value)
62FF
GOSUB to verify video RAM contents
6302
LD A,(4A58H) 3A 58 4A
Get error flag
6305
CP FFH FE FF
Compare against FFH (no error)
6307
If error occurred, jump to error handler at 633BH
6309
LD HL,4A59H 21 59 4A
Point HL to pattern storage
630C
INC (HL) 34
Increment test pattern
630D
LD A,(HL) 7E
Get incremented pattern
630E
CP FFH FE FF
Compare against FFH (limit)
6310
If not at limit, loop back to test next pattern
6312
GOSUB to 46BCH for display update
6315
LD A,(4A5BH) 3A 5B 4A
Get test mode flag from 4A5BH
6318
OR A B7
Test if zero (initial test mode)
6319
If zero, jump to display initial message
631B
LD HL,49FBH 21 FB 49
Point HL to alternate completion message at 49FBH
631E
Jump to print message
6320
LD HL,49E3H 21 E3 49
Point HL to initial completion message at 49E3H
6323
GOSUB to print string routine
6326
GOSUB to output carriage return
6329
LD A,(4A5BH) 3A 5B 4A
Get test mode flag again
632D
RET NZ C0
If not zero (not initial test), return
632E
LD A,20H 3E 20
Load A with 20H
6330
LD (4210H),A 32 10 42
Store 20H at 4210H (speed setting)
6333
OUT (ECH),A D3 EC
Write 20H to port ECH
6335
LD (4A5BH),A 32 5B 4A
Store 20H at 4A5BH (mark test mode complete)
6338
Jump to 45C4H for continuation
633BH - Video RAM Error Handler
This routine handles video RAM errors by outputting a message to indicate the failure.
633B
LD A,20H 3E 20
Load A with 20H
633D
OUT (ECH),A D3 EC
Write 20H to port ECH
633F
LD HL,496CH 21 6C 49
Point HL to error message at 496CH
6342
GOSUB to print string routine
6345
RET C9
Return from error handler
6346H - Walking Bit RAM Test
This routine performs a walking bit test on RAM. It finds top of RAM, calculates testable size, then writes patterns where a single bit walks through all positions, verifying each write.
6346
LD HL,0000H 21 00 00
Initialize HL to 0000H
6349
DEC HL 2B
[LOOP START] Decrement HL to scan for RAM
634A
LD A,(HL) 7E
Read byte from memory
634B
CPL 2F
Complement the value
634C
LD (HL),A 77
Write complemented value back
634D
XOR (HL) AE
XOR with stored value to verify
634E
If mismatch, loop to try next address
6350
LD (4A54H),HL 22 54 4A
Store top of RAM at 4A54H
6353
GOSUB to display routine
6356
GOSUB to output carriage return
6359
LD HL,(4A54H) 2A 54 4A
Reload top of RAM
635C
LD BC,4A59H 01 59 4A
Load BC with base address 4A59H
635F
OR A B7
Clear carry flag
6360
SBC HL,BC ED 42
Calculate RAM size (top - base)
6362
LD (4A56H),HL 22 56 4A
Store RAM size at 4A56H
6365
XOR A AF
Clear A to zero
6366
LD (4A59H),A 32 59 4A
Initialize pattern storage to 00H
6369H - Walking Bit Pattern Test Loop
This loop performs the walking bit test, rotating a single bit through all 8 positions.
6369
[LOOP START] GOSUB to 4686H to perform pattern write/verify
636C
LD A,(4A59H) 3A 59 4A
Get current pattern
636F
LD E,A 5F
Copy pattern to E for display
6370
GOSUB to display pattern as hex
6373
LD A,(4A59H) 3A 59 4A
Reload current pattern
6376
SCF 37
Set carry flag (for walking bit)
6377
RLA 17
Rotate A left through carry - walk the bit
6378
LD (4A59H),A 32 59 4A
Store new pattern
637B
If carry clear (bit hasn't walked out), loop back
637D
LD A,FFH 3E FF
Load A with FFH (all bits set pattern)
637F
LD (4A59H),A 32 59 4A
Store FFH pattern
6382
GOSUB to test with FFH pattern
6385
LD E,FFH 1E FF
Load E with FFH for display
638A
GOSUB to output carriage return
638D
LD HL,4A19H 21 19 4A
Point HL to message at 4A19H
6390
GOSUB to print string
6393
RET C9
Return from walking bit test
6394H - Fill RAM with Pattern and Verify
This routine fills all testable RAM with the current pattern value, then verifies that each location contains the expected value.
6394
LD BC,(4A56H) ED 4B 56 4A
Load BC with RAM size from 4A56H
6398
LD HL,4A59H 21 59 4A
Point HL to start of test area
639B
INC HL 23
Advance past pattern storage byte
639C
LD A,(4A59H) 3A 59 4A
[LOOP START] Get current pattern
639F
LD (HL),A 77
Write pattern to memory
63A0
DEC BC 0B
Decrement byte counter
63A1
INC HL 23
Advance to next location
63A2
LD A,B 78
Get high byte of counter
63A3
AND FFH E6 FF
Test if B is zero
63A5
If B not zero, continue filling
63A7
LD A,C 79
Get low byte of counter
63A8
AND FFH E6 FF
Test if C is zero
63AA
If C not zero, continue filling
63AC
LD HL,4A59H 21 59 4A
Point HL back to test area
63AF
INC HL 23
Advance past pattern storage
63B0
LD BC,(4A56H) ED 4B 56 4A
Reload RAM size
63B4
LD A,(4A59H) 3A 59 4A
Get expected pattern
63B7
LD D,A 57
Copy expected value to D
63B8
LD A,(HL) 7E
[LOOP START] Read byte from memory
63B9
CP D BA
Compare against expected value
63BA
If mismatch, GOSUB to error handler at 44ACH
63BD
INC HL 23
Advance to next memory location
63BE
DEC BC 0B
Decrement byte counter
63BF
LD A,B 78
Get high byte of counter
63C0
AND FFH E6 FF
Test if B is zero
63C2
If B not zero, continue verifying
63C4
LD A,C 79
Get low byte of counter
63C5
AND FFH E6 FF
Test if C is zero
63C7
If C not zero, continue verifying
63C9
RET C9
Return from fill and verify routine
63CAH - Clear Screen and Set Display Mode
This routine clears the screen and sets the display mode by outputting control characters.
63CA
LD A,1CH 3E 1C
Load A with 1CH (clear screen control code)
63CC
GOSUB to ROM character output routine
63CF
LD A,1FH 3E 1F
Load A with 1FH (cursor home control code)
63D1
GOSUB to ROM character output routine
63D4
LD A,0EH 3E 0E
Load A with 0EH (cursor on control code)
63D6
GOSUB to ROM character output routine
63D9
RET C9
Return from clear screen routine
63DAH - Stack-Based RAM Test
This routine performs a RAM test using the stack pointer. It finds top of RAM, sets the stack pointer there, and performs exhaustive address/data pattern testing to detect addressing faults and data corruption.
63DA
LD HL,0000H 21 00 00
Initialize HL to 0000H
63DD
DEC HL 2B
[LOOP START] Decrement HL to scan for top of RAM
63DE
LD A,(HL) 7E
Read byte from memory
63DF
CPL 2F
Complement the value
63E0
LD (HL),A 77
Write complemented value back
63E1
XOR (HL) AE
XOR with stored value to verify write
63E2
If mismatch, loop to try next address
63E4
LD (4A54H),HL 22 54 4A
Store top of RAM at 4A54H
63E7
GOSUB to output carriage return
63EA
GOSUB to display top of RAM
63ED
LD SP,(4A54H) ED 7B 54 4A
Set stack pointer to top of RAM
63F1
INC SP 33
Increment SP to point above top of RAM
63F2
XOR A AF
Clear A to zero
63F3
LD (4A59H),A 32 59 4A
Initialize XOR pattern at 4A59H to 00H
63F6
LD BC,0000H 01 00 00
Initialize BC counter to 0000H
63F9H - Address Pattern Push Loop
This routine pushes XOR-modified address values onto the stack, creating a pattern where each pushed value depends on its address, allowing detection of address line faults.
63F9
LD A,C 79
[LOOP START] Get low byte of counter
63FA
LD (4A4DH),A 32 4D 4A
Store counter low byte at 4A4DH
63FD
GOSUB to display as hex (E already has value)
6400
LD HL,(4A54H) 2A 54 4A
Get top of RAM
6403
INC HL 23
Increment HL
6404
DEC HL 2B
[INNER LOOP] Decrement HL to process next address
6405
LD A,(4A4DH) 3A 4D 4A
Get XOR pattern
6408
XOR L AD
XOR with low byte of address
6409
XOR H AC
XOR with high byte of address
640A
LD D,A 57
Store result in D (high byte of value to push)
640B
DEC HL 2B
Decrement HL for next byte
640C
LD A,(4A4DH) 3A 4D 4A
Get XOR pattern again
640F
XOR L AD
XOR with low byte of address
6410
XOR H AC
XOR with high byte of address
6411
LD E,A 5F
Store result in E (low byte of value to push)
6412
PUSH DE D5
Push the computed pattern value onto stack
6413
LD A,(4A4FH) 3A 4F 4A
Get boundary check high byte
6416
CP H BC
Compare with current H
6417
If not at boundary, continue inner loop
6419
LD A,(4A4EH) 3A 4E 4A
Get boundary check low byte
641C
CP L BD
Compare with current L
641D
If not at boundary, continue inner loop
641FH - Address Pattern Verify Loop
This routine pops values from the stack and verifies they match the expected XOR-address pattern, detecting any memory corruption or addressing faults that occurred.
641F
LD HL,(4A4EH) 2A 4E 4A
Get boundary address
6422
DEC HL 2B
Decrement for alignment
6423
INC HL 23
[LOOP START] Increment to next address
6424
LD A,(4A4DH) 3A 4D 4A
Get XOR pattern
6427
XOR L AD
XOR with low byte of address
6428
XOR H AC
XOR with high byte of address
6429
LD E,A 5F
Store expected low byte in E
642A
LD (4A50H),A 32 50 4A
Store expected low byte at 4A50H
642D
INC HL 23
Advance to next byte
642E
LD A,(4A4DH) 3A 4D 4A
Get XOR pattern again
6431
XOR H AC
XOR with high byte of address
6432
XOR L AD
XOR with low byte of address
6433
LD D,A 57
Store expected high byte in D
6434
LD (4A51H),A 32 51 4A
Store expected high byte at 4A51H
6437
LD (4A52H),HL 22 52 4A
Store current address at 4A52H
643A
EX DE,HL EB
Exchange DE and HL (HL now has expected value)
643B
LD A,L 7D
Get expected low byte
643D
LD L,A 6F
Store back in L
643E
LD A,H 7C
Get expected high byte
6440
LD H,A 67
Store back in H
6441
INC HL 23
Increment (two's complement negation)
6442
XOR A AF
Clear A and carry
6443
POP DE D1
Pop actual value from stack
6444
ADC HL,DE ED 5A
Add actual to negated expected (should be zero if match)
6446
If not zero, jump to error handler
6448
LD HL,(4A52H) 2A 52 4A
Reload current address
644B
LD A,(4A55H) 3A 55 4A
Get top boundary high byte
644E
CP H BC
Compare with current H
644F
If not at top, continue loop
6451
LD A,(4A54H) 3A 54 4A
Get top boundary low byte
6454
CP L BD
Compare with current L
6455
If not at top, continue loop
6457
LD A,(4A4DH) 3A 4D 4A
Get XOR pattern
645A
CPL 2F
Complement pattern
645B
LD (4A4DH),A 32 4D 4A
Store complemented pattern
645E
LD A,(4A59H) 3A 59 4A
Get test phase flag
6462
LD (4A59H),A 32 59 4A
Store complemented flag
6465
AND A A7
Test if A is zero
6466
If not zero, continue with complement phase
6468
INC BC 03
Increment outer loop counter
6469
Loop back to continue testing
646BH - Stack Test Error Handler
This routine handles errors detected during the stack-based RAM test, displaying the failing address and expected vs actual values.
646B
DEC SP 3B
Adjust stack pointer
646C
DEC SP 3B
Adjust stack pointer again
646D
LD HL,(4A52H) 2A 52 4A
Get failing address
6470
DEC HL 2B
Adjust address
6471
LD A,(4A50H) 3A 50 4A
Get expected low byte
6474
XOR E AB
XOR with actual low byte
6475
LD A,(4A50H) 3A 50 4A
Reload expected low byte
6478
LD A,D 7A
Get actual high byte
6479
LD (4A56H),A 32 56 4A
Store actual high byte at 4A56H
647C
If low byte mismatch, jump to report error
647E
LD SP,(4A52H) ED 7B 52 4A
Set SP to current address
6483
INC HL 23
Advance HL to high byte location
6484
LD A,(4A56H) 3A 56 4A
Get actual high byte
6488
LD A,(4A51H) 3A 51 4A
Get expected high byte
648B
XOR D AA
XOR with actual
648C
If high byte mismatch, jump to report error
648E
LD SP,(4A52H) ED 7B 52 4A
Restore SP to continue
6493
Jump back to continue verification
6495H - Report Low Byte Error
This routine reports a low byte mismatch error during stack testing.
6495
LD SP,45B0H 31 B0 45
Set SP to safe location at 45B0H
6498
LD A,(4A50H) 3A 50 4A
Get expected value
649C
LD A,E 7B
Get actual value
649D
GOSUB to error display routine
64A0
Jump to continue processing
64A2H - Report High Byte Error
This routine reports a high byte mismatch error during stack testing.
64A2
LD SP,45B0H 31 B0 45
Set SP to safe location at 45B0H
64A5
LD A,(4A51H) 3A 51 4A
Get expected high byte
64A9
LD A,(4A56H) 3A 56 4A
Get actual high byte
64AC
GOSUB to error display routine
64AF
Jump to continue processing
64B1H - Message Data Area
This area contains ASCII message strings used by the diagnostic program.
64B1
DEFM "Tests Complete. Hit any key to re-boot" 54 65 73 74 73 20 43 6F 6D 70 6C 65 74 65 64 2E 20 48 69 74 20 61 6E 79 20 6B 65 79 20 74 6F 20 72 65 2D 62 6F 6F 74
ASCII message: "Tests Completed. Hit any key to re-boot"
64D9
DEFB 0DH 0D
Carriage return
64DA
DEFM "ROM A Checksum should be 9633" 52 4F 4D 20 41 20 43 68 65 63 6B 73 75 6D 20 73 68 6F 75 6C 64 20 62 65 20 39 36 33 33
ASCII message: "ROM A Checksum should be 9633"
6727H - Additional Message Data
This area contains more ASCII message strings.
6727
DEFM "Quick Ram Test Complete" 51 75 69 63 6B 20 52 61 6D 20 54 65 73 74 20 43 6F 6D 70 6C 65 74 65
ASCII message: "Quick Ram Test Complete"
673E
DEFB 0DH 0D
Carriage return
673F
DEFB 03H 03
End of text marker (ETX)
6740
DEFB 0DH 0D
Carriage return
6741
DEFB 0DH 0D
Carriage return
6742
DEFM "Complete Test Finished" 43 6F 6D 70 6C 65 74 65 20 54 65 73 74 20 46 69 6E 69 73 68 65 64
ASCII message: "Complete Test Finished"
6758
DEFB 0DH 0D
Carriage return
6759
DEFB 03H 03
End of text marker (ETX)
675A
DEFB 00H 00
Null terminator
675B
DEFM "E O" 45 20 4F
ASCII: "E O"
675E
DEFB 03H 03
End of text marker
675F
DEFB FFH FF
Padding byte FFH
6760
DEFM " O" 20 4F
ASCII: " O"
6762
DEFB FFH FF
Padding byte FFH
6763
DEFB FFH FF
Padding byte FFH
6764
DEFB FFH FF
Padding byte FFH
6765
DEFB FFH FF
Padding byte FFH
6766
DEFB FFH FF
Padding byte FFH
6767
DEFB FFH FF
Padding byte FFH
6768
DEFB FFH FF
Padding byte FFH
6769
DEFB 00H 00
Null terminator
676A
DEFB FFH FF
Padding byte FFH