Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide
translations



Rockbox mail archive

Subject: question: pointer alignment on ColdFire and SH7034

question: pointer alignment on ColdFire and SH7034

From: Frederic Devernay <frederic.devernay_at_m4x.org>
Date: Wed, 26 Oct 2005 13:45:28 +0200

Dear all,

While doing a bit of work on rockboy optimization (some people think it would be
nice to have it run full speed), I came accross this in the rockboy source:
#ifdef ALLOW_UNALIGNED_IO /* long long is ok since this is i386-only anyway? */
#define MEMCPY8(d, s) ((*(long long *)(d)) = (*(long long *)(s)))
#else
#define MEMCPY8(d, s) memcpy((d), (s), 8)
#endif

A first optimization (which already gives a nice performance boost) is to
replace the second define by
#define MEMCPY8(d, s) {d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; d[3] = s[3]; \
   d[4] = s[4]; d[5] = s[5]; d[6] = s[6]; d[7] = s[7];}

but it would even be better if we could use the first one. So the question is:

On the processors we use (ColdFire and SH7034), is the following instruction
authorized, even if s and d are not aligned?
((*(long long *)(d)) = (*(long long *)(s)))

Fred

PS: other rockboy optimizations are on the way...
Received on 2005-10-26

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy