NASM 2.06rc7
[nasm/perl-rewrite.git] / test / lnxhello.asm
blob1aa5a5f8b6d5ca403ea30e01eb79e21beddf8093
1 ;Testname=aout; Arguments=-faout -olnxhello.o -Ox; Files=stdout stderr lnxhello.o
2 ;Testname=aoutb; Arguments=-faoutb -olnxhello.o -Ox; Files=stdout stderr lnxhello.o
3 ;Testname=as86; Arguments=-fas86 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o
4 ;Testname=elf32; Arguments=-felf32 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o
7 ; Assembly "Hello, World!" for Linux
11 ; Properly defined in <sys/syscall.h>
12 %define SYS_exit 1
13 %define SYS_write 4
15 section .text
17 global _start
18 _start:
19 ; gdb doesn't like to stop at the entry point address, so
20 ; we put a nop here for pure convenience
21 nop
24 write_hello:
25 mov edx, hello_len
26 mov ecx, hello
28 .loop:
29 mov eax, SYS_write
30 mov ebx, 1 ; stdout
31 int 80h
33 cmp eax, -4096
34 ja error
36 add ecx, eax
37 sub edx, eax
38 jnz .loop
40 ok:
41 mov eax, SYS_exit
42 xor ebx, ebx
43 int 80h
44 hlt
46 error:
47 mov eax, SYS_exit
48 mov ebx, 1 ; Error
49 int 80h
50 hlt
52 section .rodata
53 hello: db "Hello, World!", 10
54 hello_len equ $-hello