Hi Sardar,
here is what i found.
74: c = 128;
004010F8 mov byte ptr [ebp-4],80h
75: i = (unsigned int)c;
004010FC movsx eax,byte ptr [ebp-4]
00401100 mov dword ptr [ebp-8],eax
76: j = (unsigned char)c;
00401103 mov ecx,dword ptr [ebp-4]
00401106 and ecx,0FFh
0040110C mov dword ptr [ebp-0Ch],ecx
77:
78: printf( "%d : %d : %u : %d : %d : %d : %d \n",
79: c, (unsigned int)c, (unsigned int)c, (unsignedchar)c,
80: i, j, (unsigned int)128 );
0040110F push 80h
00401114 mov edx,dword ptr [ebp-0Ch]
00401117 push edx
00401118 mov eax,dword ptr [ebp-8]
0040111B push eax
0040111C mov ecx,dword ptr [ebp-4]
0040111F and ecx,0FFh
00401125 push ecx
00401126 movsx edx,byte ptr [ebp-4]
0040112A push edx
0040112B movsx eax,byte ptr [ebp-4]
0040112F push eax
00401130 movsx ecx,byte ptr [ebp-4]
00401134 push ecx
00401135 push offset string "%d : %d : %u : %d : %d : %d : %d"...
(00420f84)
0040113A call printf (00401220)
0040113F add esp,20h
If you look at this, when ever we use (unsigned int) if copy only a
byte, but for (unsigned char) it copy a dword. So in case of (unsigned
int) the rest of the 3 bytes remains uninitializied. Right now i dont
have reasoning for this, but might help to.
I tried initializing i to 0. but still doesn't work.
tell me what u think of this.