Initializing the vector table in the assembly source file requires that all the entries in the table are initialized. Interrupts, which are not used, must be associated with a standard handler.
The labels or functions, which should be inserted in the vector table must be implemented in the assembly source file or an external reference must be available for them. The vector table can be defined in an assembly source file in an additional section containing constant variables. See the following listing for an example.
XDEF ResetFunc DataSec: SECTION Data: DS.W 5 ; Each interrupt increments an element of the table. CodeSec: SECTION ; Implementation of the interrupt functions. IRQ1Func: LD D0, #0 BRA int SWIFunc: LD D0, #4 BRA int ResetFunc: LD D0, #8 BRA entry DummyFunc: RTI int: PSHH LD X #Data ; Load address of symbol Data in X ; X <- address of the appropriate element in the tab Ofset: TSTA TBEQ D0, Ofset3 Ofset2: INC X DEC A BNE Ofset2 Ofset3: INC.W (0,X); The table element is incremented PULH RTI entry: LD S, #0x10FF ; Init Stack Pointer to $1100-$1=$10FF TXS CLRX CLRH CLI; Enables interrupts loop: BRA loop ORG $FFF8 ; Definition of the vector table in an absolute section ; starting at address $FFF8. IRQ1Int: DC.W IRQ1Func IRQ0Int: DC.W DummyFunc SWIInt: DC.W SWIFunc ResetInt: DC.W ResetFunc
The section should now be placed at the expected address. This is performed in the linker parameter file, as listed in the following listing:
LINK test.abs NAMES test.o+ END SECTIONS MY_ROM = READ_ONLY 0x0800 TO 0x08FF; MY_RAM = READ_WRITE 0x0B00 TO 0x0CFF; MY_STACK = READ_WRITE 0x0D00 TO 0x0DFF; END PLACEMENT DEFAULT_RAM INTO MY_RAM; DEFAULT_ROM INTO MY_ROM; SSTACK INTO MY_STACK; END INIT ResetFunc