public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: dave madden <dhm@mersenne.com>
To: gcc-help@gcc.gnu.org
Subject: Re: Thumb->ARM->Thumb in inline-wrapped asm? [31740]
Date: Thu, 28 Feb 2008 17:44:00 -0000	[thread overview]
Message-ID: <85skzdf21f.fsf@voxan.mersenne.com> (raw)
In-Reply-To: <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.

           reply	other threads:[~2008-02-28 17:02 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1204180364.24623.ezmlm@gcc.gnu.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85skzdf21f.fsf@voxan.mersenne.com \
    --to=dhm@mersenne.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).