10.8.4 Example Vector-Table Assembly Source Code

The following example shows how to create a vector dispatch for interrupt vector 0. The vector dispatch is a jump from the vector table to the actual Interrupt Service Routine (ISR).

/*  Input section .vector_0 is mapped to the .vectors output
       *  section in the linker script.
       */   
   .globl _vector_dispatch_0
   .section .vector_0,code
   .align 2
   .set nomips16
   .ent __vector_dispatch_0
__vector_dispatch_0:
       /* Jump to the actual ISR code */
   j	isrvector0
   nop
   .end __vector_dispatch_0
   .size __vector_dispatch_0, .-__vector_dispatch_0

The following example shows how to place the Interrupt Service Routine directly into the vector table. The mapping in the linker script will automatically adjust the vector spacing to accommodate the function’s code.

/*  Input section .vector_0 is mapped to the .vectors output
       *  section in the linker script.
       */
       .section .vector_0,code
    .align 2
    .globl isrvector0
    .set nomips16
    .set nomicromips
    .ent isrvector0
isrvector0:
    .set noat
       /*  Interrupt Service Routine code directly in the vector table.
        *  Be sure to preserve registers as appropriate for an ISR.
        */   
    eret
    .set at
    .end isrvector0
    .size isrvector0, .-isrvector0

From XC32 C code, use the standard vector(n) and at_vector(n) function attributes on your ISR function.

For further information on these function attributes, see your compiler's user's guide.