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
0
votes
0 answers

Strange error compiling with NASM compiler

I'm officially stumped... I'm getting the strangest error compiling this .ASM file... For some reason, the line mov bx, word [w1] causes the compiler to say the following: error: invalid effective address. However, the line before it, mov ax, word…
Joseph Caruso
  • 175
  • 1
  • 11
0
votes
0 answers

Wrong argc when using AT&T syntax

I was reading this assembly tutorial and I got the example to work, so I decided to try to improve it. Once I did so, it stopped working, so I tried to convert it to AT&T syntax so I could compile it with gcc and get debug information (because I'm…
Addison
  • 3,791
  • 3
  • 28
  • 48
0
votes
1 answer

String copy in Assembly

I've got a problems with copying string to empty array in Assembly. Firstly, I get some junks instead string which i would like to copy. Secondly, the program should work with string up to 100 chars but when I declare an array with 100 chars, I got…
0
votes
2 answers

Conditional jump fails in linux x86 intel syntax(NASM)

STORY(IM A NEWBIE): I started reading a pdf tutorial about programming in assembly(x86 intel) using the famous nasm assembler and i have a problem executing a very basic assembly code(inspired by a code about loops from the tutorial). THE PROBLEM(JE…
user3403823
0
votes
1 answer

inline intel syntax to inline gcc

I'm trying to convert a snippet of mine to a compiler that uses an inline asm syntax similar to gcc's. I read the documentation and all was fine until I encountered this line: mov eax, dword ptr fs:[0x20] I converted that to: movl 0x20(%fs:),…
user513647
  • 105
  • 1
  • 14
-1
votes
1 answer

GCC inline assembly cannot load local variable's address into register in x64 Intel format?

I am quite used to Intel-format inline assembly. Does anyone knows how to convert the two AT&T lines into Intel format in the code below? It is basically loading local variable's address into a register. int main(int argc, const char *argv[]){ …
xuancong84
  • 1,412
  • 16
  • 17
-1
votes
1 answer

Assembly translation

I am trying to translate the following C code to assembly: void write (int bitpos, unsigned short sample) { int pos = bitpos / 16; int posA = bitpos - pos * 16; unsigned short write1 = sample >> posA; } I keep getting an error in the…
Tiasn
  • 185
  • 2
  • 2
  • 8
-2
votes
1 answer

converting from intel assembly to gas/at&t

so can someone just do this tranlation for me? from intel assembly to at&t assembly? I'm learning gas syntax but having a little difficulty understanding some petty things... mov ecx, dword ptr[esp + 0xC + 0xC]
-3
votes
1 answer

Meaning of "EC" in x86 disassembly

I am trying to disassemble Hex "8B EC". The disassembler gives me mov ebp, esp "8B" - MOV Instruction; "EC" - ???; How disassembler know that "EC" is ebp, esp?
user3719859
  • 25
  • 1
  • 1
  • 5
-4
votes
1 answer

Assembly language and printing result. Fibbonacci sequence

I use Assembly on x86 Linux, with instructions for Intel 8086. I have a problem with my program, which should count the element of Fibbonacci sequence. This program I run with args, for e.g.: ./fibb 1 2 3 , what means: 1st element of sequence is 1,…
-4
votes
1 answer

Procedures from C in assembly

I have to write a short program in Assembly but my version not works. It should print ASCII char, next change it to the integer value by atoi function and print out this value. Important is using for that, procedures from C: puts() and atoi().…
1 2 3
8
9