I am optimizing some code and I want to have a C function call an ASM function. (no problem here). Problem is that depending on compilation settings, the ASM function will be called using either a CALL instruction or CALLA. Is there any way to detect this at compile-time in a header file or similar so that the ASM function can have a matching RET or RETA instruction. Any mismatch would surely blow up the stack. I would like to make the code as portable as possible and work for any device.
The MSP430X devices have #defines in the header such as __MSP430_HAS_MSP430XV2_CPU__ which indicate the extended instruction set. Unfortunately this does not necessarily mean that a CALLA will be used at compile time since the user could override the compiler to only use 16-bit calls.
Any ideas?