News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

AT&T vs Intel assembly format

Started by noman9607, April 17, 2006, 04:38:15 PM

Previous topic - Next topic

noman9607

I have downloaded a c compiler that has inline assembley ability. It does not use the familiar  Intel format that MASM uses but
what it calls the "AT&T" or "ATT" format which looks like the following:

size_t __declspec(naked) str_len(char * s)
{
    _asm("movl 4(%esp),%ecx");   // first arg is at 4(%esp)
    _asm("jecxz exit1");         // check for '0' NULL in ecx
    _asm("movl $-1,%eax");       // -1 to start
_asm("L1:");
    _asm("inc %eax");
    _asm("cmpb $0,(%ecx,%eax)"); // compares '0' with the byte pointed to
                                 // by ecx with an offfset of eax.
    _asm("jne L1");              // not finished yet?
_asm("exit1:");
    _asm("ret $4");              // ret in eax (pop 4 bytes before returning)
}

   My question is can I use this format anywhere else or is this some kind of "roll your own assembly format"
that the author cooked up? I really like the whole package, but I don't want to spend a lot of time on a
proprietary type of format.
thanks,
by the way, it is the LCC-win32 pkg by Jacob Navia

Tedd

It's the same format used by the GNU Assembler (Gas).

I'm not sure how many others support it.
As I see it, it is meant to be more help for a compiler than a human user, so it can be a little awkward at times - with all of the (often redundent) specifiers and extra symbols.

Anyway, as long as you learn programming in 'an' assembler, the syntax isn't particularly important. The instructions work the same, and the variance in syntaxes is not so great, so moving to another assembler is just a matter of getting comfortable (rather than needing to re-learn everything.)
No snowflake in an avalanche feels responsible.

arafel

noman9607,

It's a widely used syntax in Unix/Linux world (it started to fade out lately though). Some other well known compilers such as GCC support it.

But, as Tedd has mentioned already, AT&T is not a very friendly syntax for a programmer. If you already familiar with Intel syntax, perhaps it will be better to use some external assembler which supports it and link the object to your C project. Also try checking if LCC has some kind of a switch for choosing the assembly syntax.

drhowarddrfine

I started, but had to stop, learning this for my FreeBSD box.  I really didn't have any difficulty figuring it out at all even though I, too, heard it was inconvenient/backwards/difficult.  At that time, just last year, I was ready to plow right into some stuff but got sidetracked and haven't had a chance to get back into it.

mnemonic

If you use LCC you could as well use PellesC which is - as far as I know - based on LCC but in my opinion far better and up to date.
PellesC supports the familiar Intel syntax like MASM.

On Pelles homepage you should find a sample source on how to use inline assembly within PellesC.

Regards
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Mark Jones

Also (if appicable) you might consider building the assembler commands into a MASM32 static library and include that in your C program instead. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

noman9607

Thanks, for the info guys. The assembler format is not a deal breaker but the resource editor that comes with it crashes the ide .
How come Ted,the first guy to answer calls himself a procrastinator?
I'll switch to Pelles since Hutch is going to roll it (the assembler anyway) into masm32. The docs with Lcc-32 are very nice though. They are well written and perfect for learning C. The author even wrote a manual on how he wrote the compiler and it is a pleasure to read. So i'm going to chuck the compiler from the Frenchman, but keep the English language manuals that he wrote and use the compiler from Sweden  which he wrote in English but I like the editor from England (Ultra Studio) and the debugger from America and I'll take lessons from Hutch in Australia.

Tedd

Quote from: noman9607 on April 17, 2006, 11:04:44 PM
How come Ted,the first guy to answer calls himself a procrastinator?
Because I am? :bg I procrastinate!

Quote
...i'm going to chuck the compiler from the Frenchman, but keep the English language manuals that he wrote and use the compiler from Sweden  which he wrote in English but I like the editor from England (Ultra Studio) and the debugger from America and I'll take lessons from Hutch in Australia.
A truly mutlinational solution! :U
No snowflake in an avalanche feels responsible.

Vortex