本文介绍了美元符号在gnu大会标签中的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
gnu组件标签前面的美元符号的含义是什么?
例如, mov msg有什么区别,%si
和 mov $ msg,%si
https://github.com/cirosantilli/x86-bare-metal-examples/blob/master/bios_hello_world.S ) #includecommon.h
BEGIN
mov $ msg,%si
mov $ 0x0e,%ah
循环:
lodsb
或%al,%al
jz暂停
int $ 0x10
jmp循环
暂停:
hlt
msg:
.asciz hello world
(讨论了寄存器之前%和常量之前$的一般用法;但是,我不认为它使用带有标签的$几乎与下面的答案一样清晰)。
在寻址常量时使用$(美元)符号,例如:
movl $ 1,%eax
(把 1
到%eax
寄存器)
或处理某个变量的地址时,例如: movl $ var,%eax
(这意味着将地址 var
标签并放入% eax
寄存器)。
如果您不要使用美元符号,这意味着从 var
标签并将其注册为。
What is the meaning of a dollar sign in front of a gnu assembly label?
For example, what is the difference between mov msg, %si
and mov $msg, %si
(For more context, I'm playing around with the x86 Bare Metal Examples: https://github.com/cirosantilli/x86-bare-metal-examples/blob/master/bios_hello_world.S)
#include "common.h"
BEGIN
mov $msg, %si
mov $0x0e, %ah
loop:
lodsb
or %al, %al
jz halt
int $0x10
jmp loop
halt:
hlt
msg:
.asciz "hello world"
(What do the dollar ($) and percentage (%) signs represent in assembly intel x86? discusses the general use of % before registers and $ before constants; but, I don't think it lays out the use of $ with labels nearly as clearly as the answer below )
解决方案
You use $(dollar) sign when addressing a constant, e.g.:movl $1, %eax
(put 1
to %eax
register)or when handling an address of some variable, e.g.: movl $var, %eax
(this means take an address of var
label and put it into %eax
register).If you don't use dollar sign that would mean "take the value from var
label and put it to register".
这篇关于美元符号在gnu大会标签中的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!