<strong>The</strong> <strong>ARM</strong>-<strong>THUMB</strong> <strong>Procedure</strong> <strong>Call</strong> <strong>Standard</strong>NoteNoteIn the limit-checked variants of this standard, SL (r10) is neither preserved nor altered by the calledroutine itself, but only by limit-checking support code.Return is usually to the instruction following the call sequence, but this standard does not require that.A called routine need not preserve the values of r0-r3, IP (r12) and LR (r14). Formally:Pre: stack limit
<strong>The</strong> <strong>ARM</strong>-<strong>THUMB</strong> <strong>Procedure</strong> <strong>Call</strong> <strong>Standard</strong>4.4.1 Variable number of parameters (variadic routines)<strong>The</strong> list of machine parameter values is converted to integer machine words as if by storing each value in turn intoconsecutive memory words. <strong>The</strong>se integer parameter words are passed to a variadic routine as if by:o Loading the first 4 words into integer registers a1-a4 (lowest addressed into a1). If there are fewer than 4words, they are loaded into a1-a3, a1-a2, or a1 only.oNotePushing remaining words onto the stack in reverse order (so the first remaining parameter word is atVAL(SP), the second at VAL(SP)+4, and so on).Consequently, a floating-point value can be passed in integer registers, or can be split between aninteger register and memory.4.4.2 Fixed number of parametersMachine-level parameter values are passed to a non-variadic routine as if:oooNote<strong>The</strong> first N floating-point values are removed from the parameter list and assigned to floating-point argumentregisters of the appropriate precision. <strong>The</strong> number N and the details of the assignment depend on theselected floating-point architecture (see section 4.6, <strong>The</strong> FPA procedure call standard and 4.7, <strong>The</strong> VFP(scalar mode) procedure call standard).<strong>The</strong> first 4 integer values are removed from the parameter list and assigned to integer registers a1-a4. Fewerthan 4 integer parameter values there are assigned to a1-a3, a1-a2, or a1 only.Remaining values are pushed onto the stack in reverse order.Consequently, a machine-level floating-point value is passed in a floating-point register or in memory,never in integer registers. (But, a source-level floating-point field does not always map to a machinelevelfloating-point value. Consider, for example, a floating-point field in an inhomogeneous structure.)4.5 Result returnA procedure returns no result.A function returns a single value of integer sort or floating-point sort. A value occupies 1 or more words.A function of integer sort:o Must return a 1-word value in a1.ooMay return a value of length 2-4 words in a1-a2, a1-a3, or a1-a4, respectively.Must return a longer value indirectly, in memory, via an additional address parameter.A function of floating-point sort:ooMust return an atomic floating-point value in f0 or d0, as appropriate to its precision.May return a compound floating-point value in f0-fN, or d0-dN, where N depends on the selected floating-pointarchitecture (see section 4.6, <strong>The</strong> FPA procedure call standard and 4.7, <strong>The</strong> VFP (scalar mode) procedurecall standard).Section 7, <strong>ARM</strong> C and C++ Conventions, describes how source language entities of various lengths are returned.SWS ESPC 0002 A-05 Page 13 of 37