summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2018-10-26 15:37:21 +0200
committer hap <happppp@users.noreply.github.com>2018-10-26 15:37:33 +0200
commit6525cd6c42ffb96a92dabc848e309c6cb96209ae (patch)
tree696ae2019eb4d367c1cb5578d47dc6292c1945e2
parent2b8ab63d08941963d87831b0f82413039039b4a6 (diff)
m68k chk2cmp2: fix oversight on prev commit for unsigned compare (nw)
-rw-r--r--src/devices/cpu/m68000/m68k_in.cpp156
1 files changed, 105 insertions, 51 deletions
diff --git a/src/devices/cpu/m68000/m68k_in.cpp b/src/devices/cpu/m68000/m68k_in.cpp
index e1cfa6e7346..a0d1db557f2 100644
--- a/src/devices/cpu/m68000/m68k_in.cpp
+++ b/src/devices/cpu/m68000/m68k_in.cpp
@@ -3589,15 +3589,21 @@ M68KMAKE_OP(chk2cmp2, 8, ., pcdi)
{
uint32_t word2 = OPER_I_16();
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();
- 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);
+ int32_t lower_bound = m68ki_read_pcrel_8(ea);
+ int32_t upper_bound = m68ki_read_pcrel_8(ea + 1);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int32_t)(int8_t)lower_bound;
+ upper_bound = (int32_t)(int8_t)upper_bound;
+
+ if(!BIT_F(word2))
+ compare = (int32_t)(int8_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3613,15 +3619,21 @@ M68KMAKE_OP(chk2cmp2, 8, ., pcix)
{
uint32_t word2 = OPER_I_16();
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();
- 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);
+ int32_t lower_bound = m68ki_read_pcrel_8(ea);
+ int32_t upper_bound = m68ki_read_pcrel_8(ea + 1);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int32_t)(int8_t)lower_bound;
+ upper_bound = (int32_t)(int8_t)upper_bound;
+
+ if(!BIT_F(word2))
+ compare = (int32_t)(int8_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3637,15 +3649,21 @@ M68KMAKE_OP(chk2cmp2, 8, ., .)
{
uint32_t word2 = OPER_I_16();
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;
- 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);
+ int32_t lower_bound = m68ki_read_8(ea);
+ int32_t upper_bound = m68ki_read_8(ea + 1);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int32_t)(int8_t)lower_bound;
+ upper_bound = (int32_t)(int8_t)upper_bound;
+
+ if(!BIT_F(word2))
+ compare = (int32_t)(int8_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3661,15 +3679,21 @@ M68KMAKE_OP(chk2cmp2, 16, ., pcdi)
{
uint32_t word2 = OPER_I_16();
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();
- 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);
+ int32_t lower_bound = m68ki_read_pcrel_16(ea);
+ int32_t upper_bound = m68ki_read_pcrel_16(ea + 2);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int32_t)(int16_t)lower_bound;
+ upper_bound = (int32_t)(int16_t)upper_bound;
+
+ if(!BIT_F(word2))
+ compare = (int32_t)(int16_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3685,15 +3709,21 @@ M68KMAKE_OP(chk2cmp2, 16, ., pcix)
{
uint32_t word2 = OPER_I_16();
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();
- 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);
+ int32_t lower_bound = m68ki_read_pcrel_16(ea);
+ int32_t upper_bound = m68ki_read_pcrel_16(ea + 2);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int32_t)(int16_t)lower_bound;
+ upper_bound = (int32_t)(int16_t)upper_bound;
+
+ if(!BIT_F(word2))
+ compare = (int32_t)(int16_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3709,15 +3739,21 @@ M68KMAKE_OP(chk2cmp2, 16, ., .)
{
uint32_t word2 = OPER_I_16();
int32_t compare = REG_DA()[(word2 >> 12) & 15] & 0xffff;
- if(!BIT_F(word2))
- 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);
+ int32_t lower_bound = m68ki_read_16(ea);
+ int32_t upper_bound = m68ki_read_16(ea + 2);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int32_t)(int16_t)lower_bound;
+ upper_bound = (int32_t)(int16_t)upper_bound;
+
+ if(!BIT_F(word2))
+ compare = (int32_t)(int16_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3732,14 +3768,20 @@ M68KMAKE_OP(chk2cmp2, 32, ., pcdi)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- int32_t compare = (int32_t)REG_DA()[(word2 >> 12) & 15];
-
+ int64_t compare = REG_DA()[(word2 >> 12) & 15];
uint32_t ea = EA_PCDI_32();
- int32_t lower_bound = (int32_t)m68ki_read_pcrel_32(ea);
- int32_t upper_bound = (int32_t)m68ki_read_pcrel_32(ea + 4);
+ int64_t lower_bound = m68ki_read_pcrel_32(ea);
+ int64_t upper_bound = m68ki_read_pcrel_32(ea + 4);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int64_t)(int32_t)lower_bound;
+ upper_bound = (int64_t)(int32_t)upper_bound;
+ compare = (int64_t)(int32_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3754,14 +3796,20 @@ M68KMAKE_OP(chk2cmp2, 32, ., pcix)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- int32_t compare = (int32_t)REG_DA()[(word2 >> 12) & 15];
-
+ int64_t compare = REG_DA()[(word2 >> 12) & 15];
uint32_t ea = EA_PCIX_32();
- int32_t lower_bound = (int32_t)m68ki_read_pcrel_32(ea);
- int32_t upper_bound = (int32_t)m68ki_read_pcrel_32(ea + 4);
+ int64_t lower_bound = m68ki_read_pcrel_32(ea);
+ int64_t upper_bound = m68ki_read_pcrel_32(ea + 4);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int64_t)(int32_t)lower_bound;
+ upper_bound = (int64_t)(int32_t)upper_bound;
+ compare = (int64_t)(int32_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);
@@ -3776,14 +3824,20 @@ M68KMAKE_OP(chk2cmp2, 32, ., .)
if(CPU_TYPE_IS_EC020_PLUS())
{
uint32_t word2 = OPER_I_16();
- int32_t compare = (int32_t)REG_DA()[(word2 >> 12) & 15];
-
+ int64_t compare = REG_DA()[(word2 >> 12) & 15];
uint32_t ea = M68KMAKE_GET_EA_AY_32;
- int32_t lower_bound = (int32_t)m68ki_read_32(ea);
- int32_t upper_bound = (int32_t)m68ki_read_32(ea + 4);
+ int64_t lower_bound = m68ki_read_32(ea);
+ int64_t upper_bound = m68ki_read_32(ea + 4);
+
+ if (lower_bound > upper_bound)
+ {
+ lower_bound = (int64_t)(int32_t)lower_bound;
+ upper_bound = (int64_t)(int32_t)upper_bound;
+ compare = (int64_t)(int32_t)compare;
+ }
- m_not_z_flag = !((upper_bound==compare) | (lower_bound==compare));
m_c_flag = (compare >= lower_bound && compare <= upper_bound) ? CFLAG_CLEAR : CFLAG_SET;
+ m_not_z_flag = ((upper_bound == compare) || (lower_bound == compare)) ? 0 : 1;
if(COND_CS() && BIT_B(word2))
m68ki_exception_trap(EXCEPTION_CHK);