Why can't nasm replace gas, in *bsd or linux?

Programming, for all ages and all languages.
Post Reply
jronald
Posts: 1
Joined: Sat Feb 07, 2009 1:05 am

Why can't nasm replace gas, in *bsd or linux?

Post by jronald »

In my opinion, assembly language is essentially mnemonics,
so it will not bring incompatibility problem, also, the clearer the better.
Is it true?

So could you tell me why gas is not out?
Because habit?

http://www.nasm.us/doc/nasmdoc1.html#section-1.1.1
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Why can't nasm replace gas, in *bsd or linux?

Post by AndrewAPrice »

GAS uses AT&T syntax, while NASM, FASM, and the majority of other assemblers use Intel syntax. The majority of OSS tools that use GAS (including GCC) are still relying on AT&T syntax.

GCC can generate Intel syntax though (and there's nothing really stopping you from replacing GAS with your own assembler), and also GAS also works with Intel syntax (not TRUE Intel syntax as I found out the hard way, but close to it).
My OS is Perception.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why can't nasm replace gas, in *bsd or linux?

Post by Solar »

MessiahAndrw wrote:GAS uses AT&T syntax, while NASM, FASM, and the majority of other assemblers use Intel syntax.
Some people (like me) prefer the AT&T syntax. It feels "weird" to anyone who's learned Assembler from the usual suspects nowadays (Intel manuals, AoA etc.), but "natural" to dinosaurs like me. ;-)
The majority of OSS tools that use GAS (including GCC) are still relying on AT&T syntax.
Actually GCC doesn't feed GAS assembler source. The handover between GCC and GAS is done in form of a binary representation, which can be disassembled by the -S option.

And there are more dependencies between GCC and the binutils package than just GAS, so I wouldn't bet on any other assembler replacing GAS in binutils...
Every good solution is obvious once you've found it.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Why can't nasm replace gas, in *bsd or linux?

Post by Combuster »

There's still YASM which can assemble both proper intel syntax, as well as AT&T syntax. But as Solar pointed out, there are a lot of hidden dependencies between gcc an binutils forcing you pretty much use them together.

I won't bite the AT&T vs intel syntax troll.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: Why can't nasm replace gas, in *bsd or linux?

Post by earlz »

[troll]
Intel for the win! Intel syntax is the form used by the official intel manuals and the form used by the opcode format itself.
backwards operands and random % and $ signs everywhere doesn't help readability either.
[/troll]

I think it'd be pretty nifty if pcc targeted the 8086 and such with yasm as it's backend assembler.. but many people would argue its an obsolete architecture to develop in C for.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Why can't nasm replace gas, in *bsd or linux?

Post by Love4Boobies »

MessiahAndrw wrote:GCC can generate Intel syntax though (and there's nothing really stopping you from replacing GAS with your own assembler), and also GAS also works with Intel syntax (not TRUE Intel syntax as I found out the hard way, but close to it).
I hear it's not really maintained that well so it doesn't always produce optimal code and sometimes it can even produce wrong code. I'm not sure exactly why this is.
earlz wrote:[troll]
Intel for the win! Intel syntax is the form used by the official intel manuals and the form used by the opcode format itself.
backwards operands and random % and $ signs everywhere doesn't help readability either.
[/troll]
Believe it or not, however official the Intel manuals might be, AT&T came up with the original assembly syntax (for the x86?). And the signs you're talking about aren't thar random, they are a safety feature (for separating registers from labels and so on). I'm sure AT&T fans have things they too find weird about the Intel syntax. I am an Intel fan, myself. I just thought I should mention this.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why can't nasm replace gas, in *bsd or linux?

Post by Solar »

Love4Boobies wrote:I hear [GAS intel mode] is not really maintained that well so it doesn't always produce optimal code and sometimes it can even produce wrong code. I'm not sure exactly why this is.
From the binutils / GAS manual:

as is primarily intended to assemble the output of the gnu C compiler gcc for use by the linker ld.

It's a compiler backend first, and a standalone assembler second.
Every good solution is obvious once you've found it.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Why can't nasm replace gas, in *bsd or linux?

Post by Love4Boobies »

Solar wrote:It's a compiler backend first, and a standalone assembler second.
I can understand that but they could, at least for the sake of inline assembly, do something about this whole mess...
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why can't nasm replace gas, in *bsd or linux?

Post by Solar »

I just don't think they consider intel-style inline assembly - a highly implementation-specific construct of very limited usefulness in user space - to be that much of a priority, given that they still haven't nailed all of the language standards yet...
Every good solution is obvious once you've found it.
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Re: Why can't nasm replace gas, in *bsd or linux?

Post by iammisc »

probably because gas is the GNU assembler and gcc is the GNU compiler collection.

Notice the parallels....
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Why can't nasm replace gas, in *bsd or linux?

Post by qw »

Being a GCC and NASM fan, I would love GCC to produce NASM-style assembly output.

As far as I know, David Lindauer's CC386 is the only C compiler that produces NASM output. But with all due respect, CC386 is not half as good as GCC is.

Roel
Post Reply