root / target-i386 / ops_template.h @ 480c1cdb
History | View | Annotate | Download (13 kB)
1 | 2c0262af | bellard | /*
|
---|---|---|---|
2 | 2c0262af | bellard | * i386 micro operations (included several times to generate
|
3 | 2c0262af | bellard | * different operand sizes)
|
4 | 2c0262af | bellard | *
|
5 | 2c0262af | bellard | * Copyright (c) 2003 Fabrice Bellard
|
6 | 2c0262af | bellard | *
|
7 | 2c0262af | bellard | * This library is free software; you can redistribute it and/or
|
8 | 2c0262af | bellard | * modify it under the terms of the GNU Lesser General Public
|
9 | 2c0262af | bellard | * License as published by the Free Software Foundation; either
|
10 | 2c0262af | bellard | * version 2 of the License, or (at your option) any later version.
|
11 | 2c0262af | bellard | *
|
12 | 2c0262af | bellard | * This library is distributed in the hope that it will be useful,
|
13 | 2c0262af | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 2c0262af | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 | 2c0262af | bellard | * Lesser General Public License for more details.
|
16 | 2c0262af | bellard | *
|
17 | 2c0262af | bellard | * You should have received a copy of the GNU Lesser General Public
|
18 | 2c0262af | bellard | * License along with this library; if not, write to the Free Software
|
19 | 2c0262af | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 | 2c0262af | bellard | */
|
21 | 2c0262af | bellard | #define DATA_BITS (1 << (3 + SHIFT)) |
22 | 2c0262af | bellard | #define SHIFT_MASK (DATA_BITS - 1) |
23 | 14ce26e7 | bellard | #define SIGN_MASK (((target_ulong)1) << (DATA_BITS - 1)) |
24 | 14ce26e7 | bellard | #if DATA_BITS <= 32 |
25 | 14ce26e7 | bellard | #define SHIFT1_MASK 0x1f |
26 | 14ce26e7 | bellard | #else
|
27 | 14ce26e7 | bellard | #define SHIFT1_MASK 0x3f |
28 | 14ce26e7 | bellard | #endif
|
29 | 2c0262af | bellard | |
30 | 2c0262af | bellard | #if DATA_BITS == 8 |
31 | 2c0262af | bellard | #define SUFFIX b
|
32 | 2c0262af | bellard | #define DATA_TYPE uint8_t
|
33 | 2c0262af | bellard | #define DATA_STYPE int8_t
|
34 | 2c0262af | bellard | #define DATA_MASK 0xff |
35 | 2c0262af | bellard | #elif DATA_BITS == 16 |
36 | 2c0262af | bellard | #define SUFFIX w
|
37 | 2c0262af | bellard | #define DATA_TYPE uint16_t
|
38 | 2c0262af | bellard | #define DATA_STYPE int16_t
|
39 | 2c0262af | bellard | #define DATA_MASK 0xffff |
40 | 2c0262af | bellard | #elif DATA_BITS == 32 |
41 | 2c0262af | bellard | #define SUFFIX l
|
42 | 2c0262af | bellard | #define DATA_TYPE uint32_t
|
43 | 2c0262af | bellard | #define DATA_STYPE int32_t
|
44 | 2c0262af | bellard | #define DATA_MASK 0xffffffff |
45 | 14ce26e7 | bellard | #elif DATA_BITS == 64 |
46 | 14ce26e7 | bellard | #define SUFFIX q
|
47 | 14ce26e7 | bellard | #define DATA_TYPE uint64_t
|
48 | 14ce26e7 | bellard | #define DATA_STYPE int64_t
|
49 | 977d5710 | bellard | #define DATA_MASK 0xffffffffffffffffULL |
50 | 2c0262af | bellard | #else
|
51 | 2c0262af | bellard | #error unhandled operand size
|
52 | 2c0262af | bellard | #endif
|
53 | 2c0262af | bellard | |
54 | 2c0262af | bellard | /* dynamic flags computation */
|
55 | 2c0262af | bellard | |
56 | 2c0262af | bellard | static int glue(compute_all_add, SUFFIX)(void) |
57 | 2c0262af | bellard | { |
58 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
59 | 14ce26e7 | bellard | target_long src1, src2; |
60 | 2c0262af | bellard | src1 = CC_SRC; |
61 | 2c0262af | bellard | src2 = CC_DST - CC_SRC; |
62 | 2c0262af | bellard | cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1; |
63 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
64 | 2c0262af | bellard | af = (CC_DST ^ src1 ^ src2) & 0x10;
|
65 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
66 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
67 | 2c0262af | bellard | of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
68 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
69 | 2c0262af | bellard | } |
70 | 2c0262af | bellard | |
71 | 2c0262af | bellard | static int glue(compute_c_add, SUFFIX)(void) |
72 | 2c0262af | bellard | { |
73 | 14ce26e7 | bellard | int cf;
|
74 | 14ce26e7 | bellard | target_long src1; |
75 | 2c0262af | bellard | src1 = CC_SRC; |
76 | 2c0262af | bellard | cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1; |
77 | 2c0262af | bellard | return cf;
|
78 | 2c0262af | bellard | } |
79 | 2c0262af | bellard | |
80 | 2c0262af | bellard | static int glue(compute_all_adc, SUFFIX)(void) |
81 | 2c0262af | bellard | { |
82 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
83 | 14ce26e7 | bellard | target_long src1, src2; |
84 | 2c0262af | bellard | src1 = CC_SRC; |
85 | 2c0262af | bellard | src2 = CC_DST - CC_SRC - 1;
|
86 | 2c0262af | bellard | cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1; |
87 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
88 | 2c0262af | bellard | af = (CC_DST ^ src1 ^ src2) & 0x10;
|
89 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
90 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
91 | 2c0262af | bellard | of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
92 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
93 | 2c0262af | bellard | } |
94 | 2c0262af | bellard | |
95 | 2c0262af | bellard | static int glue(compute_c_adc, SUFFIX)(void) |
96 | 2c0262af | bellard | { |
97 | 14ce26e7 | bellard | int cf;
|
98 | 14ce26e7 | bellard | target_long src1; |
99 | 2c0262af | bellard | src1 = CC_SRC; |
100 | 2c0262af | bellard | cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1; |
101 | 2c0262af | bellard | return cf;
|
102 | 2c0262af | bellard | } |
103 | 2c0262af | bellard | |
104 | 2c0262af | bellard | static int glue(compute_all_sub, SUFFIX)(void) |
105 | 2c0262af | bellard | { |
106 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
107 | 14ce26e7 | bellard | target_long src1, src2; |
108 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
109 | 2c0262af | bellard | src2 = CC_SRC; |
110 | 2c0262af | bellard | cf = (DATA_TYPE)src1 < (DATA_TYPE)src2; |
111 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
112 | 2c0262af | bellard | af = (CC_DST ^ src1 ^ src2) & 0x10;
|
113 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
114 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
115 | 2c0262af | bellard | of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O;
|
116 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
117 | 2c0262af | bellard | } |
118 | 2c0262af | bellard | |
119 | 2c0262af | bellard | static int glue(compute_c_sub, SUFFIX)(void) |
120 | 2c0262af | bellard | { |
121 | 14ce26e7 | bellard | int cf;
|
122 | 14ce26e7 | bellard | target_long src1, src2; |
123 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
124 | 2c0262af | bellard | src2 = CC_SRC; |
125 | 2c0262af | bellard | cf = (DATA_TYPE)src1 < (DATA_TYPE)src2; |
126 | 2c0262af | bellard | return cf;
|
127 | 2c0262af | bellard | } |
128 | 2c0262af | bellard | |
129 | 2c0262af | bellard | static int glue(compute_all_sbb, SUFFIX)(void) |
130 | 2c0262af | bellard | { |
131 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
132 | 14ce26e7 | bellard | target_long src1, src2; |
133 | 2c0262af | bellard | src1 = CC_DST + CC_SRC + 1;
|
134 | 2c0262af | bellard | src2 = CC_SRC; |
135 | 2c0262af | bellard | cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2; |
136 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
137 | 2c0262af | bellard | af = (CC_DST ^ src1 ^ src2) & 0x10;
|
138 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
139 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
140 | 2c0262af | bellard | of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O;
|
141 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
142 | 2c0262af | bellard | } |
143 | 2c0262af | bellard | |
144 | 2c0262af | bellard | static int glue(compute_c_sbb, SUFFIX)(void) |
145 | 2c0262af | bellard | { |
146 | 14ce26e7 | bellard | int cf;
|
147 | 14ce26e7 | bellard | target_long src1, src2; |
148 | 2c0262af | bellard | src1 = CC_DST + CC_SRC + 1;
|
149 | 2c0262af | bellard | src2 = CC_SRC; |
150 | 2c0262af | bellard | cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2; |
151 | 2c0262af | bellard | return cf;
|
152 | 2c0262af | bellard | } |
153 | 2c0262af | bellard | |
154 | 2c0262af | bellard | static int glue(compute_all_logic, SUFFIX)(void) |
155 | 2c0262af | bellard | { |
156 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
157 | 2c0262af | bellard | cf = 0;
|
158 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
159 | 2c0262af | bellard | af = 0;
|
160 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
161 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
162 | 2c0262af | bellard | of = 0;
|
163 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
164 | 2c0262af | bellard | } |
165 | 2c0262af | bellard | |
166 | 2c0262af | bellard | static int glue(compute_c_logic, SUFFIX)(void) |
167 | 2c0262af | bellard | { |
168 | 2c0262af | bellard | return 0; |
169 | 2c0262af | bellard | } |
170 | 2c0262af | bellard | |
171 | 2c0262af | bellard | static int glue(compute_all_inc, SUFFIX)(void) |
172 | 2c0262af | bellard | { |
173 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
174 | 14ce26e7 | bellard | target_long src1, src2; |
175 | 2c0262af | bellard | src1 = CC_DST - 1;
|
176 | 2c0262af | bellard | src2 = 1;
|
177 | 2c0262af | bellard | cf = CC_SRC; |
178 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
179 | 2c0262af | bellard | af = (CC_DST ^ src1 ^ src2) & 0x10;
|
180 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
181 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
182 | 2c0262af | bellard | of = ((CC_DST & DATA_MASK) == SIGN_MASK) << 11;
|
183 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
184 | 2c0262af | bellard | } |
185 | 2c0262af | bellard | |
186 | 2c0262af | bellard | #if DATA_BITS == 32 |
187 | 2c0262af | bellard | static int glue(compute_c_inc, SUFFIX)(void) |
188 | 2c0262af | bellard | { |
189 | 2c0262af | bellard | return CC_SRC;
|
190 | 2c0262af | bellard | } |
191 | 2c0262af | bellard | #endif
|
192 | 2c0262af | bellard | |
193 | 2c0262af | bellard | static int glue(compute_all_dec, SUFFIX)(void) |
194 | 2c0262af | bellard | { |
195 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
196 | 14ce26e7 | bellard | target_long src1, src2; |
197 | 2c0262af | bellard | src1 = CC_DST + 1;
|
198 | 2c0262af | bellard | src2 = 1;
|
199 | 2c0262af | bellard | cf = CC_SRC; |
200 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
201 | 2c0262af | bellard | af = (CC_DST ^ src1 ^ src2) & 0x10;
|
202 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
203 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
204 | 14ce26e7 | bellard | of = ((CC_DST & DATA_MASK) == ((target_ulong)SIGN_MASK - 1)) << 11; |
205 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
206 | 2c0262af | bellard | } |
207 | 2c0262af | bellard | |
208 | 2c0262af | bellard | static int glue(compute_all_shl, SUFFIX)(void) |
209 | 2c0262af | bellard | { |
210 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
211 | 2c0262af | bellard | cf = (CC_SRC >> (DATA_BITS - 1)) & CC_C;
|
212 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
213 | 2c0262af | bellard | af = 0; /* undefined */ |
214 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
215 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
216 | 2c0262af | bellard | /* of is defined if shift count == 1 */
|
217 | 2c0262af | bellard | of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O;
|
218 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
219 | 2c0262af | bellard | } |
220 | 2c0262af | bellard | |
221 | 2c0262af | bellard | static int glue(compute_c_shl, SUFFIX)(void) |
222 | 2c0262af | bellard | { |
223 | 2c0262af | bellard | return (CC_SRC >> (DATA_BITS - 1)) & CC_C; |
224 | 2c0262af | bellard | } |
225 | 2c0262af | bellard | |
226 | 2c0262af | bellard | #if DATA_BITS == 32 |
227 | 2c0262af | bellard | static int glue(compute_c_sar, SUFFIX)(void) |
228 | 2c0262af | bellard | { |
229 | 2c0262af | bellard | return CC_SRC & 1; |
230 | 2c0262af | bellard | } |
231 | 2c0262af | bellard | #endif
|
232 | 2c0262af | bellard | |
233 | 2c0262af | bellard | static int glue(compute_all_sar, SUFFIX)(void) |
234 | 2c0262af | bellard | { |
235 | 2c0262af | bellard | int cf, pf, af, zf, sf, of;
|
236 | 2c0262af | bellard | cf = CC_SRC & 1;
|
237 | 2c0262af | bellard | pf = parity_table[(uint8_t)CC_DST]; |
238 | 2c0262af | bellard | af = 0; /* undefined */ |
239 | 2c0262af | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
240 | 2c0262af | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
241 | 2c0262af | bellard | /* of is defined if shift count == 1 */
|
242 | 2c0262af | bellard | of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O;
|
243 | 2c0262af | bellard | return cf | pf | af | zf | sf | of;
|
244 | 2c0262af | bellard | } |
245 | 2c0262af | bellard | |
246 | d36cd60e | bellard | #if DATA_BITS == 32 |
247 | d36cd60e | bellard | static int glue(compute_c_mul, SUFFIX)(void) |
248 | d36cd60e | bellard | { |
249 | d36cd60e | bellard | int cf;
|
250 | d36cd60e | bellard | cf = (CC_SRC != 0);
|
251 | d36cd60e | bellard | return cf;
|
252 | d36cd60e | bellard | } |
253 | d36cd60e | bellard | #endif
|
254 | d36cd60e | bellard | |
255 | d36cd60e | bellard | /* NOTE: we compute the flags like the P4. On olders CPUs, only OF and
|
256 | d36cd60e | bellard | CF are modified and it is slower to do that. */
|
257 | d36cd60e | bellard | static int glue(compute_all_mul, SUFFIX)(void) |
258 | d36cd60e | bellard | { |
259 | d36cd60e | bellard | int cf, pf, af, zf, sf, of;
|
260 | d36cd60e | bellard | cf = (CC_SRC != 0);
|
261 | d36cd60e | bellard | pf = parity_table[(uint8_t)CC_DST]; |
262 | d36cd60e | bellard | af = 0; /* undefined */ |
263 | d36cd60e | bellard | zf = ((DATA_TYPE)CC_DST == 0) << 6; |
264 | d36cd60e | bellard | sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
265 | d36cd60e | bellard | of = cf << 11;
|
266 | d36cd60e | bellard | return cf | pf | af | zf | sf | of;
|
267 | d36cd60e | bellard | } |
268 | d36cd60e | bellard | |
269 | 2c0262af | bellard | /* various optimized jumps cases */
|
270 | 2c0262af | bellard | |
271 | 2c0262af | bellard | void OPPROTO glue(op_jb_sub, SUFFIX)(void) |
272 | 2c0262af | bellard | { |
273 | 14ce26e7 | bellard | target_long src1, src2; |
274 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
275 | 2c0262af | bellard | src2 = CC_SRC; |
276 | 2c0262af | bellard | |
277 | 2c0262af | bellard | if ((DATA_TYPE)src1 < (DATA_TYPE)src2)
|
278 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
279 | 2c0262af | bellard | FORCE_RET(); |
280 | 2c0262af | bellard | } |
281 | 2c0262af | bellard | |
282 | 2c0262af | bellard | void OPPROTO glue(op_jz_sub, SUFFIX)(void) |
283 | 2c0262af | bellard | { |
284 | 2c0262af | bellard | if ((DATA_TYPE)CC_DST == 0) |
285 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
286 | 14ce26e7 | bellard | FORCE_RET(); |
287 | 14ce26e7 | bellard | } |
288 | 14ce26e7 | bellard | |
289 | 14ce26e7 | bellard | void OPPROTO glue(op_jnz_sub, SUFFIX)(void) |
290 | 14ce26e7 | bellard | { |
291 | 14ce26e7 | bellard | if ((DATA_TYPE)CC_DST != 0) |
292 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
293 | 2c0262af | bellard | FORCE_RET(); |
294 | 2c0262af | bellard | } |
295 | 2c0262af | bellard | |
296 | 2c0262af | bellard | void OPPROTO glue(op_jbe_sub, SUFFIX)(void) |
297 | 2c0262af | bellard | { |
298 | 14ce26e7 | bellard | target_long src1, src2; |
299 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
300 | 2c0262af | bellard | src2 = CC_SRC; |
301 | 2c0262af | bellard | |
302 | 2c0262af | bellard | if ((DATA_TYPE)src1 <= (DATA_TYPE)src2)
|
303 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
304 | 2c0262af | bellard | FORCE_RET(); |
305 | 2c0262af | bellard | } |
306 | 2c0262af | bellard | |
307 | 2c0262af | bellard | void OPPROTO glue(op_js_sub, SUFFIX)(void) |
308 | 2c0262af | bellard | { |
309 | 2c0262af | bellard | if (CC_DST & SIGN_MASK)
|
310 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
311 | 2c0262af | bellard | FORCE_RET(); |
312 | 2c0262af | bellard | } |
313 | 2c0262af | bellard | |
314 | 2c0262af | bellard | void OPPROTO glue(op_jl_sub, SUFFIX)(void) |
315 | 2c0262af | bellard | { |
316 | 14ce26e7 | bellard | target_long src1, src2; |
317 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
318 | 2c0262af | bellard | src2 = CC_SRC; |
319 | 2c0262af | bellard | |
320 | 2c0262af | bellard | if ((DATA_STYPE)src1 < (DATA_STYPE)src2)
|
321 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
322 | 2c0262af | bellard | FORCE_RET(); |
323 | 2c0262af | bellard | } |
324 | 2c0262af | bellard | |
325 | 2c0262af | bellard | void OPPROTO glue(op_jle_sub, SUFFIX)(void) |
326 | 2c0262af | bellard | { |
327 | 14ce26e7 | bellard | target_long src1, src2; |
328 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
329 | 2c0262af | bellard | src2 = CC_SRC; |
330 | 2c0262af | bellard | |
331 | 2c0262af | bellard | if ((DATA_STYPE)src1 <= (DATA_STYPE)src2)
|
332 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
333 | 2c0262af | bellard | FORCE_RET(); |
334 | 2c0262af | bellard | } |
335 | 2c0262af | bellard | |
336 | 2c0262af | bellard | /* oldies */
|
337 | 2c0262af | bellard | |
338 | 2c0262af | bellard | #if DATA_BITS >= 16 |
339 | 2c0262af | bellard | |
340 | 2c0262af | bellard | void OPPROTO glue(op_loopnz, SUFFIX)(void) |
341 | 2c0262af | bellard | { |
342 | 0b9dc5e4 | bellard | if ((DATA_TYPE)ECX != 0 && !(T0 & CC_Z)) |
343 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
344 | 2c0262af | bellard | FORCE_RET(); |
345 | 2c0262af | bellard | } |
346 | 2c0262af | bellard | |
347 | 2c0262af | bellard | void OPPROTO glue(op_loopz, SUFFIX)(void) |
348 | 2c0262af | bellard | { |
349 | 0b9dc5e4 | bellard | if ((DATA_TYPE)ECX != 0 && (T0 & CC_Z)) |
350 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
351 | 2c0262af | bellard | FORCE_RET(); |
352 | 2c0262af | bellard | } |
353 | 2c0262af | bellard | |
354 | 14ce26e7 | bellard | void OPPROTO glue(op_jz_ecx, SUFFIX)(void) |
355 | 2c0262af | bellard | { |
356 | 14ce26e7 | bellard | if ((DATA_TYPE)ECX == 0) |
357 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
358 | 2c0262af | bellard | FORCE_RET(); |
359 | 2c0262af | bellard | } |
360 | 2c0262af | bellard | |
361 | 14ce26e7 | bellard | void OPPROTO glue(op_jnz_ecx, SUFFIX)(void) |
362 | 2c0262af | bellard | { |
363 | 14ce26e7 | bellard | if ((DATA_TYPE)ECX != 0) |
364 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
365 | 2c0262af | bellard | FORCE_RET(); |
366 | 2c0262af | bellard | } |
367 | 2c0262af | bellard | |
368 | 2c0262af | bellard | #endif
|
369 | 2c0262af | bellard | |
370 | 2c0262af | bellard | /* various optimized set cases */
|
371 | 2c0262af | bellard | |
372 | 2c0262af | bellard | void OPPROTO glue(op_setb_T0_sub, SUFFIX)(void) |
373 | 2c0262af | bellard | { |
374 | 14ce26e7 | bellard | target_long src1, src2; |
375 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
376 | 2c0262af | bellard | src2 = CC_SRC; |
377 | 2c0262af | bellard | |
378 | 2c0262af | bellard | T0 = ((DATA_TYPE)src1 < (DATA_TYPE)src2); |
379 | 2c0262af | bellard | } |
380 | 2c0262af | bellard | |
381 | 2c0262af | bellard | void OPPROTO glue(op_setz_T0_sub, SUFFIX)(void) |
382 | 2c0262af | bellard | { |
383 | 2c0262af | bellard | T0 = ((DATA_TYPE)CC_DST == 0);
|
384 | 2c0262af | bellard | } |
385 | 2c0262af | bellard | |
386 | 2c0262af | bellard | void OPPROTO glue(op_setbe_T0_sub, SUFFIX)(void) |
387 | 2c0262af | bellard | { |
388 | 14ce26e7 | bellard | target_long src1, src2; |
389 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
390 | 2c0262af | bellard | src2 = CC_SRC; |
391 | 2c0262af | bellard | |
392 | 2c0262af | bellard | T0 = ((DATA_TYPE)src1 <= (DATA_TYPE)src2); |
393 | 2c0262af | bellard | } |
394 | 2c0262af | bellard | |
395 | 2c0262af | bellard | void OPPROTO glue(op_sets_T0_sub, SUFFIX)(void) |
396 | 2c0262af | bellard | { |
397 | 2c0262af | bellard | T0 = lshift(CC_DST, -(DATA_BITS - 1)) & 1; |
398 | 2c0262af | bellard | } |
399 | 2c0262af | bellard | |
400 | 2c0262af | bellard | void OPPROTO glue(op_setl_T0_sub, SUFFIX)(void) |
401 | 2c0262af | bellard | { |
402 | 14ce26e7 | bellard | target_long src1, src2; |
403 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
404 | 2c0262af | bellard | src2 = CC_SRC; |
405 | 2c0262af | bellard | |
406 | 2c0262af | bellard | T0 = ((DATA_STYPE)src1 < (DATA_STYPE)src2); |
407 | 2c0262af | bellard | } |
408 | 2c0262af | bellard | |
409 | 2c0262af | bellard | void OPPROTO glue(op_setle_T0_sub, SUFFIX)(void) |
410 | 2c0262af | bellard | { |
411 | 14ce26e7 | bellard | target_long src1, src2; |
412 | 2c0262af | bellard | src1 = CC_DST + CC_SRC; |
413 | 2c0262af | bellard | src2 = CC_SRC; |
414 | 2c0262af | bellard | |
415 | 2c0262af | bellard | T0 = ((DATA_STYPE)src1 <= (DATA_STYPE)src2); |
416 | 2c0262af | bellard | } |
417 | 2c0262af | bellard | |
418 | 2c0262af | bellard | /* shifts */
|
419 | 2c0262af | bellard | |
420 | 2c0262af | bellard | void OPPROTO glue(glue(op_shl, SUFFIX), _T0_T1)(void) |
421 | 2c0262af | bellard | { |
422 | 2c0262af | bellard | int count;
|
423 | 14ce26e7 | bellard | count = T1 & SHIFT1_MASK; |
424 | 2c0262af | bellard | T0 = T0 << count; |
425 | 2c0262af | bellard | FORCE_RET(); |
426 | 2c0262af | bellard | } |
427 | 2c0262af | bellard | |
428 | 2c0262af | bellard | void OPPROTO glue(glue(op_shr, SUFFIX), _T0_T1)(void) |
429 | 2c0262af | bellard | { |
430 | 2c0262af | bellard | int count;
|
431 | 14ce26e7 | bellard | count = T1 & SHIFT1_MASK; |
432 | 2c0262af | bellard | T0 &= DATA_MASK; |
433 | 2c0262af | bellard | T0 = T0 >> count; |
434 | 2c0262af | bellard | FORCE_RET(); |
435 | 2c0262af | bellard | } |
436 | 2c0262af | bellard | |
437 | 2c0262af | bellard | void OPPROTO glue(glue(op_sar, SUFFIX), _T0_T1)(void) |
438 | 2c0262af | bellard | { |
439 | 14ce26e7 | bellard | int count;
|
440 | 14ce26e7 | bellard | target_long src; |
441 | 14ce26e7 | bellard | |
442 | 14ce26e7 | bellard | count = T1 & SHIFT1_MASK; |
443 | 2c0262af | bellard | src = (DATA_STYPE)T0; |
444 | 2c0262af | bellard | T0 = src >> count; |
445 | 2c0262af | bellard | FORCE_RET(); |
446 | 2c0262af | bellard | } |
447 | 2c0262af | bellard | |
448 | 2c0262af | bellard | #undef MEM_WRITE
|
449 | 2c0262af | bellard | #include "ops_template_mem.h" |
450 | 2c0262af | bellard | |
451 | 34e01bbf | bellard | #define MEM_WRITE 0 |
452 | 2c0262af | bellard | #include "ops_template_mem.h" |
453 | 2c0262af | bellard | |
454 | 34e01bbf | bellard | #if !defined(CONFIG_USER_ONLY)
|
455 | 34e01bbf | bellard | #define MEM_WRITE 1 |
456 | 34e01bbf | bellard | #include "ops_template_mem.h" |
457 | 34e01bbf | bellard | |
458 | 34e01bbf | bellard | #define MEM_WRITE 2 |
459 | 34e01bbf | bellard | #include "ops_template_mem.h" |
460 | 34e01bbf | bellard | #endif
|
461 | 34e01bbf | bellard | |
462 | 2c0262af | bellard | /* bit operations */
|
463 | 2c0262af | bellard | #if DATA_BITS >= 16 |
464 | 2c0262af | bellard | |
465 | 2c0262af | bellard | void OPPROTO glue(glue(op_bt, SUFFIX), _T0_T1_cc)(void) |
466 | 2c0262af | bellard | { |
467 | 2c0262af | bellard | int count;
|
468 | 2c0262af | bellard | count = T1 & SHIFT_MASK; |
469 | 2c0262af | bellard | CC_SRC = T0 >> count; |
470 | 2c0262af | bellard | } |
471 | 2c0262af | bellard | |
472 | 2c0262af | bellard | void OPPROTO glue(glue(op_bts, SUFFIX), _T0_T1_cc)(void) |
473 | 2c0262af | bellard | { |
474 | 2c0262af | bellard | int count;
|
475 | 2c0262af | bellard | count = T1 & SHIFT_MASK; |
476 | 2c0262af | bellard | T1 = T0 >> count; |
477 | 14ce26e7 | bellard | T0 |= (((target_long)1) << count);
|
478 | 2c0262af | bellard | } |
479 | 2c0262af | bellard | |
480 | 2c0262af | bellard | void OPPROTO glue(glue(op_btr, SUFFIX), _T0_T1_cc)(void) |
481 | 2c0262af | bellard | { |
482 | 2c0262af | bellard | int count;
|
483 | 2c0262af | bellard | count = T1 & SHIFT_MASK; |
484 | 2c0262af | bellard | T1 = T0 >> count; |
485 | 14ce26e7 | bellard | T0 &= ~(((target_long)1) << count);
|
486 | 2c0262af | bellard | } |
487 | 2c0262af | bellard | |
488 | 2c0262af | bellard | void OPPROTO glue(glue(op_btc, SUFFIX), _T0_T1_cc)(void) |
489 | 2c0262af | bellard | { |
490 | 2c0262af | bellard | int count;
|
491 | 2c0262af | bellard | count = T1 & SHIFT_MASK; |
492 | 2c0262af | bellard | T1 = T0 >> count; |
493 | 14ce26e7 | bellard | T0 ^= (((target_long)1) << count);
|
494 | 14ce26e7 | bellard | } |
495 | 14ce26e7 | bellard | |
496 | 14ce26e7 | bellard | void OPPROTO glue(glue(op_add_bit, SUFFIX), _A0_T1)(void) |
497 | 14ce26e7 | bellard | { |
498 | 14ce26e7 | bellard | A0 += ((DATA_STYPE)T1 >> (3 + SHIFT)) << SHIFT;
|
499 | 2c0262af | bellard | } |
500 | 2c0262af | bellard | |
501 | 2c0262af | bellard | void OPPROTO glue(glue(op_bsf, SUFFIX), _T0_cc)(void) |
502 | 2c0262af | bellard | { |
503 | 14ce26e7 | bellard | int count;
|
504 | 14ce26e7 | bellard | target_long res; |
505 | 14ce26e7 | bellard | |
506 | 2c0262af | bellard | res = T0 & DATA_MASK; |
507 | 2c0262af | bellard | if (res != 0) { |
508 | 2c0262af | bellard | count = 0;
|
509 | 2c0262af | bellard | while ((res & 1) == 0) { |
510 | 2c0262af | bellard | count++; |
511 | 2c0262af | bellard | res >>= 1;
|
512 | 2c0262af | bellard | } |
513 | 686f3f26 | bellard | T1 = count; |
514 | debf7a7c | bellard | CC_DST = 1; /* ZF = 0 */ |
515 | 2c0262af | bellard | } else {
|
516 | 2c0262af | bellard | CC_DST = 0; /* ZF = 1 */ |
517 | 2c0262af | bellard | } |
518 | 2c0262af | bellard | FORCE_RET(); |
519 | 2c0262af | bellard | } |
520 | 2c0262af | bellard | |
521 | 2c0262af | bellard | void OPPROTO glue(glue(op_bsr, SUFFIX), _T0_cc)(void) |
522 | 2c0262af | bellard | { |
523 | 14ce26e7 | bellard | int count;
|
524 | 14ce26e7 | bellard | target_long res; |
525 | 14ce26e7 | bellard | |
526 | 2c0262af | bellard | res = T0 & DATA_MASK; |
527 | 2c0262af | bellard | if (res != 0) { |
528 | 2c0262af | bellard | count = DATA_BITS - 1;
|
529 | 2c0262af | bellard | while ((res & SIGN_MASK) == 0) { |
530 | 2c0262af | bellard | count--; |
531 | 2c0262af | bellard | res <<= 1;
|
532 | 2c0262af | bellard | } |
533 | 686f3f26 | bellard | T1 = count; |
534 | debf7a7c | bellard | CC_DST = 1; /* ZF = 0 */ |
535 | 2c0262af | bellard | } else {
|
536 | 2c0262af | bellard | CC_DST = 0; /* ZF = 1 */ |
537 | 2c0262af | bellard | } |
538 | 2c0262af | bellard | FORCE_RET(); |
539 | 2c0262af | bellard | } |
540 | 2c0262af | bellard | |
541 | 2c0262af | bellard | #endif
|
542 | 2c0262af | bellard | |
543 | 2c0262af | bellard | #if DATA_BITS == 32 |
544 | 2c0262af | bellard | void OPPROTO op_update_bt_cc(void) |
545 | 2c0262af | bellard | { |
546 | 2c0262af | bellard | CC_SRC = T1; |
547 | 2c0262af | bellard | } |
548 | 2c0262af | bellard | #endif
|
549 | 2c0262af | bellard | |
550 | 2c0262af | bellard | /* string operations */
|
551 | 2c0262af | bellard | |
552 | 2c0262af | bellard | void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void) |
553 | 2c0262af | bellard | { |
554 | 2c0262af | bellard | T0 = DF << SHIFT; |
555 | 2c0262af | bellard | } |
556 | 2c0262af | bellard | |
557 | 2c0262af | bellard | /* port I/O */
|
558 | 14ce26e7 | bellard | #if DATA_BITS <= 32 |
559 | 2c0262af | bellard | void OPPROTO glue(glue(op_out, SUFFIX), _T0_T1)(void) |
560 | 2c0262af | bellard | { |
561 | 4487d0ac | bellard | glue(cpu_out, SUFFIX)(env, T0, T1 & DATA_MASK); |
562 | 2c0262af | bellard | } |
563 | 2c0262af | bellard | |
564 | 2c0262af | bellard | void OPPROTO glue(glue(op_in, SUFFIX), _T0_T1)(void) |
565 | 2c0262af | bellard | { |
566 | 4487d0ac | bellard | T1 = glue(cpu_in, SUFFIX)(env, T0); |
567 | 2c0262af | bellard | } |
568 | 2c0262af | bellard | |
569 | 2c0262af | bellard | void OPPROTO glue(glue(op_in, SUFFIX), _DX_T0)(void) |
570 | 2c0262af | bellard | { |
571 | 4487d0ac | bellard | T0 = glue(cpu_in, SUFFIX)(env, EDX & 0xffff);
|
572 | 2c0262af | bellard | } |
573 | 2c0262af | bellard | |
574 | 2c0262af | bellard | void OPPROTO glue(glue(op_out, SUFFIX), _DX_T0)(void) |
575 | 2c0262af | bellard | { |
576 | 4487d0ac | bellard | glue(cpu_out, SUFFIX)(env, EDX & 0xffff, T0);
|
577 | 2c0262af | bellard | } |
578 | 2c0262af | bellard | |
579 | 3e25f951 | bellard | void OPPROTO glue(glue(op_check_io, SUFFIX), _T0)(void) |
580 | 3e25f951 | bellard | { |
581 | 3e25f951 | bellard | glue(glue(check_io, SUFFIX), _T0)(); |
582 | 3e25f951 | bellard | } |
583 | 3e25f951 | bellard | |
584 | 3e25f951 | bellard | void OPPROTO glue(glue(op_check_io, SUFFIX), _DX)(void) |
585 | 3e25f951 | bellard | { |
586 | 3e25f951 | bellard | glue(glue(check_io, SUFFIX), _DX)(); |
587 | 3e25f951 | bellard | } |
588 | 14ce26e7 | bellard | #endif
|
589 | 3e25f951 | bellard | |
590 | 2c0262af | bellard | #undef DATA_BITS
|
591 | 2c0262af | bellard | #undef SHIFT_MASK
|
592 | 14ce26e7 | bellard | #undef SHIFT1_MASK
|
593 | 2c0262af | bellard | #undef SIGN_MASK
|
594 | 2c0262af | bellard | #undef DATA_TYPE
|
595 | 2c0262af | bellard | #undef DATA_STYPE
|
596 | 2c0262af | bellard | #undef DATA_MASK
|
597 | 2c0262af | bellard | #undef SUFFIX |