root / tests / test-i386.h @ 2edcdce3
History | View | Annotate | Download (3.2 kB)
1 | d57c4e01 | bellard | |
---|---|---|---|
2 | d57c4e01 | bellard | #define exec_op glue(exec_, OP)
|
3 | d57c4e01 | bellard | #define exec_opl glue(glue(exec_, OP), l)
|
4 | d57c4e01 | bellard | #define exec_opw glue(glue(exec_, OP), w)
|
5 | d57c4e01 | bellard | #define exec_opb glue(glue(exec_, OP), b)
|
6 | d57c4e01 | bellard | |
7 | d57c4e01 | bellard | #define EXECOP2(size, res, s1, flags) \
|
8 | d57c4e01 | bellard | asm ("push %4\n\t"\ |
9 | d57c4e01 | bellard | "popf\n\t"\
|
10 | d57c4e01 | bellard | stringify(OP) size " %" size "2, %" size "0\n\t" \ |
11 | d57c4e01 | bellard | "pushf\n\t"\
|
12 | d57c4e01 | bellard | "popl %1\n\t"\
|
13 | d57c4e01 | bellard | : "=q" (res), "=g" (flags)\ |
14 | d57c4e01 | bellard | : "q" (s1), "0" (res), "1" (flags)); |
15 | d57c4e01 | bellard | |
16 | d57c4e01 | bellard | #define EXECOP1(size, res, flags) \
|
17 | d57c4e01 | bellard | asm ("push %3\n\t"\ |
18 | d57c4e01 | bellard | "popf\n\t"\
|
19 | d57c4e01 | bellard | stringify(OP) size " %" size "0\n\t" \ |
20 | d57c4e01 | bellard | "pushf\n\t"\
|
21 | d57c4e01 | bellard | "popl %1\n\t"\
|
22 | d57c4e01 | bellard | : "=q" (res), "=g" (flags)\ |
23 | d57c4e01 | bellard | : "0" (res), "1" (flags)); |
24 | d57c4e01 | bellard | |
25 | d57c4e01 | bellard | #ifdef OP1
|
26 | d57c4e01 | bellard | void exec_opl(int s0, int s1, int iflags) |
27 | d57c4e01 | bellard | { |
28 | d57c4e01 | bellard | int res, flags;
|
29 | d57c4e01 | bellard | res = s0; |
30 | d57c4e01 | bellard | flags = iflags; |
31 | d57c4e01 | bellard | EXECOP1("", res, flags);
|
32 | d57c4e01 | bellard | printf("%-10s A=%08x R=%08x CCIN=%04x CC=%04x\n",
|
33 | d57c4e01 | bellard | stringify(OP) "l", s0, res, iflags, flags & CC_MASK);
|
34 | d57c4e01 | bellard | } |
35 | d57c4e01 | bellard | |
36 | d57c4e01 | bellard | void exec_opw(int s0, int s1, int iflags) |
37 | d57c4e01 | bellard | { |
38 | d57c4e01 | bellard | int res, flags;
|
39 | d57c4e01 | bellard | res = s0; |
40 | d57c4e01 | bellard | flags = iflags; |
41 | d57c4e01 | bellard | EXECOP1("w", res, flags);
|
42 | d57c4e01 | bellard | printf("%-10s A=%08x R=%08x CCIN=%04x CC=%04x\n",
|
43 | d57c4e01 | bellard | stringify(OP) "w", s0, res, iflags, flags & CC_MASK);
|
44 | d57c4e01 | bellard | } |
45 | d57c4e01 | bellard | |
46 | d57c4e01 | bellard | void exec_opb(int s0, int s1, int iflags) |
47 | d57c4e01 | bellard | { |
48 | d57c4e01 | bellard | int res, flags;
|
49 | d57c4e01 | bellard | res = s0; |
50 | d57c4e01 | bellard | flags = iflags; |
51 | d57c4e01 | bellard | EXECOP1("b", res, flags);
|
52 | d57c4e01 | bellard | printf("%-10s A=%08x R=%08x CCIN=%04x CC=%04x\n",
|
53 | d57c4e01 | bellard | stringify(OP) "b", s0, res, iflags, flags & CC_MASK);
|
54 | d57c4e01 | bellard | } |
55 | d57c4e01 | bellard | #else
|
56 | d57c4e01 | bellard | void exec_opl(int s0, int s1, int iflags) |
57 | d57c4e01 | bellard | { |
58 | d57c4e01 | bellard | int res, flags;
|
59 | d57c4e01 | bellard | res = s0; |
60 | d57c4e01 | bellard | flags = iflags; |
61 | d57c4e01 | bellard | EXECOP2("", res, s1, flags);
|
62 | d57c4e01 | bellard | printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
|
63 | d57c4e01 | bellard | stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK);
|
64 | d57c4e01 | bellard | } |
65 | d57c4e01 | bellard | |
66 | d57c4e01 | bellard | void exec_opw(int s0, int s1, int iflags) |
67 | d57c4e01 | bellard | { |
68 | d57c4e01 | bellard | int res, flags;
|
69 | d57c4e01 | bellard | res = s0; |
70 | d57c4e01 | bellard | flags = iflags; |
71 | d57c4e01 | bellard | EXECOP2("w", res, s1, flags);
|
72 | d57c4e01 | bellard | printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
|
73 | d57c4e01 | bellard | stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK);
|
74 | d57c4e01 | bellard | } |
75 | d57c4e01 | bellard | |
76 | d57c4e01 | bellard | void exec_opb(int s0, int s1, int iflags) |
77 | d57c4e01 | bellard | { |
78 | d57c4e01 | bellard | int res, flags;
|
79 | d57c4e01 | bellard | res = s0; |
80 | d57c4e01 | bellard | flags = iflags; |
81 | d57c4e01 | bellard | EXECOP2("b", res, s1, flags);
|
82 | d57c4e01 | bellard | printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
|
83 | d57c4e01 | bellard | stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK);
|
84 | d57c4e01 | bellard | } |
85 | d57c4e01 | bellard | #endif
|
86 | d57c4e01 | bellard | |
87 | d57c4e01 | bellard | void exec_op(int s0, int s1) |
88 | d57c4e01 | bellard | { |
89 | d57c4e01 | bellard | exec_opl(s0, s1, 0);
|
90 | d57c4e01 | bellard | exec_opw(s0, s1, 0);
|
91 | d57c4e01 | bellard | exec_opb(s0, s1, 0);
|
92 | d57c4e01 | bellard | #ifdef OP_CC
|
93 | d57c4e01 | bellard | exec_opl(s0, s1, CC_C); |
94 | d57c4e01 | bellard | exec_opw(s0, s1, CC_C); |
95 | d57c4e01 | bellard | exec_opb(s0, s1, CC_C); |
96 | d57c4e01 | bellard | #endif
|
97 | d57c4e01 | bellard | } |
98 | d57c4e01 | bellard | |
99 | d57c4e01 | bellard | void glue(test_, OP)(void) |
100 | d57c4e01 | bellard | { |
101 | d57c4e01 | bellard | exec_op(0x12345678, 0x812FADA); |
102 | d57c4e01 | bellard | exec_op(0x12341, 0x12341); |
103 | d57c4e01 | bellard | exec_op(0x12341, -0x12341); |
104 | d57c4e01 | bellard | exec_op(0xffffffff, 0); |
105 | d57c4e01 | bellard | exec_op(0xffffffff, -1); |
106 | d57c4e01 | bellard | exec_op(0xffffffff, 1); |
107 | d57c4e01 | bellard | exec_op(0xffffffff, 2); |
108 | d57c4e01 | bellard | exec_op(0x7fffffff, 0); |
109 | d57c4e01 | bellard | exec_op(0x7fffffff, 1); |
110 | d57c4e01 | bellard | exec_op(0x7fffffff, -1); |
111 | d57c4e01 | bellard | exec_op(0x80000000, -1); |
112 | d57c4e01 | bellard | exec_op(0x80000000, 1); |
113 | d57c4e01 | bellard | exec_op(0x80000000, -2); |
114 | d57c4e01 | bellard | exec_op(0x12347fff, 0); |
115 | d57c4e01 | bellard | exec_op(0x12347fff, 1); |
116 | d57c4e01 | bellard | exec_op(0x12347fff, -1); |
117 | d57c4e01 | bellard | exec_op(0x12348000, -1); |
118 | d57c4e01 | bellard | exec_op(0x12348000, 1); |
119 | d57c4e01 | bellard | exec_op(0x12348000, -2); |
120 | d57c4e01 | bellard | exec_op(0x12347f7f, 0); |
121 | d57c4e01 | bellard | exec_op(0x12347f7f, 1); |
122 | d57c4e01 | bellard | exec_op(0x12347f7f, -1); |
123 | d57c4e01 | bellard | exec_op(0x12348080, -1); |
124 | d57c4e01 | bellard | exec_op(0x12348080, 1); |
125 | d57c4e01 | bellard | exec_op(0x12348080, -2); |
126 | d57c4e01 | bellard | } |
127 | d57c4e01 | bellard | |
128 | d57c4e01 | bellard | void *glue(_test_, OP) __init_call = glue(test_, OP);
|
129 | d57c4e01 | bellard | |
130 | d57c4e01 | bellard | #undef OP
|
131 | d57c4e01 | bellard | #undef OP_CC |