DOSPLUS 3.5 for the Model III - SYS6/SYS Disassembled

Page Customization

Introduction/Summary

DOSPLUS 3.5 SYS6/SYS Disassembly - The DEBUG Monitor (Model III)

SYS6/SYS is the low overlay of the DEBUG monitor, requested with code 53H by DEBUG@ (440DH). DEBUG@ is reached by an RST 30H (the monitor's breakpoints are RST 30H instructions, F7H), by the BREAK key when the DEBUG on BREAK switch at 429BHH is set, and by the D key at start-up; with DEBUG on, ABORT@ also leads to it. The file is a load module of 5 blocks, 1022 bytes, from 4E00H to 51FDH, with the transfer address 4E00H. Its variables are outside the overlay, at 4265HH-4286HH, so the breakpoints, the display mode and the addresses last from one entry to the next.

The Parts of SYS6/SYS

AddressContents
4E00H-4E51HThe routine table, routine 2, and the entry: registers saved, breakpoints taken out (4E00H, 4E06H).
4E52H-4ED6HThe command loop and the short commands S, X, ;, -, A, H, D and U (4E52H).
4ED7H-4F82HThe register and memory display, the register names and flag letters (4ED7H).
4F83H-4FDDHO and G, the return to the program, setting a breakpoint (4F83H, 4FCDH).
4FDEH-505FHM (memory) and R (register) (4FDEH, 5014H).
5060H-5133HI and C, the single step, and its instruction tables (5060H, 50E3H).
5134H-51FDHA line of bytes, key and number input, number and character display (5134H, 5187H, 51A2H, 51CFH).

Entering and Leaving

The monitor drops the overlay handler's return and the word it saved from 429AHH-429BHH, so it never returns through the handler, and saves the program's registers on the stack and from there to 426DHH-4284HH: AF, BC, DE, HL, the alternate set, IX, IY, the SP and the PC (the return address of the RST 30H or the call to DEBUG@). It then runs on the program's stack. When the byte before the PC is F7H, the PC is moved back onto it, so a breakpoint's own instruction runs next; then both breakpoints are taken out, each one's old byte put back if the F7H is still there (4E36H).

G takes an address for the PC and up to two breakpoints; O goes to EXIT@ (402DH). Both set 429BHH to FFH, so BREAK enters DEBUG again, put every register back from the save area and jump to the PC (4FA7H). A breakpoint that cannot be set (the F7H does not stay, as in ROM) sends the monitor back to its command loop (4FCDH).

The Display and the Commands

X shows the twelve registers, each with the 16 bytes at its address in hexadecimal or as characters (H or A), or the flags as letters (S Z 1 H 1 P N C, a minus sign for a clear flag) for AF and AF', then four lines of memory from the display address; S shows sixteen lines, the 256 byte page of that address. ; and - move the display by 64 or 256 bytes, D sets its address and U repeats the display until a key is pressed. Commands are typed on the last line of the screen (3FC0H). M shows the address and the byte on lines 13 and 14, marks the byte in the memory lines with the graphics 8AH and 85H, and takes new values, a space or comma moving on and ENTER ending. R takes a register name and a value. Numbers are hexadecimal, ended by a space, a comma or ENTER (51A2H); a wrong key ends the command.

The Single Step

I and C find the length and kind of the instruction at the PC in three tables of masks (50E3H, 5111H, 5118H): one byte opcodes, those after EDH, those after DDH and FDH. A breakpoint goes after the instruction; a jump, call or return also gets one at its target: the operand's address (JP, CALL), the displacement (JR, DJNZ), the word at the program's SP (RET, RETN, RETI), or the saved HL, IX or IY (JP (HL), JP (IX), JP (IY)). C does not follow a CALL: the call runs to the breakpoint after it. Conditional instructions get both breakpoints. An RST is treated as a one byte instruction, so the step runs the whole restart routine before it stops.

Differences from the Manual

The manual lists the commands as the bytes have them. Three things it does not say: the step of JP (IX) takes its target from IY, because the test at 50D2H looks at bit 5 of the byte after the prefix (E9H) instead of the prefix itself; the M command keeps its address in the second breakpoint block; and the C command steps over a call by running it.

Differences from the Model I

The code is the Model I SYS6/SYS at the same addresses; only the work area is elsewhere, 4265H-4286H in place of 405DH-407EH, and the DEBUG on BREAK switch is 429BH. The screen addresses (3F40H, 3F80H, 3FC0H) and the ROM routines (0033H, 0049H, 002BH) are the same.

Variables

The Work Area ({405D}H-{407E}H)

Address
Size
Contents
4265HH-4267HH
3 bytes
First Breakpoint
4265H
4268HH-426AHH
3 bytes
Second Breakpoint, M Address
4268H
426BHH-426CHH
2 bytes
Display Address
426BH
426DHH-4282HH
22 bytes
Saved Registers
426DH
4283HH-4284HH
2 bytes
PC
4283H
4285HH
1 byte
Byte Form
4285H
4286HH
1 byte
Display Mode
4286H

Other Memory

Address
Size
Contents
429BHH
1 byte
DEBUG on BREAK
Set to FFH when the program goes (4FA4H).
4020H-4021H
2 bytes
ROM Cursor Address
4E5CH, 4FEFH
4F57H-4F82H
44 bytes
Names and Flag Letters
4F57H, 4F7BH
50E3H-5133H
81 bytes
Instruction Tables
50E3H

Outside Routines

AddressContents
0033HROM: display the character in Register A.
0049HROM: wait for a key (5188H).
002BHROM: scan the keyboard (4EA6H).
402DHSYS0/SYS: EXIT@, where O goes (4F83H).

Disassembly

4265H - The Monitor's Work Area

Not in the file: SYS6/SYS keeps its variables in the RAM at 4265H-4286H, outside the overlay area, so they last from one entry of the monitor to the next.

4265-4267
DEFS 3
The first breakpoint block: the address (00H 00H when none) and the byte the RST 30H replaced. Single step's second breakpoint, at a jump's target (50DEH).
4268-426A
DEFS 3
The second breakpoint block: the address and the old byte. G's first breakpoint and single step's breakpoint after the instruction; 4268H-4269H is also the address of the M command (4FE4H).
426B-426C
DEFS 2
The memory display address (4EB9H-4ECAH, 4F36H).
426D-4282
DEFS 22
The saved registers: AF 426DH, BC 426FH, DE 4271H, HL 4273H, AF' 4275H, BC' 4277H, DE' 4279H, HL' 427BH, IX 427DH, IY 427FH, SP 4281H (4E24H-4E26H).
4283-4284
DEFS 2
The program's PC, where G and the single step go (4FC5H).
4285
DEFS 1
The form of memory bytes: 41H (A) characters, else hexadecimal (4ED3H, 5142H).
4286
DEFS 1
The display mode: 00H the registers (X), else the full screen of memory (S) (4EA2H, 4EDCH).

4E00H - The Routine Table

Data: SYS6/SYS's table of routines 2 and 3, one word each, used by SYS0/SYS's overlay request handler (its 49D3H-49E6H) for the request codes 52H and 53H. DEBUG@ (440DH, which jumps to 445DH) requests 53H; no file of the diskette requests 52H.

4E00-4E01
DEFW 4E04H 04 4E
Routine 2: 4E04H, XOR A and RET, which SYS0/SYS's record locator requests when it loads SYS6/SYS back (its 4D5FH-4D6CH).
4E02-4E03
DEFW 4E06H 06 4E
Routine 3: 4E06H, the DEBUG monitor, which saves the registers and runs the commands.

4E04H - Routine 2

Nothing to do when SYS0/SYS's record locator brings SYS6/SYS back.

4E04
XOR A AF
Set Register A to 00H by XORing it with itself, and set the Z FLAG: routine 2 has no work to do.
4E05
RET C9
RETurn to SYS0/SYS's overlay request handler (49E7H) with Register A = 00H.

4E06H - DEBUG - Entering the Monitor

Routine 3, requested by DEBUG@ (445DH: PUSH AF / LD A,53H / RST 28H), which RST 30H (400FH), the BREAK key with 429BH set, and the start-up's D key reach. The stack holds the handler's return 49E7H, the word it saved from 429AH-429BH, the program's AF and the program's return address (its PC). The monitor saves every register of the program to 426DH-4284H (the PC at 4283H, the SP at 4281H), runs on the program's own stack, steps the PC back over an RST 30H breakpoint, and takes its two breakpoints out of memory.

4E06
POP AF F1
Restore Register Pair AF from the top of the stack: it drops the handler's return 49E7H; the monitor does not go back through the handler.
4E07
POP AF F1
Restore Register Pair AF from the top of the stack: it drops the word saved from 429AH-429BH, which is not put back.
4E08
POP AF F1
Restore Register Pair AF from the top of the stack: the program's Register A and flags, which DEBUG@ pushed at 445DH.
4E09
PUSH AF F5
Save Register Pair AF, the program's, to the top of the stack again: it is the eleventh word of the save area, which 4E26H overwrites with the SP.
4E0A
PUSH IY FD E5
Save Index Register IY, the program's, to the top of the stack.
4E0C
PUSH IX DD E5
Save Index Register IX, the program's, to the top of the stack.
4E0E
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF'.
4E0F
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate BC', DE' and HL'.
4E10
PUSH HL E5
Save Register Pair HL (the program's HL') to the top of the stack.
4E11
PUSH DE D5
Save Register Pair DE (the program's DE') to the top of the stack.
4E12
PUSH BC C5
Save Register Pair BC (the program's BC') to the top of the stack.
4E13
PUSH AF F5
Save Register Pair AF (the program's AF') to the top of the stack.
4E14
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF' again.
4E15
EXX D9
Exchange Register Pairs BC, DE and HL with the alternates again: the main registers are back.
4E16
PUSH HL E5
Save Register Pair HL, the program's, to the top of the stack.
4E17
PUSH DE D5
Save Register Pair DE, the program's, to the top of the stack.
4E18
PUSH BC C5
Save Register Pair BC, the program's, to the top of the stack.
4E19
PUSH AF F5
Save Register Pair AF, the program's, to the top of the stack: twelve words with the program's return above them.
4E1A
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, to take the Stack Pointer.
4E1D
ADD HL,SP 39
ADD the Stack Pointer to Register Pair HL: Register Pair HL = the address of the saved registers.
4E1E
LD DE,426DH 11 6D 42
Point Register Pair DE to 426DH, the register save area.
4E21
LD BC,0018H 01 18 00
Load Register Pair BC with 0018H, the 24 bytes of the twelve words.
4E24
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL (the stack) to Register Pair DE (426DH-4284H): AF, BC, DE, HL, AF', BC', DE', HL', IX, IY, AF and the program's PC at 4283H.
4E26
LD (4281H),HL 22 81 42
Store Register Pair HL, the address above the copied words, to 4281H: the program's Stack Pointer, over the second copy of AF.
4E29
LD SP,HL F9
Load the Stack Pointer with Register Pair HL: the monitor runs on the program's stack, above which nothing of its own is left.
4E2A
LD HL,(4283H) 2A 83 42
Load Register Pair HL with the program's PC from 4283H.
4E2D
DEC HL 2B
DECrement Register Pair HL by 1, to the byte before the return address.
4E2E
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL.
4E2F
CP F7H FE F7
Compare Register A against F7H, the RST 30H the monitor puts at a breakpoint.
4E31
If the NZ FLAG is set (not an RST 30H), JUMP to 4E36H.
4E33
LD (4283H),HL 22 83 42
Store Register Pair HL to 4283H: the PC is the breakpoint's address, so the instruction there runs when the program goes on.
4E36
LD HL,4265H 21 65 42
Point Register Pair HL to 4265H, the first of the two breakpoint blocks (an address and the byte the RST 30H replaced).
4E39
LD B,02H 06 02
Load Register B with 02H, the two breakpoints.
4E3B
XOR A AF
Set Register A to 00H by XORing it with itself, to clear the breakpoint's address with.
4E3C
LD C,02H 0E 02
Load Register C with 02H; Register C is not used by this loop.
4E3E
LD E,(HL) 5E
Load Register E with the low byte of the breakpoint's address at Register Pair HL.
4E3F
LD (HL),A 77
Store Register A (00H) to the low byte at Register Pair HL.
4E40
INC HL 23
INCrement Register Pair HL by 1 to the high byte of the address.
4E41
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the breakpoint's address.
4E42
LD (HL),A 77
Store Register A (00H) to the high byte at Register Pair HL: the block is free.
4E43
INC HL 23
INCrement Register Pair HL by 1 to the saved byte.
4E44
LD A,D 7A
Load Register A with Register D, the high byte of the address.
4E45
OR E B3
OR Register A with Register E: the Z FLAG when Register Pair DE is 0000H, no breakpoint.
4E46
If the Z FLAG is set (no breakpoint in this block), JUMP to 4E4FH.
4E48
LD A,(DE) 1A
Load Register A with the byte at the breakpoint's address, Register Pair DE.
4E49
CP F7H FE F7
Compare Register A against F7H, the RST 30H of a breakpoint.
4E4B
If the NZ FLAG is set (the program changed the byte), JUMP to 4E4FH and leave it.
4E4D
LD A,(HL) 7E
Load Register A with the saved byte at Register Pair HL.
4E4E
LD (DE),A 12
Store Register A to the breakpoint's address at Register Pair DE: the program's byte is back.
4E4F
INC HL 23
INCrement Register Pair HL by 1 to the next breakpoint block.
4E50
DECrement Register B and loop back to 4E3BH while Register B is not zero.

4E52H - The Command Loop

Shows the display, reads a command key on the bottom line and runs the command. Every command returns here (4E52H is pushed as its return), which also resets the Stack Pointer from 4281H. G and O leave the monitor; S and X choose the display, A and H the form of memory bytes, ; and - move the memory display, D sets its address, U updates the display until a key is pressed, M changes memory, R changes a register, and I and C step one instruction.

4E52
LD SP,(4281H) ED 7B 81 42
Load the Stack Pointer with the program's SP from 4281H.
4E56
GOSUB to 4ED7H to show the registers and memory, or the full screen of memory.
4E59
LD HL,3FC0H 21 C0 3F
Point Register Pair HL to 3FC0H, the first column of the screen's last line.
4E5C
LD (4020H),HL 22 20 40
Store Register Pair HL to 4020H, the ROM's cursor address: the command is typed on the last line.
4E5F
GOSUB to 5187H to wait for a key and display it: Register A = the key, letters in upper case.
4E62
CP 47H FE 47
Compare Register A against 47H (G), the Go command.
4E64
If the Z FLAG is set (G), JUMP to 4F89H for the Go command.
4E67
CP 4FH FE 4F
Compare Register A against 4FH (O), the exit to DOSPLUS.
4E69
If the Z FLAG is set (O), JUMP to 4F83H for the exit to DOSPLUS.
4E6C
LD HL,4E52H 21 52 4E
Point Register Pair HL to 4E52H, the command loop, for the commands to return to.
4E6F
PUSH HL E5
Save Register Pair HL (4E52H) to the top of the stack as the command's return.
4E70
CP 53H FE 53
Compare Register A against 53H (S), the full screen memory display.
4E72
If the Z FLAG is set (S), JUMP to 4EA2H to store the nonzero key as the display mode.
4E74
CP 3BH FE 3B
Compare Register A against 3BH (;), the next memory page.
4E76
If the Z FLAG is set (;), JUMP to 4EB6H for the next memory page.
4E78
CP 2DH FE 2D
Compare Register A against 2DH (-), the previous memory page.
4E7A
If the Z FLAG is set (-), JUMP to 4ECEH for the previous memory page.
4E7C
CP 41H FE 41
Compare Register A against 41H (A), memory bytes as characters.
4E7E
If the Z FLAG is set (A), JUMP to 4ED3H to store the key as the byte form.
4E80
CP 43H FE 43
Compare Register A against 43H (C), the step over a call.
4E82
If the Z FLAG is set (C), JUMP to 4E8EH, the JP Z,5060H below, with the Z FLAG set: C and I both go to 5060H.
4E84
CP 44H FE 44
Compare Register A against 44H (D), the memory display address.
4E86
If the Z FLAG is set (D), JUMP to 4EB0H to take the display address.
4E88
CP 48H FE 48
Compare Register A against 48H (H), memory bytes in hexadecimal.
4E8A
If the Z FLAG is set (H), JUMP to 4ED3H to store the key as the byte form.
4E8C
CP 49H FE 49
Compare Register A against 49H (I), the single step.
4E8E
If the Z FLAG is set (I, or C from 4E82H), JUMP to 5060H.
4E91
CP 4DH FE 4D
Compare Register A against 4DH (M), the memory change.
4E93
If the Z FLAG is set (M), JUMP to 4FDEH for the memory change.
4E96
CP 52H FE 52
Compare Register A against 52H (R), the register change.
4E98
If the Z FLAG is set (R), JUMP to 5014H for the register change.
4E9B
CP 55H FE 55
Compare Register A against 55H (U), the display update.
4E9D
If the Z FLAG is set (U), JUMP to 4EA6H for the display update.
4E9F
SUB 58H D6 58
SUBtract 58H (X), the register display, from Register A: 00H for X.
4EA1
RET NZ C0
If the NZ FLAG is set (no command), RETurn to the command loop at 4E52H.
4EA2
LD (4286H),A 32 86 42
Store Register A to 4286H, the display mode: 00H (X) the registers, 53H (S) the full screen of memory.
4EA5
RET C9
RETurn to the command loop at 4E52H with the new display mode.
4EA6
GOSUB to 002BH in the ROM to scan the keyboard: Register A = the key pressed, or 00H.
4EA9
OR A B7
OR Register A with itself: the NZ FLAG when a key is pressed.
4EAA
RET NZ C0
If the NZ FLAG is set (a key), RETurn to the command loop at 4E52H.
4EAB
GOSUB to 4ED7H to show the display again, with the memory as it is now.
4EAE
JUMP back to 4EA6H to scan the keyboard again.
4EB0
GOSUB to 51A2H to read a hexadecimal address into Register Pair HL; the Z FLAG when none was typed.
4EB3
RET Z C8
If the Z FLAG is set (no address), RETurn to the command loop at 4E52H.
4EB4
JUMP to 4ECAH to store Register Pair HL as the memory display address.
4EB6
LD BC,0040H 01 40 00
Load Register Pair BC with 0040H, the 64 bytes of the four lines of the register display.
4EB9
LD HL,(426BH) 2A 6B 42
Load Register Pair HL with the memory display address from 426BH.
4EBC
LD A,(4286H) 3A 86 42
Load Register A with the display mode from 4286H.
4EBF
OR A B7
OR Register A with itself: the Z FLAG for the register display.
4EC0
If the Z FLAG is set (registers), JUMP to 4EC9H to move by Register Pair BC.
4EC2
LD C,00H 0E 00
Full screen: load Register C with 00H: Register Pair BC = 0000H for the next page, FF00H for the previous.
4EC4
LD A,B 78
Load Register A with Register B, the high byte of the step.
4EC5
OR A B7
OR Register A with itself: the Z FLAG for the next page (Register B 00H).
4EC6
If the NZ FLAG is set (the previous page, FF00H), JUMP to 4EC9H.
4EC8
INC B 04
INCrement Register B by 1: Register Pair BC = 0100H, the 256 bytes of a full screen.
4EC9
ADD HL,BC 09
ADD Register Pair BC, the step, to Register Pair HL, the memory display address.
4ECA
LD (426BH),HL 22 6B 42
Store Register Pair HL to 426BH, the memory display address.
4ECD
RET C9
RETurn to the command loop at 4E52H with the new display address.
4ECE
LD BC,FFC0H 01 C0 FF
Load Register Pair BC with FFC0H, minus 64 bytes, for the previous page.
4ED1
JUMP back to 4EB9H to move the memory display address by Register Pair BC.
4ED3
LD (4285H),A 32 85 42
Store Register A, the key (41H A or 48H H), to 4285H, the form of memory bytes.
4ED6
RET C9
RETurn to the command loop at 4E52H with the new byte form.

4ED7H - The Display

Clears the screen (cursor home and 1CH) and shows either the register display (X: the twelve registers, each with the 16 bytes at its address or, for AF and AF', the flags, then four lines of memory from 426BH) or the full screen display (S: sixteen lines of 16 bytes from the start of the 256 byte page of 426BH).

4ED7
LD A,1CH 3E 1C
Load Register A with 1CH, the code that moves the cursor to the top left of the screen.
4ED9
GOSUB to 0033H in the ROM to display the character in Register A.
4EDC
LD A,(4286H) 3A 86 42
Load Register A with the display mode from 4286H.
4EDF
OR A B7
OR Register A with itself: the NZ FLAG for the full screen display.
4EE0
If the NZ FLAG is set (S), JUMP to 4F4EH for the full screen display.
4EE2
LD HL,426DH 21 6D 42
Point Register Pair HL to 426DH, the saved registers.
4EE5
PUSH HL E5
Save Register Pair HL (the next saved register) to the top of the stack.
4EE6
LD HL,4F57H 21 57 4F
Point Register Pair HL to 4F57H, the register names, three characters each.
4EE9
LD B,0CH 06 0C
Load Register B with 0CH, the twelve registers.
4EEB
JUMP to 4EEDH, the next instruction: the jump does nothing.
4EED
GOSUB to 51F4H to display the three characters of the name at Register Pair HL, which moves on to the next name.
4EF0
EX (SP),HL E3
Exchange the top of the Stack Pointer with Register Pair HL: Register Pair HL = the saved register, the next name goes to the stack.
4EF1
LD E,(HL) 5E
Load Register E with the low byte of the register at Register Pair HL.
4EF2
INC HL 23
INCrement Register Pair HL by 1 to the high byte.
4EF3
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL: Register Pair DE = the register's value.
4EF4
INC HL 23
INCrement Register Pair HL by 1 to the next saved register.
4EF5
PUSH HL E5
Save Register Pair HL (the next saved register) to the top of the stack.
4EF6
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the register's value.
4EF7
GOSUB to 51ECH to display a space after the name.
4EFA
LD A,3DH 3E 3D
Load Register A with 3DH, an equals sign after the register's name.
4EFC
GOSUB to 0033H in the ROM to display the equals sign in Register A.
4EFF
GOSUB to 51ECH to display a space after the equals sign.
4F02
GOSUB to 51D3H to display Register Pair HL, the value, as four hexadecimal digits.
4F05
LD A,B 78
Load Register A with Register B, the registers left (12 for AF, 8 for AF').
4F06
AND 0BH E6 0B
AND Register A with 0BH, keeping bits 3, 1 and 0.
4F08
CP 08H FE 08
Compare Register A against 08H: only 0CH (AF) and 08H (AF') give 08H.
4F0A
If the NZ FLAG is set (not AF or AF'), JUMP to 4F2BH to display the memory at the register's address.
4F0C
LD C,L 4D
Load Register C with Register L, the flags of AF or AF'.
4F0D
PUSH BC C5
Save Register Pair BC (Register B the count, Register C the flags) to the top of the stack.
4F0E
GOSUB to 51ECH to display a space before the flags.
4F11
LD HL,4F7BH 21 7B 4F
Point Register Pair HL to 4F7BH, the flag letters S Z 1 H 1 P N C.
4F14
LD B,08H 06 08
Load Register B with 08H, the eight bits of the flags.
4F16
SLA C CB 21
Shift Register C left one bit: the C FLAG = the next flag bit, bit 7 first.
4F18
LD A,(HL) 7E
Load Register A with the flag's letter at Register Pair HL.
4F19
If the C FLAG is set (the flag is set), JUMP to 4F1DH to display its letter.
4F1B
LD A,2DH 3E 2D
Load Register A with 2DH, a minus sign, for a flag that is clear.
4F1D
GOSUB to 0033H in the ROM to display the letter or the minus sign in Register A.
4F20
INC HL 23
INCrement Register Pair HL by 1 to the next flag letter.
4F21
DECrement Register B and loop back to 4F16H while Register B is not zero.
4F23
POP BC C1
Restore Register Pair BC from the top of the stack: Register B = the registers left.
4F24
LD A,1EH 3E 1E
Load Register A with 1EH, the code that clears the rest of the line.
4F26
GOSUB to 0033H in the ROM to display the code in Register A.
4F29
JUMP to 4F2EH to end the line of AF or AF' with a carriage return.
4F2B
GOSUB to 5134H to display a colon and the 16 bytes at Register Pair HL, the register's value.
4F2E
GOSUB to 51F0H to display a carriage return, the end of the register's line.
4F31
POP HL E1
Restore Register Pair HL from the top of the stack: the next saved register.
4F32
EX (SP),HL E3
Exchange the top of the Stack Pointer with Register Pair HL: Register Pair HL = the next name, the next saved register goes to the stack.
4F33
DECrement Register B and loop back to 4EEDH while Register B is not zero.
4F35
POP HL E1
Restore Register Pair HL from the top of the stack: it drops the saved register pointer.
4F36
LD HL,(426BH) 2A 6B 42
Load Register Pair HL with the memory display address from 426BH.
4F39
LD B,04H 06 04
Load Register B with 04H, four lines of memory.
4F3B
JUMP to 4F40H for the first line, without a carriage return before it.
4F3D
GOSUB to 51F0H to display a carriage return before the next line.
4F40
LD A,C6H 3E C6
Load Register A with C6H, the ROM's space compression code for six spaces (C0H + 6).
4F42
GOSUB to 0033H in the ROM to display the six spaces of Register A.
4F45
GOSUB to 51D3H to display Register Pair HL, the line's address, as four hexadecimal digits.
4F48
GOSUB to 5134H to display a colon and the 16 bytes at Register Pair HL, which moves on 16 bytes.
4F4B
DECrement Register B and loop back to 4F3DH while Register B is not zero.
4F4D
RET C9
RETurn with the display shown and Register Pair HL past the last line.
4F4E
LD HL,(426BH) 2A 6B 42
Full screen: load Register Pair HL with the memory display address from 426BH.
4F51
LD L,00H 2E 00
Load Register L with 00H: Register Pair HL = the start of its 256 byte page.
4F53
LD B,10H 06 10
Load Register B with 10H, sixteen lines of 16 bytes.
4F55
JUMP back to 4F40H to display the lines, Register B of them.
4F57-4F7A
DEFM "AF BC DE HL AF'BC'DE'HL'IX IY SP PC " 41 46 20 42 43 20 44 45 20 48 4C 20 41 46 27 42 43 27 44 45 27 48 4C 27 49 58 20 49 59 20 53 50 20 50 43 20
The names of the twelve registers, three characters each, in the order of the save area at 426DH-4284H; 4EEDH displays them and the R command (502CH) looks them up.
4F7B-4F82
DEFM "SZ1H1PNC" 53 5A 31 48 31 50 4E 43
The letters of the eight flag bits, bit 7 first: S, Z, bit 5 (shown as 1), H, bit 3 (shown as 1), P (parity or overflow), N and C.

4F83H - O and G - Leaving the Monitor

O puts 402DH (EXIT@) into the PC and goes; G takes an optional address for the PC and up to two breakpoint addresses (separated by a comma or a space, ENTER ending). Going sets 429BH, so BREAK enters DEBUG again, puts the registers back from the save area, loads the Stack Pointer and jumps to the PC with Register Pair HL restored last.

4F83
LD HL,402DH 21 2D 40
O: point Register Pair HL to 402DH, EXIT@, as the address to go to.
4F86
SCF 37
Set the C FLAG, as if ENTER had ended the address.
4F87
JUMP to 4F93H to store Register Pair HL as the PC and go.
4F89
LD B,02H 06 02
G: load Register B with 02H, the most breakpoints.
4F8B
LD DE,426AH 11 6A 42
Point Register Pair DE to 426AH, the last byte of the second breakpoint block, for 4FCDH.
4F8E
GOSUB to 51A2H to read the address to go to into Register Pair HL; the Z FLAG when none was typed, the C FLAG when ENTER ended it.
4F91
If the Z FLAG is set (no address: the PC stays), JUMP to 4F96H.
4F93
LD (4283H),HL 22 83 42
Store Register Pair HL to 4283H, the program's PC.
4F96
If the C FLAG is set (ENTER), JUMP to 4FA2H to go.
4F98
GOSUB to 51A2H to read a breakpoint address into Register Pair HL.
4F9B
PUSH AF F5
Save Register Pair AF (the flags of the input) to the top of the stack.
4F9C
If the NZ FLAG is set (an address), GOSUB to 4FCDH to put an RST 30H there, recorded in the block that ends at Register Pair DE.
4F9F
POP AF F1
Restore Register Pair AF from the top of the stack: the flags of the input.
4FA0
DECrement Register B and loop back to 4F96H while Register B is not zero.
4FA2
LD A,FFH 3E FF
Load Register A with FFH, the value that turns the DEBUG on BREAK switch on.
4FA4
LD (429BH),A 32 9B 42
Store Register A (FFH) to 429BH in SYS0/SYS: BREAK enters DEBUG again.
4FA7
LD HL,4282H 21 82 42
Point Register Pair HL to 4282H, the high byte of the saved SP; the single step (50B7H) comes here too.
4FAA
LD B,0BH 06 0B
Load Register B with 0BH, the eleven words from the SP down to AF.
4FAC
LD D,(HL) 56
Load Register D with the high byte at Register Pair HL.
4FAD
DEC HL 2B
DECrement Register Pair HL by 1 to the low byte.
4FAE
LD E,(HL) 5E
Load Register E with the low byte at Register Pair HL.
4FAF
DEC HL 2B
DECrement Register Pair HL by 1 to the next word down.
4FB0
PUSH DE D5
Save Register Pair DE, the saved word, to the top of the stack.
4FB1
DECrement Register B and loop back to 4FACH while Register B is not zero.
4FB3
POP AF F1
Restore Register Pair AF from the top of the stack, the program's.
4FB4
POP BC C1
Restore Register Pair BC from the top of the stack, the program's.
4FB5
POP DE D1
Restore Register Pair DE from the top of the stack, the program's.
4FB6
POP HL E1
Restore Register Pair HL from the top of the stack, the program's (loaded again at 4FC9H).
4FB7
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF'.
4FB8
EXX D9
Exchange Register Pairs BC, DE and HL with the alternates BC', DE' and HL'.
4FB9
POP AF F1
Restore Register Pair AF from the top of the stack: the program's AF'.
4FBA
POP BC C1
Restore Register Pair BC from the top of the stack: the program's BC'.
4FBB
POP DE D1
Restore Register Pair DE from the top of the stack: the program's DE'.
4FBC
POP HL E1
Restore Register Pair HL from the top of the stack: the program's HL'.
4FBD
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF' again.
4FBE
EXX D9
Exchange Register Pairs BC, DE and HL with the alternates again: both sets are the program's.
4FBF
POP IX DD E1
Restore Index Register IX from the top of the stack, the program's.
4FC1
POP IY FD E1
Restore Index Register IY from the top of the stack, the program's.
4FC3
POP HL E1
Restore Register Pair HL from the top of the stack: the program's SP.
4FC4
LD SP,HL F9
Load the Stack Pointer with Register Pair HL, the program's SP.
4FC5
LD HL,(4283H) 2A 83 42
Load Register Pair HL with the program's PC from 4283H.
4FC8
PUSH HL E5
Save Register Pair HL, the PC, to the top of the program's stack.
4FC9
LD HL,(4273H) 2A 73 42
Load Register Pair HL with the program's HL from 4273H.
4FCC
RET C9
RETurn to the PC with every register as the save area holds it.

4FCDH - Setting a Breakpoint

Puts an RST 30H (F7H) at Register Pair HL and records the address and the old byte in the block that ends at Register Pair DE (the byte at Register Pair DE, then the address below it); Register Pair DE returns 3 bytes lower, the end of the block before. When the byte does not take the F7H (ROM), the monitor goes back to 4E36H, which takes out what was set.

4FCD
LD A,(HL) 7E
Load Register A with the byte at the breakpoint's address, Register Pair HL.
4FCE
LD (DE),A 12
Store Register A, the old byte, to the block at Register Pair DE.
4FCF
DEC DE 1B
DECrement Register Pair DE by 1 to the high byte of the block's address.
4FD0
LD A,F7H 3E F7
Load Register A with F7H, the opcode of RST 30H.
4FD2
LD (HL),A 77
Store Register A (F7H) to the breakpoint's address at Register Pair HL.
4FD3
CP (HL) BE
Compare Register A against the byte at Register Pair HL, to see that it took the F7H.
4FD4
If the NZ FLAG is set (read only memory), JUMP to 4E36H to take out the breakpoints and go back to the command loop.
4FD7
LD A,H 7C
Load Register A with Register H, the high byte of the address.
4FD8
LD (DE),A 12
Store Register A to the block's high byte at Register Pair DE.
4FD9
DEC DE 1B
DECrement Register Pair DE by 1 to the low byte.
4FDA
LD A,L 7D
Load Register A with Register L, the low byte of the address.
4FDB
LD (DE),A 12
Store Register A to the block's low byte at Register Pair DE.
4FDC
DEC DE 1B
DECrement Register Pair DE by 1 to the end of the block before.
4FDD
RET C9
RETurn with the breakpoint set and Register Pair DE 3 bytes lower.

4FDEH - M - Changing Memory

Takes an optional address (else the last one, 4268H), shows the display with the address on line 13 and the byte on line 14 (and the byte marked in the memory lines by 8AH and 85H), and takes a new value: a value is stored, nothing typed leaves the byte, a space or comma moves on to the next address, ENTER ends. The address is kept in 4268H-4269H, the second breakpoint block, which 4E36H cleared on entry.

4FDE
LD HL,(4268H) 2A 68 42
Load Register Pair HL with the address last changed from 4268H.
4FE1
GOSUB to 51A2H to read an address into Register Pair HL; the Z FLAG and Register Pair HL kept when none was typed.
4FE4
LD (4268H),HL 22 68 42
Store Register Pair HL to 4268H, the address to change.
4FE7
RET C D8
If the C FLAG is set (ENTER), RETurn to the command loop at 4E52H.
4FE8
PUSH HL E5
Save Register Pair HL, the address, to the top of the stack.
4FE9
GOSUB to 4ED7H to show the display; 5163H marks the byte at 4268H in its memory lines.
4FEC
LD HL,3F40H 21 40 3F
Point Register Pair HL to 3F40H, the first column of the screen's line 13.
4FEF
LD (4020H),HL 22 20 40
Store Register Pair HL to 4020H, the ROM's cursor address.
4FF2
LD HL,(4268H) 2A 68 42
Load Register Pair HL with the address to change from 4268H.
4FF5
GOSUB to 51D3H to display Register Pair HL, the address, as four hexadecimal digits.
4FF8
PUSH HL E5
Save Register Pair HL, the address, to the top of the stack.
4FF9
LD HL,3F80H 21 80 3F
Point Register Pair HL to 3F80H, the first column of the screen's line 14.
4FFC
LD (4020H),HL 22 20 40
Store Register Pair HL to 4020H, the ROM's cursor address.
4FFF
POP HL E1
Restore Register Pair HL from the top of the stack: the address.
5000
GOSUB to 51CFH to display the byte at Register Pair HL in hexadecimal (Register Pair HL moves on by 1).
5003
LD A,2DH 3E 2D
Load Register A with 2DH, a minus sign after the old value.
5005
GOSUB to 0033H in the ROM to display the minus sign in Register A.
5008
POP DE D1
Restore Register Pair DE from the top of the stack: the address to change.
5009
GOSUB to 51A2H to read the new value into Register Pair HL; the Z FLAG when none was typed.
500C
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the address, Register E = the new value.
500D
If the Z FLAG is set (no value), JUMP to 5010H and leave the byte.
500F
LD (HL),E 73
Store Register E, the new value, to the byte at Register Pair HL.
5010
RET C D8
If the C FLAG is set (ENTER), RETurn to the command loop at 4E52H.
5011
INC HL 23
INCrement Register Pair HL by 1 to the next address.
5012
JUMP back to 4FE4H to change the next byte, at Register Pair HL.

5014H - R - Changing a Register

Takes a register name of two characters, or three for AF', BC', DE' and HL', then a space or comma and a hexadecimal value, which is stored in the save area; the name is looked up in the table at 4F57H.

5014
GOSUB to 5187H to read the first character of the name into Register A.
5017
RET Z C8
If the Z FLAG is set (ENTER, space or comma), RETurn to the command loop at 4E52H.
5018
LD C,A 4F
Load Register C with Register A, the first character.
5019
GOSUB to 5187H to read the second character of the name into Register A.
501C
RET Z C8
If the Z FLAG is set (ENTER, space or comma), RETurn to the command loop at 4E52H.
501D
LD D,A 57
Load Register D with Register A, the second character.
501E
LD E,20H 1E 20
Load Register E with 20H, a space: the third character of a two character name.
5020
GOSUB to 5187H to read the next key into Register A.
5023
RET C D8
If the C FLAG is set (ENTER), RETurn to the command loop at 4E52H.
5024
If the Z FLAG is set (a space or comma), JUMP to 502CH with the two character name.
5026
LD E,A 5F
Load Register E with Register A, the third character (the ' of an alternate register).
5027
GOSUB to 5187H to read the key after the name into Register A.
502A
RET NZ C0
If the NZ FLAG is set (not a separator), RETurn to the command loop at 4E52H.
502B
RET C D8
If the C FLAG is set (ENTER), RETurn to the command loop at 4E52H.
502C
LD HL,4F57H 21 57 4F
Point Register Pair HL to 4F57H, the register names.
502F
LD B,0CH 06 0C
Load Register B with 0CH, the twelve names in the table at 4F57H.
5031
LD A,(HL) 7E
Load Register A with the first character of the name at Register Pair HL.
5032
CP C B9
Compare Register A against Register C, the first character typed.
5033
If the Z FLAG is set (it agrees), JUMP to 503BH to compare the next character.
5035
INC HL 23
INCrement Register Pair HL by 1, the first of three steps to the next name.
5036
INC HL 23
INCrement Register Pair HL by 1 (503EH comes in here after the first character agreed).
5037
INC HL 23
INCrement Register Pair HL by 1 (5043H comes in here after two characters agreed).
5038
DECrement Register B and loop back to 5031H while Register B is not zero.
503A
RET C9
RETurn to the command loop at 4E52H: no register has the name typed.
503B
INC HL 23
INCrement Register Pair HL by 1 to the name's second character.
503C
LD A,(HL) 7E
Load Register A with the second character at Register Pair HL.
503D
CP D BA
Compare Register A against Register D, the second character typed.
503E
If the NZ FLAG is set (it differs), JUMP back to 5036H for the next name.
5040
INC HL 23
INCrement Register Pair HL by 1 to the name's third character.
5041
LD A,(HL) 7E
Load Register A with the third character at Register Pair HL.
5042
CP E BB
Compare Register A against Register E, the third character typed (or a space).
5043
If the NZ FLAG is set (it differs), JUMP back to 5037H for the next name.
5045
LD A,18H 3E 18
Load Register A with 18H, 24 bytes, twice the twelve names.
5047
SUB B 90
SUBtract Register B, the names left, from Register A.
5048
SUB B 90
SUBtract Register B again: Register A = 24 less twice the names left, the register's offset in the save area.
5049
LD C,A 4F
Load Register C with Register A, the offset in the save area.
504A
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the offset.
504C
LD HL,426DH 21 6D 42
Point Register Pair HL to 426DH, the register save area.
504F
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: Register Pair HL = the saved register.
5050
PUSH HL E5
Save Register Pair HL, the saved register's address, to the top of the stack.
5051
LD A,1EH 3E 1E
Load Register A with 1EH, the code that clears the rest of the line.
5053
GOSUB to 0033H in the ROM to display the code in Register A.
5056
POP DE D1
Restore Register Pair DE from the top of the stack: the saved register's address.
5057
GOSUB to 51A2H to read the value into Register Pair HL; the Z FLAG when none was typed.
505A
RET Z C8
If the Z FLAG is set (no value), RETurn to the command loop at 4E52H.
505B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the saved register, Register Pair DE = the value.
505C
LD (HL),E 73
Store Register E, the low byte of the value, to the saved register at Register Pair HL.
505D
INC HL 23
INCrement Register Pair HL by 1 to the saved register's high byte.
505E
LD (HL),D 72
Store Register D, the high byte of the value, to Register Pair HL.
505F
RET C9
RETurn to the command loop at 4E52H with the register changed.

5060H - I and C - The Single Step

Finds the length and the kind of the instruction at the PC from three tables of masks (5080H): 50E3H for one byte opcodes, 5111H after EDH and 5118H after DDH or FDH. A breakpoint goes after the instruction (block 4268H-426AH); for a jump, a call or a return a second breakpoint goes at its target (block 4265H-4267H), worked out from the saved registers. The C command does not follow a CALL: only the breakpoint after it is set. Then the program goes (4FA7H) and comes back to the monitor at the first breakpoint it reaches.

5060
PUSH AF F5
Save Register Pair AF, Register A the command (49H I or 43H C), to the top of the stack for 50B2H.
5061
LD DE,(4283H) ED 5B 83 42
Load Register Pair DE with the program's PC from 4283H.
5065
LD A,(DE) 1A
Load Register A with the instruction's first byte at Register Pair DE.
5066
LD HL,5118H 21 18 51
Point Register Pair HL to 5118H, the table for instructions after DDH or FDH.
5069
CP DDH FE DD
Compare Register A against DDH, the IX prefix.
506B
If the Z FLAG is set (DDH), JUMP to 507BH to look up the byte after the prefix.
506D
CP FDH FE FD
Compare Register A against FDH, the IY prefix.
506F
If the Z FLAG is set (FDH), JUMP to 507BH to look up the byte after the prefix.
5071
LD HL,50E3H 21 E3 50
Point Register Pair HL to 50E3H, the table for one byte opcodes.
5074
CP EDH FE ED
Compare Register A against EDH, the prefix of the extended instructions.
5076
If the NZ FLAG is set (no prefix), JUMP to 507EH to look up Register A in the table at 50E3H.
5078
LD HL,5111H 21 11 51
Point Register Pair HL to 5111H, the table for instructions after EDH.
507B
INC DE 13
INCrement Register Pair DE by 1 to the byte after the prefix.
507C
LD A,(DE) 1A
Load Register A with the byte after the prefix at Register Pair DE.
507D
DEC DE 1B
DECrement Register Pair DE by 1 back to the instruction's address.
507E
LD C,A 4F
Load Register C with Register A, the byte to look up (the opcode, or the byte after the prefix).
507F
LD A,(HL) 7E
Load Register A with the mask of the table entry at Register Pair HL.
5080
AND C A1
AND Register A with Register C: the bits of the byte that the entry looks at.
5081
INC HL 23
INCrement Register Pair HL by 1 to the entry's value.
5082
CP (HL) BE
Compare Register A against the entry's value at Register Pair HL.
5083
INC HL 23
INCrement Register Pair HL by 1 to the entry's kind and length.
5084
If the Z FLAG is set (the byte matches), JUMP to 508CH with Register Pair HL at the kind and length.
5086
INC HL 23
INCrement Register Pair HL by 1 to the next entry.
5087
LD A,(HL) 7E
Load Register A with the next entry's first byte at Register Pair HL.
5088
CP 05H FE 05
Compare Register A against 05H: a byte below 05H is the length at the end of the table, every mask is higher.
508A
If the NC FLAG is set (a mask), JUMP back to 507FH to try the next entry.
508C
LD A,(HL) 7E
Load Register A with the kind and length at Register Pair HL (the matching entry's, or the table's last byte).
508D
LD B,A 47
Load Register B with Register A: bits 7-4 the kind, bits 3-0 the length.
508E
AND 0FH E6 0F
AND Register A with 0FH, the length of the instruction in bytes.
5090
LD L,A 6F
Load Register L with Register A, the length of the instruction.
5091
LD H,00H 26 00
Load Register H with 00H: Register Pair HL = the length.
5093
ADD HL,DE 19
ADD Register Pair DE, the instruction's address, to Register Pair HL: the address of the next instruction.
5094
PUSH DE D5
Save Register Pair DE, the instruction's address, to the top of the stack.
5095
LD DE,426AH 11 6A 42
Point Register Pair DE to 426AH, the last byte of the second breakpoint block.
5098
GOSUB to 4FCDH to put a breakpoint at the next instruction, Register Pair HL; Register Pair DE returns 4267H.
509B
POP HL E1
Restore Register Pair HL from the top of the stack: the instruction's address.
509C
LD A,B 78
Load Register A with Register B, the kind and length.
509D
AND F0H E6 F0
AND Register A with F0H, the kind: 00H for an instruction that does not jump.
509F
If the Z FLAG is set (no jump), JUMP to 50B7H to go.
50A1
INC HL 23
INCrement Register Pair HL by 1 to the instruction's second byte, its operand.
50A2
CP 20H FE 20
Compare Register A against 20H, to sort the kinds.
50A4
If the C FLAG is set (10H: the target is in Register Pair HL), JUMP to 50DBH.
50A6
If the Z FLAG is set (20H: the target is in Index Register IX or IY), JUMP to 50CFH.
50A8
CP 40H FE 40
Compare Register A against 40H, to sort the kinds.
50AA
If the C FLAG is set (30H: a relative jump), JUMP to 50C3H.
50AC
If the Z FLAG is set (40H: a jump to the address in the operand), JUMP to 50BDH.
50AE
CP 60H FE 60
Compare Register A against 60H, to sort the kinds.
50B0
If the C FLAG is set (50H: a return, the target on the stack), JUMP to 50BAH.
50B2
POP AF F1
60H, a call: restore Register Pair AF from the top of the stack, the command pushed at 5060H.
50B3
CP 49H FE 49
Compare Register A against 49H (I), the step that follows calls.
50B5
If the Z FLAG is set (I), JUMP to 50BDH to follow the call to the address in its operand.
50B7
JUMP to 4FA7H to put the registers back and go to the PC; for C a call is run whole, up to the breakpoint after it.
50BA
LD HL,(4281H) 2A 81 42
A return: load Register Pair HL with the program's SP from 4281H.
50BD
LD A,(HL) 7E
Load Register A with the low byte of the target at Register Pair HL (the operand, or the top of the program's stack).
50BE
INC HL 23
INCrement Register Pair HL by 1 to the high byte.
50BF
LD H,(HL) 66
Load Register H with the high byte of the target at Register Pair HL.
50C0
LD L,A 6F
Load Register L with Register A: Register Pair HL = the target.
50C1
JUMP to 50DEH to put the second breakpoint at the target.
50C3
LD C,(HL) 4E
A relative jump: load Register C with the displacement at Register Pair HL.
50C4
XOR A AF
Set Register A to 00H by XORing it with itself, the high byte of a positive displacement.
50C5
BIT 7,C CB 79
Test bit 7 of Register C, the sign of the displacement.
50C7
If the Z FLAG is set (a positive displacement), JUMP to 50CAH.
50C9
CPL 2F
Complement Register A to FFH, the high byte of a negative displacement.
50CA
LD B,A 47
Load Register B with Register A: Register Pair BC = the displacement as 16 bits.
50CB
INC HL 23
INCrement Register Pair HL by 1 to the next instruction, from which the displacement counts.
50CC
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: Register Pair HL = the target of the relative jump.
50CD
JUMP to 50DEH to put the second breakpoint at the target.
50CF
LD HL,(427DH) 2A 7D 42
JP (IX) or JP (IY): load Register Pair HL with the program's IX from 427DH.
50D2
BIT 5,C CB 69
Test bit 5 of Register C. Meant to tell FDH (bit 5 set) from DDH, but Register C holds the byte after the prefix (E9H), whose bit 5 is set: the target is always taken from IY.
50D4
If the Z FLAG is set (bit 5 clear), JUMP to 50DEH with Register Pair HL = IX; with E9H in Register C this is never taken.
50D6
LD HL,(427FH) 2A 7F 42
Load Register Pair HL with the program's IY from 427FH.
50D9
JUMP to 50DEH to put the second breakpoint at the target.
50DB
LD HL,(4273H) 2A 73 42
JP (HL): load Register Pair HL with the program's HL from 4273H.
50DE
GOSUB to 4FCDH to put the second breakpoint at the target, Register Pair HL, in the block that ends at 4267H.
50E1
JUMP to 50B7H to go to the PC with both breakpoints set.

50E3H - The Instruction Tables

Data: entries of three bytes, a mask, a value and a byte that gives the kind (bits 7-4) and the length (bits 3-0) of the instructions whose byte, ANDed with the mask, equals the value; the first entry that matches is taken. Each table ends with a byte below 05H, the length of every instruction it does not list. Kinds: 00H no jump, 10H JP (HL), 20H JP (IX) or (IY), 30H relative, 40H to the operand's address, 50H return, 60H call.

50E3-50E5
DEFB C7H,C0H,51H C7 C0 51
Mask C7H, value C0H: RET cc (C0H, C8H ... F8H), a return of 1 byte (51H).
50E6-50E8
DEFB FFH,C9H,51H FF C9 51
Mask FFH, value C9H: RET, a return of 1 byte (51H).
50E9-50EB
DEFB FFH,E9H,11H FF E9 11
Mask FFH, value E9H: JP (HL), 1 byte to the address in Register Pair HL (11H).
50EC-50EE
DEFB CFH,01H,03H CF 01 03
Mask CFH, value 01H: LD BC/DE/HL/SP,nn, 3 bytes (03H).
50EF-50F1
DEFB E7H,22H,03H E7 22 03
Mask E7H, value 22H: LD (nn),HL, LD HL,(nn), LD (nn),A and LD A,(nn), 3 bytes (03H).
50F2-50F4
DEFB C7H,C2H,43H C7 C2 43
Mask C7H, value C2H: JP cc,nn, 3 bytes to the address in the operand (43H).
50F5-50F7
DEFB FFH,C3H,43H FF C3 43
Mask FFH, value C3H: JP nn, 3 bytes to the address in the operand (43H).
50F8-50FA
DEFB C7H,C4H,63H C7 C4 63
Mask C7H, value C4H: CALL cc,nn, a call of 3 bytes (63H).
50FB-50FD
DEFB FFH,CDH,63H FF CD 63
Mask FFH, value CDH: CALL nn, a call of 3 bytes (63H).
50FE-5100
DEFB C7H,06H,02H C7 06 02
Mask C7H, value 06H: LD r,n and LD (HL),n, 2 bytes without a jump (02H).
5101-5103
DEFB F7H,D3H,02H F7 D3 02
Mask F7H, value D3H: OUT (n),A and IN A,(n), 2 bytes (02H).
5104-5106
DEFB C7H,C6H,02H C7 C6 02
Mask C7H, value C6H: ADD A,n ... CP n, 2 bytes (02H).
5107-5109
DEFB FFH,CBH,02H FF CB 02
Mask FFH, value CBH: the CBH instructions, 2 bytes (02H).
510A-510C
DEFB F7H,10H,32H F7 10 32
Mask F7H, value 10H: DJNZ and JR, a relative jump of 2 bytes (32H).
510D-510F
DEFB E7H,20H,32H E7 20 32
Mask E7H, value 20H: JR NZ, JR Z, JR NC and JR C, a relative jump of 2 bytes (32H).
5110
DEFB 01H 01
The end of the one byte opcode table: every other opcode is 1 byte without a jump, RST n included (it is stepped over as if it returned).
5111-5113
DEFB C7H,43H,04H C7 43 04
After EDH, mask C7H, value 43H: LD (nn),rr and LD rr,(nn), 4 bytes (04H).
5114-5116
DEFB F7H,45H,52H F7 45 52
After EDH, mask F7H, value 45H: RETN and RETI, a return of 2 bytes (52H).
5117
DEFB 02H 02
The end of the EDH table: every other instruction after EDH is 2 bytes without a jump.
5118-511A
DEFB FEH,34H,03H FE 34 03
After DDH or FDH, mask FEH, value 34H: INC (IX+d) and DEC (IX+d), 3 bytes (03H).
511B-511D
DEFB C0H,40H,03H C0 40 03
After DDH or FDH, mask C0H, value 40H: the loads 40H-7FH with (IX+d), 3 bytes (03H).
511E-5120
DEFB C0H,80H,03H C0 80 03
After DDH or FDH, mask C0H, value 80H: ADD A,(IX+d) ... CP (IX+d), 3 bytes (03H).
5121-5123
DEFB FFH,21H,04H FF 21 04
After DDH or FDH, mask FFH, value 21H: LD IX,nn, 4 bytes (04H).
5124-5126
DEFB FFH,22H,04H FF 22 04
After DDH or FDH, mask FFH, value 22H: LD (nn),IX, 4 bytes (04H).
5127-5129
DEFB FFH,2AH,04H FF 2A 04
After DDH or FDH, mask FFH, value 2AH: LD IX,(nn), 4 bytes (04H).
512A-512C
DEFB FFH,36H,04H FF 36 04
After DDH or FDH, mask FFH, value 36H: LD (IX+d),n, 4 bytes (04H).
512D-512F
DEFB FFH,CBH,04H FF CB 04
After DDH or FDH, mask FFH, value CBH: the CBH instructions with (IX+d), 4 bytes (04H).
5130-5132
DEFB FFH,E9H,22H FF E9 22
After DDH or FDH, mask FFH, value E9H: JP (IX) and JP (IY), 2 bytes to the address in the index register (22H).
5133
DEFB 02H 02
The end of the DDH and FDH table: every other instruction after DDH or FDH is 2 bytes without a jump.

5134H - A Line of 16 Bytes

Displays a colon and a space, then the 16 bytes at Register Pair HL, in hexadecimal (H) or as characters (A, a dot for a control or space compression code). Before each byte 5163H displays a space, or 8AH and 85H around the byte at 4268H (the address of the M command), and an extra space after the eighth byte. Register Pair HL returns 16 bytes on.

5134
PUSH BC C5
Save Register Pair BC (Register B the caller's count) to the top of the stack.
5135
LD A,3AH 3E 3A
Load Register A with 3AH, a colon after the address or the value.
5137
GOSUB to 0033H in the ROM to display the colon in Register A.
513A
GOSUB to 51ECH to display a space after the colon.
513D
LD B,10H 06 10
Load Register B with 10H, the 16 bytes of the line.
513F
GOSUB to 5163H to display the space or the mark before the byte at Register Pair HL.
5142
LD A,(4285H) 3A 85 42
Load Register A with the form of the bytes from 4285H.
5145
CP 41H FE 41
Compare Register A against 41H (A), bytes as characters.
5147
If the NZ FLAG is set (hexadecimal), JUMP to 515CH with the NZ FLAG for the CALL there.
5149
GOSUB to 51ECH to display a space before the character.
514C
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL.
514D
CP 20H FE 20
Compare Register A against 20H, the first character that can be shown.
514F
If the C FLAG is set (a control code), JUMP to 5155H to show a dot.
5151
CP C0H FE C0
Compare Register A against C0H, the first space compression code.
5153
If the C FLAG is set (a character or a graphic), JUMP to 5157H to show it.
5155
LD A,2EH 3E 2E
Load Register A with 2EH, a dot in place of a byte that cannot be shown.
5157
GOSUB to 0033H in the ROM to display the character in Register A.
515A
INC HL 23
INCrement Register Pair HL by 1 to the next byte.
515B
XOR A AF
Set Register A to 00H by XORing it with itself, which sets the Z FLAG so the CALL below is not made.
515C
If the NZ FLAG is set (hexadecimal), GOSUB to 51CFH to display the byte at Register Pair HL as two digits, Register Pair HL moving on by 1.
515F
DECrement Register B and loop back to 513FH while Register B is not zero.
5161
POP BC C1
Restore Register Pair BC from the top of the stack, the caller's count.
5162
RET C9
RETurn with the line displayed and Register Pair HL 16 bytes on.
5163
LD DE,(4268H) ED 5B 68 42
Load Register Pair DE with the address of the M command from 4268H.
5167
PUSH HL E5
Save Register Pair HL, the byte's address, to the top of the stack.
5168
SCF 37
Set the C FLAG, so the SBC below subtracts 1 more from Register Pair HL.
5169
SBC HL,DE ED 52
SUBtract Register Pair DE and the C FLAG from Register Pair HL: 0000H when the byte follows the M command's byte.
516B
LD A,85H 3E 85
Load Register A with 85H, the graphic that marks the right side of the M command's byte.
516D
If the Z FLAG is set (the byte after the M address), JUMP to 517DH to display it in place of the space.
516F
GOSUB to 5181H to display the extra space before the ninth byte.
5172
INC HL 23
INCrement Register Pair HL by 1: 0000H when the byte is the M command's.
5173
LD A,L 7D
Load Register A with Register L, the low byte of the difference.
5174
OR H B4
OR Register A with Register H: the Z FLAG for the M command's byte.
5175
POP HL E1
Restore Register Pair HL from the top of the stack: the byte's address.
5176
LD A,8AH 3E 8A
Load Register A with 8AH, the graphic that marks the left side of the M command's byte.
5178
If the Z FLAG is set (the M command's byte), JUMP to 0033H in the ROM to display Register A (8AH), which returns to the caller.
517B
JUMP to 5185H to display a space before the byte.
517D
GOSUB to 0033H in the ROM to display the graphic in Register A (85H).
5180
POP HL E1
Restore Register Pair HL from the top of the stack: the byte's address.
5181
LD A,B 78
Load Register A with Register B, the bytes of the line still to show.
5182
CP 08H FE 08
Compare Register A against 08H: the ninth byte gets an extra space before it.
5184
RET NZ C0
If the NZ FLAG is set (another byte), RETurn without the extra space.
5185
JUMP to 51ECH to display a space, which returns to the caller.

5187H - Reading a Key

Waits for a key (ROM 0049H) and returns it in Register A. ENTER returns the Z FLAG and the C FLAG without displaying it; a comma or a space is displayed and returns the Z FLAG; any other key is displayed and returns the NZ FLAG, letters as capitals. Register Pair DE is kept.

5187
PUSH DE D5
Save Register Pair DE to the top of the stack.
5188
GOSUB to 0049H in the ROM to wait for a key: Register A = the key.
518B
POP DE D1
Restore Register Pair DE from the top of the stack.
518C
CP 0DH FE 0D
Compare Register A against 0DH, ENTER, the key that ends a command.
518E
SCF 37
Set the C FLAG for ENTER; the Z FLAG from the compare is kept.
518F
RET Z C8
If the Z FLAG is set (ENTER), RETurn with the Z FLAG and the C FLAG set.
5190
PUSH DE D5
Save Register Pair DE to the top of the stack.
5191
GOSUB to 0033H in the ROM to display the key in Register A.
5194
POP DE D1
Restore Register Pair DE from the top of the stack.
5195
CP 2CH FE 2C
Compare Register A against 2CH, a comma, which separates the values.
5197
RET Z C8
If the Z FLAG is set (a comma), RETurn with the Z FLAG and the NC FLAG.
5198
CP 20H FE 20
Compare Register A against 20H, a space, which separates the values.
519A
RET Z C8
If the Z FLAG is set (a space), RETurn with the Z FLAG and the NC FLAG.
519B
CP 41H FE 41
Compare Register A against 41H (A): the C FLAG for a key below the letters.
519D
CCF 3F
Complement the C FLAG: the NC FLAG for a key below the letters.
519E
RET NC D0
If the NC FLAG is set (a digit or a sign), RETurn with the NZ FLAG and Register A as typed.
519F
AND 5FH E6 5F
AND Register A with 5FH: a lower case letter becomes a capital (the C FLAG is cleared).
51A1
RET C9
RETurn with the NZ FLAG and the NC FLAG and Register A = the letter.

51A2H - Reading a Hexadecimal Number

Reads hexadecimal digits into Register Pair HL until ENTER, a space or a comma. With no digit before the separator the Z FLAG returns and Register Pair HL is kept. With digits the NZ FLAG returns, with the C FLAG when ENTER ended them (the RRA / ADC A,81H at 51BAH turns the C FLAG of 5187H into that result). A key that is not a digit goes back to the command loop at 4E52H.

51A2
GOSUB to 5187H to read the first key into Register A.
51A5
RET Z C8
If the Z FLAG is set (a separator at once), RETurn with the Z FLAG and Register Pair HL kept.
51A6
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H, the number so far.
51A9
GOSUB to 51BEH to turn the key in Register A into its value, 0-15; the C FLAG when it is not a hexadecimal digit.
51AC
If the C FLAG is set (not a digit), JUMP to 4E52H, the command loop, which resets the Stack Pointer.
51AF
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 2.
51B0
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 4.
51B1
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 8.
51B2
ADD HL,HL 29
ADD Register Pair HL to itself: the number times 16, the low four bits 0.
51B3
ADD A,L 85
ADD Register L to Register A, the digit's value.
51B4
LD L,A 6F
Load Register L with Register A: the digit is the low four bits of Register Pair HL.
51B5
GOSUB to 5187H to read the next key into Register A.
51B8
If the NZ FLAG is set (not a separator), JUMP back to 51A9H for the next digit.
51BA
RRA 1F
Rotate Register A right through the C FLAG: the C FLAG from 5187H (set for ENTER) goes into bit 7.
51BB
ADC A,81H CE 81
ADD 81H and the C FLAG (bit 0 of the separator) to Register A: the C FLAG for ENTER (0DH), the NC FLAG for a space or comma, the NZ FLAG for all three.
51BD
RET C9
RETurn with Register Pair HL = the number, the NZ FLAG, and the C FLAG when ENTER ended it.
51BE
SUB 30H D6 30
SUBtract 30H, the digit 0, from the character in Register A.
51C0
RET C D8
If the C FLAG is set (below 0), RETurn with the C FLAG: not a hexadecimal digit.
51C1
ADD A,E9H C6 E9
ADD E9H to Register A: the C FLAG for a character from G (47H) up.
51C3
RET C D8
If the C FLAG is set (G or higher), RETurn with the C FLAG: not a hexadecimal digit.
51C4
ADD A,06H C6 06
ADD 06H to Register A: the C FLAG for A to F.
51C6
If the C FLAG is set (A to F), JUMP to 51CBH.
51C8
ADD A,07H C6 07
ADD 07H to Register A: the C FLAG for the characters : to @ between 9 and A.
51CA
RET C D8
If the C FLAG is set (: to @), RETurn with the C FLAG: not a hexadecimal digit.
51CB
ADD A,0AH C6 0A
ADD 0AH to Register A: Register A = the digit's value, 0-15.
51CD
OR A B7
OR Register A with itself to clear the C FLAG: a hexadecimal digit.
51CE
RET C9
RETurn with Register A = the value and the NC FLAG.

51CFH - Displaying Numbers and Characters

51CFH displays the byte at Register Pair HL in hexadecimal and moves Register Pair HL on; 51D3H displays Register Pair HL as four digits; 51D8H Register A as two digits; 51E1H the low four bits of Register A as one digit; 51ECH a space; 51F0H a carriage return; 51F4H the three characters at Register Pair HL, which moves on 3. All display through the ROM's 0033H.

51CF
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL.
51D0
INC HL 23
INCrement Register Pair HL by 1 to the next byte.
51D1
JUMP to 51D8H to display Register A as two hexadecimal digits.
51D3
LD A,H 7C
Load Register A with Register H, the high byte.
51D4
GOSUB to 51D8H to display Register A as two hexadecimal digits.
51D7
LD A,L 7D
Load Register A with Register L, the low byte, and go on to display it.
51D8
PUSH AF F5
Save Register Pair AF, the byte, to the top of the stack.
51D9
RRA 1F
Rotate Register A right one bit (the high four bits move towards bits 3-0).
51DA
RRA 1F
Rotate Register A right one bit (the high four bits move towards bits 3-0).
51DB
RRA 1F
Rotate Register A right one bit (the high four bits move towards bits 3-0).
51DC
RRA 1F
Rotate Register A right one bit: the high four bits are in bits 3-0.
51DD
GOSUB to 51E1H to display the high digit of Register A.
51E0
POP AF F1
Restore Register Pair AF from the top of the stack: the byte again, for its low digit.
51E1
AND 0FH E6 0F
AND Register A with 0FH to keep the digit, 0-15.
51E3
ADD A,90H C6 90
ADD 90H to Register A, the first step of the digit conversion.
51E5
DAA 27
Decimal adjust Register A: 90H-99H for 0-9, 00H-05H with the C FLAG for 10-15.
51E6
ADC A,40H CE 40
ADD 40H and the C FLAG to Register A, the second step of the conversion.
51E8
DAA 27
Decimal adjust Register A: the ASCII digit, 30H-39H or 41H-46H.
51E9
JUMP to 0033H in the ROM to display the character in Register A, which returns to the caller.
51EC
LD A,20H 3E 20
Load Register A with 20H, a space, to display.
51EE
JUMP back to 51E9H to display the space in Register A.
51F0
LD A,0DH 3E 0D
Load Register A with 0DH, a carriage return, to display.
51F2
JUMP back to 51E9H to display the carriage return in Register A.
51F4
GOSUB to 51FAH to display the first character at Register Pair HL.
51F7
GOSUB to 51FAH to display the second character at Register Pair HL.
51FA
LD A,(HL) 7E
Load Register A with the character at Register Pair HL.
51FB
INC HL 23
INCrement Register Pair HL by 1 to the next character.
51FC
JUMP back to 51E9H to display the character in Register A. 51FDH is the last byte of SYS6/SYS.