From owner-freebsd-questions@FreeBSD.ORG Thu Oct 18 18:47:25 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 4868616A419 for ; Thu, 18 Oct 2007 18:47:25 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) by mx1.freebsd.org (Postfix) with ESMTP id 3447013C4B3 for ; Thu, 18 Oct 2007 18:47:25 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from mail0.rawbw.com (localhost [127.0.0.1]) by mail0.rawbw.com (8.13.8/8.13.8) with ESMTP id l9IIlNpJ043360; Thu, 18 Oct 2007 11:47:23 -0700 (PDT) Received: (from www@localhost) by mail0.rawbw.com (8.13.8/8.13.8/Submit) id l9IIlNLS043358; Thu, 18 Oct 2007 11:47:23 -0700 (PDT) X-Authentication-Warning: mail0.rawbw.com: www set sender to yuri@rawbw.com using -f Received: from new-5000.Cadence.COM (new-5000.Cadence.COM [158.140.1.25]) by webmail.rawbw.com (IMP) with HTTP for ; Thu, 18 Oct 2007 11:47:23 -0700 Message-ID: <1192733243.4717aa3b1843f@webmail.rawbw.com> Date: Thu, 18 Oct 2007 11:47:23 -0700 From: Yuri To: Derek Ragona References: <1192731161.4717a21980065@webmail.rawbw.com> <6.0.0.22.2.20071018132410.02311ad8@mail.computinginnovations.com> In-Reply-To: <6.0.0.22.2.20071018132410.02311ad8@mail.computinginnovations.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 158.140.1.25 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 18:47:25 -0000 > 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); }