Atmel CAVR-4 Manuale Utente
CAVR-4
Part1. Using the compiler
Assembler language interface
105
Hidden parameters
In addition to the parameters visible in a function declaration and definition, there can
be hidden parameters:
be hidden parameters:
●
A function returning structures or unions larger than four bytes gets an extra hidden
parameter, which is a default pointer—depending on the used memory
model—pointing to the location where the result should be stored. This pointer
must be returned to the called by the assembler function.
parameter, which is a default pointer—depending on the used memory
model—pointing to the location where the result should be stored. This pointer
must be returned to the called by the assembler function.
●
For non-static C++ member functions, the
this
pointer is passed as the first
parameter (but placed after the return structure pointer, if there is one). Note that
static member functions do not have a
static member functions do not have a
this
pointer.
FUNCTION EXIT
The called function exits by deallocating auto variables, restoring registers, deallocating
stack parameters, and finally performing a
stack parameters, and finally performing a
RET
instruction which pops the return address
from the return address stack. Note that an interrupt function returns by performing a
RETI
function.
Return values
A function can return a value to the function or program that called it, or it can be of the
type
type
void
. The return value of a function, if any, can be scalar (such as integers and
pointers), floating-point, or a structure. A return value can be passed via register or via
the stack.
the stack.
For both calling conventions, the following details are valid:
●
The return address stack (RSTACK) and the data stack (CSTACK) are two separate
stacks. The RSTACK uses the internal I/O port
stacks. The RSTACK uses the internal I/O port
SP
, which is declared in the
ioderivative.h
include files provided with the product.
●
struct
and
union
values larger than 4 bytes are passed using a pointer; this
pointer is returned via register
●
The implicit first parameter passed to a function, pointing to the memory to be used
for storing the return value, is always passed on the stack if the value is larger than 4
bytes.
for storing the return value, is always passed on the stack if the value is larger than 4
bytes.