Re: Thumb->ARM->Thumb in inline-wrapped asm? [31740]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "dhm" == dave madden <dhm@xxxxxxxxxxxx> 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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux