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

查看:267
本文介绍了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?

两条指令之间到底有什么不同?

What exactly different between two instruction?

推荐答案

区别在于,使用$数字值,而没有$则是地址

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

对应于intel语法:

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

以Intel语法:

mov eax, 10
mov eax, offset foo

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

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

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