div.c
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#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);
}