initial import
[staff/goc4/2018bti7061.git] / asm-5-programming / examples / eatsyscall / eatsyscall.asm
1 ; Executable name : EATSYSCALL
2 ; Version : 1.0
3 ; Created date : 1/7/2009
4 ; Last update : 2/18/2009
5 ; Author : Jeff Duntemann
6 ; Description : A simple program in assembly for Linux, using NASM 2.05,
7 ; demonstrating the use of Linux INT 80H syscalls to display text.
8 ;
9 ; Build using these commands:
10 ; nasm -f elf -g eatsyscall.asm
11 ; ld -o eatsyscall eatsyscall.o
12 ;
13 SECTION .data ; Section containing initialised data
14
15 EatMsg: db "Eat at Joe's!",10
16 EatLen: equ $-EatMsg
17
18 SECTION .bss ; Section containing uninitialized data
19
20 SECTION .text ; Section containing code
21 global _start ; Linker needs this to find the entry point!
22 _start:
23 nop ; This no-op keeps gdb happy...
24 mov eax,4 ; Specify sys_write call
25 mov ebx,1 ; Specify File Descriptor 1: Standard Output
26 mov ecx,EatMsg ; Pass offset of the message
27 mov edx,EatLen ; Pass the length of the message
28 int 80H ; Make kernel call
29 nop
30 MOV eax,1 ; Code for Exit Syscall
31 mov ebx,0 ; Return a code of zero
32 int 80H ; Make kernel call