source: rtems/doc/supplements/i960/callconv.texi @ 139b2e4a

4.104.114.84.95
Last change on this file since 139b2e4a was 139b2e4a, checked in by Joel Sherrill <joel.sherrill@…>, on 06/04/97 at 18:32:07

added CVS Id string

  • Property mode set to 100644
File size: 4.9 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1997.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@ifinfo
10@node Calling Conventions, Calling Conventions Introduction, CPU Model Dependent Features Floating Point Unit, Top
11@end ifinfo
12@chapter Calling Conventions
13@ifinfo
14@menu
15* Calling Conventions Introduction::
16* Calling Conventions Processor Background::
17* Calling Conventions Calling Mechanism::
18* Calling Conventions Register Usage::
19* Calling Conventions Parameter Passing::
20* Calling Conventions User-Provided Routines::
21* Calling Conventions Leaf Procedures::
22@end menu
23@end ifinfo
24
25@ifinfo
26@node Calling Conventions Introduction, Calling Conventions Processor Background, Calling Conventions, Calling Conventions
27@end ifinfo
28@section Introduction
29
30Each high-level language compiler generates
31subroutine entry and exit code based upon a set of rules known
32as the compiler's calling convention.   These rules address the
33following issues:
34
35@itemize @bullet
36@item register preservation and usage
37
38@item parameter passing
39
40@item call and return mechanism
41@end itemize
42
43A compiler's calling convention is of importance when
44interfacing to subroutines written in another language either
45assembly or high-level.  Even when the high-level language and
46target processor are the same, different compilers may use
47different calling conventions.  As a result, calling conventions
48are both processor and compiler dependent.
49
50@ifinfo
51@node Calling Conventions Processor Background, Calling Conventions Calling Mechanism, Calling Conventions Introduction, Calling Conventions
52@end ifinfo
53@section Processor Background
54
55All members of the i960 architecture family support
56two methods for performing procedure calls: a RISC-style
57branch-and-link and an integrated call and return mechanism.
58
59On a branch-and-link, the processor branches to the
60invoked procedure and saves the return address in a register,
61G14.  Typically, the invoked procedure will not invoke another
62procedure and is referred to as a leaf procedure.  Many
63high-level language compilers for the i960 family recognize leaf
64procedures and automatically optimize them to utilize the
65branch-and-link mechanism.  Branch-and-link procedures are
66invoked using the bal and balx instructions and return control
67via the bx instruction.  By convention, G14 is zero when not in
68a leaf procedure.  It is the responsibility of the leaf
69procedure to clear G14 before returning.
70
71The integrated call and return mechanism also
72branches to the invoked procedure and saves the return address
73as did the branch and link mechanism. However, the important
74difference is that the call, callx, and calls instructions save
75the local register set (R0 through R15) before transferring
76control to the invoked procedure.  The ret instruction
77automatically restores the previous local register set.  The
78i960CA provides a register cache which can be configured to
79retain the last five to sixteen recent register caches.  When
80the register cache is full, the oldest cached register set is
81written to the stack.
82
83@ifinfo
84@node Calling Conventions Calling Mechanism, Calling Conventions Register Usage, Calling Conventions Processor Background, Calling Conventions
85@end ifinfo
86@section Calling Mechanism
87
88All RTEMS directives are invoked using either a call
89or callx instruction and return to the user via the ret
90instruction.
91
92@ifinfo
93@node Calling Conventions Register Usage, Calling Conventions Parameter Passing, Calling Conventions Calling Mechanism, Calling Conventions
94@end ifinfo
95@section Register Usage
96
97As discussed above, the call and callx instructions
98automatically save the current contents of the local register
99set (R0 through R15).  The contents of the local registers will
100be restored as part of returning to the application.  The
101contents of global registers G0 through G7 are not preserved by
102RTEMS directives.
103
104@ifinfo
105@node Calling Conventions Parameter Passing, Calling Conventions User-Provided Routines, Calling Conventions Register Usage, Calling Conventions
106@end ifinfo
107@section Parameter Passing
108
109RTEMS uses the standard i960 family C parameter
110passing mechanism in which G0 contains the first parameter, G1
111the second,  and so on  for the remaining parameters.  No RTEMS
112directive requires more than six parameters.
113
114@ifinfo
115@node Calling Conventions User-Provided Routines, Calling Conventions Leaf Procedures, Calling Conventions Parameter Passing, Calling Conventions
116@end ifinfo
117@section User-Provided Routines
118
119All user-provided routines invoked by RTEMS, such as
120user extensions, device drivers, and MPCI routines, must also
121adhere to these calling conventions.
122
123@ifinfo
124@node Calling Conventions Leaf Procedures, Memory Model, Calling Conventions User-Provided Routines, Calling Conventions
125@end ifinfo
126@section Leaf Procedures
127
128RTEMS utilizes leaf procedures internally to improve
129performance.  This improves execution speed as well as reducing
130stack usage and the number of register sets which must be cached.
131
132
Note: See TracBrowser for help on using the repository browser.