From 0902da8113cb68fdbf016717d36c87ad95ccd4a3 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Tue, 18 Jan 2022 00:24:47 +0100 Subject: [PATCH] Fix SRA/SRAV opcodes These opcodes surprisingly let the 33th bit shift in into the lower 32-bits, before sign-extension. --- vr4300/functions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vr4300/functions.c b/vr4300/functions.c index e181fdd..f632f07 100644 --- a/vr4300/functions.c +++ b/vr4300/functions.c @@ -1452,7 +1452,7 @@ int VR4300_SRA(struct vr4300 *vr4300, unsigned dest = GET_RD(iw); unsigned sa = iw >> 6 & 0x1F; - exdc_latch->result = (int32_t) rt >> sa; + exdc_latch->result = (int32_t) (rt >> sa); exdc_latch->dest = dest; return 0; } @@ -1466,7 +1466,7 @@ int VR4300_SRAV(struct vr4300 *vr4300, unsigned dest = GET_RD(iw); unsigned sa = rs & 0x1F; - exdc_latch->result = (int32_t) rt >> sa; + exdc_latch->result = (int32_t) (rt >> sa); exdc_latch->dest = dest; return 0; }