c语言程序的汇编语言怎么理解,怎么感觉好复杂啊。
下面的C程序,经过汇编后,打开就变成了下面的汇编程序。。。感觉都看不懂,请各位高手指点,怎么去理解...像c语言程序那样。。。
#include<stdio.h>
int array[20];
int func_type_1()
{
int i;
for(i=20;i--;)
{
array[i]=i;
printf("%d\t",i,array[i]);
}
return 0;
}
int main(int argc,char *argv[])
{
int i;
func_type_1();
return 0;
}
.file "int_32bits_revesal.c"
.comm array,80,32
.section .rodata
.LC0:
.string "%d\t"
.text
.globl func_type_1
.type func_type_1, @function
func_type_1:
pushl %ebp
movl %esp, %ebp
subl $40, %esp
movl $20, -12(%ebp)
jmp .L2
.L3:
movl -12(%ebp), %eax
movl -12(%ebp), %edx
movl %edx, array(,%eax,4)
movl -12(%ebp), %eax
movl array(,%eax,4), %edx
movl $.LC0, %eax
movl %edx, 8(%esp)
movl -12(%ebp), %edx
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
.L2:
cmpl $0, -12(%ebp)
setne %al
subl $1, -12(%ebp)
testb %al, %al
jne .L3
movl $0, %eax
leave
ret
.size func_type_1, .-func_type_1
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
call func_type_1
movl $0, %eax
movl %ebp, %esp
popl %ebp
ret
.size main, .-main
.ident "GCC: (GNU) 4.5.1 20100924 (Red Hat 4.5.1-4)"
.section .note.GNU-stack,"",@progbits
50,2-9 底端
1,2-9 顶端
[解决办法]
计算机组成原理→DOS命令→汇编语言→C语言(不包括C++)、代码书写规范→数据结构、编译原理、操作系统→计算机网络、数据库原理、正则表达式→其它语言(包括C++)、架构……
[解决办法]
main: pushl %ebp //将寄存器ebp的值入栈保存其值,因为待会要改变其值。 movl %esp, %ebp//将栈指针esp的赋值给基指针ebp andl $-16, %esp //分配堆区存放局部变量 call func_type_1 //调用函数func_type_1 ===>func_type_1(); movl $0, %eax //将返回值存放于寄存器eax====》return 0; movl %ebp, %esp //将ebp的值赋给esp popl %ebp //恢复ebp原来的值 ret //将执行权返回给系统
[解决办法]
LZ 可以从简单的程序 开始 看下
这个 应该可以理解