From 3d9c95541b711029d246dbfffff6be3e4011ec53 Mon Sep 17 00:00:00 2001 From: fridtjof Date: Wed, 13 May 2026 15:07:24 +0200 Subject: [PATCH] CR16C: fix incorrect comparison behavior for CMP evaluation of conditions for flags L and N was swapped around. Programmer's reference: "PSR.L is set to 1 if src1 is greater than src2 (unsigned comparison)" "PSR.N is set to 1 if src1 is greater than src2 (signed comparison)" --- target/cr16c/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/cr16c/translate.c b/target/cr16c/translate.c index 7c8a948687..8882a09c1a 100644 --- a/target/cr16c/translate.c +++ b/target/cr16c/translate.c @@ -699,8 +699,8 @@ static bool trans_MACSW(DisasContext *ctx, arg_MACSW *a) { static void gen_cmp(TCGv_i32 src1, TCGv_i32 src2) { tcg_gen_setcond_i32(TCG_COND_EQ, psr_z, src1, src2); - tcg_gen_setcond_i32(TCG_COND_GT, psr_l, src1, src2); - tcg_gen_setcond_i32(TCG_COND_GTU, psr_n, src1, src2); + tcg_gen_setcond_i32(TCG_COND_GTU, psr_l, src1, src2); + tcg_gen_setcond_i32(TCG_COND_GT, psr_n, src1, src2); } static bool trans_CMP_imm(DisasContext *ctx, arg_CMP_imm *a) {