English it's not my first language so if i spell wrong some words sorry. I've some trouble with the stack, all codes that i will put here works perfectly.
This code for example it's easy and i understand the stack of it.
.globl f f: push %ebx movl 8(%esp), %eax movl 12(%esp), %ebx addl %ebx, %eax ret
STACK
------- VAR Y --> ESP + 12 ------- VAR X --> ESP + 8 ------- RET --> RETURN ------- %EBX --> %ESP -------
But with this code i've some t
.code32 .globl f f: pushl %ebx movl 8(%esp), %ebx subl $8, %esp # Creo posto nella stack per i parametri movl $1, (%esp) movl $2, 4(%esp) call a addl %ebx, %eax addl $8, %esp #Tolgo posto nella stack popl %ebx ret
The code work perfectly but i've many question about that?. Where is %ebx and ret on stack now?
Code of asm transalted in c:
int f(int x){ return x + g(y,z); }
And this is the stack that i've made
STACK
-------- 8(%esp) --> x parameter of function f -------- 4(%esp) --> z parameter of function g -------- (%esp) --> y parameter of funcion g --------
So the question now is where are %ebx and ret on this stack now?