没代码,瞎猜~
一般返回值在 EAX 寄存器
没将返回值写到eax中,但调用者依旧去读取eax的值,谁也不知道是个啥~~
下面是一个例子,和你的代码结构差不多~
看一下汇编,就知道 EAX 寄存器的作用了
c代码
#include
#define false 0
int GetData(int flg)
{
while(false)
if(flg)
return(1);
else
return(-1);
}
void main(){
int retval;
retval = GetData(false);
printf("%d",retval);
getchar();
}
对应的汇编代码
int GetData(int flg)
{
push ebp
mov ebp,esp
sub esp,0C0h
push ebx
push esi
push edi
lea edi,[ebp-0C0h]
mov ecx,30h
mov eax,0CCCCCCCCh
rep stos dword ptr es:[edi]
while(false)
xor eax,eax
je GetData+36h (4113D6h)
if(flg)
xor eax,eax
je GetData+2Fh (4113CFh)
return(1);
mov eax,1 ;在 EAX 中写入返回值:1
jmp GetData+36h (4113D6h)
else
jmp GetData+34h (4113D4h)
return(-1);
or eax,0FFFFFFFFh ;在 EAX 中写入返回值:-1
jmp GetData+36h (4113D6h)
jmp GetData+1Eh (4113BEh)
}
void main(){
push ebp
mov ebp,esp
sub esp,0CCh
push ebx
push esi
push edi
lea edi,[ebp-0CCh]
mov ecx,33h
mov eax,0CCCCCCCCh
rep stos dword ptr es:[edi]
int retval;
retval = GetData(false);
call @ILT+225(_GetData) (4110E6h)
mov dword ptr [ret],eax ;将 eax 的返回值写到 内存中的变量
printf("%d",retval);
mov esi,esp
mov eax,dword ptr [ret]
push eax
push offset string "%d" (41573Ch)
call dword ptr [__imp__printf (4182B4h)]
add esp,8
cmp esi,esp
call @ILT+300(__RTC_CheckEsp) (411131h)
getchar();
mov esi,esp
call dword ptr [__imp__getchar (4182B8h)]
cmp esi,esp
call @ILT+300(__RTC_CheckEsp) (411131h)
}