Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Aug 2005 10:03:27 +0200 (CEST)
From:      marcov@stack.nl (Marco van de Voort)
To:        freebsd-hackers@freebsd.org
Subject:   Re: hello world but not in 32bit x86 but in amd64 for amd64 platform
Message-ID:  <20050818080327.EFAE32287D@snail.stack.nl>
In-Reply-To: <20050817145510.GD26422@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> > 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050818080327.EFAE32287D>