General push for x86-64 support, dubbed 0.99.00.
[nasm.git] / test / lnxhello.asm
blob7bc8ff0a9800ff610e2762c4b6e0e218253615bb
2 ; Assembly "Hello, World!" for Linux
6 ; Properly defined in <sys/syscall.h>
7 %define SYS_exit 1
8 %define SYS_write 4
10 section .text
12 global _start
13 _start:
14 ; gdb doesn't like to stop at the entry point address, so
15 ; we put a nop here for pure convenience
16 nop
19 write_hello:
20 mov edx, hello_len
21 mov ecx, hello
23 .loop:
24 mov eax, SYS_write
25 mov ebx, 1 ; stdout
26 int 80h
28 cmp eax, -4096
29 ja error
31 add ecx, eax
32 sub edx, eax
33 jnz .loop
35 ok:
36 mov eax, SYS_exit
37 xor ebx, ebx
38 int 80h
39 hlt
41 error:
42 mov eax, SYS_exit
43 mov ebx, 1 ; Error
44 int 80h
45 hlt
47 section .rodata
48 hello: db "Hello, World!", 10
49 hello_len equ $-hello