summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/m68000/m68k_in.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/m68000/m68k_in.cpp')
-rw-r--r--src/devices/cpu/m68000/m68k_in.cpp214
1 files changed, 66 insertions, 148 deletions
diff --git a/src/devices/cpu/m68000/m68k_in.cpp b/src/devices/cpu/m68000/m68k_in.cpp
index 8e5e621d19d..e1cfa6e7346 100644
--- a/src/devices/cpu/m68000/m68k_in.cpp
+++ b/src/devices/cpu/m68000/m68k_in.cpp
@@ -3588,26 +3588,19 @@ M68KMAKE_OP(chk2cmp2, 8, ., pcdi)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15]&0xff;
+ int32_t compare = REG_DA()[(word2 >> 12) & 15] & 0xff;
+ if(!BIT_F(word2))
+ compare = (int32_t)(int8_t)compare;
+
uint32_t ea = EA_PCDI_8();
- uint32_t lower_bound = m68ki_read_pcrel_8(ea);
- uint32_t upper_bound = m68ki_read_pcrel_8(ea + 1);
+ int32_t lower_bound = (int32_t)(int8_t)m68ki_read_pcrel_8(ea);
+ int32_t upper_bound = (int32_t)(int8_t)m68ki_read_pcrel_8(ea + 1);
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound);
- else
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- m_c_flag = upper_bound - compare;
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3619,26 +3612,19 @@ M68KMAKE_OP(chk2cmp2, 8, ., pcix)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15]&0xff;
+ int32_t compare = REG_DA()[(word2 >> 12) & 15] & 0xff;
+ if(!BIT_F(word2))
+ compare = (int32_t)(int8_t)compare;
+
uint32_t ea = EA_PCIX_8();
- uint32_t lower_bound = m68ki_read_pcrel_8(ea);
- uint32_t upper_bound = m68ki_read_pcrel_8(ea + 1);
+ int32_t lower_bound = (int32_t)(int8_t)m68ki_read_pcrel_8(ea);
+ int32_t upper_bound = (int32_t)(int8_t)m68ki_read_pcrel_8(ea + 1);
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound);
- else
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- m_c_flag = upper_bound - compare;
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3650,26 +3636,19 @@ M68KMAKE_OP(chk2cmp2, 8, ., .)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15]&0xff;
+ int32_t compare = REG_DA()[(word2 >> 12) & 15] & 0xff;
+ if(!BIT_F(word2))
+ compare = (int32_t)(int8_t)compare;
+
uint32_t ea = M68KMAKE_GET_EA_AY_8;
- uint32_t lower_bound = m68ki_read_8(ea);
- uint32_t upper_bound = m68ki_read_8(ea + 1);
+ int32_t lower_bound = (int32_t)(int8_t)m68ki_read_8(ea);
+ int32_t upper_bound = (int32_t)(int8_t)m68ki_read_8(ea + 1);
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound);
- else
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- m_c_flag = upper_bound - compare;
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3681,31 +3660,19 @@ M68KMAKE_OP(chk2cmp2, 16, ., pcdi)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15]&0xffff;
+ int32_t compare = REG_DA()[(word2 >> 12) & 15] & 0xffff;
+ if(!BIT_F(word2))
+ compare = (int32_t)(int16_t)compare;
+
uint32_t ea = EA_PCDI_16();
- uint32_t lower_bound = m68ki_read_pcrel_16(ea);
- uint32_t upper_bound = m68ki_read_pcrel_16(ea + 2);
+ int32_t lower_bound = (int32_t)(int16_t)m68ki_read_pcrel_16(ea);
+ int32_t upper_bound = (int32_t)(int16_t)m68ki_read_pcrel_16(ea + 2);
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound);
- else
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- m_c_flag = CFLAG_16(m_c_flag);
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare);
- else
- m_c_flag = upper_bound - compare;
- m_c_flag = CFLAG_16(m_c_flag);
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3717,31 +3684,19 @@ M68KMAKE_OP(chk2cmp2, 16, ., pcix)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15]&0xffff;
+ int32_t compare = REG_DA()[(word2 >> 12) & 15] & 0xffff;
+ if(!BIT_F(word2))
+ compare = (int32_t)(int16_t)compare;
+
uint32_t ea = EA_PCIX_16();
- uint32_t lower_bound = m68ki_read_pcrel_16(ea);
- uint32_t upper_bound = m68ki_read_pcrel_16(ea + 2);
+ int32_t lower_bound = (int32_t)(int16_t)m68ki_read_pcrel_16(ea);
+ int32_t upper_bound = (int32_t)(int16_t)m68ki_read_pcrel_16(ea + 2);
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound);
- else
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- m_c_flag = CFLAG_16(m_c_flag);
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare);
- else
- m_c_flag = upper_bound - compare;
- m_c_flag = CFLAG_16(m_c_flag);
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3753,32 +3708,19 @@ M68KMAKE_OP(chk2cmp2, 16, ., .)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15]&0xffff;
- uint32_t ea = M68KMAKE_GET_EA_AY_16;
- uint32_t lower_bound = m68ki_read_16(ea);
- uint32_t upper_bound = m68ki_read_16(ea + 2);
-
+ int32_t compare = REG_DA()[(word2 >> 12) & 15] & 0xffff;
if(!BIT_F(word2))
- m_c_flag = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound);
- else
- m_c_flag = compare - lower_bound;
+ compare = (int32_t)(int16_t)compare;
+
+ uint32_t ea = M68KMAKE_GET_EA_AY_16;
+ int32_t lower_bound = (int32_t)(int16_t)m68ki_read_16(ea);
+ int32_t upper_bound = (int32_t)(int16_t)m68ki_read_16(ea + 2);
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- m_c_flag = CFLAG_16(m_c_flag);
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
- if(!BIT_F(word2))
- m_c_flag = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare);
- else
- m_c_flag = upper_bound - compare;
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- m_c_flag = CFLAG_16(m_c_flag);
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3790,25 +3732,17 @@ M68KMAKE_OP(chk2cmp2, 32, ., pcdi)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15];
+ int32_t compare = (int32_t)REG_DA()[(word2 >> 12) & 15];
+
uint32_t ea = EA_PCDI_32();
- uint32_t lower_bound = m68ki_read_pcrel_32(ea);
- uint32_t upper_bound = m68ki_read_pcrel_32(ea + 4);
+ int32_t lower_bound = (int32_t)m68ki_read_pcrel_32(ea);
+ int32_t upper_bound = (int32_t)m68ki_read_pcrel_32(ea + 4);
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- m_c_flag = CFLAG_SUB_32(lower_bound, compare, m_c_flag);
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- m_c_flag = upper_bound - compare;
- m_c_flag = CFLAG_SUB_32(compare, upper_bound, m_c_flag);
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3820,25 +3754,17 @@ M68KMAKE_OP(chk2cmp2, 32, ., pcix)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15];
+ int32_t compare = (int32_t)REG_DA()[(word2 >> 12) & 15];
+
uint32_t ea = EA_PCIX_32();
- uint32_t lower_bound = m68ki_read_pcrel_32(ea);
- uint32_t upper_bound = m68ki_read_pcrel_32(ea + 4);
+ int32_t lower_bound = (int32_t)m68ki_read_pcrel_32(ea);
+ int32_t upper_bound = (int32_t)m68ki_read_pcrel_32(ea + 4);
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- m_c_flag = CFLAG_SUB_32(lower_bound, compare, m_c_flag);
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- m_c_flag = upper_bound - compare;
- m_c_flag = CFLAG_SUB_32(compare, upper_bound, m_c_flag);
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();
@@ -3850,25 +3776,17 @@ M68KMAKE_OP(chk2cmp2, 32, ., .)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- uint32_t compare = REG_DA()[(word2 >> 12) & 15];
+ int32_t compare = (int32_t)REG_DA()[(word2 >> 12) & 15];
+
uint32_t ea = M68KMAKE_GET_EA_AY_32;
- uint32_t lower_bound = m68ki_read_32(ea);
- uint32_t upper_bound = m68ki_read_32(ea + 4);
+ int32_t lower_bound = (int32_t)m68ki_read_32(ea);
+ int32_t upper_bound = (int32_t)m68ki_read_32(ea + 4);
- m_c_flag = compare - lower_bound;
m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
- m_c_flag = CFLAG_SUB_32(lower_bound, compare, m_c_flag);
- if(COND_CS())
- {
- if(BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
- return;
- }
+ m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
- m_c_flag = upper_bound - compare;
- m_c_flag = CFLAG_SUB_32(compare, upper_bound, m_c_flag);
if(COND_CS() && BIT_B(word2))
- m68ki_exception_trap(EXCEPTION_CHK);
+ m68ki_exception_trap(EXCEPTION_CHK);
return;
}
m68ki_exception_illegal();