flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Heap > AT&T Syntax - Why?!?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7110
Location: Slovakia
AT&T Syntax - Why?!?
Does anyone have some idea why stupid ugly AT&T syntax is used in UNIX C? (except for lazyness of compiler-writers). I can't see any pros of this syntax (except extremely easy compilation). It tries to be kind-of portable, but isn't and it makes hell to write.

PS: I am forced to use it in school project... ugh
Post 03 Apr 2006, 09:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1416
Location: Ukraine
i think, it is because of hystoric ages: once upon a time unix was based on other processors, where syntaxis was similar to the current at&t, and, when it was ported to the intel platform, programmers decided to adopt intel mnemonics to their customs instead change own. so, i would say more soft - it is "not usual" to those, who was started from intel basic - who knows about other, who started from pdp or motorola cpus, etc. Wink
Post 03 Apr 2006, 10:16
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 444
Location: BC, Canada
Re: AT&T Syntax - Why?!?

vid wrote:
Does anyone have some idea why stupid ugly AT&T syntax is used in UNIX C? (except for lazyness of compiler-writers). I can't see any pros of this syntax (except extremely easy compilation). It tries to be kind-of portable, but isn't and it makes hell to write.

PS: I am forced to use it in school project... ugh



i really dislike the syntax aswell, probably why i never used GCC for anything and always used LCC, but now i think most UNIX C compilers support intel syntax (i know gcc does)

_________________
redghost.ca
Post 03 Apr 2006, 10:57
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7110
Location: Slovakia
as inline assembler? like __intel_asm("mov eax, [ebx]")
Post 03 Apr 2006, 11:36
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2148
Location: Estonia
Does it go something like:

Code:

movl 6,eax
movl 7,ebx
subl eax,ebx



Very Happy that is really wierd because when I have eax=6 and ebx=7 then
writing "SUB EAX,EBX" I get -1 in EAX, but from the previous code
you don't expect the EAX to remain unchanged and 1 in EBX Neutral
Post 03 Apr 2006, 13:46
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 444
Location: BC, Canada

vid wrote:
as inline assembler? like __intel_asm("mov eax, [ebx]")



yes in GCC its a compile line option i believe that lets you do inline intel syntax rather than at&t, im sure you can find info on its use @ google &| the gcc website

edit: i was bored i found this

http://www.reversing.be/article.php?story=20051203194931893


Quote:


Code:

asm(".intel_syntax noprefix\n");
asm("mov edx,len\n");
asm("mov ecx,offset inlined\n");
asm("mov ebx,1\n");
asm("mov eax,4\n");
asm("int 0x80\n");




notice the first line :

asm(".intel_syntax noprefix\n");

This denotes that the folowing assembly snippet uses intel syntax to the
native assembler gas
now compile this with the following command line
gcc -o intelinlined -masm=intel intelinlined.c

notice the switch -masm=intel
that is all you need to do to inline with intel syntax in gcc
hope this was usefull enough
now lets try running the above code and see if it works


_________________
redghost.ca
Post 03 Apr 2006, 14:06
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7110
Location: Slovakia
many thanks RedGhost.
Post 03 Apr 2006, 15:47
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Plue



Joined: 15 Dec 2005
Posts: 151
The normal inline asm in gcc has a syntax to ease the job of the gcc authors.

_________________
Roses are red
Violets are blue
Some poems rhyme
And some don't.
Post 04 Apr 2006, 19:12
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1317
Location: usa
Re: AT&T Syntax - Why?!?

vid wrote:
... stupid ugly AT&T syntax is ... hell to write.

