From owner-freebsd-questions@FreeBSD.ORG Thu Oct 18 19:40:10 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 54E4116A468 for ; Thu, 18 Oct 2007 19:40:10 +0000 (UTC) (envelope-from icantthinkofone@charter.net) Received: from mtao03.charter.net (mtao03.charter.net [209.225.8.188]) by mx1.freebsd.org (Postfix) with ESMTP id 05F7913C465 for ; Thu, 18 Oct 2007 19:40:09 +0000 (UTC) (envelope-from icantthinkofone@charter.net) Received: from aa04.charter.net ([10.20.200.156]) by mtao03.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20071018194004.VVBS10962.mtao03.charter.net@aa04.charter.net>; Thu, 18 Oct 2007 15:40:04 -0400 Received: from robs-laptop.com ([71.85.241.27]) by aa04.charter.net with ESMTP id <20071018194004.HXXY1254.aa04.charter.net@robs-laptop.com>; Thu, 18 Oct 2007 15:40:04 -0400 Message-ID: <4717B692.8090405@charter.net> Date: Thu, 18 Oct 2007 14:40:02 -0500 From: icantthinkofone User-Agent: Thunderbird 2.0.0.6 (X11/20070914) MIME-Version: 1.0 To: Yuri References: <1192731161.4717a21980065@webmail.rawbw.com> <6.0.0.22.2.20071018132410.02311ad8@mail.computinginnovations.com> <1192733243.4717aa3b1843f@webmail.rawbw.com> <6.0.0.22.2.20071018141850.02482e78@mail.computinginnovations.com> <1192735722.4717b3ea8273a@webmail.rawbw.com> In-Reply-To: <1192735722.4717b3ea8273a@webmail.rawbw.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Chzlrs: 0 Cc: freebsd-questions@freebsd.org, Derek Ragona 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:40:10 -0000 Yuri wrote: >> 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, > > Opening a file is just an example. I want to be able to make any system call > this way since my program for whatever reasons has to be compiled with such gcc > options that prevent being linked to system calls in the traditional way. No > hardware issues for me. > > Btw I submitted the wrong assembly code with my previous message. > The right one (still not working) is below. > > Lack of documentation causes me to ask this kind of question here. > > 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" > " movl %esp,%ebx\n" > " push 28(%ebx)\n" > " push 24(%ebx)\n" > " push 20(%ebx)\n" > " push 16(%ebx)\n" > " push 12(%ebx)\n" > " push 8(%ebx)\n" > " push 4(%ebx)\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, (int)fname,O_WRONLY|O_CREAT,0,0,0,0); // open > printf("fd=%i\n",fd); > } > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > I think the problem may relate to how FreeBSD handles the stack. Try pushing an extra word, anything will do, before making the int 80. Let us know if that makes it work and I'll point to a link that explains it.