Ubuntu18.04下Intelアセンブラコンパイラnasm用法紹介
1656 ワード
nasmコンパイラ
NASM Command−Line Syntax To assemble a file, you issue a command of the form
For example,
will assemble myfile.asm into an ELF object file myfile.o. And
will assemble myfile.asm into a raw binary file myfile.com. To produce a listing file, with the hex codes output from NASM displayed on the left of the original sources, use the -l option to give a listing file name, for example:
To get further usage instructions from NASM, try typing
The option --help is an alias for the −h option. The option -hf will also list the available output file formats, and what they are. If you use Linux but aren’t sure whether your system is a.out or ELF, type
(in the directory in which you put the NASM binary when you installed it). If it says something like nasm: ELF 32−bit LSB executable i386 (386 and up) Version 1 then your system is ELF, and you should use the option −f elf when you want NASM to produce Linux object files. If it says nasm: Linux/i386 demand−paged executable (QMAGIC) or something similar, your system is a.out, and you should use −f aout instead (Linux a.out systems have long been obsolete, and are rare these days.) Like Unix compilers and assemblers, NASM is silent unless it goes wrong: you won’t see any output at all, unless it gives error messages.
NASM Command−Line Syntax To assemble a file, you issue a command of the form
nasm −f [−o
For example,
nasm -f elf myfile.asm
will assemble myfile.asm into an ELF object file myfile.o. And
nasm -f bin myfile.asm -o myfile.com
will assemble myfile.asm into a raw binary file myfile.com. To produce a listing file, with the hex codes output from NASM displayed on the left of the original sources, use the -l option to give a listing file name, for example:
nasm -f coff myfile.asm -l myfile.lst
To get further usage instructions from NASM, try typing
nasm -h
The option --help is an alias for the −h option. The option -hf will also list the available output file formats, and what they are. If you use Linux but aren’t sure whether your system is a.out or ELF, type
file nasm
(in the directory in which you put the NASM binary when you installed it). If it says something like nasm: ELF 32−bit LSB executable i386 (386 and up) Version 1 then your system is ELF, and you should use the option −f elf when you want NASM to produce Linux object files. If it says nasm: Linux/i386 demand−paged executable (QMAGIC) or something similar, your system is a.out, and you should use −f aout instead (Linux a.out systems have long been obsolete, and are rare these days.) Like Unix compilers and assemblers, NASM is silent unless it goes wrong: you won’t see any output at all, unless it gives error messages.