This commit is contained in:
folkert van heusden 2022-03-31 13:19:48 +02:00
parent 5e9bcf8785
commit 1ea4658257

21
cpu.cpp
View file

@ -723,19 +723,20 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t add = word_mode ? v & 0xff00 : 0;
v = (v + 1) & (word_mode ? 0xff : 0xffff);
v |= add;
setPSW_n(word_mode ? v > 127 : v > 32767);
setPSW_n(SIGN(v, word_mode));
setPSW_z(v == 0);
setPSW_v(word_mode ? v == 0x80 : v == 0x8000);
setRegister(dst_reg, false, v | add);
setRegister(dst_reg, false, v);
}
else {
uint16_t a = getGAMAddress(dst_mode, dst_reg, word_mode, false);
uint16_t v = b -> read(a, word_mode);
int32_t vl = (v + 1) & (word_mode ? 0xff : 0xffff);
setPSW_n(word_mode ? vl > 127 : vl > 32767);
setPSW_n(SIGN(vl, word_mode));
setPSW_z(vl == 0);
setPSW_v(word_mode ? vl == 0x80 : v == 0x8000);
@ -752,7 +753,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
v = (v - 1) & (word_mode ? 0xff : 0xffff);
setPSW_n(word_mode ? v > 127 : v > 32767);
setPSW_n(SIGN(v, word_mode));
setPSW_z(v == 0);
setPSW_v(word_mode ? v == 0x7f : v == 0x7fff);
@ -763,7 +764,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t v = b -> read(a, word_mode);
int32_t vl = (v - 1) & (word_mode ? 0xff : 0xffff);
setPSW_n(word_mode ? vl > 127 : vl > 32767);
setPSW_n(SIGN(vl, word_mode));
setPSW_z(vl == 0);
setPSW_v(word_mode ? vl == 0x7f : vl == 0x7fff);
@ -780,7 +781,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
v = (-v) & (word_mode ? 0xff : 0xffff);
setPSW_n(word_mode ? v > 127 : v > 32767);
setPSW_n(SIGN(v, word_mode));
setPSW_z(v == 0);
setPSW_v(word_mode ? v == 0x80 : v == 0x8000);
@ -1028,7 +1029,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t v = (vl << 1) & (word_mode ? 0xff : 0xffff);
uint16_t add = word_mode ? v & 0xff00 : 0;
setPSW_n(word_mode ? v & 0x80 : v & 0x8000);
setPSW_n(SIGN(v, word_mode));
setPSW_z(v == 0);
setPSW_c(word_mode ? vl & 0x80 : vl & 0x8000);
setPSW_v(getPSW_n() ^ getPSW_c());
@ -1040,7 +1041,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
int32_t vl = b -> read(a, word_mode);
uint16_t v = (vl << 1) & (word_mode ? 0xff : 0xffff);
setPSW_n(word_mode ? v & 0x80 : v & 0x8000);
setPSW_n(SIGN(v, word_mode));
setPSW_z(v == 0);
setPSW_c(word_mode ? vl & 0x80 : vl & 0x8000);
setPSW_v(getPSW_n() ^ getPSW_c());
@ -1055,7 +1056,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t a = getGAMAddress(dst_mode, dst_reg, false, false);
uint16_t v = b -> read(a, false, true);
setPSW_n(word_mode ? v & 0x80 : v & 0x8000);
setPSW_n(SIGN(v, word_mode));
setPSW_z(v == 0);
setPSW_v(false);
@ -1070,7 +1071,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
// retrieve word from '15/14'-stack
uint16_t v = popStack();
setPSW_n(word_mode ? v & 0x80 : v & 0x8000);
setPSW_n(SIGN(v, word_mode));
setPSW_z(v == 0);
setPSW_v(false);