We need to process a FULL SCREEN debug screen.
4F17
LD A,1CH
LET Register A = 1CH (ASCII: Clear Screen).
Original Source Code Comment: HOME CURSOR
4F19
GOSUB to 0033H.
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
Original Source Code Comment: OUT TO THE DISPLAY
4F1C
LD HL,3C00H
LET Register Pair HL = 3C00H (i.e., the first screen location).
Original Source Code Comment: TOP OF THE SCREEN
4F1F
LD (4020H),HLLD (CURSOR),HL
Set the cursor position by storing the value held in Register HL into the memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: SET THE CURSOR POSITION
4F22
GOSUB to 4F80H to display the memory.
Original Source Code Comment: DISPLAY THE MEMORY
4F25
GOSUB to 5273H to display a carriage return.
Original Source Code Comment: OUTPUT A CR
4F28
LD HL,(4020H)LD HL,(CURSOR)
Fetch the value stored at memory location 4020H (i.e., the cursor location on screen) and put it into Register HL.
Original Source Code Comment: GET THE PRESENT CURSOR LOCATION
4F2B
LD (4F61H),HLLD (CURSAV),HL
Store the value held in Register HL (i.e., the cursor location on screen) into the memory location 4F61H.
Original Source Code Comment: AND SAVE IT FOR LATER
4F2E
LD BC,00C0H
LET Register Pair BC = 00C0H (Decimal: 192) as an offset to HL to move the cursor down 3 lines.
Original Source Code Comment: MOVE THE CURSOR DOWN 3 LINES
4F31
ADD HL,BC
ADD the value held in Register Pair BC (the 3 line offset) to Register Pair HL (the current screen position). The results are held in Register Pair HL.
Original Source Code Comment: HL = NEW CURSOR POSITION
4F32
LD (4020H),HLLD (CURSOR),HL
Store the value held in Register HL into the memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: SET IT
4F35
LD HL,4FA2HLD HL,DISPL7
LET Register Pair HL = 4FA2H so as to point to the message storage area for "SP PC AF ..".
Original Source Code Comment: HL => 'SP PC AF ETC' MSG
4F38
GOSUB to 021BH to display that message.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
4F3B
GOSUB to 5273H to display a carriage return.
Original Source Code Comment: AND A CR
4F3E
LD HL,4108HLD HL,MEM+8
LET Register Pair HL = 4108H to point to the bottom of the REGISTER SAVE area.
4F41
PUSH HL
Save Register HL (i.e., the pointer to the REGISTER SAVE area) to the top of the STACK. In a few instructions we will have a EXchange command to swap this value.
4F42
LD HL,4FA2HLD HL,DISPL7
LET Register Pair HL = 4FA2H (i.e., the storage location for the message " AF BC DE HL AF").
4F45
LD B,0CH
LET Register B = 0CH (Decimal: 12) since there are 12 register pairs.
Original Source Code Comment: SET FOR 12 REGISTER PAIRS
4F47DISPL1
EX (SP),HL
EXchange the value stored in Register Pair HL (i.e., the storage location for the message " AF BC DE HL AF") with the value stored at the top of the STACK (i.e., the pointer to the REGISTER SAVE area).
4F48
LD E,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the LSB of one of the registers) and put it into Register E.
4F49
INC HL
Bump the value stored in Register Pair HL by 1.
4F4A
LD D,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL (i.e., the LSB of one of the registers) and put it into Register D. Now Register Pair DE contains the value of saved register.
4F4B
INC HL
Bump the value stored in Register Pair HL by 1 to point to the LSB of the next register pair in the REGISTER SAVE area.
4F4C
PUSH HL
Save Register HL (i.e., the pointer to the next register pair in the REGISTER SAVE area) to the top of the STACK.
4F4D
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the pointer to the next register pair in the REGISTER SAVE area) with the value stored in Register Pair DE (i.e., the value of a saved register pair from the REGISTER SAVE area).
4F4E
LD A,H
LET Register A = Register H so that we can display the MSB of the value held for that Register Pair.
4F4F
JUMP to 5258H to convert that MSB to ASCII and display
4F52
LD A,L
LET Register A = Register H so that we can display the LSB of the value held for that Register Pair.
4F53
GOSUB to 526CH to display a byte held in Register A (i.e., that LSB) as a two byte ascii value followed by a space.
4F56
LD A,B
LET Register A = Register B (i.e., the counter for the 12 register pairs to dump).
4F57
AND 0BH
MASK the value of Register A against 0BH (0000 1011). This has the effect of turning off bits 7, 6, 5, 4, 2, leaving only bits 3, 1, 0 active.
The effect of masking the counter by 0BH is as follows
4F59
CP 08H
Compare the value held in Register A against 08H. Results:
- If Register A equals 08H, the Z FLAG is set.
- If A < 08H, the CARRY FLAG will be set.
- if A >= 08H, the NO CARRY FLAG will be set.
4F5B
POP HL
Restore Register Pair HL (i.e., the pointer to the next register pair in the REGISTER SAVE area) the from the top of the STACK.
4F5C
EX (SP),HL
EXchange the value stored in Register Pair HL (i.e., the pointer to the next register pair in the REGISTER SAVE area) with the value stored at the top of the STACK (i.e., the storage location for the message " AF BC DE HL AF").
4F5D
LOOP back to 4F47H until Register B is ZERO.
4F5F
POP HL
Clear the STACK.
4F60
LD HL,[CURSAV]
LET Register Pair HL = a value placed by other locations in this overlay into "CURSAV".
Original Source Code Comment: CURSOR SAVED HERE
4F63
LD BC,0040HLD BC,KEYN
LET Register Pair BC = 0040H (Decimal: 64) for an offset of one screen line.
Original Source Code Comment: BUMP DOWN ONE LINE
4F66
ADD HL,BC
ADD the value held in Register Pair BC (i.e., one screen line offset) to Register Pair HL (i.e., the saved cursor location). The results are held in Register Pair HL.
Original Source Code Comment: HL = NEW CURSOR
4F67
LD (4020H),HLLD (CURSOR),HL
Store the value held in Register HL (i.e., the advanced by one line cursor location) into the memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: SET IT
4F6A
LD HL,4FD7HLD HL,PC
LET Register Pair HL = 4FD7H, which points to the message PC.
Original Source Code Comment: HL => 'PC' MSG
4F6D
GOSUB to 021BH to display that message.
NOTE: 021BH will display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
4F70
GOSUB to 526FH to display a space.
Original Source Code Comment: AND A SPACE
4F73
LD HL,(411EH)LD HL,(MEM+30)
Fetch the value stored at memory location 411EH (i.e., the Program Counter for the running program MINUS 1) and put it into Register HL.
Original Source Code Comment: HL => USERS PC AREA
4F76
LD B,10H
LET Register B = 10H (Decimal: 16) to set up for a loop of 16.
Original Source Code Comment: SET FOR 16 BYTES
4F78
LD A,(HL)
Fetch the value stored at memory location pointed to by Register Pair HL and put it into Register A.
Original Source Code Comment: GET A BYTE
4F79
GOSUB to 526CH to print a byte held in Register A as a two byte ascii value followed by a space.
Original Source Code Comment: OUTPUT IT AS TWO BYTE ASCII AND SPACE
4F7C
INC HL
Bump Register Pair HL to point to the next byte.
Original Source Code Comment: BUMP TO NEXT BYTE
4F7D
LOOP back to 4F78H until Register B is ZERO.
Original Source Code Comment: LOOP FOR COUNT
4F7F
RET
RETurn to the caller.
Original Source Code Comment: DONE WITH DISPLAY