x86-32汇编语言基础汇总

x86-32汇编语言基础汇总

常用命令

从C代码生成汇编代码
gcc -O2 -S code.c -m32 -fno-omit-frame-pointer

编译.s文件为.o文件
as -o code.o code.s --32
使用gdb调试则加
-gstabs

链接.o文件生成可执行文件
ld -o exe code1.o code2.o -m elf_i386

调用lib_c库函数
ld命令加上参数,-m参数也不能丢
-lc -dynamic-linker /lib/ld-linux.so.2

output:
    .asciz "The number is %d\n"
num:
    .long 666 
.section .text
.globl _start
_start:
    movl $num, %eax
    pushl (%eax)
    push $output
    call printf
    addl $8, %esp
    push $0
    call exit

保存为test.s,然后使用命令
as test.s -o test.o --32
ld test.o -o test -m elf_i386 -lc -dynamic-linker /lib/ld-linux.so.2
./test

即可观察到输出。

基础语法

1.数据
C声明Intel数据类型汇编代码后缀大小(字节)
char字节b1
shortw2
int双字l4
long int双字l4
char*双字l4
float单精度s4
double双精度l8
long double扩展精度t10/12


汇编语言指令所处理的数据类型一般是采用汇编语言的后缀来进行区分。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值