使用YASM编程 - 02
2017-09-02 13:36
204 查看
Yasm 支持的GAS(Gnu asm)格式
实现:
1 基本框架
2 调用外部API
3 导出_start
4 mov xor push 等
5 使用 label 数字 寄存器
6 定义数字和定义字符串常量
7 编译
8 链接
实现:
1 基本框架
2 调用外部API
3 导出_start
4 mov xor push 等
5 使用 label 数字 寄存器
6 定义数字和定义字符串常量
7 编译
8 链接
/********************************************************* * Gnu asm 注释和字符串风格和C风格一样 * 还支持单行注释# * gas NASM * movl (movb movw) mov * pushl(pushb pushw) push * addl add * xorl xor * ... * ... * ... * 指令有(b w l 后缀) 没有后缀 * .global _start global _start * hello: .string "hello\n" hello: "hello",0x0a,0 * %eax (%在寄存器使用的前缀) eax(没有前缀) * $11 11(数字没有前缀) * .extern extern * * 如果是二元操作 * 操作符 目的操作数,源操作数 *********************************************************/ #testGas.asm #os:windows .data hello: .string "hello GAS\n" resultString: .string "Add1(%d,%d)=%d\n" msg: .string "hello\n" tlt: .string "msg\n" one: .int 100 two: .int 200 .extern _MessageBoxA@16 .extern _printf .global _start #build.bat /***************************************************************************** vsyasm -p gas -w -f win32 testGAS.asm link /entry:start /subsystem:console /libpath:C:\masm32\lib user32.lib msvcrt.lib testGAS.obj *****************************************************************************/ .text add1: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax movl 12(%ebp),%edx addl %edx,%eax popl %ebp ret callMessageBox: xorl %eax,%eax pushl %eax pushl $msg pushl $tlt pushl %eax call _MessageBoxA@16 ret _start: pushl one pushl two call add1 addl $8,%esp pushl %eax pushl two pushl one pushl $resultString call _printf addl $0x10,%esp ret
相关文章推荐
- 02.JAVA并发编程-线程的使用-构建启动线程
- 使用YASM编程 - 04
- 使用YASM编程 -07 模拟导入表
- 使用YASM编程 - 03
- 使用YASM编程 - 05
- 使用YASM编程 - 06
- 使用YASM编程 - 01
- 02-HDFS的原理和使用操作、编程
- 第七课-第二讲 07_02_bash脚本编程之六 使用脚本选项及组合条件测试
- 多线程编程之一:关键段的使用
- 使用VC调用matlab engine编程
- 使用PIG Latin 进行编程,Pig Latin语言详解
- 开始使用QML编程(4)
- Android编程使用Service实现Notification定时发送功能示例
- 谈谈使用VFW在windows下编程控制摄像头(一)【转360doc】
- Android之网络编程(二)使用 HttpURLConnection
- IOS多线程编程之NSThread的使用
- TCP/IP网络编程 基于Linux编程_1 --套接字中标准I/O的使用
- 深入解析Python设计模式编程中建造者模式的使用
- ubuntu下使用codeblocks编程运行时终端不能复制粘贴的解决方法