The ARM-THUMB Procedure Call Standard
SWS ESPC 0002 B-01 Page 1 of 37
The ARM-THUMB Procedure Call
Standard
Development Systems Business Unit
Engineering Software Group
Document number: SWS ESPC 0002 B-01
Date of Issue: 24 October, 2000
Author: -
Authorized by:
© Copyright ARM Limited 1998, 2000. All rights reserved.
Abstract
This document defines a family of procedure call standards for the ARM and THUMB instruction sets.
Keywords
procedure call, function call, calling conventions
Distribution list
Name Function Name Function
The ARM-THUMB Procedure Call Standard
SWS ESPC 0002 B-01 Page 2 of 37
Contents
1 ABOUT THIS DOCUMENT 5
1.1 Change control 5
1.1.1 Current status and anticipated changes 5
1.1.2 Change history 5
1.2 References 5
1.3 Terms and abbreviations 6
2SCOPE 7
3 INTRODUCTION 8
3.1 Design goals 8
3.2 Conformance 8
3.3 Processes, the memory model, and the stack 8
3.3.1 The stack 9
3.4 Pre-conditions and post-conditions 9
4 THE BASE STANDARD 10
4.1 Machine registers 10
4.2 Floating point registers 11
4.3 Subroutine call 11
4.4 Parameter passing 12
4.4.1 Variable number of parameters (variadic routines) 13
4.4.2 Fixed number of parameters 13
4.5 Result return 13
4.6 The FPA procedure call standard 14
4.7 The VFP (scalar mode) procedure call standard 14
4.8 The no floating-point hardware procedure call standard 15
5 THE STANDARD VARIANTS 16
5.1 Inter-working between ARM-state and Thumb-state 16
5.2 Read-only position-independence—PIC 16
The ARM-THUMB Procedure Call Standard
SWS ESPC 0002 B-01 Page 3 of 37
5.3 Read-write position-independence—PID 17
5.3.1 Position-independent data addressing 17
5.3.2 RWPI defined 17
5.4 Re-entrant code 17
5.5 Shared libraries 18
5.6 The shared-library data-addressing architecture 18
5.7 Stack limit checking 19
5.8 Chunked stacks 20
6 STACK UNWINDING 21
6.1.1 Background 21
6.1.2 What this standard defines 21
6.2 Allowed alternatives for unwinding 21
6.2.1 Basic routine shape 22
6.2.2 The stack-moves-once condition 22
6.2.3 Unwinding a fixed size activation record by interpreting an entry sequence 22
6.2.4 Unwinding a fixed size activation record by executing an exit sequence 23
6.2.5 Constraints on frame pointers 23
6.2.6 Unwinding an activation record using a frame pointer 24
6.3 The shape of routine entry 24
7 ARM C AND C++ CONVENTIONS 25
7.1 ANSI C and C++ argument passing conventions 25
7.2 Narrow arguments 26
7.3 Result return 26
7.3.1 Non-floating-point results 26
7.3.2 Floating-point results 26
7.3.3 Value-in-registers result return 27
7.4 __shared_library 27
8 RATIONALE FOR ATPCS VARIANTS 28
8.1 The base standard and its variants 28
8.2 ARM Shared Libraries 29
8.2.1 Basic static data addressing in a shared-library-using application 30
8.2.2 Exported data 30
8.2.3 Base-standard clients 31
8.3 Dynamically loaded libraries 31
8.4 Legacy issues 32
The ARM-THUMB Procedure Call Standard
SWS ESPC 0002 B-01 Page 4 of 37
8.4.1 Floating point argument passing 32
8.4.2 Narrow arguments 33
8.5 Derivation of library variant costs 34
The ARM-THUMB Procedure Call Standard
SWS ESPC 0002 B-01 Page 5 of 37
1 ABOUT THIS DOCUMENT
1.1 Change control
1.1.1 Current status and anticipated changes
Release A-05 of this specification is the first public release, the ADS-1.0 release.
Release B-01 is the ADS-1.1 release. The description of parameter passing has been extensively revised, but
where release A-05 can be implemented without major difficulties, the resulting parameter lists are almost always
identical. Differences occur only where release A-05 proved too difficult to implement precisely.
Future releases of this standard are likely to:
o
Define more precisely the interaction between this standard and the IEEE754 standard for floating-point
arithmetic.
o
Define more precisely the mapping of C, C++, and Java source language entities to the machine-level values
passed as parameters across publicly visible interfaces.
1.1.2 Change history
Issue Date By Change
A-01 18 March, 1998 - First partial draft for early review (WD, HM, SW, EN)
A-01 20 March, 1998 - Second partial draft for internal review.
A-02 30 March, 1998 - First external-review DRAFT.
A-03 17 July, 1998 - Second external-review DRAFT
A-04 23 October 1998 - FINAL internal review DRAFT
A-05 5 November, 1998 - Editorial changes following review
B-01 24 October, 2000 - Added 8-byte stack alignment motivated by ARM architecture 5.
Revised floating-point argument marshalling after it was found
impossible to implement. Made minor editorial improvements.
1.2 References
This document refers to the following documents.
Ref Doc No Author(s) Title