LS-DOS 6.3.1 for the Model 4 - SYS5/SYS Disassembled

Page Customization

Introduction/Summary

LS-DOS 6.3.1 SYS5/SYS Disassembly (Model 4)

SYS5/SYS is the system debugger of LS-DOS 6.3.1, the "ghost" debugger that the DEBUG command turns on and @DEBUG (SVC 27) calls. It is a load module of 1536 bytes, 1471 of them loaded: 1469 at 1E00H-23BCH and the length word at 23FEH-23FFH, with its transfer address at 1E00H. It keeps everything it remembers in DBGSV$, the 32 bytes at 00A0H-00BFH in the resident system's low memory, which no file loads (00A0H). The extended commands of DEBUG (EXT) are not here: SYS9/SYS puts them in high memory, and SYS5 hands every key it does not know to them through EXTDBG$, as the key less 30H (22DBH).

Every way into the debugger goes through @DEBUG at 19A0H on the SYS0/SYS page, which pushes Register Pair AF and sends request 97H: a breakpoint or any RST 30H, since 0030H jumps to 19A0H; SVC 27, which arrives with Register A holding the program's Register C; the BREAK key, when @DBGHK at 199FH holds 00H (DEBUG on) and BREAK is not disabled; @RUN, which jumps to 0030H with the transfer address on the stack when SFLAG$ bit 7 (DEBUG on) is set and the file is not execute only; and the D key held down at boot. RST28 sets @DBGHK to C9H while it loads SYS5, so BREAK cannot enter it again while it runs; SYS5 never returns through RST28, and G sets @DBGHK to 00H when it lets the program go on (1F9CH). The entry saves every register of the program in DBGSV$, its Program Counter being the return address on the stack, and puts back the bytes of the two breakpoints (1E00H, 1E32H).

The display fills the first 16 rows of the screen (1ED5H). In the register display the rows are af, bc, de, hl, af', bc', de', hl', ix, iy, sp and pc, each with its value, then the eight flags for af and af' or the 16 bytes the register pair points to, in hex and in ASCII, and four lines of memory from the display address. In the full screen display all 16 rows are one page of memory. The byte at the modification address is framed by two graphic bars (2173H). The commands are typed on row 16; letters may be typed in either case, nothing can be taken back, and a character that is not a hex digit where a number is wanted ends the command (1E4CH, 21C9H).

