汇编语言程序设计学习笔记(二)(Linux 版)

汇编:

gcc  -O1 main.c -c -o main.o

$cat main.o

.file "main.c"
.text
.globl sum
.type sum, @function
sum:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
addl 8(%ebp), %eax
addl %eax, accum
popl %ebp
ret
.size sum, .-sum
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
movl $0, %eax
popl %ebp
ret
.size main, .-main
.globl accum
.bss
.align 4
.type accum, @object
.size accum, 4
accum:
.zero 4
.ident "GCC: (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3"
.section .note.GNU-stack,"",@progbits


反汇编:

$ objdump -d main.o

对照C源代码 $objdump -S main

main.o:     file format elf32-i386

Disassembly of section .text:

00000000 <sum>:
   0: 55                   push   %ebp
   1: 89 e5                mov    %esp,%ebp
   3: 8b 45 0c             mov    0xc(%ebp),%eax
   6: 03 45 08             add    0x8(%ebp),%eax
   9: 01 05 00 00 00 00    add    %eax,0x0
   f: 5d                   pop    %ebp
  10: c3                   ret    


00000011 <main>:
  11: 55                   push   %ebp
  12: 89 e5                mov    %esp,%ebp
  14: b8 00 00 00 00       mov    $0x0,%eax
  19: 5d                   pop    %ebp
  1a: c3                   ret    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值