B.1.9. Vectored interrupt service routine

See Example B.9 for an example of the vectored interrupt service routine code.

Example B.9. Vectored interrupt service routine

0x18    LDR pc,    [pc, #-0x120]    ;Load Vector into PC
;.......................................................

vector_handler
       ; Code to enable interrupt nesting
       STMFD r13!, {r12, r14}       ; stack lr_irq and r12 [plus other regs used below, if appropriate]
       MRS r12, spsr                ; Copy spsr into r12...
       STMFD r13!, {r12}            ; and save to stack

; Add code to clear the interrupt source
; Read from VICIRQSTATUS to determine the source of the interrupt
       MSR cpsr_c, #0x1f            ; Switch to SYS mode, re-enable IRQ
       STMFD r13!, {r0-r3, r14}     ; stack lr_sys and r0-r3

; Interrupt service routine...
; NOTE: ADS 1.2 requires preservation of 8-byte stack alignment
; with respect to all external interfaces
; See ADS 1.2 Developer Guide - Section 2.3.3
; ...
       BL 2nd_level_handler         ; this will corrupt lr_sys and r0-r3
; ...

; Code to exit handler
       LDMFD r13!, {r0-r3, r14}     ; unstack lr_sys and r0-r3
       MSR cpsr_c, #0x92            ; Disable IRQ, and return to IRQ mode
       LDMFD r13!, {r12}            ; unstack r12...
       MSR spsr_cxsf, r12           ; and restore spsr...
       LDMFD r13!, {r12, r14}       ; unstack registers
       LDR r1, =VectorAddr
       STR r0, [r1]                 ; Acknowledge Vectored IRQ has been serviced
       SUBS pc, lr, #4              ; Return from ISR
Copyright © 2002 ARM Limited. All rights reserved.ARM DDI 0273A
Non-Confidential