4

Let's say .data section has following item:

0x1234 00010203 04050607 08090a0b 0c0d0e0f
0x1238 10000000

And in code,

mov $0x1234, %eax
mov 0x1238, %ebx

I believe with $ symbol, it would be constant number, so %eax will have memory address, but what about %ebx?

What exactly different between two instruction?

1 Answer 1

10

The difference is that with $ it's the numeric value while without $ it's the contents of memory at that address

If argument of instruction is without any special marker (such as % for register or $ for numeric constant), then it is memory access. So following:

movl 10, %eax
movl foo, %eax

Corresponds to intel syntax:

mov eax, [10]
mov eax, [foo]

To use numeric constant, or use address of label, there is $ operator:

movl $10, %eax
movl $foo, %eax

In Intel syntax:

mov eax, 10
mov eax, offset foo

http://x86asm.net/articles/what-i-dislike-about-gas/

2
  • So are you saying mov $0x1238, %ebx is just numeric constant and not memory access even though 0x1238 address is present in memory ?
    – REALFREE
    Sep 26, 2013 at 20:04
  • Memory access here is data, not instruction
    – phuclv
    Sep 26, 2013 at 23:59

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.