diff --git a/gen_input/templates/tcc/CORENAME.cpp.gtl b/gen_input/templates/tcc/CORENAME.cpp.gtl index 78a45ed..3480e56 100644 --- a/gen_input/templates/tcc/CORENAME.cpp.gtl +++ b/gen_input/templates/tcc/CORENAME.cpp.gtl @@ -177,8 +177,8 @@ private: <%instr.behavior.eachLine{%>${it} <%}%> tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,${idx}); + gen_trap_check(tu); return returnValue; } <%}%> @@ -187,8 +187,13 @@ private: ****************************************************************************/ compile_ret_t illegal_instruction(virt_addr_t &pc, code_word_t instr, tu_builder& tu) { vm_impl::gen_sync(tu, iss::PRE_SYNC, instr_descr.size()); + if(this->disass_enabled){ + /* generate console output when executing the command */ + tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, std::string("illegal_instruction")); + } pc = pc + ((instr & 3) == 3 ? 4 : 2); gen_raise_trap(tu, 0, 2); // illegal instruction trap + this->gen_set_tval(tu, instr); vm_impl::gen_sync(tu, iss::POST_SYNC, instr_descr.size()); vm_impl::gen_trap_check(tu); return BRANCH; diff --git a/src/vm/tcc/vm_tgc5c.cpp b/src/vm/tcc/vm_tgc5c.cpp index a45b74a..1c23d54 100644 --- a/src/vm/tcc/vm_tgc5c.cpp +++ b/src/vm/tcc/vm_tgc5c.cpp @@ -362,8 +362,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,0); + gen_trap_check(tu); return returnValue; } @@ -398,8 +398,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,1); + gen_trap_check(tu); return returnValue; } @@ -443,8 +443,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,2); + gen_trap_check(tu); return returnValue; } @@ -496,8 +496,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,3); + gen_trap_check(tu); return returnValue; } @@ -542,8 +542,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,4); + gen_trap_check(tu); return returnValue; } @@ -588,8 +588,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,5); + gen_trap_check(tu); return returnValue; } @@ -634,8 +634,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,6); + gen_trap_check(tu); return returnValue; } @@ -680,8 +680,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,7); + gen_trap_check(tu); return returnValue; } @@ -726,8 +726,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,8); + gen_trap_check(tu); return returnValue; } @@ -772,8 +772,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,9); + gen_trap_check(tu); return returnValue; } @@ -813,8 +813,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,10); + gen_trap_check(tu); return returnValue; } @@ -854,8 +854,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,11); + gen_trap_check(tu); return returnValue; } @@ -895,8 +895,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,12); + gen_trap_check(tu); return returnValue; } @@ -936,8 +936,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,13); + gen_trap_check(tu); return returnValue; } @@ -977,8 +977,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,14); + gen_trap_check(tu); return returnValue; } @@ -1014,8 +1014,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,15); + gen_trap_check(tu); return returnValue; } @@ -1051,8 +1051,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,16); + gen_trap_check(tu); return returnValue; } @@ -1088,8 +1088,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,17); + gen_trap_check(tu); return returnValue; } @@ -1127,8 +1127,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,18); + gen_trap_check(tu); return returnValue; } @@ -1166,8 +1166,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,19); + gen_trap_check(tu); return returnValue; } @@ -1205,8 +1205,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,20); + gen_trap_check(tu); return returnValue; } @@ -1244,8 +1244,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,21); + gen_trap_check(tu); return returnValue; } @@ -1283,8 +1283,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,22); + gen_trap_check(tu); return returnValue; } @@ -1322,8 +1322,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,23); + gen_trap_check(tu); return returnValue; } @@ -1361,8 +1361,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,24); + gen_trap_check(tu); return returnValue; } @@ -1400,8 +1400,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,25); + gen_trap_check(tu); return returnValue; } @@ -1439,8 +1439,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,26); + gen_trap_check(tu); return returnValue; } @@ -1478,8 +1478,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,27); + gen_trap_check(tu); return returnValue; } @@ -1517,8 +1517,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,28); + gen_trap_check(tu); return returnValue; } @@ -1558,8 +1558,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,29); + gen_trap_check(tu); return returnValue; } @@ -1597,8 +1597,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,30); + gen_trap_check(tu); return returnValue; } @@ -1636,8 +1636,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,31); + gen_trap_check(tu); return returnValue; } @@ -1675,8 +1675,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,32); + gen_trap_check(tu); return returnValue; } @@ -1716,8 +1716,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,33); + gen_trap_check(tu); return returnValue; } @@ -1757,8 +1757,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,34); + gen_trap_check(tu); return returnValue; } @@ -1796,8 +1796,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,35); + gen_trap_check(tu); return returnValue; } @@ -1835,8 +1835,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,36); + gen_trap_check(tu); return returnValue; } @@ -1866,8 +1866,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,37); + gen_trap_check(tu); return returnValue; } @@ -1889,8 +1889,8 @@ private: auto returnValue = std::make_tuple(TRAP); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,38); + gen_trap_check(tu); return returnValue; } @@ -1912,8 +1912,8 @@ private: auto returnValue = std::make_tuple(TRAP); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,39); + gen_trap_check(tu); return returnValue; } @@ -1935,8 +1935,8 @@ private: auto returnValue = std::make_tuple(TRAP); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,40); + gen_trap_check(tu); return returnValue; } @@ -1958,8 +1958,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,41); + gen_trap_check(tu); return returnValue; } @@ -2000,8 +2000,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,42); + gen_trap_check(tu); return returnValue; } @@ -2044,8 +2044,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,43); + gen_trap_check(tu); return returnValue; } @@ -2088,8 +2088,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,44); + gen_trap_check(tu); return returnValue; } @@ -2127,8 +2127,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,45); + gen_trap_check(tu); return returnValue; } @@ -2170,8 +2170,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,46); + gen_trap_check(tu); return returnValue; } @@ -2213,8 +2213,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,47); + gen_trap_check(tu); return returnValue; } @@ -2242,8 +2242,8 @@ private: auto returnValue = std::make_tuple(FLUSH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,48); + gen_trap_check(tu); return returnValue; } @@ -2282,8 +2282,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,49); + gen_trap_check(tu); return returnValue; } @@ -2324,8 +2324,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,50); + gen_trap_check(tu); return returnValue; } @@ -2366,8 +2366,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,51); + gen_trap_check(tu); return returnValue; } @@ -2408,8 +2408,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,52); + gen_trap_check(tu); return returnValue; } @@ -2467,8 +2467,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,53); + gen_trap_check(tu); return returnValue; } @@ -2515,8 +2515,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,54); + gen_trap_check(tu); return returnValue; } @@ -2577,8 +2577,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,55); + gen_trap_check(tu); return returnValue; } @@ -2625,8 +2625,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,56); + gen_trap_check(tu); return returnValue; } @@ -2661,8 +2661,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,57); + gen_trap_check(tu); return returnValue; } @@ -2694,8 +2694,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,58); + gen_trap_check(tu); return returnValue; } @@ -2726,8 +2726,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,59); + gen_trap_check(tu); return returnValue; } @@ -2764,8 +2764,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,60); + gen_trap_check(tu); return returnValue; } @@ -2787,8 +2787,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,61); + gen_trap_check(tu); return returnValue; } @@ -2818,8 +2818,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,62); + gen_trap_check(tu); return returnValue; } @@ -2854,8 +2854,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,63); + gen_trap_check(tu); return returnValue; } @@ -2888,8 +2888,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,64); + gen_trap_check(tu); return returnValue; } @@ -2923,8 +2923,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,65); + gen_trap_check(tu); return returnValue; } @@ -2947,8 +2947,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,66); + gen_trap_check(tu); return returnValue; } @@ -2978,8 +2978,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,67); + gen_trap_check(tu); return returnValue; } @@ -3017,8 +3017,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,68); + gen_trap_check(tu); return returnValue; } @@ -3048,8 +3048,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,69); + gen_trap_check(tu); return returnValue; } @@ -3079,8 +3079,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,70); + gen_trap_check(tu); return returnValue; } @@ -3110,8 +3110,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,71); + gen_trap_check(tu); return returnValue; } @@ -3141,8 +3141,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,72); + gen_trap_check(tu); return returnValue; } @@ -3172,8 +3172,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,73); + gen_trap_check(tu); return returnValue; } @@ -3201,8 +3201,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,74); + gen_trap_check(tu); return returnValue; } @@ -3235,8 +3235,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,75); + gen_trap_check(tu); return returnValue; } @@ -3269,8 +3269,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,76); + gen_trap_check(tu); return returnValue; } @@ -3307,8 +3307,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,77); + gen_trap_check(tu); return returnValue; } @@ -3344,8 +3344,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,78); + gen_trap_check(tu); return returnValue; } @@ -3380,8 +3380,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,79); + gen_trap_check(tu); return returnValue; } @@ -3416,8 +3416,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,80); + gen_trap_check(tu); return returnValue; } @@ -3439,8 +3439,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,81); + gen_trap_check(tu); return returnValue; } @@ -3477,8 +3477,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,82); + gen_trap_check(tu); return returnValue; } @@ -3517,8 +3517,8 @@ private: auto returnValue = std::make_tuple(BRANCH); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,83); + gen_trap_check(tu); return returnValue; } @@ -3540,8 +3540,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,84); + gen_trap_check(tu); return returnValue; } @@ -3576,8 +3576,8 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,85); + gen_trap_check(tu); return returnValue; } @@ -3599,18 +3599,23 @@ private: auto returnValue = std::make_tuple(CONT); tu.close_scope(); - gen_trap_check(tu); vm_base::gen_sync(tu, POST_SYNC,86); + gen_trap_check(tu); return returnValue; } /**************************************************************************** * end opcode definitions ****************************************************************************/ - compile_ret_t illegal_intruction(virt_addr_t &pc, code_word_t instr, tu_builder& tu) { + compile_ret_t illegal_instruction(virt_addr_t &pc, code_word_t instr, tu_builder& tu) { vm_impl::gen_sync(tu, iss::PRE_SYNC, instr_descr.size()); + if(this->disass_enabled){ + /* generate console output when executing the command */ + tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, std::string("illegal_instruction")); + } pc = pc + ((instr & 3) == 3 ? 4 : 2); gen_raise_trap(tu, 0, 2); // illegal instruction trap + this->gen_set_tval(tu, instr); vm_impl::gen_sync(tu, iss::POST_SYNC, instr_descr.size()); vm_impl::gen_trap_check(tu); return BRANCH; @@ -3712,7 +3717,7 @@ vm_impl::gen_single_inst_behavior(virt_addr_t &pc, unsigned int &inst_cnt, ++inst_cnt; auto f = decode_instr(root, instr); if (f == nullptr) { - f = &this_class::illegal_intruction; + f = &this_class::illegal_instruction; } return (this->*f)(pc, instr, tu); }