Reputation: 5
section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string
Kernel source references:
How does the system know that it has to exit when it read EAX,1 and not EBX,1 ? Since 1 means Sys_Exit.
Upvotes: 0
Views: 7270
Reputation: 1174
This comportement is defined in what we call ABI (application binary interface). This should help : What is Application Binary Interface (ABI)?
Upvotes: 1