On 02/11/2017 13:45, Pavel Dovgalyuk wrote: >> But if u16.high is -1, shouldn't you return EXCP_INTERRUPT first (via >> "Finally, check if we need to exit to the main loop" in >> cpu_handle_interrupt)? Then only cause the exception when that one is >> processed. > The case is the following. > 1. There are no pending instructions to execute, cpu_loop_exec_tb finished. > 2. There are no interrupts and cpu_handle_interrupt sets cpu->exception_index > = EXCP_INTERRUPT > 3. There are no pending exceptions and cpu_handle_exception goes to the last > branch, > because there is an exception flag in the log. > 4. cpu_exec_nocache translates the block and tries to execute it, causing an > exception >
Then the fix is indeed to clear u16.high in cpu_handle_interrupt instead of cpu_loop_exec_tb---see my other reply. Paolo