mirror of
https://github.com/holub/mame
synced 2025-04-24 09:20:02 +03:00
- m6805.c: Modernized M6805 CPU core. [MooglyGuy]
This commit is contained in:
parent
13d9f05bab
commit
fc6ff102b1
@ -13,9 +13,10 @@ HNZC
|
||||
|
||||
*/
|
||||
|
||||
#define OP_HANDLER(_name) INLINE void _name (m6805_Regs* cpustate)
|
||||
#define OP_HANDLER(_name) void m6805_base_device::_name()
|
||||
#define DERIVED_OP_HANDLER(_arch,_name) void _arch##_device::_name()
|
||||
|
||||
#define OP_HANDLER_BIT(_name) INLINE void _name (m6805_Regs* cpustate, UINT8 bit)
|
||||
#define OP_HANDLER_BIT(_name) void m6805_base_device::_name(UINT8 bit)
|
||||
|
||||
OP_HANDLER( illegal )
|
||||
{
|
||||
@ -158,27 +159,23 @@ OP_HANDLER( bms )
|
||||
/* $2e BIL relative ---- */
|
||||
OP_HANDLER( bil )
|
||||
{
|
||||
if(SUBTYPE==SUBTYPE_HD63705)
|
||||
{
|
||||
BRANCH( cpustate->nmi_state!=CLEAR_LINE );
|
||||
}
|
||||
else
|
||||
{
|
||||
BRANCH( cpustate->irq_state[0]!=CLEAR_LINE );
|
||||
}
|
||||
BRANCH(m_irq_state[0] != CLEAR_LINE);
|
||||
}
|
||||
|
||||
DERIVED_OP_HANDLER( hd63705, bil )
|
||||
{
|
||||
BRANCH(m_nmi_state != CLEAR_LINE);
|
||||
}
|
||||
|
||||
/* $2f BIH relative ---- */
|
||||
OP_HANDLER( bih )
|
||||
{
|
||||
if(SUBTYPE==SUBTYPE_HD63705)
|
||||
{
|
||||
BRANCH( cpustate->nmi_state==CLEAR_LINE );
|
||||
}
|
||||
else
|
||||
{
|
||||
BRANCH( cpustate->irq_state[0]==CLEAR_LINE );
|
||||
}
|
||||
BRANCH(m_irq_state[0] == CLEAR_LINE);
|
||||
}
|
||||
|
||||
DERIVED_OP_HANDLER( hd63705, bih )
|
||||
{
|
||||
BRANCH(m_nmi_state == CLEAR_LINE);
|
||||
}
|
||||
|
||||
/* $30 NEG direct -*** */
|
||||
@ -789,17 +786,19 @@ OP_HANDLER( rti )
|
||||
PULLBYTE(CC);
|
||||
PULLBYTE(A);
|
||||
PULLBYTE(X);
|
||||
PULLWORD(pPC);
|
||||
PULLWORD(m_pc);
|
||||
#if IRQ_LEVEL_DETECT
|
||||
if( m6805.irq_state != CLEAR_LINE && (CC & IFLAG) == 0 )
|
||||
m6805.pending_interrupts |= M6805_INT_IRQ;
|
||||
if( m_irq_state != CLEAR_LINE && (CC & IFLAG) == 0 )
|
||||
{
|
||||
m_pending_interrupts |= M6805_INT_IRQ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* $81 RTS inherent ---- */
|
||||
OP_HANDLER( rts )
|
||||
{
|
||||
PULLWORD(pPC);
|
||||
PULLWORD(m_pc);
|
||||
}
|
||||
|
||||
/* $82 ILLEGAL */
|
||||
@ -807,14 +806,23 @@ OP_HANDLER( rts )
|
||||
/* $83 SWI absolute indirect ---- */
|
||||
OP_HANDLER( swi )
|
||||
{
|
||||
PUSHWORD(cpustate->pc);
|
||||
PUSHBYTE(cpustate->x);
|
||||
PUSHBYTE(cpustate->a);
|
||||
PUSHBYTE(cpustate->cc);
|
||||
PUSHWORD(m_pc);
|
||||
PUSHBYTE(m_x);
|
||||
PUSHBYTE(m_a);
|
||||
PUSHBYTE(m_cc);
|
||||
SEI;
|
||||
if(SUBTYPE==SUBTYPE_HD63705) RM16( cpustate, 0x1ffa, &pPC ); else RM16( cpustate, 0xfffc, &pPC );
|
||||
RM16(0xfffc, &m_pc);
|
||||
}
|
||||
|
||||
DERIVED_OP_HANDLER( hd63705, swi )
|
||||
{
|
||||
PUSHWORD(m_pc);
|
||||
PUSHBYTE(m_x);
|
||||
PUSHBYTE(m_a);
|
||||
PUSHBYTE(m_cc);
|
||||
SEI;
|
||||
RM16(0x1ffa, &m_pc);
|
||||
}
|
||||
/* $84 ILLEGAL */
|
||||
|
||||
/* $85 ILLEGAL */
|
||||
@ -1009,7 +1017,7 @@ OP_HANDLER( bsr )
|
||||
{
|
||||
UINT8 t;
|
||||
IMMBYTE(t);
|
||||
PUSHWORD(cpustate->pc);
|
||||
PUSHWORD(m_pc);
|
||||
PC += SIGNED(t);
|
||||
}
|
||||
|
||||
@ -1157,7 +1165,7 @@ OP_HANDLER( jmp_di )
|
||||
OP_HANDLER( jsr_di )
|
||||
{
|
||||
DIRECT;
|
||||
PUSHWORD(cpustate->pc);
|
||||
PUSHWORD(m_pc);
|
||||
PC = EA;
|
||||
}
|
||||
|
||||
@ -1312,7 +1320,7 @@ OP_HANDLER( jmp_ex )
|
||||
OP_HANDLER( jsr_ex )
|
||||
{
|
||||
EXTENDED;
|
||||
PUSHWORD(cpustate->pc);
|
||||
PUSHWORD(m_pc);
|
||||
PC = EA;
|
||||
}
|
||||
|
||||
@ -1467,7 +1475,7 @@ OP_HANDLER( jmp_ix2 )
|
||||
OP_HANDLER( jsr_ix2 )
|
||||
{
|
||||
INDEXED2;
|
||||
PUSHWORD(cpustate->pc);
|
||||
PUSHWORD(m_pc);
|
||||
PC = EA;
|
||||
}
|
||||
|
||||
@ -1622,7 +1630,7 @@ OP_HANDLER( jmp_ix1 )
|
||||
OP_HANDLER( jsr_ix1 )
|
||||
{
|
||||
INDEXED1;
|
||||
PUSHWORD(cpustate->pc);
|
||||
PUSHWORD(m_pc);
|
||||
PC = EA;
|
||||
}
|
||||
|
||||
@ -1777,7 +1785,7 @@ OP_HANDLER( jmp_ix )
|
||||
OP_HANDLER( jsr_ix )
|
||||
{
|
||||
INDEXED;
|
||||
PUSHWORD(cpustate->pc);
|
||||
PUSHWORD(m_pc);
|
||||
PC = EA;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,13 +5,363 @@
|
||||
#ifndef __M6805_H__
|
||||
#define __M6805_H__
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
class m6805_device;
|
||||
|
||||
// device type definition
|
||||
extern const device_type M6805;
|
||||
extern const device_type M68HC05EG;
|
||||
extern const device_type M68705;
|
||||
extern const device_type HD63705;
|
||||
|
||||
// ======================> m6805_base_device
|
||||
|
||||
// Used by core CPU interface
|
||||
class m6805_base_device : public cpu_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
m6805_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, const device_type type, const char *name, UINT32 addr_width);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
// device_execute_interface overrides
|
||||
virtual UINT32 execute_min_cycles() const;
|
||||
virtual UINT32 execute_max_cycles() const;
|
||||
virtual UINT32 execute_input_lines() const;
|
||||
virtual void execute_run();
|
||||
virtual void execute_set_input(int inputnum, int state) = 0;
|
||||
virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const;
|
||||
virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const;
|
||||
|
||||
// device_memory_interface overrides
|
||||
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
|
||||
|
||||
// device_disasm_interface overrides
|
||||
virtual UINT32 disasm_min_opcode_bytes() const;
|
||||
virtual UINT32 disasm_max_opcode_bytes() const;
|
||||
virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
|
||||
|
||||
// device_state_interface overrides
|
||||
virtual void state_string_export(const device_state_entry &entry, astring &string);
|
||||
|
||||
private:
|
||||
// opcode/condition tables
|
||||
static const UINT8 m_flags8i[256];
|
||||
static const UINT8 m_flags8d[256];
|
||||
static const UINT8 m_cycles1[256];
|
||||
|
||||
protected:
|
||||
void rd_s_handler_b(UINT8 *b);
|
||||
void rd_s_handler_w(PAIR *p);
|
||||
void wr_s_handler_b(UINT8 *b);
|
||||
void wr_s_handler_w(PAIR *p);
|
||||
void RM16(UINT32 addr, PAIR *p);
|
||||
|
||||
void brset(UINT8 bit);
|
||||
void brclr(UINT8 bit);
|
||||
void bset(UINT8 bit);
|
||||
void bclr(UINT8 bit);
|
||||
|
||||
void bra();
|
||||
void brn();
|
||||
void bhi();
|
||||
void bls();
|
||||
void bcc();
|
||||
void bcs();
|
||||
void bne();
|
||||
void beq();
|
||||
void bhcc();
|
||||
void bhcs();
|
||||
void bpl();
|
||||
void bmi();
|
||||
void bmc();
|
||||
void bms();
|
||||
virtual void bil();
|
||||
virtual void bih();
|
||||
void bsr();
|
||||
|
||||
void neg_di();
|
||||
void com_di();
|
||||
void lsr_di();
|
||||
void ror_di();
|
||||
void asr_di();
|
||||
void lsl_di();
|
||||
void rol_di();
|
||||
void dec_di();
|
||||
void inc_di();
|
||||
void tst_di();
|
||||
void clr_di();
|
||||
|
||||
void nega();
|
||||
void coma();
|
||||
void lsra();
|
||||
void rora();
|
||||
void asra();
|
||||
void lsla();
|
||||
void rola();
|
||||
void deca();
|
||||
void inca();
|
||||
void tsta();
|
||||
void clra();
|
||||
|
||||
void negx();
|
||||
void comx();
|
||||
void lsrx();
|
||||
void rorx();
|
||||
void asrx();
|
||||
void aslx();
|
||||
void lslx();
|
||||
void rolx();
|
||||
void decx();
|
||||
void incx();
|
||||
void tstx();
|
||||
void clrx();
|
||||
|
||||
void neg_ix1();
|
||||
void com_ix1();
|
||||
void lsr_ix1();
|
||||
void ror_ix1();
|
||||
void asr_ix1();
|
||||
void lsl_ix1();
|
||||
void rol_ix1();
|
||||
void dec_ix1();
|
||||
void inc_ix1();
|
||||
void tst_ix1();
|
||||
void clr_ix1();
|
||||
|
||||
void neg_ix();
|
||||
void com_ix();
|
||||
void lsr_ix();
|
||||
void ror_ix();
|
||||
void asr_ix();
|
||||
void lsl_ix();
|
||||
void rol_ix();
|
||||
void dec_ix();
|
||||
void inc_ix();
|
||||
void tst_ix();
|
||||
void clr_ix();
|
||||
|
||||
void rti();
|
||||
void rts();
|
||||
virtual void swi();
|
||||
|
||||
void tax();
|
||||
void txa();
|
||||
|
||||
void rsp();
|
||||
void nop();
|
||||
|
||||
void suba_im();
|
||||
void cmpa_im();
|
||||
void sbca_im();
|
||||
void cpx_im();
|
||||
void anda_im();
|
||||
void bita_im();
|
||||
void lda_im();
|
||||
void eora_im();
|
||||
void adca_im();
|
||||
void ora_im();
|
||||
void adda_im();
|
||||
|
||||
void ldx_im();
|
||||
void suba_di();
|
||||
void cmpa_di();
|
||||
void sbca_di();
|
||||
void cpx_di();
|
||||
void anda_di();
|
||||
void bita_di();
|
||||
void lda_di();
|
||||
void sta_di();
|
||||
void eora_di();
|
||||
void adca_di();
|
||||
void ora_di();
|
||||
void adda_di();
|
||||
void jmp_di();
|
||||
void jsr_di();
|
||||
void ldx_di();
|
||||
void stx_di();
|
||||
void suba_ex();
|
||||
void cmpa_ex();
|
||||
void sbca_ex();
|
||||
void cpx_ex();
|
||||
void anda_ex();
|
||||
void bita_ex();
|
||||
void lda_ex();
|
||||
void sta_ex();
|
||||
void eora_ex();
|
||||
void adca_ex();
|
||||
void ora_ex();
|
||||
void adda_ex();
|
||||
void jmp_ex();
|
||||
void jsr_ex();
|
||||
void ldx_ex();
|
||||
void stx_ex();
|
||||
void suba_ix2();
|
||||
void cmpa_ix2();
|
||||
void sbca_ix2();
|
||||
void cpx_ix2();
|
||||
void anda_ix2();
|
||||
void bita_ix2();
|
||||
void lda_ix2();
|
||||
void sta_ix2();
|
||||
void eora_ix2();
|
||||
void adca_ix2();
|
||||
void ora_ix2();
|
||||
void adda_ix2();
|
||||
void jmp_ix2();
|
||||
void jsr_ix2();
|
||||
void ldx_ix2();
|
||||
void stx_ix2();
|
||||
void suba_ix1();
|
||||
void cmpa_ix1();
|
||||
void sbca_ix1();
|
||||
void cpx_ix1();
|
||||
void anda_ix1();
|
||||
void bita_ix1();
|
||||
void lda_ix1();
|
||||
void sta_ix1();
|
||||
void eora_ix1();
|
||||
void adca_ix1();
|
||||
void ora_ix1();
|
||||
void adda_ix1();
|
||||
void jmp_ix1();
|
||||
void jsr_ix1();
|
||||
void ldx_ix1();
|
||||
void stx_ix1();
|
||||
void suba_ix();
|
||||
void cmpa_ix();
|
||||
void sbca_ix();
|
||||
void cpx_ix();
|
||||
void anda_ix();
|
||||
void bita_ix();
|
||||
void lda_ix();
|
||||
void sta_ix();
|
||||
void eora_ix();
|
||||
void adca_ix();
|
||||
void ora_ix();
|
||||
void adda_ix();
|
||||
void jmp_ix();
|
||||
void jsr_ix();
|
||||
void ldx_ix();
|
||||
void stx_ix();
|
||||
|
||||
void illegal();
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void interrupt_vector();
|
||||
|
||||
const char *m_tag;
|
||||
|
||||
// address spaces
|
||||
const address_space_config m_program_config;
|
||||
|
||||
// CPU registers
|
||||
PAIR m_ea; /* effective address */
|
||||
|
||||
UINT32 m_sp_mask; /* Stack pointer address mask */
|
||||
UINT32 m_sp_low; /* Stack pointer low water mark (or floor) */
|
||||
PAIR m_pc; /* Program counter */
|
||||
PAIR m_s; /* Stack pointer */
|
||||
UINT8 m_a; /* Accumulator */
|
||||
UINT8 m_x; /* Index register */
|
||||
UINT8 m_cc; /* Condition codes */
|
||||
|
||||
UINT16 m_pending_interrupts; /* MB */
|
||||
|
||||
int m_irq_state[9]; /* KW Additional lines for HD63705 */
|
||||
int m_nmi_state;
|
||||
|
||||
// other internal states
|
||||
int m_icount;
|
||||
|
||||
// address spaces
|
||||
address_space *m_program;
|
||||
direct_read_data *m_direct;
|
||||
};
|
||||
|
||||
// ======================> m6805_device
|
||||
|
||||
class m6805_device : public m6805_base_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
m6805_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: m6805_base_device(mconfig, tag, owner, clock, M6805, "M6805", 12) { }
|
||||
|
||||
protected:
|
||||
virtual void execute_set_input(int inputnum, int state);
|
||||
};
|
||||
|
||||
// ======================> m68hc05eg_device
|
||||
|
||||
class m68hc05eg_device : public m6805_base_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
m68hc05eg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: m6805_base_device(mconfig, tag, owner, clock, M68HC05EG, "M68HC05EG", 13) { }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_reset();
|
||||
|
||||
virtual void execute_set_input(int inputnum, int state);
|
||||
|
||||
virtual void interrupt_vector();
|
||||
};
|
||||
|
||||
// ======================> m68705_device
|
||||
|
||||
class m68705_device : public m6805_base_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
m68705_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: m6805_base_device(mconfig, tag, owner, clock, M68705, "M68705", 12) { }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_reset();
|
||||
|
||||
virtual void execute_set_input(int inputnum, int state);
|
||||
|
||||
virtual void interrupt();
|
||||
};
|
||||
|
||||
// ======================> hd63705_device
|
||||
|
||||
class hd63705_device : public m6805_base_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
hd63705_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: m6805_base_device(mconfig, tag, owner, clock, HD63705, "HD63705", 16) { }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_reset();
|
||||
|
||||
virtual void execute_set_input(int inputnum, int state);
|
||||
|
||||
virtual void interrupt_vector();
|
||||
|
||||
// opcodes
|
||||
virtual void bil();
|
||||
virtual void bih();
|
||||
virtual void swi();
|
||||
};
|
||||
|
||||
enum { M6805_PC=1, M6805_S, M6805_CC, M6805_A, M6805_X, M6805_IRQ_STATE };
|
||||
|
||||
#define M6805_IRQ_LINE 0
|
||||
|
||||
DECLARE_LEGACY_CPU_DEVICE(M6805, m6805);
|
||||
|
||||
/****************************************************************************
|
||||
* 68HC05EG section
|
||||
****************************************************************************/
|
||||
@ -20,11 +370,10 @@ DECLARE_LEGACY_CPU_DEVICE(M6805, m6805);
|
||||
#define M68HC05EG_INT_TIMER (M6805_IRQ_LINE+1)
|
||||
#define M68HC05EG_INT_CPI (M6805_IRQ_LINE+2)
|
||||
|
||||
DECLARE_LEGACY_CPU_DEVICE(M68HC05EG, m68hc05eg);
|
||||
|
||||
/****************************************************************************
|
||||
* 68705 section
|
||||
****************************************************************************/
|
||||
|
||||
#define M68705_A M6805_A
|
||||
#define M68705_PC M6805_PC
|
||||
#define M68705_S M6805_S
|
||||
@ -36,11 +385,10 @@ DECLARE_LEGACY_CPU_DEVICE(M68HC05EG, m68hc05eg);
|
||||
#define M68705_IRQ_LINE M6805_IRQ_LINE
|
||||
#define M68705_INT_TIMER 0x01
|
||||
|
||||
DECLARE_LEGACY_CPU_DEVICE(M68705, m68705);
|
||||
|
||||
/****************************************************************************
|
||||
* HD63705 section
|
||||
****************************************************************************/
|
||||
|
||||
#define HD63705_A M6805_A
|
||||
#define HD63705_PC M6805_PC
|
||||
#define HD63705_S M6805_S
|
||||
@ -63,8 +411,6 @@ DECLARE_LEGACY_CPU_DEVICE(M68705, m68705);
|
||||
#define HD63705_INT_ADCONV 0x07
|
||||
#define HD63705_INT_NMI 0x08
|
||||
|
||||
DECLARE_LEGACY_CPU_DEVICE(HD63705, hd63705);
|
||||
|
||||
CPU_DISASSEMBLE( m6805 );
|
||||
|
||||
#endif /* __M6805_H__ */
|
||||
|
@ -30,7 +30,7 @@ struct m6809_config
|
||||
extern const device_type M6809;
|
||||
extern const device_type M6809E;
|
||||
|
||||
// ======================> m6809_device
|
||||
// ======================> m6809_base_device
|
||||
|
||||
// Used by core CPU interface
|
||||
class m6809_base_device : public cpu_device,
|
||||
@ -114,8 +114,6 @@ protected:
|
||||
|
||||
int m_extra_cycles; /* cycles used up by interrupts */
|
||||
|
||||
device_irq_acknowledge_callback m_irq_callback;
|
||||
|
||||
PAIR m_ea; /* effective address */
|
||||
|
||||
// other internal states
|
||||
|
Loading…
Reference in New Issue
Block a user