I need guidance on inlining asm code in my linux C programs. I have some intel-assembler experience and I have made a few stumbling and generally failed efforts to get to grips with AT&T syntax.
However I was trawling through the gcc info pages and found a switch called "-masm=".
I have discovered (excitedly) that gcc will apparently compile a block of asm that is written as regular intel style code. See the screenshot attached to see my simplest-possible test.
My question is this:
Given that A) intel asm is easy, B) AT&T is hard, C) AT&T is gcc and unix standard, D) I have not been able to find any GOOD sources of information (reference or tutorials) on AT&T assembly.
What should I use, intel or AT&T? I do want to conform to industry standards but at the same time AT&T is a nightmare.
I'm willing to put time into learning AT&T, but only if it's going to be time-well spent in the long run, from where I'm standing (angry and frustrated) it just doesn't look that way.
I need the advice of a more experienced unix assembly coder.
Last edited by wossname; Mar 26th, 2008 at 02:53 PM.
I'd go for Intel ASM anyday.
The reason is that I am in touch with that every day. And that I think AT&T ASM is Harder but it doesn't add anything.
Though I am still looking for a way to use intel ASM in my GCC C++ Code.
I did code both Assembler Languages on Linux. And I think AT&T is a load of Rubbish...
Certainly the syntax is a lot harder in AT&T assembler but I do think it add's something - re-tartegability (I made that word up clearly). AT&T syntax doesn't tie the code to any particular CPU, it's probably the closest thing to portable ASM we're likely to get.
I havent really done much ASM since I started this thread so I guess I'll play it by ear.
Wait a minute.... the output of your program cant be right.... when a program terminates on a Linux system isn't the %ebx register used as the exit status?
Certainly the syntax is a lot harder in AT&T assembler but I do think it add's something - re-tartegability (I made that word up clearly). AT&T syntax doesn't tie the code to any particular CPU, it's probably the closest thing to portable ASM we're likely to get.
I havent really done much ASM since I started this thread so I guess I'll play it by ear.
Honestly woss, the very second a programmer decides to use assembly language, that programmer is starting to worry about platform specific information. The basic rule of thumb is if you need asm to be portable, then you are far better off staying with a high level language.
With ASM you need to be very specific about the hardware. Every processor has advantages in this or that and disadvantages in this and that. Some processors do inc faster then add, others do add faster then inc. Some will go apeshit nuts if you have misaligned data, others will just tax you and keep on going as if it never happened.
Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde