什么是函数尾声和序言?
我读到了类似“尾声和序言”的内容
在阅读某些 CPU 架构中的一些调用约定时,当从另一个函数调用一个函数时,
。什么是函数序言或结尾?
While reading some calling convention in some CPU architecture I read something like
"epilogue and prologue", when a function is called from another function.
What is a function prologue or epilogue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
函数的尾声和序言只是一组指令,它们在调用函数时“设置”函数的上下文,并在函数返回时进行清理。
序言通常执行以下任务:
参数尾声通常只需要恢复任何保存寄存器并恢复堆栈指针,以便“释放”函数为自己使用而保留的任何内存。
序言/尾声中可能使用的确切机制取决于 CPU 体系结构、平台标准、函数的参数和返回值以及函数可能使用的特定调用约定。
The epilogue and prologue of a function are simply the set of instructions that 'set up' the context for the function when it's called and clean up when it returns.
The prologue typically performs such tasks as:
The epilogue generally only needs to restore any save registers and restore the stack pointer such that any memory reserved by the function for its own use is 'freed'.
The exact mechanisms that might be used in a prologue/epilogue are Dependant on the CPU architecture, the platforms standard, the arguments and return values of the function, and the particular calling convention the function might be using.
维基百科 FTW: https://en.wikipedia.org/wiki/Function_prologue
这似乎解释了在我看来,这相当不错。如果有任何不清楚的地方,请告诉我,我可以尝试解决问题。
Wikipedia FTW: https://en.wikipedia.org/wiki/Function_prologue
This seemed to explain it fairly well, in my opinion. If there is anything that is unclear, let me know and I can try and clear things up.