summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-08-21 22:43:00 +0000
committerJens Arnold <amiconn@rockbox.org>2005-08-21 22:43:00 +0000
commit658c8451ead9e7d07478c903c430af9c7799f324 (patch)
tree6415395ad9332aaa42a24c77797e870d40775c4e /firmware
parent9757dc1bea98f8a931f2e774c71c1c4db2bf8dcd (diff)
downloadrockbox-658c8451ead9e7d07478c903c430af9c7799f324.tar.gz
rockbox-658c8451ead9e7d07478c903c430af9c7799f324.zip
Coldfire: assembler optimised SWAB32() inline function. Added SWAW32() even if it isn't currently used.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7379 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/system.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 2a8b98c7a5..895b3f7529 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -207,6 +207,16 @@ static inline unsigned short SWAB16(unsigned short value)
return (value >> 8) | (value << 8);
}
+static inline unsigned long SWAW32(unsigned long value)
+ /*
+ result[31..16] = value[15.. 0];
+ result[15.. 0] = value[31..16];
+ */
+{
+ asm ("swap %%0" : "+r"(value));
+ return value;
+}
+
static inline unsigned long SWAB32(unsigned long value)
/*
result[31..24] = value[ 7.. 0];
@@ -215,9 +225,19 @@ static inline unsigned long SWAB32(unsigned long value)
result[ 7.. 0] = value[31..24];
*/
{
- unsigned short hi = SWAB16(value >> 16);
- unsigned short lo = SWAB16(value & 0xffff);
- return (lo << 16) | hi;
+ unsigned long mask = 0x00FF00FF;
+ asm ( /* val = ABCD */
+ "and.l %[val],%[mask] \n" /* mask = .B.D */
+ "eor.l %[mask],%[val] \n" /* val = A.C. */
+ "lsl.l #8,%[mask] \n" /* mask = B.D. */
+ "lsr.l #8,%[val] \n" /* val = .A.C */
+ "or.l %[mask],%[val] \n" /* val = BADC */
+ "swap %[val] \n" /* val = DCBA */
+ : /* outputs */
+ [val] "+d"(value),
+ [mask]"+d"(mask)
+ );
+ return value;
}
static inline void invalidate_icache(void)