From 33878520283f8e664218b8216efe94f088e494f0 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 13 Mar 2022 10:39:32 +0100 Subject: [PATCH] cmake --- CMakeLists.txt | 41 +++++++++++++++++++++++++++++++++++++++++ cpu.cpp | 19 ++++++++++++------- gen.h | 4 ++-- 3 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bddeb5c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +project(PDP-11) +cmake_minimum_required(VERSION 3.2) + + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +add_executable( + kek + bus.cpp + cpu.cpp + error.cpp + main.cpp + memory.cpp + rk05.cpp + rx02.cpp + terminal.cpp + tests.cpp + tm-11.cpp + tty.cpp + utils.cpp +) + +set(CMAKE_BUILD_TYPE Debug) + +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads) +target_link_libraries(kek Threads::Threads) + +include(FindPkgConfig) + +pkg_check_modules(NCURSES REQUIRED ncurses) +target_link_libraries(kek ${NCURSES_LIBRARIES}) +target_include_directories(kek PUBLIC ${NCURSES_INCLUDE_DIRS}) +target_compile_options(kek PUBLIC ${NCURSES_CFLAGS_OTHER}) + +pkg_check_modules(PANEL REQUIRED panel) +target_link_libraries(kek ${PANEL_LIBRARIES}) +target_include_directories(kek PUBLIC ${PANEL_INCLUDE_DIRS}) +target_compile_options(kek PUBLIC ${PANEL_CFLAGS_OTHER}) diff --git a/cpu.cpp b/cpu.cpp index 3678356..be1d2d8 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -194,7 +194,7 @@ uint16_t cpu::getGAM(const uint8_t mode, const uint8_t reg, const bool word_mode addRegister(7, prev_mode, + 2); temp = b -> read(getRegister(reg, prev_mode) + next_word, word_mode, prev_mode); //fprintf(stderr, "-> %d: %o\n", word_mode, temp); -#ifdef _DEBUG +#ifndef NDEBUG if (reg == 7) *text = format("0o%o", getPC() + next_word); // FIXME else @@ -337,7 +337,7 @@ bool cpu::double_operand_instructions(const uint16_t instr) const uint8_t src_mode = (src >> 3) & 7; const uint8_t src_reg = src & 7; -#ifdef _DEBUG +#ifndef NDEBUG std::string debug_a, debug_b; std::string *src_gam_text = &debug_a, *dst_gam_text = &debug_b; #endif @@ -433,7 +433,7 @@ bool cpu::double_operand_instructions(const uint16_t instr) if (dst_mode == 0) putGAM(dst_mode, dst_reg, word_mode, result, false, dst_gam_text); else { -#ifdef _DEBUG +#ifndef NDEBUG dst_gam_text -> assign(format("(%o)", a)); #endif b -> write(a, word_mode, result); @@ -479,7 +479,7 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr) { const uint8_t reg = (instr >> 6) & 7; -#ifdef _DEBUG +#ifndef NDEBUG std::string debug_b; std::string *dst_gam_text = &debug_b; #endif @@ -624,7 +624,7 @@ bool cpu::single_operand_instructions(const uint16_t instr) int32_t vl = -1; uint16_t v = -1; -#ifdef _DEBUG +#ifndef NDEBUG std::string debug_b; std::string *dst_gam_text = &debug_b; #endif @@ -926,7 +926,7 @@ bool cpu::conditional_branch_instructions(const uint16_t instr) const uint8_t opcode = (instr >> 8) & 255; const int8_t offset = instr & 255; bool take = false; -#ifdef _DEBUG +#ifndef NDEBUG std::string name; #endif @@ -1062,6 +1062,11 @@ bool cpu::condition_code_operations(const uint16_t instr) void cpu::pushStack(const uint16_t v) { + if (getRegister(6) == stackLimitRegister) { + printf("stackLimitRegister reached\n"); + exit(1); + } + addRegister(6, false, -2); b -> writeWord(getRegister(6, false), v); } @@ -1259,7 +1264,7 @@ bool cpu::step() return true; ok: -#ifdef _DEBUG +#ifndef NDEBUG for(int r=0; r<8; r++) fprintf(stderr, "%06o ", getRegister(r, false)); fprintf(stderr, " | n%dz%dv%dc%d P%dC%d S%d", getPSW_n(), getPSW_z(), getPSW_v(), getPSW_c(), (getPSW() >> 12) & 3, getPSW() >> 14, getBitPSW(11)); diff --git a/gen.h b/gen.h index d101bd0..1824dde 100644 --- a/gen.h +++ b/gen.h @@ -1,6 +1,6 @@ -// (C) 2018 by Folkert van Heusden +// (C) 2018-2022 by Folkert van Heusden // Released under AGPL v3.0 -#ifdef _DEBUG +#ifndef NDEBUG #define D(x) do { x } while(0); #else #define D(...) do { } while(0);