From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 18 08:03:30 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F3DF216A41F for ; Thu, 18 Aug 2005 08:03:29 +0000 (GMT) (envelope-from marcov@stack.nl) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 99C5143D45 for ; Thu, 18 Aug 2005 08:03:29 +0000 (GMT) (envelope-from marcov@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mailhost.stack.nl (Postfix) with ESMTP id 0CA48A3839 for ; Thu, 18 Aug 2005 10:03:28 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 816) id EFAE32287D; Thu, 18 Aug 2005 10:03:27 +0200 (CEST) In-Reply-To: <20050817145510.GD26422@dan.emsphone.com> To: freebsd-hackers@freebsd.org Date: Thu, 18 Aug 2005 10:03:27 +0200 (CEST) X-Mailer: ELM [version 2.4ME+ PL122a (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Message-Id: <20050818080327.EFAE32287D@snail.stack.nl> From: marcov@stack.nl (Marco van de Voort) Subject: Re: hello world but not in 32bit x86 but in amd64 for amd64 platform X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2005 08:03:30 -0000 > > Could you inform me if there exist somewhere such a program > > cfr the 32bit hello world example in > > Chapter 11 > > x86 Assembly Language Programming > > FreeBSD Developers' Handbook > > The procedure should be the same no matter what architecture you are > using. Just use AMD64 assembly... > > You can also generate an assembly hello-world program yourself: > > $ cat << EOF > test.c > int main(void) > { > write(1, "Hello world\n", 12); > return 0; > } > EOF > $ gcc -S test.c > $ cat test.s This doesn't lead you to the minimal program, simply because it is still linked to gcc. It should be static, and with no standard libs. However afaik this is not possible with the current CSU. I patched the CSU of (iirc -CURRENT somewhere close before 5.2) for the FPC x86_64 port (which isn't fully completed for time reasons) I just changed that adapted CSU to a hello world program and retested it on our only freebsd/x86_64 machine (which runs 6.0, probably compat_5 installed) and it works. The program patched to hello world is at: http://www.stack.nl/~marcov/prt0.as which is adapted from http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/rtl/freebsd/x86_64/prt0.as?view=markup to assemble the first program: as prt0.as -o prt0.o and link with ld prt0.o -o helloworld