CommandWhat SYS5 does
GG address,breakpoint,breakpoint and ENTER: go on at the address, or at the Program Counter when none is given, with up to two breakpoints (1F82H).
I, CRun one instruction. I steps into a CALL and into an RST to 00H-20H; C runs them in full (208BH).
JMove the Program Counter on by one byte (22ABH).
RR, a register pair's name, a space and a hex value: change the register pair, sp and pc included (203FH).
A, HA or H, an address and a space: modify memory from that address in ASCII or in hex (1FD6H).
DD and an address: show memory from it (1EABH).
Semicolon, minusMove the memory display on or back by 64 bytes, or by 256 in the full screen display (1EB1H).
S, XThe full screen display, and back to the register display (1E9CH).
UDraw the display again and again until a key is pressed (1EA1H).
BB source,destination,length: move a block, the length 256 by default (223FH).
FF first,last,byte: fill memory (228BH).
QQ port and ENTER reads a port, Q port,byte writes one (22B7H).
OO and ENTER: leave for LS-DOS Ready through @EXIT (1ECEH).
0 to 7drive,cylinder,sector,operation,address,count: read (R) or write (W, or the asterisk sign for the directory's data mark) disk sectors (22DFH).
Any other keyHanded to the extended debugger of SYS9 (E, L, N, P, T, V and W) when DEBUG (EXT) has installed it; otherwise nothing happens (22DBH).

A breakpoint is an F7H byte, RST 30H, put over the first byte of an instruction; its address and the byte it replaced are kept in one of two save areas of three bytes in DBGSV$ (1FC5H). When the program reaches it, the entry sees the F7H before the return address, moves the Program Counter back onto it and puts the byte back. The single step commands find the length and the kind of the instruction in three tables (211FH), put a breakpoint after it and, for a jump, a return or a call, a second one on its target, and let the program run.

The bytes are those of the LS-DOS 6.3.1 level 1H system diskette. The labels are those of the LS-DOS 6.3.1 source code of SYS5 (SYS5/ASM, which brings in the code of SYS5A/ASM), which assembles to this file byte for byte. The 6.3.0 source has the same code, with a four byte print routine for SYS9 (@PRTBYT) at 23BDH that 6.3.1 moved into SYS9.

Notes

The manual marks B, F, J, O, Q and the disk utility as commands of the Model I and III extended debugger; on the Model 4 they are part of SYS5, and the Model 4's extended commands are E, L, N, P, T, V and W. R accepts pc, which the manual says cannot be changed with R. With A, a space or a comma moves on to the next byte, so neither can be stored. The disk utility needs a separator and an address after the operation; when no sector is given the count is a whole cylinder, but when a sector is given and the count is not, only that sector is done, where the manual says a whole cylinder. The manual's example of a directory write, which leaves out the sector field, ends at the asterisk sign as a bad digit. On an error the disk utility waits for a key at once: ENTER ends the work and any other key goes on.

The TRM says of @DEBUG that ENTER continues the program and that the SVC does not return unless (E) is entered in DEBUG: in SYS5 ENTER alone does nothing, and G and ENTER goes on after the RST 28H, with or without the extended debugger. After SVC 27 the debugger shows, and G gives back, the program's Register C in Register A, which the SVC dispatcher copied there.

The first six bytes of DBGSV$ are both the variables of the commands and the two breakpoint save areas. Each entry zeroes their address bytes, so the display goes back to the register display and the modification address to 0000H every time the debugger is entered; and whatever A, H, S, B or a disk read left in them is taken as a breakpoint address at the next entry (B32). Function 0 of SYS5 (request 87H) only loads it, and nothing sends it. In the DOS's memory map all 64K are RAM, so the test that refuses a breakpoint outside RAM fails only where a program has the keyboard switched in. Breakpoints in a program that leaves through an SVC that does not return stay in memory as F7H bytes.

The routines named with an at sign (INPUT@, HEXIN@, CV2HEX@, WR1HEX@, WR2HEX@, WRSPA@, DSPASC@ and GETASC@) are called by SYS9's extended commands while SYS5 is in the overlay area. There are no hidden instructions. One instruction is changed while SYS5 runs: GETASC@ turns the SET 5,A of INPUC@ (21D5H) into BIT 5,A while an ASCII character is typed, and back.

Bugs (listed on the LS-DOS reference page): B31, single stepping a JP (IX) puts the breakpoint at the address in Index Register IY, because the test for DDH or FDH looks at the second byte, E9H, so the program runs on and an F7H is written wherever IY points (210EH); B32, the breakpoint save areas are the same bytes as the modification address, the display mode and the A or H letter, so after G, I or C with fewer than two breakpoints an F7H at one of those addresses is replaced by a stale byte at the next entry, an RST 30H planted with H among them (1E32H); B33, every entry with an F7H just before the return address is taken as a breakpoint, so a BREAK right after an instruction ending in F7H (AND 0F7H, SET 6,A) moves the Program Counter back into it and G enters the debugger again at once (1E2BH); B34, F uses the borrow of each compare in the next, so F a,a,b fills nothing and a fill up to FFFFH never ends (22A3H); B35, the display is laid out with tab codes, which show as characters after a program has turned on the video driver's special characters (1ED5H); B36, the closing bar of a byte at the end of a memory line is shown at the start of the next line that begins at the next address (21B8H); B37, a disk operation with no address uses the last number typed, the sector or the cylinder, as the buffer, or 124CH, inside the resident system, when neither was typed (2335H); B38, I and C go on without the store of 00H into @DBGHK that G makes, so BREAK cannot enter the debugger while a stepped call runs in full or a stepped program runs away (20F6H); B39, a branch to itself (DJNZ $, JR cc,$) gets its second breakpoint on its own first byte, so I and C can never get past it (211AH).

Variables

Memory Used by SYS5/SYS

Address
Size
Contents
000BH-000DH
3 bytes
SVCRET$, LSVC$
Changed by the RST 28H calls of @VDCTL at 1E5AH, 1FEEH and 1FFDH, which the SVC dispatcher stores as the last SVC.
00A0H
1 byte
SAVONE
The letter of A or H (1FD6H); the low byte of the second breakpoint's address (1FD3H), zeroed at every entry (1E39H).
00A1H
1 byte
SAVTWO
The display mode, 00H registers, 73H full screen (1E9DH, 2377H); the high byte of the second breakpoint's address, zeroed at every entry.
00A2H
1 byte
SAVTWO+1
The sectors of a cylinder of the disk utility (2305H); the byte the second breakpoint replaced.
00A3H-00A4H
2 bytes
NXTADR
The modification address of A and H, the destination of B, the buffer of a disk read (1FDFH, 225DH, 2372H); the first breakpoint's address, zeroed at every entry.
00A5H
1 byte
NXTBYT
The sector count of the disk utility (2328H); the byte the first breakpoint replaced.
00A6H-00A7H
2 bytes
DSPADR
The first address of the memory display (1EC5H, 224AH, 236FH).
00A8H-00BBH
20 bytes
AFREG to IYREG
The program's AF, BC, DE, HL, AF', BC', DE', HL', IX and IY (1E20H), loaded again by G (1F9FH).
00BCH-00BDH
2 bytes
SPREG, REGSAV
The program's Stack Pointer (1E22H), the stack of every command (1E4CH).
00BEH-00BFH
2 bytes
PCREG
The program's Program Counter (1E20H, 1E2FH, 1F8CH, 22B3H).
199FH
1 byte
@DBGHK
Set to 00H by G only, so that BREAK enters the debugger (1F9CH); I and C leave the C9H that RST28 put there (20F6H).
19A4H-19A5H
2 bytes
EXTDBG$
The extended debugger's vector, ORARET@ (1503H) until DEBUG (EXT) (22DBH).
21D6H
1 byte
INPUC@+1
EFH (SET 5,A), 6FH (BIT 5,A) while GETASC@ reads a character (2035H, 203AH).
23FEH-23FFH
2 bytes
Overlay length
05BDH, the length of SYS5 read by SYSTEM (SYSRES).

Routines of Other Files Called

AddressRoutine
0628H@KEY (BOOT/SYS): waits for a key (21CAH).
0635H@KBD (BOOT/SYS): scans the keyboard without waiting (1EA1H).
0642H@DSP (BOOT/SYS): shows a character or sends a video code; every character of the display goes through it.
0B99H@VDCTL (BOOT/SYS), through RST 28H with SVC 15: function 3 sets the cursor (1E5AH, 1FEEH, 1FFDH).
1503HORARET@ (SYS0/SYS), through EXTDBG$: OR A and RET for an unknown command (22DEH).
19E8H, 19ECH, 19F4H@WRSEC, @WRSSC and @RDSEC (SYS0/SYS): write a sector, write one with the directory's data mark, read one (2396H, 239DH, 238BH).
1A1EH@GTDCT (SYS0/SYS): the DCT of a drive in Index Register IY (22E6H).
1B0BH@EXIT (SYS0/SYS): back to LS-DOS Ready (1ED2H).

Disassembly

00A0H - DBGSV$: the Debugger's Save Area

SYS5/SYS keeps everything it remembers in DBGSV$, the 32 bytes at 00A0H-00BFH of the resident system's low memory, which no file loads. The first six bytes do two jobs. While the debugger waits for a command they are its variables: the command letter of A or H, the full screen flag, the sectors per cylinder of the disk utility, the memory modification address and the sector count. While the program runs they are the two breakpoint save areas, each an address and the byte that a breakpoint replaced: 00A3H-00A5H for the first breakpoint (the next instruction of a single step), 00A0H-00A2H for the second (the target of a jump, a call, a return or an RST). Each entry to the debugger reads both areas, puts the saved byte back wherever an F7H (RST 30H) still sits at the address, and sets both addresses to zero, so the modification address and the full screen flag start again at zero after every entry; whatever a command left in them before the next G, I or C is taken as a breakpoint at the next entry (B32). The other 26 bytes hold the registers of the program that was stopped, in the order the entry pushed them.

00A0SAVONE
DEFS 1
SAVONE, 00A0H: the letter of the last A or H command (61H or 68H), which decides whether the modify line shows and takes ASCII or hex (1FD6H, 2013H, 2029H). Also the low byte of the address held in the second breakpoint save area.
00A1SAVTWO
DEFS 1
SAVTWO, 00A1H: the display mode, 00H for the register display and non zero (73H) for the full screen display (1E9DH, 1EDFH, 2377H). Also the high byte of the address held in the second breakpoint save area.
00A2
DEFS 1
SAVTWO+1, 00A2H: the sectors per cylinder of the drive of the disk utility (2305H). Also the byte that the second breakpoint replaced.
00A3-00A4NXTADR
DEFS 2
NXTADR, 00A3H-00A4H: the memory modification address of A and H, the destination of B and the buffer of a disk read, framed by the two graphic bars in the display (1FDFH, 21A4H, 225DH, 2372H). Also the address held in the first breakpoint save area.
00A5NXTBYT
DEFS 1
NXTBYT, 00A5H: the sector count of the disk utility (2328H, 2343H, 2363H). Also the byte that the first breakpoint replaced.
00A6-00A7DSPADR
DEFS 2
DSPADR, 00A6H-00A7H: the first address of the memory display, four lines in the register display and one page of 256 bytes in the full screen display (1EC5H, 1F33H, 1F4DH).
00A8-00A9AFREG
DEFS 2
AFREG, 00A8H-00A9H: Register Pair AF of the program, the flags in 00A8H and Register A in 00A9H, the first of the twelve register pairs that the entry copies here (1E20H).
00AA-00AB
DEFS 2
AFREG+2, 00AAH-00ABH: Register Pair BC of the program, shown as bc and set by R bc (2087H, 2089H).
00AC-00AD
DEFS 2
AFREG+4, 00ACH-00ADH: Register Pair DE of the program, shown as de and set by R de.
00AE-00AFHLREG
DEFS 2
HLREG, 00AEH-00AFH: Register Pair HL of the program, which G loads last (1FC1H) and JP (HL) single stepping reads (2117H).
00B0-00B7
DEFS 8
AFREG+8, 00B0H-00B7H: the alternate Register Pairs AF', BC', DE' and HL' of the program, in that order.
00B8-00B9IXREG
DEFS 2
IXREG, 00B8H-00B9H: Index Register IX of the program, read when a JP (IX) is single stepped (210BH).
00BA-00BBIYREG
DEFS 2
IYREG, 00BAH-00BBH: Index Register IY of the program, read when a JP (IY) is single stepped, and for a JP (IX) as well (2112H, B31).
00BCSPREG
DEFS 1
SPREG, 00BCH: the low byte of the Stack Pointer of the program (the source gives SPREG one byte and REGSAV the next); the entry stores the whole word at 00BCH-00BDH (1E22H) and every command starts on that stack (1E4CH).
00BDREGSAV
DEFS 1
REGSAV, 00BDH: the high byte of the program's Stack Pointer, where G starts to push the save area back onto the stack (1F9FH).
00BE-00BFPCREG
DEFS 2
PCREG, 00BEH-00BFH: the Program Counter of the program, the address where G and the single step commands go on; G with an address and J change it, and so does R pc (1F8CH, 22B3H).

1E00H - SYS5: Entry and Register Save

The debugger is entered through @DEBUG at 19A0H on the SYS0/SYS page: PUSH AF, LD A,97H, RST 28H. Every way in ends there: RST 30H (a breakpoint, or an RST 30H in a program) jumps to 19A0H from 0030H; SVC 27 reaches it through the SVC table with Register A holding the program's Register C; the BREAK key reaches it from the task processor (EXITBRK, 1C8EH) when @DBGHK is 00H; @RUN jumps to 0030H with the program's transfer address on the stack when SFLAG$ bit 7 (DEBUG on) is set; and the D key held at boot jumps to 19A0H with @ABORT's address on the stack. RST28 sets @DBGHK to C9H, so BREAK cannot enter the debugger again while it runs, loads SYS5 and calls 1E00H. The stack then holds RST28's return address 1A77H, the Register Pair AF that @DEBUG pushed and the program's return address, the Program Counter the debugger shows. SYS5 never goes back through RST28: it drops that address, pushes every register and copies them all into the save area at 00A8H.

1E00SYS5
AND 70H E6 70
SYS5: mask Register A, the request from RST28 (87H or 97H), with 70H, keeping the function number times 10H in bits 6-4.
1E02
RET Z C8
Return at once if Register A is 00H: function 0 (request 87H) only gets SYS5 loaded. No SVC stub and no file of the 6.3.1 source sends it; @DEBUG sends 97H and every other function is taken as an entry to the debugger.
1E03
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer) to drop RST28's return address 1A77H: the debugger never returns into RST28, so the tail that would set @DBGHK back is never run.
1E04
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): the Register Pair AF that @DEBUG pushed at 19A0H, the program's own; for SVC 27, Register A is the program's Register C and the flags are those SVCUSER left (its CP 1AH and RLCA).
1E05
PUSH AF F5
Push Register Pair AF back onto the stack (Stack Pointer), above the other registers; it is copied into the save area and then written over by the Stack Pointer at 1E22H.
1E06
PUSH IY FD E5
Push Index Register IY onto the stack (Stack Pointer): it is copied to IYREG (00BAH).
1E08
PUSH IX DD E5
Push Index Register IX onto the stack (Stack Pointer): it is copied to IXREG (00B8H).
1E0A
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF' to push the program's alternate set next.
1E0B
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the program's BC', DE' and HL' are now the main registers.
1E0C
PUSH HL E5
Push Register Pair HL (the program's alternate HL') onto the stack (Stack Pointer); it is copied to 00B6H.
1E0D
PUSH DE D5
Push Register Pair DE (the program's alternate DE') onto the stack (Stack Pointer); it is copied to 00B4H.
1E0E
PUSH BC C5
Push Register Pair BC (the program's alternate BC') onto the stack (Stack Pointer); it is copied to 00B2H.
1E0F
PUSH AF F5
Push Register Pair AF (the program's alternate AF') onto the stack (Stack Pointer); it is copied to 00B0H.
1E10
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF' again, bringing back the program's main Register Pair AF.
1E11
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX) again: the program's main registers are back.
1E12
PUSH HL E5
Push Register Pair HL (the program's) onto the stack (Stack Pointer); it is copied to HLREG (00AEH).
1E13
PUSH DE D5
Push Register Pair DE (the program's) onto the stack (Stack Pointer); it is copied to 00ACH.
1E14
PUSH BC C5
Push Register Pair BC (the program's) onto the stack (Stack Pointer); it is copied to 00AAH.
1E15
PUSH AF F5
Push Register Pair AF (the program's) onto the stack (Stack Pointer), the last of the 24 bytes; it is copied to AFREG (00A8H).
1E16
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H to take the value of the Stack Pointer in the next instruction.
1E19
ADD HL,SP 39
Add the Stack Pointer to Register Pair HL: Register Pair HL points to the 22 bytes just pushed and, above them, the return address that was already on the stack, Register Pair AF first.
1E1A
LD DE,00A8H 11 A8 00LD DE,AFREG
Point Register Pair DE at 00A8H (AFREG), the register save area in DBGSV$.
1E1D
LD BC,0018H 01 18 00
Load Register Pair BC with 0018H, the 24 bytes of the twelve words: AF, BC, DE, HL, AF', BC', DE', HL', IX, IY, AF again and the Program Counter.
1E20
LDIR ED B0
Copy the 24 bytes from Register Pair HL (the stack) to Register Pair DE (00A8H-00BFH), Register Pair BC counting them (LDIR): the Program Counter lands in PCREG (00BEH).
1E22
LD (00BCH),HL 22 BC 00LD (SPREG),HL
Store Register Pair HL, now the Stack Pointer plus 24, at 00BCH (SPREG): the program's Stack Pointer as it was before the RST 30H or the call, written over the second copy of Register Pair AF.
1E25
LD SP,HL F9
Load the Stack Pointer from Register Pair HL: the debugger runs on the program's stack, below the program's Stack Pointer, and the 24 bytes are dropped.
1E26
LD HL,(00BEH) 2A BE 00LD HL,(PCREG)
Load Register Pair HL with PCREG (00BEH), the address the debugger was entered from, the Program Counter of the program.
1E29
DEC HL 2B
Decrement Register Pair HL to the byte before the Program Counter, where a breakpoint's RST 30H would be.
1E2A
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the byte just before the Program Counter.
1E2B
CP F7H FE F7
Compare Register A with F7H, the RST 30H that a breakpoint plants. Any F7H there counts, also one that is the last byte of an instruction such as AND 0F7H or SET 6,A when the entry came from BREAK or from @RUN (B33).
1E2D
Jump to 1E32H if Register A is not F7H: the entry was not a breakpoint and the Program Counter stays.
1E2F
LD (00BEH),HL 22 BE 00LD (PCREG),HL
Store Register Pair HL at 00BEH (PCREG): after a breakpoint the Program Counter is moved back onto the F7H, the address of the instruction whose first byte the breakpoint replaced, which 1E32H puts back.
1E32
LD HL,00A0H 21 A0 00LD HL,SAVONE
Point Register Pair HL at 00A0H (SAVONE), the second breakpoint save area; the first follows it at 00A3H. The two areas are the same bytes as the variables SAVONE, SAVTWO, SAVTWO+1, NXTADR and NXTBYT (B32).
1E35
LD B,02H 06 02
Load Register B with 02H, the count of the two breakpoint save areas of three bytes each.
1E37
XOR A AF
Clear Register A to 00H, to zero the address of the save area as it is read.
1E38
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of the address the breakpoint was put at.
1E39
LD (HL),A 77
Store Register A (00H) at Register Pair HL, zeroing the low byte of the address the save area holds.
1E3A
INC HL 23
Increment Register Pair HL to the high byte of the save area's address.
1E3B
LD D,(HL) 56
Load Register D with the byte at Register Pair HL: Register Pair DE is the address of the breakpoint, or 0000H for none.
1E3C
LD (HL),A 77
Store Register A (00H) at Register Pair HL, zeroing the high byte of the address the save area holds.
1E3D
INC HL 23
Increment Register Pair HL to the third byte of the save area, the byte the breakpoint replaced.
1E3E
LD A,E 7B
Load Register A with Register E, the low byte of the breakpoint's address, to test Register Pair DE for zero.
1E3F
OR D B2
OR Register A with Register D: Zero when Register Pair DE is 0000H, a save area holding no breakpoint.
1E40
Jump to 1E49H if Register Pair DE was 0000H: there is nothing to put back.
1E42
LD A,(DE) 1A
Load Register A with the byte at Register Pair DE, the address of the breakpoint.
1E43
CP F7H FE F7
Compare Register A with F7H (RST 30H): the byte is put back only if the breakpoint is still there.
1E45
Jump to 1E49H if Register A is not F7H: the program has changed the byte, or the area holds an address that a command left there and no breakpoint was set.
1E47
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the program byte that the breakpoint replaced.
1E48
LD (DE),A 12
Store Register A at Register Pair DE, putting the program byte back over the F7H. When the area held a variable instead (the modification address, the full screen flag), any F7H byte at that address is replaced by a stale byte (B32).
1E49
INC HL 23
Increment Register Pair HL past the saved byte to the next save area (00A3H after the first pass).
1E4A
Decrement Register B and jump back to 1E37H for the second save area until Register B is 0.

1E4CH - CMND: the Command Loop

Every command starts here: the stack is set back to the program's Stack Pointer, the display is drawn again from the save area and the cursor goes to row 16, column 0, under the 16 rows of the display. INPUT@ reads one key and shows it, with letters made lower case, so the commands may be typed in either case. G is taken at once; for every other command 1E4CH is pushed as the return address, so a command ends with RET, and one that meets a bad hexadecimal digit jumps straight back here. The commands of SYS5 are G, S, semicolon, minus, O, C, D, I, A, H, R, U, X, then B, F, J, Q and the digits 0 to 7 (the disk utility); any other key is handed to EXTDBG$, the extended debugger of SYS9 when DEBUG (EXT) has installed it, else ORARET@, which does nothing.

1E4CCMND
LD SP,(00BCH) ED 7B BC 00LD SP,(SPREG)
CMND: load the Stack Pointer from 00BCH (SPREG), the program's Stack Pointer, throwing away whatever the last command left on the stack.
1E50
Call 1ED5H (WRREGS) to draw the display: the twelve register pairs and four lines of memory, or sixteen lines of memory in the full screen mode.
1E53
LD HL,1000H 21 00 10
Load Register Pair HL with 1000H: Register H the row 16, Register L the column 0, the line under the display.
1E56
LD B,03H 06 03
Load Register B with 03H, function 3 of @VDCTL: set the cursor to the row in Register H and the column in Register L.
1E58
LD A,0FH 3E 0F
Load Register A with 0FH, SVC 15, @VDCTL, the video control SVC.
1E5A
RST 28H EF
Call @VDCTL with RST 28H to move the cursor to row 16, column 0 (the SVC dispatcher stores 15 as the last SVC in LSVC$).
1E5B
Call 21C9H (INPUT@) to read the command key into Register A, shown on the screen and made lower case; Zero for a space or a comma, Carry for ENTER.
1E5E
CP 67H FE 67
Compare Register A with 67H, g: G, go to an address with up to two breakpoints.
1E60
Jump to 1F82H (CMD_G) if Register A is g; G does not return here, so no return address is pushed for it.
1E63
LD HL,1E4CH 21 4C 1ELD HL,CMND
Point Register Pair HL at 1E4CH (CMND), the return address for every other command.
1E66
PUSH HL E5
Push Register Pair HL (1E4CH) onto the stack (Stack Pointer): each command below ends with RET into the command loop.
1E67
CP 73H FE 73
Compare Register A with 73H, s: S, the full screen display mode.
1E69
Jump to 1E9DH (CMD_S) if Register A is s; Register A (73H) is stored as the non zero full screen flag.
1E6B
CP 3BH FE 3B
Compare Register A with 3BH, the semicolon: advance the memory display.
1E6D
Jump to 1EB1H (CMD_INC) if Register A is the semicolon: 64 bytes on in the register display, 256 in the full screen.
1E6F
CP 2DH FE 2D
Compare Register A with 2DH, the minus sign: move the memory display back.
1E71
Jump to 1EC9H (CMD_DEC) if Register A is the minus sign: 64 bytes back, or 256 in the full screen.
1E73
CP 6FH FE 6F
Compare Register A with 6FH, o: O, leave the debugger for the DOS.
1E75
Jump to 1ECEH (CMD_O) if Register A is o; it waits for ENTER first.
1E77
CP 63H FE 63
Compare Register A with 63H, c: C, single step that runs a CALL in full.
1E79
Jump to 1E81H if Register A is c, where the Zero flag still set takes the JP Z to 208BH.
1E7B
CP 64H FE 64
Compare Register A with 64H, d: D, show memory from an address.
1E7D
Jump to 1EABH (CMD_D) if Register A is d, to set the display address.
1E7F
CP 69H FE 69
Compare Register A with 69H, i: I, single step into a CALL.
1E81CMD_C
CMD_C: jump to 208BH (CMD_CI) if the Zero flag is set, for I or C; Register A tells them apart there.
1E84
CP 61H FE 61
Compare Register A with 61H, a: A, modify memory in ASCII.
1E86
Jump to 1FD6H (CMD_AH) if Register A is a, to modify memory in ASCII.
1E89
CP 68H FE 68
Compare Register A with 68H, h: H, modify memory in hex.
1E8B
Jump to 1FD6H (CMD_AH) if Register A is h; Register A is kept there as the mode.
1E8E
CP 72H FE 72
Compare Register A with 72H, r: R, give a register pair a new value.
1E90
Jump to 203FH (CMD_R) if Register A is r, to change a register pair.
1E93
CP 75H FE 75
Compare Register A with 75H, u: U, draw the display again and again until a key is pressed.
1E95
Jump to 1EA1H (CMD_U) if Register A is u, to redraw until a key comes.
1E97
CP 78H FE 78
Compare Register A with 78H, x: X, back to the register display.
1E99
Jump to 223FH (BLOCK) if Register A is not x, to try B, F, J, Q, the disk utility and the extended debugger.
1E9CCMD_X
XOR A AF
CMD_X: clear Register A to 00H, the flag of the register display mode.
1E9DCMD_S
LD (00A1H),A 32 A1 00LD (SAVTWO),A
CMD_S: store Register A at 00A1H (SAVTWO): 00H from X for the register display, 73H from S for the full screen. The next entry to the debugger zeroes it again (1E3CH).
1EA0
RET C9
Return to the command loop at 1E4CH, which draws the display in the new mode.

1EA1H - Commands U, D, Semicolon, Minus and O

U draws the display over and over, which shows the work of background tasks such as the clock, until a key is pressed; the key is used up. D sets the first address of the memory display. The semicolon and the minus sign move it on or back by 64 bytes in the register display or by a page of 256 bytes in the full screen display. O leaves the debugger through @EXIT, but only when ENTER follows it.

1EA1CMD_U
CMD_U: call @KBD at 0635H (on the BOOT/SYS page), which scans the keyboard without waiting, Register A the key or 00H for none.
1EA4
OR A B7
OR Register A with itself to test for 00H, no key pressed.
1EA5
RET NZ C0
Return to the command loop at 1E4CH if Register A is not zero: a key ends U and is not taken as the next command.
1EA6
Call 1ED5H (WRREGS) to draw the display again from the save area and memory as they are now.
1EA9
Jump back to 1EA1H to scan the keyboard again.
1EABCMD_D
CMD_D: call 21E4H (HEXIN@) to read an address into Register Pair HL, Zero when no digit came before the space, comma or ENTER.
1EAE
RET Z C8
Return to the command loop if the Zero flag is set: D with no address leaves the display where it was.
1EAF
Jump to 1EC5H to store Register Pair HL as the new display address.
1EB1CMD_INC
LD BC,0040H 01 40 00
CMD_INC: load Register Pair BC with 0040H, the 64 bytes of the four memory lines of the register display.
1EB4
LD HL,(00A6H) 2A A6 00LD HL,(DSPADR)
Load Register Pair HL with 00A6H (DSPADR), the first address of the memory display.
1EB7
LD A,(00A1H) 3A A1 00LD A,(SAVTWO)
Load Register A with 00A1H (SAVTWO), 00H in the register display, non zero in the full screen display.
1EBA
OR A B7
OR Register A with itself to test for 00H, the register display.
1EBB
Jump to 1EC4H if Register A is 00H: the step stays at 64 bytes, 0040H or FFC0H in Register Pair BC.
1EBD
LD C,00H 0E 00
Load Register C with 00H: in the full screen the step becomes a whole page, 0000H or FF00H in Register Pair BC.
1EBF
LD A,B 78
Load Register A with Register B, 00H for the semicolon and FFH for the minus sign.
1EC0
OR A B7
OR Register A with itself to test Register B for 00H.
1EC1
Jump to 1EC4H if Register A is not zero: FF00H in Register Pair BC is the step of 256 bytes back.
1EC3
INC B 04
Increment Register B: Register Pair BC becomes 0100H, the step of 256 bytes on.
1EC4
ADD HL,BC 09
Add Register Pair BC to Register Pair HL, moving the display address on or back.
1EC5
LD (00A6H),HL 22 A6 00LD (DSPADR),HL
Store Register Pair HL at 00A6H (DSPADR), the new first address of the memory display (the full screen display rounds it down to a page at 1F50H).
1EC8
RET C9
Return to the command loop at 1E4CH, which draws the display from the new address.
1EC9CMD_DEC
LD BC,FFC0H 01 C0 FF
CMD_DEC: load Register Pair BC with FFC0H, minus 64, the step back of the register display.
1ECC
Jump to 1EB4H to apply the step to the display address (FF00H in the full screen).
1ECECMD_O
CMD_O: call 21C9H (INPUT@) for the next key, Carry only for ENTER.
1ED1
RET NC D0
Return to the command loop at 1E4CH if Carry is clear: O followed by anything but ENTER does nothing.
1ED2
Jump to @EXIT at 1B0BH (on the SYS0/SYS page) to end the program and go to LS-DOS Ready, with Register Pair HL holding 1E4CH (from 1E63H) as a non zero return code. SYS1 sets @DBGHK again from SFLAG$ bit 7.

1ED5H - WRREGS: the Display

The display fills the first 16 rows of the 80 by 24 screen, every row exactly 80 characters, so each one leads into the next without a new line. In the register display, rows 0 to 11 are the twelve register pairs af, bc, de, hl, af', bc', de', hl', ix, iy, sp and pc, each as its name, an equals sign and the value as two hex bytes; af and af' are followed by the eight flags, the others by the 16 bytes of memory they point to, in hex and in ASCII. Rows 12 to 15 are four lines of 16 bytes from DSPADR. In the full screen display all 16 rows are memory, one page of 256 bytes. The spaces are written as the video driver's tab codes, C0H plus the number of spaces, so the layout holds only while the driver shows C0H-FFH as tabs; after a program has turned on its special characters (15H) the codes show as characters and the rows run together (B35). The 1CH that homes the cursor also sets 80 characters a line and normal video.

1ED5WRREGS
LD A,1CH 3E 1C
WRREGS: load Register A with 1CH, the video code that homes the cursor to row 0, column 0 and also sets 80 characters a line and normal (not reverse) video.
1ED7
Call @DSP at 0642H (on the BOOT/SYS page) to send the character in Register A to the video, here the 1CH.
1EDA
LD A,0FH 3E 0F
Load Register A with 0FH, the video code that turns the cursor off while the display is drawn.
1EDC
Call @DSP at 0642H to send the 0FH in Register A: the cursor stays off for the command line too.
1EDF
LD A,(00A1H) 3A A1 00LD A,(SAVTWO)
Load Register A with 00A1H (SAVTWO), the display mode: 00H for the register display.
1EE2
OR A B7
OR Register A with itself to test the mode for 00H.
1EE3
Jump to 1F4DH (FULDSP) if Register A is not zero: the full screen display shows no registers.
1EE5
LD HL,00A8H 21 A8 00LD HL,AFREG
Point Register Pair HL at 00A8H (AFREG), the first saved register pair.
1EE8
PUSH HL E5
Push Register Pair HL (the save pointer) onto the stack (Stack Pointer); the loop keeps the save pointer and the table pointer on the stack in turn.
1EE9
LD HL,1F56H 21 56 1FLD HL,REGTBL
Point Register Pair HL at 1F56H (REGTBL), the twelve names of three characters each.
1EEC
LD B,0CH 06 0C
Load Register B with 0CH, the count of the twelve register pairs, counting down from 12.
1EEE
Call 2235H (WR3BYT) to show three characters from Register Pair HL, the register's name; Register Pair HL steps to the next name.
1EF1
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL gets the save pointer and the table pointer goes onto the stack.
1EF2
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL, the low byte of the saved register pair.
1EF3
INC HL 23
Increment Register Pair HL to the high byte of the saved register pair.
1EF4
LD D,(HL) 56
Load Register D with the byte at Register Pair HL: Register Pair DE is the value of the register pair.
1EF5
INC HL 23
Increment Register Pair HL to the next register pair of the save area.
1EF6
PUSH HL E5
Push Register Pair HL (the next save pointer) onto the stack (Stack Pointer), above the table pointer.
1EF7
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the value of the register pair, to show and to point the memory line.
1EF8
LD A,3DH 3E 3D
Load Register A with 3DH, the equals sign that follows the name.
1EFA
Call @DSP at 0642H to show the equals sign in Register A.
1EFD
Call 2231H (WRSPA@) to show a space between the equals sign and the value.
1F00
LD A,H 7C
Load Register A with Register H, the high byte of the value.
1F01
Call 222EH (WRHEX) to show Register A as two hex digits and a space.
1F04
LD A,L 7D
Load Register A with Register L, the low byte of the value.
1F05
Call 222EH (WRHEX) to show Register A as two hex digits and a space: the line has 11 characters so far.
1F08
LD A,B 78
Load Register A with Register B, the loop count, 12 for af and 8 for af'.
1F09
AND 0BH E6 0B
AND Register A with 0BH: the counts 12 and 8 both give 08H, every other count from 1 to 11 something else.
1F0B
CP 08H FE 08
Compare Register A with 08H to find the lines of af and af', which show the flags instead of memory.
1F0D
Jump to 1F2BH (NOFLG) if Register A is not 08H: show the 16 bytes that the register pair points to.
1F0F
LD C,L 4D
Load Register C with Register L, the F register (flags) of the pair, low byte of AF or AF'.
1F10
PUSH BC C5
Push Register Pair BC (Register B the loop count) onto the stack (Stack Pointer) while Register B counts the flags.
1F11
LD HL,1F7AH 21 7A 1FLD HL,FLGTBL
Point Register Pair HL at 1F7AH (FLGTBL), the letters of the eight flags from bit 7 to bit 0.
1F14
LD B,08H 06 08
Load Register B with 08H, the count of the eight flag bits.
1F16
SLA C CB 21
Shift Register C left: the next flag bit, from bit 7 down, goes into Carry.
1F18
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the letter of this flag.
1F19
Jump to 1F1DH if Carry is set: a flag that is set shows its letter.
1F1B
LD A,2DH 3E 2D
Load Register A with 2DH, the minus sign shown for a flag that is clear.
1F1D
Call @DSP at 0642H to show the letter or the minus sign in Register A.
1F20
INC HL 23
Increment Register Pair HL to the letter of the next flag.
1F21
Decrement Register B and jump back to 1F16H until Register B is 0, all eight flags shown.
1F23
POP BC C1
Pop Register Pair BC from the stack (Stack Pointer): Register B is the loop count of the register pairs again.
1F24
LD A,FDH 3E FD
Load Register A with FDH, the tab code for 61 spaces (FDH less C0H; the source's comment says 60): 11 characters, 8 flags and 61 spaces make the 80 of the row.
1F26
Call @DSP at 0642H to send the tab code in Register A, which ends the row.
1F29
Jump to 1F2EH to go on with the next register pair.
1F2BNOFLG
NOFLG: call 2173H (WRMEM) to show the 16 bytes from Register Pair HL, the value of the register pair, in hex and in ASCII, 69 characters that end the row.
1F2E
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the save pointer of the next register pair.
1F2F
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL gets the table pointer and the save pointer goes onto the stack.
1F30
Decrement Register B and jump back to 1EEEH until Register B is 0, all twelve register pairs shown.
1F32
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer) to drop the save pointer, now past the save area.
1F33
LD HL,(00A6H) 2A A6 00LD HL,(DSPADR)
Load Register Pair HL with 00A6H (DSPADR), the first address of the memory lines.
1F36
LD B,04H 06 04
Load Register B with 04H, the four memory lines under the registers.
1F38
LD A,C6H 3E C6
Load Register A with C6H, the tab code for 6 spaces at the start of a memory line.
1F3A
Call @DSP at 0642H to send the tab code in Register A.
1F3D
Call 2215H (WR2HEX@) to show Register Pair HL, the address of the line, as four hex digits.
1F40
Call 2231H (WRSPA@) to show a space after the address.
1F43
Call 2173H (WRMEM) to show the 16 bytes from Register Pair HL; it returns with Register Pair HL 16 bytes on, the address of the next line.
1F46
Decrement Register B and jump back to 1F38H until Register B is 0: four lines, or sixteen in the full screen display.
1F48
LD A,1FH 3E 1F
Load Register A with 1FH, the video code that clears from the cursor to the end of the screen, rows 16 to 23 and the old command line.
1F4A
Jump to @DSP at 0642H to send the 1FH in Register A; its return goes back to the caller of WRREGS.
1F4DFULDSP
LD HL,(00A6H) 2A A6 00LD HL,(DSPADR)
FULDSP: load Register Pair HL with 00A6H (DSPADR), the display address.
1F50
LD L,00H 2E 00
Load Register L with 00H, rounding Register Pair HL down to the start of its page of 256 bytes.
1F52
LD B,10H 06 10
Load Register B with 10H, the 16 lines of the full screen display.
1F54
Jump to 1F38H to show the 16 memory lines from Register Pair HL.
1F56-1F79REGTBL
DEFM "af bc de hl af'bc'de'hl'ix iy sp pc " 61 66 20 62 63 20 64 65 20 68 6C 20 61 66 27 62 63 27 64 65 27 68 6C 27 69 78 20 69 79 20 73 70 20 70 63 20
REGTBL, 1F56H-1F79H: the names of the twelve register pairs, three characters each, in the order of the save area from 00A8H (AFREG) to 00BEH (PCREG). WRREGS shows them and R looks a name up here, pc included, so R pc changes the Program Counter, which the manual says R cannot do.
1F7A-1F81FLGTBL
DEFM "SZ1H1PNC" 53 5A 31 48 31 50 4E 43
FLGTBL, 1F7AH-1F81H: the letters of the flags from bit 7 to bit 0: Sign, Zero, 1 for bit 5, Half carry, 1 for bit 3, Parity or overflow, Negative (subtract) and Carry. A clear bit shows a minus sign.

1F82H - CMD_G: Go, with Up to Two Breakpoints

G takes an optional start address and up to two breakpoint addresses, separated by commas: G alone goes on at the Program Counter. A breakpoint is an F7H byte (RST 30H) put over the first byte of an instruction, its address and the byte it replaced kept in a save area, the first breakpoint in 00A3H-00A5H and the second in 00A0H-00A2H. G then sets @DBGHK to 00H, so that BREAK enters the debugger again (also when DEBUG is off and the debugger was entered through SVC 27, an RST 30H or the D key), puts every register back from the save area, sets the program's Stack Pointer and jumps to the Program Counter with a RET. When the program reaches a breakpoint, RST 30H enters the debugger at 19A0H, the entry moves the Program Counter back onto the F7H and puts both bytes back. G with no breakpoint, or with one, leaves the other save areas holding the variables of the commands typed before it (B32).

1F82CMD_G
LD B,02H 06 02
CMD_G: load Register B with 02H, the most breakpoints G takes.
1F84
LD DE,00A5H 11 A5 00LD DE,NXTBYT
Point Register Pair DE at 00A5H (NXTBYT), the last byte of the first save area; the setter at 1FC5H fills each area from its end down and leaves Register Pair DE at 00A2H for the second.
1F87
Call 21E4H (HEXIN@) for the start address in Register Pair HL; Zero if none was typed, Carry if ENTER ended it.
1F8A
Jump to 1F8FH if the Zero flag is set: no start address, the Program Counter stays.
1F8C
LD (00BEH),HL 22 BE 00LD (PCREG),HL
Store Register Pair HL at 00BEH (PCREG): the program goes on at the address typed.
1F8F
Jump to 1F9BH if Carry is set: ENTER ended the line, no more breakpoints.
1F91
Call 21E4H (HEXIN@) for a breakpoint address in Register Pair HL, Zero if none.
1F94
PUSH AF F5
Push Register Pair AF onto the stack (Stack Pointer): the flags from HEXIN@, Carry for ENTER, are needed after the setter.
1F95
Call 1FC5H to put a breakpoint at Register Pair HL if the Zero flag is clear (an address was typed); Register Pair DE moves to the next save area.
1F98
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer), the flags of HEXIN@ again for the test at 1F8FH.
1F99
Decrement Register B and jump back to 1F8FH until Register B is 0: two breakpoints at most.
1F9B
XOR A AF
Clear Register A to 00H, the NOP that turns DEBUG on at @DBGHK.
1F9C
LD (199FH),A 32 9F 19LD (@DBGHK),A
Store Register A (00H) at 199FH (@DBGHK): the RET there becomes a NOP, so BREAK enters the debugger again (RST28 had set C9H when it loaded SYS5); SYS1 sets it from SFLAG$ bit 7 at the next @EXIT.
1F9F
LD HL,00BDH 21 BD 00LD HL,REGSAV
Point Register Pair HL at 00BDH (REGSAV), the last byte of the saved Stack Pointer, to push the save area from the top down.
1FA2
LD B,0BH 06 0B
Load Register B with 0BH, the eleven register pairs from SP down to AF; the Program Counter is handled on its own at 1FBDH.
1FA4
LD D,(HL) 56
Load Register D with the byte at Register Pair HL, the high byte of the register pair.
1FA5
DEC HL 2B
Decrement Register Pair HL to the low byte of the register pair.
1FA6
LD E,(HL) 5E
Load Register E with the byte at Register Pair HL: Register Pair DE is the saved register pair.
1FA7
DEC HL 2B
Decrement Register Pair HL to the high byte of the register pair below it.
1FA8
PUSH DE D5
Push Register Pair DE onto the stack (Stack Pointer): SP, IY, IX, HL', DE', BC', AF', HL, DE, BC and AF, so AF is on top.
1FA9
Decrement Register B and jump back to 1FA4H until Register B is 0, all eleven pushed.
1FAB
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): the program's Register Pair AF from 00A8H.
1FAC
POP BC C1
Pop Register Pair BC from the stack (Stack Pointer): the program's Register Pair BC.
1FAD
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer): the program's Register Pair DE.
1FAE
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the program's Register Pair HL, replaced by the Stack Pointer word at 1FBBH and loaded again at 1FC1H.
1FAF
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF': the program's AF goes into the alternate set for now.
1FB0
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX): the four values just loaded wait in the alternate registers.
1FB1
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): the program's alternate Register Pair AF' from 00B0H.
1FB2
POP BC C1
Pop Register Pair BC from the stack (Stack Pointer): the program's alternate Register Pair BC'.
1FB3
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer): the program's alternate Register Pair DE'.
1FB4
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the program's alternate Register Pair HL'.
1FB5
EX AF,AF' 08
Exchange Register Pair AF with the alternate Register Pair AF' again: AF is the program's main pair and AF' its alternate.
1FB6
EXX D9
Exchange Register Pairs BC, DE and HL with the alternate set (EXX) again: both sets now hold the program's values in their places.
1FB7
POP IX DD E1
Pop Index Register IX from the stack (Stack Pointer): the program's Index Register IX from 00B8H.
1FB9
POP IY FD E1
Pop Index Register IY from the stack (Stack Pointer): the program's Index Register IY from 00BAH.
1FBB
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the program's Stack Pointer from 00BCH.
1FBC
LD SP,HL F9
Load the Stack Pointer from Register Pair HL: the program's stack again, as it was before the debugger was entered (or as R sp set it).
1FBD
LD HL,(00BEH) 2A BE 00LD HL,(PCREG)
Load Register Pair HL with 00BEH (PCREG), the address where the program goes on.
1FC0
PUSH HL E5
Push Register Pair HL (the Program Counter) onto the program's stack (Stack Pointer); the two bytes under the program's Stack Pointer are overwritten.
1FC1
LD HL,(00AEH) 2A AE 00LD HL,(HLREG)
Load Register Pair HL with 00AEH (HLREG), the program's own Register Pair HL.
1FC4
RET C9
Return, which pops the Program Counter: the program goes on with every register as the save area holds it.
1FC5
LD A,(HL) 7E
Put a breakpoint ($?17 in the source): load Register A with the byte at Register Pair HL, the first byte of the instruction that the breakpoint replaces.
1FC6
LD (DE),A 12
Store Register A at Register Pair DE, the third byte of the save area (00A5H or 00A2H).
1FC7
DEC DE 1B
Decrement Register Pair DE to the high byte of the save area's address.
1FC8
LD A,F7H 3E F7
Load Register A with F7H, RST 30H, the breakpoint.
1FCA
LD (HL),A 77
Store Register A (F7H) at Register Pair HL over the instruction's first byte.
1FCB
CP (HL) BE
Compare Register A with the byte at Register Pair HL to see if the store took: in the DOS's memory map every address is RAM, so it fails only where a program has the keyboard switched in.
1FCC
Jump to 1E32H if the F7H did not stay: the breakpoints already put are taken out again and the command loop goes on; G, I or C is not done.
1FCF
LD A,H 7C
Load Register A with Register H, the high byte of the breakpoint's address.
1FD0
LD (DE),A 12
Store Register A at Register Pair DE, the high byte of the save area's address (00A4H or 00A1H).
1FD1
DEC DE 1B
Decrement Register Pair DE to the low byte of the save area's address.
1FD2
LD A,L 7D
Load Register A with Register L, the low byte of the breakpoint's address.
1FD3
LD (DE),A 12
Store Register A at Register Pair DE, the low byte of the save area's address (00A3H or 00A0H).
1FD4
DEC DE 1B
Decrement Register Pair DE to the end of the next save area (00A2H after the first).
1FD5
RET C9
Return with the breakpoint put and its save area filled.

