Next: , Previous: Miscellaneous, Up: Miscellaneous

5.1 Explicit register specification

In certain situations, like writing callback hooks, “patchers”, standard shared libraries, etc., functions have to receive arguments in particular registers.

-mregparm’ (see -mregparm) is not appropriate in this case, since it does not give the programmer enough control on which registers will be used.

To overcome this problem in the AmigaOS port of ‘GCC’, explicit register specification has been extended to be available for function arguments, as well:

     void myhook(struct Hook* hook __asm("a0"), APTR object __asm("a2"),
                 APTR message __asm("a1"))
Note: This feature is currently not available in ‘G++’.

Only the ‘ANSI’-style declarations (prototypes) are supported.

Registers have to be specified both in function declarations (prototypes) and definitions (function code).

This feature was first made available in the ‘GCC’, ‘Geek Gadgets’ snapshot ‘961012’.