__arch__swab32.
This function reverses the bytes in a word.
The method was discovered in 1986 following a competition between ARM programmers. It requires just 4 instructions and 1 work register.
unsigned long reverse(unsigned long v)
{
unsigned long t;
t = v ^ ((v << 16) | (v >> 16)); // EOR r1,r0,r0,ROR #16 [*]
t &= ~0xff0000; // BIC r1,r1,#&ff0000
v = (v << 24) | (v >> 8); // MOV r0,r0,ROR #8
return v ^ (t >> 8); // EOR r0,r0,r1,LSR #8
}
Could we use the asm. optimized version instead of the generic ___swab32?
[*] http://gcc.gnu.org/PR18560
Signature · 3 lines
/* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */
#define say(x) lie(x)