4 #define exec_op glue(exec_, OP)
5 #define exec_opl glue(glue(exec_, OP), l)
6 #define exec_opw glue(glue(exec_, OP), w)
7 #define exec_opb glue(glue(exec_, OP), b)
9 #define EXECOP2(size, res, s1, flags) \
12 stringify(OP) size " %" size "2, %" size "0\n\t" \
15 : "=q" (res), "=g" (flags)\
16 : "q" (s1), "0" (res), "1" (flags));
18 #define EXECOP1(size, res, flags) \
21 stringify(OP) size " %" size "0\n\t" \
24 : "=q" (res), "=g" (flags)\
25 : "0" (res), "1" (flags));
28 inline void exec_opl(int s0
, int s1
, int iflags
)
33 EXECOP1("", res
, flags
);
35 printf("%-6s A=%08x R=%08x CCIN=%04x CC=%04x\n",
36 stringify(OP
) "l", s0
, res
, iflags
, flags
& CC_MASK
);
38 printf("%08x %04x %04x\n",
39 res
, iflags
, flags
& CC_MASK
);
42 inline void exec_opw(int s0
, int s1
, int iflags
)
47 EXECOP1("w", res
, flags
);
49 printf("%-6s A=%08x R=%08x CCIN=%04x CC=%04x\n",
50 stringify(OP
) "w", s0
, res
, iflags
, flags
& CC_MASK
);
52 printf("%08x %04x %04x\n",
53 res
, iflags
, flags
& CC_MASK
);
56 inline void exec_opb(int s0
, int s1
, int iflags
)
61 EXECOP1("b", res
, flags
);
63 printf("%-6s A=%08x R=%08x CCIN=%04x CC=%04x\n",
64 stringify(OP
) "b", s0
, res
, iflags
, flags
& CC_MASK
);
66 printf("%08x %04x %04x\n",
67 res
, iflags
, flags
& CC_MASK
);
71 inline void exec_opl(int s0
, int s1
, int iflags
)
76 EXECOP2("", res
, s1
, flags
);
78 printf("%-6s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
79 stringify(OP
) "l", s0
, s1
, res
, iflags
, flags
& CC_MASK
);
81 printf("%08x %04x %04x\n",
82 res
, iflags
, flags
& CC_MASK
);
85 inline void exec_opw(int s0
, int s1
, int iflags
)
90 EXECOP2("w", res
, s1
, flags
);
92 printf("%-6s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
93 stringify(OP
) "w", s0
, s1
, res
, iflags
, flags
& CC_MASK
);
95 printf("%08x %04x %04x\n",
96 res
, iflags
, flags
& CC_MASK
);
99 inline void exec_opb(int s0
, int s1
, int iflags
)
104 EXECOP2("b", res
, s1
, flags
);
106 printf("%-6s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
107 stringify(OP
) "b", s0
, s1
, res
, iflags
, flags
& CC_MASK
);
109 printf("%08x %04x %04x\n",
110 res
, iflags
, flags
& CC_MASK
);
114 void exec_op(int s0
, int s1
)
117 int o
,s
,z
,a
,c
,p
,flags_in
;
118 for (o
= 0; o
< 2; o
++) {
119 for (s
= 0; s
< 2; s
++) {
120 for (z
= 0; z
< 2; z
++) {
121 for (a
= 0; a
< 2; a
++) {
122 for (c
= 0; c
< 2; c
++) {
123 for (p
= 0; p
< 2; p
++) {
125 flags_in
= (o
? CC_O
: 0)
131 exec_opl(s0
, s1
, flags_in
);
132 exec_opw(s0
, s1
, flags_in
);
133 exec_opb(s0
, s1
, flags_in
);
139 exec_opl(s0
, s1
, CC_C
);
140 exec_opw(s0
, s1
, CC_C
);
141 exec_opb(s0
, s1
, CC_C
);
145 void glue(test_
, OP
)(void)
149 static unsigned int val
[NVALS
]
150 = { 0x00, 0x01, 0x02, 0x03,
152 0x7E, 0x7F, 0x80, 0x81, 0x82,
154 0xFC, 0xFD, 0xFE, 0xFF,
156 0xFF00, 0xFF01, 0xFF02, 0xFF03,
157 0xFF3F, 0xFF40, 0xFF41,
158 0xFF7E, 0xFF7F, 0xFF80, 0xFF81, 0xFF82,
159 0xFFBF, 0xFFC0, 0xFFC1,
160 0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF,
162 0xFFFFFF00, 0xFFFFFF01, 0xFFFFFF02, 0xFFFFFF03,
163 0xFFFFFF3F, 0xFFFFFF40, 0xFFFFFF41,
164 0xFFFFFF7E, 0xFFFFFF7F, 0xFFFFFF80, 0xFFFFFF81, 0xFFFFFF82,
165 0xFFFFFFBF, 0xFFFFFFC0, 0xFFFFFFC1,
166 0xFFFFFFFC, 0xFFFFFFFD, 0xFFFFFFFE, 0xFFFFFFFF
169 exec_op(0x12345678, 0x812FADA);
170 exec_op(0x12341, 0x12341);
171 exec_op(0x12341, -0x12341);
172 exec_op(0xffffffff, 0);
173 exec_op(0xffffffff, -1);
174 exec_op(0xffffffff, 1);
175 exec_op(0xffffffff, 2);
176 exec_op(0x7fffffff, 0);
177 exec_op(0x7fffffff, 1);
178 exec_op(0x7fffffff, -1);
179 exec_op(0x80000000, -1);
180 exec_op(0x80000000, 1);
181 exec_op(0x80000000, -2);
182 exec_op(0x12347fff, 0);
183 exec_op(0x12347fff, 1);
184 exec_op(0x12347fff, -1);
185 exec_op(0x12348000, -1);
186 exec_op(0x12348000, 1);
187 exec_op(0x12348000, -2);
188 exec_op(0x12347f7f, 0);
189 exec_op(0x12347f7f, 1);
190 exec_op(0x12347f7f, -1);
191 exec_op(0x12348080, -1);
192 exec_op(0x12348080, 1);
193 exec_op(0x12348080, -2);
195 #if TEST_INTEGER_VERBOSE
197 for (i
= 0; i
< NVALS
; i
++)
198 for (j
= 0; j
< NVALS
; j
++)
199 exec_op(val
[i
], val
[j
]);
205 void *glue(_test_
, OP
) __init_call
= glue(test_
, OP
);