Installing nasm on Ubuntu and simple use of nasm on Ubuntu

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.