View Single Post
Old 24 April 2017, 00:16   #1
Registered User
patrik's Avatar
Join Date: Jan 2005
Location: UmeƄ
Age: 41
Posts: 675
AROS startup code


I would like to learn how to write my own startup code for AROS.

On classic AmigaOS, it is very simple - it executes the first function found in an executable file, you just need to setup SysBase before calling any exec.library functions. An hello world example with own startup code would look like this:
#include <exec/exec.h>
#include <dos/dos.h>

#include <proto/exec.h>
#include <proto/dos.h>

struct ExecBase *SysBase = NULL;
struct DosLibrary *DOSBase = NULL;

LONG Something(void) {
	SysBase = *(struct ExecBase **) 4;
	DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 36);
	if(NULL != DOSBase) {
		Printf("Hello Amiga!\n");
	CloseLibrary((struct Library *) DOSBase);
	return 0;
Compiles with:
vc +aos68k -c99 -nostdlib -o helloamiga helloamiga.c
For MorphOS, you just need to add the __abox__ symbol, for AmigaOS4 the function needs to be named _start and have a specific signature and there is some more code required for the exec iface, but basically it is no big problem, atleast not with vbcc.

With gcc things seem a bit trickier, but it is doable - there is for example an excellent guide for writing your own startup code in MorphOS using gcc, with a complete example attached at the end.

If I try something similar on AROS and compile the above code with:
gcc -nostdlib -nostartfiles -o helloamiga helloamiga.c
I do get an executable without producing any warnings or anything, but it will crash if I try to execute it, so obviously I'm missing something required which I am unaware of.

Haven't been able to find any information similar to the MorphOS guide for AROS, so I'm hoping someone can point me in the right direction.
patrik is offline  
Page generated in 0.04326 seconds with 11 queries