Comparison between at&t Assembly format and Intel assembly format

Source: Internet
Author: User

GCC uses at&t's Assembly format, also known as the gas format (GNU asembler GNU Assembler), while Microsoft uses Intel's Assembly format.
Basic syntax
There are several differences in syntax.
1. Register naming principles

At&t Intel Description
% Eax Eax Intel does not contain a percentage sign

2. source/destination operand order

At&t Intel Description
Movl % eax, % EBX MoV EBX, eax The destination operand of Intel is first, and the source operand is later

3. Constant/immediate Number Format

At&t Intel Description
Movl $ _ value, % EBX MoV eax, _ value Intel immediate number without the $ symbol
Movl $ 0xd00d, % EBX MoV EBX, 0xd00d The rule also applies to the hexadecimal instant number.

4. operand length identifier

At&t Intel Description
Movw % ax, % BX MoV BX, ax In Intel assembly, the length of an operand is not identified by a directive symbol.

In at&t format, each operation has a character suffix, indicating the size of the operand. For example, the mov command has three forms:

Movb transfer bytes

Movw

Movl dual-character Transfer

In many machines, 32 digits are called long words, which are caused by the historical habits of the era in which 16 characters are used as the standard.

--------- Excerpt from deep understanding of computer systems

5. Addressing Mode

At&t Intel
Imm32 (basepointer, indexpointer, indexscale) [Basepointer + indexpointer * indexscale + imm32)

The actual results of the two types of addressing should be

Imm32 + basepointer + indexpointer * indexscale

In at&t's Assembly format, jump commands are a bit special.

Directly jump, that is, the jump target is encoded as part of the instruction.

Example: JMP label_1

Indirect jump, that is, the jump target is read from the register or memory location. The statement is followed by an operand indicator after.

For example, JMP * % eax uses the value in register % eax as the jump target.

JMP * (% eax) uses the value in % eax as the read address and reads the jump target from the memory.

-------- From deep understanding of computer systems

 

The following are some examples of addressing:

At&t :' -4 (% EBP)'Equivalent to Intel :' [EBP-4]'
At&t :' Foo (, % eax, 4)'Equivalent to Intel :' [Foo + eax * 4]'
At&t :' Foo (, 1)'Equivalent to Intel' [Foo]'
At&t :' % GS: foo' Equivalent to Intel' GS: foo'
Example from http://sourceware.org/binutils/docs/as/i386_002dMemory.html#i386_002dMemory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.