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 you to return multiple values 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;
You can use __value_in_regs anywhere where you need to return multiple values from a function. Examples include:
returning multiple values from C and C++ functions
returning multiple values from embedded assembly language functions
making supervisor calls
re‑implementing __user_initial_stackheap.
See __value_in_regs in the Compiler Reference Guide for more information about __value_in_regs.