If I have a call procedure on asm:
push ebp
mov ebp esp
sub ebp, 8
Can I assume right now that both [ebp-4] and [ebp-8] are initialized to zero, or can they have random values?
If I have a call procedure on asm:
push ebp
mov ebp esp
sub ebp, 8
Can I assume right now that both [ebp-4] and [ebp-8] are initialized to zero, or can they have random values?
you should never depend on this as this might be depending on the implementation. to be in a predictable state, always init a register or memory cell with a certain value.
They will definitely have random values unless you explicitly initialize them.
They will have whatever value was in that memory before, which is unlikely to be 0
. This is not 'random' per se - indeed, it's probably somewhat predictable; this usually doesn't do any good, but just don't get any clever ideas about using it for a RNG :)
Remember, all you did in that code was:
The CPU won't read anything into this beyond that, unless you tell it to. That is the essence of assembler. Moreover, when used in normal arithmetic, ESP is not special cased at all - it's just a number.