1 |
|
|
2 |
#define exec_op glue(exec_, OP) |
#define exec_op glue(exec_, OP) |
3 |
|
#define exec_opq glue(glue(exec_, OP), q) |
4 |
#define exec_opl glue(glue(exec_, OP), l) |
#define exec_opl glue(glue(exec_, OP), l) |
5 |
#define exec_opw glue(glue(exec_, OP), w) |
#define exec_opw glue(glue(exec_, OP), w) |
6 |
#define exec_opb glue(glue(exec_, OP), b) |
#define exec_opb glue(glue(exec_, OP), b) |
7 |
|
|
8 |
#define EXECOP2(size, res, s1, flags) \ |
#define EXECOP2(size, rsize, res, s1, flags) \ |
9 |
asm ("push %4\n\t"\ |
asm ("push %4\n\t"\ |
10 |
"popf\n\t"\ |
"popf\n\t"\ |
11 |
stringify(OP) size " %" size "2, %" size "0\n\t" \ |
stringify(OP) size " %" rsize "2, %" rsize "0\n\t" \ |
12 |
"pushf\n\t"\ |
"pushf\n\t"\ |
13 |
"popl %1\n\t"\ |
"pop %1\n\t"\ |
14 |
: "=q" (res), "=g" (flags)\ |
: "=q" (res), "=g" (flags)\ |
15 |
: "q" (s1), "0" (res), "1" (flags)); |
: "q" (s1), "0" (res), "1" (flags)); \ |
16 |
|
printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n", \ |
17 |
|
stringify(OP) size, s0, s1, res, iflags, flags & CC_MASK); |
18 |
|
|
19 |
#define EXECOP1(size, res, flags) \ |
#define EXECOP1(size, rsize, res, flags) \ |
20 |
asm ("push %3\n\t"\ |
asm ("push %3\n\t"\ |
21 |
"popf\n\t"\ |
"popf\n\t"\ |
22 |
stringify(OP) size " %" size "0\n\t" \ |
stringify(OP) size " %" rsize "0\n\t" \ |
23 |
"pushf\n\t"\ |
"pushf\n\t"\ |
24 |
"popl %1\n\t"\ |
"pop %1\n\t"\ |
25 |
: "=q" (res), "=g" (flags)\ |
: "=q" (res), "=g" (flags)\ |
26 |
: "0" (res), "1" (flags)); |
: "0" (res), "1" (flags)); \ |
27 |
|
printf("%-10s A=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n", \ |
28 |
|
stringify(OP) size, s0, res, iflags, flags & CC_MASK); |
29 |
|
|
30 |
#ifdef OP1 |
#ifdef OP1 |
31 |
void exec_opl(int s0, int s1, int iflags) |
#if defined(__x86_64__) |
32 |
|
void exec_opq(long s0, long s1, long iflags) |
33 |
{ |
{ |
34 |
int res, flags; |
long res, flags; |
35 |
res = s0; |
res = s0; |
36 |
flags = iflags; |
flags = iflags; |
37 |
EXECOP1("", res, flags); |
EXECOP1("q", "", res, flags); |
|
printf("%-10s A=%08x R=%08x CCIN=%04x CC=%04x\n", |
|
|
stringify(OP) "l", s0, res, iflags, flags & CC_MASK); |
|
38 |
} |
} |
39 |
|
#endif |
40 |
|
|
41 |
void exec_opw(int s0, int s1, int iflags) |
void exec_opl(long s0, long s1, long iflags) |
42 |
{ |
{ |
43 |
int res, flags; |
long res, flags; |
44 |
res = s0; |
res = s0; |
45 |
flags = iflags; |
flags = iflags; |
46 |
EXECOP1("w", res, flags); |
EXECOP1("l", "k", res, flags); |
|
printf("%-10s A=%08x R=%08x CCIN=%04x CC=%04x\n", |
|
|
stringify(OP) "w", s0, res, iflags, flags & CC_MASK); |
|
47 |
} |
} |
48 |
|
|
49 |
void exec_opb(int s0, int s1, int iflags) |
void exec_opw(long s0, long s1, long iflags) |
50 |
{ |
{ |
51 |
int res, flags; |
long res, flags; |
52 |
res = s0; |
res = s0; |
53 |
flags = iflags; |
flags = iflags; |
54 |
EXECOP1("b", res, flags); |
EXECOP1("w", "w", res, flags); |
55 |
printf("%-10s A=%08x R=%08x CCIN=%04x CC=%04x\n", |
} |
56 |
stringify(OP) "b", s0, res, iflags, flags & CC_MASK); |
|
57 |
|
void exec_opb(long s0, long s1, long iflags) |
58 |
|
{ |
59 |
|
long res, flags; |
60 |
|
res = s0; |
61 |
|
flags = iflags; |
62 |
|
EXECOP1("b", "b", res, flags); |
63 |
} |
} |
64 |
#else |
#else |
65 |
void exec_opl(int s0, int s1, int iflags) |
#if defined(__x86_64__) |
66 |
|
void exec_opq(long s0, long s1, long iflags) |
67 |
|
{ |
68 |
|
long res, flags; |
69 |
|
res = s0; |
70 |
|
flags = iflags; |
71 |
|
EXECOP2("q", "", res, s1, flags); |
72 |
|
} |
73 |
|
#endif |
74 |
|
|
75 |
|
void exec_opl(long s0, long s1, long iflags) |
76 |
{ |
{ |
77 |
int res, flags; |
long res, flags; |
78 |
res = s0; |
res = s0; |
79 |
flags = iflags; |
flags = iflags; |
80 |
EXECOP2("", res, s1, flags); |
EXECOP2("l", "k", res, s1, flags); |
|
printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n", |
|
|
stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK); |
|
81 |
} |
} |
82 |
|
|
83 |
void exec_opw(int s0, int s1, int iflags) |
void exec_opw(long s0, long s1, long iflags) |
84 |
{ |
{ |
85 |
int res, flags; |
long res, flags; |
86 |
res = s0; |
res = s0; |
87 |
flags = iflags; |
flags = iflags; |
88 |
EXECOP2("w", res, s1, flags); |
EXECOP2("w", "w", res, s1, flags); |
|
printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n", |
|
|
stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK); |
|
89 |
} |
} |
90 |
|
|
91 |
void exec_opb(int s0, int s1, int iflags) |
void exec_opb(long s0, long s1, long iflags) |
92 |
{ |
{ |
93 |
int res, flags; |
long res, flags; |
94 |
res = s0; |
res = s0; |
95 |
flags = iflags; |
flags = iflags; |
96 |
EXECOP2("b", res, s1, flags); |
EXECOP2("b", "b", res, s1, flags); |
|
printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n", |
|
|
stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK); |
|
97 |
} |
} |
98 |
#endif |
#endif |
99 |
|
|
100 |
void exec_op(int s0, int s1) |
void exec_op(long s0, long s1) |
101 |
{ |
{ |
102 |
|
s0 = i2l(s0); |
103 |
|
s1 = i2l(s1); |
104 |
|
#if defined(__x86_64__) |
105 |
|
exec_opq(s0, s1, 0); |
106 |
|
#endif |
107 |
exec_opl(s0, s1, 0); |
exec_opl(s0, s1, 0); |
108 |
exec_opw(s0, s1, 0); |
exec_opw(s0, s1, 0); |
109 |
exec_opb(s0, s1, 0); |
exec_opb(s0, s1, 0); |
110 |
#ifdef OP_CC |
#ifdef OP_CC |
111 |
|
#if defined(__x86_64__) |
112 |
|
exec_opq(s0, s1, CC_C); |
113 |
|
#endif |
114 |
exec_opl(s0, s1, CC_C); |
exec_opl(s0, s1, CC_C); |
115 |
exec_opw(s0, s1, CC_C); |
exec_opw(s0, s1, CC_C); |
116 |
exec_opb(s0, s1, CC_C); |
exec_opb(s0, s1, CC_C); |