unicorn/qemu/target/m68k
Laurent Vivier 68c9ab9b77
target/m68k: fix V flag for CC_OP_SUBx
V flag for subtraction is:

v = (res ^ src1) & (src1 ^ src2)

(see COMPUTE_CCR() in target/m68k/helper.c)

But gen_flush_flags() uses:

v = (res ^ src2) & (src1 ^ src2)

The problem has been found with the following program:

.global _start
_start:
move.l #-2147483648,%d0
subq.l #1,%d0
jvc 1f
move.l #1,%d1
move.l #1,%d0
trap #0
1:
move.l #0,%d1
move.l #1,%d0
trap #0

It works fine (exit(1)) on real hardware, and with "-singlestep".

"-singlestep" uses gen_helper_flush_flags(), whereas
without "-singlestep", V flag is computed directly in
gen_flush_flags().

This patch updates gen_flush_flags() to have the same result
as with gen_helper_flush_flags().

Backports commit 043b936ef6fe53396b3c6b8f5562ea3e238a071d from qemu
2018-03-03 14:59:20 -05:00
..
cpu-qom.h Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00
cpu.c target/m68k: implement rtd 2018-03-03 14:27:01 -05:00
cpu.h target/m68k: implement rtd 2018-03-03 14:27:01 -05:00
helper.c Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00
helper.h Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00
Makefile.objs Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00
op_helper.c Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00
qregs.def Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00
translate.c target/m68k: fix V flag for CC_OP_SUBx 2018-03-03 14:59:20 -05:00
unicorn.c Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00
unicorn.h Move target-* CPU file into a target/ folder 2018-03-01 22:50:58 -05:00