展会信息港展会大全

prolog and epilog 是啥意思
来源:互联网   发布日期:2011-10-01 15:06:55   浏览:30913次  

导读: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...

#4楼 得分:0回复于:2008-03-05 12:51:08

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约定在编写虚拟设备驱动时特别有用。 

赞助本站

人工智能实验室
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港