ASH was incorrectly implemented: 'ss' in the documentation is still the regular addressing mode

This commit is contained in:
folkert van heusden 2022-03-19 21:03:05 +01:00
parent 3e82a3d17a
commit 949fd5f7f8

11
cpu.cpp
View file

@ -467,7 +467,8 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
case 2: { // ASH case 2: { // ASH
int16_t R = getRegister(reg), oldR = R; int16_t R = getRegister(reg), oldR = R;
int8_t shift = dst > 31 ? -(64 - dst) : dst; uint16_t a = getGAMAddress(dst_mode, dst_reg, false, false);
int16_t shift = b->read(a, false);
if (shift > 0) { if (shift > 0) {
R <<= shift - 1; R <<= shift - 1;
@ -475,7 +476,7 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
R <<= 1; R <<= 1;
} }
else if (shift < 0) { else if (shift < 0) {
R >>= -shift - 1; R >>= -(shift - 1);
setPSW_c(R & 1); setPSW_c(R & 1);
R >>= 1; R >>= 1;
} }
@ -484,7 +485,11 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
setPSW_z(R == 0); setPSW_z(R == 0);
setPSW_v(sign(R) != sign(oldR)); setPSW_v(sign(R) != sign(oldR));
setRegister(reg, R); if (dst_mode == 0)
putGAM(dst_mode, dst_reg, false, R, false);
else
b->write(a, false, R);
return true; return true;
} }