| |||
| Home > Handling Processor Exceptions > SVC handlers > SVC handlers in assembly language | |||
The easiest way to call the handler for the requested SVC
number is to use a jump table. If r0 contains
the SVC number, the code in Example 6.7 can be inserted into the top-level handler
given in Example 6.6, following
on from the BIC instruction.
Example 6.7. SVC jump table
CMP r0,#MaxSVC ; Range check
LDRLS pc, [pc,r0,LSL #2]
B SVCOutOfRange
SVCJumpTable
DCD SVCnum0
DCD SVCnum1
; DCD for each of other SVC routines
SVCnum0 ; SVC number 0 code
B EndofSVC
SVCnum1 ; SVC number 1 code
B EndofSVC
; Rest of SVC handling code
;
EndofSVC
; Return execution to top level
; SVC handler so as to restore
; registers and return to program.