* ARM register constraint
@ 2001-12-12 18:24 Shaun Jackman
0 siblings, 0 replies; only message in thread
From: Shaun Jackman @ 2001-12-12 18:24 UTC (permalink / raw)
To: gcc-help
I took this function from the ARM documentation to load an unaligned pointer.
It has one constraint that I can't seem to express though. %0 must be less
than %3. (ie r1 and r2, not r2 and r1) or the ldmia will end up with the
values swapped in those two registers. How can I express this constraint to
GCC?
Please cc me as I'm not a member of this list,
Thanks,
Shaun
/**
* unaligned load
*/
uint32
ld32( const uint32* p)
{
uint32 ret, a, b;
// enter with address in %1 (32 bits)
// uses %2, %3; result in %0.
// Note %0 must be less than %3 e.g. 0,1
asm(
"\n\t@ get word aligned address"
"\n\tbic %2,%1,#3"
"\n\t@ get 64 bits containing answer"
"\n\tldmia %2,{%0,%3}"
"\n\t@ correction factor in bytes"
"\n\tand %2,%1,#3"
"\n\t@ ...now in bits and test if aligned"
"\n\tmovs %2,%2,lsl#3"
"\n\t@ produce bottom of result word ; (if not aligned)"
"\n\tmovne %0,%0,lsr %2"
"\n\t@ get other shift amount"
"\n\trsbne %2,%2,#32"
"\n\t@ combine two halves to get result"
"\n\torrne %0,%0,%3,lsl %2"
: "=r" (ret), "+r" (p), "=r" (a), "=r" (b));
return ret;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-12-13 2:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-12 18:24 ARM register constraint Shaun Jackman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).