From a15d464532cc74e8199d425eef0e2de4ba588b70 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Fri, 29 Mar 2024 11:51:25 +0100 Subject: [PATCH] ASH for shift > 32 fix --- cpu.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index b8708f4..19d789a 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -681,10 +681,6 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr) bool sign = SIGN(R, wm_word); - // extend sign-bit - if (sign) - R |= 0xffff0000; - if (shift == 0) { setPSW_c(false); setPSW_v(false); @@ -706,14 +702,16 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr) setPSW_v(SIGN(R, wm_word) != SIGN(oldR, wm_word)); } else { - int shift_n = (64 - shift) - 1; + int shift_n = 64 - shift; + uint32_t sign_extend = sign ? 0x8000 : 0; - R >>= shift_n; + for(int i=0; i>= 1; + R |= sign_extend; + } - setPSW_c(R & 1); setPSW_v(SIGN(R, wm_word) != SIGN(oldR, wm_word)); - - R >>= 1; } R &= 0xffff;