Assembly programming is a little different. There are many assembly languages, but for Linux, NASM or GAS is usually used. Use this to install both:
sudo aptitude install nasm build-essential
I will use NASM for this page. To write an assembly program, you will first need to write the code, then assemble and link it. To begin, enter this code into a file names “hw.asm”:
strData: db "Hello World!", 10 global _start _start: mov eax, 4 mov ebx, 1 mov ecx, strData mov edx, 13 int 0x80 mov eax, 1 int 0x80
To compile, open a terminal, and use these commands:
nasm hw.asm -f elf
This will assemble hw.asm and name the ouput “hw.o”.
To link, use:
ld hw.o -o hw
To run the program, type its name in the terminal:
The words “Hello World!” will be put to the screen.