Appendix G — Debug Expressions

Debug80 supports Z80-focused expressions in the standard VS Code Watch panel and in conditional breakpoints. Add Watches while the program is paused. Add a breakpoint condition by right-clicking a breakpoint and choosing Edit Breakpoint.

Examples

These examples show the shape of the expression language:

A
HL
PC
zero
not carry
PACMO_LIVES
[PACMO_LIVES]
[HL]
[IX + 4]
PC eq MainLoop
[PACMO_LIVES] eq 0
zero and A eq 0
(A ^ $ff) eq $df

Registers

Watch expressions can refer directly to Z80 registers:

A
B
C
BC
DE
HL
IX
IY
SP
PC
I
R

Alternate registers are supported:

A'
BC'
DE'
HL'
AF'

Index-register and stack-pointer halves are supported:

IXH
IXL
IYH
IYL
SPH
SPL

Flags

Flags use spelled-out names:

zero
carry
sign
parity
halfCarry

This keeps carry separate from the C register.

zero
not carry
zero and A eq 0

Symbols

Symbols from the active source map can be used by name. A symbol by itself evaluates to its address or constant value.

MainLoop
PACMO_LIVES
PC eq MainLoop

Build the active target again if a symbol Watch is missing or appears stale.

Memory Reads

Square brackets read one byte from memory at the address inside the brackets:

[HL]
[PACMO_LIVES]
[IX + 4]

Parentheses group expressions:

(A + 1) eq $21
([FLAGS] & $80) ne 0

Operators

Arithmetic operators:

+ - * / %

Bitwise operators:

& | ^ ~

Comparison operators:

eq ne lt le gt ge

Logical operators:

and or not

The ^ operator is bitwise XOR.

Truth Values

Debug80 treats zero as false and any non-zero value as true:

A
[PLAYER_LIVES]
not [PLAYER_LIVES]
carry or zero

Conditional breakpoints use the same syntax. When execution reaches a conditional breakpoint, a true or non-zero expression stops the program. A false or zero expression lets execution continue. If the expression cannot be evaluated, Debug80 stops and reports the error in the Debug Console.