- tftp_send_optack() was not 64-bit clean (patch from SF bug #1787500)
[bochs-mirror.git] / cpu / lazy_flags.cc
blob4b6cf2eb10f035ca066f759a7e54b63d5245dc19
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: lazy_flags.cc,v 1.34 2007/03/18 19:29:17 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2001 MandrakeSoft S.A.
6 //
7 // MandrakeSoft S.A.
8 // 43, rue d'Aboukir
9 // 75002 Paris - France
10 // http://www.linux-mandrake.com/
11 // http://www.mandrakesoft.com/
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 /////////////////////////////////////////////////////////////////////////
29 #define NEED_CPU_REG_SHORTCUTS 1
30 #include "bochs.h"
31 #include "cpu.h"
32 #define LOG_THIS BX_CPU_THIS_PTR
35 // This array defines a look-up table for the even parity-ness
36 // of an 8bit quantity, for optimal assignment of the parity bit
37 // in the EFLAGS register
38 const bx_bool bx_parity_lookup[256] = {
39 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
40 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
41 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
42 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
43 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
44 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
45 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
46 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
47 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
48 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
49 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
50 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
51 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
52 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
53 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
54 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
57 bx_bool BX_CPU_C::get_CFLazy(void)
59 unsigned cf;
61 BX_ASSERT((BX_CPU_THIS_PTR lf_flags_status & 0x00000f) == BX_LF_INDEX_OSZAPC);
63 switch (BX_CPU_THIS_PTR oszapc.instr) {
64 case BX_INSTR_ADD8:
65 cf = (BX_CPU_THIS_PTR oszapc.result_8 <
66 BX_CPU_THIS_PTR oszapc.op1_8);
67 break;
68 case BX_INSTR_ADD16:
69 cf = (BX_CPU_THIS_PTR oszapc.result_16 <
70 BX_CPU_THIS_PTR oszapc.op1_16);
71 break;
72 case BX_INSTR_ADD32:
73 cf = (BX_CPU_THIS_PTR oszapc.result_32 <
74 BX_CPU_THIS_PTR oszapc.op1_32);
75 break;
76 #if BX_SUPPORT_X86_64
77 case BX_INSTR_ADD64:
78 cf = (BX_CPU_THIS_PTR oszapc.result_64 <
79 BX_CPU_THIS_PTR oszapc.op1_64);
80 break;
81 #endif
82 // used only if CF = 1 when executing ADC instruction
83 case BX_INSTR_ADC8:
84 cf = (BX_CPU_THIS_PTR oszapc.result_8 <=
85 BX_CPU_THIS_PTR oszapc.op1_8);
86 break;
87 // used only if CF = 1 when executing ADC instruction
88 case BX_INSTR_ADC16:
89 cf = (BX_CPU_THIS_PTR oszapc.result_16 <=
90 BX_CPU_THIS_PTR oszapc.op1_16);
91 break;
92 // used only if CF = 1 when executing ADC instruction
93 case BX_INSTR_ADC32:
94 cf = (BX_CPU_THIS_PTR oszapc.result_32 <=
95 BX_CPU_THIS_PTR oszapc.op1_32);
96 break;
97 #if BX_SUPPORT_X86_64
98 // used only if CF = 1 when executing ADC instruction
99 case BX_INSTR_ADC64:
100 cf = (BX_CPU_THIS_PTR oszapc.result_64 <=
101 BX_CPU_THIS_PTR oszapc.op1_64);
102 break;
103 #endif
104 case BX_INSTR_SUB8:
105 cf = (BX_CPU_THIS_PTR oszapc.op1_8 <
106 BX_CPU_THIS_PTR oszapc.op2_8);
107 break;
108 case BX_INSTR_SUB16:
109 cf = (BX_CPU_THIS_PTR oszapc.op1_16 <
110 BX_CPU_THIS_PTR oszapc.op2_16);
111 break;
112 case BX_INSTR_SUB32:
113 cf = (BX_CPU_THIS_PTR oszapc.op1_32 <
114 BX_CPU_THIS_PTR oszapc.op2_32);
115 break;
116 #if BX_SUPPORT_X86_64
117 case BX_INSTR_SUB64:
118 cf = (BX_CPU_THIS_PTR oszapc.op1_64 <
119 BX_CPU_THIS_PTR oszapc.op2_64);
120 break;
121 #endif
122 // used only if CF = 1 when executing SBB instruction
123 case BX_INSTR_SBB8:
124 cf = (BX_CPU_THIS_PTR oszapc.op1_8 < BX_CPU_THIS_PTR oszapc.result_8) ||
125 (BX_CPU_THIS_PTR oszapc.op2_8==0xff);
126 break;
127 // used only if CF = 1 when executing SBB instruction
128 case BX_INSTR_SBB16:
129 cf = (BX_CPU_THIS_PTR oszapc.op1_16 < BX_CPU_THIS_PTR oszapc.result_16) ||
130 (BX_CPU_THIS_PTR oszapc.op2_16==0xffff);
131 break;
132 // used only if CF = 1 when executing SBB instruction
133 case BX_INSTR_SBB32:
134 cf = (BX_CPU_THIS_PTR oszapc.op1_32 < BX_CPU_THIS_PTR oszapc.result_32) ||
135 (BX_CPU_THIS_PTR oszapc.op2_32==0xffffffff);
136 break;
137 #if BX_SUPPORT_X86_64
138 // used only if CF = 1 when executing SBB instruction
139 case BX_INSTR_SBB64:
140 cf = (BX_CPU_THIS_PTR oszapc.op1_64 < BX_CPU_THIS_PTR oszapc.result_64) ||
141 (BX_CPU_THIS_PTR oszapc.op2_64==BX_CONST64(0xffffffffffffffff));
142 break;
143 #endif
144 case BX_INSTR_NEG8:
145 cf = (BX_CPU_THIS_PTR oszapc.result_8 != 0);
146 break;
147 case BX_INSTR_NEG16:
148 cf = (BX_CPU_THIS_PTR oszapc.result_16 != 0);
149 break;
150 case BX_INSTR_NEG32:
151 cf = (BX_CPU_THIS_PTR oszapc.result_32 != 0);
152 break;
153 #if BX_SUPPORT_X86_64
154 case BX_INSTR_NEG64:
155 cf = (BX_CPU_THIS_PTR oszapc.result_64 != 0);
156 break;
157 #endif
158 case BX_INSTR_LOGIC8:
159 case BX_INSTR_LOGIC16:
160 case BX_INSTR_LOGIC32:
161 case BX_INSTR_BITSCAN16:
162 case BX_INSTR_BITSCAN32:
163 #if BX_SUPPORT_X86_64
164 case BX_INSTR_LOGIC64:
165 case BX_INSTR_BITSCAN64:
166 #endif
167 cf = 0;
168 break;
169 case BX_INSTR_SAR8:
170 if (BX_CPU_THIS_PTR oszapc.op2_8 < 8) {
171 cf = (BX_CPU_THIS_PTR oszapc.op1_8 >>
172 (BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
174 else {
175 cf = (BX_CPU_THIS_PTR oszapc.op1_8 & 0x80) > 0;
177 break;
178 case BX_INSTR_SHR8:
179 cf = (BX_CPU_THIS_PTR oszapc.op1_8 >>
180 (BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
181 break;
182 case BX_INSTR_SAR16:
183 if (BX_CPU_THIS_PTR oszapc.op2_16 < 16) {
184 cf = (BX_CPU_THIS_PTR oszapc.op1_16 >>
185 (BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
187 else {
188 cf = (BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000) > 0;
190 break;
191 case BX_INSTR_SHR16:
192 case BX_INSTR_SHRD16:
193 cf = (BX_CPU_THIS_PTR oszapc.op1_16 >>
194 (BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
195 break;
196 case BX_INSTR_SAR32:
197 case BX_INSTR_SHR32:
198 case BX_INSTR_SHRD32:
199 cf = (BX_CPU_THIS_PTR oszapc.op1_32 >>
200 (BX_CPU_THIS_PTR oszapc.op2_32 - 1)) & 0x01;
201 break;
202 #if BX_SUPPORT_X86_64
203 case BX_INSTR_SAR64:
204 case BX_INSTR_SHR64:
205 case BX_INSTR_SHRD64:
206 cf = (BX_CPU_THIS_PTR oszapc.op1_64 >>
207 (BX_CPU_THIS_PTR oszapc.op2_64 - 1)) & 0x01;
208 break;
209 #endif
210 case BX_INSTR_SHL8:
211 if (BX_CPU_THIS_PTR oszapc.op2_8 <= 8) {
212 cf = (BX_CPU_THIS_PTR oszapc.op1_8 >>
213 (8 - BX_CPU_THIS_PTR oszapc.op2_8)) & 0x01;
215 else {
216 cf = 0;
218 break;
219 case BX_INSTR_SHL16:
220 if (BX_CPU_THIS_PTR oszapc.op2_16 <= 16) {
221 cf = (BX_CPU_THIS_PTR oszapc.op1_16 >>
222 (16 - BX_CPU_THIS_PTR oszapc.op2_16)) & 0x01;
224 else {
225 cf = 0;
227 break;
228 case BX_INSTR_SHL32:
229 cf = (BX_CPU_THIS_PTR oszapc.op1_32 >>
230 (32 - BX_CPU_THIS_PTR oszapc.op2_32)) & 0x01;
231 break;
232 #if BX_SUPPORT_X86_64
233 case BX_INSTR_SHL64:
234 cf = (BX_CPU_THIS_PTR oszapc.op1_64 >>
235 (64 - BX_CPU_THIS_PTR oszapc.op2_64)) & 0x01;
236 break;
237 #endif
238 case BX_INSTR_IMUL8:
239 cf = ! ((BX_CPU_THIS_PTR oszapc.op1_8 < 0x80 &&
240 BX_CPU_THIS_PTR oszapc.op2_8 == 0) ||
241 ((BX_CPU_THIS_PTR oszapc.op1_8 & 0x80) &&
242 BX_CPU_THIS_PTR oszapc.op2_8 == 0xff));
243 break;
244 case BX_INSTR_IMUL16:
245 cf = ! ((BX_CPU_THIS_PTR oszapc.op1_16 < 0x8000 &&
246 BX_CPU_THIS_PTR oszapc.op2_16 == 0) ||
247 ((BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000) &&
248 BX_CPU_THIS_PTR oszapc.op2_16 == 0xffff));
249 break;
250 case BX_INSTR_IMUL32:
251 cf = ! ((BX_CPU_THIS_PTR oszapc.op1_32 < 0x80000000 &&
252 BX_CPU_THIS_PTR oszapc.op2_32 == 0) ||
253 ((BX_CPU_THIS_PTR oszapc.op1_32 & 0x80000000) &&
254 BX_CPU_THIS_PTR oszapc.op2_32 == 0xffffffff));
255 break;
256 #if BX_SUPPORT_X86_64
257 case BX_INSTR_IMUL64:
258 cf = ! ((BX_CPU_THIS_PTR oszapc.op1_64 < BX_CONST64(0x8000000000000000) &&
259 BX_CPU_THIS_PTR oszapc.op2_64 == 0) ||
260 ((BX_CPU_THIS_PTR oszapc.op1_64 & BX_CONST64(0x8000000000000000)) &&
261 BX_CPU_THIS_PTR oszapc.op2_64 == BX_CONST64(0xffffffffffffffff)));
262 break;
263 #endif
264 case BX_INSTR_MUL8:
265 cf = (BX_CPU_THIS_PTR oszapc.op2_8 != 0);
266 break;
267 case BX_INSTR_MUL16:
268 cf = (BX_CPU_THIS_PTR oszapc.op2_16 != 0);
269 break;
270 case BX_INSTR_MUL32:
271 cf = (BX_CPU_THIS_PTR oszapc.op2_32 != 0);
272 break;
273 #if BX_SUPPORT_X86_64
274 case BX_INSTR_MUL64:
275 cf = (BX_CPU_THIS_PTR oszapc.op2_64 != 0);
276 break;
277 #endif
278 default:
279 cf = 0; // Keep compiler quiet.
280 BX_PANIC(("get_CF: OSZAPC: unknown instr %u",
281 (unsigned) BX_CPU_THIS_PTR oszapc.instr));
284 BX_CPU_THIS_PTR lf_flags_status &= 0xfffff0;
285 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<0);
286 BX_CPU_THIS_PTR eflags.val32 |= (!!cf)<<0;
287 return(cf);
290 bx_bool BX_CPU_C::get_AFLazy(void)
292 unsigned af;
294 switch ((BX_CPU_THIS_PTR lf_flags_status>>8) & 0x00000f) {
295 case BX_LF_INDEX_OSZAPC:
296 switch (BX_CPU_THIS_PTR oszapc.instr) {
297 case BX_INSTR_ADD8:
298 case BX_INSTR_ADC8:
299 case BX_INSTR_SUB8:
300 case BX_INSTR_SBB8:
301 af =
302 ((BX_CPU_THIS_PTR oszapc.op1_8 ^
303 BX_CPU_THIS_PTR oszapc.op2_8) ^
304 BX_CPU_THIS_PTR oszapc.result_8) & 0x10;
305 break;
306 case BX_INSTR_ADD16:
307 case BX_INSTR_ADC16:
308 case BX_INSTR_SUB16:
309 case BX_INSTR_SBB16:
310 af =
311 ((BX_CPU_THIS_PTR oszapc.op1_16 ^
312 BX_CPU_THIS_PTR oszapc.op2_16) ^
313 BX_CPU_THIS_PTR oszapc.result_16) & 0x10;
314 break;
315 case BX_INSTR_ADD32:
316 case BX_INSTR_ADC32:
317 case BX_INSTR_SUB32:
318 case BX_INSTR_SBB32:
319 af =
320 ((BX_CPU_THIS_PTR oszapc.op1_32 ^
321 BX_CPU_THIS_PTR oszapc.op2_32) ^
322 BX_CPU_THIS_PTR oszapc.result_32) & 0x10;
323 break;
324 #if BX_SUPPORT_X86_64
325 case BX_INSTR_ADD64:
326 case BX_INSTR_ADC64:
327 case BX_INSTR_SUB64:
328 case BX_INSTR_SBB64:
329 af =
330 ((BX_CPU_THIS_PTR oszapc.op1_64 ^
331 BX_CPU_THIS_PTR oszapc.op2_64) ^
332 BX_CPU_THIS_PTR oszapc.result_64) & 0x10;
333 break;
334 #endif
335 case BX_INSTR_NEG8:
336 af = (BX_CPU_THIS_PTR oszapc.result_8 & 0x0f) != 0;
337 break;
338 case BX_INSTR_NEG16:
339 af = (BX_CPU_THIS_PTR oszapc.result_16 & 0x0f) != 0;
340 break;
341 case BX_INSTR_NEG32:
342 af = (BX_CPU_THIS_PTR oszapc.result_32 & 0x0f) != 0;
343 break;
344 #if BX_SUPPORT_X86_64
345 case BX_INSTR_NEG64:
346 af = (BX_CPU_THIS_PTR oszapc.result_64 & 0x0f) != 0;
347 break;
348 #endif
349 case BX_INSTR_LOGIC8:
350 case BX_INSTR_LOGIC16:
351 case BX_INSTR_LOGIC32:
352 case BX_INSTR_BITSCAN16:
353 case BX_INSTR_BITSCAN32:
354 #if BX_SUPPORT_X86_64
355 case BX_INSTR_LOGIC64:
356 case BX_INSTR_BITSCAN64:
357 case BX_INSTR_SAR64:
358 case BX_INSTR_SHR64:
359 case BX_INSTR_SHRD64:
360 case BX_INSTR_SHL64:
361 case BX_INSTR_IMUL64:
362 case BX_INSTR_MUL64:
363 #endif
364 case BX_INSTR_SAR8:
365 case BX_INSTR_SAR16:
366 case BX_INSTR_SAR32:
367 case BX_INSTR_SHR8:
368 case BX_INSTR_SHR16:
369 case BX_INSTR_SHR32:
370 case BX_INSTR_SHRD16:
371 case BX_INSTR_SHRD32:
372 case BX_INSTR_SHL8:
373 case BX_INSTR_SHL16:
374 case BX_INSTR_SHL32:
375 case BX_INSTR_IMUL8:
376 case BX_INSTR_IMUL16:
377 case BX_INSTR_IMUL32:
378 case BX_INSTR_MUL8:
379 case BX_INSTR_MUL16:
380 case BX_INSTR_MUL32:
381 af = 0;
382 break;
383 default:
384 af = 0; // Keep compiler quiet.
385 BX_PANIC(("get_AF: OSZAPC: unknown instr %u",
386 (unsigned) BX_CPU_THIS_PTR oszapc.instr));
388 BX_CPU_THIS_PTR lf_flags_status &= 0xfff0ff;
389 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<4);
390 BX_CPU_THIS_PTR eflags.val32 |= (!!af)<<4;
391 return(af);
393 case BX_LF_INDEX_OSZAP:
394 switch (BX_CPU_THIS_PTR oszap.instr) {
395 case BX_INSTR_INC8:
396 af = (BX_CPU_THIS_PTR oszap.result_8 & 0x0f) == 0;
397 break;
398 case BX_INSTR_INC16:
399 af = (BX_CPU_THIS_PTR oszap.result_16 & 0x0f) == 0;
400 break;
401 case BX_INSTR_INC32:
402 af = (BX_CPU_THIS_PTR oszap.result_32 & 0x0f) == 0;
403 break;
404 #if BX_SUPPORT_X86_64
405 case BX_INSTR_INC64:
406 af = (BX_CPU_THIS_PTR oszap.result_64 & 0x0f) == 0;
407 break;
408 #endif
409 case BX_INSTR_DEC8:
410 af = (BX_CPU_THIS_PTR oszap.result_8 & 0x0f) == 0x0f;
411 break;
412 case BX_INSTR_DEC16:
413 af = (BX_CPU_THIS_PTR oszap.result_16 & 0x0f) == 0x0f;
414 break;
415 case BX_INSTR_DEC32:
416 af = (BX_CPU_THIS_PTR oszap.result_32 & 0x0f) == 0x0f;
417 break;
418 #if BX_SUPPORT_X86_64
419 case BX_INSTR_DEC64:
420 af = (BX_CPU_THIS_PTR oszap.result_64 & 0x0f) == 0x0f;
421 break;
422 #endif
423 default:
424 af = 0; // Keep compiler quiet.
425 BX_PANIC(("get_AF: OSZAP: unknown instr %u",
426 (unsigned) BX_CPU_THIS_PTR oszap.instr));
428 BX_CPU_THIS_PTR lf_flags_status &= 0xfff0ff;
429 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<4);
430 BX_CPU_THIS_PTR eflags.val32 |= (!!af)<<4;
431 return(af);
433 default:
434 BX_PANIC(("get_AF: unknown case"));
435 return(0);
439 bx_bool BX_CPU_C::get_ZFLazy(void)
441 unsigned zf;
443 switch ((BX_CPU_THIS_PTR lf_flags_status>>12) & 0x00000f) {
444 case BX_LF_INDEX_OSZAPC:
445 switch (BX_CPU_THIS_PTR oszapc.instr) {
446 case BX_INSTR_LOGIC8:
447 case BX_INSTR_ADD8:
448 case BX_INSTR_ADC8:
449 case BX_INSTR_SUB8:
450 case BX_INSTR_SBB8:
451 case BX_INSTR_NEG8:
452 case BX_INSTR_SAR8:
453 case BX_INSTR_SHR8:
454 case BX_INSTR_SHL8:
455 zf = (BX_CPU_THIS_PTR oszapc.result_8 == 0);
456 break;
457 case BX_INSTR_LOGIC16:
458 case BX_INSTR_ADD16:
459 case BX_INSTR_ADC16:
460 case BX_INSTR_SUB16:
461 case BX_INSTR_SBB16:
462 case BX_INSTR_NEG16:
463 case BX_INSTR_SAR16:
464 case BX_INSTR_SHR16:
465 case BX_INSTR_SHRD16:
466 case BX_INSTR_SHL16:
467 zf = (BX_CPU_THIS_PTR oszapc.result_16 == 0);
468 break;
469 case BX_INSTR_LOGIC32:
470 case BX_INSTR_ADD32:
471 case BX_INSTR_ADC32:
472 case BX_INSTR_SUB32:
473 case BX_INSTR_SBB32:
474 case BX_INSTR_NEG32:
475 case BX_INSTR_SAR32:
476 case BX_INSTR_SHR32:
477 case BX_INSTR_SHRD32:
478 case BX_INSTR_SHL32:
479 zf = (BX_CPU_THIS_PTR oszapc.result_32 == 0);
480 break;
481 #if BX_SUPPORT_X86_64
482 case BX_INSTR_LOGIC64:
483 case BX_INSTR_ADD64:
484 case BX_INSTR_ADC64:
485 case BX_INSTR_SUB64:
486 case BX_INSTR_SBB64:
487 case BX_INSTR_NEG64:
488 case BX_INSTR_SAR64:
489 case BX_INSTR_SHR64:
490 case BX_INSTR_SHRD64:
491 case BX_INSTR_SHL64:
492 zf = (BX_CPU_THIS_PTR oszapc.result_64 == 0);
493 break;
494 #endif
495 case BX_INSTR_IMUL8:
496 case BX_INSTR_MUL8:
497 zf = (BX_CPU_THIS_PTR oszapc.op1_8 == 0);
498 break;
499 case BX_INSTR_IMUL16:
500 case BX_INSTR_MUL16:
501 zf = (BX_CPU_THIS_PTR oszapc.op1_16 == 0);
502 break;
503 case BX_INSTR_IMUL32:
504 case BX_INSTR_MUL32:
505 zf = (BX_CPU_THIS_PTR oszapc.op1_32 == 0);
506 break;
507 #if BX_SUPPORT_X86_64
508 case BX_INSTR_IMUL64:
509 case BX_INSTR_MUL64:
510 zf = (BX_CPU_THIS_PTR oszapc.op1_64 == 0);
511 break;
512 #endif
513 case BX_INSTR_BITSCAN16:
514 case BX_INSTR_BITSCAN32:
515 #if BX_SUPPORT_X86_64
516 case BX_INSTR_BITSCAN64:
517 #endif
518 zf = 0;
519 break;
520 default:
521 zf = 0;
522 BX_PANIC(("get_ZF: OSZAPC: unknown instr"));
524 BX_CPU_THIS_PTR lf_flags_status &= 0xff0fff;
525 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<6);
526 BX_CPU_THIS_PTR eflags.val32 |= zf<<6; // zf always exactly 0 or 1.
527 return(zf);
529 case BX_LF_INDEX_OSZAP:
530 switch (BX_CPU_THIS_PTR oszap.instr) {
531 case BX_INSTR_INC8:
532 case BX_INSTR_DEC8:
533 zf = (BX_CPU_THIS_PTR oszap.result_8 == 0);
534 break;
535 case BX_INSTR_INC16:
536 case BX_INSTR_DEC16:
537 zf = (BX_CPU_THIS_PTR oszap.result_16 == 0);
538 break;
539 case BX_INSTR_INC32:
540 case BX_INSTR_DEC32:
541 zf = (BX_CPU_THIS_PTR oszap.result_32 == 0);
542 break;
543 #if BX_SUPPORT_X86_64
544 case BX_INSTR_INC64:
545 case BX_INSTR_DEC64:
546 zf = (BX_CPU_THIS_PTR oszap.result_64 == 0);
547 break;
548 #endif
549 default:
550 zf = 0;
551 BX_PANIC(("get_ZF: OSZAP: unknown instr"));
553 BX_CPU_THIS_PTR lf_flags_status &= 0xff0fff;
554 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<6);
555 BX_CPU_THIS_PTR eflags.val32 |= zf<<6; // zf always exactly 0 or 1.
556 return(zf);
558 default:
559 BX_PANIC(("get_ZF: unknown case"));
560 return(0);
564 bx_bool BX_CPU_C::get_SFLazy(void)
566 unsigned sf;
568 switch ((BX_CPU_THIS_PTR lf_flags_status>>16) & 0x00000f) {
569 case BX_LF_INDEX_OSZAPC:
570 switch (BX_CPU_THIS_PTR oszapc.instr) {
571 case BX_INSTR_LOGIC8:
572 case BX_INSTR_ADD8:
573 case BX_INSTR_ADC8:
574 case BX_INSTR_SUB8:
575 case BX_INSTR_SBB8:
576 case BX_INSTR_NEG8:
577 case BX_INSTR_SAR8:
578 case BX_INSTR_SHR8:
579 case BX_INSTR_SHL8:
580 sf = (BX_CPU_THIS_PTR oszapc.result_8 >= 0x80);
581 break;
582 case BX_INSTR_LOGIC16:
583 case BX_INSTR_ADD16:
584 case BX_INSTR_ADC16:
585 case BX_INSTR_SUB16:
586 case BX_INSTR_SBB16:
587 case BX_INSTR_NEG16:
588 case BX_INSTR_SAR16:
589 case BX_INSTR_SHR16:
590 case BX_INSTR_SHRD16:
591 case BX_INSTR_SHL16:
592 case BX_INSTR_BITSCAN16:
593 sf = (BX_CPU_THIS_PTR oszapc.result_16 >= 0x8000);
594 break;
595 case BX_INSTR_LOGIC32:
596 case BX_INSTR_ADD32:
597 case BX_INSTR_ADC32:
598 case BX_INSTR_SUB32:
599 case BX_INSTR_SBB32:
600 case BX_INSTR_NEG32:
601 case BX_INSTR_SAR32:
602 case BX_INSTR_SHR32:
603 case BX_INSTR_SHRD32:
604 case BX_INSTR_SHL32:
605 case BX_INSTR_BITSCAN32:
606 sf = (BX_CPU_THIS_PTR oszapc.result_32 >= 0x80000000);
607 break;
608 #if BX_SUPPORT_X86_64
609 case BX_INSTR_LOGIC64:
610 case BX_INSTR_ADD64:
611 case BX_INSTR_ADC64:
612 case BX_INSTR_SUB64:
613 case BX_INSTR_SBB64:
614 case BX_INSTR_NEG64:
615 case BX_INSTR_SAR64:
616 case BX_INSTR_SHR64:
617 case BX_INSTR_SHRD64:
618 case BX_INSTR_SHL64:
619 case BX_INSTR_BITSCAN64:
620 sf = (BX_CPU_THIS_PTR oszapc.result_64 >= BX_CONST64(0x8000000000000000));
621 break;
622 #endif
623 case BX_INSTR_IMUL8:
624 case BX_INSTR_MUL8:
625 sf = (BX_CPU_THIS_PTR oszapc.op1_8 >= 0x80);
626 break;
627 case BX_INSTR_IMUL16:
628 case BX_INSTR_MUL16:
629 sf = (BX_CPU_THIS_PTR oszapc.op1_16 >= 0x8000);
630 break;
631 case BX_INSTR_IMUL32:
632 case BX_INSTR_MUL32:
633 sf = (BX_CPU_THIS_PTR oszapc.op1_32 >= 0x80000000);
634 break;
635 #if BX_SUPPORT_X86_64
636 case BX_INSTR_IMUL64:
637 case BX_INSTR_MUL64:
638 sf = (BX_CPU_THIS_PTR oszapc.op1_64 >= BX_CONST64(0x8000000000000000));
639 break;
640 #endif
641 default:
642 sf = 0; // Keep compiler quiet.
643 BX_PANIC(("get_SF: OSZAPC: unknown instr"));
645 BX_CPU_THIS_PTR lf_flags_status &= 0xf0ffff;
646 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<7);
647 BX_CPU_THIS_PTR eflags.val32 |= (!!sf)<<7;
648 return(sf);
650 case BX_LF_INDEX_OSZAP:
651 switch (BX_CPU_THIS_PTR oszap.instr) {
652 case BX_INSTR_INC8:
653 case BX_INSTR_DEC8:
654 sf = (BX_CPU_THIS_PTR oszap.result_8 >= 0x80);
655 break;
656 case BX_INSTR_INC16:
657 case BX_INSTR_DEC16:
658 sf = (BX_CPU_THIS_PTR oszap.result_16 >= 0x8000);
659 break;
660 case BX_INSTR_INC32:
661 case BX_INSTR_DEC32:
662 sf = (BX_CPU_THIS_PTR oszap.result_32 >= 0x80000000);
663 break;
664 #if BX_SUPPORT_X86_64
665 case BX_INSTR_INC64:
666 case BX_INSTR_DEC64:
667 sf = (BX_CPU_THIS_PTR oszap.result_64 >= BX_CONST64(0x8000000000000000));
668 break;
669 #endif
670 default:
671 sf = 0; // Keep compiler quiet.
672 BX_PANIC(("get_SF: OSZAP: unknown instr"));
674 BX_CPU_THIS_PTR lf_flags_status &= 0xf0ffff;
675 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<7);
676 BX_CPU_THIS_PTR eflags.val32 |= (!!sf)<<7;
677 return(sf);
679 default:
680 BX_PANIC(("get_SF: unknown case"));
681 return(0);
685 #define GET_ADD_OVERFLOW(op1, op2, result, mask) \
686 (((~((op1) ^ (op2)) & ((op2) ^ (result))) & (mask)) != 0)
688 #define GET_SUB_OVERFLOW(op1, op2, result, mask) \
689 (((((op1) ^ (op2)) & ((op1) ^ (result))) & (mask)) != 0)
691 bx_bool BX_CPU_C::get_OFLazy(void)
693 unsigned of;
695 switch ((BX_CPU_THIS_PTR lf_flags_status>>20) & 0x00000f) {
696 case BX_LF_INDEX_OSZAPC:
697 switch (BX_CPU_THIS_PTR oszapc.instr) {
698 case BX_INSTR_ADD8:
699 case BX_INSTR_ADC8:
700 of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8, BX_CPU_THIS_PTR oszapc.op2_8,
701 BX_CPU_THIS_PTR oszapc.result_8, 0x80);
702 break;
703 case BX_INSTR_ADD16:
704 case BX_INSTR_ADC16:
705 of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16, BX_CPU_THIS_PTR oszapc.op2_16,
706 BX_CPU_THIS_PTR oszapc.result_16, 0x8000);
707 break;
708 case BX_INSTR_ADD32:
709 case BX_INSTR_ADC32:
710 of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32, BX_CPU_THIS_PTR oszapc.op2_32,
711 BX_CPU_THIS_PTR oszapc.result_32, 0x80000000);
712 break;
713 #if BX_SUPPORT_X86_64
714 case BX_INSTR_ADD64:
715 case BX_INSTR_ADC64:
716 of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64, BX_CPU_THIS_PTR oszapc.op2_64,
717 BX_CPU_THIS_PTR oszapc.result_64, BX_CONST64(0x8000000000000000));
718 break;
719 #endif
720 case BX_INSTR_SUB8:
721 case BX_INSTR_SBB8:
722 of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8, BX_CPU_THIS_PTR oszapc.op2_8,
723 BX_CPU_THIS_PTR oszapc.result_8, 0x80);
724 break;
725 case BX_INSTR_SUB16:
726 case BX_INSTR_SBB16:
727 of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16, BX_CPU_THIS_PTR oszapc.op2_16,
728 BX_CPU_THIS_PTR oszapc.result_16, 0x8000);
729 break;
730 case BX_INSTR_SUB32:
731 case BX_INSTR_SBB32:
732 of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32, BX_CPU_THIS_PTR oszapc.op2_32,
733 BX_CPU_THIS_PTR oszapc.result_32, 0x80000000);
734 break;
735 #if BX_SUPPORT_X86_64
736 case BX_INSTR_SUB64:
737 case BX_INSTR_SBB64:
738 of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64, BX_CPU_THIS_PTR oszapc.op2_64,
739 BX_CPU_THIS_PTR oszapc.result_64, BX_CONST64(0x8000000000000000));
740 break;
741 #endif
742 case BX_INSTR_NEG8:
743 of = (BX_CPU_THIS_PTR oszapc.result_8 == 0x80);
744 break;
745 case BX_INSTR_NEG16:
746 of = (BX_CPU_THIS_PTR oszapc.result_16 == 0x8000);
747 break;
748 case BX_INSTR_NEG32:
749 of = (BX_CPU_THIS_PTR oszapc.result_32 == 0x80000000);
750 break;
751 #if BX_SUPPORT_X86_64
752 case BX_INSTR_NEG64:
753 of = (BX_CPU_THIS_PTR oszapc.result_64 == BX_CONST64(0x8000000000000000));
754 break;
755 #endif
756 case BX_INSTR_LOGIC8:
757 case BX_INSTR_LOGIC16:
758 case BX_INSTR_LOGIC32:
759 case BX_INSTR_BITSCAN16:
760 case BX_INSTR_BITSCAN32:
761 case BX_INSTR_SAR8:
762 case BX_INSTR_SAR16:
763 case BX_INSTR_SAR32:
764 #if BX_SUPPORT_X86_64
765 case BX_INSTR_LOGIC64:
766 case BX_INSTR_BITSCAN64:
767 case BX_INSTR_SAR64:
768 #endif
769 of = 0;
770 break;
771 case BX_INSTR_SHR8:
772 if (BX_CPU_THIS_PTR oszapc.op2_8 == 1)
773 of = (BX_CPU_THIS_PTR oszapc.op1_8 >= 0x80);
774 else
775 of = 0; /* undocumented, but hardware really does it */
776 break;
777 case BX_INSTR_SHR16:
778 if (BX_CPU_THIS_PTR oszapc.op2_16 == 1)
779 of = (BX_CPU_THIS_PTR oszapc.op1_16 >= 0x8000);
780 else
781 of = 0; /* undocumented, but hardware really does it */
782 break;
783 case BX_INSTR_SHR32:
784 if (BX_CPU_THIS_PTR oszapc.op2_32 == 1)
785 of = (BX_CPU_THIS_PTR oszapc.op1_32 >= 0x80000000);
786 else
787 of = 0; /* undocumented, but hardware really does it */
788 break;
789 #if BX_SUPPORT_X86_64
790 case BX_INSTR_SHR64:
791 if (BX_CPU_THIS_PTR oszapc.op2_64 == 1)
792 of = (BX_CPU_THIS_PTR oszapc.op1_64 >= BX_CONST64(0x8000000000000000));
793 else
794 of = 0; /* undocumented, but hardware really does it */
795 break;
796 #endif
797 case BX_INSTR_SHRD16:
798 /* undocumented, but this formula works right for any shift count */
799 of = (((BX_CPU_THIS_PTR oszapc.result_16 << 1) ^
800 BX_CPU_THIS_PTR oszapc.result_16) & 0x8000) > 0;
801 break;
802 case BX_INSTR_SHRD32:
803 /* undocumented, but this formula works right for any shift count */
804 of = (((BX_CPU_THIS_PTR oszapc.result_32 << 1) ^
805 BX_CPU_THIS_PTR oszapc.result_32) & 0x80000000) > 0;
806 break;
807 #if BX_SUPPORT_X86_64
808 case BX_INSTR_SHRD64:
809 /* undocumented, but this formula works right for any shift count */
810 of = (((BX_CPU_THIS_PTR oszapc.result_64 << 1) ^
811 BX_CPU_THIS_PTR oszapc.result_64) & BX_CONST64(0x8000000000000000)) > 0;
812 break;
813 #endif
814 case BX_INSTR_SHL8:
815 if (BX_CPU_THIS_PTR oszapc.op2_8 == 1)
816 of = ((BX_CPU_THIS_PTR oszapc.op1_8 ^
817 BX_CPU_THIS_PTR oszapc.result_8) & 0x80) > 0;
818 else
819 of = (((BX_CPU_THIS_PTR oszapc.op1_8 <<
820 (BX_CPU_THIS_PTR oszapc.op2_8 - 1)) ^
821 BX_CPU_THIS_PTR oszapc.result_8) & 0x80) > 0;
822 break;
823 case BX_INSTR_SHL16:
824 if (BX_CPU_THIS_PTR oszapc.op2_16 == 1)
825 of = ((BX_CPU_THIS_PTR oszapc.op1_16 ^
826 BX_CPU_THIS_PTR oszapc.result_16) & 0x8000) > 0;
827 else
828 of = (((BX_CPU_THIS_PTR oszapc.op1_16 <<
829 (BX_CPU_THIS_PTR oszapc.op2_16 - 1)) ^
830 BX_CPU_THIS_PTR oszapc.result_16) & 0x8000) > 0;
831 break;
832 case BX_INSTR_SHL32:
833 if (BX_CPU_THIS_PTR oszapc.op2_32 == 1)
834 of = ((BX_CPU_THIS_PTR oszapc.op1_32 ^
835 BX_CPU_THIS_PTR oszapc.result_32) & 0x80000000) > 0;
836 else
837 of = (((BX_CPU_THIS_PTR oszapc.op1_32 <<
838 (BX_CPU_THIS_PTR oszapc.op2_32 - 1)) ^
839 BX_CPU_THIS_PTR oszapc.result_32) & 0x80000000) > 0;
840 break;
841 #if BX_SUPPORT_X86_64
842 case BX_INSTR_SHL64:
843 if (BX_CPU_THIS_PTR oszapc.op2_64 == 1)
844 of = ((BX_CPU_THIS_PTR oszapc.op1_64 ^
845 BX_CPU_THIS_PTR oszapc.result_64) & BX_CONST64(0x8000000000000000)) > 0;
846 else
847 of = (((BX_CPU_THIS_PTR oszapc.op1_64 <<
848 (BX_CPU_THIS_PTR oszapc.op2_64 - 1)) ^
849 BX_CPU_THIS_PTR oszapc.result_64) & BX_CONST64(0x8000000000000000)) > 0;
850 break;
851 #endif
852 case BX_INSTR_IMUL8:
853 of = ! ((BX_CPU_THIS_PTR oszapc.op1_8 < 0x80 &&
854 BX_CPU_THIS_PTR oszapc.op2_8 == 0) ||
855 ((BX_CPU_THIS_PTR oszapc.op1_8 & 0x80) &&
856 BX_CPU_THIS_PTR oszapc.op2_8 == 0xff));
857 break;
858 case BX_INSTR_IMUL16:
859 of = ! ((BX_CPU_THIS_PTR oszapc.op1_16 < 0x8000 &&
860 BX_CPU_THIS_PTR oszapc.op2_16 == 0) ||
861 ((BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000) &&
862 BX_CPU_THIS_PTR oszapc.op2_16 == 0xffff));
863 break;
864 case BX_INSTR_IMUL32:
865 of = ! ((BX_CPU_THIS_PTR oszapc.op1_32 < 0x80000000 &&
866 BX_CPU_THIS_PTR oszapc.op2_32 == 0) ||
867 ((BX_CPU_THIS_PTR oszapc.op1_32 & 0x80000000) &&
868 BX_CPU_THIS_PTR oszapc.op2_32 == 0xffffffff));
869 break;
870 #if BX_SUPPORT_X86_64
871 case BX_INSTR_IMUL64:
872 of = ! ((BX_CPU_THIS_PTR oszapc.op1_64 < BX_CONST64(0x8000000000000000) &&
873 BX_CPU_THIS_PTR oszapc.op2_64 == 0) ||
874 ((BX_CPU_THIS_PTR oszapc.op1_64 & BX_CONST64(0x8000000000000000)) &&
875 BX_CPU_THIS_PTR oszapc.op2_64 == BX_CONST64(0xffffffffffffffff)));
876 break;
877 #endif
878 case BX_INSTR_MUL8:
879 of = (BX_CPU_THIS_PTR oszapc.op2_8 != 0);
880 break;
881 case BX_INSTR_MUL16:
882 of = (BX_CPU_THIS_PTR oszapc.op2_16 != 0);
883 break;
884 case BX_INSTR_MUL32:
885 of = (BX_CPU_THIS_PTR oszapc.op2_32 != 0);
886 break;
887 #if BX_SUPPORT_X86_64
888 case BX_INSTR_MUL64:
889 of = (BX_CPU_THIS_PTR oszapc.op2_64 != 0);
890 break;
891 #endif
892 default:
893 of = 0; // Keep compiler happy.
894 BX_PANIC(("get_OF: OSZAPC: unknown instr"));
896 BX_CPU_THIS_PTR lf_flags_status &= 0x0fffff;
897 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<11);
898 BX_CPU_THIS_PTR eflags.val32 |= (!!of)<<11;
899 return(of);
901 case BX_LF_INDEX_OSZAP:
902 switch (BX_CPU_THIS_PTR oszap.instr) {
903 case BX_INSTR_INC8:
904 of = (BX_CPU_THIS_PTR oszap.result_8 == 0x80);
905 break;
906 case BX_INSTR_INC16:
907 of = (BX_CPU_THIS_PTR oszap.result_16 == 0x8000);
908 break;
909 case BX_INSTR_INC32:
910 of = (BX_CPU_THIS_PTR oszap.result_32 == 0x80000000);
911 break;
912 #if BX_SUPPORT_X86_64
913 case BX_INSTR_INC64:
914 of = (BX_CPU_THIS_PTR oszap.result_64 == BX_CONST64(0x8000000000000000));
915 break;
916 #endif
917 case BX_INSTR_DEC8:
918 of = (BX_CPU_THIS_PTR oszap.result_8 == 0x7F);
919 break;
920 case BX_INSTR_DEC16:
921 of = (BX_CPU_THIS_PTR oszap.result_16 == 0x7FFF);
922 break;
923 case BX_INSTR_DEC32:
924 of = (BX_CPU_THIS_PTR oszap.result_32 == 0x7FFFFFFF);
925 break;
926 #if BX_SUPPORT_X86_64
927 case BX_INSTR_DEC64:
928 of = (BX_CPU_THIS_PTR oszap.result_64 == BX_CONST64(0x7FFFFFFFFFFFFFFF));
929 break;
930 #endif
931 default:
932 of = 0; // Keep compiler happy.
933 BX_PANIC(("get_OF: OSZAP: unknown instr"));
935 BX_CPU_THIS_PTR lf_flags_status &= 0x0fffff;
936 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<11);
937 BX_CPU_THIS_PTR eflags.val32 |= (!!of)<<11;
938 return(of);
940 default:
941 BX_PANIC(("get_OF: unknown case"));
942 return(0);
946 bx_bool BX_CPU_C::get_PFLazy(void)
948 unsigned pf;
950 switch ((BX_CPU_THIS_PTR lf_flags_status>>4) & 0x00000f) {
951 case BX_LF_INDEX_OSZAPC:
952 switch (BX_CPU_THIS_PTR oszapc.instr) {
953 case BX_INSTR_LOGIC8:
954 case BX_INSTR_ADD8:
955 case BX_INSTR_ADC8:
956 case BX_INSTR_SUB8:
957 case BX_INSTR_SBB8:
958 case BX_INSTR_NEG8:
959 case BX_INSTR_SAR8:
960 case BX_INSTR_SHR8:
961 case BX_INSTR_SHL8:
962 pf = bx_parity_lookup[BX_CPU_THIS_PTR oszapc.result_8];
963 break;
964 case BX_INSTR_LOGIC16:
965 case BX_INSTR_ADD16:
966 case BX_INSTR_ADC16:
967 case BX_INSTR_SUB16:
968 case BX_INSTR_SBB16:
969 case BX_INSTR_NEG16:
970 case BX_INSTR_SAR16:
971 case BX_INSTR_SHR16:
972 case BX_INSTR_SHRD16:
973 case BX_INSTR_SHL16:
974 case BX_INSTR_BITSCAN16:
975 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_16];
976 break;
977 case BX_INSTR_LOGIC32:
978 case BX_INSTR_ADD32:
979 case BX_INSTR_ADC32:
980 case BX_INSTR_SUB32:
981 case BX_INSTR_SBB32:
982 case BX_INSTR_NEG32:
983 case BX_INSTR_SAR32:
984 case BX_INSTR_SHR32:
985 case BX_INSTR_SHRD32:
986 case BX_INSTR_SHL32:
987 case BX_INSTR_BITSCAN32:
988 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_32];
989 break;
990 #if BX_SUPPORT_X86_64
991 case BX_INSTR_LOGIC64:
992 case BX_INSTR_ADD64:
993 case BX_INSTR_ADC64:
994 case BX_INSTR_SUB64:
995 case BX_INSTR_SBB64:
996 case BX_INSTR_NEG64:
997 case BX_INSTR_SAR64:
998 case BX_INSTR_SHR64:
999 case BX_INSTR_SHRD64:
1000 case BX_INSTR_SHL64:
1001 case BX_INSTR_BITSCAN64:
1002 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_64];
1003 break;
1004 #endif
1005 case BX_INSTR_IMUL8:
1006 case BX_INSTR_MUL8:
1007 pf = bx_parity_lookup[BX_CPU_THIS_PTR oszapc.op1_8];
1008 break;
1009 case BX_INSTR_IMUL16:
1010 case BX_INSTR_MUL16:
1011 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.op1_16];
1012 break;
1013 case BX_INSTR_IMUL32:
1014 case BX_INSTR_MUL32:
1015 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.op1_32];
1016 break;
1017 #if BX_SUPPORT_X86_64
1018 case BX_INSTR_IMUL64:
1019 case BX_INSTR_MUL64:
1020 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.op1_64];
1021 break;
1022 #endif
1023 default:
1024 pf = 0; // Keep compiler quiet.
1025 BX_PANIC(("get_PF: OSZAPC: unknown instr"));
1027 BX_CPU_THIS_PTR lf_flags_status &= 0xffff0f;
1028 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<2);
1029 BX_CPU_THIS_PTR eflags.val32 |= (pf)<<2; // pf is always 0 or 1 here
1030 return(pf);
1032 case BX_LF_INDEX_OSZAP:
1033 switch (BX_CPU_THIS_PTR oszap.instr) {
1034 case BX_INSTR_INC8:
1035 case BX_INSTR_DEC8:
1036 pf = bx_parity_lookup[BX_CPU_THIS_PTR oszap.result_8];
1037 break;
1038 case BX_INSTR_INC16:
1039 case BX_INSTR_DEC16:
1040 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszap.result_16];
1041 break;
1042 case BX_INSTR_INC32:
1043 case BX_INSTR_DEC32:
1044 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszap.result_32];
1045 break;
1046 #if BX_SUPPORT_X86_64
1047 case BX_INSTR_INC64:
1048 case BX_INSTR_DEC64:
1049 pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszap.result_64];
1050 break;
1051 #endif
1052 default:
1053 pf = 0; // Keep compiler quiet.
1054 BX_PANIC(("get_PF: OSZAP: unknown instr"));
1056 BX_CPU_THIS_PTR lf_flags_status &= 0xffff0f;
1057 BX_CPU_THIS_PTR eflags.val32 &= ~(1<<2);
1058 BX_CPU_THIS_PTR eflags.val32 |= (pf)<<2; // pf is always 0 or 1 here
1059 return(pf);
1061 default:
1062 BX_PANIC(("get_PF: unknown case"));
1063 return(0);