1FD6H - CMD_AH: Modify Memory in Hex or ASCII

A and H both modify memory from an address, the modification address NXTADR when none is typed; they differ only in how the byte is shown and typed. The address and the byte appear at the left of rows 13 and 14, in the six spaces that start the memory lines, while the bars in the display frame the byte. With H a hexadecimal value is typed (the last two digits count) and stored when a space or ENTER follows; with A the character typed is stored as it is, without the change to lower case. A space or a comma alone moves on without a change, so neither can be put into memory with A; ENTER ends the command, and with H any character that is not a hex digit ends it with the byte unchanged. A or H followed at once by ENTER only sets the address and the mode. The letter is kept in SAVONE (00A0H), which the next entry to the debugger zeroes, and so is NXTADR, which the next entry also zeroes (B32).

1FD6CMD_AH
LD (00A0H),A 32 A0 00LD (SAVONE),A
CMD_AH: store Register A, the command letter 61H (a) or 68H (h), at 00A0H (SAVONE) as the mode of the modify line.
1FD9
LD HL,(00A3H) 2A A3 00LD HL,(NXTADR)
Load Register Pair HL with 00A3H (NXTADR), the modification address, the default when no address is typed.
1FDC
Call 21E4H (HEXIN@) for an address in Register Pair HL; with no digit Register Pair HL keeps the default.
1FDF
LD (00A3H),HL 22 A3 00LD (NXTADR),HL
Store Register Pair HL at 00A3H (NXTADR): the address to modify, which the display frames with the bars.
1FE2
RET C D8
Return to the command loop if Carry is set: ENTER ended the address (or the last value) and nothing more is done.
1FE3
PUSH HL E5
Push Register Pair HL (the modification address) onto the stack (Stack Pointer) for 2007H.
1FE4
Call 1ED5H (WRREGS) to draw the display again, with the bars at the new address.
1FE7
LD HL,0D00H 21 00 0D
Load Register Pair HL with 0D00H: Register H the row 13, Register L the column 0, the start of the second memory line in the register display.
1FEA
LD B,03H 06 03
Load Register B with 03H, function 3 of @VDCTL, set the cursor to Register H and Register L.
1FEC
LD A,0FH 3E 0F
Load Register A with 0FH, SVC 15, @VDCTL, for the cursor of row 13.
1FEE
RST 28H EF
Call @VDCTL with RST 28H to put the cursor at row 13, column 0.
1FEF
LD HL,(00A3H) 2A A3 00LD HL,(NXTADR)
Load Register Pair HL with 00A3H (NXTADR), the modification address again.
1FF2
Call 2215H (WR2HEX@) to show Register Pair HL as four hex digits over the start of row 13.
1FF5
PUSH HL E5
Push Register Pair HL (the modification address) onto the stack (Stack Pointer) while the cursor is moved.
1FF6
LD HL,0E00H 21 00 0E
Load Register Pair HL with 0E00H: Register H the row 14, Register L the column 0.
1FF9
LD B,03H 06 03
Load Register B with 03H, function 3 of @VDCTL, set the cursor to Register H and Register L.
1FFB
LD A,0FH 3E 0F
Load Register A with 0FH, SVC 15, @VDCTL, for the cursor of row 14.
1FFD
RST 28H EF
Call @VDCTL with RST 28H to put the cursor at row 14, column 0.
1FFE
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the modification address.
1FFF
Call 2013H (AHDSP) to show the byte at Register Pair HL, as two hex digits for H or as a character for A.
2002
LD A,2DH 3E 2D
Load Register A with 2DH, the minus sign that follows the old byte.
2004
Call @DSP at 0642H to show the minus sign in Register A; the new value is typed after it.
2007
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer): the modification address pushed at 1FE3H.
2008
Call 2029H (AHGET) for the new value: in Register Pair HL for H, the character in Register L for A; Zero when nothing but a space or comma was typed, Carry for ENTER.
200B
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the modification address and Register E the new byte.
200C
Jump to 200FH if the Zero flag is set: a space or a comma alone leaves the byte as it is.
200E
LD (HL),E 73
Store Register E, the new value, at Register Pair HL, the modification address.
200F
RET C D8
Return to the command loop if Carry is set: ENTER ends the command, the byte stored if a value came before it.
2010
INC HL 23
Increment Register Pair HL to the next address.
2011
Jump back to 1FDFH to store the next address in NXTADR and modify it.
2013AHDSP
LD A,(00A0H) 3A A0 00LD A,(SAVONE)
AHDSP: load Register A with 00A0H (SAVONE), the letter of the command.
2016
CP 61H FE 61
Compare Register A with 61H, a, the ASCII mode.
2018
Jump to 2211H (WR1HEX@) if Register A is not a: show the byte at Register Pair HL in hex.
201BDSPASC@
LD A,(HL) 7E
DSPASC@: load Register A with the byte at Register Pair HL to show it as a character (SYS9's commands call this entry too).
201C
CP 20H FE 20
Compare Register A with 20H, the first character that can be shown.
201E
Jump to 2024H if Register A is below 20H: a control code is shown as a period.
2020
CP C0H FE C0
Compare Register A with C0H, the first tab or special character code of the video driver.
2022
Jump to 2026H if Register A is below C0H: 20H-BFH, characters and graphics, are shown as they are.
2024TYP3
LD A,2EH 3E 2E
TYP3: load Register A with 2EH, the period shown for 00H-1FH and C0H-FFH.
2026TYP4
TYP4: jump to @DSP at 0642H to show the character in Register A; its return goes back to the caller.
2029AHGET
LD A,(00A0H) 3A A0 00LD A,(SAVONE)
AHGET: load Register A with 00A0H (SAVONE), the letter of the command.
202C
CP 61H FE 61
Compare Register A with 61H, a, the ASCII mode.
202E
Jump to 21E4H (HEXIN@) if Register A is not a: the value is read in hex into Register Pair HL.
2031GETASC@
PUSH HL E5
GETASC@: push Register Pair HL onto the stack (Stack Pointer); the entry is also used by SYS9's commands.
2032
LD HL,21D6H 21 D6 21
Point Register Pair HL at 21D6H, the second byte of the SET 5,A at 21D5H (INPUC@) that makes the keys lower case.
2035
LD (HL),6FH 36 6F
Store 6FH at Register Pair HL: the instruction becomes BIT 5,A, which leaves the character as it was typed.
2037
Call 21C9H (INPUT@) for one key in Register A, shown, Zero for a space or comma, Carry for ENTER.
203A
LD (HL),EFH 36 EF
Store EFH at Register Pair HL (21D6H): SET 5,A again for every other input.
203C
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer).
203D
LD L,A 6F
Load Register L with Register A, the character typed, as the value; the flags of INPUT@ are kept.
203E
RET C9
Return with the character in Register L and Register A.

