summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Michael Zapf <Michael.Zapf@mizapf.de>2019-03-21 00:54:18 +0100
committer Michael Zapf <Michael.Zapf@mizapf.de>2019-03-21 00:54:18 +0100
commita91062c565d1dde5fe0828ac70c7ba30deb47f8b (patch)
tree6e16bfa9e1a223941062c1f8eb6f46cf232e40ba
parent528858986214518abb276ac2f7a5a989b3ed79d0 (diff)
tms99xx: Fixed handling of C and OV status bits for INV and SLA instructions.
-rw-r--r--src/devices/cpu/tms9900/tms9900.cpp8
-rw-r--r--src/devices/cpu/tms9900/tms9995.cpp8
2 files changed, 12 insertions, 4 deletions
diff --git a/src/devices/cpu/tms9900/tms9900.cpp b/src/devices/cpu/tms9900/tms9900.cpp
index d1576197247..840fd5d631a 100644
--- a/src/devices/cpu/tms9900/tms9900.cpp
+++ b/src/devices/cpu/tms9900/tms9900.cpp
@@ -2167,6 +2167,7 @@ void tms99xx_device::alu_clr_swpb()
bool setstatus = true;
bool check_ov = true;
+ bool check_c = true;
switch (m_command)
{
@@ -2184,6 +2185,7 @@ void tms99xx_device::alu_clr_swpb()
// LAE
dest_new = ~src_val & 0xffff;
check_ov = false;
+ check_c = false;
break;
case NEG:
// LAECO
@@ -2226,7 +2228,7 @@ void tms99xx_device::alu_clr_swpb()
if (setstatus)
{
if (check_ov) set_status_bit(ST_OV, ((src_val & 0x8000)==sign) && ((dest_new & 0x8000)!=sign));
- set_status_bit(ST_C, (dest_new & 0x10000) != 0);
+ if (check_c) set_status_bit(ST_C, (dest_new & 0x10000) != 0);
m_current_value = dest_new & 0xffff;
compare_and_set_lae(m_current_value, 0);
}
@@ -2518,6 +2520,7 @@ void tms99xx_device::alu_shift()
uint16_t sign = 0;
uint32_t value;
int count;
+ bool check_ov = false;
switch (m_state)
{
@@ -2575,6 +2578,7 @@ void tms99xx_device::alu_shift()
case SLA:
carry = ((value & 0x8000)!=0);
value <<= 1;
+ check_ov = true;
if (carry != ((value&0x8000)!=0)) overflow = true;
break;
case SRC:
@@ -2587,7 +2591,7 @@ void tms99xx_device::alu_shift()
m_current_value = value & 0xffff;
set_status_bit(ST_C, carry);
- set_status_bit(ST_OV, overflow);
+ if (check_ov) set_status_bit(ST_OV, overflow); // only SLA
compare_and_set_lae(m_current_value, 0);
m_address = m_address_saved; // Register address
if (TRACE_STATUS) logerror("ST = %04x (val=%04x)\n", ST, m_current_value);
diff --git a/src/devices/cpu/tms9900/tms9995.cpp b/src/devices/cpu/tms9900/tms9995.cpp
index c52a6c5cc39..09509f4623e 100644
--- a/src/devices/cpu/tms9900/tms9995.cpp
+++ b/src/devices/cpu/tms9900/tms9995.cpp
@@ -3090,6 +3090,7 @@ void tms9995_device::alu_shift()
uint16_t sign = 0;
uint32_t value;
int count;
+ bool check_ov = false;
switch (m_inst_state)
{
@@ -3138,6 +3139,7 @@ void tms9995_device::alu_shift()
case SLA:
carry = ((value & 0x8000)!=0);
value <<= 1;
+ check_ov = true;
if (carry != ((value&0x8000)!=0)) overflow = true;
break;
case SRC:
@@ -3150,7 +3152,7 @@ void tms9995_device::alu_shift()
m_current_value = value & 0xffff;
set_status_bit(ST_C, carry);
- set_status_bit(ST_OV, overflow);
+ if (check_ov) set_status_bit(ST_OV, overflow); // only SLA
compare_and_set_lae(m_current_value, 0);
m_address = m_address_saved; // Register address
LOGMASKED(LOG_STATUS, "ST = %04x (val=%04x)\n", ST, m_current_value);
@@ -3168,6 +3170,7 @@ void tms9995_device::alu_single_arithm()
uint32_t src_val = m_current_value & 0x0000ffff;
uint16_t sign = 0;
bool check_ov = true;
+ bool check_c = true;
switch (m_command)
{
@@ -3218,6 +3221,7 @@ void tms9995_device::alu_single_arithm()
// LAE
dest_new = ~src_val & 0xffff;
check_ov = false;
+ check_c = false;
break;
case NEG:
// LAECO
@@ -3245,7 +3249,7 @@ void tms9995_device::alu_single_arithm()
}
if (check_ov) set_status_bit(ST_OV, ((src_val & 0x8000)==sign) && ((dest_new & 0x8000)!=sign));
- set_status_bit(ST_C, (dest_new & 0x10000) != 0);
+ if (check_c) set_status_bit(ST_C, (dest_new & 0x10000) != 0);
m_current_value = dest_new & 0xffff;
compare_and_set_lae(m_current_value, 0);