public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/65897] New: GAS named variable of extended asm (::"m" or "g") is in wrong code style, variable stays still in ".att_syntax" -32(%ebp) not ".intel_syntax noprefix" DWORD PTR [ebp-0x20] while rest of the code is switched on corectly
@ 2015-04-26 22:11 sstsoft at wp dot pl
  2015-04-26 22:40 ` [Bug inline-asm/65897] GAS(asm) "named variable" of extended asm (type ::"m" or "g") generated in wrong code style, variable stays still in ".att_syntax" -32(%ebp) not ".intel_syntax noprefix" DWORD PTR [ebp-0x20] while rest of the code is switched on correctly to Intel pinskia at gcc dot gnu.org
  2015-05-12 19:30 ` sstsoft at wp dot pl
  0 siblings, 2 replies; 3+ messages in thread
From: sstsoft at wp dot pl @ 2015-04-26 22:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65897
           Summary: GAS named variable of extended asm (::"m" or "g") is
                    in wrong code style, variable stays still in
                    ".att_syntax" -32(%ebp) not ".intel_syntax noprefix"
                    DWORD PTR [ebp-0x20] while rest of the code is
                    switched on corectly
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sstsoft at wp dot pl
  Target Milestone: ---

GNU Asembler version 2.32.2
GCC 4.8.1
QT Creator 5.3.1

"g++ -c -fno-keep-inline-dllexport -save-temps -Wattributes
-fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -v
-momit-leaf-frame-pointer -os -Wno-write-strings -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-label -Wno-unused-value -Wunknown-pragmas
-std=gnu++0x -pthread -fopenmp -fverbose-asm -g -std=c++0x -frtti -Wall -Wextra
-fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG
-DQT_GUI_LIB -DQT_CORE_LIB ..."

simple code as below:
int val;
asm volatile (".INTEL_SYNTAX noprefix\n mov eax,%[val]\n" :: [val] "g" [&val]
asm volatile (".ATT_SYNTAX\n");

is compiled into-> mov eax,-32(%ebp)

rather than correct version for Intel syntax:

-> mov eax,DWORD PTR[ebp-0x20]

First of all i thunk it was capital problem (INTEL not .intel) but it's not.
BTW. Why generated /APP /NO_APP rather than #APP #NO_APP? 
When i switch on -masm=intel globally and disable .intel_syntax in my inline
asm() it compiles whole code correctly(as above). 
When I make ATT code after asm(".att_syntax\n movl -32(%ebp),%eax\n" :: [val]
"g" (&val)); + .intel switched globaly ON, code generated for val stays in
"att" so, no error produced, compilation successed. It's happens either when
syntax is double changed into one asm() statement, 2 statements(as posted), or
three .intel + code + .att, Code .s for named variable is always formated wrong
(as default in ATT mode). Any other code even with global variables is produced
okey, asembler code is working but not when i add named variable (extended
assembly). Even if gcc optimizes val into registry, produces %eax rather than
eax output so it must be a bug not a feature.

I know there is =r, r mode. But for me it's bad that GCC don't know what
register names im using in inline asembly, GAS it's not. Named variables it's
only way to force asm for using locals, "g" mode, 
#__VA_ARGS__ myasm() = myasm_vars() defs is the only way for simpler ported
code. 

Bug is well known by others:
http://gotoanswer.com/?q=GCC+inline+assembly+error%3A+Error%3A+junk+%60%28%25esp%29%27+after+expression
https://www.c-plusplus.net/forum/106506-full
http://stackoverflow.com/questions/13856792/gcc-inline-assembly-error-error-junk-esp-after-expression

Sorry, english is not my primary language.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-12 19:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-26 22:11 [Bug inline-asm/65897] New: GAS named variable of extended asm (::"m" or "g") is in wrong code style, variable stays still in ".att_syntax" -32(%ebp) not ".intel_syntax noprefix" DWORD PTR [ebp-0x20] while rest of the code is switched on corectly sstsoft at wp dot pl
2015-04-26 22:40 ` [Bug inline-asm/65897] GAS(asm) "named variable" of extended asm (type ::"m" or "g") generated in wrong code style, variable stays still in ".att_syntax" -32(%ebp) not ".intel_syntax noprefix" DWORD PTR [ebp-0x20] while rest of the code is switched on correctly to Intel pinskia at gcc dot gnu.org
2015-05-12 19:30 ` sstsoft at wp dot pl

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).