Fix carry flag in thumb2 data operations From: Alexey Starikovskiy --- target-arm/translate.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-) diff --git a/target-arm/translate.c b/target-arm/translate.c index 75c0ad4..df8ca6a 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -7903,29 +7903,23 @@ thumb2_logic_op(int op) static int gen_thumb2_data_op(DisasContext *s, int op, int conds, uint32_t shifter_out, TCGv t0, TCGv t1) { - int logic_cc; - - logic_cc = 0; + if (op < 5 && conds && shifter_out) + gen_set_CF_bit31(t1); switch (op) { case 0: /* and */ tcg_gen_and_i32(t0, t0, t1); - logic_cc = conds; break; case 1: /* bic */ tcg_gen_andc_i32(t0, t0, t1); - logic_cc = conds; break; case 2: /* orr */ tcg_gen_or_i32(t0, t0, t1); - logic_cc = conds; break; case 3: /* orn */ tcg_gen_orc_i32(t0, t0, t1); - logic_cc = conds; break; case 4: /* eor */ tcg_gen_xor_i32(t0, t0, t1); - logic_cc = conds; break; case 8: /* add */ if (conds) @@ -7960,11 +7954,8 @@ gen_thumb2_data_op(DisasContext *s, int op, int conds, uint32_t shifter_out, TCG default: /* 5, 6, 7, 9, 12, 15. */ return 1; } - if (logic_cc) { + if (op < 5 && conds) gen_logic_CC(t0); - if (shifter_out) - gen_set_CF_bit31(t1); - } return 0; }