diff --git a/cpu.cpp b/cpu.cpp index 8b23949..5bd16ef 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -1671,7 +1671,7 @@ void cpu::trap(uint16_t vector, const int new_ipl, const bool is_interrupt) it_is_a_trap = true; - for(;;) { + do { try { processing_trap_depth++; @@ -1722,7 +1722,6 @@ void cpu::trap(uint16_t vector, const int new_ipl, const bool is_interrupt) // if we reach this point then the trap was processed without causing // another trap - break; } catch(const int exception) { DOLOG(debug, true, "trap during execution of trap (%d)", exception); @@ -1730,6 +1729,7 @@ void cpu::trap(uint16_t vector, const int new_ipl, const bool is_interrupt) setPSW(before_psw, false); } } + while(0); } cpu::operand_parameters cpu::addressing_to_string(const uint8_t mode_register, const uint16_t pc, const word_mode_t word_mode) const diff --git a/cpu.h b/cpu.h index e06f125..af35766 100644 --- a/cpu.h +++ b/cpu.h @@ -150,6 +150,7 @@ public: void lowlevel_register_sp_set(const uint8_t set, const uint16_t value); uint16_t lowlevel_register_get(const uint8_t set, const uint8_t reg); void lowlevel_psw_set(const uint16_t value) { psw = value; } + uint16_t lowlevel_register_sp_get(const uint8_t nr) const { return sp[nr]; } void setStackPointer(const int which, const uint16_t value) { assert(which >= 0 && which < 4); sp[which] = value; } void setPC(const uint16_t value) { pc = value; } diff --git a/main.cpp b/main.cpp index bab238b..213d7f5 100644 --- a/main.cpp +++ b/main.cpp @@ -174,6 +174,19 @@ int run_cpu_validation(const std::string & filename) } // TODO check SP[] + { + json_t *a_sp = json_object_get(registers_after, "sp"); + size_t array_size = json_array_size(a_sp); + assert(array_size == 4); + for(size_t i=0; ilowlevel_register_sp_get(i); + if (json_integer_value(temp) != sp) { + DOLOG(warning, true, "SP[%d] register mismatch (is: %06o (%d), should be: %06o (%d))", i, sp, sp, json_integer_value(temp), json_integer_value(temp)); + err = true; + } + } + } { json_t *a_psw = json_object_get(registers_after, "psw");