// @topic W130110 C++ program that checks for multiplication overflow
// @brief using in-line assembly (__asm) section

// main_sm_calc.cpp

#include <iostream>
#include <cstdlib>

/*unsigned short*/ int one = 0x2000;
/*unsigned short*/ int two = 0x0100;
/*unsigned short*/ int result;

/*unsigned short*/ int one32 = 0x2000; //0000;
/*unsigned short*/ int two32 = 0x0100; //0000;

int main()
{
    while (std::cin) {
        std::cout << "one32: "; std::cin >> std::hex >> one32;
        std::cout << "two32: "; std::cin >> std::hex >> two32;
        //result = one * two;
        result = one32 * two32;
        __asm {
            jo result_overflow
            jmp result_good
        }
    result_overflow:
        std::cout << "overflow in " << std::dec << one32 << "*" << two32 << "=" << result << " " << std::hex << result << "\n";
        //system("pause");
        //return 1;
        continue;
    result_good:
        std::cout << "everything okay in " << std::dec << one32 << "*" << two32 << "=" << result << " " << std::hex << result << "\n";
        //system("pause");
        //return 0;
        continue;
    }//while
}