当前位置: 首页 > 工具软件 > Yasm > 使用案例 >

【asm】汇编器yasm使用说明

南宫天逸
2023-12-01

DATE: 2018.11.21


1、汇编器yasm

项目网址:http://yasm.tortall.net/
下载:http://yasm.tortall.net/Download.html
在编译x86汇编代码时,可以使用yasm实现跨平台编译(Windows, Linux, Mac OSX)。

yasm介绍:
Yasm is a complete rewrite of the NASM assembler under the “new” BSD License (some portions are under other licenses, see COPYING for details).

Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes, outputs binary, ELF32, ELF64, 32 and 64-bit Mach-O, RDOFF2, COFF, Win32, and Win64 object formats, and generates source debugging information in STABS, DWARF 2, and CodeView 8 formats.

Yasm can be easily integrated into Visual Studio 2005/2008 and 2010 for assembly of NASM or GAS syntax code into Win32 or Win64 object files.

yasm继承自masm,扩展了支持语法和平台,支持Intel格式语法和GNU AS语法。

疑惑:yasm或者nasm可以进行x86 纯汇编的编译,但是支持inline assembly和Intrinsic assembly吗?

2、yasm使用说明
Running Yasm

Version Information:

yasm --version
Command Line Option Help:

yasm --help
Assemble test.asm to Win32 object file test.obj with CodeView 8.0 (VS2005) source debug info:

yasm -f win32 -g cv8 test.asm
Assemble test2.asm to Win64 object file test.obj with CodeView 8.0 source debug info:

yasm -f win64 -g cv8 test2.asm
Assemble test3.asm to AMD64 ELF object file test3.o with DWARF2 debugging information:

yasm -f elf64 -g dwarf2 test3.asm
Alternative to above:

yasm -f elf -m amd64 -g dwarf2 test3.asm
Assemble test4.s (GAS syntax file) to 32-bit x86 ELF object file testo.o with DWARF2 debugging information:

yasm -p gas -f elf32 -g dwarf2 -o testo.o test4.s

yasm -i %(RootDir)%(Directory)\ -f win32 -o $(IntDir)%(Filename).obj %(FullPath)
yasm -i %(RootDir)%(Directory)\ -f win64 -o $(IntDir)%(Filename).obj %(FullPath)

yasm -f maco32 test.asm
yasm -f maco64 test.asm

yasm的使用详细参考文档:http://www.tortall.net/projects/yasm/manual/manual.pdf

3、安装配置方法
./configure
make
make install

prefix的作用
profile
.bash_profile


THE END!

 类似资料: