Page 3 of 4

Posted: Mon Apr 16, 2007 1:58 am
by pcmattman
I thought I couldn't understand it. Now I'm learning AT&T syntax, it's actually really readable.

Posted: Mon Apr 16, 2007 3:38 am
by mystran
Like I've stated several times, I find AT&T easier to read as well, as it's very regular. A nice bonus is that you can identify registers from the % even if you didn't know such a register exists (say, you're reading code for an architecture you don't know very well).

Posted: Mon Apr 16, 2007 4:30 am
by Combuster
while register use is more obvious in at&t syntax, IMHO memory addressing is more obvious in intel syntax as it is more explicit:

compare
foo(%eax,%ebx,0x4)
to
[foo + eax + 4*ebx]

if you know neither syntax, you can sensibly know in the second case what is being computed while you can't in AT&T syntax without looking it up.

Also, a memory access is hard to distinguish from a register access, while in intel syntax, you'll see [...] for every explicit memory operand, while in at&t "mov foo, %eax" is a memory access that reads pretty much like an immediate access.


now SIB addressing in AT&T isn't that hard to learn, but once you've seen some other dialects neither ATT nor Intel looks bad... Consider the following 68k assembly:

Code: Select all

mov.w ([foo,A3],D5.w*2,bar), -(A5)
I'll leave it as an excercise for the reader to try and figure what that does without getting the manual. :twisted:

Posted: Mon Apr 16, 2007 4:38 am
by pcmattman
Registers on the PDP-11 are annoying - r0, r1... sp...

Is there a version of GAS that takes Intel syntax? Can you use Intel syntax with GCC?

Either way, assembly is much easier than most say, once you take the time to learn it.

Posted: Mon Apr 16, 2007 8:59 am
by Brynet-Inc
pcmattman wrote:Registers on the PDP-11 are annoying - r0, r1... sp...

Is there a version of GAS that takes Intel syntax? Can you use Intel syntax with GCC?

Either way, assembly is much easier than most say, once you take the time to learn it.
I've posted this about a billion times, You CAN use intel syntax in C (inline)..

This is how you do it in C...
(Note that after you use Intel syntax you much switch back..)

Code: Select all

asm(".intel_syntax noprefix");
asm("mov eax, edx");
asm(.att_syntax");
And this is how you could do it in a file assembled with GAS..

Code: Select all

.intel_syntax noprefix
mov eax, edx
.att_syntax
But it's not worth the trouble, AT&T syntax is great.. 8)

Posted: Mon Apr 16, 2007 9:03 am
by Aali
-masm=intel will make gcc spew intel syntax

(which means you dont need to specify it in your inline asm)

it does make the build process less obvious though

and you can't mix and match with AT&T somewhere else in the code

Posted: Mon Apr 16, 2007 11:46 pm
by B.E
IMHO assembly has it's place. but only if you use it in the right manner. For example, someone could write a whole system (by system, I mean a program that is database driven) in assembly, but wouldn't be maintainable (i.e if the code need to be ported to another achecture).

If you know that the archecture unlikly to change. then Assembly is the best laguage in the world (in moderation, is even better C).

Posted: Tue Apr 17, 2007 8:32 am
by Tyler
mystran wrote:Like I've stated several times, I find AT&T easier to read as well, as it's very regular. A nice bonus is that you can identify registers from the % even if you didn't know such a register exists (say, you're reading code for an architecture you don't know very well).
No offense but that is a terrible reason to choose a syntax... If you don't know the ISA then you probably shouldn't be programming it. Intel Syntax is so much cleaner looking, and it actually matches the ISA instead of making up its own (movl etc)

Posted: Tue Apr 17, 2007 9:01 am
by binutils
Yes to some human, But not to GCC

Posted: Fri Apr 27, 2007 4:42 pm
by mathematician
There may have been a time when portability was an issue with assembly language, but nowadays about 97% of desk top computers are IBM compatible PC's (much to the disgust of Mac users), and most of them are running Windows (much to the disgust of Linux users).

Posted: Fri Apr 27, 2007 7:07 pm
by Colonel Kernel
mathematician wrote:There may have been a time when portability was an issue with assembly language, but nowadays about 97% of desk top computers are IBM compatible PC's (much to the disgust of Mac users)
Uhhh... Macs these days are x86-compatible too. Where have you been?

Also, there are still a lot of high-end servers out there running various *nix flavours on different architectures. For example, the project I'm working on now involves porting code between x86, Sparc, PowerPC, Itanium, and PA-RISC. This is a big commercial project for a big customer with big $$$... portability still matters IMNSHO.

Posted: Thu May 03, 2007 6:52 am
by Solar
mathematician wrote:nowadays about 97% of desk top computers are IBM compatible PC's...
...yet still only a fraction of all software engineers write software for the x86.

And allmost all lifeforms are insects.

Aren't statistics great? ;-)

Posted: Fri May 04, 2007 1:16 am
by pcmattman
Haven't you heard? 24.53% of statistics are made up on the spot?

Posted: Fri May 04, 2007 2:01 am
by Solar
Actually I was referring to this article and the fact that most CPUs today are 8bit... 8)

Posted: Fri May 04, 2007 2:05 am
by pcmattman
Aha... I just felt like throwing in that time-tested joke...