.section .data path: .asciz "open_file.c" .section .text .global _start _start: mov $5, %eax mov $path, %ebx // 0 is O_RDONLY mov $0, %ecx int $0x80 // File descriptor should be in eax now // We'll copy it to ebx too so we can close the file mov %eax, %ebx // Allocate 1024 bytes on the stack sub $1024, %esp mov $3, %eax // File descriptor needs is in ebx at this point mov %esp, %ecx mov $1024, %edx int $0x80 mov %eax, %edx mov $4, %eax mov $1, %ebx // ecx actually had the right value already mov %esp, %ecx // We already put the length into edx int $0x80 mov $6, %eax // File descriptor needs to be in ebx here int $0x80 mov $1, %eax mov $0, %ebx int $0x80