public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "noloader at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug driver/67301] New: Unable to compile program using extended assembly and asmSymbolicName
Date: Fri, 21 Aug 2015 04:44:00 -0000	[thread overview]
Message-ID: <bug-67301-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67301

            Bug ID: 67301
           Summary: Unable to compile program using extended assembly and
                    asmSymbolicName
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: noloader at gmail dot com
  Target Milestone: ---

The following program:

  $ cat test.cxx
  int main(int argc, char* argv[])
  {
      __asm__ __volatile__ (

            "\t movl %[__ARGC], %%eax \n"
            :
            : __ARGC "" (argc)
      );

      return 0;
  }

Results in a failed compile:

  $ g++ test.cxx
  test.cxx: In function ‘int main(int, char**)’:
  test.cxx:7:5: error: expected string-literal before ‘__ARGC’
     : __ARGC "" (argc)
     ^
  test.cxx:7:5: error: expected ‘(’ before ‘__ARGC’
  test.cxx:7:5: error: ‘__ARGC’ was not declared in this scope
  test.cxx:7:12: error: expected ‘)’ before string constant
     : __ARGC "" (argc)
            ^
  test.cxx:7:12: error: expected ‘)’ before string constant

Above, I am trying to use GCC's extended ASM like Microsoft's MASM.

According to the online manual and Assembler Instructions with C Expression
Operands, § 6.44.3.1 Input Operands
(https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html), asmSymbolicName is
being used correctly.

    Operands are separated by commas. Each operand has this format:

      [ [asmSymbolicName] ] constraint (cexpression)

    asmSymbolicName

        Specifies a symbolic name for the operand. Reference the name in the
      assembler template by enclosing it in square brackets (i.e. ‘%[Value]’).
      The scope of the name is the asm statement that contains the definition.
      Any valid C variable name is acceptable, including names already defined
      in the surrounding code.
>From gcc-bugs-return-495319-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Aug 21 05:06:10 2015
Return-Path: <gcc-bugs-return-495319-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31883 invoked by alias); 21 Aug 2015 05:04:26 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 31842 invoked by uid 48); 21 Aug 2015 05:04:18 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug driver/67301] Unable to compile program using extended assembly and asmSymbolicName
Date: Fri, 21 Aug 2015 05:04:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: driver
X-Bugzilla-Version: 4.9.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pinskia at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-67301-4-PsiMhPveNX@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67301-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67301-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-08/txt/msg01461.txt.bz2
Content-length: 582

https://gcc.gnu.org/bugzilla/show_bug.cgi?idg301

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Try:
 int main(int argc, char* argv[])
  {
      __asm__ __volatile__ (

            "\t movl %[__ARGC], %%eax \n"
            :
            : [__ARGC] "r" (argc)
      );

      return 0;
  }

Basically the syntax for naming operands is [XYZ] but since it is optional, [
is used to say it is optional part of the syntax.  Yes it is slightly confusing
but that is what you get when you use [] as both part of the actual syntax and
saying it is an optional part.


             reply	other threads:[~2015-08-21  4:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-21  4:44 noloader at gmail dot com [this message]
2015-08-21  5:11 ` [Bug driver/67301] " noloader at gmail dot com
2015-08-21  9:01 ` [Bug inline-asm/67301] " rguenth at gcc dot 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=bug-67301-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).