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

32 Bit swap algorithem

Hi,
I'm using LPC4088 (Cortex M4) and I need to swap uint32_t on the bit level.
I have a chip that transfer data 32bits (with SSP) with Lsb first - so I have to swap the result in my code.
Because I do it very often - I need the fastest algorithem to do that.

1. The easy way its to shift 32 times and create a new variable depend on the lsb bits.
2. Another technic is to handle the uint32 as 4 bytes (8 bit) and to use lookup table for each byte to swap it. This technic read first byte - swap it (with lookup table) and put in the new location (at the msb side) - and continue for all 4 byte.

Maybe there is a faster technic - (ASM, C..)

Any better solution?
Doron

0