Why is mov eax, val not the syntax equivalent of Intel mov $ val,% eax?

I am trying to understand the differences between Intel syntax and AT & T syntax (I use GNU as).

I have two files, intel.s:

.intel_syntax noprefix

val:
    mov eax, val

and atandt.s:

val:
    mov $val, %eax

I am trying to convert the AT & T version to the Intel version. But I have different results:

$ objdump -d intel.o

intel.o:     file format elf32-i386


Disassembly of section .text:

00000000 <val>:
   0:   a1 00 00 00 00          mov    0x0,%eax

and

$ objdump -d atandt.o

atandt.o:     file format elf32-i386


Disassembly of section .text:

00000000 <val>:
   0:   b8 00 00 00 00          mov    $0x0,%eax

Why are they different?

+4
source share
1 answer

Intel instruction loads the contents of val. To download its address, use

    mov eax, offset val
+5
source

Source: https://habr.com/ru/post/1685357/


All Articles