1. Install nasm on Ubuntu at http://www.nasm.us/pub/nasm/releasebuilds/2.10.07/to download the 2.10.07.tar.gzversion (This compression method is generally used on ubuntu ). If you want to download nasm of another version, you can choose http://www.nasm.us/to download it. 2. Installation Method: run the following command: Decompress: tarzxvf
1. Install nasm on Ubuntu
First, download the 2.10.07.tar.gzversion at http://www.nasm.us/pub/nasm/releasebuilds/2.10.07/( usually in ubuntu ). If you want to download nasm of another version, you can choose http://www.nasm.us/to download it.
2. Installation Method: Use the following command:
Unzip: tar zxvf nasm-2.10.07.tar.gz
Enter the extracted directory
Then execute the command:./configure
Make
Sudo make install
Through the above steps, nasm is installed on ubuntu. You can also run the nasm-version command to check whether the installation is successful. If nasm version information is displayed, the installation is successful. Otherwise, further installation is required.
3. Use nasm for compilation in ubuntu:
The source code of hello. asm is as follows:
**************************************** *********************
Section. text
Global main
Main:
Mov eax, 4; called on 4
Mov ebx, 1; ebx returns 1 to indicate output
Mov ecx, msge; the first address of the string is sent to ecx
Mov edx, 14; the length of the string is sent to edx
Int 80 h; Output string
Mov eax, 1; 1 call
Int 80 h; End
Msge:
Db "Hello world! ", 0ah, 0dh
**************************************** *********************
Save the above Code as hello. asm, put the file in the directory of nasm after decompression, and run the following command in the directory:
Nasm-f elf64 (elf32) hello. asm (note that elf64 or elf32 depends on the number of digits of the operating system)
Gcc-o hello. o
./Hello
If hello wrod is output, the installation is successful.