I am trying to write a C code with just inline functions so that there would be no access to stack. But I see the compiler is inserting a push instruction at the start of the main. Also, this behaviour is not seen every time. With a slight change in the code sometimes I don't see the push instruction. I would like to know the what is the reason behind this
Target CPU: Cortex M23
Compiler: GCC
Code structure:
#include "interface.h"
int main(void)
{
unsigned int operation;
operation = <SFR read>; status = check_status(operation); if(status) { return(status); }
Disassembly:
int main(void){ c00069c: b510 push {r4, lr}
<rest of the inline functions>
}
Header file: interface.h
inline unsigned int check_status(unsigned int oper) __attribute__((always_inline));
inline unsigned int check_status(unsigned int oper)
<function body>
Automatic variables go on the stack - so, if you don't want the stack to be used, don't create auto variables!