flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Questions about AT&T syntax.

Author
Thread Post new topic Reply to topic
nerdguy



Joined: 24 Nov 2013
Posts: 7
nerdguy 06 Dec 2013, 09:42
Well, forgive me if I ask some silly questions, until now I had been doing assembly and C separately 'cause I never needed that + I used the nice Intel Syntax, now I have this GCC which uses the AT&T syntax,
After reading some horrible pages about AT&T syntax, I tried some code.
So what I am trying to do is put the value in RSI into a character (char c) through this :
Of course there is something wrong, I am doing some lazy stuff, cause GCC says mov
doesn't support that.
Forgive me again for my knowledge, I have just started with inline assembly in C,
(Because I never needed it,)
Here goes my first try : (I screwed up)
Code:
void return_rsi(char *c)
{ 
// Put RSI in char C
__asm__ __volatile__ ( "movl %%rsi,%0" : : "d" ( *c ) );
}
    

Now is FSF using AT&T syntax, because of some other free-non-free policy?
Look at this :
Code:
movl %%RSI,%%RBX ; I don't even know how to write AT&T Code
int $0x10
    

and this
Code:
mov RBX,RSI
int 0x10
    

Now why is AT&T syntax still in use?
Post 06 Dec 2013, 09:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20448
Location: In your JS exploiting you and your system
revolution 06 Dec 2013, 11:56
With AT&T the order of operands is reversed.
Code:
mov source,dest    
Plus a number of other differences.

Anyhow, I though that GCC could be coaxed into Intel mode with some pragma or something.
Post 06 Dec 2013, 11:56
View user's profile Send private message Visit poster's website Reply with quote
nerdguy



Joined: 24 Nov 2013
Posts: 7
nerdguy 06 Dec 2013, 12:18
@revolution
Code:
.intel_syntax noprefix
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Let the awesome intel syntax go here
; And switch back to AT&T! Useless piece of puke
.att_syntax noprefix
; Compile with
; gcc -<Options> -masm=intel source.c    

Man, this AT&T syntax is a killer!
Post 06 Dec 2013, 12:18
View user's profile Send private message Reply with quote
dogman



Joined: 18 Jul 2013
Posts: 114
dogman 17 Dec 2013, 19:00
AT&T syntax is ugly as hell and goes against the object code operand order in many cases. About the *only* thing good about it on Intel is the instructions specify operand length so you don't have to code byte, word, dword ugliness. It was not designed for humans to use, since UNIX-heads write C, not assembler like real men. So it's more about being easy to parse than it is about being useful and it is a back-end to all their compilers which are really not true compilers (they don't put out object code) but translators from whatever source language to assembly code on target X. Of course that means it's good for them if the assembly syntax varies as little as possible across the many platforms gcc has oozed and slimed itself onto.

The % for registers and $ for immediate operand stuff is a pain in the ass for humans and the operand reversal is a true mind-fart, especially since it's not 100%.
Post 17 Dec 2013, 19:00
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 17 Dec 2013, 19:42
dogman,

You may guess why AT&T syntax is so thorough about operand's meaning (cf. MASM vs. TASM .ideal and fasm memory references' syntax). PDP's MACRO-11 also had those %0, …, %7 native names for slightly more user-friendly R0, …, R5, SP, PC, along with # for numeric literals and so on. That's all about simplification of source parsing (several KiBs of memory and lousy CPU speed definitely require it).
Post 17 Dec 2013, 19:42
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.