User`s manual

94 digi.com Debugging with Dynamic C
Example There are numerous examples of using printf() in the programs provided in
the Samples folder where you installed Dynamic C.
To display a string to the Stdio window place the following line of code in your
application:
printf("Entering my_function().\n");
To do the same thing, but without using root memory:
xdata entering {“Entering my_function().”};
...
printf("%ls\n", entering);
6.3.2 Software Breakpoints
Software breakpoints have always been available in Dynamic C. They have been improved over several
versions: the “Clear All Breakpoints” command was introduced in DC 7.10; the ability to set breakpoints
in ISRs was introduced in DC 7.30; DC 9 introduces persistent breakpoints and the ability to set break-
points in edit mode.
Pros Software breakpoints can be set on any C statement unless it is marked “node-
bug” and in any “#asm debug” assembly block. Breakpoints let you run a pro-
gram at full speed until the specified stopping point is reached. You can set
multiple breakpoints in a program or even on the same line. They are easy to tog-
gle on and off individually and can all be cleared with one command. You can
choose whether to leave interrupts turned on (soft breakpoint) or not (hard
breakpoint).
When stopped at a breakpoint, you can examine up-to-date contents in debug
windows and choose other debugging features to employ, such as single step-
ping, dumping memory, fly-over watch expressions.
Cons To support large sector flash, breakpoint internals require that breakpoint over-
head remain, even when the breakpoint has been toggled off. Recompile the pro-
gram to remove this overhead.
When the debug keyword is added to an assembly block, relative jumps (which
are limited to 128 bytes) may go out of range. If this happens, change the JR in-
struction to a JP instruction. Another solution is to embed a null C statement in
the assembly code like so:
#asm
...
c ; // Set a breakpoint on the semicolon
...
#endasm
Uses Use software breakpoints when you need to stop at a specified location to begin
single stepping or to examine variables, memory locations or register values.