??? 01/10/08 15:18 Read: times |
#149224 - DAA Misunderstanding |
Last night, I was working on my Verilog 8051 model, and from the description in the "bible", I was having trouble understanding exactly how the DA A (Decimal-adjust Accumulator for Addition) instruction is supposed to work. So I decided I would just try it, and I found that my SiLabs C8051F120 doesn't seem to behave anywhere close to what I expected.
This screenshot shows what I am talking about: ![]() Here, I have just set the auxiliary carry flag (AC) in PSW, loaded the ACC with 0Ah, and executed the DA A instruction. According to the bible, if AC is set or if the low order nibble of ACC is greater than nine, then the DA A instruction should add 6 to the low order nibble of ACC, giving a result of 10h in ACC. But this doesn't happen! As the screenshot shows, DA A didn't make the expected adjustment. After seeing this, I wrote a program to exercise DA A for all possible values of carry, aux carry, and ACC. The result is here, and shows all kinds of goofiness in cases where carry and aux carry are not both zero before the DA A is executed. Can somebody help me understand what's going on here? Am I being stupid? Or is the C8051F120 wrong? Or is the bible wrong? Or is this a case where the part doesn't match the bible, but it doesn't matter somehow? Or ??? It might also help if somebody could experiment with a different chip. I don't have an easy way to do that offhand. Thanks, -- Russ |