标签:
square函数主要计算一个数的平方
code:
.section .data .section .text .global _start fmt: .ascii "%d\n\0" _start: pushq $2 call square addq $8, %rsp #复位%rsp movl %eax, %esi movq $fmt, %rdi xorl %eax, %eax call printf #调用printf movl $0, %edi call exit #调用exit .type square, @function square: pushq %rbp movq %rsp, %rbp movl 16(%rbp), %eax imull %eax, %eax movq %rbp, %rsp popq %rbp ret
编译命令:
gcc -c square.s -g && ld ./square.o -lc -dynamic-linker /lib64/ld-linux-x86-64.so.2 && ./a.out
TODO
解释movl 16(%rbp), %eax指令的意思。
标签:
原文地址:http://my.oschina.net/guonaihong/blog/490007