From 0cd0f6a9da6dedfe0bf2ef173e12577ce01d58a9 Mon Sep 17 00:00:00 2001 From: fractasy <89866610+fractasy@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:20:56 +0100 Subject: [PATCH] Fix op_rem_w() overflow, as per RISC-V spec (#169) --- core/src/zisk_ops.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/zisk_ops.rs b/core/src/zisk_ops.rs index f8e50dc2..89d9c02e 100644 --- a/core/src/zisk_ops.rs +++ b/core/src/zisk_ops.rs @@ -733,7 +733,7 @@ pub const fn op_rem_w(a: u64, b: u64) -> (u64, bool) { return ((a as i32) as u64, true); } - (((a as i32) % (b as i32)) as u64, false) + ((((a as i32) as i64) % ((b as i32) as i64)) as u64, false) } #[inline(always)] pub fn opc_rem_w(ctx: &mut InstContext) {