PSW handling fixes

This commit is contained in:
folkert van heusden 2022-06-12 22:34:09 +02:00
parent 9b3cb02064
commit a460aa9d82
2 changed files with 6 additions and 4 deletions

View file

@ -407,6 +407,8 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
DOLOG(debug, true, "writeb PSW %s", a & 1 ? "MSB" : "LSB"); DOLOG(debug, true, "writeb PSW %s", a & 1 ? "MSB" : "LSB");
uint16_t vtemp = c -> getPSW(); uint16_t vtemp = c -> getPSW();
value &= ~16; // cannot set T bit via this
if (a & 1) if (a & 1)
vtemp = (vtemp & 0x00ff) | (value << 8); vtemp = (vtemp & 0x00ff) | (value << 8);
else else
@ -433,7 +435,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
else { else {
if (a == 0177776) { // PSW if (a == 0177776) { // PSW
DOLOG(debug, true, "write PSW %o", value); DOLOG(debug, true, "write PSW %o", value);
c -> setPSW(value, false); c -> setPSW(value & ~16, false);
return value; return value;
} }

View file

@ -1366,9 +1366,9 @@ bool cpu::single_operand_instructions(const uint16_t instr)
case 0b000110111: // MFPS (get PSW to something) / SXT case 0b000110111: // MFPS (get PSW to something) / SXT
if (word_mode) { // MFPS if (word_mode) { // MFPS
uint16_t temp = psw & 0xff; uint16_t temp = psw & 0xff;
bool extend_b7 = temp & 128; bool extend_b7 = psw & 128;
if (extend_b7) if (extend_b7 && dst_mode == 0)
temp |= 0xff00; temp |= 0xff00;
set_flags = putGAM(dst_mode, dst_reg, word_mode, temp, false); set_flags = putGAM(dst_mode, dst_reg, word_mode, temp, false);
@ -1376,7 +1376,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
if (set_flags) { if (set_flags) {
setPSW_z(temp == 0); setPSW_z(temp == 0);
setPSW_v(false); setPSW_v(false);
setPSW_n(!extend_b7); setPSW_n(extend_b7);
} }
} }
else { // SXT else { // SXT