From 2334daff167ef604cc05faa1a558d53b31771706 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Thu, 4 Apr 2024 18:03:39 +0200 Subject: [PATCH] cannot replace the run-mode bits nor the set of registers --- cpu.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index ab7e333..4aaeb5c 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -277,10 +277,13 @@ int cpu::getPSW_spl() const void cpu::setPSW(const uint16_t v, const bool limited) { - if (limited) - psw = (v & 0174037) | (psw & 0174340); - else + if (limited) { + // cannot replace the run-mode bits nor the set of registers + psw = (psw & 177400) | (v & 0377); + } + else { psw = v & 0174377; // mask off 'unused' bits (8-10) + } } void cpu::setPSW_flags_nzv(const uint16_t value, const word_mode_t word_mode)