user2586185
user2586185

Reputation: 3

Different kinds of assembly?

What is the difference for code of this type:

    .text
    .globl main
    .type  main, @function
main:
    movl $0, %eax
    movl $0, (%esp)
    call exit

and code of this type:

    section .text
    global _start
_start:
    mov  edx, eax

Which is more conventional and better for optimization?

Upvotes: 0

Views: 107

Answers (3)

bkausbk
bkausbk

Reputation: 2790

The first one is AT&T assembly style, the second is Intel assembly style. There is no real big difference. GCC usually produces assembly with AT&T style for example (see GNU Assembler GAS) whereas Microsoft and Intel compilers will produce Intel assembly style (see MASM, NASM) outputs.

I prefer Intel style because it seems to look clearer for me, but I think it's a matter of personal taste.

There is a document about differences of both styles which could be helpfull.

http://simon.baymoo.org/universe/tools/symset/symset.txt

Upvotes: 3

Michael
Michael

Reputation: 58487

The first is written in AT&T syntax for GAS. The second is written in Intel syntax, and appears to be for NASM.

I'd say Intel syntax is more conventional, since they're the designers of the x86 processors. Although you still see AT&T syntax being used. None is really more suited for optimization than the other.

Upvotes: 0

James
James

Reputation: 9278

Then first is called AT&T style assembly and is an abomination.

The second is Intel style and is used by Intel in their x86 instruction set documentation.

Upvotes: 2

Related Questions