Questions tagged [intel-syntax]

Intel syntax (as opposed to AT&T syntax) is an x86 assembly syntax using "opcode dst, src", square brackets for memory operands, and keywords to set the size of an operand: e.g. add dword [eax], 123. There are two main flavours of Intel syntax: NASM-style and MASM/TASM-style.

Intel Syntax is used in Intel's (and AMD's) manuals, and by many assemblers. See the tag wiki for links to those and to assembler manuals.

The other major syntax for x86 assembly is AT&T (). Other syntaxes include HLA, and the Go assembler's x86 syntax (which looks like 16-bit, using AX to actually mean AL/AX/EAX/RAX depending on the operand-size).

All flavours of Intel Syntax share these characteristics:

  • Parameter order: destination <- source. pinsrd xmm0, eax, 2
  • Square brackets indicate a memory operand: add eax, [esi] (but beware the differences between NASM and MASM for symbols, offset vs. just omitting the []).
  • Operand size: implied by a register name, or specified explicitly with dword (NASM) or dword ptr (MASM) in instructions with no register operand.
    add qword [fs:rdi + r10], 123. (Put the size operator on the memory operand.)
  • Immediate values and other numeric constants: No $ prefix. For hex, use a trailing h, and make sure the number starts with a 0. e.g. 0deadbeefH. Some Intel-syntax assemblers (e.g. NASM) also support C-style 0xdeadbeef constants, but all support trailing-h. Binary constants can use a b suffix.

The two major flavours of Intel syntax are NASM-style and MASM/TASM style.
How to know if an assembly code has particular syntax (emu8086, NASM, TASM, ...)?
and x86, difference between BYTE and BYTE PTR

The GNU assembler, as/gas (and compatible ones like clang's built-in assembler) supports a .intel_syntax noprefix directive to switch to a mode with MASM-like syntax. There isn't official documentation for GAS's intel-syntax. See also Distinguishing memory from constant in GNU as .intel_syntax. If you're not sure, encode the machine-code you want somehow (e.g. using another assembler) and disassemble in Intel syntax with objdump -drwC -Mintel.


131 questions
6
votes
1 answer

error in backend: 32-bit absolute addressing is not supported in 64-bit mode

I'm working on ASM intel_syntax noprefix on a mac using gcc, and for some reason I keep getting this error in backend: 32-bit absolute addressing is not supported in 64-bit mode Does this have something to do with the variables, since, at the…
Miguel Guerra
  • 145
  • 1
  • 8
5
votes
2 answers

Disambiguate labels from register names in the Intel syntax

I'm wondering how to distinguish label names from register names in some instructions in the Intel syntax. For example, call rdx usually means an indirect jump, but what if we have a label rdx in the same assembly file? I believe it could be…
Rui Ueyama
  • 321
  • 2
  • 4
5
votes
1 answer

ASM: too many memory references for `mov'

It's me again, I have a new problem in my idt.S file (Intel syntax compiled with gcc). When I try to compile the following code: load_idt: mov edx, (esp + 4) ; On this line lidt (edx) sti ret I get an error that I…
Slendi
  • 157
  • 1
  • 13
5
votes
1 answer

x86-64 assembly order of operands

What is the order of operands in x86-64 assembly?: instruction destination, source Or: instruction source, destination I have three books and two different approaches!
Josiah
  • 53
  • 7
5
votes
1 answer

How do GNU assembler x86 instruction suffixes like ".s" in "mov.s" work?

GNU assembler appears to have some means of controlling the alternative forms of the opcode being emitted for some instructions. E.g. .intel_syntax noprefix mov eax, ecx mov.s eax, ecx Processing the above code with as test.s -o test.o && objdump…
Ruslan
  • 18,162
  • 8
  • 67
  • 136
5
votes
1 answer

X86 intel syntax - ambigious size for mov, junk h after expression?

I was working with AT&T syntax but thought i'd try out intel. I have this code: .text .global _start _start: mov ebx, 0 mov eax, 1 int 80h Which should return 0, right? It did with AT&T before i converted…
user7637341
  • 421
  • 1
  • 6
  • 15
5
votes
2 answers

How to know if an assembly code has particular syntax (emu8086, NASM, TASM, ...)?

I want to know how,by looking through a sample source code, recognise if the syntax used is em8086, TASM or NASM? I am a new to assembly..I would like to know more about emu8086 please.
user6473027
5
votes
2 answers

How to set gcc or clang to use Intel syntax permanently for inline asm() statements?

I have the following code which compiles fine with the gcc command gcc ./example.c. The program itself calls the function "add_two" which simply adds two integers. To use the intel syntax within the extended assembly instructions I need to switch at…
Dennis
  • 965
  • 1
  • 9
  • 17
4
votes
0 answers

Obtaining the address of the current section in GNU Assembly without $$

The NASM Documentation describes the special tokens $ and $$: NASM supports two special tokens in expressions, allowing calculations to involve the current assembly position: the $ and $$ tokens. $ evaluates to the assembly position at the…
user2023370
  • 10,488
  • 6
  • 50
  • 83
4
votes
1 answer

x86-64 Intel Syntax for rel8 immediate operand?

The first form of JMP in x86-64 is: Opcode Instruction Description EB cb JMP rel8 Jump short, RIP = RIP + 8-bit displacement sign So for example JMP rel8=-2 is eb fe. fe is a one byte signed 2s-compliment -2. How do I express this rel8…
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319
4
votes
1 answer

Assembly programming - "variables" defined using (what looks like) labels, or variable names?

I have seen "variables" in assembly "defined" using two syntaxes, the first looks like a label, and the second looks like a variable name. Can the two be used interchangeably, or is there a specific reason for each ones use? For example: msg db…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
3
votes
2 answers

How Do I Convert This ATT assembly to Intel Syntax? Jump to a non-relative address without using registers

I was reading this article " assembly-challenge-jump-to-a-non-relative-address-without-using-registers ". I need to do exactly what he suggests here (Jump to a non-relative address without using registers), only I need to do it in intel syntax…
ChrisMan
  • 119
  • 1
  • 2
  • 10
3
votes
1 answer

Offset before square bracket in x86 intel asm on GCC

From all the docs I've found, there is no mention of syntax like offset[var+offset2] in Intel x86 syntax but GCC with the following flags gcc -S hello.c -o - -masm=intel for this program #include int main(){ char c = 'h'; …
Hritik
  • 673
  • 1
  • 6
  • 24
3
votes
2 answers

Getting Intel-syntax asm output from icc, instead of the default AT&T syntax?

I am stuck at a problem. I've been using gcc to compile/assemble my C code for a while and got used to reading Intel assembly syntax. I used the -masm=intel flag when generating the assembly files. Yet recently, due to company migrations, they…
Syntax_Error
  • 5,964
  • 15
  • 53
  • 73
3
votes
1 answer

Referencing memory operands in .intel_syntax GNU C inline assembly

I'm catching a link error when compiling and linking a source file with inline assembly. Here are the test files: via:$ cat test.cxx extern int libtest(); int main(int argc, char* argv[]) { return libtest(); } $ cat lib.cxx #include…
jww
  • 97,681
  • 90
  • 411
  • 885
1
2
3
8 9