Comment 5 for bug 579320

Revision history for this message
Aanjhan Ranganathan (aanjhan) wrote :

- Log -----------------------------------------------------------------
commit 5d0aafb931d03d7487accdb0d2d331e105a8d68b
Author: Aanjhan Ranganathan <email address hidden>
Date: Fri Sep 24 23:16:30 2010 +0200

   Fixes bug LP: #579320. See change log file for details.

diff --git a/ChangeLog b/ChangeLog
index 7681e26..6c5783b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-09-24 Aanjhan Ranganathan <email address hidden>

+ * src/8085-instructions.c: CMP instruction should not check and
+ set S, P and AC flags as there is no result that is computed. It
+ affects only C and Z flags. Hence removed most code in that
+ function. Fixes bug LP: #579320.
+
       * src/8085-instructions.c: Fixed the long standing DAA
       bug. Followed http://www.ray.masmcode.com/BCDdaa.html plus had to
       ensure the addition operation on the accumulator must be done
diff --git a/src/8085-instructions.c b/src/8085-instructions.c
index 4c5c042..157e0ad 100644
--- a/src/8085-instructions.c
+++ b/src/8085-instructions.c
@@ -502,19 +502,16 @@ _eef_inst_func_xra (eef_addr_t opnd_addr, gchar sec)
 static gint
 _eef_inst_func_cmp_i (eef_addr_t opnd_addr, eef_data_t data)
 {
- _eef_find_and_set_flags (sys.reg.a);
-
- sys.flag.s = (sys.reg.a < data);
-
- _eef_flag_check_and_set_aux_c (sys.reg.a, data, '-');

+ /* Since this is just comparison, there is no "result"
+ that affects the S, P and AC flags is present. Hence
+ no need to check and set flags */
  if (sys.reg.a < data)
- sys.flag.c = 1, sys.flag.z = 0;
+ sys.flag.c = 1, sys.flag.z = 0;
  else if (sys.reg.a > data)
- sys.flag.c = 0, sys.flag.z = 0;
+ sys.flag.c = 0, sys.flag.z = 0;
  else
- sys.flag.c = 0, sys.flag.z = 1;
-
+ sys.flag.c = 0, sys.flag.z = 1;
  return 0;
 }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog | 5 +++++
 src/8085-instructions.c | 15 ++++++---------
 2 files changed, 11 insertions(+), 9 deletions(-)