Function a subroutine which returns a value through

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: he calling program, other than by returning a single value, is when it is passed a pointer to the data as an argument. The function can then use the pointer to access and modify the data structure. In order to support flexible mixing of routines generated by different compilers and written in assembly language, ARM Limited has defined a set of rules for procedure entry and exit. The ARM Procedure Call Standard (APCS) is employed by the ARM C compiler, though this is of significance to the C programmer only when the assembly-level output must be understood in detail. Arguments and parameters ARM Procedure Call Standard Functions and procedures 177 The APCS imposes a number of conventions on the otherwise 'vanilla' flavour of the ARM architecture: It defines particular uses for the 'general-purpose' registers. It defines which form of stack is used from the full/empty, ascending/descending choices supported by the ARM instruction set. It defines the format of a stack-based data structure used for back-tracing when debugging programs. It defines the function argument and result passing mechanism to be used by all externally visible functions and procedures. ('Externally visible' means that the procedure interface is offered outside the current programming module. A func tion which is used only within the current module may be optimized by deviating from this convention.) It supports the ARM shared library mechanism, which means it supports a standard way for shared (re-entrant) code to access static data. ARCS register usage The convention for the use of the 16 currently visible ARM registers is summarized in Table 6.2. The registers are divided into three sets: Table 6.2 APCS register use convention. Register 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 APCS name al a2 a3 a4 vl v2 v3 v4 v5 sb/v6 sl/v7 fp ip sp Ir pc APCS role Argument 1 / integer result / scratch register Argument 2 / scratch register Argument 3 / scratch register Argument 4 / scratch register Register variable 1 Register variable 2 Register variable 3 Register variable 4 Register variable 5 Static base / register varia...
View Full Document

Ask a homework question - tutors are online