这个汇编语句是什么意思? [英] What does this assembly statement mean?

查看:33
本文介绍了这个汇编语句是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看 gcc 使用 -s 标志生成的汇编代码.一些语句如下所示.

I am looking at the assembly code generated by gcc by using the -s flag. Some statements look like the following.

movl    is_leader(%rip), destination

这里,is_leader 是 C 代码中int 类型的全局定义变量.我不明白的是这里的 is_leader(%rip) 一词.rip 不是指令指针吗?我需要知道如何使用此语句来访问 is_leader.

Here, is_leader is a globally defined variable of type int in the C code. What I don't understand is the term is_leader(%rip) here. Isn't rip the instruction pointer? I need to know how is this statement used to access is_leader.

推荐答案

它要求汇编器生成代码,将当前指令的地址与指令指针的对象地址之间的差值加减.

It asks the assembler to generate code that adds or subtracts the difference between the address of the current instruction and the address of the object to the instruction pointer.

>

这在不生成绝对地址的情况下给出了对象的地址(通常,偏移量适合 16 或 32 位,因此生成的代码也更短,因此速度更快).

This gives the address of the object without generating an absolute address (and generally, the offset fits into 16 or 32 bits, so the resulting code is also shorter and thus faster).

这增加了两个item之间的距离保持不变的约束,所以这只能用于同一个可加载对象中的数据;如果不满足该条件,链接器将标记错误.

This adds the constraint that the distance between both items remains constant, so this can be used only for data in the same loadable object; the linker will flag an error if that condition is not met.

这篇关于这个汇编语句是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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