[i386] Parity Flag Not Set On xor %eax,%eax
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| QEMU |
Fix Released
|
Undecided
|
Unassigned | ||
Bug Description
Tested against qemu-1.7.0 as well as qemu-1.7.50 on Debian Sid
Steps To Reproduce
$ cat > prog.hex << EOF
7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
02 00 03 00 01 00 00 00 54 80 04 08 34 00 00 00
00 00 00 00 00 00 00 00 34 00 20 00 01 00 28 00
00 00 00 00 01 00 00 00 00 00 00 00 00 80 04 08
00 80 04 08 76 00 00 00 76 00 00 00 05 00 00 00
00 10 00 00
31 c0
9c
b8 04 00 00 00
bb 01 00 00 00
89 e1
ba 04 00 00 00
cd 80
b8 01 00 00 00
bb 00 00 00 00
cd 80
EOF
$ xxd -p -r prog.hex > prog
$ chmod 700 prog
$ ./prog | hexdump -vC
00000000 46 02 00 00 |F...|
00000004
$ qemu-i386 ./prog | hexdump -vC
00000000 42 02 00 00 |B...|
00000004
On the other hand if [xor %eax, %eax] (31 c0) is replaced with sub %eax,%eax (29 c0), then the parity flag is set correctly.

Parity should be set for a zero result.
Signed-off-by: Richard Henderson <email address hidden> i386/cc_ helper. c | 2 +- i386/translate. c | 2 +-
---
target-
target-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/target- i386/cc_ helper. c b/target- i386/cc_ helper. c i386/cc_ helper. c i386/cc_ helper. c cc_compute_ all(target_ ulong dst, target_ulong src1,
index ee04092..05dd12b 100644
--- a/target-
+++ b/target-
@@ -103,7 +103,7 @@ target_ulong helper_
case CC_OP_EFLAGS:
return src1;
case CC_OP_CLR:
- return CC_Z;
+ return CC_Z | CC_P;
case CC_OP_MULB: all_mulb( dst, src1); i386/translate. c b/target- i386/translate. c i386/translate. c i386/translate. c eflags( DisasContext *s) movi_tl( cpu_cc_ src, CC_Z); movi_tl( cpu_cc_ src, CC_Z | CC_P);
set_cc_ op(s, CC_OP_EFLAGS);
return compute_
diff --git a/target-
index b0f2279..34f35e7 100644
--- a/target-
+++ b/target-
@@ -748,7 +748,7 @@ static void gen_compute_
return;
}
if (s->cc_op == CC_OP_CLR) {
- tcg_gen_
+ tcg_gen_
return;
}
--
1.8.4.2