static void saturn_set_info(UINT32 state, cpuinfo *info) { switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ case CPUINFO_INT_INPUT_STATE + SATURN_NMI_STATE: saturn.nmi_state = info->i; break; case CPUINFO_INT_INPUT_STATE + SATURN_IRQ_STATE: saturn.irq_state = info->i; break; case CPUINFO_INT_PC: case CPUINFO_INT_REGISTER + SATURN_PC: saturn.pc = info->i; change_pc(saturn.pc); break; case CPUINFO_INT_SP: saturn.stackpointer = info->i; break; case CPUINFO_INT_REGISTER + SATURN_D0: saturn.d[0] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_D1: saturn.d[1] = info->i; break; #if 0 case CPUINFO_INT_REGISTER + SATURN_A: saturn.reg[A] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_B: saturn.reg[B] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_C: saturn.reg[C] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_D: saturn.reg[D] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_R0: saturn.reg[R0] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_R1: saturn.reg[R1] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_R2: saturn.reg[R2] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_R3: saturn.reg[R3] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_R4: saturn.reg[R4] = info->i; break; #endif case CPUINFO_INT_REGISTER + SATURN_P: saturn.p = info->i; break; case CPUINFO_INT_REGISTER + SATURN_IN: saturn.in = info->i; break; case CPUINFO_INT_REGISTER + SATURN_OUT: saturn.out = info->i; break; case CPUINFO_INT_REGISTER + SATURN_CARRY: saturn.carry = info->i; break; case CPUINFO_INT_REGISTER + SATURN_ST: saturn.st = info->i; break; case CPUINFO_INT_REGISTER + SATURN_HST: saturn.hst = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK0: saturn.rstk[0] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK1: saturn.rstk[1] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK2: saturn.rstk[2] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK3: saturn.rstk[3] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK4: saturn.rstk[4] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK5: saturn.rstk[5] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK6: saturn.rstk[6] = info->i; break; case CPUINFO_INT_REGISTER + SATURN_RSTK7: saturn.rstk[7] = info->i; break; } }
static void HandleBranch( UINT32 insn ) { UINT32 off = (insn & INSN_BRANCH) << 2; /* Save PC into LR if this is a branch with link */ if (insn & INSN_BL) { SetRegister(14,R15 + 4); } /* Sign-extend the 24-bit offset in our calculations */ if (off & 0x2000000u) { R15 -= ((~(off | 0xfc000000u)) + 1) - 8; } else { R15 += off + 8; } change_pc(R15 & ADDRESS_MASK); arm_icount -= 2 * S_CYCLE + N_CYCLE; }
static void t11_set_info(UINT32 state, cpuinfo *info) { switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ case CPUINFO_INT_INPUT_STATE + T11_IRQ0: set_irq_line(T11_IRQ0, info->i); break; case CPUINFO_INT_INPUT_STATE + T11_IRQ1: set_irq_line(T11_IRQ1, info->i); break; case CPUINFO_INT_INPUT_STATE + T11_IRQ2: set_irq_line(T11_IRQ2, info->i); break; case CPUINFO_INT_INPUT_STATE + T11_IRQ3: set_irq_line(T11_IRQ3, info->i); break; case CPUINFO_INT_PC: case CPUINFO_INT_REGISTER + T11_PC: PC = info->i; change_pc(PC); break; case CPUINFO_INT_SP: case CPUINFO_INT_REGISTER + T11_SP: SP = info->i; break; case CPUINFO_INT_REGISTER + T11_PSW: PSW = info->i; break; case CPUINFO_INT_REGISTER + T11_R0: REGW(0) = info->i; break; case CPUINFO_INT_REGISTER + T11_R1: REGW(1) = info->i; break; case CPUINFO_INT_REGISTER + T11_R2: REGW(2) = info->i; break; case CPUINFO_INT_REGISTER + T11_R3: REGW(3) = info->i; break; case CPUINFO_INT_REGISTER + T11_R4: REGW(4) = info->i; break; case CPUINFO_INT_REGISTER + T11_R5: REGW(5) = info->i; break; } }
static void t11_check_irqs(void) { const struct irq_table_entry *irq = &irq_table[t11.irq_state & 15]; int priority = PSW & 0xe0; /* compare the priority of the interrupt to the PSW */ if (irq->priority > priority) { int vector = irq->vector; int new_pc, new_psw; /* call the callback; if we don't get -1 back, use the return value as our vector */ if (t11.irq_callback != NULL) { int new_vector = (*t11.irq_callback)(t11.irq_state & 15); if (new_vector != -1) vector = new_vector; } /* fetch the new PC and PSW from that vector */ assert((vector & 3) == 0); new_pc = RWORD(vector); new_psw = RWORD(vector + 2); /* push the old state, set the new one */ PUSH(PSW); PUSH(PC); PCD = new_pc; PSW = new_psw; change_pc(PC); t11_check_irqs(); /* count cycles and clear the WAIT flag */ t11.interrupt_cycles += 114; t11.wait_state = 0; } }
static void m6502_set_info(UINT32 state, union cpuinfo *info) { switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ case CPUINFO_INT_INPUT_STATE + M6502_IRQ_LINE: m6502_set_irq_line(M6502_IRQ_LINE, info->i); break; case CPUINFO_INT_INPUT_STATE + M6502_SET_OVERFLOW:m6502_set_irq_line(M6502_SET_OVERFLOW, info->i); break; case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI: m6502_set_irq_line(INPUT_LINE_NMI, info->i); break; case CPUINFO_INT_PC: PCW = info->i; change_pc(PCD); break; case CPUINFO_INT_REGISTER + M6502_PC: m6502.pc.w.l = info->i; break; case CPUINFO_INT_SP: S = info->i; break; case CPUINFO_INT_REGISTER + M6502_S: m6502.sp.b.l = info->i; break; case CPUINFO_INT_REGISTER + M6502_P: m6502.p = info->i; break; case CPUINFO_INT_REGISTER + M6502_A: m6502.a = info->i; break; case CPUINFO_INT_REGISTER + M6502_X: m6502.x = info->i; break; case CPUINFO_INT_REGISTER + M6502_Y: m6502.y = info->i; break; case CPUINFO_INT_REGISTER + M6502_EA: m6502.ea.w.l = info->i; break; case CPUINFO_INT_REGISTER + M6502_ZP: m6502.zp.w.l = info->i; break; /* --- the following bits of info are set as pointers to data or functions --- */ case CPUINFO_PTR_IRQ_CALLBACK: m6502.irq_callback = info->irqcallback; break; } }
static void m65c02_set_irq_line(int irqline, int state) { if (irqline == INPUT_LINE_NMI) { if (m6502.nmi_state == state) return; m6502.nmi_state = state; if( state != CLEAR_LINE ) { LOG(( "M6502#%d set_nmi_line(ASSERT)\n", cpu_getactivecpu())); EAD = M6502_NMI_VEC; m6502_ICount -= 7; PUSH(PCH); PUSH(PCL); PUSH(P & ~F_B); P = (P & ~F_D) | F_I; /* knock out D and set I flag */ PCL = RDMEM(EAD); PCH = RDMEM(EAD+1); LOG(("M6502#%d takes NMI ($%04x)\n", cpu_getactivecpu(), PCD)); change_pc(PCD); } } else m6502_set_irq_line(irqline,state); }
INLINE void SET_PC(int pc) { hc11.pc = pc; change_pc(hc11.pc); }
static void HandleMemSingle( UINT32 insn ) { UINT32 rn, rnv, off, rd; /* Fetch the offset */ if (insn & INSN_I) { off = decodeShift(insn, NULL); } else { off = insn & INSN_SDT_IMM; } /* Calculate Rn, accounting for PC */ rn = (insn & INSN_RN) >> INSN_RN_SHIFT; if (insn & INSN_SDT_P) { /* Pre-indexed addressing */ if (insn & INSN_SDT_U) { rnv = (GetRegister(rn) + off); } else { rnv = (GetRegister(rn) - off); } if (insn & INSN_SDT_W) { SetRegister(rn,rnv); } else if (rn == eR15) { rnv = (rnv & ADDRESS_MASK) + 8; } } else { /* Post-indexed addressing */ if (rn == eR15) { rnv = (R15 & ADDRESS_MASK) + 8; } else { rnv = GetRegister(rn); } } /* Do the transfer */ rd = (insn & INSN_RD) >> INSN_RD_SHIFT; if (insn & INSN_SDT_L) { /* Load */ arm_icount -= S_CYCLE + I_CYCLE + N_CYCLE; if (insn & INSN_SDT_B) { SetRegister(rd,(UINT32) READ8(rnv)); } else { if (rd == eR15) { R15 = (READ32(rnv) & ADDRESS_MASK) | (R15 & PSR_MASK) | (R15 & MODE_MASK); change_pc(R15 & ADDRESS_MASK); /* The docs are explicit in that the bottom bits should be masked off when writing to R15 in this way, however World Cup Volleyball 95 has an example of an unaligned jump (bottom bits = 2) where execution should definitely continue from the rounded up address. In other cases, 4 is subracted from R15 here to account for pipelining. */ if ((READ32(rnv)&3)==0) R15 -= 4; arm_icount -= S_CYCLE + N_CYCLE; } else { SetRegister(rd,READ32(rnv)); } } } else { /* Store */ arm_icount -= 2 * N_CYCLE; if (insn & INSN_SDT_B) { WRITE8(rnv, (UINT8) GetRegister(rd) & 0xffu); } else { WRITE32(rnv, rd == eR15 ? R15 + 8 : GetRegister(rd)); } } /* Do post-indexing writeback */ if (!(insn & INSN_SDT_P)/* && (insn&INSN_SDT_W)*/) { if (insn & INSN_SDT_U) { /* Writeback is applied in pipeline, before value is read from mem, so writeback is effectively ignored */ if (rd==rn) { SetRegister(rn,GetRegister(rd)); } else { SetRegister(rn,(rnv + off)); } } else { /* Writeback is applied in pipeline, before value is read from mem, so writeback is effectively ignored */ if (rd==rn) { SetRegister(rn,GetRegister(rd)); } else { SetRegister(rn,(rnv - off)); } } } } /* HandleMemSingle */
/* Generate interrupts */ static void Interrupt(void) { /* the 6805 latches interrupt requests internally, so we don't clear */ /* pending_interrupts until the interrupt is taken, no matter what the */ /* external IRQ pin does. */ #if (1) //HAS_HD63705) if( (m6805.pending_interrupts & (1<<HD63705_INT_NMI)) != 0) { PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); RM16( 0x1ffc, &pPC); change_pc(PC); m6805.pending_interrupts &= ~(1<<HD63705_INT_NMI); m6805_ICount -= 11; } else if( (m6805.pending_interrupts & ((1<<M6805_IRQ_LINE)|HD63705_INT_MASK)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #else if( (m6805.pending_interrupts & (1<<M6805_IRQ_LINE)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #endif { /* standard IRQ */ //#if (HAS_HD63705) // if(SUBTYPE!=SUBTYPE_HD63705) //#endif // PC |= ~AMASK; PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); //#if (HAS_HD63705) if(SUBTYPE==SUBTYPE_HD63705) { /* Need to add emulation of other interrupt sources here KW-2/4/99 */ /* This is just a quick patch for Namco System 2 operation */ if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ1); RM16( 0x1ff8, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ2); RM16( 0x1fec, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_ADCONV))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_ADCONV); RM16( 0x1fea, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER1); RM16( 0x1ff6, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER2); RM16( 0x1ff4, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER3))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER3); RM16( 0x1ff2, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_PCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_PCI); RM16( 0x1ff0, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_SCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_SCI); RM16( 0x1fee, &pPC); change_pc(PC); } } else //#endif { RM16( 0xffff - 5, &pPC ); change_pc(PC); } } // CC & IFLAG m6805.pending_interrupts &= ~(1<<M6805_IRQ_LINE); } m6805_ICount -= 11; } } static void m6805_reset() { int (*save_irqcallback)(int) = m6805.irq_callback; memset(&m6805, 0, sizeof(m6805)); m6805.irq_callback = save_irqcallback; /* Force CPU sub-type and relevant masks */ m6805.subtype = SUBTYPE_M6805; SP_MASK = 0x07f; SP_LOW = 0x060; /* Initial stack pointer */ S = SP_MASK; /* IRQ disabled */ SEI; RM16( 0xfffe , &pPC ); change_pc(PC); } void m6805Reset() { m6805_reset(); } //static void m6805_init(int ) //int (*irqcallback)(int)) //{ // m6805.irq_callback = irqcallback; //} //static void m6805_exit(void) //{ // /* nothing to do */ //} void m6805SetIrqLine(int , int state) { /* Basic 6805 only has one IRQ line */ /* See HD63705 specific version */ if (m6805.irq_state[0] == state) return; m6805.irq_state[0] = state; if (state != CLEAR_LINE) m6805.pending_interrupts |= 1<<M6805_IRQ_LINE; } #include "6805ops.c" /* execute instructions on this CPU until icount expires */ int m6805Run(int cycles) { UINT8 ireg; m6805_ICount = cycles; do { if (m6805.pending_interrupts != 0) { if (SUBTYPE==SUBTYPE_M68705) { m68705_Interrupt(); } else { Interrupt(); } } ireg=M_RDOP(PC++); switch( ireg ) { case 0x00: brset(0x01); break; case 0x01: brclr(0x01); break; case 0x02: brset(0x02); break; case 0x03: brclr(0x02); break; case 0x04: brset(0x04); break; case 0x05: brclr(0x04); break; case 0x06: brset(0x08); break; case 0x07: brclr(0x08); break; case 0x08: brset(0x10); break; case 0x09: brclr(0x10); break; case 0x0A: brset(0x20); break; case 0x0B: brclr(0x20); break; case 0x0C: brset(0x40); break; case 0x0D: brclr(0x40); break; case 0x0E: brset(0x80); break; case 0x0F: brclr(0x80); break; case 0x10: bset(0x01); break; case 0x11: bclr(0x01); break; case 0x12: bset(0x02); break; case 0x13: bclr(0x02); break; case 0x14: bset(0x04); break; case 0x15: bclr(0x04); break; case 0x16: bset(0x08); break; case 0x17: bclr(0x08); break; case 0x18: bset(0x10); break; case 0x19: bclr(0x10); break; case 0x1a: bset(0x20); break; case 0x1b: bclr(0x20); break; case 0x1c: bset(0x40); break; case 0x1d: bclr(0x40); break; case 0x1e: bset(0x80); break; case 0x1f: bclr(0x80); break; case 0x20: bra(); break; case 0x21: brn(); break; case 0x22: bhi(); break; case 0x23: bls(); break; case 0x24: bcc(); break; case 0x25: bcs(); break; case 0x26: bne(); break; case 0x27: beq(); break; case 0x28: bhcc(); break; case 0x29: bhcs(); break; case 0x2a: bpl(); break; case 0x2b: bmi(); break; case 0x2c: bmc(); break; case 0x2d: bms(); break; case 0x2e: bil(); break; case 0x2f: bih(); break; case 0x30: neg_di(); break; case 0x31: illegal(); break; case 0x32: illegal(); break; case 0x33: com_di(); break; case 0x34: lsr_di(); break; case 0x35: illegal(); break; case 0x36: ror_di(); break; case 0x37: asr_di(); break; case 0x38: lsl_di(); break; case 0x39: rol_di(); break; case 0x3a: dec_di(); break; case 0x3b: illegal(); break; case 0x3c: inc_di(); break; case 0x3d: tst_di(); break; case 0x3e: illegal(); break; case 0x3f: clr_di(); break; case 0x40: nega(); break; case 0x41: illegal(); break; case 0x42: illegal(); break; case 0x43: coma(); break; case 0x44: lsra(); break; case 0x45: illegal(); break; case 0x46: rora(); break; case 0x47: asra(); break; case 0x48: lsla(); break; case 0x49: rola(); break; case 0x4a: deca(); break; case 0x4b: illegal(); break; case 0x4c: inca(); break; case 0x4d: tsta(); break; case 0x4e: illegal(); break; case 0x4f: clra(); break; case 0x50: negx(); break; case 0x51: illegal(); break; case 0x52: illegal(); break; case 0x53: comx(); break; case 0x54: lsrx(); break; case 0x55: illegal(); break; case 0x56: rorx(); break; case 0x57: asrx(); break; case 0x58: aslx(); break; case 0x59: rolx(); break; case 0x5a: decx(); break; case 0x5b: illegal(); break; case 0x5c: incx(); break; case 0x5d: tstx(); break; case 0x5e: illegal(); break; case 0x5f: clrx(); break; case 0x60: neg_ix1(); break; case 0x61: illegal(); break; case 0x62: illegal(); break; case 0x63: com_ix1(); break; case 0x64: lsr_ix1(); break; case 0x65: illegal(); break; case 0x66: ror_ix1(); break; case 0x67: asr_ix1(); break; case 0x68: lsl_ix1(); break; case 0x69: rol_ix1(); break; case 0x6a: dec_ix1(); break; case 0x6b: illegal(); break; case 0x6c: inc_ix1(); break; case 0x6d: tst_ix1(); break; case 0x6e: illegal(); break; case 0x6f: clr_ix1(); break; case 0x70: neg_ix(); break; case 0x71: illegal(); break; case 0x72: illegal(); break; case 0x73: com_ix(); break; case 0x74: lsr_ix(); break; case 0x75: illegal(); break; case 0x76: ror_ix(); break; case 0x77: asr_ix(); break; case 0x78: lsl_ix(); break; case 0x79: rol_ix(); break; case 0x7a: dec_ix(); break; case 0x7b: illegal(); break; case 0x7c: inc_ix(); break; case 0x7d: tst_ix(); break; case 0x7e: illegal(); break; case 0x7f: clr_ix(); break; case 0x80: rti(); break; case 0x81: rts(); break; case 0x82: illegal(); break; case 0x83: swi(); break; case 0x84: illegal(); break; case 0x85: illegal(); break; case 0x86: illegal(); break; case 0x87: illegal(); break; case 0x88: illegal(); break; case 0x89: illegal(); break; case 0x8a: illegal(); break; case 0x8b: illegal(); break; case 0x8c: illegal(); break; case 0x8d: illegal(); break; case 0x8e: illegal(); break; case 0x8f: illegal(); break; case 0x90: illegal(); break; case 0x91: illegal(); break; case 0x92: illegal(); break; case 0x93: illegal(); break; case 0x94: illegal(); break; case 0x95: illegal(); break; case 0x96: illegal(); break; case 0x97: tax(); break; case 0x98: CLC; break; case 0x99: SEC; break; #if IRQ_LEVEL_DETECT case 0x9a: CLI; if (m6805.irq_state != CLEAR_LINE) m6805.pending_interrupts |= 1<<M6805_IRQ_LINE; break; #else case 0x9a: CLI; break; #endif case 0x9b: SEI; break; case 0x9c: rsp(); break; case 0x9d: nop(); break; case 0x9e: illegal(); break; case 0x9f: txa(); break; case 0xa0: suba_im(); break; case 0xa1: cmpa_im(); break; case 0xa2: sbca_im(); break; case 0xa3: cpx_im(); break; case 0xa4: anda_im(); break; case 0xa5: bita_im(); break; case 0xa6: lda_im(); break; case 0xa7: illegal(); break; case 0xa8: eora_im(); break; case 0xa9: adca_im(); break; case 0xaa: ora_im(); break; case 0xab: adda_im(); break; case 0xac: illegal(); break; case 0xad: bsr(); break; case 0xae: ldx_im(); break; case 0xaf: illegal(); break; case 0xb0: suba_di(); break; case 0xb1: cmpa_di(); break; case 0xb2: sbca_di(); break; case 0xb3: cpx_di(); break; case 0xb4: anda_di(); break; case 0xb5: bita_di(); break; case 0xb6: lda_di(); break; case 0xb7: sta_di(); break; case 0xb8: eora_di(); break; case 0xb9: adca_di(); break; case 0xba: ora_di(); break; case 0xbb: adda_di(); break; case 0xbc: jmp_di(); break; case 0xbd: jsr_di(); break; case 0xbe: ldx_di(); break; case 0xbf: stx_di(); break; case 0xc0: suba_ex(); break; case 0xc1: cmpa_ex(); break; case 0xc2: sbca_ex(); break; case 0xc3: cpx_ex(); break; case 0xc4: anda_ex(); break; case 0xc5: bita_ex(); break; case 0xc6: lda_ex(); break; case 0xc7: sta_ex(); break; case 0xc8: eora_ex(); break; case 0xc9: adca_ex(); break; case 0xca: ora_ex(); break; case 0xcb: adda_ex(); break; case 0xcc: jmp_ex(); break; case 0xcd: jsr_ex(); break; case 0xce: ldx_ex(); break; case 0xcf: stx_ex(); break; case 0xd0: suba_ix2(); break; case 0xd1: cmpa_ix2(); break; case 0xd2: sbca_ix2(); break; case 0xd3: cpx_ix2(); break; case 0xd4: anda_ix2(); break; case 0xd5: bita_ix2(); break; case 0xd6: lda_ix2(); break; case 0xd7: sta_ix2(); break; case 0xd8: eora_ix2(); break; case 0xd9: adca_ix2(); break; case 0xda: ora_ix2(); break; case 0xdb: adda_ix2(); break; case 0xdc: jmp_ix2(); break; case 0xdd: jsr_ix2(); break; case 0xde: ldx_ix2(); break; case 0xdf: stx_ix2(); break; case 0xe0: suba_ix1(); break; case 0xe1: cmpa_ix1(); break; case 0xe2: sbca_ix1(); break; case 0xe3: cpx_ix1(); break; case 0xe4: anda_ix1(); break; case 0xe5: bita_ix1(); break; case 0xe6: lda_ix1(); break; case 0xe7: sta_ix1(); break; case 0xe8: eora_ix1(); break; case 0xe9: adca_ix1(); break; case 0xea: ora_ix1(); break; case 0xeb: adda_ix1(); break; case 0xec: jmp_ix1(); break; case 0xed: jsr_ix1(); break; case 0xee: ldx_ix1(); break; case 0xef: stx_ix1(); break; case 0xf0: suba_ix(); break; case 0xf1: cmpa_ix(); break; case 0xf2: sbca_ix(); break; case 0xf3: cpx_ix(); break; case 0xf4: anda_ix(); break; case 0xf5: bita_ix(); break; case 0xf6: lda_ix(); break; case 0xf7: sta_ix(); break; case 0xf8: eora_ix(); break; case 0xf9: adca_ix(); break; case 0xfa: ora_ix(); break; case 0xfb: adda_ix(); break; case 0xfc: jmp_ix(); break; case 0xfd: jsr_ix(); break; case 0xfe: ldx_ix(); break; case 0xff: stx_ix(); break; } m6805_ICount -= cycles1[ireg]; m6805.nTotalCycles += cycles1[ireg]; } while( m6805_ICount > 0 ); return cycles - m6805_ICount; }
int ArmRun( int cycles ) { UINT32 pc; UINT32 insn; arm_icount = cycles; arm.ArmLeftCycles = cycles; do { /* load instruction */ pc = R15; insn = Arm_program_opcode_dword_32le( pc & ADDRESS_MASK ); switch (insn >> INSN_COND_SHIFT) { case COND_EQ: if (Z_IS_CLEAR(pc)) goto L_Next; break; case COND_NE: if (Z_IS_SET(pc)) goto L_Next; break; case COND_CS: if (C_IS_CLEAR(pc)) goto L_Next; break; case COND_CC: if (C_IS_SET(pc)) goto L_Next; break; case COND_MI: if (N_IS_CLEAR(pc)) goto L_Next; break; case COND_PL: if (N_IS_SET(pc)) goto L_Next; break; case COND_VS: if (V_IS_CLEAR(pc)) goto L_Next; break; case COND_VC: if (V_IS_SET(pc)) goto L_Next; break; case COND_HI: if (C_IS_CLEAR(pc) || Z_IS_SET(pc)) goto L_Next; break; case COND_LS: if (C_IS_SET(pc) && Z_IS_CLEAR(pc)) goto L_Next; break; case COND_GE: if (!(pc & N_MASK) != !(pc & V_MASK)) goto L_Next; /* Use x ^ (x >> ...) method */ break; case COND_LT: if (!(pc & N_MASK) == !(pc & V_MASK)) goto L_Next; break; case COND_GT: if (Z_IS_SET(pc) || (!(pc & N_MASK) != !(pc & V_MASK))) goto L_Next; break; case COND_LE: if (Z_IS_CLEAR(pc) && (!(pc & N_MASK) == !(pc & V_MASK))) goto L_Next; break; case COND_NV: goto L_Next; } /* Condition satisfied, so decode the instruction */ if ((insn & 0x0fc000f0u) == 0x00000090u) /* Multiplication */ { HandleMul(insn); R15 += 4; } else if (!(insn & 0x0c000000u)) /* Data processing */ { HandleALU(insn); } else if ((insn & 0x0c000000u) == 0x04000000u) /* Single data access */ { HandleMemSingle(insn); R15 += 4; } else if ((insn & 0x0e000000u) == 0x08000000u ) /* Block data access */ { HandleMemBlock(insn); R15 += 4; } else if ((insn & 0x0e000000u) == 0x0a000000u) /* Branch */ { HandleBranch(insn); } else if ((insn & 0x0f000000u) == 0x0e000000u) /* Coprocessor */ { HandleCoPro(insn); R15 += 4; } else if ((insn & 0x0f000000u) == 0x0f000000u) /* Software interrupt */ { pc=R15+4; R15 = eARM_MODE_SVC; /* Set SVC mode so PC is saved to correct R14 bank */ SetRegister( 14, pc ); /* save PC */ R15 = (pc&PSR_MASK)|(pc&IRQ_MASK)|0x8|eARM_MODE_SVC|I_MASK|(pc&MODE_MASK); change_pc(pc&ADDRESS_MASK); arm_icount -= 2 * S_CYCLE + N_CYCLE; } else /* Undefined */ { L_Next: arm_icount -= S_CYCLE; R15 += 4; } arm_check_irq_state(); } while( arm_icount > 0 ); arm.ArmTotalCycles += (cycles - arm_icount); return cycles - arm_icount; } /* arm_execute */
static void jz(void) { UINT8 i=M_RDMEM_OPCODE(); if (R.A == 0) { R.PC.w.l = ((R.PC.w.l-1) & 0xf00) | i; change_pc(R.PC.w.l); } else ADJUST_CYCLES }
static void ret(void) { R.PC.w.l = ((pull() & 0x0f) << 8); R.PC.w.l |= pull(); change_pc(R.PC.w.l); }
inline void SetRegister( int rIndex, UINT32 value ) { arm.sArmRegister[sRegisterTable[MODE][rIndex]] = value; if (rIndex == eR15) change_pc(value & ADDRESS_MASK); }
/**************************************************************************** * Set program counter ****************************************************************************/ void konami_set_pc(unsigned val) { PC = val; change_pc(PC); }
void sc61860_set_pc (unsigned val) { sc61860.pc = val; change_pc(sc61860.pc); }
static WRITE8_HANDLER( m6509_write_00000 ) { m6509.pc_bank.b.h2=data&0xf; m6509.pc.w.h=m6509.pc_bank.w.h; change_pc(PCD); }
void ppc603_exception(int exception) { switch( exception ) { case EXCEPTION_IRQ: /* External Interrupt */ if( ppc_get_msr() & MSR_EE ) { UINT32 msr = ppc_get_msr(); SRR0 = ppc.npc; SRR1 = msr & 0xff73; msr &= ~(MSR_POW | MSR_EE | MSR_PR | MSR_FP | MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1 | MSR_IR | MSR_DR | MSR_RI); if( msr & MSR_ILE ) msr |= MSR_LE; else msr &= ~MSR_LE; ppc_set_msr(msr); if( msr & MSR_IP ) ppc.npc = 0xfff00000 | 0x0500; else ppc.npc = 0x00000000 | 0x0500; ppc.interrupt_pending &= ~0x1; change_pc(ppc.npc); } break; case EXCEPTION_DECREMENTER: /* Decrementer overflow exception */ if( ppc_get_msr() & MSR_EE ) { UINT32 msr = ppc_get_msr(); SRR0 = ppc.npc; SRR1 = msr & 0xff73; msr &= ~(MSR_POW | MSR_EE | MSR_PR | MSR_FP | MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1 | MSR_IR | MSR_DR | MSR_RI); if( msr & MSR_ILE ) msr |= MSR_LE; else msr &= ~MSR_LE; ppc_set_msr(msr); if( msr & MSR_IP ) ppc.npc = 0xfff00000 | 0x0900; else ppc.npc = 0x00000000 | 0x0900; ppc.interrupt_pending &= ~0x2; change_pc(ppc.npc); } break; case EXCEPTION_TRAP: /* Program exception / Trap */ { UINT32 msr = ppc_get_msr(); SRR0 = ppc.pc; SRR1 = (msr & 0xff73) | 0x20000; /* 0x20000 = TRAP bit */ msr &= ~(MSR_POW | MSR_EE | MSR_PR | MSR_FP | MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1 | MSR_IR | MSR_DR | MSR_RI); if( msr & MSR_ILE ) msr |= MSR_LE; else msr &= ~MSR_LE; ppc_set_msr(msr); if( msr & MSR_IP ) ppc.npc = 0xfff00000 | 0x0700; else ppc.npc = 0x00000000 | 0x0700; change_pc(ppc.npc); } break; case EXCEPTION_SYSTEM_CALL: /* System call */ { UINT32 msr = ppc_get_msr(); SRR0 = ppc.npc; SRR1 = (msr & 0xff73); msr &= ~(MSR_POW | MSR_EE | MSR_PR | MSR_FP | MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1 | MSR_IR | MSR_DR | MSR_RI); if( msr & MSR_ILE ) msr |= MSR_LE; else msr &= ~MSR_LE; ppc_set_msr(msr); if( msr & MSR_IP ) ppc.npc = 0xfff00000 | 0x0c00; else ppc.npc = 0x00000000 | 0x0c00; change_pc(ppc.npc); } break; case EXCEPTION_SMI: if( ppc_get_msr() & MSR_EE ) { UINT32 msr = ppc_get_msr(); SRR0 = ppc.npc; SRR1 = msr & 0xff73; msr &= ~(MSR_POW | MSR_EE | MSR_PR | MSR_FP | MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1 | MSR_IR | MSR_DR | MSR_RI); if( msr & MSR_ILE ) msr |= MSR_LE; else msr &= ~MSR_LE; ppc_set_msr(msr); if( msr & MSR_IP ) ppc.npc = 0xfff00000 | 0x1400; else ppc.npc = 0x00000000 | 0x1400; ppc.interrupt_pending &= ~0x4; change_pc(ppc.npc); } break; case EXCEPTION_DSI: { UINT32 msr = ppc_get_msr(); SRR0 = ppc.npc; SRR1 = msr & 0xff73; msr &= ~(MSR_POW | MSR_EE | MSR_PR | MSR_FP | MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1 | MSR_IR | MSR_DR | MSR_RI); if( msr & MSR_ILE ) msr |= MSR_LE; else msr &= ~MSR_LE; ppc_set_msr(msr); if( msr & MSR_IP ) ppc.npc = 0xfff00000 | 0x0300; else ppc.npc = 0x00000000 | 0x0300; ppc.interrupt_pending &= ~0x4; change_pc(ppc.npc); } break; case EXCEPTION_ISI: { UINT32 msr = ppc_get_msr(); SRR0 = ppc.npc; SRR1 = msr & 0xff73; msr &= ~(MSR_POW | MSR_EE | MSR_PR | MSR_FP | MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1 | MSR_IR | MSR_DR | MSR_RI); if( msr & MSR_ILE ) msr |= MSR_LE; else msr &= ~MSR_LE; ppc_set_msr(msr); if( msr & MSR_IP ) ppc.npc = 0xfff00000 | 0x0400; else ppc.npc = 0x00000000 | 0x0400; ppc.interrupt_pending &= ~0x4; change_pc(ppc.npc); } break; default: fatalerror("ppc: Unhandled exception %d", exception); break; } }
INLINE void saturn_load_pc(int reg) { saturn.pc=S64_READ_A(reg); change_pc(saturn.pc); }
INLINE void saturn_indirect_jump(int reg) { saturn.pc=READ_20(S64_READ_A(reg)); change_pc(saturn.pc); }
INLINE void saturn_return_interrupt(void) { saturn.pc=saturn_pop(); // saturn_ICount-=10; change_pc(saturn.pc); }
void m65ce02_set_pc (unsigned val) { PCW = val; change_pc(PCD); }
/* Generate interrupts */ static void Interrupt(void) { /* the 6805 latches interrupt requests internally, so we don't clear */ /* pending_interrupts until the interrupt is taken, no matter what the */ /* external IRQ pin does. */ #if (HAS_HD63705) if( (m6805.pending_interrupts & (1<<HD63705_INT_NMI)) != 0) { PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); RM16( 0x1ffc, &pPC); change_pc(PC); m6805.pending_interrupts &= ~(1<<HD63705_INT_NMI); m6805_ICount -= 11; } else if( (m6805.pending_interrupts & ((1<<M6805_IRQ_LINE)|HD63705_INT_MASK)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #else if( (m6805.pending_interrupts & (1<<M6805_IRQ_LINE)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #endif { /* standard IRQ */ //#if (HAS_HD63705) // if(SUBTYPE!=SUBTYPE_HD63705) //#endif // PC |= ~AMASK; PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); #if (HAS_HD63705) if(SUBTYPE==SUBTYPE_HD63705) { /* Need to add emulation of other interrupt sources here KW-2/4/99 */ /* This is just a quick patch for Namco System 2 operation */ if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ1); RM16( 0x1ff8, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ2); RM16( 0x1fec, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_ADCONV))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_ADCONV); RM16( 0x1fea, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER1); RM16( 0x1ff6, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER2); RM16( 0x1ff4, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER3))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER3); RM16( 0x1ff2, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_PCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_PCI); RM16( 0x1ff0, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_SCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_SCI); RM16( 0x1fee, &pPC); change_pc(PC); } } else #endif { RM16( 0xffff - 5, &pPC ); change_pc(PC); } } // CC & IFLAG m6805.pending_interrupts &= ~(1<<M6805_IRQ_LINE); } m6805_ICount -= 11; } } static void state_register(const char *type, int index) { state_save_register_item(type, index, A); state_save_register_item(type, index, PC); state_save_register_item(type, index, S); state_save_register_item(type, index, X); state_save_register_item(type, index, CC); state_save_register_item(type, index, m6805.pending_interrupts); state_save_register_item_array(type, index, m6805.irq_state); } static void m6805_init(int index, int clock, const void *config, int (*irqcallback)(int)) { state_register("m6805", index); m6805.irq_callback = irqcallback; }
static int ppc603_execute(int cycles) { int exception_type; UINT32 opcode; ppc_icount = cycles; ppc_tb_base_icount = cycles; ppc_dec_base_icount = cycles + ppc.dec_frac; /* check if decrementer exception occurs during execution */ if ((UINT32)(DEC - ppc_icount) > (UINT32)(DEC)) { ppc_dec_trigger_cycle = ppc_icount - DEC; } else { ppc_dec_trigger_cycle = 0x7fffffff; } change_pc(ppc.npc); #ifdef __GNUC__ /* MinGW's optimizer kills setjmp()/longjmp() */ (void)__builtin_return_address(1); #endif exception_type = setjmp(ppc.exception_jmpbuf); if (exception_type) { ppc.npc = ppc.pc; ppc603_exception(exception_type); } while( ppc_icount > 0 ) { ppc.pc = ppc.npc; CALL_MAME_DEBUG; if (MSR & MSR_IR) opcode = ppc_readop_translated(ppc.pc); else opcode = ROPCODE64(ppc.pc); ppc.npc = ppc.pc + 4; switch(opcode >> 26) { case 19: optable19[(opcode >> 1) & 0x3ff](opcode); break; case 31: optable31[(opcode >> 1) & 0x3ff](opcode); break; case 59: optable59[(opcode >> 1) & 0x3ff](opcode); break; case 63: optable63[(opcode >> 1) & 0x3ff](opcode); break; default: optable[opcode >> 26](opcode); break; } ppc_icount--; if(ppc_icount == ppc_dec_trigger_cycle) { ppc.interrupt_pending |= 0x2; } ppc603_check_interrupts(); } /* update timebase */ /* timebase is incremented once every four core clock cycles, so adjust the cycles accordingly */ ppc.tb += ((ppc_tb_base_icount - ppc_icount) / 4); /* update decrementer */ ppc.dec_frac = ((ppc_dec_base_icount - ppc_icount) % (bus_freq_multiplier * 2)); DEC -= ((ppc_dec_base_icount - ppc_icount) / (bus_freq_multiplier * 2)); return cycles - ppc_icount; }
void m6509_set_pc (unsigned val) { PCW = val&0xffff; change_pc(PCD); }
void s2650_set_pc(unsigned val) { S.page = val & PAGE; S.iar = val & PMSK; change_pc(S.page + S.iar); }
static void jt_1(void) { UINT8 i=M_RDMEM_OPCODE(); if (test_r(1)) { R.PC.w.l = ((R.PC.w.l-1) & 0xf00) | i; change_pc(R.PC.w.l); } else ADJUST_CYCLES }
/* Generate interrupts */ static void Interrupt(void) { /* the 6805 latches interrupt requests internally, so we don't clear */ /* pending_interrupts until the interrupt is taken, no matter what the */ /* external IRQ pin does. */ #if (HAS_HD63705) if( (m6805.pending_interrupts & (1<<HD63705_INT_NMI)) != 0) { PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); RM16( 0x1ffc, &pPC); change_pc(PC); m6805.pending_interrupts &= ~(1<<HD63705_INT_NMI); m6805_ICount -= 11; } else if( (m6805.pending_interrupts & ((1<<M6805_IRQ_LINE)|HD63705_INT_MASK)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #else if( (m6805.pending_interrupts & (1<<M6805_IRQ_LINE)) != 0 ) { if ( (CC & IFLAG) == 0 ) { #endif { /* standard IRQ */ /*#if (HAS_HD63705) */ /* if(SUBTYPE!=SUBTYPE_HD63705) */ /*#endif */ /* PC |= ~AMASK; */ PUSHWORD(m6805.pc); PUSHBYTE(m6805.x); PUSHBYTE(m6805.a); PUSHBYTE(m6805.cc); SEI; /* no vectors supported, just do the callback to clear irq_state if needed */ if (m6805.irq_callback) (*m6805.irq_callback)(0); #if (HAS_HD63705) if(SUBTYPE==SUBTYPE_HD63705) { /* Need to add emulation of other interrupt sources here KW-2/4/99 */ /* This is just a quick patch for Namco System 2 operation */ if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ1); RM16( 0x1ff8, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_IRQ2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_IRQ2); RM16( 0x1fec, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_ADCONV))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_ADCONV); RM16( 0x1fea, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER1))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER1); RM16( 0x1ff6, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER2))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER2); RM16( 0x1ff4, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_TIMER3))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_TIMER3); RM16( 0x1ff2, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_PCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_PCI); RM16( 0x1ff0, &pPC); change_pc(PC); } else if((m6805.pending_interrupts&(1<<HD63705_INT_SCI))!=0) { m6805.pending_interrupts &= ~(1<<HD63705_INT_SCI); RM16( 0x1fee, &pPC); change_pc(PC); } } else #endif { RM16( 0xffff - 5, &pPC ); change_pc(PC); } } /* CC & IFLAG */ m6805.pending_interrupts &= ~(1<<M6805_IRQ_LINE); } m6805_ICount -= 11; } } static void state_register(const char *type) { int cpu = cpu_getactivecpu(); state_save_register_UINT8(type, cpu, "A", &A, 1); state_save_register_UINT16(type, cpu, "PC", &PC, 1); state_save_register_UINT16(type, cpu, "S", &S, 1); state_save_register_UINT8(type, cpu, "X", &X, 1); state_save_register_UINT8(type, cpu, "CC", &CC, 1); state_save_register_UINT16(type, cpu, "PENDING", &m6805.pending_interrupts, 1); state_save_register_INT32(type, cpu, "IRQ_STATE", &m6805.irq_state[0], 1); } static void m6805_init(void) { state_register("m6805"); }
static void jtf(void) { UINT8 i=M_RDMEM_OPCODE(); if (R.t_flag) { R.PC.w.l = ((R.PC.w.l-1) & 0xf00) | i; change_pc(R.PC.w.l); R.t_flag = 0; } else ADJUST_CYCLES }
INLINE void CHANGE_PC(UINT16 new_pc) { tms.pc = new_pc; change_pc(tms.pc << 1); }
static void saturn_reset(void) { saturn.stackpointer=0; saturn.pc=0; change_pc(saturn.pc); }