203FH - CMD_R: Give a Register Pair a New Value

R is followed at once by the name of a register pair, two letters with an apostrophe for the alternate set, a space and the new value in hex: R hl 4000, R de' 0. The name is looked up in REGTBL, which holds all twelve names of the display, so R sp changes the Stack Pointer that G will load and R pc changes the Program Counter, which the manual says cannot be done. R sp also moves the stack the debugger itself runs on, as the command loop loads the Stack Pointer from SPREG. A space after R, a name that is not in the table, or no value, leaves the registers as they are.

203FCMD_R
CMD_R: call 21C9H (INPUT@) for the first letter of the name in Register A.
2042
RET Z C8
Return to the command loop if the Zero flag is set: a space, a comma or ENTER instead of a letter.
2043
LD C,A 4F
Load Register C with Register A, the first letter of the name.
2044
Call 21C9H (INPUT@) for the second letter of the name in Register A.
2047
RET Z C8
Return to the command loop if the Zero flag is set: a separator or ENTER after one letter.
2048
LD D,A 57
Load Register D with Register A, the second letter of the name.
2049
LD E,20H 1E 20
Load Register E with 20H, the space that is the third character of every name but the alternate ones.
204B
Call 21C9H (INPUT@) for the third character in Register A: the space before the value, or an apostrophe.
204E
RET C D8
Return to the command loop if Carry is set: ENTER after the name, no value.
204F
Jump to 2057H if the Zero flag is set: a space or a comma, the name is complete with the space in Register E.
2051
LD E,A 5F
Load Register E with Register A, the third character, the apostrophe of an alternate register pair.
2052
Call 21C9H (INPUT@) for the separator after the apostrophe.
2055
RET NZ C0
Return to the command loop if the Zero flag is clear: anything but a space, a comma or ENTER.
2056
RET C D8
Return to the command loop if Carry is set: ENTER after the name leaves no value to read.
2057
LD HL,1F56H 21 56 1FLD HL,REGTBL
Point Register Pair HL at 1F56H (REGTBL), the twelve names of three characters.
205A
LD B,0CH 06 0C
Load Register B with 0CH, the count of the twelve names, counting down from 12.
205C
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the first letter of a name in the table.
205D
CP C B9
Compare Register A with Register C, the first letter typed.
205E
Jump to 2066H if Register A equals Register C, to compare the second letter.
2060
INC HL 23
Increment Register Pair HL to the second letter of this name.
2061
INC HL 23
Increment Register Pair HL to the third letter (the entry when the second letter did not match).
2062
INC HL 23
Increment Register Pair HL to the first letter of the next name (the entry when the third did not match).
2063
Decrement Register B and jump back to 205CH until Register B is 0, all twelve names tried.
2065
RET C9
Return to the command loop: the name typed is not in the table and nothing is changed.
2066
INC HL 23
Increment Register Pair HL to the second letter of the name whose first letter matched.
2067
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the second letter in the table.
2068
CP D BA
Compare Register A with Register D, the second letter typed.
2069
Jump back to 2061H if Register A differs from Register D, to try the next name.
206B
INC HL 23
Increment Register Pair HL to the third character of the name.
206C
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the third character in the table, a space or an apostrophe.
206D
CP E BB
Compare Register A with Register E, the third character typed.
206E
Jump back to 2062H if Register A differs from Register E, to try the next name.
2070
LD A,18H 3E 18
Load Register A with 18H, 24, the size of the save area, to turn the count in Register B into an offset.
2072
SUB B 90
Subtract Register B (12 for af down to 1 for pc) from Register A.
2073
SUB B 90
Subtract Register B again: Register A is 24 less twice the count, 00H for af up to 16H for pc.
2074
LD C,A 4F
Load Register C with Register A, the offset into the save area.
2075
LD B,00H 06 00
Load Register B with 00H: Register Pair BC is the offset.
2077
LD HL,00A8H 21 A8 00LD HL,AFREG
Point Register Pair HL at 00A8H (AFREG), the start of the register save area.
207A
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL points to the saved register pair named.
207B
PUSH HL E5
Push Register Pair HL (the pointer) onto the stack (Stack Pointer) while the line is cleared.
207C
LD A,1EH 3E 1E
Load Register A with 1EH, the video code that clears from the cursor to the end of the line.
207E
Call @DSP at 0642H to send the 1EH in Register A.
2081
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer): the pointer to the saved register pair.
2082
Call 21E4H (HEXIN@) for the new value in Register Pair HL, Zero if no digit was typed.
2085
RET Z C8
Return to the command loop if the Zero flag is set: no value, the register pair keeps its value.
2086
EX DE,HL EB
Exchange Register Pair DE with Register Pair HL: Register Pair HL is the pointer, Register Pair DE the value.
2087
LD (HL),E 73
Store Register E, the low byte of the value, at Register Pair HL in the save area.
2088
INC HL 23
Increment Register Pair HL to the high byte of the saved register pair.
2089
LD (HL),D 72
Store Register D, the high byte of the value, at Register Pair HL.
208A
RET C9
Return to the command loop, which shows the new value.

