9.3.1. Installing the handlers at reset

If your application does not rely on the debugger or debug monitor to start program execution, you can load the vector table directly from your assembly language reset (or startup) code.

If your ROM is at location 0x0 in memory, you can simply have a branch statement for each vector at the start of your code. This could also include the FIQ handler if it is running directly from 0x1c. See Interrupt handlers.

Example 9.1 shows code that sets up the vectors if they are located in ROM at address zero. Note that you can substitute branch statements for the loads.

Example 9.1. 

Vector_Init_Block
				LDR	PC, Reset_Addr
				LDR	PC, Undefined_Addr
				LDR	PC, SWI_Addr
				LDR	PC, Prefetch_Addr
				LDR	PC, Abort_Addr
				NOP					;Reserved vector
				LDR	PC, IRQ_Addr
				LDR	PC, FIQ_Addr
Reset_Addr				DCD	Start_Boot
Undefined_Addr				DCD	Undefined_Handler
SWI_Addr				DCD	SWI_Handler
Prefetch_Addr				DCD	Prefetch_Handler
Abort_Addr				DCD	Abort_Handler
				DCD	0				;Reserved vector
IRQ_Addr				DCD	IRQ_Handler
FIQ_Addr				DCD	FIQ_Handler

If there is RAM at location zero, the vectors (plus the FIQ handler if required) must be copied down from an area in ROM into the RAM. In this case, you must use load pc instructions, and copy the storage locations, to make the code relocatable.

Example 9.2 copies down the vectors given in Example 9.1 to the vector table in RAM.

Example 9.2. 

	MOV		r8, #0
	ADR		r9, Vector_Init_Block
	LDMIA		r9!,{r0-r7}					;Copy the vectors (8 words)
	STMIA		r8!,{r0-r7}
	LDMIA		r9!,{r0-r7}					;Copy the DCD'ed addresses
	STMIA		r8!,{r0-r7}					;(8 words again)

Alternatively, you can use the scatter loading mechanism to install the vector table. Refer to Chapter 10 Writing Code for ROM for more information.

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0040D
Non-Confidential