First of all, I want to say
1) I haven't read all of your post, yet.
2) I'm no expert, so I could be wrong in some areas. Please, someone, correct me if I have mislead/misinformed/etc.
Your code
int OpenFile(char *pszFile, int nMode)
{
int nFile;
asm volatile
(
"mov r0, %1\n" //...