_text segment byte public 'code'
assume cs:_text
_save proc near
push ebp
mov ebp,esp
mov esi,[ebp+8]
mov eax,[ebp+4]
mov [esi],eax
pop ebp
mov eax,0
ret
_save endp
_resume proc near
push ebp
mov ebp,esp
mov esi,[ebp+8]
mov eax,[esi]
mov [ebp+4],eax
pop ebp
mov eax,1
ret
_resume endp
_text ends
end
*****************************.cpp文件***************************************************
#include<stdio.h>
extern "C" int save(long * s);
extern "C" int resume(long * s);
void main(){
long sp;
printf("Both the code in the if and the code in the else will be exe!!!\n");
if(save(&sp)){
printf("return form the if\n");
return;
}else{
printf("return form the else\n");
resume(&sp);
}
return;
}