From 98598ca5e2b27a49292e6dd6fd444c7838824d5a Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Fri, 8 Apr 2011 16:34:35 -0700 Subject: [PATCH] [sim] fixed multiply-high in rv32 --- riscv/insns/mulhsu.h | 2 +- riscv/insns/mulhu.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/riscv/insns/mulhsu.h b/riscv/insns/mulhsu.h index 506424d..e5f1c95 100644 --- a/riscv/insns/mulhsu.h +++ b/riscv/insns/mulhsu.h @@ -5,4 +5,4 @@ if(xpr64) RD = (int128_t(a) * uint128_t(b)) >> 64; } else - RD = sext32((sreg_t(RS1) * reg_t(RS2)) >> 32); + RD = sext32((sreg_t(RS1) * reg_t((uint32_t)RS2)) >> 32); diff --git a/riscv/insns/mulhu.h b/riscv/insns/mulhu.h index b6f45dd..6334426 100644 --- a/riscv/insns/mulhu.h +++ b/riscv/insns/mulhu.h @@ -1,4 +1,4 @@ if(xpr64) RD = (uint128_t(RS1) * uint128_t(RS2)) >> 64; else - RD = sext32((RS1 * RS2) >> 32); + RD = sext32(((uint64_t)(uint32_t)RS1 * (uint64_t)(uint32_t)RS2) >> 32); -- 2.30.2