mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-02-10 14:30:59 +00:00
ppcexec: Simplify ppc_exec_inner.
One while loop instead of two. One call to ppc_read_instruction instead of four.
This commit is contained in:
parent
7b1ea17fb8
commit
e63f928a3c
@ -264,62 +264,46 @@ typedef enum {
|
||||
template <ppc_exec_type_t exec_type>
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user