Next: , Previous: Special startups, Up: Special startups

6.7.1 Calling convention

On the amiga almost all shared libraries are called with the library base in a6 and other parameters in other registers. The result is placed in d0 usually.

If you want to write your own shared library you should stick to this model to make it easier for others to interface with it - but unfortunately gcc doesn't support registerized parameters. The solution to this problem is to write an assembler wrapper for each function you need. Since all those wrappers look the same it's easy to simplify their notation by using preprocessor macros. You can find appropriate macros in the stabs.h file of the libnix sources. Usage:

     /* Define some function that has 1 argument in d0 */

As a bonus these macros add your function to your library's jump vector. All you have to do is to care for the right linkage order. And don't forget to add a ‘ADDTABL_END();’ at the end of the vector.

Attention: Other programmers may decide to patch into your library's jump vector - therefore it's a good idea to call even own functions over this vector. To achieve this you have to provide some inline functions (like those in the gnu:os-include/inline directory) or glue code and you have to privatize the function's name by adding some '__'s or similar. You will also have to set up your OWN library base.