作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
[已编辑]有人可以向我解释一下我们如何在这个问题中通过相应的汇编代码的每一行来获取 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/
我是一名优秀的程序员,十分优秀!