From: Andi Hellmund <mail@andihellmund.com>
To: kevin diggs <diggskevin38@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: need volatile for asm?
Date: Wed, 16 Feb 2011 05:25:00 -0000 [thread overview]
Message-ID: <4D5B1310.5070406@andihellmund.com> (raw)
In-Reply-To: <AANLkTinh2xWeoY_FNn1F1G3c_ykoevAomYph2FO8nt0u@mail.gmail.com>
On 02/16/2011 12:11 AM, kevin diggs wrote:
> Hi,
>
> Does the asm in:
>
> #include<stdio.h>
>
> 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
next prev parent reply other threads:[~2011-02-15 23:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-15 23:58 kevin diggs
2011-02-16 5:25 ` Andi Hellmund [this message]
2011-02-16 10:33 ` Andrew Haley
2011-02-16 10:59 ` Drasko DRASKOVIC
2011-02-16 11:18 ` Andi Hellmund
2011-02-16 12:12 ` David Brown
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=4D5B1310.5070406@andihellmund.com \
--to=mail@andihellmund.com \
--cc=diggskevin38@gmail.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).