BITS 32 ; params: name number %macro define_syscall0 2 global %1 %1: push %2 ; syscall number int 0x80 ; exec syscall add esp, 4 ret %endmacro %macro define_syscall1 2 global %1 %1: push ebp mov ebp, esp mov eax, [ebp + 8] push eax push %2 int 0x80 add esp, 8 pop ebp ret %endmacro %macro define_syscall2 2 global %1 %1: push ebp mov ebp, esp mov eax, [ebp + 12] push eax mov eax, [ebp + 8] push eax ; push long 123 ; push long 0xCAFEBABE push %2 int 0x80 add esp, 12 pop ebp ret %endmacro %macro define_syscall3 2 global %1 %1: push ebp mov ebp, esp mov eax, [ebp + 16] push eax mov eax, [ebp + 12] push eax mov eax, [ebp + 8] push eax push %2 int 0x80 add esp, 16 pop ebp ret %endmacro SECTION .text define_syscall0 exit, 0x01 define_syscall2 open, 0x02 define_syscall1 close, 0x03 define_syscall3 read, 0x04 define_syscall3 write, 0x05 define_syscall1 sbrk, 0x0F define_syscall1 start_process, 0x10