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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#include "../src/determine_slotting.c"
#include <stdio.h>
#define EXPAND(__octaword) \
__octaword.instr[3].slot, \
__octaword.instr[2].slot, \
__octaword.instr[1].slot, \
__octaword.instr[0].slot
#define PRINT_DEBUG(__rule, __start, __end, __check) printf("%s: %c%c%c%c -> %c%c%c%c (%c%c%c%c)\n", __rule, __start, __end, __check)
#define RULE(__octaword, _3, _2, _1, _0) \
__octaword.instr[3].slot = _3; \
__octaword.instr[2].slot = _2; \
__octaword.instr[1].slot = _1; \
__octaword.instr[0].slot = _0
#define DEFINE(__start3, __start2, __start1, __start0, __end3, __end2, __end1, __end0, __rule) \
{ \
.start.instr[3].slot = SLOT_##__start3, \
.start.instr[2].slot = SLOT_##__start2, \
.start.instr[1].slot = SLOT_##__start1, \
.start.instr[0].slot = SLOT_##__start0, \
.end.instr[3].slot = SLOT_##__end3, \
.end.instr[2].slot = SLOT_##__end2, \
.end.instr[1].slot = SLOT_##__end1, \
.end.instr[0].slot = SLOT_##__end0, \
.rule = __rule \
}
struct {
struct octaword_t start;
struct octaword_t end;
const char rule[8];
} test[] = {
DEFINE(U, U, U, U, U, U, U, U, "1A "),
DEFINE(L, L, L, L, L, L, L, L, "1B "),
DEFINE(E, U, U, U, L, U, U, U, "2A "),
DEFINE(U, E, U, U, U, L, U, U, "2A "),
DEFINE(U, U, E, U, U, U, L, U, "2A "),
DEFINE(U, U, U, E, U, U, U, L, "2A "),
DEFINE(L, U, U, U, L, U, U, U, "2A "),
DEFINE(U, L, U, U, U, L, U, U, "2A "),
DEFINE(U, U, L, U, U, U, L, U, "2A "),
DEFINE(U, U, U, L, U, U, U, L, "2A "),
DEFINE(E, L, L, L, U, L, L, L, "2B "),
DEFINE(L, E, L, L, L, U, L, L, "2B "),
DEFINE(L, L, E, L, L, L, U, L, "2B "),
DEFINE(L, L, L, E, L, L, L, U, "2B "),
DEFINE(U, L, L, L, U, L, L, L, "2B "),
DEFINE(L, U, L, L, L, U, L, L, "2B "),
DEFINE(L, L, U, L, L, L, U, L, "2B "),
DEFINE(L, L, L, U, L, L, L, U, "2B "),
DEFINE(U, U, E, E, U, U, L, L, "3A "),
DEFINE(U, U, E, L, U, U, L, L, "3A "),
DEFINE(U, U, L, E, U, U, L, L, "3A "),
DEFINE(U, E, U, E, U, L, U, L, "3A "),
DEFINE(U, E, U, L, U, L, U, L, "3A "),
DEFINE(U, L, U, E, U, L, U, L, "3A "),
DEFINE(U, E, E, U, U, L, L, U, "3A "),
DEFINE(U, E, L, U, U, L, L, U, "3A "),
DEFINE(U, L, E, U, U, L, L, U, "3A "),
DEFINE(E, U, U, E, L, U, U, L, "3A "),
DEFINE(E, U, U, L, L, U, U, L, "3A "),
DEFINE(L, U, U, E, L, U, U, L, "3A "),
DEFINE(E, U, E, U, L, U, L, U, "3A "),
DEFINE(L, U, E, U, L, U, L, U, "3A "),
DEFINE(E, U, L, U, L, U, L, U, "3A "),
DEFINE(E, E, U, U, L, L, U, U, "3A "),
DEFINE(E, L, U, U, L, L, U, U, "3A "),
DEFINE(L, E, U, U, L, L, U, U, "3A "),
DEFINE(L, L, E, E, L, L, U, U, "3B "),
DEFINE(L, L, E, U, L, L, U, U, "3B "),
DEFINE(L, L, U, E, L, L, U, U, "3B "),
DEFINE(L, E, L, E, L, U, L, U, "3B "),
DEFINE(L, U, L, E, L, U, L, U, "3B "),
DEFINE(L, E, L, U, L, U, L, U, "3B "),
DEFINE(L, E, E, L, L, U, U, L, "3B "),
DEFINE(L, U, E, L, L, U, U, L, "3B "),
DEFINE(L, E, U, L, L, U, U, L, "3B "),
DEFINE(E, L, L, E, U, L, L, U, "3B "),
DEFINE(E, L, L, U, U, L, L, U, "3B "),
DEFINE(U, L, L, E, U, L, L, U, "3B "),
DEFINE(E, L, E, L, U, L, U, L, "3B "),
DEFINE(E, L, U, L, U, L, U, L, "3B "),
DEFINE(U, L, E, L, U, L, U, L, "3B "),
DEFINE(E, E, L, L, U, U, L, L, "3B "),
DEFINE(E, U, L, L, U, U, L, L, "3B "),
DEFINE(U, E, L, L, U, U, L, L, "3B "),
DEFINE(U, U, L, L, U, U, L, L, "3AB "),
DEFINE(U, L, U, L, U, L, U, L, "3AB "),
DEFINE(U, L, L, U, U, L, L, U, "3AB "),
DEFINE(L, U, U, L, L, U, U, L, "3AB "),
DEFINE(L, U, L, U, L, U, L, U, "3AB "),
DEFINE(L, L, U, U, L, L, U, U, "3AB "),
DEFINE(E, L, E, U, U, L, L, U, "4AB "),
DEFINE(E, L, U, E, U, L, U, L, "4AB "),
DEFINE(E, U, E, L, L, U, U, L, "4AB "),
DEFINE(E, U, L, E, L, U, L, U, "4AB "),
DEFINE(U, E, E, L, U, L, U, L, "4AB "),
DEFINE(U, E, L, E, U, L, L, U, "4AB "),
DEFINE(L, E, E, U, L, U, L, U, "4AB "),
DEFINE(L, E, U, E, L, U, U, L, "4AB "),
DEFINE(E, U, E, E, L, U, L, U, "4AD "),
DEFINE(U, E, E, E, U, L, U, L, "4AD "),
DEFINE(E, L, E, E, U, L, U, L, "4BD "),
DEFINE(L, E, E, E, L, U, L, U, "4BD "),
DEFINE(L, U, E, E, L, U, L, U, "4ABD"),
DEFINE(U, L, E, E, U, L, U, L, "4ABD"),
DEFINE(E, E, E, U, U, L, L, U, "4CA "),
DEFINE(E, E, U, E, U, L, U, L, "4CA "),
DEFINE(E, E, L, E, U, L, L, U, "4CB "),
DEFINE(E, E, E, L, U, L, U, L, "4CB "),
DEFINE(E, E, U, L, U, L, U, L, "4CAB"),
DEFINE(E, E, L, U, U, L, L, U, "4CAB"),
DEFINE(E, E, E, E, U, L, U, L, "4CD "),
};
int main() {
struct octaword_t check;
const char * fail = "FAILURE, -> ";
const char * succ = " ";
const char * which;
int i;
for (i = 0; i < sizeof(test) / sizeof(test[0]); i++) {
check = determine_slotting(test[i].start);
if ((test[i].end.instr[3].slot != check.instr[3].slot)
|| (test[i].end.instr[2].slot != check.instr[2].slot)
|| (test[i].end.instr[1].slot != check.instr[1].slot)
|| (test[i].end.instr[0].slot != check.instr[0].slot))
{
which = fail;
} else {
which = succ;
}
printf("%s", which);
PRINT_DEBUG(test[i].rule, EXPAND(test[i].start), EXPAND(test[i].end), EXPAND(check));
}
#if 0
/* A.1 Rule 1 - Four of a Kind */
RULE(start, SLOT_U, SLOT_U, SLOT_U, SLOT_U);
end = determine_slotting(start);
PRINT_DEBUG("Rule 1A", EXPAND(start), EXPAND(end));
RULE(start, SLOT_L, SLOT_L, SLOT_L, SLOT_L);
end = determine_slotting(start);
PRINT_DEBUG("Rule 1B", EXPAND(start), EXPAND(end));
/* A.2 Rule 2 - Three of a Kind */
#endif
return 0;
}
|