mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-08-14 03:25:45 +00:00
Finally: a working daa
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
@@ -320,25 +320,23 @@ void EightBit::LR35902::set(int n, uint8_t& operand) {
|
|||||||
|
|
||||||
void EightBit::LR35902::daa(uint8_t& a, uint8_t& f) {
|
void EightBit::LR35902::daa(uint8_t& a, uint8_t& f) {
|
||||||
|
|
||||||
auto updated = a;
|
int updated = a;
|
||||||
|
|
||||||
auto lowAdjust = (f & HC) | (lowNibble(a) > 9);
|
|
||||||
auto highAdjust = (f & CF) | (a > 0x99);
|
|
||||||
|
|
||||||
if (f & NF) {
|
if (f & NF) {
|
||||||
if (lowAdjust)
|
if (f & HC)
|
||||||
updated -= 6;
|
updated = (updated - 6) & Mask8;
|
||||||
if (highAdjust)
|
if (f & CF)
|
||||||
updated -= 0x60;
|
updated -= 0x60;
|
||||||
} else {
|
} else {
|
||||||
if (lowAdjust)
|
if ((f & HC) || lowNibble(updated) > 9)
|
||||||
updated += 6;
|
updated += 6;
|
||||||
if (highAdjust)
|
if ((f & CF) || updated > 0x9F)
|
||||||
updated += 0x60;
|
updated += 0x60;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = (f & (CF | NF)) | (a > 0x99) | ((a ^ updated) & HC);
|
clearFlag(f, HC | ZF);
|
||||||
a = updated;
|
setFlag(f, CF, (f & CF) || (updated & Bit8));
|
||||||
|
a = updated & Mask8;
|
||||||
|
|
||||||
adjustZero<LR35902>(f, a);
|
adjustZero<LR35902>(f, a);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user