Question:
How to define a function without a prologue and epilogue so that only the body code is generated?
For example, so that the function
void func() {
__asm__ volatile__ ("nop");
}
compiled to code
0: 90 nop
instead of code
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 90 nop
4: 5d pop %ebp
5: c3 ret
Are there standard C (visual c, gcc) facilities?
Answer:
There is no such possibility in the C standard. It can be provided by specific compilers. For example, for Visual C ++ on x86 platform it will look like this:
__declspec( naked ) void func( void ) { __asm { nop } }
For ARM gcc:
void func() __attribute__ ((naked));
void func(void) {
__asm__ __volatile__("nop");
}