SVC is a privileged instruction in ARM architecture that generates a software interrupt for requesting system services.
SVC #immediate
Β (where immediate is typically a service number)<aside> π‘
TheΒ stackΒ is a region of memory used for temporary storage during program execution. It operates in a "last in, first out" (LIFO) manner. The stack is used to store function parameters, local variables, return addresses, and to save CPU registers during function calls and interrupts. Each function call pushes data onto the stack, and data is popped off when the function returns.
The stack grows downward in memory
</aside>
<aside> π‘
ARM GCC calling convention (AAPCS, ARM Architecture Procedure Call Standard):
r0
, r1
, r2
, r3
.s0
βs15
(if FPU is enabled and used).r0
(and r1
for 64-bit values).s0
(or d0
for double).r0
βr3
, r12
(can be changed by called function).r4
βr11
, sp
, lr
(must be preserved by called function).sp
): Must be 8-byte aligned at function entry.r12
: Intra-procedure-call scratch register (used by linker, not preserved).lr
: Link register (return address).sp
: Stack pointer.int foo(int a, int b, int c, int d, int e);
// a β r0, b β r1, c β r2, d β r3, e β stack
References:
Let me know if you want details for a specific ARM variant or ABI!
</aside>