
/*----------------------------------------------------------------------*/
/*                           MulDiv.cpp                                 */
/* Authored By : H.P.Kasmaei                                            */
/* Last Update : November 9, 2007                                       */
/* http://www.hpkclasses.ir/                                            */
/*----------------------------------------------------------------------*/
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>


/*----------------------------------------------------------------------*/
/*                              M A I N                                 */
/*----------------------------------------------------------------------*/

void main ()
{

   short int a,b;
   unsigned short int high_mul, low_mul;
   short int quotient, remainder;
   long x;

   cout<<"Input First Number:";
   cin>>a;
   cout<<endl<<"Input Second Number:";
   cin>>b;

   asm {
      mov ax,a
      mov bx,b

      imul bx

      mov low_mul,ax
      mov high_mul,dx

      mov ax,a
      mov bx,b
      cwd
      idiv bx
      mov quotient, ax
      mov remainder, dx
   }

   x=high_mul;
   x<<=16;
   x+=low_mul;

   cout<<"\nMultiply Result="<<x<<endl;
   cout<<"Quotient ="<< quotient <<endl;
   cout<<"Remainder ="<< remainder <<endl;
}



