From: Rune Holm Date: Sun, 20 Jun 2021 19:03:05 +0000 (+0200) Subject: introducing CPU state parameter 4 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=514f1d4e24f7e938c0a0d79330f8a6ef5a2eb5fa;p=pistorm introducing CPU state parameter 4 --- diff --git a/m68k.h b/m68k.h index b3a5687..86c019a 100644 --- a/m68k.h +++ b/m68k.h @@ -387,7 +387,7 @@ void m68k_state_register(const char *type, int index); unsigned int m68k_get_reg(void* context, m68k_register_t reg); /* Poke values into the internals of the currently running CPU context */ -void m68k_set_reg(m68k_register_t reg, unsigned int value); +void m68k_set_reg(void *context, m68k_register_t regnum, unsigned int value); /* Check if an instruction is valid for the specified CPU type */ unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type); diff --git a/m68k_in.c b/m68k_in.c index 8cafe9a..d0d50d7 100644 --- a/m68k_in.c +++ b/m68k_in.c @@ -1854,7 +1854,7 @@ M68KMAKE_OP(andi, 32, ., .) M68KMAKE_OP(andi, 16, toc, .) { - m68ki_set_ccr(m68ki_get_ccr() & OPER_I_8(state)); + m68ki_set_ccr(state, m68ki_get_ccr(state) & OPER_I_8(state)); } @@ -2303,7 +2303,7 @@ M68KMAKE_OP(bcc, 8, ., .) if(M68KMAKE_CC) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + m68ki_branch_8(state, MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); @@ -2317,7 +2317,7 @@ M68KMAKE_OP(bcc, 16, ., .) uint offset = OPER_I_16(state); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); + m68ki_branch_16(state, offset); return; } REG_PC += 2; @@ -2334,7 +2334,7 @@ M68KMAKE_OP(bcc, 32, ., .) uint offset = OPER_I_32(state); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); + m68ki_branch_32(state, offset); return; } REG_PC += 4; @@ -2345,7 +2345,7 @@ M68KMAKE_OP(bcc, 32, ., .) if(M68KMAKE_CC) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + m68ki_branch_8(state, MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); @@ -3180,7 +3180,7 @@ M68KMAKE_OP(bkpt, 0, ., .) M68KMAKE_OP(bra, 8, ., .) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + m68ki_branch_8(state, MASK_OUT_ABOVE_8(REG_IR)); // TODO: review this... // if(REG_PC == REG_PPC) // USE_ALL_CYCLES(); @@ -3192,7 +3192,7 @@ M68KMAKE_OP(bra, 16, ., .) uint offset = OPER_I_16(state); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); + m68ki_branch_16(state, offset); // TODO: review this... // if(REG_PC == REG_PPC) // USE_ALL_CYCLES(); @@ -3206,7 +3206,7 @@ M68KMAKE_OP(bra, 32, ., .) uint offset = OPER_I_32(state); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); + m68ki_branch_32(state, offset); // TODO: review this... // if(REG_PC == REG_PPC) // USE_ALL_CYCLES(); @@ -3217,7 +3217,7 @@ M68KMAKE_OP(bra, 32, ., .) // TODO: review this... m68ki_exception_illegal(state); // m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ -// m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); +// m68ki_branch_8(state, MASK_OUT_ABOVE_8(REG_IR)); // if(REG_PC == REG_PPC) // USE_ALL_CYCLES(); } @@ -3270,7 +3270,7 @@ M68KMAKE_OP(bsr, 8, ., .) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(state, REG_PC); - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + m68ki_branch_8(state, MASK_OUT_ABOVE_8(REG_IR)); } @@ -3280,7 +3280,7 @@ M68KMAKE_OP(bsr, 16, ., .) m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(state, REG_PC); REG_PC -= 2; - m68ki_branch_16(offset); + m68ki_branch_16(state, offset); } @@ -3292,7 +3292,7 @@ M68KMAKE_OP(bsr, 32, ., .) m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(state, REG_PC); REG_PC -= 4; - m68ki_branch_32(offset); + m68ki_branch_32(state, offset); return; } else @@ -3301,7 +3301,7 @@ M68KMAKE_OP(bsr, 32, ., .) m68ki_exception_illegal(state); // m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ // m68ki_push_32(state, REG_PC); -// m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); +// m68ki_branch_8(state, MASK_OUT_ABOVE_8(REG_IR)); } } @@ -4514,7 +4514,7 @@ M68KMAKE_OP(dbf, 16, ., .) uint offset = OPER_I_16(state); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); + m68ki_branch_16(state, offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } @@ -4536,7 +4536,7 @@ M68KMAKE_OP(dbcc, 16, ., .) uint offset = OPER_I_16(state); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); + m68ki_branch_16(state, offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } @@ -5251,7 +5251,7 @@ M68KMAKE_OP(eori, 32, ., .) M68KMAKE_OP(eori, 16, toc, .) { - m68ki_set_ccr(m68ki_get_ccr() ^ OPER_I_8(state)); + m68ki_set_ccr(state, m68ki_get_ccr(state) ^ OPER_I_8(state)); } @@ -5349,7 +5349,7 @@ M68KMAKE_OP(illegal, 0, ., .) M68KMAKE_OP(jmp, 32, ., .) { - m68ki_jump(M68KMAKE_GET_EA_AY_32); + m68ki_jump(state, M68KMAKE_GET_EA_AY_32); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ } @@ -5359,7 +5359,7 @@ M68KMAKE_OP(jsr, 32, ., .) uint ea = M68KMAKE_GET_EA_AY_32; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(state, REG_PC); - m68ki_jump(ea); + m68ki_jump(state, ea); } @@ -6774,7 +6774,7 @@ M68KMAKE_OP(move, 16, frc, d) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { - DY = MASK_OUT_BELOW_16(DY) | m68ki_get_ccr(); + DY = MASK_OUT_BELOW_16(DY) | m68ki_get_ccr(state); return; } m68ki_exception_illegal(state); @@ -6785,7 +6785,7 @@ M68KMAKE_OP(move, 16, frc, .) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { - m68ki_write_16(state, M68KMAKE_GET_EA_AY_16, m68ki_get_ccr()); + m68ki_write_16(state, M68KMAKE_GET_EA_AY_16, m68ki_get_ccr(state)); return; } m68ki_exception_illegal(state); @@ -6794,13 +6794,13 @@ M68KMAKE_OP(move, 16, frc, .) M68KMAKE_OP(move, 16, toc, d) { - m68ki_set_ccr(DY); + m68ki_set_ccr(state, DY); } M68KMAKE_OP(move, 16, toc, .) { - m68ki_set_ccr(M68KMAKE_GET_OPER_AY_16); + m68ki_set_ccr(state, M68KMAKE_GET_OPER_AY_16); } @@ -8404,7 +8404,7 @@ M68KMAKE_OP(ori, 32, ., .) M68KMAKE_OP(ori, 16, toc, .) { - m68ki_set_ccr(m68ki_get_ccr() | OPER_I_8(state)); + m68ki_set_ccr(state, m68ki_get_ccr(state) | OPER_I_8(state)); } @@ -9336,7 +9336,7 @@ M68KMAKE_OP(rtd, 32, ., .) m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16(state))); - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); return; } m68ki_exception_illegal(state); @@ -9358,7 +9358,7 @@ M68KMAKE_OP(rte, 32, ., .) { new_sr = m68ki_pull_16(state); new_pc = m68ki_pull_32(state); - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; @@ -9375,7 +9375,7 @@ M68KMAKE_OP(rte, 32, ., .) new_sr = m68ki_pull_16(state); new_pc = m68ki_pull_32(state); m68ki_fake_pull_16(state); /* format word */ - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; @@ -9385,7 +9385,7 @@ M68KMAKE_OP(rte, 32, ., .) new_sr = m68ki_pull_16(state); new_pc = m68ki_pull_32(state); m68ki_fake_pull_16(state); /* format word */ - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; @@ -9420,7 +9420,7 @@ rte_loop: new_sr = m68ki_pull_16(state); new_pc = m68ki_pull_32(state); m68ki_fake_pull_16(state); /* format word */ - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; @@ -9436,7 +9436,7 @@ rte_loop: new_pc = m68ki_pull_32(state); m68ki_fake_pull_16(state); /* format word */ m68ki_fake_pull_32(state); /* address */ - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; @@ -9460,7 +9460,7 @@ rte_loop: m68ki_fake_pull_32(state); /* $30: pd1 */ m68ki_fake_pull_32(state); /* $34: pd2 */ m68ki_fake_pull_32(state); /* $38: pd3 */ - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; @@ -9479,7 +9479,7 @@ rte_loop: m68ki_fake_pull_32(state); /* $18: data output buffer */ m68ki_fake_pull_32(state); /* $1c: internal registers */ - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; @@ -9514,7 +9514,7 @@ rte_loop: m68ki_fake_pull_32(state); /* $54: */ m68ki_fake_pull_32(state); /* $58: */ - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); m68ki_set_sr(state, new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; @@ -9547,15 +9547,15 @@ M68KMAKE_OP(rtm, 32, ., .) M68KMAKE_OP(rtr, 32, ., .) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_ccr(m68ki_pull_16(state)); - m68ki_jump(m68ki_pull_32(state)); + m68ki_set_ccr(state, m68ki_pull_16(state)); + m68ki_jump(state, m68ki_pull_32(state)); } M68KMAKE_OP(rts, 32, ., .) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_jump(m68ki_pull_32(state)); + m68ki_jump(state, m68ki_pull_32(state)); } diff --git a/m68kcpu.c b/m68kcpu.c index 49c65a0..1b1f44f 100644 --- a/m68kcpu.c +++ b/m68kcpu.c @@ -676,8 +676,9 @@ unsigned int m68k_get_reg(void* context, m68k_register_t regnum) return 0; } -void m68k_set_reg(m68k_register_t regnum, unsigned int value) +void m68k_set_reg(void *context, m68k_register_t regnum, unsigned int value) { + m68ki_cpu_core* state = context != NULL ?(m68ki_cpu_core*)context : &m68ki_cpu; switch(regnum) { case M68K_REG_D0: REG_D[0] = MASK_OUT_ABOVE_32(value); return; @@ -696,8 +697,10 @@ void m68k_set_reg(m68k_register_t regnum, unsigned int value) case M68K_REG_A5: REG_A[5] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A6: REG_A[6] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A7: REG_A[7] = MASK_OUT_ABOVE_32(value); return; - case M68K_REG_PC: m68ki_jump(MASK_OUT_ABOVE_32(value)); return; - case M68K_REG_SR: m68ki_set_sr_noint_nosp(value); return; + case M68K_REG_PC: + m68ki_jump(state, MASK_OUT_ABOVE_32(value)); return; + case M68K_REG_SR: + m68ki_set_sr_noint_nosp(state, value); return; case M68K_REG_SP: REG_SP = MASK_OUT_ABOVE_32(value); return; case M68K_REG_USP: if(FLAG_S) REG_USP = MASK_OUT_ABOVE_32(value); @@ -1148,7 +1151,7 @@ void m68k_pulse_reset(m68ki_cpu_core *state) /* Reset VBR */ REG_VBR = 0; /* Go to supervisor mode */ - m68ki_set_sm_flag(SFLAG_SET | MFLAG_CLEAR); + m68ki_set_sm_flag(state, SFLAG_SET | MFLAG_CLEAR); /* Invalidate the prefetch queue */ #if M68K_EMULATE_PREFETCH @@ -1157,10 +1160,10 @@ void m68k_pulse_reset(m68ki_cpu_core *state) #endif /* M68K_EMULATE_PREFETCH */ /* Read the initial stack pointer and program counter */ - m68ki_jump(0); + m68ki_jump(state, 0); REG_SP = m68ki_read_imm_32(state); REG_PC = m68ki_read_imm_32(state); - m68ki_jump(REG_PC); + m68ki_jump(state, REG_PC); CPU_RUN_MODE = RUN_MODE_NORMAL; diff --git a/m68kcpu.h b/m68kcpu.h index a2c7e5c..388e42f 100644 --- a/m68kcpu.h +++ b/m68kcpu.h @@ -866,19 +866,19 @@ extern jmp_buf m68ki_aerr_trap; /* Get the condition code register */ -#define m68ki_get_ccr() ((COND_XS() >> 4) | \ - (COND_MI() >> 4) | \ - (COND_EQ() << 2) | \ - (COND_VS() >> 6) | \ - (COND_CS() >> 8)) +#define m68ki_get_ccr(state) ((COND_XS() >> 4) | \ + (COND_MI() >> 4) | \ + (COND_EQ() << 2) | \ + (COND_VS() >> 6) | \ + (COND_CS() >> 8)) /* Get the status register */ -#define m68ki_get_sr() ( FLAG_T1 | \ - FLAG_T0 | \ - (FLAG_S << 11) | \ - (FLAG_M << 11) | \ - FLAG_INT_MASK | \ - m68ki_get_ccr()) +#define m68ki_get_sr(state) ( FLAG_T1 | \ + FLAG_T0 | \ + (FLAG_S << 11) | \ + (FLAG_M << 11) | \ + FLAG_INT_MASK | \ + m68ki_get_ccr(state)) @@ -1640,7 +1640,7 @@ static inline void m68ki_fake_pull_32(m68ki_cpu_core *state) * These functions will also call the pc_changed callback if it was enabled * in m68kconf.h. */ -static inline void m68ki_jump(uint new_pc) +static inline void m68ki_jump(m68ki_cpu_core *state, uint new_pc) { REG_PC = new_pc; m68ki_pc_changed(REG_PC); @@ -1659,17 +1659,17 @@ static inline void m68ki_jump_vector(m68ki_cpu_core *state, uint vector) * So far I've found no problems with not calling pc_changed for 8 or 16 * bit branches. */ -static inline void m68ki_branch_8(uint offset) +static inline void m68ki_branch_8(m68ki_cpu_core *state, uint offset) { REG_PC += MAKE_INT_8(offset); } -static inline void m68ki_branch_16(uint offset) +static inline void m68ki_branch_16(m68ki_cpu_core *state, uint offset) { REG_PC += MAKE_INT_16(offset); } -static inline void m68ki_branch_32(uint offset) +static inline void m68ki_branch_32(m68ki_cpu_core *state, uint offset) { REG_PC += offset; m68ki_pc_changed(REG_PC); @@ -1680,7 +1680,7 @@ static inline void m68ki_branch_32(uint offset) /* Set the S flag and change the active stack pointer. * Note that value MUST be 4 or 0. */ -static inline void m68ki_set_s_flag(uint value) +static inline void m68ki_set_s_flag(m68ki_cpu_core *state, uint value) { /* Backup the old stack pointer */ REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)] = REG_SP; @@ -1693,7 +1693,7 @@ static inline void m68ki_set_s_flag(uint value) /* Set the S and M flags and change the active stack pointer. * Note that value MUST be 0, 2, 4, or 6 (bit2 = S, bit1 = M). */ -static inline void m68ki_set_sm_flag(uint value) +static inline void m68ki_set_sm_flag(m68ki_cpu_core *state, uint value) { /* Backup the old stack pointer */ REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)] = REG_SP; @@ -1705,7 +1705,7 @@ static inline void m68ki_set_sm_flag(uint value) } /* Set the S and M flags. Don't touch the stack pointer. */ -static inline void m68ki_set_sm_flag_nosp(uint value) +static inline void m68ki_set_sm_flag_nosp(m68ki_cpu_core *state, uint value) { /* Set the S and M flags */ FLAG_S = value & SFLAG_SET; @@ -1714,7 +1714,7 @@ static inline void m68ki_set_sm_flag_nosp(uint value) /* Set the condition code register */ -static inline void m68ki_set_ccr(uint value) +static inline void m68ki_set_ccr(m68ki_cpu_core *state, uint value) { FLAG_X = BIT_4(value) << 4; FLAG_N = BIT_3(value) << 4; @@ -1733,14 +1733,14 @@ static inline void m68ki_set_sr_noint(m68ki_cpu_core *state, uint value) FLAG_T1 = BIT_F(value); FLAG_T0 = BIT_E(value); FLAG_INT_MASK = value & 0x0700; - m68ki_set_ccr(value); - m68ki_set_sm_flag((value >> 11) & 6); + m68ki_set_ccr(state, value); + m68ki_set_sm_flag(state, (value >> 11) & 6); } /* Set the status register but don't check for interrupts nor * change the stack pointer */ -static inline void m68ki_set_sr_noint_nosp(uint value) +static inline void m68ki_set_sr_noint_nosp(m68ki_cpu_core *state, uint value) { /* Mask out the "unimplemented" bits */ value &= CPU_SR_MASK; @@ -1749,8 +1749,8 @@ static inline void m68ki_set_sr_noint_nosp(uint value) FLAG_T1 = BIT_F(value); FLAG_T0 = BIT_E(value); FLAG_INT_MASK = value & 0x0700; - m68ki_set_ccr(value); - m68ki_set_sm_flag_nosp((value >> 11) & 6); + m68ki_set_ccr(state, value); + m68ki_set_sm_flag_nosp(state, (value >> 11) & 6); } /* Set the status register and check for interrupts */ @@ -1764,7 +1764,7 @@ static inline void m68ki_set_sr(m68ki_cpu_core *state, uint value) /* ------------------------- Exception Processing ------------------------- */ /* Initiate exception processing */ -static inline uint m68ki_init_exception(void) +static inline uint m68ki_init_exception(m68ki_cpu_core *state) { /* Save the old status register */ uint sr = m68ki_get_sr(); @@ -1773,7 +1773,7 @@ static inline uint m68ki_init_exception(void) FLAG_T1 = FLAG_T0 = 0; m68ki_clear_trace(); /* Enter supervisor mode */ - m68ki_set_s_flag(SFLAG_SET); + m68ki_set_s_flag(state, SFLAG_SET); return sr; } @@ -2068,7 +2068,7 @@ m68ki_stack_frame_0111(m68ki_cpu_core *state, uint sr, uint vector, uint pc, uin */ static inline void m68ki_exception_trap(m68ki_cpu_core *state, uint vector) { - uint sr = m68ki_init_exception(); + uint sr = m68ki_init_exception(state); if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) m68ki_stack_frame_0000(state, REG_PC, sr, vector); @@ -2084,7 +2084,7 @@ static inline void m68ki_exception_trap(m68ki_cpu_core *state, uint vector) /* Trap#n stacks a 0 frame but behaves like group2 otherwise */ static inline void m68ki_exception_trapN(m68ki_cpu_core *state, uint vector) { - uint sr = m68ki_init_exception(); + uint sr = m68ki_init_exception(state); m68ki_stack_frame_0000(state, REG_PC, sr, vector); m68ki_jump_vector(state, vector); @@ -2095,7 +2095,7 @@ static inline void m68ki_exception_trapN(m68ki_cpu_core *state, uint vector) /* Exception for trace mode */ static inline void m68ki_exception_trace(m68ki_cpu_core *state) { - uint sr = m68ki_init_exception(); + uint sr = m68ki_init_exception(state); if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) { @@ -2122,7 +2122,7 @@ static inline void m68ki_exception_trace(m68ki_cpu_core *state) /* Exception for privilege violation */ static inline void m68ki_exception_privilege_violation(m68ki_cpu_core *state) { - uint sr = m68ki_init_exception(); + uint sr = m68ki_init_exception(state); #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON if(CPU_TYPE_IS_000(CPU_TYPE)) @@ -2166,7 +2166,7 @@ static inline void m68ki_exception_bus_error(m68ki_cpu_core *state) REG_DA[i] = REG_DA_SAVE[i]; } - uint sr = m68ki_init_exception(); + uint sr = m68ki_init_exception(state); m68ki_stack_frame_1000(state, REG_PPC, sr, EXCEPTION_BUS_ERROR); m68ki_jump_vector(state, EXCEPTION_BUS_ERROR); @@ -2185,7 +2185,7 @@ static inline void m68ki_exception_1010(m68ki_cpu_core *state) m68ki_disassemble_quick(ADDRESS_68K(REG_PPC),CPU_TYPE))); #endif - sr = m68ki_init_exception(); + sr = m68ki_init_exception(state); m68ki_stack_frame_0000(state, REG_PPC, sr, EXCEPTION_1010); m68ki_jump_vector(state, EXCEPTION_1010); @@ -2204,7 +2204,7 @@ static inline void m68ki_exception_1111(m68ki_cpu_core *state) m68ki_disassemble_quick(ADDRESS_68K(REG_PPC),CPU_TYPE))); #endif - sr = m68ki_init_exception(); + sr = m68ki_init_exception(state); m68ki_stack_frame_0000(state, REG_PPC, sr, EXCEPTION_1111); m68ki_jump_vector(state, EXCEPTION_1111); @@ -2227,7 +2227,7 @@ static inline void m68ki_exception_illegal(m68ki_cpu_core *state) if (m68ki_illg_callback(REG_IR)) return; - sr = m68ki_init_exception(); + sr = m68ki_init_exception(state); #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON if(CPU_TYPE_IS_000(CPU_TYPE)) @@ -2246,7 +2246,7 @@ static inline void m68ki_exception_illegal(m68ki_cpu_core *state) /* Exception for format errror in RTE */ static inline void m68ki_exception_format_error(m68ki_cpu_core *state) { - uint sr = m68ki_init_exception(); + uint sr = m68ki_init_exception(state); m68ki_stack_frame_0000(state, REG_PC, sr, EXCEPTION_FORMAT_ERROR); m68ki_jump_vector(state, EXCEPTION_FORMAT_ERROR); @@ -2257,7 +2257,7 @@ static inline void m68ki_exception_format_error(m68ki_cpu_core *state) /* Exception for address error */ static inline void m68ki_exception_address_error(m68ki_cpu_core *state) { - uint32 sr = m68ki_init_exception(); + uint32 sr = m68ki_init_exception(state); /* If we were processing a bus error, address error, or reset, * this is a catastrophic failure. @@ -2342,7 +2342,7 @@ static inline void m68ki_exception_interrupt(m68ki_cpu_core *state, uint int_lev } /* Start exception processing */ - sr = m68ki_init_exception(); + sr = m68ki_init_exception(state); /* Set the interrupt mask to the level of the one being serviced */ FLAG_INT_MASK = int_level<<8; @@ -2359,12 +2359,12 @@ static inline void m68ki_exception_interrupt(m68ki_cpu_core *state, uint int_lev if(FLAG_M && CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Create throwaway frame */ - m68ki_set_sm_flag(FLAG_S); /* clear M */ + m68ki_set_sm_flag(state, FLAG_S); /* clear M */ sr |= 0x2000; /* Same as SR in master stack frame except S is forced high */ m68ki_stack_frame_0001(state, REG_PC, sr, vector); } - m68ki_jump(new_pc); + m68ki_jump(state, new_pc); /* Defer cycle counting until later */ USE_CYCLES(CYC_EXCEPTION[vector]); diff --git a/m68kfpu.c b/m68kfpu.c index 8ec06bc..d98b1f7 100644 --- a/m68kfpu.c +++ b/m68kfpu.c @@ -2052,7 +2052,7 @@ static void fbcc16(m68ki_cpu_core *state) if (TEST_CONDITION(state, condition)) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset-2); + m68ki_branch_16(state, offset - 2); } USE_CYCLES(7); @@ -2069,7 +2069,7 @@ static void fbcc32(m68ki_cpu_core *state) if (TEST_CONDITION(state, condition)) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset-4); + m68ki_branch_32(state, offset - 4); } USE_CYCLES(7);