.text:004010A0 ; =============== S U B R O U T I N E =======================================
.text:004010A0
.text:004010A0
.text:004010A0 sub_4010A0      proc near              ; CODE XREF: _main+1Cp
.text:004010A0                                        ; _main:loc_4014ECp
.text:004010A0                push    ebx
.text:004010A1                push    esi
.text:004010A2                push    edi
.text:004010A3                push    offset Format  ; "\n\nTo Continue, press INSERT\n"
.text:004010A8                call    ds:printf
.text:004010AE                mov    ebx, ds:GetAsyncKeyState
.text:004010B4                mov    edi, ds:Sleep
.text:004010BA                add    esp, 4
.text:004010BD                xor    esi, esi
.text:004010BF                nop
.text:004010C0
.text:004010C0 loc_4010C0:                            ; CODE XREF: sub_4010A0+36j
.text:004010C0                push    2Dh            ; vKey
.text:004010C2                call    ebx ; GetAsyncKeyState
.text:004010C4                test    al, 1
.text:004010C6                jz      short loc_4010CD
.text:004010C8                mov    esi, 1
.text:004010CD
.text:004010CD loc_4010CD:                            ; CODE XREF: sub_4010A0+26j
.text:004010CD                push    0C8h            ; dwMilliseconds
.text:004010D2                call    edi ; Sleep
.text:004010D4                test    esi, esi


signed int __cdecl sub_4010A0()
{
  signed int v0; // esi@1

  printf("\n\nTo Continue, press INSERT\n");
  v0 = 0;
  do
  {
    if ( GetAsyncKeyState(45) & 1 )
      v0 = 1;
    Sleep(0xC8u);
  }
  while ( !v0 );
  return 1;
}



above is the psuedocode for the assembly code above it! im curious as to WHERE the unsigned int variable v0 is declared and initalized in the above assembly code! for some reason i cant seem to find it!! -thx
Posted on 2010-11-14 09:23:52 by maybnxtseasn
It's here

.text:004010C8                mov    esi, 1
Posted on 2010-11-14 09:45:45 by JimmyClif
i just don't see how it's declared there ^_^ i can see it's recieving the value one...but i don't see how this is the variables declaration...!
Posted on 2010-11-14 11:41:15 by maybnxtseasn
.text:004010BD                 xor     esi, esi


is the same as:

v0 ^= v0;


which is an optimized form of v0=0;

in otherwords, these two instructions are the same except the xor version is smaller:

xor esi, esi ; v0 ^= v0
mov esi, 0x00000000 ; v0 = 0


Posted on 2010-11-14 11:49:49 by Synfire

i just don't see how it's declared there ^_^ i can see it's recieving the value one...but i don't see how this is the variables declaration...!


The variable is mapped directly to the esi register. An actual variable in memory is never declared, because the compiler has optimized it away.
Local function variables would normally be declared as part of the stackframe. But as you might notice, there is no stack frame in the entire function. All local variables have been optimized away, and only registers are used inside the code.
Posted on 2010-11-15 07:32:31 by Scali