208BH - CMD_CI: Single Step with I and C

I and C run one instruction. The instruction at the Program Counter is looked up in three tables, one for the plain opcodes, one for those after EDH and one for those after DDH or FDH, which give its length and its kind. A breakpoint goes on the next instruction, and for a jump, a return, a call (with I), or an RST to 00H-20H (with I), a second one goes on the target: the address the jump names, the address at the top of the stack for a return, Register Pair HL for JP (HL) and the index register for JP (IX) or JP (IY). C runs a CALL, and every RST, in full, with the breakpoint after it; I steps into them, except RST 28H, RST 30H and RST 38H, which it treats like C. The program then runs from the Program Counter through G's register restore and comes back at one of the breakpoints. The test that tells JP (IX) from JP (IY) looks at the second byte of the instruction, always E9H, instead of the prefix, so a JP (IX) gets its breakpoint at Index Register IY's address (B31). I and C go on through 1F9FH, past the store that G makes into @DBGHK, so BREAK cannot reach the debugger while the stepped instruction runs (B38); and a branch to itself, DJNZ $ or JR cc,$, gets its second breakpoint on its own first byte, so it can never be stepped past (B39).

208BCMD_CI
PUSH AF F5
CMD_CI: push Register Pair AF onto the stack (Stack Pointer), Register A holding 69H (i) or 63H (c), for the CALL and RST cases.
208C
LD DE,(00BEH) ED 5B BE 00LD DE,(PCREG)
Load Register Pair DE with 00BEH (PCREG), the address of the instruction to step.
2090
LD A,(DE) 1A
Load Register A with the byte at Register Pair DE, the first byte of the instruction.
2091
LD HL,2157H 21 57 21LD HL,XY_TAB
Point Register Pair HL at 2157H (XY_TAB), the table of the instructions that follow DDH or FDH.
2094
CP DDH FE DD
Compare Register A with DDH, the prefix of the Index Register IX instructions.
2096
Jump to 20A6H if Register A is DDH, to look up the second byte in XY_TAB.
2098
CP FDH FE FD
Compare Register A with FDH, the prefix of the Index Register IY instructions.
209A
Jump to 20A6H if Register A is FDH, to look up the second byte in XY_TAB.
209C
LD HL,211FH 21 1F 21LD HL,OP_TAB
Point Register Pair HL at 211FH (OP_TAB), the table of the plain opcodes.
209F
CP EDH FE ED
Compare Register A with EDH, the prefix of the extended instructions.
20A1
Jump to 20A9H if Register A is not EDH: the first byte is looked up in OP_TAB.
20A3
LD HL,2150H 21 50 21LD HL,ED_TAB
Point Register Pair HL at 2150H (ED_TAB), the table of the instructions that follow EDH.
20A6
INC DE 13
Increment Register Pair DE to the second byte of the prefixed instruction.
20A7
LD A,(DE) 1A
Load Register A with the byte at Register Pair DE, the second byte, which the table decodes.
20A8
DEC DE 1B
Decrement Register Pair DE back to the first byte, the address of the instruction.
20A9
LD C,A 4F
Load Register C with Register A, the byte to decode: the opcode, or the byte after the prefix (E9H for a JP (IX) or JP (IY)).
20AA
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the mask of this table entry.
20AB
AND C A1
AND Register A with Register C, keeping only the bits of the opcode that the entry tests.
20AC
INC HL 23
Increment Register Pair HL to the test byte of the entry.
20AD
CP (HL) BE
Compare Register A with the test byte at Register Pair HL: equal when the opcode belongs to this entry.
20AE
INC HL 23
Increment Register Pair HL to the kind and length byte of the entry.
20AF
Jump to 20B7H if the Zero flag is set: Register Pair HL points to the kind and length of the instruction.
20B1
INC HL 23
Increment Register Pair HL to the first byte of the next entry.
20B2
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL: a mask (05H or above), or the length of every other instruction at the end of the table.
20B3
CP 05H FE 05
Compare Register A with 05H: every mask is C0H or above and every final length 01H or 02H.
20B5
Jump back to 20AAH if Register A is 05H or above, to try the next entry.
20B7
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the kind of the instruction in bits 7-4 and its length in bits 3-0.
20B8
LD B,A 47
Load Register B with Register A, keeping the kind and length byte.
20B9
AND 0FH E6 0F
AND Register A with 0FH, keeping the length in bytes.
20BB
LD L,A 6F
Load Register L with Register A, the length of the instruction in bytes.
20BC
LD H,00H 26 00
Load Register H with 00H: Register Pair HL is the length.
20BE
ADD HL,DE 19
Add Register Pair DE, the instruction's address, to Register Pair HL: Register Pair HL is the address of the next instruction.
20BF
PUSH DE D5
Push Register Pair DE (the instruction's address) onto the stack (Stack Pointer).
20C0
LD DE,00A5H 11 A5 00LD DE,NXTBYT
Point Register Pair DE at 00A5H (NXTBYT), the end of the first breakpoint save area.
20C3
Call 1FC5H to put the first breakpoint at Register Pair HL, the next instruction; Register Pair DE moves to 00A2H. If that address is not RAM the command is dropped there.
20C6
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the address of the instruction being stepped.
20C7
LD A,B 78
Load Register A with Register B, the kind and length byte.
20C8
AND F0H E6 F0
AND Register A with F0H, keeping the kind: 0 regular, 1 JP (HL), 2 JP (IX) or JP (IY), 3 JR or DJNZ, 4 JP, 5 RET, 6 CALL, 7 RST.
20CA
Jump to 20F6H if Register A is 00H: a regular instruction needs only the breakpoint after it.
20CC
INC HL 23
Increment Register Pair HL to the second byte of the instruction, where an operand starts.
20CD
CP 20H FE 20
Compare Register A with 20H to sort out the kinds 1 and 2.
20CF
Jump to 2117H if Register A is below 20H: kind 1, JP (HL).
20D1
Jump to 210BH if Register A is 20H: kind 2, JP (IX) or JP (IY).
20D3
CP 40H FE 40
Compare Register A with 40H to sort out the kinds 3 and 4.
20D5
Jump to 2102H if Register A is below 40H: kind 3, JR or DJNZ.
20D7
Jump to 20FCH if Register A is 40H: kind 4, JP nn, whose target follows the opcode.
20D9
CP 60H FE 60
Compare Register A with 60H to sort out the kinds 5 and 6.
20DB
Jump to 20F9H if Register A is below 60H: kind 5, a return.
20DD
Jump to 20F1H if Register A is 60H: kind 6, a call.
20DF
LD A,C 79
Kind 7, an RST: load Register A with Register C, the opcode.
20E0
AND 38H E6 38
AND Register A with 38H, the bits of the opcode that give the RST's address (00H to 38H).
20E2
LD L,A 6F
Load Register L with Register A, the RST's address.
20E3
LD H,00H 26 00
Load Register H with 00H: Register Pair HL is the target of the RST.
20E5
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): Register A is the command, i or c, pushed at 208BH.
20E6
CP 63H FE 63
Compare Register A with 63H, c, the command that runs an RST in full.
20E8
Jump to 20F6H if Register A is c: the RST runs in full with only the breakpoint after it.
20EA
LD A,L 7D
Load Register A with Register L, the address of the RST.
20EB
CP 28H FE 28
Compare Register A with 28H: RST 28H (the SVCs), RST 30H (the debugger) and RST 38H (the interrupts) are not stepped into.
20ED
Jump to 20F6H if Register A is 28H or above: run that RST in full, as C does.
20EF
Jump to 211AH to put the second breakpoint at Register Pair HL, the RST's address 00H to 20H.
20F1
POP AF F1
Kind 6, a call: pop Register Pair AF from the stack (Stack Pointer), Register A the command.
20F2
CP 69H FE 69
Compare Register A with 69H, i, the command that steps into a call.
20F4
Jump to 20FCH if Register A is i: the second breakpoint goes on the called address.
20F6
Jump to 1F9FH in CMD_G to load the registers and run from the Program Counter: after a regular instruction, a C call or RST, an RST 28H to 38H, and from 211DH after every second breakpoint. It goes past the store of 00H into @DBGHK at 1F9CH, so @DBGHK stays C9H while the instruction runs (B38). The command's Register Pair AF is left on the debugger's stack for the kinds 0 to 5, which is harmless, as the program's Stack Pointer replaces it.
20F9
LD HL,(00BCH) 2A BC 00LD HL,(SPREG)
Kind 5, a return: load Register Pair HL with 00BCH (SPREG), the program's Stack Pointer, where the return address is.
20FC
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the low byte of the target (the operand of JP or CALL, or the return address on the stack).
20FD
INC HL 23
Increment Register Pair HL to the high byte of the target.
20FE
LD H,(HL) 66
Load Register H with the byte at Register Pair HL, the high byte of the target.
20FF
LD L,A 6F
Load Register L with Register A: Register Pair HL is the target.
2100
Jump to 211AH to put the second breakpoint at Register Pair HL.
2102
LD C,(HL) 4E
Kind 3, JR or DJNZ: load Register C with the byte at Register Pair HL, the displacement.
2103
LD A,C 79
Load Register A with Register C, the displacement, to take its sign.
2104
RLCA 07
Rotate Register A left: bit 7, the sign of the displacement, goes into Carry.
2105
SBC A,A 9F
Subtract Register A with Carry from itself: Register A is 00H for a jump forward and FFH for a jump back.
2106
LD B,A 47
Load Register B with Register A: Register Pair BC is the displacement as a 16 bit number.
2107
INC HL 23
Increment Register Pair HL to the next instruction, the base of the displacement.
2108
ADD HL,BC 09
Add Register Pair BC to Register Pair HL: Register Pair HL is the target of the relative jump.
2109
Jump to 211AH to put the second breakpoint at Register Pair HL.
210B
LD HL,(00B8H) 2A B8 00LD HL,(IXREG)
Kind 2, JP (IX) or JP (IY): load Register Pair HL with 00B8H (IXREG), the program's Index Register IX.
210E
BIT 5,C CB 69
Test bit 5 of Register C, meant to tell DDH (bit 5 clear) from FDH (bit 5 set). Register C holds the second byte, E9H, whose bit 5 is always set (B31).
2110
Jump to 211AH if bit 5 was clear, with Index Register IX's address: never taken, as Register C is E9H.
2112
LD HL,(00BAH) 2A BA 00LD HL,(IYREG)
Load Register Pair HL with 00BAH (IYREG), the program's Index Register IY: the target of every JP (IY), and of every JP (IX) too (B31).
2115
Jump to 211AH to put the second breakpoint at Register Pair HL.
2117
LD HL,(00AEH) 2A AE 00LD HL,(HLREG)
Kind 1, JP (HL): load Register Pair HL with 00AEH (HLREG), the program's Register Pair HL, the target.
211A
Call 1FC5H to put the second breakpoint at Register Pair HL, the target, with Register Pair DE at 00A2H; if it is not RAM the command is dropped. When the target is the instruction itself (DJNZ $, JR cc,$), the breakpoint lands on its own first byte (B39).
211D
Jump to 20F6H to run the program from the Program Counter.

211FH - OP_TAB, ED_TAB and XY_TAB: Instruction Lengths and Kinds

Each entry is three bytes: a mask ANDed with the opcode, the value the result must equal, and a byte with the kind of the instruction in bits 7-4 (0 regular, 1 JP (HL), 2 JP (IX) or JP (IY), 3 JR or DJNZ, 4 JP, 5 a return, 6 a call, 7 RST) and its length in bits 3-0. A single byte below 05H ends each table with the length of every opcode that no entry matched, all of them of kind 0. The tables cover the documented instructions; a few undocumented ones get a wrong length: DDH or FDH with 40H-BFH is always three bytes, which is right only for the forms with (IX+d), DDH or FDH with 26H or 2EH (LD IXH,n and LD IXL,n) counts two bytes instead of three, and the undocumented copies of RETN after EDH count as regular.

