Messages in this thread | | | From | Paweł Sikora <> | Subject | [arm] __arch__swab32. | Date | Fri, 3 Dec 2004 17:02:19 +0100 |
| |
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
-- /* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */
#define say(x) lie(x) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |