Can a function have more than one return value?
Is there a work around?
Maybee in Assembler to return both, R0 & R1.
:-)
Is this silly?
Can a function have more than one return value? not ARM but C: NO
Is there a work around? not really "a work around" but methods: 1) (a) global variable(s). 2) return a pointer to a global array/struct with the values. 3) call with a pointer to an array/struct in which to store the values. 4) there may be more
Maybee in Assembler to return both, R0 & R1. Is this silly? yes, because how are you going to make the calling c code 'read' somet5hing it is not supposed to 'read'
now, as I said "there may be more", her is one since you specifically say "R0 & R1", it seems you could use a union such as (example)
union WorkAround { unsigned char c[2]; unsigned short s; };
void foo (union WorkAround transfer2) { ... }
union WorkAround WAstore
foo (WAstore);
varuable 1 = WAstore.c[0]; varuable 2 = WAstore.c[1];
EXAMPLE, not assumed to be syntaxically correct. I see no reason this would now work and this may be what you are looking for
Erik
In C ? No.
In C ? Yes. Return a pointer to a structure, or pack several small datatypes into one large datatype, or use global variables. The first is probably the cleanest way to do it, the other two might have their uses in certain situations.
In assembler, all bets are off. As long as the caller (which should also be in assembly) knows what the exit status of the function is (which registers are changes etc), you can do whatever you want in assembly. Just be sure to meticulously document everything, and don't ever call such a function from any language that has particular calling conventions.