- BRK
In 6502 assembly language programming, BRK is an
opcode that causes asoftware interrupt or trap. The generalized actions of BRK are as follows:* The B
bit in theprocessor status register is set to indicate that a BRK instruction is being processed.
* Theprogram counter is incremented by two and thenpushed on to the stack, most significantbyte first.* The
status register ispushed on to the stack.*
Maskable interrupt s (IRQ) are disabled by setting the I bit in thestatus register .* The
program counter is loaded with the address stored in memory address 0xFFFE (LSB) and 0xFFFF (MSB—the 6502 islittle endian ), and execution is continued at that point.Note that neither the accumulator or
index registers are pushed on to the stack. Also, the vector (0xFFFE) through which theprocessor jumps in response to BRK is the same as that for aninterrupt request , requiring that the IRQ service routine get a copy of thestatus register from the stack to check the Bbit so as to determine whether the interrupt was hardware or software.In the original 6502, the simultaneous assertion of a
hardware interrupt line and execution of BRK was not accounted for in the design—the BRK instruction will be ignored in such a case. Also, the status of thedecimal mode flag in theprocessor status register was preserved, which could potentially result in a difficult to locate bug in theinterrupt handler ifdecimal mode happened to be enabled at the time of BRK being executed. This was fixed in theCMOS versions of the processor.
Wikimedia Foundation. 2010.