Laptop User Manual
Preserving the Debugger Operating Environment
MVME166IG/D2 4-15
4
The following is an example of an exception handler which can pass an 
exception along to the debugger: 
*
*** EXCEPT - Exception handler ****
*
EXCEPT SUBQ.L #4,A7    Save space in stack for a PC value.
  LINK A6,#0    Frame pointer for accessing PC space.
  MOVEM.L A0-A5/D0-D7,-(SP)  Save registers.
  :
  : decide here if your code handles exception, if so, branch...
  :
  MOVE.L BUFVBR,A0 Pass exception to debugger; Get saved VBR.
  MOVE.W 14(A6),D0   Get the vector offset from stack frame.
  AND.W #$0FFF,D0   Mask off the format information.
  MOVE.L (A0,D0.W),4(A6) Store address of debugger exc handler.
  MOVEM.L (SP)+,A0-A5/D0-D7  Restore registers.
  UNLK A6
  RTS     Put addr of exc handler into PC and go.
166Bug Generalized Exception Handler
The 166Bug has a generalized exception handler which it uses to handle all of 
the exceptions not listed in Table 4-2. For all these exceptions, the target stack 
pointer is left pointing to the top of the exception stack frame created. In this 
way, if an unexpected exception occurs during execution of your code, you are 
presented with the exception stack frame to help determine the cause of the 
exception. The following example illustrates this: 
Example: Bus error at address $F00000. It is assumed for this example 
that an access of memory location $F00000 initiates bus error 
exception processing. 










