Statistics
| Branch: | Revision:

root / tests / test-i386.h @ 7aaabde7

History | View | Annotate | Download (3.4 kB)

1 d57c4e01 bellard
2 d57c4e01 bellard
#define exec_op glue(exec_, OP)
3 776f2227 bellard
#define exec_opq glue(glue(exec_, OP), q)
4 d57c4e01 bellard
#define exec_opl glue(glue(exec_, OP), l)
5 d57c4e01 bellard
#define exec_opw glue(glue(exec_, OP), w)
6 d57c4e01 bellard
#define exec_opb glue(glue(exec_, OP), b)
7 d57c4e01 bellard
8 776f2227 bellard
#define EXECOP2(size, rsize, res, s1, flags) \
9 d57c4e01 bellard
    asm ("push %4\n\t"\
10 d57c4e01 bellard
         "popf\n\t"\
11 776f2227 bellard
         stringify(OP) size " %" rsize "2, %" rsize "0\n\t" \
12 d57c4e01 bellard
         "pushf\n\t"\
13 776f2227 bellard
         "pop %1\n\t"\
14 d57c4e01 bellard
         : "=q" (res), "=g" (flags)\
15 776f2227 bellard
         : "q" (s1), "0" (res), "1" (flags)); \
16 776f2227 bellard
    printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n", \
17 776f2227 bellard
           stringify(OP) size, s0, s1, res, iflags, flags & CC_MASK);
18 d57c4e01 bellard
19 776f2227 bellard
#define EXECOP1(size, rsize, res, flags) \
20 d57c4e01 bellard
    asm ("push %3\n\t"\
21 d57c4e01 bellard
         "popf\n\t"\
22 776f2227 bellard
         stringify(OP) size " %" rsize "0\n\t" \
23 d57c4e01 bellard
         "pushf\n\t"\
24 776f2227 bellard
         "pop %1\n\t"\
25 d57c4e01 bellard
         : "=q" (res), "=g" (flags)\
26 776f2227 bellard
         : "0" (res), "1" (flags)); \
27 776f2227 bellard
    printf("%-10s A=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n", \
28 776f2227 bellard
           stringify(OP) size, s0, res, iflags, flags & CC_MASK);
