diff --git a/CMakeLists.txt b/CMakeLists.txt index 29ceafa..2fee93a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,8 @@ add_executable( include(CheckIPOSupported) check_ipo_supported(RESULT supported) -set(CMAKE_BUILD_TYPE RelWithDebInfo) -#set(CMAKE_BUILD_TYPE Debug) +#set(CMAKE_BUILD_TYPE RelWithDebInfo) +set(CMAKE_BUILD_TYPE Debug) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) diff --git a/cpu.cpp b/cpu.cpp index 2415f84..ea6985a 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -139,7 +139,7 @@ void cpu::setPSW_n(const bool v) void cpu::setPSW_spl(const int v) { - psw &= 7 << 5; + psw &= ~(7 << 5); psw |= v << 5; } diff --git a/tests.cpp b/tests.cpp index 6d0ec3d..16f8d02 100644 --- a/tests.cpp +++ b/tests.cpp @@ -69,27 +69,27 @@ void test__registers(cpu *const c) // PSW c -> reset(); - assert(c -> getPSW() == 0); + assert(c -> getPSW() == 0 | (7 << 5)); c -> reset(); c -> setPSW_c(true); - assert(c -> getPSW() == 1); + assert(c -> getPSW() == 1 | (7 << 5)); c -> reset(); c -> setPSW_v(true); - assert(c -> getPSW() == 2); + assert(c -> getPSW() == 2 | (7 << 5)); c -> reset(); c -> setPSW_z(true); - assert(c -> getPSW() == 4); + assert(c -> getPSW() == 4 | (7 << 5)); c -> reset(); c -> setPSW_n(true); - assert(c -> getPSW() == 8); + assert(c -> getPSW() == 8 | (7 << 5)); c -> reset(); - c -> setPSW_spl(7); - assert(c -> getPSW() == (7 << 5)); + c -> setPSW_spl(1); + assert(c -> getPSW() == (1 << 5)); } void test_cmp(cpu *const c) @@ -1391,9 +1391,11 @@ void test_rts(cpu *const c) c -> setRegister(6, 01000); b -> writeWord(0, 0004010); b -> writeWord(10, 0b0000000010000000); - do_test(c, 2); - assert(c -> getRegister(0) == 10); + do_test(c, 1); assert(c -> getRegister(6) == 0776); + do_test(c, 1); + assert(c -> getRegister(0) == 10); + assert(c -> getRegister(6) == 01000); assert(c -> getRegister(7) == 2); // c -> reset(); @@ -1698,7 +1700,7 @@ void test_swab(cpu *const c) b -> writeWord(0, 000301); // SWAB R1 do_test(c, 1); assert(c -> getRegister(1) == 0177577); - assert(c -> getPSW_n()); + assert(!c -> getPSW_n()); assert(!c -> getPSW_z()); assert(!c -> getPSW_v()); assert(!c -> getPSW_c()); diff --git a/tty.cpp b/tty.cpp index af6a4f3..befd9a6 100644 --- a/tty.cpp +++ b/tty.cpp @@ -112,6 +112,8 @@ void tty::writeWord(const uint16_t addr, uint16_t v) if (addr == PDP11TTY_TPB) { char c = v & 127; + D(fprintf(stderr, "PDP11TTY print '%c'\n", c);) + #if defined(ESP32) if (xQueueSend(queue, &c, portMAX_DELAY) != pdTRUE) Serial.println(F("queue TTY character failed"));