Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
810 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...