函数调用

For functions declared with the naked attribute, the compiler generates code without prolog and epilog code. You can use this feature to write your own prolog/epilog code using inline assembler code. Naked functions are particularly useful in writing virtual device drivers.

先讲一下背景知识,在函数被调用时,需要有一段程序来保存当前的堆栈信息,以及一些寄存器。当函数调用结束后,就要恢恢复现场。 
保存现现场的代码为prolog, 而恢复现场的代码则为epilog。

我们在写函数时,要告诉编译器,我们将采取哪种方式保护和恢复现场。 通常有以下类型:
  stdcall 
  cdecl 
  fastcall 
  thiscall 
  naked call 

naked call为其中一种,它告诉编译器:我自己会保护和恢复现场,你不用给我添加了。 这样你可以在你的函数中使用内嵌汇编自己来做这些事。 
naked约定在编写虚拟设备驱动时特别有用。

你可能感兴趣的:(C/C++,develop,and,test)