Comment 9 for bug 579320

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

- 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;
 }