← Back to team overview

gnusim8085-devel team mailing list archive

[Bug 745461] Re: Flags not set properly after DAA

 

I believe the below code, which is part of the DAA instruction code is
the reason for this bug:

  if (sys.reg.a > 0x99 || sys.flag.c)
  {
    sys.reg.a = sys.reg.a + 0x60;
    sys.flag.c = 1;
  }

After this operation there are no statements to modify the flags. When
this condition is not activated the function _eef_inst_func_add_i is
called which in turn calls the _eef_find_and_set_flags function and thus
there is no issues.

It should have been something like this:

  if (sys.reg.a > 0x99 || sys.flag.c)
  {
    sys.reg.a = sys.reg.a + 0x60;
    sys.flag.c = 1;
    _eef_find_and_set_flags (sys.reg.a);
  }

-- 
You received this bug notification because you are a member of
GNUSim8085 developers, which is subscribed to gnusim8085.
https://bugs.launchpad.net/bugs/745461

Title:
  Flags not set properly after DAA

Status in gnusim8085:
  New

Bug description:
  Flags are not being set properly after DAA. Consider the following code:
  MVI A, 099H
  ADI 01H
  DAA
  after this, the result should be 00 with carry set, which it is. However, the sign flag is set and Zero flag is cleared. It should be the other way round. The bug is perhaps caused by setting these flag before doing the final DAA adjustments, when the result was 9A, which would set the sign flag and clear the Z flag. After correction, the result is 00, so sign flag should be cleared, while the Z flag should be set.



References