9.16 __svc

The __svc keyword declares a SuperVisor Call (SVC) function taking up to four integer-like arguments and returning up to four results in a value_in_regs structure.

__svc is a function qualifier. It affects the type of a function.


__svc(int svc_num) return-type function-name([argument-list]);
Is the immediate value used in the SVC instruction.
It is an expression evaluating to an integer in the range:
  • 0 to 224–1 (a 24-bit value) in an ARM instruction.
  • 0-255 (an 8-bit value) in a 16-bit Thumb instruction.


This causes function invocations to be compiled inline as an AAPCS-compliant operation that behaves similarly to a normal call to a function.
You can use the __value_in_regs qualifier to specify that a small structure of up to 16 bytes is returned in registers, rather than by the usual structure-passing mechanism defined in the AAPCS.


When an ARM architecture variant or ARM architecture-based processor that does not support an SVC instruction is specified on the command line using the --cpu option, the compiler generates an error.


__svc(42) void terminate_1(int procnum); // terminate_1 returns no results
__svc(42) int terminate_2(int procnum);  // terminate_2 returns one result
typedef struct res_type
    int res_1;
    int res_2;
    int res_3;
    int res_4;
} res_type;
__svc(42) __value_in_regs res_type terminate_3(int procnum);
                                         // terminate_3 returns more than
                                         // one result
Related reference
9.17 __svc_indirect
9.18 __svc_indirect_r7
7.29 --cpu=name compiler option
9.19 __value_in_regs
Related information
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.