A system and method are presented for saving and restoring the state of a diagnostic
module in a microprocessor. The diagnostic module contains a complex break state
machine, capable of halting the microprocessor at specified breakpoints. These
breakpoints are based on combinations of instruction locations and/or data values,
along with previous machine states. A problem occurs with prior art diagnostic
modules when the processor returns from an exception occurring during a fix-up
cycle inserted to handle a data load miss associated with an instruction located
in a branch delay slot (the location immediately following a conditional branch
instruction). Under these circumstances, the exception handler restores the program
counter to the location of the branch instruction, causing the branch to be re-executed.
The prior art state machine erroneously updates its internal state a second time
when the branch is re-executed. According to the system and method disclosed herein,
at each state change the previous machine state saved. Thus, when a branch instruction
is re-executed, the complex break state machine of the present invention is restored
to its previous state, thereby correcting the error.