# AppleWin Debugger Tutorial

## Breakpoints

You now have a variety of options when specifying a breakpoint. Breakpoints can also be disabled, and later re-enabled. This lets ones set a bunch of breakpoints, and quickly re-activate them without having to re-enter the breakpoint logic.

Command | Effect
BPA r [op] value | Adds (conditional) Breakpoint. Default operator is equal ‘=’ (In a future version, will dispatch to BPX, BPR, BPP, or BPIO.)
BPX BPX expression BPX address[,len] BPX [op] symbol | Add Breakpoint trigger to stop executing when the PC is within the range of the Address, Symbol, or Expression. i.e. Range is: [addr,addr+len) Default length is 1. Default comparison operator is equal ‘=’
BP | Currently an Alias for BPX. (In a future version, will also support Loading and Saving of breakpoints.)
BPM address[,len] | Add Breakpoint trigger when memory is accessed by CPU or hard disk controller's DMA.
BPMR address[,len] | Add Breakpoint trigger when memory is read by CPU or hard disk controller's DMA.
BPMW address[,len] | Add Breakpoint trigger when memory is written by CPU or hard disk controller's DMA.
BPR reg [op] value | Add Breakpoint trigger when Register’s ‘reg’ value is compared to the Value.
BPV vpos[,len] | Add Breakpoint trigger when video-scanner's vertical position matches vpos. (NB. Auto-disable when hit.)
BPD # | Disable Breakpoint (grayed out).
BPE # | Enable Breakpoint (colored red).
BPC # | Clear specified Breakpoint. Note: The asterisk ‘*’ may be used to clear all breakpoints.
BPL | List Breakpoints.
BPIO | (In a future version, will add Breakpoint trigger on memory read or write.)
BPP | (In a future version, will add Breakpoint trigger on specific flag cleared or set.)
BRK [0|1|2|3|all] [on|off] | Break on BRK or Invalid 1-3 byte opcodes
BRKOP [opcode] | Break on Opcode
BRKINT [on|off] | Break on Interrupt

The general format for the conditional breakpoint is:

- BPA register [operator] value.

You can use the following comparison operators:

Op | Name | Effect
= | Equal | Break when register is equal to value.
! | Not Equal | Break when register is not equal to value.
< | Less Than | Break when register is less than value.
> | Greater Than | Break when register is greater than value.
<= | Less Than or Equal | Break when register is less than or equal to value.
>= | Greater Than or Equal | Break when register is greater than or equal to value.

Breaking on any of the 6502 registers is fully supported:

Reg | Name | Effect
A | Accumulator | Break when Accumulator is triggered.
X | Register X | Break when Index X is triggered.
Y | Register Y | Break when Index Y is triggered.
PC | Program Counter | Break when PC is triggered.
S | Stack Pointer | Break when Stack Pointer is triggered.
P | Processor Status (flags) | Break when flags are triggered.

## Notes:

- BPP, Breaking on a specific flag (either set, or cleared) is forthcoming in a future version.

You can use the following optional address prefixes (each delimited by a "/" or forward-slash):

Prefix | Name | Effect
s<n> | Slot | Specify slot 0-7 for Saturn card.
<nnn> | Bank number | Specify bank 00 (main) 01-100 for RamWorks card's 64K bank or 0-7 for Saturn card's 16K bank.
l<1|2> | Language Card 4K bank 1 or 2 | Specify language card 4K bank.
rom | ROM | Specify ROM. (Can't be used with other prefixes.)

## Notes:

- The order of prefixes doesn't matter, and prefixes are case-insensitive.

- In the image above, prefixing the blue "M" are the bank number (white "01") and LC bank (green "2"), and after the address range is a green "R" meaning trigger on-read. So this breakpoint was set using 'BPMR 01/L2/D000,1000'

Examples:

Input | Effect
BPX < FA62 | Add Breakpoint when PC < $FA62.
BPR PC < D000 | Add Breakpoint when PC < $D000.
BPR A 0 | Add Breakpoint when Accumulator is zero.
BPR A ! 0 | Add Breakpoint when Accumulator is not zero.
BPR S < 1FF | Add Breakpoint when Stack has had something pushed onto it.
BPV A0 | Add Breakpoint when video-scanner is at line 160 ($A0) which is the start of the MIXED area.
BRK ON | Break execution when the opcode to be executed is $00 (ie. BRK).
BRK ALL ON | Break execution when the opcode to be executed is $00 (ie. BRK) or any Invalid opcode.
BRK 0 OFF | Disable breaking execution when the opcode to be executed is $00 (ie. BRK).
BRKOP 6C | Break execution when the opcode to be executed is $6C (ie. JMP (ABS)).
BRKINT ON | Break execution just after an interrupt occurs.
BPM E000,2000 | Add breakpoint when an access occurs to main or aux memory or ROM in the range $E000-FFFF.
BP 00/L1/D000 | Add breakpoint when PC = main memory language card's 4K bank 1 at $D000.
BPMW 01/D000,1000 | Add breakpoint when a write occurs to aux memory (either 4K bank) in the range $D000-DFFF.
BP ROM/FF58 | Add breakpoint when PC = ROM at $FF58.
BPM S3/7/L1/D800 | Add breakpoint when an access occurs to slot 3's Saturn card's 16K bank 7, 4K bank 1 at $D800.