11 int mul1(int x, int y)
16 int mul2(int x, int y, int z)
21 int mul3(int x, int y, int z)
26 int sub0(int x, int y, int z)
31 int sub1(int x, int y)
33 return x - (y * CONST);
36 int sub2(int x, int y)
41 int sub3(int x, int y)
50 int cmp1(int x, int y) {
54 int cmp2(int x, int y) {
58 int cmp3(int x, int y) {
62 int cmp4(int x, int y) {
66 int cmp5(int x, int y, int z) {
67 return x + z == z + y;
70 int cmp6(int x, int y, int z) {
71 return x + z != y + z;
74 int cmp7(int x, int y, int z) {
75 return x - z == y - z;
78 int cmp8(int x, int y, int z) {
90 int and1(int a, int b) {
94 int and2(int a, int b) {
95 return (a|b) & ~(a&b);
106 int shrs1(unsigned x) {
110 int demorgan1(int a, int b) {
114 int demorgan2(int a, int b) {
118 int eor1(int a, int b) {
124 #define TU(func,x,expect) \
125 printf("%s(%d) = %d (should be %d)\n", #func, x, func(x), expect);
126 #define TB(func,x,y,expect) \
127 printf("%s(%d,%d) = %d (should be %d)\n", #func, x, y, func(x,y), expect);
128 #define TT(func,x,y,z,expect) \
129 printf("%s(%d,%d,%d) = %d (should be %d)\n", #func, x, y, z, func(x,y,z), expect);
133 TT(mul2, 9, 2, 5, 27);
134 TT(mul3, 5, 2, 9, 27);
135 TT(sub0, 42, 17, 59, 84);
136 TB(sub1, 23, 17, -691);
137 TB(sub2, 42, 17, 59);
138 TB(sub3, 42, 17, -59);
144 TT(cmp5, 42, 17, -4, 0);
145 TT(cmp6, 42, 17, -4, 1);
146 TT(cmp7, 42, 17, -4, 0);
147 TT(cmp8, 42, 17, -4, 1);
150 TB(and1, 42, 17, 42);
151 TB(and2, 42, 17, 42^17);
155 TB(demorgan1, 42, 17, ~(42|17));
156 TB(demorgan2, 42, 17, ~(42&17));
157 TB(eor1, 42, 17, 42&~17);