;=================================================================
; SYSCALLS
; see system functions: /usr/include/asm/unistd_32.h
; see arguments: man 2 <cmd>
;=================================================================
; COMPILATION
; compiler: nasm -f elf hello.asm
; linker: ld -s -o hello hello.o
;=================================================================
; REGISTERS
; xtended 32b: eax, ebx, ecx, edx
; float: st0, st1
;=================================================================
; SIZES
; b: byte (8 bits)
; w: word (16 bits)
; dw: dword (32 bits)
; q: quadwords (64 bits)
;=================================================================
; SPECIAL
; $: end of variable address
;=================================================================
; ARGUMENTS
; use :eax, ebx, ecx, edx, esi, edi, ebp
; or: eax et ebx contient l'adresse de la liste
; input args: found in eax (nb args),
; ebx (program name ie arg 0), ecx (arg 1)
section .data
msg: db 'hello world',10 ; declare msg
msgLen: equ $-msg
section .bss
; variables, reserving memory
section .text
global _start
_start:
;kernel write
mov eax,4 ; arg 1: syscall write id
mov ebx,1 ; arg 2: file descriptor (standard output)
mov ecx,msg ; arg 3: msg location
mov edx,msgLen ; arg 4: msg length
int 80h ; kernel call
;kernel exit
mov eax,1 ; argument 1: syscall 'exit' id
mov ebx,0 ; argument 2: exit code 0
int 80h ; kernel call