* Re: Thumb->ARM->Thumb in inline-wrapped asm? [31740]
[not found] <1204180364.24623.ezmlm@gcc.gnu.org>
@ 2008-02-28 17:44 ` dave madden
0 siblings, 0 replies; only message in thread
From: dave madden @ 2008-02-28 17:44 UTC (permalink / raw)
To: gcc-help
>>>>> "dhm" == dave madden <dhm@mersenne.com> writes:
dhm> I'm hoping to put together an inline func wrapper for an
dhm> asm() fragment that can, for the sake of argument, disable
dhm> interrupts and return CPSR to a Thumb function.
Following up my own message, it turns out I'd wandered down Stupid
Lane after misinterpreting other error messages. The way to do this
is the ADR pseudo-op, which reliably gets the necessary address into a
register. One solution that appears to work is:
/*
* Thumb-mode function to disable interrupts and return current
* value of CPSR
*/
static inline int
portDISABLE_INTERRUPTS( void ) {
int retval, tmp;
__asm__ __volatile__ ( "adr %0 , 1$\n"
"bx %0\n"
".arm\n"
"1$: mrs %0 , CPSR\n"
"orr %1 , %0 , #0xc0\n"
"msr CPSR_c , %1\n"
"adr %1 , 2$ + 1\n"
"bx %1\n"
".thumb\n"
"2$:\n"
: "=r" (retval), "=r" (tmp) );
return retval;
}
d.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-02-28 17:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1204180364.24623.ezmlm@gcc.gnu.org>
2008-02-28 17:44 ` Thumb->ARM->Thumb in inline-wrapped asm? [31740] dave madden
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).