Why are these registers being pushed onto the stack?

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

      

(x86 32-bit Linux)

Why are these registers being pushed onto the stack?
Migration for some reason ...?
But why is only "edi" 'esi' 'ebx' pressed?

+3


source to share


1 answer


This is a gcc implementation for an x86 code generator. Surprisingly hard to find good docs for this, I found this page to be pretty accurate. Main part:

after the ret statement:

%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 

      



the phrase "should contain content from the time of the conversation" explains why they are inserted in the function prologue and pushed again in the epilogue.

+5


source







All Articles