Here in this tutorial we will write a simple program in Assembly Language that simply prints a “Hello World” in the console/terminal.

Here we will use Intel Core 2 Duo as our Machine that runs Ubuntu 11.10.

section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string

Now open the terminal by Going to Application >> Accesories >> Terminal in Ubuntu Linux

$gedit hello.asm

Copy and paste the Program in to hello.asm and Save It.

Now to compile it using Nasm

$nasm -f elf hello.asm

It should not show any error. If nasm is already not there in Ubuntu Linux then install it by typing #sudo apt-get install nasm

Now create an executable object file by typing

$ld -s -o hello hello.o

To execute the program


Hello World


The above should print in the terminal. Now you are Done.