From C64-Wiki
Jump to navigationJump to search

BRK (short for "BReaKpoint") is the mnemonic for a machine language instruction which sets the break and interrupt flags, increments the program counter by two and stores it along with the processor status flags onto the stack. Finally it raises an IRQ interrupt event.

BRK is intended for use as a debugging tool which a programmer may place at specific points in a program, to check the state of processor flags at these points in the code. Most machine language monitors are "hooked" onto the warm start, and set up to fetch and display the program counter and processor status flags that were pushed onto the stack by a BRK instruction.

Note that since BRK increments the program counter by 2 instead of 1, it is advisable to use a NOP after it to avoid issues.

Addressing mode[edit | edit source]

Opcode Addressing
in bytes
Number of
Dec Hex
0 00 Implied BRK 1 7

BRK only supports the implied addressing mode, as shown in the table at right.

CPU flags[edit | edit source]

BRK affects 2 of the CPU's status flags: