68k exception handling

A 68k program may produce exceptions, often caused by bugs. For debugging, an exception handler can be of great use.

Some games were published with their exception handler, while some others just reset the system.

=Generic exception handler=

Allocate a longword variable called "PCERROR". Make the appropriate vectors point to the related routines below.

Divide by zero/Illegal instruction
Cause: See 68k vector table.

6 bytes stack frame: 0:SR.w, 2:PC.l

Address error/Bus error
Cause: See 68k vector table.

14 bytes stack frame: 0:R/W.w, 2:Access address.l, 6:Instruction.l, 8:SR.w, 10:PC.l

Display for debug


Don't forget to mask out all interrupts as soon as an exception is raised:

All register values can be retrieved from the previous MOVEMs and displayed on the fix layer:

Don't forget to set up a palette.