diff options
author | 2011-07-26 09:57:41 +0000 | |
---|---|---|
committer | 2011-07-26 09:57:41 +0000 | |
commit | cf4ff0407ba64d4ea323df92391e40039272f4b5 (patch) | |
tree | 527a6fbb3ab3aef26f31a9c4348e0b9c0abbe579 | |
parent | 2ecf7ec6addc68d70c38934bc0e4d9358dd0e488 (diff) |
m68k: Generate a per-cpu-type jump table. Correct linef handling
makes the atari st less cranky. [O. Galibert]
-rw-r--r-- | src/emu/cpu/m68000/m68k_in.c | 61 | ||||
-rw-r--r-- | src/emu/cpu/m68000/m68kcpu.c | 14 | ||||
-rw-r--r-- | src/emu/cpu/m68000/m68kcpu.h | 1 | ||||
-rw-r--r-- | src/emu/cpu/m68000/m68kmake.c | 2 |
4 files changed, 36 insertions, 42 deletions
diff --git a/src/emu/cpu/m68000/m68k_in.c b/src/emu/cpu/m68000/m68k_in.c index 7cce71fc383..7722fe475a8 100644 --- a/src/emu/cpu/m68000/m68k_in.c +++ b/src/emu/cpu/m68000/m68k_in.c @@ -104,7 +104,7 @@ M68KMAKE_PROTOTYPE_FOOTER /* Build the opcode handler table */ void m68ki_build_opcode_table(void); -extern void (*m68ki_instruction_jump_table[0x10000])(m68ki_cpu_core *m68k); /* opcode handler jump table */ +extern void (*m68ki_instruction_jump_table[][0x10000])(m68ki_cpu_core *m68k); /* opcode handler jump table */ extern unsigned char m68ki_cycles[][0x10000]; @@ -127,7 +127,7 @@ M68KMAKE_TABLE_HEADER #define NUM_CPU_TYPES 5 -void (*m68ki_instruction_jump_table[0x10000])(m68ki_cpu_core *m68k); /* opcode handler jump table */ +void (*m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000])(m68ki_cpu_core *m68k); /* opcode handler jump table */ unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */ /* This is used to generate the opcode handler jump table */ @@ -155,10 +155,19 @@ M68KMAKE_TABLE_FOOTER /* Build the opcode handler jump table */ + +static void m68ki_set_one(unsigned short opcode, const opcode_handler_struct *s) +{ + for(int i=0; i<NUM_CPU_TYPES; i++) + if(s->cycles[i] != 0xff) { + m68ki_cycles[i][opcode] = s->cycles[i]; + m68ki_instruction_jump_table[i][opcode] = s->opcode_handler; + } +} + void m68ki_build_opcode_table(void) { const opcode_handler_struct *ostruct; - int instr; int i; int j; int k; @@ -166,9 +175,11 @@ void m68ki_build_opcode_table(void) for(i = 0; i < 0x10000; i++) { /* default to illegal */ - m68ki_instruction_jump_table[i] = m68k_op_illegal; for(k=0;k<NUM_CPU_TYPES;k++) + { + m68ki_instruction_jump_table[k][i] = m68k_op_illegal; m68ki_cycles[k][i] = 0; + } } ostruct = m68k_opcode_handler_table; @@ -177,22 +188,14 @@ void m68ki_build_opcode_table(void) for(i = 0;i < 0x10000;i++) { if((i & ostruct->mask) == ostruct->match) - { - m68ki_instruction_jump_table[i] = ostruct->opcode_handler; - for(k=0;k<NUM_CPU_TYPES;k++) - m68ki_cycles[k][i] = ostruct->cycles[k]; - } + m68ki_set_one(i, ostruct); } ostruct++; } while(ostruct->mask == 0xff00) { for(i = 0;i <= 0xff;i++) - { - m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; - for(k=0;k<NUM_CPU_TYPES;k++) - m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k]; - } + m68ki_set_one(ostruct->match | i, ostruct); ostruct++; } while(ostruct->mask == 0xf1f8) @@ -200,50 +203,31 @@ void m68ki_build_opcode_table(void) for(i = 0;i < 8;i++) { for(j = 0;j < 8;j++) - { - instr = ostruct->match | (i << 9) | j; - m68ki_instruction_jump_table[instr] = ostruct->opcode_handler; - for(k=0;k<NUM_CPU_TYPES;k++) - m68ki_cycles[k][instr] = ostruct->cycles[k]; - } + m68ki_set_one(ostruct->match | (i << 9) | j, ostruct); } ostruct++; } while(ostruct->mask == 0xfff0) { for(i = 0;i <= 0x0f;i++) - { - m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; - for(k=0;k<NUM_CPU_TYPES;k++) - m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k]; - } + m68ki_set_one(ostruct->match | i, ostruct); ostruct++; } while(ostruct->mask == 0xf1ff) { for(i = 0;i <= 0x07;i++) - { - m68ki_instruction_jump_table[ostruct->match | (i << 9)] = ostruct->opcode_handler; - for(k=0;k<NUM_CPU_TYPES;k++) - m68ki_cycles[k][ostruct->match | (i << 9)] = ostruct->cycles[k]; - } + m68ki_set_one(ostruct->match | (i << 9), ostruct); ostruct++; } while(ostruct->mask == 0xfff8) { for(i = 0;i <= 0x07;i++) - { - m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; - for(k=0;k<NUM_CPU_TYPES;k++) - m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k]; - } + m68ki_set_one(ostruct->match | i, ostruct); ostruct++; } while(ostruct->mask == 0xffff) { - m68ki_instruction_jump_table[ostruct->match] = ostruct->opcode_handler; - for(k=0;k<NUM_CPU_TYPES;k++) - m68ki_cycles[k][ostruct->match] = ostruct->cycles[k]; + m68ki_set_one(ostruct->match, ostruct); ostruct++; } } @@ -7216,7 +7200,6 @@ M68KMAKE_OP(move16, 32, ., .) UINT16 w2 = OPER_I_16(m68k); int ax = m68k->ir & 7; int ay = (w2 >> 12) & 7; - m68ki_write_32(m68k, REG_A[ay], m68ki_read_32(m68k, REG_A[ax])); m68ki_write_32(m68k, REG_A[ay]+4, m68ki_read_32(m68k, REG_A[ax]+4)); m68ki_write_32(m68k, REG_A[ay]+8, m68ki_read_32(m68k, REG_A[ax]+8)); diff --git a/src/emu/cpu/m68000/m68kcpu.c b/src/emu/cpu/m68000/m68kcpu.c index c368b2f1dc9..4d21789dda7 100644 --- a/src/emu/cpu/m68000/m68kcpu.c +++ b/src/emu/cpu/m68000/m68kcpu.c @@ -667,7 +667,7 @@ static CPU_EXECUTE( m68k ) { /* Read an instruction and call its handler */ m68k->ir = m68ki_read_imm_16(m68k); - m68ki_instruction_jump_table[m68k->ir](m68k); + m68k->jump_table[m68k->ir](m68k); m68k->remaining_cycles -= m68k->cyc_instruction[m68k->ir]; } else @@ -688,7 +688,7 @@ static CPU_EXECUTE( m68k ) if (!m68k->mmu_tmp_buserror_occurred) { - m68ki_instruction_jump_table[m68k->ir](m68k); + m68k->jump_table[m68k->ir](m68k); m68k->remaining_cycles -= m68k->cyc_instruction[m68k->ir]; } @@ -1624,6 +1624,7 @@ static CPU_INIT( m68000 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init16(*m68k->program); m68k->sr_mask = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[0]; m68k->cyc_instruction = m68ki_cycles[0]; m68k->cyc_exception = m68ki_exception_cycle_table[0]; m68k->cyc_bcc_notake_b = -2; @@ -1675,6 +1676,7 @@ static CPU_INIT( m68008 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init8(*m68k->program); m68k->sr_mask = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[0]; m68k->cyc_instruction = m68ki_cycles[0]; m68k->cyc_exception = m68ki_exception_cycle_table[0]; m68k->cyc_bcc_notake_b = -2; @@ -1729,6 +1731,7 @@ static CPU_INIT( m68010 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init16(*m68k->program); m68k->sr_mask = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[1]; m68k->cyc_instruction = m68ki_cycles[1]; m68k->cyc_exception = m68ki_exception_cycle_table[1]; m68k->cyc_bcc_notake_b = -4; @@ -1779,6 +1782,7 @@ static CPU_INIT( m68020 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init32(*m68k->program); m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[2]; m68k->cyc_instruction = m68ki_cycles[2]; m68k->cyc_exception = m68ki_exception_cycle_table[2]; m68k->cyc_bcc_notake_b = -2; @@ -1896,6 +1900,7 @@ static CPU_INIT( m68ec020 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init32(*m68k->program); m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[2]; m68k->cyc_instruction = m68ki_cycles[2]; m68k->cyc_exception = m68ki_exception_cycle_table[2]; m68k->cyc_bcc_notake_b = -2; @@ -1948,6 +1953,7 @@ static CPU_INIT( m68030 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init32mmu(*m68k->program); m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[3]; m68k->cyc_instruction = m68ki_cycles[3]; m68k->cyc_exception = m68ki_exception_cycle_table[3]; m68k->cyc_bcc_notake_b = -2; @@ -2006,6 +2012,7 @@ static CPU_INIT( m68ec030 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init32(*m68k->program); m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[3]; m68k->cyc_instruction = m68ki_cycles[3]; m68k->cyc_exception = m68ki_exception_cycle_table[3]; m68k->cyc_bcc_notake_b = -2; @@ -2055,6 +2062,7 @@ static CPU_INIT( m68040 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init32mmu(*m68k->program); m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[4]; m68k->cyc_instruction = m68ki_cycles[4]; m68k->cyc_exception = m68ki_exception_cycle_table[4]; m68k->cyc_bcc_notake_b = -2; @@ -2112,6 +2120,7 @@ static CPU_INIT( m68ec040 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init32(*m68k->program); m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[4]; m68k->cyc_instruction = m68ki_cycles[4]; m68k->cyc_exception = m68ki_exception_cycle_table[4]; m68k->cyc_bcc_notake_b = -2; @@ -2161,6 +2170,7 @@ static CPU_INIT( m68lc040 ) new(&m68k->memory) m68k_memory_interface; m68k->memory.init32mmu(*m68k->program); m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ + m68k->jump_table = m68ki_instruction_jump_table[4]; m68k->cyc_instruction = m68ki_cycles[4]; m68k->cyc_exception = m68ki_exception_cycle_table[4]; m68k->cyc_bcc_notake_b = -2; diff --git a/src/emu/cpu/m68000/m68kcpu.h b/src/emu/cpu/m68000/m68kcpu.h index 3a91823bd6f..3190a6409cf 100644 --- a/src/emu/cpu/m68000/m68kcpu.h +++ b/src/emu/cpu/m68000/m68kcpu.h @@ -669,6 +669,7 @@ struct _m68ki_cpu_core UINT32 virq_state; UINT32 nmi_pending; + void (**jump_table)(m68ki_cpu_core *m68k); const UINT8* cyc_instruction; const UINT8* cyc_exception; diff --git a/src/emu/cpu/m68000/m68kmake.c b/src/emu/cpu/m68000/m68kmake.c index 72268ac5d54..d8c6fb3ec9c 100644 --- a/src/emu/cpu/m68000/m68kmake.c +++ b/src/emu/cpu/m68000/m68kmake.c @@ -622,7 +622,7 @@ static int get_oper_cycles(opcode_struct* op, int ea_mode, int cpu_type) int size = g_size_select_table[op->size]; if(op->cpus[cpu_type] == '.') - return 0; + return 255; if(cpu_type < CPU_TYPE_020) { |