Functions that return multiple values
through registers
In C and C++, one way of returning multiple values from a
function is to use a structure. Normally, structures are returned
on the stack, with all the associated expense this entails.
To reduce memory traffic and reduce code size, the compiler
enables multiple values to be returned from a function through the
registers. Up to four words can be returned from a function in a struct by
qualifying the function with __value_in_regs.
For example:
typedef struct s_coord { int x; int y; } coord;
coord reflect(int x1, int y1) __value_in_regs;
__value_in_regs can be used anywhere where
multiple values have to be returned from a function. Examples include:
returning multiple
values from C and C++ functions
returning multiple values from embedded assembly
language functions
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.