From owner-freebsd-questions@FreeBSD.ORG Thu Oct 18 19:21:09 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3586016A418 for ; Thu, 18 Oct 2007 19:21:09 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from betty.computinginnovations.com (mail.computinginnovations.com [64.81.227.250]) by mx1.freebsd.org (Postfix) with ESMTP id CDD8313C48D for ; Thu, 18 Oct 2007 19:21:08 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from p28.computinginnovations.com (dhcp-10-20-30-100.computinginnovations.com [10.20.30.100]) (authenticated bits=0) by betty.computinginnovations.com (8.13.8/8.13.8) with ESMTP id l9IJL1LX069751; Thu, 18 Oct 2007 14:21:02 -0500 (CDT) (envelope-from derek@computinginnovations.com) Message-Id: <6.0.0.22.2.20071018141850.02482e78@mail.computinginnovations.com> X-Sender: derek@mail.computinginnovations.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Date: Thu, 18 Oct 2007 14:20:44 -0500 To: Yuri From: Derek Ragona In-Reply-To: <1192733243.4717aa3b1843f@webmail.rawbw.com> References: <1192731161.4717a21980065@webmail.rawbw.com> <6.0.0.22.2.20071018132410.02311ad8@mail.computinginnovations.com> <1192733243.4717aa3b1843f@webmail.rawbw.com> Mime-Version: 1.0 X-ComputingInnovations-MailScanner-Information: Please contact the ISP for more information X-ComputingInnovations-MailScanner: Found to be clean X-ComputingInnovations-MailScanner-From: derek@computinginnovations.com X-Spam-Status: No Content-Type: text/plain; charset="us-ascii"; format=flowed X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org Subject: Re: Calling syscalls through int 0x80 documentation? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Oct 2007 19:21:09 -0000 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 > >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.