(Set exception)
(VOIDP)() Setexc( num, newvec )
WORD num;
VOID (*newvec)();
Setexc() allows to read or modify system exception vectors.
Opcode
5 (0x05)
Availability
Parameters
num is the m68k CPU exception vector number you want to redirect.
newvec is the pointer to your new vector handler.
Binding
pea newvec
move.w #num,-(sp)
move.w #$05,-(sp)
trap #13
addq.l #8,sp
Commands and arguments
Passing VEC_INQUIRE (-1) as newvec will return current system exception handler.
CPU exception vectors
num (name) |
num (value) |
Vector |
VEC_BUSERROR |
0x02 |
Bus error exception |
VEC_ADDRESSERROR |
0x03 |
Address error exception |
VEC_ILLEGALINSTRUCTION |
0x04 |
Illegal instruction exception |
VEC_DIVIDEBYZERO |
0x05 |
Divide by zero exception |
VEC_CHKINST |
0x06 |
CHK instruction exception |
VEC_TRAPINST |
0x07 |
TRAPV, FTRAPcc, TRAPcc, cpTRAPcc instruction exception |
VEC_PRIVILEGEVIOLATION |
0x08 |
Privilege violation exception |
VEC_TRACE |
0x09 |
Trace exception |
VEC_LINEA |
0x0a |
Line-A exception |
VEC_LINEF |
0x0b |
Line-F exception |
VEC_COPROVIOLATION |
0x0d |
Coprocessor protocol violation exception |
VEC_FORMATERROR |
0x0e |
Format error exception |
VEC_UNINITINTERRUPT |
0x0f |
Uninitialized interrupt exception |
VEC_AUTOVECTOR0 |
0x18 |
Spurious interrupt |
VEC_AUTOVECTOR1 |
0x19 |
Autovectorised level 1 interrupt |
VEC_AUTOVECTOR2 = VEC_HBL |
0x1a |
Autovectorised level 2 interrupt (HBL) |
VEC_AUTOVECTOR3 |
0x1b |
Autovectorised level 3 interrupt |
VEC_AUTOVECTOR4 = VEC_VBL |
0x1c |
Autovectorised level 4 interrupt (VBL) |
VEC_AUTOVECTOR5 |
0x1d |
Autovectorised level 5 interrupt |
VEC_AUTOVECTOR6 |
0x1e |
Autovectorised level 6 interrupt |
VEC_AUTOVECTOR7 |
0x1f |
Autovectorised level 7 interrupt |
VEC_TRAP0 |
0x20 |
Trap #0 |
VEC_TRAP1 = VEC_GEMDOS |
0x21 |
Trap #1 (GemDOS) |
VEC_TRAP2 = VEC_GEM |
0x22 |
Trap #2 (AES, VDI) |
VEC_TRAP3 |
0x23 |
Trap #3 |
VEC_TRAP4 |
0x24 |
Trap #4 |
VEC_TRAP5 |
0x25 |
Trap #5 |
VEC_TRAP6 |
0x26 |
Trap #6 |
VEC_TRAP7 |
0x27 |
Trap #7 |
VEC_TRAP8 |
0x28 |
Trap #8 |
VEC_TRAP9 |
0x29 |
Trap #9 |
VEC_TRAP10 |
0x2a |
Trap #10 |
VEC_TRAP11 |
0x2b |
Trap #11 |
VEC_TRAP12 |
0x2c |
Trap #12 |
VEC_TRAP13 = VEC_BIOS |
0x2d |
Trap #13 (BIOS) |
VEC_TRAP14 = VEC_XBIOS |
0x2e |
Trap #14 (XBIOS) |
VEC_TRAP15 |
0x2f |
Trap #15 |
FPU exception vectors
num (name) |
num (value) |
Vector |
VEC_FPUUNORDEREDCONDITION |
0x30 |
Branch or set on unordered condition exception |
VEC_FPUINEXACT |
0x31 |
Inexact result exception |
VEC_FPUDIVIDEBYZERO |
0x32 |
Floating-point divide by zero exception |
VEC_FPUUNDERFLOW |
0x33 |
Underflow exception |
VEC_FPUOPERANDERROR |
0x34 |
Operand error exception |
VEC_FPUOVERFLOW |
0x35 |
Overflow exception |
VEC_FPUSIGNAN |
0x36 |
Signaling NAN exception |
PMMU exception vectors
num (name) |
num (value) |
Vector |
VEC_PMMUCONFIGERROR |
0x38 |
Configuration error exception |
VEC_PMMUILLEGAL |
0x39 |
Illegal operation exception |
VEC_PMMUACCESSVIOLATION |
0x3a |
Access violation exception |
MFP #0 exception vectors
Note: The default vector base value can be set in MFP Vector Register. TOS sets it so the base vector is 0x40.
num (name) |
num (value) |
Vector |
VEC_MFP0_0 = VEC_PARALLEL |
0x40 |
MFP interrupt #0 (GPIP pin #0, Parallel port receive) |
VEC_MFP0_1 |
0x41 |
MFP interrupt #1 (GPIP pin #1, RS-232 carrier detect) |
VEC_MFP0_2 |
0x42 |
MFP interrupt #2 (GPIP pin #2, RS-232 clear to send) |
VEC_MFP0_3 = VEC_BLITTER |
0x43 |
MFP interrupt #3 (GPIP pin #3, Blitter operation complete) |
VEC_MFP0_4 = VEC_TIMERD |
0x44 |
MFP interrupt #4 (Timer D, RS-232 baud rate generator) |
VEC_MFP0_5 = VEC_TIMERC |
0x45 |
MFP interrupt #5 (Timer C, 200hz system clock) |
VEC_MFP0_6 = VEC_ACIA |
0x46 |
MFP interrupt #6 (GPIP pin #4, ACIA receive) |
VEC_MFP0_7 = VEC_DISKDMA |
0x47 |
MFP interrupt #7 (GPIP pin #5, Floppy, hard disk DMA) |
VEC_MFP0_8 = VEC_TIMERB |
0x48 |
MFP interrupt #8 (Timer B, HBL) |
VEC_MFP0_9 |
0x49 |
MFP interrupt #9 (RS-232 transmit error) |
VEC_MFP0_10 |
0x4a |
MFP interrupt #10 (RS-232 transmit buffer error) |
VEC_MFP0_11 |
0x4b |
MFP interrupt #11 (RS-232 receive error) |
VEC_MFP0_12 |
0x4c |
MFP interrupt #12 (RS-232 receive buffer error) |
VEC_MFP0_13 = VEC_TIMERA |
0x4d |
MFP interrupt #13 (Timer A, audio DMA) |
VEC_MFP0_14 |
0x4e |
MFP interrupt #14 (GPIP pin #6, RS-232 ring indicator) |
VEC_MFP0_15 |
0x4f |
MFP interrupt #15 (GPIP pin #7, Monochrome monitor) |
MFP #1 exception vectors
Note: The default vector base value can be set in MFP Vector Register. TOS sets it so the base vector is 0x50. This second MFP is only present on TT machines.
num (name) |
num (value) |
Vector |
VEC_MFP1_0 |
0x50 |
MFP interrupt #0 (GPIP pin #0) |
VEC_MFP1_1 |
0x51 |
MFP interrupt #1 (GPIP pin #1) |
VEC_MFP1_2 |
0x52 |
MFP interrupt #2 (GPIP pin #2, SCC DMA complete) |
VEC_MFP1_3 |
0x53 |
MFP interrupt #3 (GPIP pin #3, RS-232 ring indicator) |
VEC_MFP1_4 |
0x54 |
MFP interrupt #4 (Timer D, RS-232 baud rate generator) |
VEC_MFP1_5 |
0x55 |
MFP interrupt #5 (Timer C, SCC TRxCB) |
VEC_MFP1_6 |
0x56 |
MFP interrupt #6 (GPIP pin #4) |
VEC_MFP1_7 |
0x57 |
MFP interrupt #7 (GPIP pin #5, SCSI DMA complete) |
VEC_MFP1_8 |
0x58 |
MFP interrupt #8 (Timer B) |
VEC_MFP1_9 |
0x59 |
MFP interrupt #9 (RS-232 transmit error) |
VEC_MFP1_10 |
0x5a |
MFP interrupt #10 (RS-232 transmit buffer error) |
VEC_MFP1_11 |
0x5b |
MFP interrupt #11 (RS-232 receive error) |
VEC_MFP1_12 |
0x5c |
MFP interrupt #12 (RS-232 receive buffer error) |
VEC_MFP1_13 |
0x5d |
MFP interrupt #13 (Timer A) |
VEC_MFP1_14 |
0x5e |
MFP interrupt #14 (GPIP pin #6, Real time clock) |
VEC_MFP1_15 |
0x5f |
MFP interrupt #15 (GPIP pin #7, SCSI controller) |
SCC exception vectors
num (name) |
num (value) |
Vector |
VEC_SCC_B_TBE |
0x60 |
SCC Port B transmit buffer empty |
VEC_SCC_B_ESC |
0x62 |
SCC Port B external status change |
VEC_SCC_B_RCA |
0x64 |
SCC Port B receive character available |
VEC_SCC_B_SRC |
0x66 |
SCC Port B special receive condition |
VEC_SCC_A_TBE |
0x68 |
SCC Port A transmit buffer empty |
VEC_SCC_A_ESC |
0x6a |
SCC Port A external status change |
VEC_SCC_A_RCA |
0x6c |
SCC Port A receive character available |
VEC_SCC_A_SRC |
0x6e |
SCC Port A special receive condition |
System exception vectors
num (name) |
num (value) |
Vector |
VEC_TIMER |
0x100 |
System timer (etv_timer) |
VEC_CRITICALERROR |
0x101 |
Critical error handler (etv_critic) |
VEC_TERMINATE |
0x102 |
Process terminate handler (etv_term) |
Return Value
The (VOIDP)() value is the previous function pointer to the system vector.
Comments
m68k CPU has predefined exception vectors, like bus error, illegal instruction, division by zero, and so on. For example, the bus error exception is the #2 exception. Virtual memory managers redirect it to a custom routine to swap needed memory in.
If you need to redirect some vectors in your program, beware to restore them upon exit, or the system will crash. If you make a
TSR program, you must use
XBRA? protocol to ensure your vector will not be deleted by some other programs. Last but not least, redirecting system vectors under a mutitasking OS like
MiNT is definitely not recommended, and should be avoided.