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
View all questions in Keil forum