movl (%edi),%eax对应什么源代码
时间: 2024-05-04 15:13:22 浏览: 17
movl (%edi), %eax是一条x86汇编指令,它的作用是将%edi寄存器中的地址所指向的内存数据加载到%eax寄存器中。根据这条指令,可以推测对应的源代码可能是在C语言中访问一个指针所指向的内存位置并将其值赋给一个变量。
相关问题:
1. 什么是x86汇编?
2. 如何在C语言中使用指针?
3. 请解释一下寄存器和内存的区别。
相关问题
movl %esi, %eax
movl %esi, %eax是一条汇编指令,它的作用是将寄存器%esi中的值移动到寄存器%eax中。在汇编语言中,movl表示将数据从一个地方移动到另一个地方,%esi和%eax是两个寄存器名,它们都是CPU内部的一些特殊寄存器,用于存储数据和指令。这条指令的含义是将%esi中的数据复制到%eax中,可以用来实现数据的读取、写入和传递等操作。
#include <stdio.h> #define X (?) #define Y 23 int array1[X][Y]; int array2[X]; int test() { int sum= (?) ; int i=0; do { if( (?) ) continue; sum+= (?) ; }while(i<X && i<Y); return (?) ; } int main() { return 0; } 汇编代码如下: test: pushl %ebp movl %esp, %ebp subl $16, %esp movl $14, -8(%ebp) movl $0, -4(%ebp) .L5: movl -4(%ebp), %eax movl array2(,%eax,4), %ecx movl -4(%ebp), %edx movl %edx, %eax addl %eax, %eax addl %edx, %eax sall $5, %eax addl $array1, %eax movl (%eax), %eax imull %ecx, %eax cmpl $6, %eax jle .L2 movl -4(%ebp), %eax movl array2(,%eax,4), %ecx movl -4(%ebp), %edx movl %edx, %eax addl %eax, %eax addl %edx, %eax sall $5, %eax addl $array1, %eax movl (%eax), %eax movl %ecx, %edx subl %eax, %edx movl %edx, %eax cmpl $7, %eax jle .L6 .L2: movl -4(%ebp), %edx movl %edx, %eax addl %eax, %eax addl %edx, %eax sall $5, %eax addl $array1, %eax movl (%eax), %edx movl -4(%ebp), %eax movl array2(,%eax,4), %eax addl %edx, %eax addl -4(%ebp), %eax addl %eax, -8(%ebp) addl $1, -4(%ebp) jmp .L3 .L6: nop .L3: cmpl $18, -4(%ebp) jg .L4 cmpl $22, -4(%ebp) jle .L5 .L4: movl -8(%ebp), %eax subl $5, %eax imull -8(%ebp), %eax leave ret填空?的位置
#include <stdio.h>
#define X 16
#define Y 23
int array1[X][Y];
int array2[X];
int test() {
int sum= 0;
int i=0;
do {
if(array2[i] == 0) continue;
sum+= array1[i][array2[i]];
}while(i<X && i<Y);
return sum;
}
int main() {
return 0;
}
汇编代码如下:
test:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $0, -4(%ebp)
.L5:
cmpl $16, -4(%ebp)
jge .L4
movl -4(%ebp), %eax
movl array2(,%eax,4), %edx
testl %edx, %edx
je .L3
movl -4(%ebp), %eax
movl %eax, %ecx
sall $5, %ecx
addl $array1, %ecx
movl array2(,%eax,4), %eax
movl (%ecx,%eax,4), %eax
addl %eax, %edx
movl %edx, %eax
addl $1, -4(%ebp)
jmp .L5
.L3:
addl $1, -4(%ebp)
jmp .L5
.L4:
movl %edx, %eax
leave
ret
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)