c++ - Purpose of rep stos assembly command in this code from Visual Studio -
this question has answer here:
take @ following code:
void f() { }
i compiled in visual studio 2013, debug, 32-bit mode , looked @ dissassembly.
void f() { 00304cb0 push ebp 00304cb1 mov ebp,esp 00304cb3 sub esp,0c0h 00304cb9 push ebx 00304cba push esi 00304cbb push edi 00304cbc lea edi,[ebp-0c0h] 00304cc2 mov ecx,30h 00304cc7 mov eax,0cccccccch 00304ccc rep stos dword ptr es:[edi] } 00304cce pop edi 00304ccf pop esi 00304cd0 pop ebx 00304cd1 mov esp,ebp 00304cd3 pop ebp 00304cd4 ret
what purpose of rep stos instruction?
i'm curious.
the rep stos
instruction writes value in eax
starting @ address pointed edi
(your local stack in case), ecx
(0x30) times. value in eax
0xcccccccc
magic number chosen microsoft indicate uninitialized memory. debugger catch if try , dereference pointer memory. diagnostic checking enabled /rtcu
option.
now might ask why, empty function body, memory reserved on local stack. because have edit , continue turned on /zi
option. compiler setting aside space in case decide use in debug session.
Comments
Post a Comment