hello world but not in 32bit x86 but in amd64 for amd64 platform

Marco van de Voort marcov at stack.nl
Thu Aug 18 08:03:30 GMT 2005


> > 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



More information about the freebsd-hackers mailing list