“%register"与“%register"之间的区别和“(%注册)"在 x86 汇编 AT&T 语法中? [英] Difference between "%register" and "(%register)" in x86 assembly AT&T syntax?
问题描述
到目前为止,我目前的理解是:movq %rdi, %rax
会将值从寄存器 %rdi
移动到寄存器 %rax
So far my current understanding is something along the lines of:
movq %rdi, %rax
will move the value from the register %rdi
to the register %rax
和 movq (%rdi), %rax
会将值从内存中的 (%rdi)
移动到寄存器 %rax
and movq (%rdi), %rax
will move the value from memory at (%rdi)
to the register %rax
但是,我无法理解这在功能上的实际含义.在什么情况下,这两条装配线会以不同的结果结束?
However, I'm having trouble understanding what this actually means functionally. In what instance will these two assembly lines end with a different result?
推荐答案
每次地址 (%rdi) 处的内存不包含自己的地址时,都会产生不同的结果.换句话说,几乎总是.如果不是,这只是巧合或非常不寻常的代码的结果.
It will yield a different result every time the memory at adress (%rdi) does not contain its own adress. In other words, almost always. And when not, it's just a coincidence or a consequence of very unusual code.
一些 C 来演示等效问题两个 printf 语句何时会打印相同的结果?"
Some C to demonstrate the equivalent question "When will the two printf statements print the same result?"
#include <stdio.h>
int main()
{
int a,*p;
int b=5;
p=&b;
a=*p;
printf("%d\n", a);
a=(int)p;
printf("%d\n", a);
}
而且,是的,这会产生警告 cast from pointer to integer of different size
但这不是重点.
And, yes, this yields the warning cast from pointer to integer of different size
but that's beside the point.
这篇关于“%register"与“%register"之间的区别和“(%注册)"在 x86 汇编 AT&T 语法中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!