From owner-freebsd-hackers Sat Mar 4 5:21:56 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from 1Cust163.tnt1.waldorf.md.da.uu.net (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 2A21D37B78A; Sat, 4 Mar 2000 05:21:45 -0800 (PST) (envelope-from green@FreeBSD.org) Date: Sat, 4 Mar 2000 08:21:50 -0500 (EST) From: Brian Fundakowski Feldman X-Sender: green@green.dyndns.org To: "Thomas M. Sommers" Cc: freebsd-hackers@freebsd.org Subject: Re: Can't write to stdout in assembly In-Reply-To: <38C0EA12.A4252C20@mail.ptd.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, 4 Mar 2000, Thomas M. Sommers wrote: > >From what I understand, the following should print "Hello, world." on > stdout. I stole the code from the Linux HOWTO, but I think it should > work on FreeBSD as well. Instead, the call to write returns 9 (EBADF). > [ Linux-specific asm elided ... ] > > Can anyone explain what I've done wrong? > > As a related question, can anyone point me to the source for the int > 0x80 handler? I've looked all over but can't find it. You're trying to run Linux assembly on FreeBSD. The calling conventions are not the same at all, and cannot be treated as such. Even if you really needed to write in assembly, you shouldn't call the syscalls directly. Note that the library stubs are just that, stubs to call the system calls. Try doing something more along the lines of: pushl $stringlen pushl stringaddr pushl $0x1 call write which would result in %eax containing the return value. For what it's worth, you can find all of the syscall calling conventions in src/lib/libc, and you can find where the calling conventions are "defined" by looking at src/sys/i386/i386/trap.c. > Thanks. -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message