This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Thumb->ARM->Thumb in inline-wrapped asm? [31740]
- From: dave madden <dhm at mersenne dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 28 Feb 2008 09:01:32 -0800
- Subject: Re: Thumb->ARM->Thumb in inline-wrapped asm? [31740]
- References: <1204180364.24623.ezmlm@gcc.gnu.org>
>>>>> "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.