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

too many references for 'mov' when using two 64-bit registers?

I'm trying to compile one very simple program, but I get 2 errors that I can not fix: 1.s:13:Error: too many memory references for 'mov' 1.s:15:Error: too many memory references for 'lea' Here is my code, I hope someone sees my…
Marijam
  • 5
  • 2
0
votes
0 answers

how can I store 20 digit number to 64-bit Register in Assembly

.intel_syntax noprefix number1: .quad 8403406020084561865 , 3325915310126341549 , 1038926090642473899 , 12330590014810845464 mov r12,[number1+0] mov r13,[number1+8] mov rcx,[number1+16] **mov rsi,[number1+24]** I can store…
ataberkty
  • 1
  • 1
0
votes
0 answers

What is the difference between mov dword ptr [eax], 5 and mov dword [eax], 5?

What is the difference between the operations: mov dword ptr [eax], 5 and mov dword [eax], 5 Furthermore, do mov dword ptr [eax], 5 and mov [eax], dword ptr 5 do the same thing?
Ark
  • 73
  • 2
  • 8
0
votes
0 answers

Understanding compiler's mov [mem], reg instructions for C using CPUID instruction

I've been studying assembly in school, and I'm trying to apply it to a real situation. I have a product that is no longer supported and I want to see how a portion of the code that uses the CPUID to perform several checks is working. I've only…
richbai90
  • 4,994
  • 4
  • 50
  • 85
0
votes
1 answer

How can I run C-code with assembly inserts

I have C-program with assembly insert. Here is code: main.c: #include int f() { int a = 0, b; __asm__ (".intel_syntax noprefix\n\t" "mov edx, 1\n\t" :"=r"(b) :"r"(a) :"eax" …
0
votes
1 answer

What is EXTRN in Intel-syntax assembly?

x86 CPU: MSVC (2010) What does EXTRN _printf:PROC means in code bellow and why after ":" we use some "PROC" directive instead of "near" or "far"? CONST SEGMENT $SG3830 DB 'hello, world', 0AH, 00H CONST ENDS PUBLIC _main EXTRN …
Deno
  • 57
  • 5
0
votes
1 answer

Differences between Assembly Languages

I'm very new to Assembly Language and I know there are many, many types of assembly languages. Such as ARM, MIPS, x86 etc. So I have questions. Below is more Information Hello World in ARM .text .global _start _start: mov r0, #1 …
0
votes
0 answers

Cannot get correct immediate mode from GNU assembler for symbols with intel_syntax

I am trying to write a simple assembly program with GNU assembler (as) in MAC OS. Part of the program looks like the following: .intel_syntax noprefix .globl _main .text ... mov rdx, len syscall ... .data message: .asciz "this is a…
0
votes
1 answer

OS resets on far jump after disabling paging

I'm working on modifying a routine that switches to and from realmode to perform a BIOS interrupt, but running into issues with paging. I had it working prior with no paging, but now that my OS uses paging, I need to disable it before entering…
23scurtu
  • 138
  • 10
0
votes
1 answer

Different behavior calling JMP with register vs value

I'm trying to perform an absolute jump to the address 0x7C00 as part of a procedure in a hobby OS. I'm using intel syntax in GAS and testing in QEMU. I tried two methods: jmp 0x00007c00 and mov eax, 0x00007C00 jmp eax The second method seems to…
23scurtu
  • 138
  • 10
0
votes
1 answer

invalid instruction suffix for mov?

I have this piece of inline assembly code that should print A in text mode: void print(){ asm volatile( "mov ax,0xb800\n" "mov ds,ax\n" /*<-as complains about this*/ "movb 0,'A'\n" ); } However…
0
votes
0 answers

Conversion of far jmp from NASM/Intel to GAS/AT&T

I just have a simple line of NASM/Intel syntax assembly that I need in GAS/AT&T syntax. The line is JMP 0x08:reload_CS I couldn't find anything online, but I have tried: jmp $0x08, reload_CS jmp reload_CS + $0x08 Is one of these correct? If not…
drewpel
  • 465
  • 1
  • 3
  • 16
0
votes
2 answers

Converting [symbol + constant] Intel syntax addressing mode to AT&T syntax?

I just cant figure out how to add an offset to my destination when moving a value, specifically in Intel syntax I have: MOV [gdtr + 2], EAX and for AT&T syntax I have tried converting it to: movl %eax, gdtr(2,1) which gives an error when…
drewpel
  • 465
  • 1
  • 3
  • 16
0
votes
1 answer

How to pass arguments to inline GCC/Clang asembly with Intel syntax?

All documentation uses AT&T syntax. int EAX; asm( "movl $5, %0" : "=a" (EAX) ); How do I re-write this using Intel syntax? int EAX; asm( ".intel_syntax noprefix;" "mov %0, 5" :"=a"(EAX) ); Doesn't work: error: unknown token in expression …
Alexander
  • 9
  • 3
0
votes
1 answer

Errors A2022 and MSB3721 show up when I try to run my C++/MASM program

I run this code, which is called from a C++ program that just accepts input for the integers num1 and num2 and passes them to sum.asm. I get the errors: A2022: instruction operands must be the same size in sum.asm line 5 MSB3721: The command…
Cindy
  • 66
  • 4
1 2 3
8 9