m6805: don't decrement 0 cycles for illegal opcodes

This commit is contained in:
hap 2024-12-12 19:47:28 +01:00
parent 8931792bb8
commit 191705f261
4 changed files with 57 additions and 53 deletions

View File

@ -245,9 +245,9 @@ const u8 m6800_cpu_device::flags8d[256]= /* decrement */
/* include the opcode functions */
#include "6800ops.hxx"
/* Note: don't use 0 cycles here for invalid opcodes so that we don't */
/* hang in an infinite loop if we hit one */
#define XX 4 // invalid opcode unknown cc
// to prevent the possibility of MAME locking up, don't use 0 cycles here
#define XX 4 // illegal opcode unknown cycle count
const u8 m6800_cpu_device::cycles_6800[256] =
{
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
@ -289,7 +289,8 @@ const u8 m6800_cpu_device::cycles_nsc8105[256] =
/*E*/ 5, 5, 5,XX, 5, 5, 5, 6, 5, 5, 5, 5, 5, 6,XX, 7,
/*F*/ 4, 4, 4,XX, 4, 4, 4, 5, 4, 4, 4, 4, 4, 5,XX, 6
};
#undef XX // /invalid opcode unknown cc
#undef XX // /illegal opcode unknown cc
const m6800_cpu_device::op_func m6800_cpu_device::m6800_insn[0x100] = {

View File

@ -130,9 +130,9 @@ enum
#define TSR_ICF1 0x40
#define TSR_ICF2 0x80
/* Note: don't use 0 cycles here for invalid opcodes so that we don't */
/* hang in an infinite loop if we hit one */
#define XX 4 // invalid opcode unknown cc
// to prevent the possibility of MAME locking up, don't use 0 cycles here
#define XX 4 // illegal opcode unknown cycle count
const u8 m6801_cpu_device::cycles_6803[256] =
{
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
@ -174,7 +174,8 @@ const u8 m6801_cpu_device::cycles_63701[256] =
/*E*/ 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
/*F*/ 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5
};
#undef XX // /invalid opcode unknown cc
#undef XX // /illegal opcode unknown cc
const m6800_cpu_device::op_func m6801_cpu_device::m6803_insn[0x100] = {

View File

@ -5,6 +5,7 @@
Hitachi HD6305 series
TODO:
- HD6305xx has a 14-bit address space, not 13 (memory_access in m6805.h)
- add unimplemented opcodes: STOP, WAIT, DAA, and HD63705Z0 also has MUL
- add HD6305Y2 peripherals (nothing to test it with?)
- add HD63705Z0 peripherals

View File

@ -242,20 +242,23 @@ const m6805_base_device::op_handler_table m6805_base_device::s_hc_b_ops =
#undef big
// to prevent the possibility of MAME locking up, don't use 0 cycles here
#define XX 4 // illegal opcode unknown cycle count
const m6805_base_device::cycle_count_table m6805_base_device::s_hmos_cycles =
{
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
/*0*/ 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
/*1*/ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
/*2*/ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
/*3*/ 6, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 0, 6, 6, 0, 6,
/*4*/ 4, 0, 0, 4, 4, 0, 4, 4, 4, 4, 4, 0, 4, 4, 0, 4,
/*5*/ 4, 0, 0, 4, 4, 0, 4, 4, 4, 4, 4, 0, 4, 4, 0, 4,
/*6*/ 7, 0, 0, 7, 7, 0, 7, 7, 7, 7, 7, 0, 7, 7, 0, 7,
/*7*/ 6, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 0, 6, 6, 0, 6,
/*8*/ 9, 6, 0,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*9*/ 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2,
/*A*/ 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 8, 2, 0,
/*3*/ 6,XX,XX, 6, 6,XX, 6, 6, 6, 6, 6,XX, 6, 6,XX, 6,
/*4*/ 4,XX,XX, 4, 4,XX, 4, 4, 4, 4, 4,XX, 4, 4,XX, 4,
/*5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XX, 6, 5,XX, 6,
/*7*/ 5,XX,XX, 5, 5,XX, 5, 5, 5, 5, 5,XX, 5, 4,XX, 5,
/*8*/ 9, 6,XX,11,XX,XX,XX,XX,XX,XX,XX,XX,XX, 2, 4, 4,
/*9*/ XX,XX,XX,XX,XX,XX,XX, 2, 1, 1, 2, 2, 2, 1,XX, 2,
/*A*/ 2, 2, 2, 2, 2, 2, 2,XX, 2, 2, 2, 2,XX, 6, 2,XX,
/*B*/ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 6, 3, 3,
/*C*/ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 7, 4, 4,
/*D*/ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 7, 5, 5,
@ -347,6 +350,8 @@ const m6805_base_device::cycle_count_table m6805_base_device::s_hd63705_cycles =
/*F*/ 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 2, 6, 3, 4
};
#undef XX // /illegal opcode unknown cc
//-------------------------------------------------
// m6809_base_device - constructor
@ -391,11 +396,7 @@ void m6805_base_device::device_start()
space(AS_PROGRAM).specific(m_program13);
}
// get the minimum not including the zero placeholders for illegal instructions
m_min_cycles = *std::min_element(
std::begin(m_params.m_cycles),
std::end(m_params.m_cycles),
[] (u8 x, u8 y) { return u8(x - 1) < u8(y - 1); });
m_min_cycles = *std::min_element(std::begin(m_params.m_cycles), std::end(m_params.m_cycles));
m_max_cycles = *std::max_element(std::begin(m_params.m_cycles), std::end(m_params.m_cycles));
// set our instruction counter