Join the DZone community and get the full member experience.Join For Free
The canonical Hello World program in assambler. Compile it with: nasm -f elf hello.s ld -s -o hello hello.o Helloworld is a function. It uses the write system call to print to stdout (file descriptor 1). This is written in NASM (Intel) syntax, hence it will not work with gas, tasm or masm. It was written for Linux. The details may vary on other platforms. Download NASM for free at http://nasm.sourceforge.net/
section .data hello: db "Hello world!",10 hellolen: equ $ - hello section .text global _start _start: call helloworld mov eax,1 ; start exit procedure mov ebx,0 int 80h helloworld: mov eax,4 ; 4 is the code for the write system call mov ebx,1 ; 1 is the fd for stdout mov ecx,hello ; the address of the string mov edx,hellolen ; the length of the string int 80h ; trigger an interrupt; this should be 21h for DOS ret
Opinions expressed by DZone contributors are their own.