Preserve SP PC when clearing halt

Also don't re-init pipeline if SP wasn't already halted.

Fixes #151
This commit is contained in:
Adam Gashlin 2020-05-29 23:49:32 -07:00
parent ec94eef39b
commit 0c40ffdde2

View file

@ -101,8 +101,12 @@ void rsp_status_write(struct rsp *rsp, uint32_t rt) {
prev_status = rsp->regs[RSP_CP0_REGISTER_SP_STATUS];
status = prev_status;
if (rt & SP_CLR_HALT) {
if ((rt & SP_CLR_HALT) && (status & SP_STATUS_HALT)) {
// Save PC around pipeline init
uint32_t pc = rsp->pipeline.ifrd_latch.pc;
rsp_pipeline_init(&rsp->pipeline);
rsp->pipeline.ifrd_latch.pc = pc;
status &= ~SP_STATUS_HALT;
}