summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ricardo Barreira <rbarreira@gmail.com>2017-11-23 00:45:54 +0000
committer Ricardo Barreira <rbarreira@gmail.com>2017-11-23 00:45:54 +0000
commit3fd99bb3bbc160c7436d5bed7a66c34b46cd93b8 (patch)
treec9326d3b651b7c5ad861a75e6e92d63c1de92390
parent631e01d984c935f859245e842f859bc2b9e411d2 (diff)
hcd62121: Fixed some silly mistakes in CL flag calculations.
-rw-r--r--src/devices/cpu/hcd62121/hcd62121.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/devices/cpu/hcd62121/hcd62121.cpp b/src/devices/cpu/hcd62121/hcd62121.cpp
index 79b101e6cf3..2c42e7881f6 100644
--- a/src/devices/cpu/hcd62121/hcd62121.cpp
+++ b/src/devices/cpu/hcd62121/hcd62121.cpp
@@ -701,10 +701,12 @@ inline void hcd62121_cpu_device::op_addb(int size)
bool zero_low = true;
u8 carry = 0;
- set_cl_flag((m_temp1[size-1] & 0x0f) + (m_temp2[size-1] & 0x0f) > 9);
-
for (int i = 0; i < size; i++)
{
+ if (i == size - 1) {
+ set_cl_flag((m_temp1[i] & 0x0f) + (m_temp2[i] & 0x0f) + carry > 9);
+ }
+
int num1 = (m_temp1[i] & 0x0f) + ((m_temp1[i] & 0xf0) >> 4) * 10;
int num2 = (m_temp2[i] & 0x0f) + ((m_temp2[i] & 0xf0) >> 4) * 10;
@@ -734,10 +736,12 @@ inline void hcd62121_cpu_device::op_subb(int size)
bool zero_low = true;
u8 carry = 0;
- set_cl_flag((m_temp1[size-1] & 0x0f) < (m_temp2[size-1] & 0x0f));
-
for (int i = 0; i < size; i++)
{
+ if (i == size - 1) {
+ set_cl_flag((m_temp1[i] & 0x0f) - (m_temp2[i] & 0x0f) - carry < 0);
+ }
+
int num1 = (m_temp1[i] & 0x0f) + ((m_temp1[i] & 0xf0) >> 4) * 10;
int num2 = (m_temp2[i] & 0x0f) + ((m_temp2[i] & 0xf0) >> 4) * 10;
@@ -766,8 +770,6 @@ inline void hcd62121_cpu_device::op_sub(int size)
bool zero_low = true;
u8 carry = 0;
- set_cl_flag((m_temp1[0] & 0x0f) < (m_temp2[0] & 0x0f));
-
for (int i = 0; i < size; i++)
{
if (i == size - 1) {