From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19207 invoked by alias); 28 Feb 2008 17:02:05 -0000 Received: (qmail 19055 invoked by uid 22791); 28 Feb 2008 17:02:04 -0000 X-Spam-Check-By: sourceware.org Received: from zz30.net (HELO secure3.zz30.net) (69.65.4.130) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 28 Feb 2008 17:01:39 +0000 Received: from c-24-22-8-198.hsd1.mn.comcast.net ([24.22.8.198] helo=voxan.mersenne.com) by secure3.zz30.net with esmtpa (Exim 4.68) (envelope-from ) id 1JUmBB-0002EH-H3 for gcc-help@gcc.gnu.org; Thu, 28 Feb 2008 11:04:21 -0600 Date: Thu, 28 Feb 2008 17:44:00 -0000 Message-Id: <85skzdf21f.fsf@voxan.mersenne.com> To: gcc-help@gcc.gnu.org Subject: Re: Thumb->ARM->Thumb in inline-wrapped asm? [31740] X-Draft-From: ("nnimap+mail.mersenne.com:INBOX" 9545) References: <1204180364.24623.ezmlm@gcc.gnu.org> From: dave madden Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-02/txt/msg00361.txt.bz2 >>>>> "dhm" == dave madden 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.