Datasheet
ARM Compiler Reference
3-6 Copyright © 1999-2001 ARM Limited. All rights reserved. ARM DUI 0067D
3.1.2 Function keywords
Several keywords tell the compiler to give a function special treatment. These are all
ARM extensions to the ANSI C specification:
Declarations inside functions
Declarations inside a function indicate that the following statements are processed
differently. The
asm
keyword does not modify the surrounding function, but it does
indicate that the statements following the keyword are different.
__asm
This instructs the compiler that the following code is written in assembler
language (see Inline assembler on page 3-18).
Function qualifiers
Function qualifiers affect the type of a function. The qualifiers are placed after the
parameter list in the same position that
const
and
volatile
can appear for C++ member
function types.
__irq
This enables a C or C++ function to be used as an interrupt routine called
by the
IRQ
or
FIQ
vectors. All corrupted registers except floating-point
registers are preserved, not only those that are normally preserved under
the ATPCS. The default ATPCS mode must be used. The function exits
by setting the pc to lr–4 and the CPSR to the value in SPSR. It is not
available in tcc or tcpp. No arguments or return values can be used with
__irq
functions.
See the chapter on Handling Processor Exceptions in the ADS Developer
Guide for detailed information on using
__irq
.
__pure
This asserts that a function declaration is pure. Functions that are pure are
candidates for common subexpression elimination. By default, functions
are assumed to be impure (causing side-effects). A function is properly
defined as pure only if:
• its result depends exclusively on the values of its arguments
• it has no side effects, for example it cannot call impure functions.
So, a pure function cannot use global variables or dereference pointers,
because the compiler assumes that the function does not access memory
(except stack memory) at all. When called twice with the same
parameters, a pure function must return the same value each time.
The __pure declaration can also be used as a prefix or postfix declaration.
In some cases the prefix form can be ambiguous and readability is
improved by using the postfix form: