Page 1 of 1

inline assambly error?

Posted: Fri Feb 14, 2003 1:15 pm
by amirsadig
I try to write my syscalls, therefore I make fisrt some test.
the below code will be called when the Interrupt 0x80 occure.
but when I complie it the ld bring me the error "undefined reference to `write' ". but its in another file which has been linked with this code!!.

what the error ?

void syscall(regs_t *regs)
{
__asm__ __volatile__(
   "mov %0, %%ebx;
mov %1, %%ecx;
pushl %%ecx ;
pushl %%ebx ;
call write ;"
   ::"r"(regs->ebx), "r"(regs->ecx)
);
}

Re:inline assambly error?

Posted: Fri Feb 14, 2003 1:29 pm
by Therx
I'm not sure but maybe the 'write' should be '_write' if its in a C file

Re:inline assambly error?

Posted: Fri Feb 14, 2003 2:22 pm
by Tim
Why does this need to be written in inline assembly at all? It's equivalent to this:

Code: Select all

write(regs->ebx, regs->ecx);
In fact, your code will crash because it doesn't adjust the stack after the call (you need add %%esp, $8).

Re:inline assambly error?

Posted: Fri Feb 14, 2003 5:49 pm
by amirsadig
I have found the error:
the function write was static function in the others file. after I declare it as non static the program work.

Tim:
I know what you have written, but that code was only for test purpose and I will recode it so that it call the syscall from table. so I kept my syscall like linux sys_call, so that I can port GNU Libc easy and what you have seen is only the syscall service routine. the interrupt handdler does the return from syscall and it work when I passed the parameter to my rapper function, which call the interrupt (int 0x80) after passing the parameter to register ( eax, ebx ..)