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 the following example can be inserted into the top-level handler given in the Example 44 example, following on from the BIC instruction.

Example 45. SVC jump table

    AREA SVC_Area, CODE, READONLY
    PRESERVE8
    IMPORT SVCOutOfRange
    IMPORT MaxSVC
    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.
    END

Copyright © 2010-2012 ARM. All rights reserved.ARM DUI 0471G
Non-ConfidentialID021412