Debian Codegraph @

travis/test/lnxhello.asm

raw
1 ;
2 ; Assembly "Hello, World!" for Linux
3 ;
4
5
6 ; Properly defined in <sys/syscall.h>
7 %define SYS_exit 1
8 %define SYS_write 4
9
10 section .text
11
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
17
18
19 write_hello:
20 mov edx, hello_len
21 mov ecx, hello
22
23 .loop:
24 mov eax, SYS_write
25 mov ebx, 1 ; stdout
26 int 80h
27
28 cmp eax, -4096
29 ja error
30
31 add ecx, eax
32 sub edx, eax
33 jnz .loop
34
35 ok:
36 mov eax, SYS_exit
37 xor ebx, ebx
38 int 80h
39 hlt
40
41 error:
42 mov eax, SYS_exit
43 mov ebx, 1 ; Error
44 int 80h
45 hlt
46
47 section .rodata
48 hello: db "Hello, World!", 10
49 hello_len equ $-hello