From b9fc0b4b80c37b949f559fd59ca6c666fc7d19bd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Dec 2014 17:47:44 -0500 Subject: armemu: Clean up naming and formatting for SSAT16 --- src/core/arm/interpreter/armemu.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp index 07d205755..837875d4f 100644 --- a/src/core/arm/interpreter/armemu.cpp +++ b/src/core/arm/interpreter/armemu.cpp @@ -6081,22 +6081,28 @@ L_stm_s_takeabort: //ichfly //SSAT16 { - u8 tar = BITS(12, 15); - u8 src = BITS(0, 3); - u8 val = BITS(16, 19) + 1; - s16 a1 = (state->Reg[src]); - s16 a2 = (state->Reg[src] >> 0x10); - s16 min = (s16)(0x8000 >> (16 - val)); - s16 max = 0x7FFF >> (16 - val); - if (min > a1) a1 = min; - if (max < a1) a1 = max; - if (min > a2) a2 = min; - if (max < a2) a2 = max; - u32 temp2 = ((u32)(a2)) << 0x10; - state->Reg[tar] = (a1 & 0xFFFF) | (temp2); + const u8 rd_idx = BITS(12, 15); + const u8 rn_idx = BITS(0, 3); + const u8 num_bits = BITS(16, 19) + 1; + const s16 min = (0x8000 >> (16 - num_bits)); + const s16 max = (0x7FFF >> (16 - num_bits)); + s16 rn_lo = (state->Reg[rn_idx]); + s16 rn_hi = (state->Reg[rn_idx] >> 16); + + if (rn_lo > max) + rn_lo = max; + else if (rn_lo < min) + rn_lo = min; + + if (rn_hi > max) + rn_hi = max; + else if (rn_hi < min) + rn_hi = min; + + state->Reg[rd_idx] = (rn_lo & 0xFFFF) | ((rn_hi & 0xFFFF) << 16); + return 1; } - return 1; default: break; } -- cgit v1.2.3 From 92c53fe52220630664ae77a4c915d5af768b8adc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Dec 2014 20:35:10 -0500 Subject: armemu: Fix SSAT16 The lower-bound would never be negative like it should --- src/core/arm/interpreter/armemu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp index 837875d4f..e39ea2cae 100644 --- a/src/core/arm/interpreter/armemu.cpp +++ b/src/core/arm/interpreter/armemu.cpp @@ -6084,7 +6084,7 @@ L_stm_s_takeabort: const u8 rd_idx = BITS(12, 15); const u8 rn_idx = BITS(0, 3); const u8 num_bits = BITS(16, 19) + 1; - const s16 min = (0x8000 >> (16 - num_bits)); + const s16 min = -(0x8000 >> (16 - num_bits)); const s16 max = (0x7FFF >> (16 - num_bits)); s16 rn_lo = (state->Reg[rn_idx]); s16 rn_hi = (state->Reg[rn_idx] >> 16); -- cgit v1.2.3