On 08/10/2014 11:44, David Gálvez wrote:
+ asm volatile("move.l d1,-(SP)\n\t" : : : );
I'm really not sure that this block does what you think (and I'm pretty sure it does not). By doing so, you modify SP, but GCC does not know that. Afterwards, it may access local variables or parameters through SP. If you change SP, those references will be wrong.
The only safe way to preserve registers in a callback is to implement it as a full assembler stub (in a .S file). So it can save/restore the registers, get the parameters and call a standard C function containing the main callback code.
-- Vincent Rivière