I have this code:
typedef union { uint i; uchar b[2]; } UINT;
UINT ByteToHex(unsigned char b);
I write a little code in assembler that convert a hex byte y two ascii byte.
when I call this routine from C
void main(void){ UINT asc;
asc=ByteToHex(0x49); }
The value returned in asc is not 0x3439. However the value 0x3439 is returned in r6 and r7 correctly.
why?
"The value returned in asc is not 0x3439."
The value returned? Which value -- asc.i or asc.b[]? What is 'uchar'? What is the point of the union in the first place? I can't perceive any justification for a union given your apparent usage scenario.