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
1
vote
0 answers

Can MSVC display an Intel disassembly instead of AT&T syntax during a Linux-GCC-Debug session?

Currently the disassembly shows AT&T syntax below, but I'm accustomed to reading the Intel syntax. Is there an option or setting to switch between them? Thanks.
vengy
  • 1,548
  • 10
  • 18
1
vote
1 answer

GCC inline assembly intel syntax "Error: invalid use of register"

I decided to try using inline assembly in c for my basic operating system (using intel syntax because I am used to that with NASM). And I came across something I could not fix, I tried looking everywhere but nothing has worked. while trying the code…
1
vote
1 answer

Does V8 engine know how to print generated machine code using Intel syntax?

I'm using D8 shell and the flag --print-opt-code to print the code TurboFan generates. However, the code is printed using AT&T syntax. I'm not familiar with it, but with Intel syntax. I searched in d8 --help and didn't find an option for this. Does…
Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77
1
vote
1 answer

Is there a way to specify syntax for x command output?

I want to know whether I can change the syntax of the output of the following command: x/5i $rip Now it gives output like that. I guess it is AT&T syntax, correct my if I'm wrong (newbie): -> 0x100000f96: bf 01 00 00 00 movl $0x1, %edi …
vagifm
  • 397
  • 2
  • 10
1
vote
1 answer

Can I substitute a MOV operation with an OR operation?

First of all, I'd like to say that I'm new to ASM and if this is a stupid question please excuse it. I read in Agner Fog's microarchitecture manual about partial register stalls (this seems a little bit advanced, but I was curious why 32-bit…
Alex Gh
  • 55
  • 5
1
vote
0 answers

What is the "purpose" of commas in intel syntax?

I've been writing a programming game -- and with that comes writing a programming language. Initially I wanted the programming language to be a gross simplification of assembly language (like the game EXAPUNKS if anybody knows what that is). But as…
Thor Correia
  • 1,159
  • 1
  • 12
  • 20
1
vote
1 answer

What is the difference between using "offset" and "[ ]" on memory labels and registers in GAS .intel-syntax assembly?

Using GCC, compiling for 32-bit Intel architecture, with .intel_syntax noprefix. Let's suppose I have the following .data section: A: .int 0x1, 0x2 What is the difference between the following, when used as an operand: A, [A], offset A? Also, what…
1
vote
0 answers

gcc: asm syntax 'mov eax, OFFSET FLAT: .LC0'?

So I saw some code .LC0: .string "Hello world" main: sub rsp, 8 mov edi, OFFSET FLAT:.LC0 call puts xor eax, eax add rsp, 8 ret From what I've gathered, OFFSET FLAT is used…
Lewis Kelsey
  • 4,129
  • 1
  • 32
  • 42
1
vote
0 answers

Using scanf_s in dev-C++ gives error: 'scanf_s' was not declared in this scope

[Error] 'scanf_s' was not declared in this scope I'm new here and i don't know much about programming We use this type of programming at University. we add this before main body /*#include ,#pragma warning(disable:4996) #include int…
1
vote
1 answer

Mov and add are doing nothing for some reason

I got this code from my university professor, so I'm fairly certain that the code works, but for me the output is always 0. I tried it on Windows and on a virtual Ubuntu machine but still the same. I'm compiling using mingw: gcc test.c test.s This…
1
vote
2 answers

GOTPCREL(%rip) in GAS Intel syntax

How can i write following: movq variable@GOTPCREL(%rip), %r8 in GAS Intel syntax? .intel_syntax noprefix allows only this: mov r8, variable@GOTPCREL, it does not understand (), and resulting code is different - i receive segmentation fault. How can…
Mikola Akbal
  • 141
  • 2
  • 5
1
vote
0 answers

getting segmentation fault in assembly

Program received signal SIGSEGV, Segmentation fault. I am using this assembly program: and for some reason I'm getting a segmentation fault, is it related to the stack? What does this program even supposed to output? somebody told me to run it and…
1
vote
2 answers

AT&T syntax hello world works but intel syntax does not

I am writing a hello world program for linux x86_64 using GAS assembler and here is my code in AT&T syntax. #.intel_syntax noprefix .section .data msg: .ascii "hello world\n" .section .text .globl _start _start: movq $1, %rax …
wingerse
  • 3,670
  • 1
  • 29
  • 61
1
vote
0 answers

Labels with not-inline assembly

I just wanted to write some ASM code and include it in a C/C++ code, not through inline-mode, but creating a different ASM module. I've found out that a CodeBlocks project allows ASM sources, so I've followed these steps, actually with some slight…
Marco Luzzara
  • 5,540
  • 3
  • 16
  • 42
1
vote
0 answers

GNU ASM (intel syntax) getting address of label without LDA

I have a weird situation and I'm not sure if it's a bug of GNU assembler or I am doing something wrong. I will eventually switch to nasm I think, but I am using some macros that are written for the GNU assembler. For example, I have a label with…
1 2 3
8 9