This example program illustrates "Hello world" for the FreeBSD operating system in x86 assembly language.
.global _start .text _start: # write (1, message, 13) push $13 # Number of bytes push $message # Address of string to output push $1 # File handle 1 is stdout mov $4, %eax # System call 4 is write push %eax int $0x80 # exit (0) push $0 # Exit status mov $1, %eax # System call 1 is exit push %eax int $0x80 message: .ascii "Hello, world\n"
To compile and run the program, use
cc -c hello.s && ld hello.o && ./a.out
This page is an adaption of the assembly language "Hello World" program from the above.
This page explains the calling conventions of FreeBSD, but using a different assembler.
This page from 2001 explains FreeBSD assembly language programming.