Champ: Debug, set breakpoints, monitor registers, step though code

Gilbert Francois Duivesteijn

< Back to main page

header

This page shows how to use Champ for debugging, stepping through code, inspect registers and more. It is by far the most interesting page about champ on this website :) Let's start with typing in some code. Our test code is absolutely useless and does not do much. But it will help to demonstrate all the goodies that Champ has to offer as a complete development tool.

 

This code example does the following things:

The program does not give an output to screen. We can only observe the changes with the Champ Debugger.

Type in the listing or download it from the download section on this page. At the end, a ENDPROG label is added. This will help later when saving the binary to cassette. To save the source, go to <Assembly> mode and type S DBGSRC. You can also download the source file at the bottom of the page, if you don't feel like typing it in yourself.
In go to <Assembly> mode, compile the program with A, 2. Note that the data array of SMILEY starts at $C01D, as shown in the symbol table.

 

Memory monitor

D saddr [faddr]

To see the compiled program as bytes in memory, type . You can clearly see the reserved memory for our data array, 8 times $F0.

 

Disassember

Q saddr [faddr]

This shows the disassembled code, from the given start address.

 

Step through code, inspect registers and flags

J saddr, J, J...

The J saddr allows you to step through code line by line. Continue by pressing J to step into the next line. This view shows the registers, flags, program count, program listing, etc.

In this example on the left, you can see that the program has executed the first 3 lines of the code, loaded registers LH, DE and BC with values. When you press at this point another time J, the line CALL LDIRMV is executed and the labeled data array SMILEY is filled with new data.

 

Inspect variable

H label

To see the address of a label, type e.g. H SMILEY. The memory address of the label is then snown in HEX, DEC and BIN format. The value of the memory can be inspected with D saddr faddr. In the case of the example, where SMILEY is an array of 8 bytes:

H SMILEY
D $C01D $C024

It shows the initial values of the array. Now run the program and inspect again the SMILEY array.

G $C000
D $C01D $C024

We see now that the array is filled with the inverted smiley.

 

Set breakpoint

Bn=addr

Set a breakpoint at given address, where n is a number between 1 and 8. E.g.

B1=C00C

A breakpoint is set just after the copy command from VRAM to RAM. When running the program from the start, it will stop at the breakpoint and show the register and program counter view.

 

List breakpoints

T

Show all breakpoints

 

Show all labels

D E000

Show all labels. Every label uses 8 bytes. The first 2 bytes indicate the memory address, the second 6 bytes are filled with the label name. Note that the labels are stored in human readible order (big endian). In the example on the left, we can see our own defined labels SMILEY (at address $C01D), AGAIN and PRGEND.

 

Clear memory, fill memory

F saddr faddr value

Most of the time, it can be helpful to clear the memory, before running the program again. To do that, you can use the fill command F. E.g. if we want to clear the memory, recompile the program, you can do: F C000 C0FF 00

 

Downloads