808384cd0eeeba949b2908240ac39bcf560c54a3
[staff/goc4/2018bti7061.git] / asm-4-codification / examples / helloWorld / eatsyscall64.asm
1 ; Executable name : EATSYSCALL64
2 ; Version : 1.0
3 ; Created date : 08/30/2016
4 ; Last update : 08/30/2016
5 ; Author : Emmanuel Benoist
6 ; Description : A simple program in assembly for Linux, using NASM,
7 ; demonstrating the use of Linux 64-bit syscalls to display text.
8 ;
9 ; Build using these commands:
10 ; nasm -f elf64 -g eatsyscall64.asm
11 ; ld -o eatsyscall64 eatsyscall64.o
12 ;
13
14 SECTION .data ; Section containing initialised data
15
16 EatMsg: db "Eat at Joe's!",10
17 EatLen: equ $-EatMsg ; Compute the length of the string
18
19 SECTION .bss ; Section containing uninitialized data
20
21 SECTION .text ; Section containing code
22
23 global _start ; Linker needs this to find the entry point!
24
25 _start:
26 nop ; This no-op keeps gdb happy...
27 mov rax,1 ; Code for Sys_write call
28 mov rdi, 1 ; Specify File Descriptor 1: Standard Output
29 mov rsi, EatMsg ; Pass offset of the message
30 mov rdx, EatLen ; Pass the length of the message
31 syscall ; Make kernel call
32
33 mov rax, 60 ; Code for exit
34 mov rdi, 0 ; Return a code of zero
35 syscall ; Make kernel call
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63