gpt4 book ai didi

c - 反汇编 C 函数的 IA32 32 位 AT&T 汇编代码

转载 作者:行者123 更新时间:2023-11-30 19:07:28 27 4
gpt4 key购买 nike

[已编辑]有人可以向我解释一下我们如何在这个问题中通过相应的汇编代码的每一行来获取 M 和 N 的值吗?

我总是被 movl array2 部分难住了。

M和N是使用#define定义的常量

#define M <some value>
#define N <some value>

int array1[M][N];
int array2[N][M];
int copy(int i, int j)
{
array1[i][j] = array2[j][i];
}

如果上面的代码生成如下汇编代码:我们如何推导常量M和N的值?

  copy:
pushl %ebp
movl %esp, %ebp
pushl %ebx
movl 8(%ebp), %ecx
movl 12(%ebp), %ebx
leal (%ecx, %ecx, 8), %edx
sall $2, %edx
movl %ebx, %eax
sall $4, %eax
subl %ebx, %eax
sall $2, %eax
movl array2(%eax, %ecx, 4), %eax
movl %eax, array1(%edx, %ebx, 4)
popl %ebx
movl %ebp,%esp
popl %ebp
ret

最佳答案

您需要检查装配体的其他部分。例如,如果您将 M 和 N 都定义为 8,您将在程序集中找到以下内容

array1:
.zero 256
array2:
.zero 256

因为在我的机器上,int是4个字节,8乘8就是64。64 * 4 = 256。示例程序集可以在 here 找到。 .

关于c - 反汇编 C 函数的 IA32 32 位 AT&T 汇编代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46778072/

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