flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > How to produce assembly output in Intel syntax with GCC?

Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 20 Nov 2008, 22:05
I'm so exited in finding this that I couldn't resist to post this link: http://stackoverflow.com/questions/199966/how-do-you-use-gcc-to-generate-assembly-code-in-intel-syntax

Example that worked for me: gcc main.c -S -O3 -masm=intel

Google, Thanks! Very Happy
Post 20 Nov 2008, 22:05
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 21 Nov 2008, 01:59
Quote:
worked for me: gcc main.c -S -O3 -masm=intel


COOL: http://board.flatassembler.net/topic.php?p=84571#84571

What was in "main.c" ? How many lines ?

Anyway, I had tested (using CC1.EXE from MINGW, on DOS, no DGJ-PP, of course Laughing ) in the meantime:

- Seems to work somewhat

- Syntax is mostly fixed, not fully, still strange directives and MA$M (or rather TASM ideal ?) instructions ... too much of PTR and OFFSET for my taste Sad ... OTOH no ASSUME or PROTON encountered yet. Maybe some simple S&K (Search&Kick) process could fix it finally. Smile

- I've seen complaints about "ma$m=intel" being "broken" in GCC ... very valuable bug report Evil or Very Mad

- Tested also the O-hack: compiler is very stupid by default, but seems to be incredibly smart with -O3 : detects constant "variables" as well as unused variables, rearranges calculations, ... the problem is that is brews very broken code in some cases Sad Of course there have been many complaints about "-O2 and above is broken" or "-O3 and above is broken" around ... so is this a known and acceptable issue of "high quality compiler" that -O2 and above is an experimental kamikaze hack producing broken results ? The compiler doesn't warn at all Sad Sad Sad Sad
Post 21 Nov 2008, 01:59
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 21 Nov 2008, 04:39
DOS386: just about everything on my gentoo linux server is compiled with -O3... some older GCC versions might be broken, and some (poorly written, usually) might break at high optimization levels (because they're making assumptions that C/C++ doesn't guarantee).

GCC might not always produce as good code as Intel or MS compilers, but it's not a bad product... and it's under constant development.

As for "OFFSET" and "PTR", it's the defacto standard on intel because of TASM and MASM. I'm not saying that's a good thing or that you should like it, but it's pretty obvious that GCC is going to use defacto syntax rather than output for a relatively niche assembler as FASM.
Post 21 Nov 2008, 04:39
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 21 Nov 2008, 17:49
Quote:

What was in "main.c" ? How many lines ?

Not much, I've just done that to verify that what I wrote is what I wanted since it is safer than re-reading the documentation and believe you understood it correctly Razz

I've used O3 because it was much clearer to read than the default setting.
Post 21 Nov 2008, 17:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 21 Nov 2008, 17:57
Actually I am surprised you didn't preiously know that. Even I've known that for a long time and I don't even code in C. I'm not trying to boast here, just genuinely shocked Shocked. Quite a few other compilers can also generate Intel syntax.
Post 21 Nov 2008, 17:57
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 21 Nov 2008, 18:31
Quote:

Quite a few other compilers can also generate Intel syntax.

I know, I have posted an example generated with Visual C++ 2005 for you when you claimed that the compilers are stupid for not detect unneeded volatile specifiers when the problem to solve don't need them.

The thing I didn't know was that GCC allowed to override the loved for no reason at all by Unix community AT&T syntax.
Post 21 Nov 2008, 18:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 21 Nov 2008, 19:25
LocoDelAssembly wrote:
... the loved for no reason at all by Unix community AT&T syntax.
Oh, it is not for no reason. The reason is that it makes it uniquely Unix. Even though it is an abominable syntax it does have an air of Unix-ness to it whenever people read it. Wink
Post 21 Nov 2008, 19:25
View user's profile Send private message Visit poster's website Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 533
drhowarddrfine 23 Nov 2008, 04:15
I don't understand what makes it 'Unixy'. It's part of how the compiler works and isn't really for human consumption. Personally, I have no issues with ATT syntax.
Post 23 Nov 2008, 04:15
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 23 Nov 2008, 19:44
Quote:

Personally, I have no issues with ATT syntax.

Do you feel more comfortable with it than, say, fasm, nasm or similar Intel-like syntax?

I see ATT syntax as the pleasure of the masochistic, what are the advantages of ATT over Intel syntax anyway? The official architecture manuals don't use this syntax so you even have to force your mind into permanent translation, it even disagrees with the placement of the dest and src operands.
Post 23 Nov 2008, 19:44
View user's profile Send private message Reply with quote
mattst88



Joined: 12 May 2006
Posts: 260
Location: South Carolina
mattst88 23 Nov 2008, 20:03
AT&T syntax is really just a relic of Bell Labs and UNIX.

It's not around because it's loved. It's still around because many people know it.
Post 23 Nov 2008, 20:03
View user's profile Send private message Visit poster's website Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 533
drhowarddrfine 24 Nov 2008, 00:07
LocoDelAssembly wrote:
Quote:

Personally, I have no issues with ATT syntax.

Do you feel more comfortable with it than, say, fasm, nasm or similar Intel-like syntax?
Not more so. Just the same. There are things I prefer, such as left to right reading.
Quote:

I see ATT syntax as the pleasure of the masochistic, what are the advantages of ATT over Intel syntax anyway?
What are the advantages of Intel syntax? Just fewer dollar signs? I don't see what the big deal is.
Quote:
The official architecture manuals don't use this syntax so you even have to force your mind into permanent translation
I don't know what you mean by that but I don't translate anything when I use it. iow, I don't try and translate anything else into ATT. I only think in ATT.
Quote:
it even disagrees with the placement of the dest and src operands.
It does not but it is inconsistent in a couple areas and not everywhere. Just like MASM is inconcistent in a few areas.
Post 24 Nov 2008, 00:07
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 24 Nov 2008, 05:47
drhowarddrfine wrote:
LocoDelAssembly wrote:
Quote:

Personally, I have no issues with ATT syntax.

Do you feel more comfortable with it than, say, fasm, nasm or similar Intel-like syntax?
Not more so. Just the same. There are things I prefer, such as left to right reading.


680x0 had me thinking that way for a while. AT&T being so drastically different helps with shifting the mindset, imho. If it looked closer to TASM/NASM/MASM/FASM then I'd just stare lost +15% of the time while trying to read it.

EDIT by DOS386 : fixed broken quotes (is this like you tried to do ???)

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 24 Nov 2008, 05:47
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.