and very difficult to read, no doubt...
however,
It should be noted, dear Vid, that the rest of the world, not just all other cpu programmers, but even people sending mail, specify:
SOURCE, DESTINATION.
In fact, from a HISTORICAL perspective, it is INTEL that has botched it up, not Motorola et al
But for IBM marketing prowress, selecting M$ over more competent alternatives, and choosing Intel to avoid looking like homo sapiens, we would all be writing that "stupid" syntax that you so dislike!
For me, reading Intel code is just that. Code.
It is an illogical architecture, with only ONE redeeming feature: it is accepted universally throughout the commercial world.
Tragic: yes. Stupid, no, I don't agree. Mind you, I ALSO dislike the ATT syntax, but not because it presents Assembly in a logical fashion (i.e. conformant with ALL other assemblers.) I dislike it because it differs from Intel's. If that seems contradictory, it may be. I don't like INTEL's cpu, but if I have to use it for some project, then I want to use an assembler that conforms to the Intel manual, rather than conforming to the Motorola architecture, superior though that architecture ALWAYS has been.....
Smile
Post 04 Apr 2006, 21:36
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 954
Location: Czechoslovakia
vid: here is interesting discussion about it: (only for czech/slovak readers)

http://forum.builder.cz/read.php?123,841398,841409
Post 05 Apr 2006, 08:21
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 444
Location: BC, Canada
Re: AT&T Syntax - Why?!?

tom tobias wrote:

vid wrote:
... stupid ugly AT&T syntax is ... hell to write.

and very difficult to read, no doubt...
however,
It should be noted, dear Vid, that the rest of the world, not just all other cpu programmers, but even people sending mail, specify:
SOURCE, DESTINATION.
In fact, from a HISTORICAL perspective, it is INTEL that has botched it up, not Motorola et al
But for IBM marketing prowress, selecting M$ over more competent alternatives, and choosing Intel to avoid looking like homo sapiens, we would all be writing that "stupid" syntax that you so dislike!
For me, reading Intel code is just that. Code.
It is an illogical architecture, with only ONE redeeming feature: it is accepted universally throughout the commercial world.
Tragic: yes. Stupid, no, I don't agree. Mind you, I ALSO dislike the ATT syntax, but not because it presents Assembly in a logical fashion (i.e. conformant with ALL other assemblers.) I dislike it because it differs from Intel's. If that seems contradictory, it may be. I don't like INTEL's cpu, but if I have to use it for some project, then I want to use an assembler that conforms to the Intel manual, rather than conforming to the Motorola architecture, superior though that architecture ALWAYS has been.....
Smile



good thing we all aren't writing that crappy syntax, as logical as it may be Laughing

i am not biased towards non-intel/amd x86 assemblers, i find ARM to be quite nice as far as assembly goes, for me it's not because it differs from intel, but because it is similar but in a worse way

_________________
redghost.ca
Post 05 Apr 2006, 13:19
View user's profile Send private message AIM Address MSN Messenger Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
Unfortunately tomtobias is wrong here. Intel got it right from the first try...all other did a big mistake. We are lucky. Think about it honestly, if you can not understand it alone... then i will explain a little:

Registers are like variables, We do write x = 5;
So it is only logical to also write eax = 5; only that in ASM "=" is more like "a move" ... hence the notation MOV EAX,5 perfectly corect and logically clear.

You must understand that ASM is a low level language and it is supposed to expose arhitectural and hardware related issues.

About GAS and AT&T syntax it was designed to be sytupid on purpose. It was never intended to write ASM applications in it.

Instead it was designed to ease the code generation from gcc and to ease the parsing of the GAS assembler as a backend for C compilers.

Hence the notation helps parsing by prefixing constnts and registers and uses the source, destination because it is easyer to generate code from it.

BTW the memory layout (Intel versus Motorola) is also corect in Intel and very wrong in Motorola Wink
Post 05 Apr 2006, 14:21
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7110
Location: Slovakia
tom tobias: destination first is logical. you usually have one destination and one OR MORE sources. if you read in this order: i am going to set value of destination. what am i going to set it to?

in source first, you must read entire source without knowing what are you going to do with it. it is like calling function with arguments before function name Smile
Post 05 Apr 2006, 14:54
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2469
Location: Bucharest, Romania
Re: AT&T Syntax - Why?!?

tom tobias wrote:
It is an illogical architecture, with only ONE redeeming feature: it is accepted universally throughout the commercial world.


Not quite, I think it's the most logical LOW-LEVEL architecture I have seen (maybe there are others I didn't see). You see.. it depends on what you call logic. What you learnt and what you know? It's not that surprising you find other (human) languages illogical. That's why you like english so much, because you know it, and everything you don't know (or don't like) you claim it's illogical/horrible syntax/etc.

