diff --git a/cpu/ppc/ppcexec.cpp b/cpu/ppc/ppcexec.cpp index ea75790..126377c 100644 --- a/cpu/ppc/ppcexec.cpp +++ b/cpu/ppc/ppcexec.cpp @@ -264,62 +264,46 @@ typedef enum { template static void ppc_exec_inner(uint32_t start_addr, uint32_t size) { - uint64_t max_cycles; - uint32_t page_start, eb_start, eb_end; + uint64_t max_cycles = 0; + uint32_t page_start, eb_start, eb_end = 0; uint32_t opcode; uint8_t* pc_real; - max_cycles = 0; - while (power_on) { if (exec_type == debug) if (ppc_state.pc >= start_addr && ppc_state.pc < start_addr + size) break; - // define boundaries of the next execution block - // max execution block length = one memory page - eb_start = ppc_state.pc; - page_start = eb_start & PPC_PAGE_MASK; - eb_end = page_start + PPC_PAGE_SIZE - 1; - exec_flags = 0; + if (ppc_state.pc >= eb_end) { + // define boundaries of the next execution block + // max execution block length = one memory page + eb_start = ppc_state.pc; + page_start = eb_start & PPC_PAGE_MASK; + eb_end = page_start + PPC_PAGE_SIZE - 1; + exec_flags = 0; + pc_real = mmu_translate_imem(eb_start); + } - pc_real = mmu_translate_imem(eb_start); opcode = ppc_read_instruction(pc_real); + ppc_main_opcode(opcode); + if (g_icycles++ >= max_cycles || exec_timer) + max_cycles = process_events(); - // interpret execution block - while (power_on && ppc_state.pc < eb_end) { - if (exec_type == debug) - if (ppc_state.pc >= start_addr && ppc_state.pc < start_addr + size) - break; - - ppc_main_opcode(opcode); - if (g_icycles++ >= max_cycles || exec_timer) { - max_cycles = process_events(); - } - - if (exec_flags) { - // define next execution block - eb_start = ppc_next_instruction_address; - if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) { - pc_real += (int)eb_start - (int)ppc_state.pc; - opcode = ppc_read_instruction(pc_real); - } else { - page_start = eb_start & PPC_PAGE_MASK; - eb_end = page_start + PPC_PAGE_SIZE - 1; - pc_real = mmu_translate_imem(eb_start); - opcode = ppc_read_instruction(pc_real); - } - ppc_state.pc = eb_start; - exec_flags = 0; + if (exec_flags) { + // define next execution block + eb_start = ppc_next_instruction_address; + if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) { + pc_real += (int)eb_start - (int)ppc_state.pc; } else { - ppc_state.pc += 4; - pc_real += 4; - opcode = ppc_read_instruction(pc_real); + page_start = eb_start & PPC_PAGE_MASK; + eb_end = page_start + PPC_PAGE_SIZE - 1; + pc_real = mmu_translate_imem(eb_start); } - - if (exec_type == until) - if (ppc_state.pc == start_addr) - break; + ppc_state.pc = eb_start; + exec_flags = 0; + } else { [[likely]] + ppc_state.pc += 4; + pc_real += 4; } if (exec_type == until)