div.c 1.5 KB
#include <rmon.h>
#include "corefunc.h"

div()
{
	long long a, b, c, d;
	int numFailures = 0;

	a = 0x0555555555555555LL;
	b = 0x0800000000000000LL;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, 0x2aaaaaaaaaaaaabLL);
	numFailures += check_equal( d, 1);

#ifdef LATER
	b = 0x5555555555555555LL;
	a = 0x8000000000000000LL;
	c = a%b;
	d = a/b;
	osSyncPrintf("div 1\n");
	numFailures += check_equal(c, 0xd555555555555555LL);
	numFailures += check_equal( d, -1);

	a = 0xfffffffffffffffeLL;
	b = 0x5555555555555555LL;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, 1);
	numFailures += check_equal( d, 0xd555555555555556LL);
#endif

	a = 0x8000000000000000LL;
	b = 0x8000000000000000LL;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, 0);
	numFailures += check_equal( d, 1);

	a = 0x5555555555555555LL;
	b = 0x0;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, 0);
	numFailures += check_equal( d, 0);

	a = 0x5555555555555555LL;
	b = 0x5555555555555555LL;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, 0);
	numFailures += check_equal( d, 1);

	a = 0x5555555555555555LL;
	b = 0x6666666666666666LL;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, 0x1111111111111111LL);
	numFailures += check_equal( d, 1);

	a = 0x6666666666666666LL;
	b = 0x5555555555555555LL;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, b);
	numFailures += check_equal( d, 0);

	a = 4;
	b = 0x7fffffffffffffffLL;
	c = b%a;
	d = b/a;
	numFailures += check_equal(c, 3);
	numFailures += check_equal( d, 0x1fffffffffffffffLL);
	return(numFailures);
}