CP/M Commands. Excerpt from David E. Cortesi Inside CP/M © 1982


DDT Dynamic Debugging Tool


DDT is used to debug programs written in assembly language. It also finds use as a special utility program for building program images, and in applying patches to fix programs.

See the USER command for an example of using DDT to load the image of a command. An assembly-language program can be built from different modules, each assembled at a different, known origin. For example, a main program might contain a reserved space for a terminal driver subroutine. Different terminal drivers can be prepared, each customized for a particular terminal type. The correct driver can then be incorporated in the main program with DDT:

ddt main.com load image of main program

-iterm120.hex prepare to load driver for Soroq IQ120

-r read terminal driver to its origin

-g0 warm start, leaving merged program

save 37 main120.com save customized command program


DDT{ fileref}

The DDT command initializes a debugging session. The code of the debugger is loaded and moved to the top of the Transient Program Area. replacing the CCP. The address of the end of the Transient Program Area in low storage is changed to protect the debugger.

If fileref is specified, that file is loaded into the Transient Program Area. The reference must be explicit and have a filetype of either .HEX or .COM. A .COM file is loaded at 0100h: a .HEX file is loaded at its assembled origin.

The debugger then prompts with a hyphen and waits for a subcommand. A table of DDT subcommands follows this topic.

The command is ended by a warm start. One may be obtained either by typing control-c or by entering the G0 (go to zero, i.e., to the warm start jump) subcommand.


Summary of DDT Subcommands

Syntax Description

Astart Assemble into storage: DDT prompts with successive addresses from start. Enter operation names, and register names or hex values as operands. End the process with a null entry.

D{start} {, end} Display storage: DDT displays storage in hex and ASCII, 16 bytes per line. The display begins with start if given, or where the prior D left off, or with the HL value of the last instruction traced. It ends with end if given, or after 12 lines. Use any key to end the display early.

Fstart,end,xx Fill storage: DDT replicates xx in every byte from start through end. Caution: DDT will happily fill right over itself and the BDOS if told to do so.

G{start}{,b1{,b2}} Execute program: DDT transfers control to start if given, or to the test program's PC. If one or two break addresses are given, DDT makes each an RST 7 instruction: control returns to DDT if the program reaches one and the instructions are restored.

Hfirst,second Hex arithmetic: DDT responds with two numbers, first ^ second

and first-second.

Ifileref Initialize FCB: fileref is set in the default FCB at 5Ch. Any drivecode is ignored. The FCB may be used by the test program: more often it is used by the R subcommand. Use S to set up a drive number.

L{start}{,end} List instructions: DDT displays storage as instructions in assembler format, from start if given, or where the last L left off, or from the PC address of the last traced instruction. The display ends with end if given, or after 11 lines have been typed. Use the delete key to stop the display.

Mstart,end,to Copy storage: DDT copies the block of storage from start

through end to the address to.

R{bias} Read program: The file named in the default FCB at 5Ch is loaded as a program. The filetype must be .COM (load address is OlOOh+^f'a.?) or must have the .HEX format. In that case the bias is added to the load address in each line, causing the file to load away from its assembled origin. The highest load address this session and the current PC value are displayed.

Sstart Modify storage: DDT prompts with the address start and that byte's contents in hex. Enter a new value, or CR alone, to leave it unchanged. DDT prompts with the next address; enterperiod, CR to end.

T{count} Trace program: An instruction is traced. The test program PC provides its address; use X to set it. The register state and the instruction are shown before the instruction is done; use X to see the instruction's effect. If count is given, DDT continues for that many instructions; use the delete key to stop it early.

U{count} Trace without display: Instructions are traced as for T but no

state display is typed.

X Display program state: The test program registers and the instruction addressed by its PC are shown.

Xregister Modify register: DDT prompts with the contents of the named register or flag. Enter CR alone to leave them unchanged, or enter a new value. The registers are A, B, D, H, S (for SP), and P (for PC). Flags are C, Z, M, E, and I.