at&t 汇编语法中带 $ 或不带 $ 符号的数字有什么区别? [英] What's difference between number with $ or without $ symbol in at&t assembly syntax?

查看:29
本文介绍了at&t 汇编语法中带 $ 或不带 $ 符号的数字有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设 .data 部分有以下项目:

Let's say .data section has following item:

0x1234 00010203 04050607 08090a0b 0c0d0e0f
0x1238 10000000

在代码中,

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

我相信用 $ 符号,它会是常数,所以 %eax 会有内存地址,但是 %ebx 呢?

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

两条指令有什么不同?

推荐答案

区别在于有$的是数值,没有$> 这是那个地址的内存内容

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

对应intel语法:

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

要使用数字常量,或使用标签地址,有$操作符:

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

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

在英特尔语法中:

mov eax, 10
mov eax, offset foo

http://x86asm.net/articles/what-i-不喜欢天然气/

这篇关于at&t 汇编语法中带 $ 或不带 $ 符号的数字有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