From c52da9d802cbd39b7b91edb7e86e750e88905a2d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 28 May 2019 15:05:42 -0400 Subject: [PATCH] Adds some logging preparatory to a MOVE change. --- .../Mac/Clock SignalTests/EmuTOSTests.mm | 2 + .../Implementation/68000Implementation.hpp | 44 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm b/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm index f81457706..09112da71 100644 --- a/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm +++ b/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm @@ -11,6 +11,8 @@ #include #include +#define LOG_TRACE + #include "68000.hpp" #include "Comparative68000.hpp" #include "CSROMFetcher.hpp" diff --git a/Processors/68000/Implementation/68000Implementation.hpp b/Processors/68000/Implementation/68000Implementation.hpp index 98a81caa6..066099b95 100644 --- a/Processors/68000/Implementation/68000Implementation.hpp +++ b/Processors/68000/Implementation/68000Implementation.hpp @@ -47,6 +47,10 @@ template void Processor::run_for(HalfCycles duration) { const HalfCycles remaining_duration = duration + half_cycles_left_to_run_; +#ifdef LOG_TRACE + static bool should_log = true; +#endif + // This loop counts upwards rather than downwards because it simplifies calculation of // E as and when required. HalfCycles cycles_run_for; @@ -123,7 +127,7 @@ template void Proces } #ifdef LOG_TRACE - if(!(active_step_->microcycle.operation & Microcycle::IsProgram)) { + if(should_log && !(active_step_->microcycle.operation & Microcycle::IsProgram)) { switch(active_step_->microcycle.operation & (Microcycle::SelectWord | Microcycle::SelectByte | Microcycle::Read)) { default: break; @@ -241,28 +245,40 @@ template void Proces populate_trap_steps(9, get_status()); } else { #ifdef LOG_TRACE - std::cout << std::setfill('0'); - std::cout << (extend_flag_ ? 'x' : '-') << (negative_flag_ ? 'n' : '-') << (zero_result_ ? '-' : 'z'); - std::cout << (overflow_flag_ ? 'v' : '-') << (carry_flag_ ? 'c' : '-') << '\t'; - for(int c = 0; c < 8; ++ c) std::cout << "d" << c << ":" << std::setw(8) << data_[c].full << " "; - for(int c = 0; c < 8; ++ c) std::cout << "a" << c << ":" << std::setw(8) << address_[c].full << " "; - if(is_supervisor_) { - std::cout << "usp:" << std::setw(8) << std::setfill('0') << stack_pointers_[0].full << " "; - } else { - std::cout << "ssp:" << std::setw(8) << std::setfill('0') << stack_pointers_[1].full << " "; + if(should_log) { + std::cout << std::setfill('0'); + std::cout << (extend_flag_ ? 'x' : '-') << (negative_flag_ ? 'n' : '-') << (zero_result_ ? '-' : 'z'); + std::cout << (overflow_flag_ ? 'v' : '-') << (carry_flag_ ? 'c' : '-') << '\t'; + for(int c = 0; c < 8; ++ c) std::cout << "d" << c << ":" << std::setw(8) << data_[c].full << " "; + for(int c = 0; c < 8; ++ c) std::cout << "a" << c << ":" << std::setw(8) << address_[c].full << " "; + if(is_supervisor_) { + std::cout << "usp:" << std::setw(8) << std::setfill('0') << stack_pointers_[0].full << " "; + } else { + std::cout << "ssp:" << std::setw(8) << std::setfill('0') << stack_pointers_[1].full << " "; + } + std::cout << '\n'; } - std::cout << '\n'; #endif decoded_instruction_.full = prefetch_queue_.halves.high.full; #ifdef LOG_TRACE - std::cout << std::hex << (program_counter_.full - 4) << ": " << std::setw(4) << decoded_instruction_.full << '\t'; + if(should_log) { + std::cout << std::hex << (program_counter_.full - 4) << ": " << std::setw(4) << decoded_instruction_.full << '\t'; + } #endif if(signal_will_perform) { bus_handler_.will_perform(program_counter_.full - 4, decoded_instruction_.full); } +#ifdef LOG_TRACE +// should_log |= ((program_counter_.full - 4) == 0x405054); +#endif + + if(decoded_instruction_.full == 0x206f) { + printf(""); + } + if(instructions[decoded_instruction_.full].micro_operations) { if(instructions[decoded_instruction_.full].requires_supervisor && !is_supervisor_) { // A privilege violation has been detected. @@ -282,6 +298,10 @@ template void Proces // The location of the failed instruction is what should end up on the stack. program_counter_.full -= 4; +#ifdef LOG_TRACE +// should_log = true; +#endif + // The vector used depends on whether this is a vanilla unrecognised instruction, // or one on the A or F lines. switch(decoded_instruction_.full >> 12) {