gpt4 book ai didi

c - 我如何知道读取程序集的循环中包含什么

转载 作者:太空宇宙 更新时间:2023-11-04 08:14:52 26 4
gpt4 key购买 nike

所以我们目前正在努力将汇编恢复为 C....

我们得到的只是函数是

long part2(long x, long y);

通过反汇编我们得到的目标文件:

0:  48 8d 04 7f             lea    (%rdi,%rdi,2),%rax
4: 48 c1 e0 04 shl $0x4,%rax
8: 48 8d 56 1f lea 0x1f(%rsi),%rdx
c: 48 85 f6 test %rsi,%rsi
f: 48 0f 49 d6 cmovns %rsi,%rdx
13: 48 c1 fa 05 sar $0x5,%rdx
17: 48 21 d0 and %rdx,%rax
1a: c3 retq

到目前为止,我有一些看起来像这样的东西:

long someVar = 3x;
someVar = someVar << 4;
long anotherVar = y + 31;
//here is where I start to loose it....
if (y&y) {
anotherVar>>5;
...

我如何知道何时关闭 if 语句?

最佳答案

在汇编程序中,if 通常被编译为测试和条件跳转。有时还有额外的无条件跳转以跳过 else 部分。你知道 if 什么时候结束看跳转的地方。但请注意,优化可能会扰乱代码并使其难以理解。

例如:

if (x)
{ /* if_code * }
next_instruction;

变成:

text x,x
jz Label
/* if_code */
Label:
next_instruction

但是,在您的特定示例中,没有跳转。而是使用 CMOVNS 指令。那是有条件的举动。也就是说,如果 NS 条件成立,即 S 标志未设置,则 %rsi 的值将移入 %rdx。这是条件中唯一的指令!

但注意条件标志是S(符号),而不是Z(零)。因此,如果 %rsi >= 0,则移动完成。

关于c - 我如何知道读取程序集的循环中包含什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36378047/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com