ASH for shift > 32 fix
This commit is contained in:
parent
1605d1a9a7
commit
a15d464532
1 changed files with 7 additions and 9 deletions
16
cpu.cpp
16
cpu.cpp
|
@ -681,10 +681,6 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
|
||||||
|
|
||||||
bool sign = SIGN(R, wm_word);
|
bool sign = SIGN(R, wm_word);
|
||||||
|
|
||||||
// extend sign-bit
|
|
||||||
if (sign)
|
|
||||||
R |= 0xffff0000;
|
|
||||||
|
|
||||||
if (shift == 0) {
|
if (shift == 0) {
|
||||||
setPSW_c(false);
|
setPSW_c(false);
|
||||||
setPSW_v(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));
|
setPSW_v(SIGN(R, wm_word) != SIGN(oldR, wm_word));
|
||||||
}
|
}
|
||||||
else {
|
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<shift_n; i++) {
|
||||||
setPSW_c(R & 1);
|
setPSW_c(R & 1);
|
||||||
setPSW_v(SIGN(R, wm_word) != SIGN(oldR, wm_word));
|
|
||||||
|
|
||||||
R >>= 1;
|
R >>= 1;
|
||||||
|
R |= sign_extend;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPSW_v(SIGN(R, wm_word) != SIGN(oldR, wm_word));
|
||||||
}
|
}
|
||||||
|
|
||||||
R &= 0xffff;
|
R &= 0xffff;
|
||||||
|
|
Loading…
Add table
Reference in a new issue