If you don't like the Intel architecture, you are by no means forced to use/understand it's low-level logic, but why do you critique it? Build/design something yourself from scratch (that's it: from scratch because you're so afraid of starting things from scratch, I simply don't know why, perhaps because your such a lazy guy that wants to copy/paste everything), and then claim something is sh*t or illogical. Like I said, you're not forced to use or understand it if you don't like it. What I don't like about you is that you start to claim something is illogical, or claim it's horrible/etc simply because you don't like/understand it, or you think it's illogical from your perspective. But don't take your words as if you're the perfect being who IS RIGHT.


And about AT&T: I never really liked that syntax, it's not meant to be programmed by humans (especially for big projects), but rather for compilers/parsers, to make it easier for them.
Post 05 Apr 2006, 17:58
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7110
Location: Slovakia
grey beast: do you find 0x20(%eax, %eax, 4) more logical than [5*eax + 20h], in ANY mean of word "logical"?
Post 05 Apr 2006, 18:14
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2469
Location: Bucharest, Romania

vid wrote:
grey beast: do you find 0x20(%eax, %eax, 4) more logical than [5*eax + 20h], in ANY mean of word "logical"?


Me? Of course not, I don't like AT&T in any way. That's what I said in my previous post, sorry again if I mistyped something.

but there are some psychos who probably enjoy AT&T (ok, I have yet to find such a person Smile )
Post 05 Apr 2006, 18:33
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7110
Location: Slovakia
sorry then, probably i didn't read enough carefully
Post 05 Apr 2006, 20:20
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1032
Location: Michigan, USA
AT&T syntax looks like the old 68000(68k) processor way of programming, it's one of the problems I had to overcome when switching from the mac/Amiga assembly programming to the pentium. The AT&T syntax is the ugliest style of pentium assembly that I have ever seen, hopefully this has changed in the latest GCC incarnations.
Post 06 Apr 2006, 09:51
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 11971
Location: Minos Korva
Factual inaccuarcy:

tom tobias wrote:
ATT syntax, ... Assembly in a logical fashion (i.e. conformant with ALL other assemblers.)

It only takes one simple example to easily disprove your claim. ARM syntax is also OP DEST,SOURCE (similar to Intel's).
Post 06 Apr 2006, 11:28
View user's profile Send private message Visit poster's website Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1317
Location: usa

bogdanontanu wrote:
Unfortunately tomtobias is wrong here. Intel got it right from the first try...all other did a big mistake. ...
Registers are like variables, We do write x = 5;
So it is only logical to also write eax = 5; only that in ASM "=" is more like "a move" ... hence the notation MOV EAX,5 perfectly corect and logically clear.
...

yes, I may have erred in several ways. It may be as logical (for everyone else) to write ...destination-->source. I would not write:
please move shelves, books. I would write: please move [the] books to [the] shelves. I would not say or write: I wish to travel to London, departing from Paris. I would employ source then destination. I would not write: 7 = 4 + 3. I would write: 4+3 = 7. So, yes, I agree with Bogdan, wrong perhaps am I. Thinking aberrant my is maybe.
I am sure that Revolution is also correct. I used (as always) too much jalapeno (hyperbole) in preparing this dish. I should not have written ALL other assemblers, or even MOST other assemblers. I should have written mainstream assemblers. I am eager to learn from Bodgan or anyone else, why writing destination prior to source "expose(s) arhitectural and hardware related issues", while writing source, then destination does not reveal architectural or hardware related matters. Does Bogdan wish to imply that the 68020 and VAX assembers DO NOT reveal the same [low] level of hardware detail as Intel's various assemblers? I will be very eager to learn from someone how "all other did a big mistake." Where is the big error, Bogdan? Do you mean that all other assemblers since Intel's own (very primitive) assembler? Or, do you mean that Intel's architecture, with segments, and "protected mode" are superior to the VAX architecture???????
I couldn't disagree more. For me, VAX architecture was the standard, "best of breed". Motorola copied it. Intel did not.
Post 07 Apr 2006, 09:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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 can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2013, Tomasz Grysztar.