source: rtems/doc/supplements/arm/callconv.t @ 6c243f11

4.104.114.84.95
Last change on this file since 6c243f11 was 8d7393a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/30/02 at 21:43:53

2002-07-30 Joel Sherrill <joel@…>

  • BSP_TIMES, ChangeLog?, Makefile.am, arm.texi, bsp.t, callconv.t, cpumodel.t, cputable.t, fatalerr.t, intr_NOTIMES.t, memmodel.t, preface.texi, stamp-vti, timeBSP.t, timing.texi, version.texi, wksheets.texi: New files as ARM supplement initial version added.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Calling Conventions
10
11@section Introduction
12
13Each high-level language compiler generates
14subroutine entry and exit code based upon a set of rules known
15as the compiler's calling convention.   These rules address the
16following issues:
17
18@itemize @bullet
19@item register preservation and usage
20@item parameter passing
21@item call and return mechanism
22@end itemize
23
24A compiler's calling convention is of importance when
25interfacing to subroutines written in another language either
26assembly or high-level.  Even when the high-level language and
27target processor are the same, different compilers may use
28different calling conventions.  As a result, calling conventions
29are both processor and compiler dependent.
30
31@section Processor Background
32
33The ARM architecture supports a simple yet
34effective call and return mechanism.  A subroutine is invoked
35via the branch and link (@code{bl}) instruction.  This instruction
36saves the return address in the @code{lr} register.  Returning
37from a subroutine only requires that the return address be
38moved into the program counter (@code{pc}), possibly with
39an offset.  It is is important to
40note that the @code{bl} instruction does not
41automatically save or restore any registers.  It is the
42responsibility of the high-level language compiler to define the
43register preservation and usage convention.
44
45@section Calling Mechanism
46
47All RTEMS directives are invoked using the @code{bl}
48instruction and return to the user application via the
49mechanism described above.
50
51@section Register Usage
52
53As discussed above, the ARM's call and return mechanism dos
54not automatically save any registers.  RTEMS uses the registers
55@code{r0}, @code{r1}, @code{r2}, and @code{r3} as scratch registers and
56per ARM calling convention, the @code{lr} register is altered
57as well.  These registers are not preserved by RTEMS directives
58therefore, the contents of these registers should not be assumed
59upon return from any RTEMS directive.
60
61@section Parameter Passing
62
63RTEMS assumes that ARM calling conventions are followed and that
64the first four arguments are placed in registers @code{r0} through
65@code{r3}.  If there are more arguments, than that, then they
66are place on the stack.
67
68@section User-Provided Routines
69
70All user-provided routines invoked by RTEMS, such as
71user extensions, device drivers, and MPCI routines, must also
72adhere to these calling conventions.
73
Note: See TracBrowser for help on using the repository browser.