ASH for shift > 32 fix

This commit is contained in:
folkert van heusden 2024-03-29 11:51:25 +01:00
parent 1605d1a9a7
commit a15d464532
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1

16
cpu.cpp
View file

@ -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;
R >>= shift_n;
int shift_n = 64 - shift;
uint32_t sign_extend = sign ? 0x8000 : 0;
for(int i=0; i<shift_n; i++) {
setPSW_c(R & 1);
setPSW_v(SIGN(R, wm_word) != SIGN(oldR, wm_word));
R >>= 1;
R |= sign_extend;
}
setPSW_v(SIGN(R, wm_word) != SIGN(oldR, wm_word));
}
R &= 0xffff;