Re: AT&T or Intel syntax ?



psr wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi ,

I want to learn x86 assembly.
I started looking into a book called Linux Assembly Language
Programming by Bob Neveln.

The first few pages speak of MASM , TASM, NASM, GNU as , intel synatx
and At&T synatx. The books says some good points about Nasm and its
syntax matching that of Intel's.It considered AT&T syntax obscure and
difficult to understand.

But my interest in the Linux kernel tells me there is AT&T assembly in
the kernel and not Intel's syntax. So i am more interested in learning
assembly using AT&T synatx.

At the same time i am really now confused if i should follow AT&T
syntax of intel's one?

Nasm or Gas?

I do not want to waste time on gas just to realise NASM was a better
choice.

Do you people have any advice to someone like me who is a C programmer
but not an asm programmer?

Which way should i follow?

AT&T or Intel syntax, keeping in mind i 'll be reading the Linux
kernel source?

Are there any good books i can follow which will help me in building a
solid foundation of assembly?

Jonathan Bartlett's "Programming From The Ground Up" teaches assemly language using AT&T syntax:

http://www.cafepress.com/bartlettpublish.8640017

Or the "free", as in "freeloader" version:

http://savannah.nongnu.org/projects/pgubook/

I agree that AT&T syntax is "obscure and difficult to understand" - "ugly as a bulldog's hind end", too! :) (I'm a Nasm bigot) However, it *is* what you'll find in the Linux kernel. Someone should re-write the entire kernel in Nasm - get rid of that obscure C, too! Since that's not happening...

I'm not familiar with Neveln (give us a "review" once you're into it). Since you've got that, probably starting there, and learning AT&T equivalents later would work. As Bjarne points out, it's "just syntax". Probably pretty confusing for a beginner, but as you learn what we're trying to *do* with "mov eax, ebx" it'll be more obvious that "movl %ebx, %eax" is the "same thing".

If you come up with specific examples, either from the kernel or from Neveln, we can probably help you convert it to the "other way". Once the assembler has converted our masterpiece to machine language, it really *is* the same thing.

You're in a dilemma to which there's no "right answer"... but no "wrong answer" either! Either... both... Follow your "instinct" and I don't think you'll go wrong.

Best,
Frank

.



Relevant Pages

  • Re: Why is my nasm program killing itself?
    ... The binary should be killed in any kernel version (it is not conforming ... how many Linux distributions used ... this buggy linker (or maybe the linker doesn't have a bug but the object ... file generated by the assembler isn't correct and newer versions of the ...
    (alt.lang.asm)
  • Re: A (mild-mannered) defense of RosAsm
    ... > not only run in Windows and Linux but nearly on every existing ... AFAIK, your assembler will not. ... Your syntax is, to me, quite cryptic. ...
    (alt.lang.asm)
  • Re: Direct Linux syscalls
    ... > Does Linus also close his eyes when he's writing the kernel too? ... That does apply to the shared libc. ... Linux is not the way to go. ... > to make sure that the assembler supports it...yes, ...
    (comp.os.linux.development.apps)
  • Re: My view on this "Is blah an assembler"
    ... > means it would be an Assembler. ... Assembly language lacks higher-level logical ... inconsistent and ambiguous syntax (that directly ... > mov eax MySymbolic; Adress ...
    (alt.lang.asm)
  • Re: Help with Enter and Leave Instructions
    ... FASM works pretty good under Linux, ... much like all those old DOS programmers who never could move ... because just about every other assembler on the planet does this. ... the big problem with being one of these pioneers you keep ...
    (alt.lang.asm)