What's difference between number with $ or without $ symbol in at&t assembly syntax?

前端 未结 1 1584
独厮守ぢ
独厮守ぢ 2020-12-21 09:47

Let\'s say .data section has following item:

0x1234 00010203 04050607 08090a0b 0c0d0e0f
0x1238 10000000

And in code,

mov $0         


        
相关标签:
1条回答
  • 2020-12-21 10:27

    The difference is that with $ it's the numeric value while without $ it's the 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/

    0 讨论(0)
提交回复
热议问题