← Back to team overview

gnusim8085-devel team mailing list archive

[Bug 579320] Re: CMP flags not working like SUB with signed numbers

 

- Log -----------------------------------------------------------------
commit 45667ab9b4b1e11954396226ae8aedf38b874829
Author: Aanjhan Ranganathan <aanjhan@yoda.(none)>
Date:   Mon Oct 11 17:46:43 2010 +0200

   Fixes CMP instruction bug #579320. Patch from Debjit Biswas
   added. Removed my changes done previously for fixing this bug. See
   ChangeLog for details.

diff --git a/src/8085-instructions.c b/src/8085-instructions.c
index 8811cc5..57f7d80 100644
--- a/src/8085-instructions.c
+++ b/src/8085-instructions.c
@@ -502,16 +502,12 @@ _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)
 {
-
-  /* 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;
-  else if (sys.reg.a > data)
-    sys.flag.c = 0, sys.flag.z = 0;
-  else
-    sys.flag.c = 0, sys.flag.z = 1;
+  /* Patch from Debjit Biswas for CMP bug #579320 */
+  eef_data_t a = sys.reg.a;
+  _eef_flag_check_and_set_c (sys.reg.a, data, '-');
+  _eef_flag_check_and_set_aux_c (sys.reg.a, data, '-');
+  a += -1 * data;
+ _eef_find_and_set_flags (a);
  return 0;
 }


** Changed in: gnusim8085
       Status: In Progress => Fix Committed

-- 
CMP flags not working like SUB with signed numbers
https://bugs.launchpad.net/bugs/579320
You received this bug notification because you are a member of
GNUSim8085 developers, which is subscribed to gnusim8085.

Status in gnusim8085: Fix Committed

Bug description:
MVI A,001h
MVI B,0FEh
CMP B
SUB B

flags after CMP not the same as SUB.