Atmel CAVR-4 Manual De Usuario
![Atmel](https://files.manualsbrain.com/attachments/0369829915bda09f9c2e00fb805a7753579683b5/common/fit/150/50/8d2bf08978ec3e5bc63f4343ac5e91ce8d0e40045619fa520d910d64af8f/brand_logo.png)
CAVR-4
106
Calling convention
AVR® IAR C/C++ Compiler
Reference Guide
Registers used for returning values
For both calling conventions, the registers available for returning values are
R16–R19
.
Note that the size of a returned pointer depends on the memory model in use;
appropriate registers are used accordingly.
appropriate registers are used accordingly.
Stack handling
Normally, it is the responsibility of the called function to clean the stack. The only
exception is for ellipse functions—functions with a variable argument list such as
exception is for ellipse functions—functions with a variable argument list such as
printf
—for which it is the responsibility of the caller to clean the stack.
RETURN ADDRESS HANDLING
A function written in assembler language should, when finished, return to the caller. At
a function call, the return address is automatically stored on the RSTACK (not the
CSTACK).
a function call, the return address is automatically stored on the RSTACK (not the
CSTACK).
Typically, a function returns by using the
RET
instruction.
RESTRICTIONS FOR SPECIAL FUNCTION TYPES
Interrupt functions
Interrupt functions differ from ordinary C functions in that:
●
If used, flags and scratch registers are saved
●
Calls to interrupt functions are made via interrupt vectors; direct calls are not
allowed
allowed
●
No arguments can be passed to an interrupt function
●
Interrupt functions returns by using the
RETI
function.
For more information about interrupt functions, see Interrupt functions, page 29.
Return values
Passed in registers
8-bit values
R16
16-bit values
R17:R16
24-bit values
R18:R17:R16
32-bit values
R19:R18:R17:R16
Table 29: Registers used for returning values