Flags not set properly after DAA
Bug #745461 reported by
Dinesh Sharma
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gnusim8085 |
New
|
Undecided
|
Unassigned |
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.
To post a comment you must log in.
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) find_and_ set_flags (sys.reg.a);
{
sys.reg.a = sys.reg.a + 0x60;
sys.flag.c = 1;
_eef_
}