From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21188 invoked by alias); 15 Feb 2011 23:58:32 -0000 Received: (qmail 21180 invoked by uid 22791); 15 Feb 2011 23:58:31 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from wp154.webpack.hosteurope.de (HELO wp154.webpack.hosteurope.de) (80.237.132.161) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Feb 2011 23:58:26 +0000 Received: from p5dc3367a.dip.t-dialin.net ([93.195.54.122] helo=[192.168.2.100]); authenticated by wp154.webpack.hosteurope.de running ExIM with esmtpa id 1PpUmb-0002hs-1x; Wed, 16 Feb 2011 00:58:16 +0100 Message-ID: <4D5B1310.5070406@andihellmund.com> Date: Wed, 16 Feb 2011 05:25:00 -0000 From: Andi Hellmund User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11pre) Gecko/20100623 Spicebird/0.8 MIME-Version: 1.0 To: kevin diggs CC: gcc-help@gcc.gnu.org Subject: Re: need volatile for asm? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2011-02/txt/msg00224.txt.bz2 On 02/16/2011 12:11 AM, kevin diggs wrote: > Hi, > > Does the asm in: > > #include > > int main(int argc, char *argv[]) > { > unsigned int pc; > > asm("\n\t" > "call 1f\n\t" > "1: pop %0\n" > :"=g"(pc) > ); > > printf(__FILE__"`%s()-%d: %%pc is %p\n",__func__,__LINE__,pc); > > return 0; > } > > need volatile? > > Thanks! > > kevin > Hey Kevin no, you don't need the volatile keyword since the output operand (pc) is live after the asm statement which puts a side-effect on the asm statement. A possible way to verify the need of volatile would be to compile the code at a high optimization level, e.g. -O3 and check the assembly code (-S option) if the inline assembly was removed or NOT. Best regards, Andi