completed l_open:
bits 32
section .text
global l_open
l_open:
push ebp ; prologue
mov ebp, esp
push ebx ; preserve registers
push edi
push esi
mov ebx, [ebp + 8] ; name of the file (const char * name)
mov ecx, [ebp + 12] ; flags
mov edx, [ebp + 16] ; mode
mov eax, 5 ; open sys call
int 0x80
cmp eax, 0 ; check for error
jl .error
.done:
pop esi ; restore registers
pop edi
pop ebx
mov esp, ebp ; epilogue
pop ebp
ret
.error:
mov eax, -1
jmp .done
int l_open(const char *name, int flags, int mode)
opens the named file with the supplied flags and mode. Returns the integer file descriptor of the newly opened file or -1 if the file can't be opened.