211F-2121OP_TAB
DEFB 0C7H, 0C0H, 51H C7 C0 51
OP_TAB, 211FH-2121H: mask C7H, value C0H: the conditional returns C0H, C8H, D0H, D8H, E0H, E8H, F0H and F8H (the source's comment names only four), kind 5, one byte.
2122-2124
DEFB 0FFH, 0C9H, 51H FF C9 51
2122H-2124H: mask FFH, value C9H: RET, kind 5, one byte; the breakpoint goes on the address at the top of the program's stack.
2125-2127
DEFB 0FFH, 0E9H, 11H FF E9 11
2125H-2127H: mask FFH, value E9H: JP (HL), kind 1, one byte; the target is the program's Register Pair HL.
2128-212A
DEFB 0CFH, 01H, 03H CF 01 03
2128H-212AH: mask CFH, value 01H: LD BC,nn, LD DE,nn, LD HL,nn and LD SP,nn (01H, 11H, 21H, 31H), regular, three bytes.
212B-212D
DEFB 0E7H, 22H, 03H E7 22 03
212BH-212DH: mask E7H, value 22H: LD (nn),HL, LD HL,(nn), LD (nn),A and LD A,(nn) (22H, 2AH, 32H, 3AH), regular, three bytes.
212E-2130
DEFB 0C7H, 0C2H, 43H C7 C2 43
212EH-2130H: mask C7H, value C2H: the conditional jumps JP cc,nn (C2H to FAH in steps of 8), kind 4, three bytes; the target is the operand.
2131-2133
DEFB 0FFH, 0C3H, 43H FF C3 43
2131H-2133H: mask FFH, value C3H: JP nn, kind 4, three bytes.
2134-2136
DEFB 0C7H, 0C4H, 63H C7 C4 63
2134H-2136H: mask C7H, value C4H: the conditional calls CALL cc,nn (C4H to FCH in steps of 8), kind 6, three bytes.
2137-2139
DEFB 0FFH, 0CDH, 63H FF CD 63
2137H-2139H: mask FFH, value CDH: CALL nn, kind 6, three bytes; I puts the second breakpoint on the called address, C does not.
213A-213C
DEFB 0C7H, 06H, 02H C7 06 02
213AH-213CH: mask C7H, value 06H: LD r,n and LD (HL),n (06H to 3EH in steps of 8), regular, two bytes.
213D-213F
DEFB 0F7H, 0D3H, 02H F7 D3 02
213DH-213FH: mask F7H, value D3H: OUT (n),A and IN A,(n) (D3H, DBH), regular, two bytes.
2140-2142
DEFB 0C7H, 0C6H, 02H C7 C6 02
2140H-2142H: mask C7H, value C6H: the arithmetic and logic instructions with a byte operand, ADD A,n to CP n (C6H to FEH in steps of 8), regular, two bytes.
2143-2145
DEFB 0FFH, 0CBH, 02H FF CB 02
2143H-2145H: mask FFH, value CBH: every instruction after the CBH prefix (the shifts and the bit instructions), regular, two bytes.
2146-2148
DEFB 0F7H, 10H, 32H F7 10 32
2146H-2148H: mask F7H, value 10H: DJNZ and JR (10H, 18H), kind 3, two bytes; the target is the next instruction plus the displacement.
2149-214B
DEFB 0E7H, 20H, 32H E7 20 32
2149H-214BH: mask E7H, value 20H: the conditional relative jumps JR NZ, JR Z, JR NC and JR C (20H, 28H, 30H, 38H), kind 3, two bytes.
214C-214E
DEFB 0C7H, 0C7H, 71H C7 C7 71
214CH-214EH: mask C7H, value C7H: the eight RST instructions (C7H to FFH in steps of 8), kind 7, one byte.
214F
DEFB 01H 01
214FH: 01H, the end of OP_TAB: every other plain opcode is regular and one byte long.
2150-2152ED_TAB
DEFB 0C7H, 43H, 04H C7 43 04
ED_TAB, 2150H-2152H: mask C7H, value 43H: after EDH, LD (nn),rr and LD rr,(nn) (43H to 7BH in steps of 8, with the undocumented 63H and 6BH), regular, four bytes.
2153-2155
DEFB 0F7H, 45H, 52H F7 45 52
2153H-2155H: mask F7H, value 45H: after EDH, RETN and RETI (45H, 4DH), kind 5, two bytes.
2156
DEFB 02H 02
2156H: 02H, the end of ED_TAB: every other instruction after EDH is regular and two bytes long.
2157-2159XY_TAB
DEFB 0FEH, 34H, 03H FE 34 03
XY_TAB, 2157H-2159H: mask FEH, value 34H: after DDH or FDH, INC (IX+d) and DEC (IX+d) (34H, 35H), regular, three bytes.
215A-215C
DEFB 0C0H, 40H, 03H C0 40 03
215AH-215CH: mask C0H, value 40H: after DDH or FDH, every opcode 40H-7FH, the loads with (IX+d), regular, three bytes.
215D-215F
DEFB 0C0H, 80H, 03H C0 80 03
215DH-215FH: mask C0H, value 80H: after DDH or FDH, every opcode 80H-BFH, the arithmetic with (IX+d), regular, three bytes.
2160-2162
DEFB 0FFH, 21H, 04H FF 21 04
2160H-2162H: mask FFH, value 21H: LD IX,nn or LD IY,nn, regular, four bytes.
2163-2165
DEFB 0FFH, 22H, 04H FF 22 04
2163H-2165H: mask FFH, value 22H: LD (nn),IX or LD (nn),IY, regular, four bytes.
2166-2168
DEFB 0FFH, 2AH, 04H FF 2A 04
2166H-2168H: mask FFH, value 2AH: LD IX,(nn) or LD IY,(nn), regular, four bytes.
2169-216B
DEFB 0FFH, 36H, 04H FF 36 04
2169H-216BH: mask FFH, value 36H: LD (IX+d),n or LD (IY+d),n, regular, four bytes.
216C-216E
DEFB 0FFH, 0CBH, 04H FF CB 04
216CH-216EH: mask FFH, value CBH: the bit and shift instructions with (IX+d) or (IY+d), regular, four bytes.
216F-2171
DEFB 0FFH, 0E9H, 22H FF E9 22
216FH-2171H: mask FFH, value E9H: JP (IX) or JP (IY), kind 2, two bytes; 210EH reads which one from this E9H instead of the prefix (B31).
2172
DEFB 02H 02
2172H: 02H, the end of XY_TAB: every other instruction after DDH or FDH (ADD IX,rr, INC IX, PUSH IX, LD SP,IX and the like) is regular and two bytes long.

2173H - WRMEM and GRPHIC: a Line of Memory

WRMEM shows the 16 bytes from Register Pair HL after an equals sign and a greater than sign: in hex, each byte after a separator, then a space and the same bytes as characters, with a space between the eighth and the ninth in both halves, 69 characters in all. GRPHIC writes each separator: a space, or the two graphic bars around the byte at the modification address NXTADR, AAH (the right half of the character cell lit) before it and 95H (the left half lit) after it, so the bars touch the two digits. The bar after the byte is the separator of the byte that follows; for a byte at the end of a line there is none, so it gets only the bar before it, and the bar after it shows in front of the first byte of any line that starts at the next address (B36).

2173WRMEM
PUSH BC C5
WRMEM: push Register Pair BC (Register B the count of the caller's lines) onto the stack (Stack Pointer).
2174
LD A,3DH 3E 3D
Load Register A with 3DH, the equals sign that starts the memory line.
2176
Call @DSP at 0642H to show the equals sign in Register A.
2179
INC A 3C
Increment Register A to 3EH, the greater than sign.
217A
Call @DSP at 0642H to show the greater than sign in Register A.
217D
LD B,10H 06 10
Load Register B with 10H, the 16 bytes of the line (the source's comment says lines).
217F
PUSH HL E5
Push Register Pair HL (the first address of the line) onto the stack (Stack Pointer) for the ASCII half.
2180
Call 21A4H (GRPHIC) for the separator before the byte at Register Pair HL: a space, a bar, and the extra space after the eighth byte.
2183
Call 2211H (WR1HEX@) to show the byte at Register Pair HL as two hex digits; Register Pair HL steps to the next byte.
2186
Decrement Register B and jump back to 2180H until Register B is 0, all 16 bytes shown in hex.
2188
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the first address of the line again.
2189
Call 2231H (WRSPA@) to show the space between the hex and the ASCII.
218C
LD B,10H 06 10
Load Register B with 10H, the 16 characters of the ASCII half.
218E
Call 21C3H to show a space before the ninth character, when Register B is 08H.
2191
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL.
2192
CP 20H FE 20
Compare Register A with 20H: the control codes 00H-1FH cannot be shown.
2194
Jump to 219AH if Register A is below 20H, to show a period instead.
2196
CP C0H FE C0
Compare Register A with C0H: the tab and special character codes C0H-FFH would move the cursor or change the display.
2198
Jump to 219CH if Register A is below C0H: 20H-BFH, characters and graphics, are shown as they are.
219A
LD A,2EH 3E 2E
Load Register A with 2EH, the period shown for 00H-1FH and C0H-FFH.
219C
Call @DSP at 0642H to show the character in Register A.
219F
INC HL 23
Increment Register Pair HL to the next byte of the ASCII half.
21A0
Decrement Register B and jump back to 218EH until Register B is 0, all 16 characters shown; Register Pair HL is the first address of the next line.
21A2
POP BC C1
Pop Register Pair BC from the stack (Stack Pointer): Register B is the caller's line count again.
21A3
RET C9
Return with Register Pair HL 16 bytes on, at the start of the next line.
21A4GRPHIC
LD DE,(00A3H) ED 5B A3 00LD DE,(NXTADR)
GRPHIC: load Register Pair DE with 00A3H (NXTADR), the modification address.
21A8
INC DE 13
Increment Register Pair DE: the byte after the modification address, the one whose separator is the closing bar.
21A9
PUSH HL E5
Push Register Pair HL (the address of the byte about to be shown) onto the stack (Stack Pointer).
21AA
XOR A AF
Clear Register A to 00H, which also clears Carry for the subtraction.
21AB
SBC HL,DE ED 52
Subtract Register Pair DE from Register Pair HL: Zero when this byte follows the modification address.
21AD
LD A,95H 3E 95
Load Register A with 95H, the graphic character with its left half lit, the bar after the framed byte.
21AF
Jump to 21BFH if the Zero flag is set, to show the 95H bar in front of this byte, then the space after the eighth.
21B1
Call 21C3H to show a space before the ninth byte, when Register B is 08H, before the separator.
21B4
INC HL 23
Increment Register Pair HL: zero now when this byte is the modification address itself.
21B5
LD A,L 7D
Load Register A with Register L, the low byte of the difference.
21B6
OR H B4
OR Register A with Register H: Zero when Register Pair HL is 0000H, this byte the one at the modification address.
21B7
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the address of the byte about to be shown.
21B8
LD A,AAH 3E AA
Load Register A with AAH, the graphic character with its right half lit, the bar before the framed byte.
21BA
Jump to @DSP at 0642H to show the AAH bar in Register A if the Zero flag is set; its return goes back to WRMEM.
21BD
Jump to 21C7H to show the plain space separator.
21BF
Call @DSP at 0642H to show the 95H bar in Register A after the framed byte.
21C2
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the address of the byte about to be shown.
21C3
LD A,B 78
Load Register A with Register B, the count of the bytes still to show on the line ($?41: also called for the ASCII half).
21C4
CP 08H FE 08
Compare Register A with 08H: 8 left means the ninth byte is next.
21C6
RET NZ C0
Return if Register A is not 08H: no extra space.
21C7
Jump to 2231H (WRSPA@) to show a space; its return goes back to the caller.

21C9H - INPUT@, HEXIN@, CVB and the Hex Output Routines

INPUT@ waits for a key with @KEY, passes over every control code but ENTER, makes the key lower case with SET 5,A (GETASC@ turns that into BIT 5,A for the ASCII mode), shows it and returns Zero for a space or a comma and Carry, with Zero, for ENTER. Nothing can be taken back: there is no backspace, and a key that is not wanted ends the command. HEXIN@ reads hexadecimal digits up to a space, a comma or ENTER; a value of more than four digits keeps the last four, and any other character returns to the command loop at once. It returns Zero with Register Pair HL unchanged when the first key is already a separator, which is how every default works, otherwise the value in Register Pair HL with Zero clear, and Carry when ENTER ended it. The output routines write hex digits in capitals through @DSP. The entries named with an at sign are also called by SYS9, the extended debugger, while SYS5 is in the overlay area.

21C9INPUT@
PUSH DE D5
INPUT@: push Register Pair DE onto the stack (Stack Pointer); @DSP changes it.
21CA
Call @KEY at 0628H (on the BOOT/SYS page), which waits for a key and returns it in Register A.
21CD
CP 0DH FE 0D
Compare Register A with 0DH, ENTER, the key that ends every command line.
21CF
Jump to 21E1H if Register A is ENTER, to return with Carry set.
21D1
CP 20H FE 20
Compare Register A with 20H: the control codes 00H-1FH, arrows and CLEAR among them, are not taken.
21D3
Jump back to 21CAH if Register A is below 20H, to wait for another key.
21D5INPUC@
SET 5,A CB EF
INPUC@: set bit 5 of Register A, making the capitals A to Z lower case (and 40H-5FH into 60H-7FH, 80H-9FH into A0H-BFH, C0H-DFH into E0H-FFH). GETASC@ changes the second byte at 21D6H to 6FH, BIT 5,A, for the ASCII mode.
21D7
Call @DSP at 0642H to show the character in Register A; it comes back in Register A.
21DA
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer).
21DB
CP 2CH FE 2C
Compare Register A with 2CH, the comma, a separator.
21DD
RET Z C8
Return with the Zero flag set if Register A is a comma.
21DE
CP 20H FE 20
Compare Register A with 20H, the space, the other separator: Zero if it is one, and Carry clear for every key taken here.
21E0
RET C9
Return with Register A the key, Zero for a space.
21E1
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer); Register A is 0DH and the Zero flag is set by the compare at 21CDH.
21E2
SCF 37
Set Carry: ENTER returns with Carry and Zero both set.
21E3
RET C9
Return with Register A 0DH, Carry and Zero set: ENTER.
21E4HEXIN@
HEXIN@: call 21C9H (INPUT@) for the first key in Register A.
21E7
RET Z C8
Return if the Zero flag is set: a space, a comma or ENTER first, so no value; Register Pair HL keeps what the caller put in it, the default.
21E8
LD HL,0000H 21 00 00
Load Register Pair HL with 0000H to build the value.
21EB
Call 2200H (CVB) to turn the character in Register A into its value 0-15, Carry if it is not a hex digit.
21EE
Jump to 1E4CH (CMND) if Carry is set: any character that is not a hex digit or a separator ends the command, whatever it was doing.
21F1
ADD HL,HL 29
Add Register Pair HL to itself, the first of four doublings that move the value four bits up.
21F2
ADD HL,HL 29
Add Register Pair HL to itself: the value times four.
21F3
ADD HL,HL 29
Add Register Pair HL to itself again: the value times eight.
21F4
ADD HL,HL 29
Add Register Pair HL to itself a fourth time: the value times 16, the top digit lost when there were more than four.
21F5
OR L B5
OR Register A, the new digit, with Register L, which has its low four bits clear.
21F6
LD L,A 6F
Load Register L with Register A: the digit is the low digit of Register Pair HL.
21F7
Call 21C9H (INPUT@) for the next key in Register A.
21FA
Jump back to 21EBH if the Zero flag is clear: not a separator, another digit.
21FC
RRA 1F
Rotate Register A right through Carry: Register A is the separator, with Carry only after ENTER.
21FD
ADC A,81H CE 81
Add 81H with Carry to Register A, so that Zero is always clear (a value was read) and Carry is set only for ENTER: the RRA made 0DH and Carry into 86H with Carry, and 86H plus 81H plus 1 is 108H; a space gives 91H, a comma 97H.
21FF
RET C9
Return with the value in Register Pair HL, the last four digits typed.
2200CVB
SUB 30H D6 30
CVB: subtract 30H, the character 0, from Register A.
2202
RET C D8
Return with Carry set if Register A was below 30H: not a digit.
2203
ADD A,C9H C6 C9
Add C9H to Register A: the values 00H to 36H (0 to 9 and a to f) give C9H to FFH, anything above 66H (f) carries.
2205
RET C D8
Return with Carry set if Register A was above 66H, the lower case f.
2206
ADD A,06H C6 06
Add 06H to Register A: the letters a to f (FAH to FFH) carry, becoming 00H to 05H.
2208
Jump to 220DH if Carry is set: a letter, to add its 10.
220A
ADD A,27H C6 27
Add 27H to Register A: the digits 0 to 9 (CFH to D8H) give F6H to FFH, while 3AH-60H (the signs : to ` and the capitals, which INPUT@ never passes) carry.
220C
RET C D8
Return with Carry set if Register A carried: not a hex digit.
220DATOF
ADD A,0AH C6 0A
ATOF: add 0AH to Register A: the digits become 00H to 09H, the letters 0AH to 0FH.
220F
OR A B7
OR Register A with itself, clearing the Carry left by the addition (and setting Zero for a 0).
2210
RET C9
Return with the digit's value in Register A and Carry clear.
2211WR1HEX@
LD A,(HL) 7E
WR1HEX@: load Register A with the byte at Register Pair HL, to show it in hex.
2212
INC HL 23
Increment Register Pair HL to the next byte, for the caller's next call.
2213
Jump to 221AH (CV2HEX@) to show Register A as two hex digits.
2215WR2HEX@
LD A,H 7C
WR2HEX@: load Register A with Register H, the high byte of the word to show.
2216
Call 221AH (CV2HEX@) to show Register A as two hex digits.
2219
LD A,L 7D
Load Register A with Register L, the low byte, shown by CV2HEX@ below.
221ACV2HEX@
PUSH AF F5
CV2HEX@: push Register Pair AF onto the stack (Stack Pointer), keeping the byte for its low digit.
221B
RRA 1F
Rotate Register A right, the first of four rotations that bring the high digit down.
221C
RRA 1F
Rotate Register A right a second time, the high digit moving down.
221D
RRA 1F
Rotate Register A right a third time, the high digit moving down.
221E
RRA 1F
Rotate Register A right a fourth time: the high digit is in bits 3-0.
221F
Call 2223H to show bits 3-0 of Register A as a hex digit.
2222
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): the byte again, for its low digit.
2223
AND 0FH E6 0F
AND Register A with 0FH, keeping one digit, 0 to 15.
2225
ADD A,90H C6 90
Add 90H to Register A, the start of the decimal adjust trick that turns 0-15 into ASCII.
2227
DAA 27
Decimal adjust Register A: 0-9 become 90H-99H with Carry clear, 10-15 become 00H-05H with Carry set.
2228
ADC A,40H CE 40
Add 40H with Carry to Register A: D0H-D9H, or 41H-46H.
222A
DAA 27
Decimal adjust Register A again: 30H-39H, the digits 0 to 9, or 41H-46H, the capitals A to F.
222B
Jump to @DSP at 0642H to show the character in Register A; its return goes back to the caller.
222EWRHEX
WRHEX: call 221AH (CV2HEX@) to show Register A as two hex digits, then a space below.
2231WRSPA@
LD A,20H 3E 20
WRSPA@: load Register A with 20H, a space (SYS9 calls this entry too).
2233
Jump to 222BH to show the space in Register A.
2235WR3BYT
WR3BYT: call 223BH to show the character at Register Pair HL, the first of three.
2238
Call 223BH to show the second character at Register Pair HL.
223B
LD A,(HL) 7E
Load Register A with the byte at Register Pair HL, the character to show (the third when the two calls above return).
223C
INC HL 23
Increment Register Pair HL to the next character.
223D
Jump to 222BH to show the character in Register A.

223FH - Commands B, F, J and Q, and the Extended Debugger Hook

B moves a block: B source,destination,length, each part defaulting to the display address, the modification address and 256, with the defaults shown as they are taken; it copies upward with LDIR, so a destination inside the source block above its start repeats the first bytes, and a length of 0 copies 65536 bytes, the debugger with them. F fills: F first,last,byte; it never tests Carry, so ENTER after the first or the last address does not end the line. J moves the Program Counter on by one byte, the way past an RST 30H of the program itself, which would otherwise enter the debugger again on every G. Q reads a port (Q port, then ENTER) or writes one (Q port,byte). The manual marks B, F, J, Q, O and the disk utility as commands of the Model I and III extended debugger; on the Model 4 they are all in SYS5. Any other key goes to the address in EXTDBG$, with Register A holding the key less 30H.

223FBLOCK
CP 62H FE 62
BLOCK: compare Register A with 62H, b: B, move a block of memory.
2241
Jump to 228BH (FILL) if Register A is not b, to try the next command.
2243
LD HL,(00A6H) 2A A6 00LD HL,(DSPADR)
Load Register Pair HL with 00A6H (DSPADR), the display address, the default start of the block.
2246
Call 21E4H (HEXIN@) for the start address in Register Pair HL, the default kept if none is typed.
2249
RET C D8
Return to the command loop if Carry is set: ENTER after the start, or at once, moves nothing.
224A
LD (00A6H),HL 22 A6 00LD (DSPADR),HL
Store Register Pair HL at 00A6H (DSPADR): the display shows the source block afterwards.
224D
Jump to 2257H (BLO1) if the Zero flag is clear: a start address was typed.
224F
Call 2215H (WR2HEX@) to show the default start in Register Pair HL.
2252
LD A,2CH 3E 2C
Load Register A with 2CH, the comma that follows it.
2254
Call @DSP at 0642H to show the comma in Register A.
2257BLO1
LD HL,(00A3H) 2A A3 00LD HL,(NXTADR)
BLO1: load Register Pair HL with 00A3H (NXTADR), the modification address, the default destination.
225A
Call 21E4H (HEXIN@) for the destination in Register Pair HL.
225D
LD (00A3H),HL 22 A3 00LD (NXTADR),HL
Store Register Pair HL at 00A3H (NXTADR): the destination becomes the modification address.
2260
Jump to 226CH (BLO2) if the Zero flag is clear: a destination was typed.
2262
PUSH AF F5
Push Register Pair AF onto the stack (Stack Pointer): Carry tells BLO2 whether ENTER came.
2263
Call 2215H (WR2HEX@) to show the default destination in Register Pair HL.
2266
LD A,2CH 3E 2C
Load Register A with 2CH, the comma that follows the default.
2268
Call @DSP at 0642H to show the comma in Register A.
226B
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): the flags of the destination's HEXIN@.
226CBLO2
LD HL,0100H 21 00 01
BLO2: load Register Pair HL with 0100H, the default length of 256 bytes.
226F
Jump to 2276H (BLO3) if Carry is set: ENTER after the destination, the length is the default.
2271
Call 21E4H (HEXIN@) for the length in Register Pair HL.
2274
Jump to 227BH (BLO4) if the Zero flag is clear: a length was typed.
2276BLO3
PUSH HL E5
BLO3: push Register Pair HL (the length) onto the stack (Stack Pointer).
2277
Call 2215H (WR2HEX@) to show the default length in Register Pair HL.
227A
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the length.
227BBLO4
LD B,H 44
BLO4: load Register B with Register H, the high byte of the length.
227C
LD C,L 4D
Load Register C with Register L: Register Pair BC is the length, 0000H meaning 65536.
227D
LD HL,(00A6H) 2A A6 00LD HL,(DSPADR)
Load Register Pair HL with 00A6H (DSPADR), the start of the source.
2280
LD DE,(00A3H) ED 5B A3 00LD DE,(NXTADR)
Load Register Pair DE with 00A3H (NXTADR), the destination.
2284
LDIR ED B0
Copy Register Pair BC bytes from Register Pair HL to Register Pair DE, upward (LDIR).
2286
LD (00A3H),DE ED 53 A3 00LD (NXTADR),DE
Store Register Pair DE at 00A3H (NXTADR): the modification address is the byte after the copy.
228A
RET C9
Return to the command loop, which shows the source block.
228BFILL
CP 66H FE 66
FILL: compare Register A with 66H, f: F, fill memory with a byte.
228D
Jump to 22ABH (JUMP) if Register A is not f, to try the next command.
228F
Call 21E4H (HEXIN@) for the first address in Register Pair HL.
2292
RET Z C8
Return to the command loop if the Zero flag is set: no first address.
2293
PUSH HL E5
Push Register Pair HL (the first address) onto the stack (Stack Pointer).
2294
Call 21E4H (HEXIN@) for the last address in Register Pair HL.
2297
EX (SP),HL E3
Exchange Register Pair HL with the top of the stack (Stack Pointer): Register Pair HL is the first address, the last on the stack.
2298
POP BC C1
Pop Register Pair BC from the stack (Stack Pointer): the last address.
2299
RET Z C8
Return to the command loop if the Zero flag is set: no last address.
229A
PUSH HL E5
Push Register Pair HL (the first address) onto the stack (Stack Pointer) again.
229B
Call 21E4H (HEXIN@) for the fill byte in Register Pair HL.
229E
LD E,L 5D
Load Register E with Register L, the fill byte.
229F
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the first address.
22A0
RET Z C8
Return to the command loop if the Zero flag is set: no fill byte.
22A1
XOR A AF
Clear Register A, and with it Carry, for the first compare only.
22A2FIL1
PUSH HL E5
FIL1: push Register Pair HL (the address to fill) onto the stack (Stack Pointer).
22A3
SBC HL,BC ED 42
Subtract Register Pair BC, the last address, and Carry from Register Pair HL. Carry is clear only the first time; after a byte is stored it is the borrow of the last compare, so the loop goes on while Register Pair HL is not above the last address (B34).
22A5
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the address to fill.
22A6
RET NC D0
Return to the command loop if Carry is clear: the first time when the first address is not below the last, so F a,a,b fills nothing; later once Register Pair HL is past the last, which never happens when the last address is FFFFH (B34).
22A7
LD (HL),E 73
Store Register E, the fill byte, at Register Pair HL.
22A8
INC HL 23
Increment Register Pair HL to the next address.
22A9
Jump back to 22A2H for the next address, with Carry set by the compare.
22ABJUMP
CP 6AH FE 6A
JUMP: compare Register A with 6AH, j: J, move the Program Counter on by one byte.
22AD
Jump to 22B7H (QUERY) if Register A is not j.
22AF
LD HL,(00BEH) 2A BE 00LD HL,(PCREG)
Load Register Pair HL with 00BEH (PCREG), the Program Counter.
22B2
INC HL 23
Increment Register Pair HL by one byte, past an RST 30H or a byte that is not to be run.
22B3
LD (00BEH),HL 22 BE 00LD (PCREG),HL
Store Register Pair HL at 00BEH (PCREG), the new Program Counter.
22B6
RET C9
Return to the command loop, which shows the new pc line.
22B7QUERY
CP 71H FE 71
QUERY: compare Register A with 71H, q: Q, read or write a port.
22B9
Jump to 22DFH (DISKIO) if Register A is not q.
22BB
LD A,1EH 3E 1E
Load Register A with 1EH, the video code that clears to the end of the line.
22BD
Call @DSP at 0642H to send the 1EH in Register A.
22C0
Call 21E4H (HEXIN@) for the port number in Register Pair HL.
22C3
RET Z C8
Return to the command loop if the Zero flag is set: no port.
22C4
LD C,L 4D
Load Register C with Register L, the port number for IN A,(C) or OUT (C),L.
22C5
Jump to 22CEH (QUE1) if Carry is set: ENTER after the port means read it.
22C7
Call 21E4H (HEXIN@) for the byte to write in Register L.
22CA
RET Z C8
Return to the command loop if the Zero flag is set: no byte, nothing written.
22CB
OUT (C),L ED 69
Write Register L to the port in Register C (Register B is on the high address lines, which the Model 4's ports ignore).
22CD
RET C9
Return to the command loop after the byte is written to the port.
22CEQUE1
LD A,3DH 3E 3D
QUE1: load Register A with 3DH, the equals sign before the value read.
22D0
Call @DSP at 0642H to show the equals sign in Register A.
22D3
IN A,(C) ED 78
Read the port in Register C into Register A (Register B on the high address lines).
22D5
Call 221AH (CV2HEX@) to show Register A as two hex digits.
22D8
Jump to 21C9H (INPUT@) to wait for a key, so the value can be read; its return goes to the command loop, which draws the display over it.
22DBEXTDBG
LD HL,(19A4H) 2A A4 19LD HL,(EXTDBG$)
EXTDBG: load Register Pair HL with 19A4H (EXTDBG$), the extended debugger's vector: ORARET@ (1503H) until DEBUG (EXT) puts SYS9's module in high memory.
22DE
JP (HL) E9
Jump to Register Pair HL with Register A holding the key less 30H (from 22DFH; SYS9 compares with e less 0, for example) and the command loop's address 1E4CH on the stack: ORARET@ is OR A and RET, so an unknown command does nothing.

22DFH - DISKIO: the Disk Sector Utility

A digit 0 to 7 as the command is a drive, and the line is read as drive,cylinder,sector,operation,address,count. Without a cylinder the directory cylinder of the drive is used. Without a sector it starts at sector 0 and the count is a whole cylinder; with a sector the count is one sector (the manual says a whole cylinder whenever the count is left out). A count typed replaces either, its low byte only, 0 meaning 256. The operation is R to read, W to write, or an asterisk sign to write sectors with the directory's data mark, and every operation needs a separator and an address after it; any other letter reads and writes nothing. When the address is left out the buffer is whatever Register Pair HL held: the sector typed, else the cylinder typed, else 124CH for the release's drives of 18 sectors a track, inside the resident system (B37). Sector numbers run through both sides of a cylinder and on into the next cylinder; the buffer moves on 256 bytes a sector. On an error the code shows a space and the error number in hex between two asterisk signs, then waits for a key: ENTER ends the work, any other key goes on with the next sector (the manual says to hold ENTER down). After a read the full screen display shows the first sector read.

22DFDISKIO
SUB 30H D6 30
DISKIO: subtract 30H, the character 0, from Register A, the command key, to get a drive number.
22E1
CP 08H FE 08
Compare Register A with 08H: only the drives 0 to 7 have a DCT.
22E3
Jump to 22DBH (EXTDBG) if Register A is 08H or above (or the key was below 0): not a drive, the key less 30H goes to the extended debugger.
22E5
LD C,A 4F
Load Register C with Register A, the drive number, as @GTDCT and the disk SVCs want it.
22E6
Call @GTDCT at 1A1EH (on the SYS0/SYS page) to point Index Register IY at the DCT of the drive in Register C; Register Pair HL comes back as it was, 1E4CH from the command loop.
22E9
LD A,(IY+07H) FD 7E 07
Load Register A with DCT+7 at Index Register IY+07H: bits 7-5 the heads less 1, bits 4-0 the highest sector of a track.
22EC
AND E0H E6 E0
AND Register A with E0H, keeping the heads less 1 in bits 7-5.
22EE
RLCA 07
Rotate Register A left, the first of three rotations that bring bits 7-5 down to bits 2-0.
22EF
RLCA 07
Rotate Register A left a second time, the heads moving down.
22F0
RLCA 07
Rotate Register A left a third time: Register A is the heads less 1.
22F1
INC A 3C
Increment Register A to the number of heads, 1 for a floppy drive.
22F2
LD B,A 47
Load Register B with Register A, the heads, as the count of the additions below.
22F3
LD A,(IY+07H) FD 7E 07
Load Register A with DCT+7 at Index Register IY+07H again, for the sector count.
22F6
AND 1FH E6 1F
AND Register A with 1FH, keeping the highest sector of a track.
22F8
INC A 3C
Increment Register A to the sectors of a track (12H, 18, on the release's drives 0 and 1).
22F9
LD H,A 67
Load Register H with Register A, the sectors of a track; Register L is still 4CH, so Register Pair HL is now 124CH on those drives, the buffer used when no address, sector or cylinder is typed (B37).
22FA
XOR A AF
Clear Register A to 00H to add up the sectors of a cylinder.
22FBDIS1
ADD A,H 84
DIS1: add Register H, the sectors of a track, to Register A.
22FC
Decrement Register B and jump back to 22FBH until Register B is 0, once for each head.
22FE
BIT 5,(IY+04H) FD CB 04 6E
Test bit 5 of DCT+4 at Index Register IY+04H, set for a two sided drive.
2302
Jump to 2305H (DIS2) if bit 5 was clear: one side.
2304
ADD A,A 87
Add Register A to itself: two sided, twice the sectors a cylinder.
2305DIS2
LD (00A2H),A 32 A2 00
DIS2: store Register A at 00A2H (SAVTWO+1), the sectors of a cylinder, the limit of the sector number.
2308
LD A,1EH 3E 1E
Load Register A with 1EH, the video code that clears to the end of the line.
230A
Call @DSP at 0642H to send the 1EH in Register A.
230D
Call 21C9H (INPUT@) for the separator after the drive digit (the source's comment says the cylinder; any key but ENTER is taken).
2310
RET C D8
Return to the command loop if Carry is set: ENTER after the drive digit does nothing.
2311
Call 21E4H (HEXIN@) for the cylinder in Register Pair HL, Zero if none was typed.
2314
RET C D8
Return to the command loop if Carry is set: ENTER after the cylinder does nothing.
2315
LD D,L 55
Load Register D with Register L, the cylinder typed.
2316
Jump to 231BH (DIS3) if the Zero flag is clear: a cylinder was typed.
2318
LD D,(IY+09H) FD 56 09
Load Register D with DCT+9 at Index Register IY+09H, the drive's directory cylinder, the default.
231BDIS3
DIS3: call 21E4H (HEXIN@) for the sector in Register Pair HL, Zero if none was typed.
231E
LD E,L 5D
Load Register E with Register L, the sector typed.
231F
LD A,01H 3E 01
Load Register A with 01H, the count when a sector is typed: one sector.
2321
Jump to 2328H (DIS4) if the Zero flag is clear: a sector was typed.
2323
LD E,00H 1E 00
Load Register E with 00H: no sector typed, start at sector 0.
2325
LD A,(00A2H) 3A A2 00
Load Register A with 00A2H (SAVTWO+1): no sector typed, the count is a whole cylinder.
2328DIS4
LD (00A5H),A 32 A5 00LD (NXTBYT),A
DIS4: store Register A at 00A5H (NXTBYT), the count of sectors.
232B
RET C D8
Return to the command loop if Carry is set: ENTER after the sector does nothing.
232C
Call 21C9H (INPUT@) for the operation in Register A: r, w or the asterisk sign.
232F
RET C D8
Return to the command loop if Carry is set: ENTER instead of an operation.
2330
LD B,A 47
Load Register B with Register A, the operation, kept for the whole loop.
2331
Call 21C9H (INPUT@) for the separator after the operation (the source's comment says the buffer address; any key but ENTER is taken).
2334
RET C D8
Return to the command loop if Carry is set: ENTER after the operation does nothing.
2335
Call 21E4H (HEXIN@) for the buffer address in Register Pair HL; with none typed, Register Pair HL keeps the last number typed, the sector, else the cylinder, else the 124CH (on those drives) built at 22F9H (B37).
2338
PUSH HL E5
Push Register Pair HL (the first buffer address) onto the stack (Stack Pointer) for the end.
2339
Jump to 2346H (DIS6) if Carry is set: ENTER after the address, the count stays.
233B
PUSH HL E5
Push Register Pair HL (the buffer address) onto the stack (Stack Pointer) while the count is read.
233C
Call 21E4H (HEXIN@) for the count in Register Pair HL, Zero if none was typed.
233F
LD A,L 7D
Load Register A with Register L, the low byte of the count.
2340
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the buffer address.
2341
Jump to 2346H (DIS6) if the Zero flag is set: no count typed.
2343
LD (00A5H),A 32 A5 00LD (NXTBYT),A
Store Register A at 00A5H (NXTBYT), the count typed; 00H gives 256 sectors.
2346DIS6
LD A,B 78
DIS6: load Register A with Register B, the operation.
2347
CP 72H FE 72
Compare Register A with 72H, r: read the sectors into the buffer.
2349
Jump to 237BH if Register A is r, to clear the buffer and read.
234B
CP 77H FE 77
Compare Register A with 77H, w: write the buffer to the sectors.
234D
Jump to 2396H (DIS10) if Register A is w, to write a sector.
234F
CP 2AH FE 2A
Compare Register A with 2AH, the asterisk sign: write with the directory's data mark.
2351
Jump to 239DH (DIS11) if Register A is the asterisk sign; any other operation only counts the sectors.
2353DIS7
INC H 24
DIS7: increment Register H: the buffer moves on 256 bytes for the next sector.
2354
INC E 1C
Increment Register E, the sector number, for the next sector.
2355
LD A,(00A2H) 3A A2 00
Load Register A with 00A2H (SAVTWO+1), the sectors of a cylinder.
2358
DEC A 3D
Decrement Register A to the highest sector number of the cylinder.
2359
CP E BB
Compare Register A with Register E, the next sector number.
235A
Jump to 235FH (DIS8) if Register A is not below Register E: the sector is on this cylinder.
235C
LD E,00H 1E 00
Load Register E with 00H, the first sector of the next cylinder.
235E
INC D 14
Increment Register D, the cylinder, when a cylinder is used up.
235FDIS8
LD A,(00A5H) 3A A5 00LD A,(NXTBYT)
DIS8: load Register A with 00A5H (NXTBYT), the sectors still to do.
2362
DEC A 3D
Decrement Register A, the count of the sectors still to do: one done.
2363
LD (00A5H),A 32 A5 00LD (NXTBYT),A
Store Register A at 00A5H (NXTBYT), the sectors still to do.
2366
Jump back to 2346H (DIS6) if Register A is not zero: more sectors.
2368DIS8A
POP HL E1
DIS8A: pop Register Pair HL from the stack (Stack Pointer): the first buffer address.
2369
LD A,B 78
Load Register A with Register B, the operation.
236A
CP 72H FE 72
Compare Register A with 72H, r: only a read changes the display.
236C
RET NZ C0
Return to the command loop if Register A is not r: after a write the display stays as it was.
236D
LD L,00H 2E 00
Load Register L with 00H, the start of the buffer's page.
236F
LD (00A6H),HL 22 A6 00LD (DSPADR),HL
Store Register Pair HL at 00A6H (DSPADR): the display starts at the first sector read.
2372
LD (00A3H),HL 22 A3 00LD (NXTADR),HL
Store Register Pair HL at 00A3H (NXTADR): the bars mark its first byte.
2375
LD A,73H 3E 73
Load Register A with 73H, s, the non zero flag of the full screen display.
2377
LD (00A1H),A 32 A1 00LD (SAVTWO),A
Store Register A at 00A1H (SAVTWO): the full screen display shows the sector.
237A
RET C9
Return to the command loop, which shows the first sector read.
237BDIS9
PUSH HL E5
DIS9, read: push Register Pair HL (the buffer) onto the stack (Stack Pointer).
237C
PUSH DE D5
Push Register Pair DE (the cylinder and the sector) onto the stack (Stack Pointer).
237D
PUSH BC C5
Push Register Pair BC (the operation and the drive) onto the stack (Stack Pointer).
237E
LD D,H 54
Load Register D with Register H, to make Register Pair DE the buffer address.
237F
LD E,L 5D
Load Register E with Register L: Register Pair DE is the buffer address.
2380
INC DE 13
Increment Register Pair DE to the second byte of the buffer.
2381
LD (HL),00H 36 00
Store 00H at Register Pair HL, the first byte of the buffer.
2383
LD BC,00FFH 01 FF 00
Load Register Pair BC with 00FFH, the other 255 bytes.
2386
LDIR ED B0
Copy the 00H on through the 256 bytes from Register Pair HL to Register Pair DE, Register Pair BC counting (LDIR): the buffer is cleared, so a sector that cannot be read shows zeros.
2388
POP BC C1
Pop Register Pair BC from the stack (Stack Pointer): Register B the operation, Register C the drive.
2389
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer): Register D the cylinder, Register E the sector.
238A
POP HL E1
Pop Register Pair HL from the stack (Stack Pointer): the buffer.
238B
Call @RDSEC at 19F4H (on the SYS0/SYS page) to read the sector of Register Pair DE on the drive in Register C into the buffer at Register Pair HL.
238E
Jump to 2353H (DIS7) if the Zero flag is set: the sector was read.
2390
CP 06H FE 06
Compare Register A, the error code, with 06H, the code for a sector with the directory's data mark.
2392
Jump to 2353H (DIS7) if Register A is 06H: a directory sector was read, which is no error here.
2394
Jump to 23A2H (DIS12) to show the error code of the read.
2396DIS10
DIS10: call @WRSEC at 19E8H (on the SYS0/SYS page) to write the buffer at Register Pair HL to the sector of Register Pair DE on the drive in Register C.
2399
Jump to 2353H (DIS7) if the Zero flag is set: the sector was written.
239B
Jump to 23A2H (DIS12) to show the error code of the write.
239DDIS11
DIS11: call @WRSSC at 19ECH (on the SYS0/SYS page) to write the buffer at Register Pair HL to the sector of Register Pair DE on the drive in Register C with the directory's data mark.
23A0
Jump to 2353H (DIS7) if the Zero flag is set: the sector was written.
23A2DIS12
PUSH DE D5
DIS12: push Register Pair DE (the cylinder and the sector) onto the stack (Stack Pointer).
23A3
PUSH AF F5
Push Register Pair AF (Register A the error code) onto the stack (Stack Pointer).
23A4
Call 2231H (WRSPA@) to show a space before the error number.
23A7
LD A,2AH 3E 2A
Load Register A with 2AH, the asterisk sign before the error number.
23A9
Call @DSP at 0642H to show the asterisk sign in Register A.
23AC
POP AF F1
Pop Register Pair AF from the stack (Stack Pointer): Register A the error code.
23AD
Call 221AH (CV2HEX@) to show the error code in Register A as two hex digits (0FH for error 15).
23B0
LD A,2AH 3E 2A
Load Register A with 2AH, the asterisk sign after the error number (the source's comment says a space).
23B2
Call @DSP at 0642H to show the asterisk sign in Register A.
23B5
Call 21C9H (INPUT@) to wait for a key: Carry for ENTER.
23B8
POP DE D1
Pop Register Pair DE from the stack (Stack Pointer): the cylinder and the sector.
23B9
Jump to 2353H (DIS7) if Carry is clear: any key but ENTER goes on with the next sector.
23BB
Jump to 2368H (DIS8A) to end the work on ENTER.
23BD-23FD
DEFS 65
23BDH-23FDH: the rest of the overlay area, not loaded by SYS5/SYS; it holds what was there before. DIRBUF$ (2300H-23FFH) overlaps the last 189 bytes of SYS5's code, which nothing in SYS5 reads a directory into.
23FE-23FF
DEFW 05BDH BD 05
23FEH-23FFH = 05BDH (1469): the length of SYS5, 1E00H to 23BCH (LAST less 1E00H). SYSTEM (SYSRES) reads it when it copies the overlay into high memory to keep it resident.