-
add esp, x // dealloc. stack
// space, x bytes
// were allocated
// (3-6 byte inst)
pop ebp // restore caller's
// frame ptr (1 byte)
ret // return (1 byte)
-
mov esp, ebp // dealloc. stack
// space, any
// number of bytes
// allocated on the
// stack (2 byte
// instruction)
pop ebp // restore caller's
// frame ptr (1
// byte)
ret // return (1 byte)
-
leave // dealloc. stack
// frame & restores
// old frame ptr
// (1 byte)
ret // return (1 byte)
From 2) and 3), we see that stack frame deallocation could be done with 2 to 4 bytes worth of instructions. So we need to replace some more instructions in addition to the stack frame deallocation instructions to hold a