Reputation: 57
Could someone help explain this code to me?
.text:00401270 ; int __cdecl main(int argc,const char **argv,const char *envp)
.text:00401270 Dst = byte ptr −80h
...More Code...
.text:00401270 push ebp
.text:00401271 mov ebp, esp
.text:00401273 sub esp, 80h
.text:00401293 push 80h
.text:00401298 push 0
.text:0040129A lea eax, [ebp+Dst]
.text:0040129D push eax
.text:0040129E call _memset
I get that a buffer of size 0x80 is created and filled with the value 0 when _memset is called. However I do not understand the usage of the pointer [ebp+Dst]. Why is the base pointer (ebp) involved at all? Additionally, why is Dst set to a negative value?
Upvotes: 1
Views: 2564
Reputation: 38422
it's ebp, not edp; it is being used to access the stack where esp pointed before the 80-byte buffer is placed on it. then Dst, -80, is added, which points to the start (low byte) of the buffer. there is no need to do it this way in assembly, these constructs are the compiler's rendition of the C code.
Upvotes: 2