Calling syscalls through int 0x80 documentation?

Derek Ragona derek at computinginnovations.com
Thu Oct 18 12:21:09 PDT 2007


At 01:47 PM 10/18/2007, Yuri wrote:
> > You can try here:
> > http://www.ctyme.com/intr/int-80.htm
> >
>Thanks Derek.
>This site just says: parameters on stack.
>
>So when following this I write the function 'mysyscall' (below) it doesn't 
>work.
>It should return 3 but returns 14.
>And I am on i386.
>
>So something is missing.
>
>Yuri
>
>--- code----
>#include <fcntl.h>
>
>extern int mysyscall (
>           int syscall_no,
>           int a1, int a2, int a3,
>           int a4, int a5, int a6);
>
>asm(
>".text\n"
>"mysyscall:\n"
>"       push    28(%esp)\n"
>"       push    24(%esp)\n"
>"       push    20(%esp)\n"
>"       push    16(%esp)\n"
>"       push    12(%esp)\n"
>"       push    8(%esp)\n"
>"       push    4(%esp)\n"
>"       int     $0x80\n"
>"       pop     %ecx\n"
>"       pop     %ecx\n"
>"       pop     %ecx\n"
>"       pop     %ecx\n"
>"       pop     %ecx\n"
>"       pop     %ecx\n"
>"       pop     %ecx\n"
>"       ret\n"
>".previous\n"
>);
>
>main() {
>   char *fname = "myxxxfile";
>   //int fd = open(fname, O_WRONLY|O_CREAT);
>   int fd = mysyscall(5/*open*/, (int)fname,O_WRONLY|O_CREAT,0,0,0,0); // open
>   printf("fd=%i\n",fd);
>}

I guess I'd ask why you want to use syscall at all to just open a file?  I 
thought you wanted to access some hardware and had no other way to do that.

         -Derek

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.



More information about the freebsd-questions mailing list