Simple program which just exits.
======================================
.text
.globl_start
_start:
movl $1, %eax
movl $0, %ebx
int 0x80
======================================
Calling exit(0) to exit a program
1. Sys call number for exit() is 1, so load EAX with 1
movl $1, %eax
2. "status" is let say "0" -EBX must be loaded with "0"
movl $0, %ebx
3. Raise the software interrupt 0x80
int 0x80
Hello World Program
We will use the write() syscall to print the "hello world" message
Then use exit() to gracefully exit the program
write() syscall description
ssize_t write(int fd, const void *buf, size_t count);
Sys call number for write() is 4 (store in EAX)
Fd = 1 for STDOUT (in EBX)
Buf = pointer to memory location containing "hello world" string (in ECX)
Count = string length (in EDX)
======================================
.data
Helloworldstring:
.ascii "Hello World"
.text
.globl _start
_start:
# Load all the arguments for write ()
movl $4, %eax
movl $1, %ebx
movl $"HelloWorldstring, %ecx
int $0x80
#Need to exit the program
movl $1, %eax
movl $0, %ebx
int $0x80
======================================