incorrect. the first argument is only esp+4 until it enters the call. as soon as the call is entered and push ebp takes place instantly the first argument is now esp+8 not esp+4. esp+0(or esp since its +0) = return address esp+4 = function base address(from the push ebp) esp+8 = first argument in a 32bit architecture
before executing anything, we have esp pointing towards the return address. once we push ebp, esp now decrements by 4, i.e. esp = esp - 4, and after that, ebp = esp. so, the current scenario is such that: 1. esp is pointing towards the address in the stack where the original value of ebp is stored, 2. esp+4 is where the return address is stored 3. esp+8 is where the first argument of the function is. (The stack grows downwards, hence as you insert elements in the stack, the pointer is decremented by 4 at each step)
Thank u sir!
incorrect. the first argument is only esp+4 until it enters the call. as soon as the call is entered and push ebp takes place instantly the first argument is now esp+8 not esp+4. esp+0(or esp since its +0) = return address esp+4 = function base address(from the push ebp) esp+8 = first argument in a 32bit architecture
He does exactly the same at @34:51, watch the complete video before blurting out in comment section
before executing anything, we have esp pointing towards the return address. once we push ebp, esp now decrements by 4, i.e. esp = esp - 4, and after that, ebp = esp. so, the current scenario is such that:
1. esp is pointing towards the address in the stack where the original value of ebp is stored,
2. esp+4 is where the return address is stored
3. esp+8 is where the first argument of the function is.
(The stack grows downwards, hence as you insert elements in the stack, the pointer is decremented by 4 at each step)