Since DEBUG is going to need to use all registers for itself, but yet leave them undisturbed for the program being debugged, it is necessary to preserve all registers, so the next bunch of steps do just that.
With all the registers now preserved in the STACK, we next copy the STACK to 4108H and on to save them.
[4108H]
[411CH]
NOTE: 442BH is the storage location for the OVERLAY FLAG flag.
NOTE: 442BH is the storage location for the OVERLAY FLAG flag.
Check to see what the OP CODE was when DEBUG was invoked, and also see if it was from a RST 30H call or not.
[411EH]
[4E35H]
[411EH]
If this was a RST 30H call, we need to see if DEBUG was involked by a breakpoint.
[4100H]
4E3AH - "START1" - Top of loop checking breakpoints
Top of a loop of TWO iterations to check the two possible breakpoint locations for valid data.
4E44
OR D
[4E4EH]
[4E4EH]
4E51H - Command loop
Set up STACK, turn on cursor, display the screen, and process the DEBUG commands.
"START5"
[411CH]
[4023H]
NOTE: 4023H is the storage location for the CURSOR CHARACTER.
[0033H]
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
4E63H - "START6" - Main command processing
"START6"
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[4FF7H]
All the remaining commands do something that requires returning to the DEBUG screen and entering a new command, so we need to specify that when they exit, they come back to this COMMAND LOOP.
[4E51H]
[4EE3H]
[4F0AH]
[4E92H]
[50DBH]
[504DH]
[508AH]
[4EB7H]
4EB2H - X Command - Half Page Display
4EB3H - S Command - Full Page Display
4EB7H - U Command - Continuous Redisplay of Memory
Continuous redisplay of memory until a key is pressed
[002BH]
4EC1H - D Command - Dump Memory
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[5054H]
[5054H]
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[4FE7H]
[021BH]
NOTE: 021BH will display the character at (HL) until a 03H is found.
[521FH]
[5600H]
[4EC7H]
4EE3H - ; Command - Advance display to the next line
[4106H]
[4101H]
[4EF6H]
We need to process a full screen.
[4EF6H]
"OUT4"
[4106H]
[5600H]
[4106H]
4F0AH - - Command - Backspace next line
[4EE6H]
4F0FH - SUBroutine to display the DEBUG screen
[4101H]
[4F93H]
We need to process a FULL SCREEN debug screen.
[0033H]
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[4020H]
[4F61H]
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[4FA2H]
[021BH]
NOTE: 021BH will display the character at (HL) until a 03H is found.
[4108H]
[4FA2H]
[526CH]
The effect of masking the counter by 0BH is as follows
"DISPL5"
- 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.
+1="CURSAV"
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[021BH]
NOTE: 021BH will display the character at (HL) until a 03H is found.
[411EH]
[526CH]
4F80H - SUBroutine to display RAM locations
[4106H]
4F93H - Continuation of the SUBroutine to display the DEBUG screen, jumped if we need a half Page display
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[4106H]
4FA2H - Message Storage Area
"DISPL7"
"FLAGS"
"ADDR"
4FF7H - Routine to process "G" and "J" by JUMPing to a specified address
[4FE7H]
[021BH]
NOTE: 021BH will display the character at (HL) until a 03H is found.
[4105H]
[521FH]
[500AH]
[411EH]
[521FH]
[503CH]
[500AH]
[501BH]
Restore all the registers
[411EH]
[410EH]
503CH - SUBroutine to Save the Breakpoint into a Table (done backwards)
[4E35H]
504DH - Routine to MODIFY AND DISPLAY RAM - the "M" option
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[5054H]
[5054H]
[4FE7H]
[021BH]
NOTE: 021BH will display the character at (HL) until a 03H is found.
[4103H]
[521FH]
[5600H]
[5053H]
[554FH]
[4103H]
[555FH]
We need to set some flags to indicate that this is a MEMORY routine and not a DISK routine.
[5560H]
[545FH]
[5553H]
508AH - Command "R" - Modify the User Registers
[51F1H]
[50A2H]
[4FA3H]
[50B6H]
While there is one INC HL which is definitely used, the following two INC HL's are jump points; this is all to advance HL to the next entry in the REGISTER STORAGE TABLE, which may be 3, 2, or 1 character away.
[50ADH]
[50A7H]
50B6H - Continuation of the "R" Command. Jumped here when we have a first character match between the user requested register and the register storage table
[50ACH]
[50ADH]
If we are here then all 3 of the characters entered by the user for the desired register to modify have been found. With this, we need to do some math to find the location of the matched register pair with the stored value for that register pair. Register B holds the counter where we stopped parsing register pairs.
[4108H]
[0033H]
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
[521FH]
50DBH - "I" and "C" Commands - Instruction Step / Call Step Single Step Routines
[411EH]
[5195H]
[50F6H]
[5160H]
[50F9H]
[518EH]
- If Register A equals (HL), the Z FLAG is set.
- If A < (HL), the CARRY FLAG will be set.
- if A >= (HL), the NO CARRY FLAG will be set.
[5107H]
- If Register A equals 05H, the Z FLAG is set.
- If A < 05H, the CARRY FLAG will be set.
- if A >= 05H, the NO CARRY FLAG will be set.
[50FAH]
[4105H]
[5132H]
- If Register A equals 20H, the Z FLAG is set.
- If A < 20H, the CARRY FLAG will be set.
- if A >= 20H, the NO CARRY FLAG will be set.
[5158H]
[514CH]
- If Register A equals 40H, the Z FLAG is set.
- If A < 40H, the CARRY FLAG will be set.
- if A >= 40H, the NO CARRY FLAG will be set.
- If Register A equals 60H, the Z FLAG is set.
- If A < 60H, the CARRY FLAG will be set.
- if A >= 60H, the NO CARRY FLAG will be set.
5135H - Continuation of the "I"/"C" routine - Set a BREAKPOINT for either RET or JP
If the next opcode was a RET ...
If the next opcode was a JP or CALL.
5140H - Continuation of the "I"/"C" routine - Set a BREAKPOINT for either RET or JP
[5147H]
514CH - Continuation of the "I"/"C" routine - Set a BREAKPOINT for either JP (IX) or JP (IY)
[4118H]
[515BH]
[411AH]
5158H - Continuation of the "I"/"C" routine - Set a BREAKPOINT for either JP (HL)
5160H - OPCODE TABLE - "NORMAL" OPCODES
"TABLE1"
518EH - OPCODE TABLE - "ED" OPCODES
5195H - OPCODE TABLE - "DD" and "FD" OPCODES
51B1H - Display One Line of Memory
"OUTLNE"
[526FH]
- If Register A equals a SPACE, the Z FLAG is set.
- If A < 20H, the CARRY FLAG will be set.
- if A >= 20H, the NO CARRY FLAG will be set.
[51D5H]
- If Register A equals 7BH, the Z FLAG is set.
- If A < 7BH, the CARRY FLAG will be set.
- if A >= 7BH, the NO CARRY FLAG will be set.
[51D7H]
[CALL DSP]
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
[51EFH]
[0033H]
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
51F1H - SUBROUTINE to get a character from the keyboard and process accordingly
[5217H]
- If Register A equals 20H, the Z FLAG is set.
- If A < 20H, the CARRY FLAG will be set.
- if A >= 20H, the NO CARRY FLAG will be set.
[51F2H]
[0033H]
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
- If Register A equals ,, then we have a breakpoint specifier and the Z FLAG is set.
- If A < 2CH, the CARRY FLAG will be set.
- if A >= 2CH, the NO CARRY FLAG will be set.
- If Register A equals 20H, the Z FLAG is set.
- If A < 20H, the CARRY FLAG will be set.
- if A >= 20H, the NO CARRY FLAG will be set.
5217H - Continuation of the routine to get a character from the user, jumped if the key was a CARRIAGE RETURN, ←, ↓, or ↑
521AH - Continuation of the routine to get a character from the user, jumped if the key was a →
521FH - Get hexadecimal input from the user and store it in Register Pair HL
[51F1H]
- If Register A equals BACK ARROW, the Z FLAG is set.
- If A < 08H, the CARRY FLAG will be set.
- if A >= 08H, the NO CARRY FLAG will be set.
[4E51H]
The next instructions are the magic instructions to convert HEX to ASCII - First move the old value left 4 bits, and then add in the second digit.
5230
5231
5232
ADD HL,HL
ADD HL,HL
ADD HL,HL
523EH - SUBroutine called from the prior routine to get a hex digit's value
524FH - SUBroutine to Display Bytes Held in (HL) In Hexadecimal
5253H - SUBROUTINE inside the DISPLAY DEBUG ROUTINE to display the address pointed to by Register Pair HL in hexadecimal
This is the commonly jumped to OUTBYT, which converts Register A to ASCII and displays it.
525A
525B
525C
RRA
RRA
RRA
[5261]
What is next is a clever way to manipulate a 4 bit byte into ASCII. Point to remember is that 0-F are contained in 4 bits, so that's the range.
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
526CH - SUBROUTINE to display a byte held in Register A as a two-byte ascii value followed by a space
[5258H]
5273H - Display a CARRIAGE RETURN and continue at 5269H
[5269H]
5277H - Clear to the End of Screen via a ROM CALL and RETURN
NOTE: 0033H is the character print routine, to put the character held in Register A (i.e., the ASCII code for CLEAR TO END OF SCREEN) at the current cursor position.
527CH - Display the 3 characters pointed to by (HL), (HL+1), and (HL+2), and then RETurn
"OUT3"
[5282H]
[5282H]
[5269H]
5286H - "Q" Option - Quit the Utility
[4463H]
NOTE: 4463H is the storage location for the old system disk side number.
528DH - Validate a Decimal Digit and Convert to Binary
"CHKNUM"
- If Register A equals 0AH, the Z FLAG is set.
- If A < 0AH, the CARRY FLAG will be set.
- if A >= 0AH, the NO CARRY FLAG will be set.
5294H - Validate a Hexidecimal digit and Convert to Binary
"GETHEX"
5295
POP IX
[52B7H]
- If Register A equals A, the Z FLAG is set.
- If A < A, the CARRY FLAG will be set.
- if A >= A, the NO CARRY FLAG will be set.
[52A9H]
- If Register A equals 10H, the Z FLAG is set.
- If A < 10H, the CARRY FLAG will be set.
- if A >= 10H, the NO CARRY FLAG will be set.
[52B7H]
52AE
52AF
52B0
ADD HL,HL
ADD HL,HL
ADD HL,HL
52B7H - Jump point from the prior routine if the value received is less than 0
52B9H - DEBUG routine entry from DOS Loader
"ENTRY"
52BDH - Disk File Display/Modify Routine
NOTE: 4023H is the storage location for the CURSOR CHARACTER.
[5526H]
[021BH]
NOTE: 021BH will display the character at (HL) until a 03H or 0AH is found.
[5543H]
[021BH]
NOTE: 021BH will display the character at (HL) until a 03H or 0AH is found.
[5555H]
[0040H]
[4300H]
[5555H]
[4424H]
[5405H]
If we have an open file, we now need to adjust the DCB for the file.
[5555H]
[5561H]
[5561H]
[5555H]
[4300H]
[5366H]
The next few instructions clear Buffer # 1
[5555H]
[5405H]
[5553H]
[545FH]
533CH - Display the Page for Modification
[4023H]
NOTE: 4023H is the storage location for the CURSOR CHARACTER.
[0033H]
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
[545FH]
[5351H]
[4103H]
5351H - Display Data
[555BH]
[555FH]
[5389H]
- If Register A equals 20H, the Z FLAG is set.
- If A < 20H, the CARRY FLAG will be set.
- if A >= 20H, the NO CARRY FLAG will be set.
[53A5H]
53AEH - Scan the Keyboard for Display Mode Commands
[52BDH]
[53CEH]
[53CEH]
[53E2H]
[53E2H]
[5445H]
53CEH - Advance to the Next Page of the Display
[555FH]
[5561H]
[53AEH]
[555FH]
53E2H - Back up to the Previous Page of the Display
[555FH]
53E7
OR C
[53AEH]
[53AEH]
53EDH - Display a Byte in Two Digit Hexadecimal
53F0
53F2
53F4
SRL A
SRL A
SRL A
What is next is a clever way to manipulate a 4 bit byte into ASCII. Point to remember is that 0-F are contained in 4 bits, so that's the range.
5405H - This routine is JUMPed to if a CALL to open a disk file returned an error
[5415H]
[5561H]
[555FH]
5415H - This routine is JUMPed to if a CALL to open a disk file returned an error that was not EOF Error
5423H - Subroutine to check to see if we are at the cursor position
[5553H]
[554FH]
[5437H]
5437H - Continuation of the above routine if the cursor is properly positioned
[5551H]
5445H - Enter Modify Mode
"MOVE"
[4300H]
[554FH]
[5553H]
544FH - Display Data for the MODIFY COMMAND
"BACK"
[554FH]
5457H - Command Loop for the MODIFY COMMAND
[5467H]
5467H - Continuation of the Command Loop for the MODIFY COMMAND (to handle a BREAK key)
[5475H]
[545FH]
[5330H]
5475H - Continuation of the Command Loop for the MODIFY COMMAND
[54A3H]
[549DH]
[5497H]
- If Register A equals 30H, the Z FLAG is set.
- If A < 30H, the CARRY FLAG will be set.
- if A >= 30H, the NO CARRY FLAG will be set.
[5457H]
- If Register A equals 1 more than 9, the Z FLAG is set.
- If A < 1 more than 9, the CARRY FLAG will be set.
- if A >= 1 more than 9, the NO CARRY FLAG will be set.
- If Register A equals A, the Z FLAG is set.
- If A < A, the CARRY FLAG will be set.
- if A >= A, the NO CARRY FLAG will be set.
[5457H]
- If Register A equals 1 more than F, the Z FLAG is set.
- If A < 1 more than F, the CARRY FLAG will be set.
- if A >= 1 more than F, the NO CARRY FLAG will be set.
5497H - Continuation of the Command Loop for the MODIFY COMMAND - Process a BACKSPACE
[554FH]
549DH - Continuation of the Command Loop for the MODIFY COMMAND - Process a RIGHT ARROW
[554FH]
54A3H - Continuation of the Command Loop for the MODIFY COMMAND - Process a UP ARROW
[554FH]
54ACH - Continuation of the Command Loop for the MODIFY COMMAND - Process a LINE FEED
[554FH]
[554FH]
54B8H - Modify RAM
[5551H]
[5551H]
[551EH]
54C8
54CA
54CC
SLA A
SLA A
SLA A
- If Register A equals 0, the Z FLAG is set.
- If A < 0, the CARRY FLAG will be set.
- if A >= 0, the NO CARRY FLAG will be set.
[54D0H]
- If Register A equals 1 more than 9, the Z FLAG is set.
- If A < 1 more than 9, the CARRY FLAG will be set.
- if A >= 1 more than 9, the NO CARRY FLAG will be set.
[54E3H]
- If Register A equals A, the Z FLAG is set.
- If A < A, the CARRY FLAG will be set.
- if A >= A, the NO CARRY FLAG will be set.
[54D0H]
- If Register A equals 1 more than F, the Z FLAG is set.
- If A < 1 more than F, the CARRY FLAG will be set.
- if A >= 1 more than F, the NO CARRY FLAG will be set.
[54D0H]
If we are here, then we know the rotated register A is 0-9 or A-F.
[5551H]
[5551H]
[551EH]
[554FH]
[554FH]
54FEH - Get a Character from the User
[5551H]
[4020H]
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
0033H
NOTE: 0033H is the character print routine, to put the character held in Register A at the current cursor position.
550FH - Write a Diskette File Page to Diskette
[5405H]
551EH - Convert an ASCII Hexidecimal Number (stored in A) to Decimal (stored in A). On Entry Register E holds the LSB of the cursor position and on exit that is increased by 1
- If Register A equals 10, the Z FLAG is set.
- If A < 10, the CARRY FLAG will be set.
- if A >= 0AH, the NO CARRY FLAG will be set.
5526H - Message Storage Area
"TITLE"
"BPROMT"
"BUFF1"
"CURSA"
"MOVFLG"
"BDCB"
DEFW 00H
DEFW 00H
"DRV"
DEFW 00H
"NRN"
"ERN"