don't assert on disassembling an invalid instruction

This commit is contained in:
Anthony Pesch 2017-05-11 17:08:49 -04:00
parent e27a522e4a
commit 52e5095933
3 changed files with 11 additions and 21 deletions

View File

@ -160,13 +160,7 @@ static void sh4_translate(void *data, uint32_t addr, struct ir *ir, int fastmem,
if (instr.flags & SH4_FLAG_DELAYED) {
delay_instr.addr = addr + i;
delay_instr.opcode = as_read16(sh4->memory_if->space, delay_instr.addr);
/* instruction must be valid, breakpoints on delay instructions aren't
currently supported */
CHECK(sh4_disasm(&delay_instr));
/* delay instruction itself should never have a delay instr */
CHECK(!(delay_instr.flags & SH4_FLAG_DELAYED));
sh4_disasm(&delay_instr);
i += 2;
}

View File

@ -15,11 +15,7 @@ void sh4_analyze_block(const struct jit *jit, struct sh4_analysis *as) {
instr.addr = as->addr + as->size;
instr.opcode = guest->r16(guest->space, instr.addr);
/* end block on invalid instruction */
if (!sh4_disasm(&instr)) {
break;
}
int valid = sh4_disasm(&instr);
as->size += 2;
as->cycles += instr.cycles;
@ -28,11 +24,17 @@ void sh4_analyze_block(const struct jit *jit, struct sh4_analysis *as) {
delay_instr.addr = as->addr + as->size;
delay_instr.opcode = guest->r16(guest->space, delay_instr.addr);
CHECK(sh4_disasm(&delay_instr));
CHECK(!(delay_instr.flags & SH4_FLAG_DELAYED));
valid = sh4_disasm(&delay_instr);
as->size += 2;
as->cycles += delay_instr.cycles;
/* delay slots can't have another delay slot */
CHECK(!(delay_instr.flags & SH4_FLAG_DELAYED));
}
/* end block on invalid instruction */
if (!valid) {
break;
}
/* stop emitting once a branch has been hit. in addition, if fpscr has
@ -43,10 +45,5 @@ void sh4_analyze_block(const struct jit *jit, struct sh4_analysis *as) {
(SH4_FLAG_BRANCH | SH4_FLAG_SET_FPSCR | SH4_FLAG_SET_SR)) {
break;
}
/* used by debugger when stepping through instructions */
if (as->flags & SH4_SINGLE_INSTR) {
break;
}
}
}

View File

@ -10,7 +10,6 @@ enum {
SH4_FASTMEM = 0x1,
SH4_DOUBLE_PR = 0x2,
SH4_DOUBLE_SZ = 0x4,
SH4_SINGLE_INSTR = 0x8,
};
struct sh4_frontend {