ESP Calling sequence. caller Parameters (in reverse order) ESP Calling sequence.

Post on 01-Apr-2015

224 views 0 download

transcript

ESP

Calling sequence

caller Parameters (in reverse order)ESP

Calling sequence

caller Parameters (in reverse order)

ESP

Calling sequence

Return address (next instruction)

caller

calleenew EBP

parameters

old EBPESP

Calling sequence

Return address (next instruction)

caller

callee

saved registers

parameters

old EBPnew EBP

ESP

Calling sequence

Return address (next instruction)

caller

saved registers

parameters

old EBP

local variables

calleenew EBP

ESP

Calling sequence

Return address (next instruction)

caller

saved registers

parameters

old EBP

local variables

temporary storage

calleenew EBP

ESP

Stack frame of current subprogram

Calling sequence

Return address (next instruction)

caller

saved registers

parameters

old EBP

local variables

temporary storage

Working

calleenew EBP

ESP

Return address (next instruction)

Stack frame of current subprogram

caller

saved registers

parameters

old EBP

local variables

temporary storage

Working

calleenew EBP

ESP

Return address (next instruction)

Stack frame of current subprogram

caller

saved registers

parameters

old EBP

local variables

temporary storage

Working

calleenew EBP

ESP

Stack frame of current subprogram

Return address (next instruction)

caller

saved registers

parameters

old EBP

local variables

temporary storage

Working

calleenew EBP

ESP

Stack frame of current subprogram

Return address (next instruction)

caller

saved registers

parameters

old EBPcalleenew EBP

ESP

Return sequence

return value (if any) stored in EAX

Return address (next instruction)

caller parameters

old EBPcalleenew EBP ESP

Return sequence

Registers restoredreturn value (if any) stored in EAX

Return address (next instruction)

caller parameters

ESP

Return sequence

Registers restored EBP restored

return value (if any) stored in EAX

Return address (next instruction)

caller parametersESP

return value (if any) stored in EAXcontrol back to caller – at return address

callerESP

Return sequence

return value (if any) stored in EAX

caller

ESP

Working

caller

ESP

Working

callerESP

Working