Debug your program
A debugger lets you stop a program and look inside the machine: which instruction runs next, what the registers hold, and what is in memory. On this page you stop the border-colours program from the previous page and step through it.
Stop at a breakpoint
Set a breakpoint
In the editor, click just left of the line number 13, the line out (#fe),a. A red dot appears: that is a breakpoint. Click the dot again to remove it.
Start debugging
Click Debug on the build bar, or press Ctrl+F5. Klive builds and starts the program as before, but now it stops when it reaches the breakpoint.
Open the Debug side bar
Click the Debug icon in the activity bar, the second one from the top.
123- The breakpoint. The highlighted line is the instruction that runs next: the machine stopped before running it.
- The stepping buttons on the toolbar: Step Into, Step Over and Step Out.
- The Z80 CPU panel shows the registers.
Aholds07, the colour about to be written: white.
Step through the code
Press F10 (Step Over) twice. Each press runs one instruction and stops again.
1- The machine stopped at
halt. On the way,out (#fe),aset the border to white, andld e,25put 25 intoE; check it in the Z80 CPU panel.
Look at the emulator, too. The machine stopped in the middle of drawing a frame, so the screen is drawn only down to where the beam had got to. The hatched part below it is still the previous frame, and the label at the top says exactly where the beam is.
To see this, the beam position must be turned on. If the emulator’s screen shows no hatched part, click Show/Hide the beam position while paused on the emulator’s toolbar: the icon with a line between four corner marks, highlighted while it is on.

The stepping commands
| Command | Shortcut | What it does |
|---|---|---|
| Continue | F5 | Runs until the next breakpoint. |
| Step Into | F11 (F12 on macOS) | Runs one instruction. On a CALL, stops at the first instruction of the subroutine. |
| Step Over | F10 | Runs one instruction. A CALL, an RST or a block instruction such as LDIR runs completely. |
| Step Out | Shift+F11 (Shift+F12 on macOS) | Runs until the current subroutine returns. |
| Stop | F4 | Switches the machine off. |
Press F5 a few times: each time, the program runs once around its loop and stops at the breakpoint again, with A one less than before.
More to look at
The Debug side bar has more panels; click a title to open or close one. The toolbar’s last buttons open the Memory and Disassembly views. Breakpoints explains conditions, hit counts and memory breakpoints, and the other debugging guides cover every view.
Next, write your first BASIC program.