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
1 answer

how to update objdump? got: unknown command line argument -M

Working through Jon Erickson's book on Hacking. He uses an intel format assembly code. He provides the following snippet: reader@hacking:~/booksrc 08048374
: $ objdump -M intel -D a.out | grep -A20 main. I'm getting this…
cryptograthor
  • 455
  • 1
  • 7
  • 19
0
votes
1 answer

Visual studio C++ Assembly | Meaning of the brackets?

I am trying to compare the assembly for two pieces of code and they look like shown below. My question is if the additions in [esp+4] [esp+8] [esp+0Ch] are performed at run-time, or somehow resolved before that. Version 1 00FE104D mov …
Aedoro
  • 609
  • 1
  • 6
  • 21
0
votes
1 answer

Segmentation notation

I am trying to understand some of the programs that were written for MS DOS. Does the instruction mov ax, ds:4Ch move the value of ds*16 + 4Ch or does it move the value stored at the address ds*16 + 4Ch?
D Kar
  • 31
  • 4
0
votes
0 answers

How to change pixel color with PC BIOS calls?

I am trying to make a rather simple graphical game in 16-bit x86 assembly. Especially, I want to be able to change the color of a pixel. I already have an emulated bootloader(qemu) and a piece of code which makes it possible for the game to run on…
0
votes
1 answer

Few assembly syntax questions and interpretation of disassembler code

I'm trying to reverse engineer an executable file in part of some exercise/challenge. I opened the file in IDA64 disassembler. Most of the code is hidden but three subroutines are visible (including the Start). My main experience with assembly was…
Mithrandir
  • 46
  • 5
0
votes
2 answers

Run intel no prefix x86-64 assembly on MacOS

As part of a class, I need to write assembly code with specific format. The teacher refers to it as "Intel syntax x86-64". I tried to compile it with the given command (gcc -O3 -o op sc.s) and despite working great on a linux PC it fails on a Mac.…
Maxime A
  • 90
  • 1
  • 9
0
votes
0 answers

How to correctly replace printf with sys_write?

I'm making new post about the same program - I'm sorry but I think that my question is much different than the previous one. My program gets 2 parameters at the start - number of repeats and a string. Number of repeats determines how many times…
lemka8
  • 33
  • 6
0
votes
0 answers

How to print char from DL (or similar) in assembly? (intel syntax 32bit)

At the beginning, I'd like to point out that I'm totally newbie in assembly. I have to make a program that get from command line 2 arguments - int and string. Next, it has to print in console last word from string as many times as int number says.…
lemka8
  • 33
  • 6
0
votes
1 answer

Output from registers using inline assembly are zeroed out

I've been through a couple of threads already, and everything seems to be worded correctly...but my output_01 is returning false. It seems that the inline assembly is writing zeros to my variables...and I just can't figure out why. Below is code…
0
votes
1 answer

Counting recrusive function in IA86 assembly - unexpected values

I've wrote assembly program which should count the below recursive function : f(n) = f(n-1) + 2*f(n-2) - f(n-3) For n = 0 and n = 1 it returns 1, and for n = 2 it should return 0. But for this values program always returns 0, it looks like the…
0
votes
2 answers

Assembly: Define empty 2D array 32bit (NASM + Intel syntax)

How can we define empty 2D array 251x256 for 32 bit code in assembly? I have an old example in 16 bit code for assembly: DataIn byte 251 dup (256 dup (?)) Now I would like to declare the same thing but that will work for 32 bit…
C-PROG
  • 113
  • 3
  • 12
0
votes
1 answer

Assembly: Define a word in 32 bit (Intel + NASM)

I have a old assembly code in 16 bits and I want to "translate" it into a new 32 bit code for NASM. In the old 16 bit code the words are defined as: dseg segment para public 'data' i word ? j word ? Now I would like to define " i " & "…
C-PROG
  • 113
  • 3
  • 12
0
votes
0 answers

Parser: Instruction expected Error while compiling Intel assembly with NASM

Can anyone tell me why are these errors happening? I am quite new to the assembly and I have some problems compiling the file. I tried compiling it in NASM,with following code in Debian: nasm -f elf codeasm.asm -o codeasm.o and I get the following…
C-PROG
  • 113
  • 3
  • 12
0
votes
1 answer

Assembly loop through a string to count characters

i try to make an assembly code that count how many characters is in the string, but i get an error. Code, I use gcc and intel_syntax #include int main(){ char *s = "aqr b qabxx xryc pqr"; int x; asm volatile ( ".intel_syntax…
ronek22
  • 138
  • 1
  • 8
0
votes
0 answers

In 8086 assembly, why and when is offset required in mov command?

I want to know what is the difference between "mov ax, offset new" and "mov ax, new" What offset actually does, which value it adds up?
user6784306
  • 57
  • 1
  • 1
  • 5
1 2 3
8
9