29 d57c4e01 bellard
30 d57c4e01 bellard
#ifdef OP1
31 776f2227 bellard
#if defined(__x86_64__)
32 776f2227 bellard
void exec_opq(long s0, long s1, long iflags)
33 d57c4e01 bellard
{
34 776f2227 bellard
    long res, flags;
35 d57c4e01 bellard
    res = s0;
36 d57c4e01 bellard
    flags = iflags;
37 776f2227 bellard
    EXECOP1("q", "", res, flags);
38 d57c4e01 bellard
}
39 776f2227 bellard
#endif
40 d57c4e01 bellard
41 776f2227 bellard
void exec_opl(long s0, long s1, long iflags)
42 d57c4e01 bellard
{
43 776f2227 bellard
    long res, flags;
44 d57c4e01 bellard
    res = s0;
45 d57c4e01 bellard
    flags = iflags;
46 776f2227 bellard
    EXECOP1("l", "k", res, flags);
47 d57c4e01 bellard
}
48 d57c4e01 bellard
49 776f2227 bellard
void exec_opw(long s0, long s1, long iflags)
50 d57c4e01 bellard
{
51 776f2227 bellard
    long res, flags;
52 d57c4e01 bellard
    res = s0;
53 d57c4e01 bellard
    flags = iflags;
54 776f2227 bellard
    EXECOP1("w", "w", res, flags);
55 776f2227 bellard
}
56 776f2227 bellard
57 776f2227 bellard
void exec_opb(long s0, long s1, long iflags)
58 776f2227 bellard
{
59 776f2227 bellard
    long res, flags;
60 776f2227 bellard
    res = s0;
61 776f2227 bellard
    flags = iflags;
62 776f2227 bellard
    EXECOP1("b", "b", res, flags);
63 d57c4e01 bellard
}
64 d57c4e01 bellard
#else
65 776f2227 bellard
#if defined(__x86_64__)
66 776f2227 bellard
void exec_opq(long s0, long s1, long iflags)
67 776f2227 bellard
{
68 776f2227 bellard
    long res, flags;
69 776f2227 bellard
    res = s0;
70 776f2227 bellard
    flags = iflags;
71 776f2227 bellard
    EXECOP2("q", "", res, s1, flags);
72 776f2227 bellard
}
73 776f2227 bellard
#endif
74 776f2227 bellard
75 776f2227 bellard
void exec_opl(long s0, long s1, long iflags)
76 d57c4e01 bellard
{
77 776f2227 bellard
    long res, flags;
78 d57c4e01 bellard
    res = s0;
79 d57c4e01 bellard
    flags = iflags;
80 776f2227 bellard
    EXECOP2("l", "k", res, s1, flags);
81 d57c4e01 bellard
}
82 d57c4e01 bellard
83 776f2227 bellard
void exec_opw(long s0, long s1, long iflags)
84 d57c4e01 bellard
{
85 776f2227 bellard
    long res, flags;
86 d57c4e01 bellard
    res = s0;
87 d57c4e01 bellard
    flags = iflags;
88 776f2227 bellard
    EXECOP2("w", "w", res, s1, flags);
89 d57c4e01 bellard
}
90 d57c4e01 bellard
91 776f2227 bellard
void exec_opb(long s0, long s1, long iflags)
92 d57c4e01 bellard
{
93 776f2227 bellard
    long res, flags;
94 d57c4e01 bellard
    res = s0;
95 d57c4e01 bellard
    flags = iflags;
96 776f2227 bellard
    EXECOP2("b", "b", res, s1, flags);
97 d57c4e01 bellard
}
98 d57c4e01 bellard
#endif
99 d57c4e01 bellard
100 776f2227 bellard
void exec_op(long s0, long s1)
101 d57c4e01 bellard
{
102 776f2227 bellard
    s0 = i2l(s0);
103 776f2227 bellard
    s1 = i2l(s1);
104 776f2227 bellard
#if defined(__x86_64__)
105 776f2227 bellard
    exec_opq(s0, s1, 0);
106 776f2227 bellard
#endif
107 d57c4e01 bellard
    exec_opl(s0, s1, 0);
108 d57c4e01 bellard
    exec_opw(s0, s1, 0);
109 d57c4e01 bellard
    exec_opb(s0, s1, 0);
110 d57c4e01 bellard
#ifdef OP_CC
111 776f2227 bellard
#if defined(__x86_64__)
112 776f2227 bellard
    exec_opq(s0, s1, CC_C);
113 776f2227 bellard
#endif
114 d57c4e01 bellard
    exec_opl(s0, s1, CC_C);
115 d57c4e01 bellard
    exec_opw(s0, s1, CC_C);
116 d57c4e01 bellard
    exec_opb(s0, s1, CC_C);
117 d57c4e01 bellard
#endif
118 d57c4e01 bellard
}
119 d57c4e01 bellard
120 d57c4e01 bellard
void glue(test_, OP)(void)
121 d57c4e01 bellard
{
122 d57c4e01 bellard
    exec_op(0x12345678, 0x812FADA);
123 d57c4e01 bellard
    exec_op(0x12341, 0x12341);
124 d57c4e01 bellard
    exec_op(0x12341, -0x12341);
125 d57c4e01 bellard
    exec_op(0xffffffff, 0);
126 d57c4e01 bellard
    exec_op(0xffffffff, -1);
127 d57c4e01 bellard
    exec_op(0xffffffff, 1);
128 d57c4e01 bellard
    exec_op(0xffffffff, 2);
129 d57c4e01 bellard
    exec_op(0x7fffffff, 0);
130 d57c4e01 bellard
    exec_op(0x7fffffff, 1);
131 d57c4e01 bellard
    exec_op(0x7fffffff, -1);
132 d57c4e01 bellard
    exec_op(0x80000000, -1);
133 d57c4e01 bellard
    exec_op(0x80000000, 1);
134 d57c4e01 bellard
    exec_op(0x80000000, -2);
135 d57c4e01 bellard
    exec_op(0x12347fff, 0);
136 d57c4e01 bellard
    exec_op(0x12347fff, 1);
137 d57c4e01 bellard
    exec_op(0x12347fff, -1);
138 d57c4e01 bellard
    exec_op(0x12348000, -1);
139 d57c4e01 bellard
    exec_op(0x12348000, 1);
140 d57c4e01 bellard
    exec_op(0x12348000, -2);
141 d57c4e01 bellard
    exec_op(0x12347f7f, 0);
142 d57c4e01 bellard
    exec_op(0x12347f7f, 1);
143 d57c4e01 bellard
    exec_op(0x12347f7f, -1);
144 d57c4e01 bellard
    exec_op(0x12348080, -1);
145 d57c4e01 bellard
    exec_op(0x12348080, 1);
146 d57c4e01 bellard
    exec_op(0x12348080, -2);
147 d57c4e01 bellard
}
148 d57c4e01 bellard
149 d57c4e01 bellard
void *glue(_test_, OP) __init_call = glue(test_, OP);
150 d57c4e01 bellard
151 d57c4e01 bellard
#undef OP
152 d57c4e01 bellard
#undef OP_CC