#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <iostream>
using namespace std;
int ifo_add(int a,int b)
{
__asm{
mov eax,a
add eax,b
jo overflow
xor eax,eax
jmp no_overflow
overflow:
mov eax,1
no_overflow:
}
}
int main() {
int a,b;
a= 1;b= 2;printf("%11d+(%2d) %d\n",a,b,ifo_add(a,b));
a= -1;b=-2;printf("%11d+(%2d) %d\n",a,b,ifo_add(a,b));
a= 2147483647;b= 1;printf("%11d+(%2d) %d\n",a,b,ifo_add(a,b));
a=-2147483647;b=-1;printf("%11d+(%2d) %d\n",a,b,ifo_add(a,b));
a=-2147483647;b=-2;printf("%11d+(%2d) %d\n",a,b,ifo_add(a,b));
system("pause");
return 0;
}