gpt4 book ai didi

assembly - 为什么这些寄存器被压入堆栈?

转载 作者:行者123 更新时间:2023-12-04 18:48:37 25 4
gpt4 key购买 nike

push    %ebp
push %esp, %ebp
push edi
push esi
push ebx

(x86 32 位 Linux)

为什么这些寄存器被压入堆栈?
出于某种原因迁移......?
但是,为什么只推送 'edi' 'esi' 'ebx' ?

最佳答案

它是 x86 代码生成器的 gcc 实现细节。令人惊讶的是很难找到好的文档,我确实找到了 this page这是非常准确的。关键部分:

after ret instruction:

%eip contains return address
%esp points at arguments pushed by caller
called function may have trashed arguments
%eax contains return value (or trash if function is void)
%ecx, %edx may be trashed
%ebp, %ebx, %esi, %edi must contain contents from time of call


“必须包含调用时的内容”短语解释了为什么它们在函数序言中被插入并在尾声中再次弹出。

关于assembly - 为什么这些寄存器被压入堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9797335/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com