]> git.proxmox.com Git - qemu.git/blame - tests/test-i386-shift.h
added getrusage
[qemu.git] / tests / test-i386-shift.h
CommitLineData
379ca80d
FB
1
2#define exec_op glue(exec_, OP)
3#define exec_opl glue(glue(exec_, OP), l)
4#define exec_opw glue(glue(exec_, OP), w)
5#define exec_opb glue(glue(exec_, OP), b)
6
d57c4e01
FB
7#ifndef OP_SHIFTD
8
9#ifdef OP_NOBYTE
10#define EXECSHIFT(size, res, s1, s2, flags) \
11 asm ("push %4\n\t"\
12 "popf\n\t"\
13 stringify(OP) size " %" size "2, %" size "0\n\t" \
14 "pushf\n\t"\
15 "popl %1\n\t"\
16 : "=g" (res), "=g" (flags)\
17 : "r" (s1), "0" (res), "1" (flags));
18#else
19#define EXECSHIFT(size, res, s1, s2, flags) \
379ca80d
FB
20 asm ("push %4\n\t"\
21 "popf\n\t"\
22 stringify(OP) size " %%cl, %" size "0\n\t" \
23 "pushf\n\t"\
24 "popl %1\n\t"\
25 : "=q" (res), "=g" (flags)\
26 : "c" (s1), "0" (res), "1" (flags));
d57c4e01 27#endif
379ca80d 28
d57c4e01 29void exec_opl(int s2, int s0, int s1, int iflags)
379ca80d
FB
30{
31 int res, flags;
32 res = s0;
33 flags = iflags;
d57c4e01 34 EXECSHIFT("", res, s1, s2, flags);
379ca80d
FB
35 /* overflow is undefined if count != 1 */
36 if (s1 != 1)
37 flags &= ~CC_O;
38 printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
39 stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK);
40}
41
d57c4e01 42void exec_opw(int s2, int s0, int s1, int iflags)
379ca80d
FB
43{
44 int res, flags;
45 res = s0;
46 flags = iflags;
d57c4e01 47 EXECSHIFT("w", res, s1, s2, flags);
379ca80d
FB
48 /* overflow is undefined if count != 1 */
49 if (s1 != 1)
50 flags &= ~CC_O;
51 printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
52 stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK);
53}
54
d57c4e01
FB
55#else
56#define EXECSHIFT(size, res, s1, s2, flags) \
57 asm ("push %4\n\t"\
58 "popf\n\t"\
59 stringify(OP) size " %%cl, %" size "5, %" size "0\n\t" \
60 "pushf\n\t"\
61 "popl %1\n\t"\
62 : "=g" (res), "=g" (flags)\
63 : "c" (s1), "0" (res), "1" (flags), "r" (s2));
64
65void exec_opl(int s2, int s0, int s1, int iflags)
66{
67 int res, flags;
68 res = s0;
69 flags = iflags;
70 EXECSHIFT("", res, s1, s2, flags);
71 /* overflow is undefined if count != 1 */
72 if (s1 != 1)
73 flags &= ~CC_O;
74 printf("%-10s A=%08x B=%08x C=%08x R=%08x CCIN=%04x CC=%04x\n",
75 stringify(OP) "l", s0, s2, s1, res, iflags, flags & CC_MASK);
76}
77
78void exec_opw(int s2, int s0, int s1, int iflags)
79{
80 int res, flags;
81 res = s0;
82 flags = iflags;
83 EXECSHIFT("w", res, s1, s2, flags);
84 /* overflow is undefined if count != 1 */
85 if (s1 != 1)
86 flags &= ~CC_O;
87 printf("%-10s A=%08x B=%08x C=%08x R=%08x CCIN=%04x CC=%04x\n",
88 stringify(OP) "w", s0, s2, s1, res, iflags, flags & CC_MASK);
89}
90
91#endif
92
93#ifndef OP_NOBYTE
379ca80d
FB
94void exec_opb(int s0, int s1, int iflags)
95{
96 int res, flags;
97 res = s0;
98 flags = iflags;
d57c4e01 99 EXECSHIFT("b", res, s1, 0, flags);
379ca80d
FB
100 /* overflow is undefined if count != 1 */
101 if (s1 != 1)
102 flags &= ~CC_O;
103 printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
104 stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK);
105}
d57c4e01 106#endif
379ca80d 107
d57c4e01 108void exec_op(int s2, int s0, int s1)
379ca80d 109{
d57c4e01 110 exec_opl(s2, s0, s1, 0);
afeb6ee3
FB
111#ifdef OP_SHIFTD
112 if (s1 <= 15)
113 exec_opw(s2, s0, s1, 0);
114#else
d57c4e01 115 exec_opw(s2, s0, s1, 0);
afeb6ee3 116#endif
d57c4e01 117#ifndef OP_NOBYTE
379ca80d 118 exec_opb(s0, s1, 0);
d57c4e01 119#endif
379ca80d 120#ifdef OP_CC
d57c4e01
FB
121 exec_opl(s2, s0, s1, CC_C);
122 exec_opw(s2, s0, s1, CC_C);
379ca80d
FB
123 exec_opb(s0, s1, CC_C);
124#endif
125}
126
127void glue(test_, OP)(void)
128{
129 int i;
130 for(i = 0; i < 32; i++)
d57c4e01 131 exec_op(0x21ad3d34, 0x12345678, i);
379ca80d 132 for(i = 0; i < 32; i++)
d57c4e01 133 exec_op(0x813f3421, 0x82345678, i);
379ca80d
FB
134}
135
136void *glue(_test_, OP) __init_call = glue(test_, OP);
137
138#undef OP
139#undef OP_CC
d57c4e01
FB
140#undef OP_SHIFTD
141#undef OP_NOBYTE
142#undef EXECSHIFT
143