icepir8
Moderator
The code looks correct.
I hope that makes sense to you. If this is not happening then look for a type in the code you are compiling.
btw I think there may be a problem with clearing the carry flag during the opperation.
Hey icepir8
I may be missing something, but I think aprentice's code is still not doing right. Just look at this case, being all flags clear and A=0x0A. According to the table you posted, "numer added to byte" should be 0x06, but for aprentice's code,
Code:void op0x27() //DAA { if(regF&0x40) //Negative Flag Set { if((regA&0x0F)>0x09 || regF&0x20) { regA-=0x06; //Half borrow: (0-1) = (0xF-0x6) = 9 if((regA&0xF0)==0xF0) regF|=0x10; else regF&=~0x10; } if((regA&0xF0)>0x90 || regF&0x10) regA-=0x60; } else { if((regA&0x0F)>9 || regF&0x20) // regA&0x0F == 0x0A so this is true { regA+=0x06; //Half carry: (9+1) = (0xA+0x6) = 10 // regA == 0x10 now if((regA&0xF0)==0) regF|=0x10; else regF&=~0x10; // regA & 0xF0 == 0x10 now so false and carry flag is cleared. } if((regA&0xF0)>0x90 || regF&0x10) regA+=0x60; // both conditions false so do not add 0x60 to regA. } if(regA==0) regF|=0x80; else regF&=~0x80; }
it turns to be 0x66. The problem I see on his code is that flags are being updated while results are still being computed. As far as I understand the opcode, flags should be updated after the amount to be added/substracted has been dedided.
Just wanted to know what you think about that.
By the way, I've got absolutely nothing against aprenticeI'm just testing his code cause it seems several of you are using it in your emus.
Thanks again.
S.
I hope that makes sense to you. If this is not happening then look for a type in the code you are compiling.
btw I think there may be a problem with clearing the carry flag during the opperation.