This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Efficient translate from 0x12345678 to 0x87654321

Dear all,
I met a problem due to big-endian of 8051. The phenomenon is as follows:

32-bit value A[4] is in XDATA space
Ex. offset 0 = 0x12; offset 1 = 0x34; offset 2 = 0x56; offset 3 = 0x78

I used the following to get this value:
*((UINT32 *) 0);

For 8051 we got "0x12345678" because of big-endian...

Is there any "efficient"(favor size) method to transform it to 0x87654321 ?

I tried to use: A[0]+A[1]<<8+A[2]<<16+A[3]<<24 but the "machine code" gets bigger...

Thanks !

0