//-----------------------------------------------------------------
//	prodtest.cpp
//
//	This C++ program is for testing a recursive implementation 
//	of an external function written in assembly language which
//	computes the product of two unsigned integers, but without
//	using the processor's multiplication circuitry.  A pair of
//	unsigned integers should be entered on the command-line.  
//
//	 compile using:  $ g++ prodtest.cpp product.o -o prodtest
//	 execute using:  $ ./prodtest integer1 integer2
//
//	programmer: ALLAN CRUSE
//	written on: 11 APR 2007
//-----------------------------------------------------------------

#include <stdio.h>	// for printf(), fprintf()
#include <stdlib.h>	// for atoi()

extern "C" unsigned int prod( unsigned int x, unsigned int y );

int main( int argc, char *argv[] )
{
	unsigned int	x, y, z;	

	if ( argc < 3 ) 
		{
		fprintf( stderr, "two arguments are required\n" );
		return	-1;
		}

	x = atoi( argv[1] );
	y = atoi( argv[2] );
	if (( x < 0 )||( y < 0 )) 
		{
		fprintf( stderr, "arguments must be unsigned integers\n" );
		return -2;
		} 

	z = prod( x, y );

	printf( "The product of %u and %u is %u \n", x, y, z );
}