In my NASM textbook, "Guide to Assembly Programming in Linux" by Dandamundi, system call 5 (opening a file) is described with the following parameters.
EAX = 5
EBX = file name
ECX = file access mode (read, write, read/write)
EDX = file permissions
It does not clarify what the access codes (octal, I'm assuming) actually are. 0200Q and 02000Q assumedly do not work. I am trying to append the contents of one file onto another file.
I think this is the
sys_open
syscall, so the parameters should map one-to-one to those of open(2):After looking at
/usr/include/asm/unistd_32.h
, it's clear that system call number 5 resolves toopen
. In turn, looking atman 2 open
says that the second parameter must includeO_RDONLY
(00
),O_WRONLY
(01
) orO_RDWR
(02
). It may also include a number of extra flags by ORing them together, which are documented on the said manual page.In your case, you probably want to be able to write to a file and append to it. Therefore,
O_WRONLY | O_APPEND
would be desirable. After looking at the header files, that operation yields the value02001
and this is what you should put in theecx
register.