Open baikunth2a opened 3 years ago
@baikunth2a Can you share an example that is failing? The output you are observering and the expected one will be good to know.
@debjitbis08 Thanks for responding. Please observe the result of following program.
MVI A, 0AH
DAA
MVI A, 01H
DAA
HLT
Expected output A
=01
Output observed A
=07
@baikunth2a This is happening because the AC
flag is being set by the first DAA
instruction. You would need to handle the flag value from the first DAA
execution.
From the documentation,
DAA operates as follows:
Hope this helps.
Hi, I'm facing a similar issue with DAA. Here is my code to convert hex to bcd:
;
jmp start
;code start: LDA 2050H MOV C, A MVI D, 00H MVI A, 00H
loop: ADI 01H DAA JNC skip INR D
skip: DCR C JNZ loop MOV L, A MOV H, D SHLD 2060H hlt
When I insert FF at 2050, the expected output is 55 at 2060 and 02 at 2061; instead I'm getting 13 at 2060 and 0B at 2061. I cross checked my code on these websites: https://www.tutorialspoint.com/8085-program-to-convert-hex-to-bcd https://www.zseries.in/embedded%20lab/8085%20programs/hex%20to%20bcd%20conversion.php#.X6Efq3xR201
Hi, I'm facing a similar issue with DAA. Here is my code to convert hex to bcd:
`;
jmp start
;code start: LDA 2050H MOV C, A MVI D, 00H MVI A, 00H
loop: ADI 01H DAA JNC skip INR D
skip: DCR C JNZ loop MOV L, A MOV H, D SHLD 2060H hlt`
When I insert FF at 2050, the expected output is 55 at 2060 and 02 at 2061; instead I'm getting 13 at 2060 and 0B at 2061. I cross checked my code on these websites: https://www.tutorialspoint.com/8085-program-to-convert-hex-to-bcd https://www.zseries.in/embedded%20lab/8085%20programs/hex%20to%20bcd%20conversion.php#.X6Efq3xR201
On Fri, Oct 23, 2020, 11:31 AM Debjit Biswas notifications@github.com wrote:
@baikunth2a https://github.com/baikunth2a Can you share an example that is failing? The output you are observering and the expected one will be good to know.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/debjitbis08/sim8085/issues/18#issuecomment-714927705, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQYBATKWH45FPI6WJOQSXHLSMEKDFANCNFSM4R4BEVVQ .
@abhishekUpmanyu that's because the AC flag was set by DCR C
, and 06/60 was being added to the accumulator after DAA
since it takes AC flag into account.
Just load 02H in C and see the result. The expected result is 02H, but due to the DCR C
instruction the result becomes 08H (02H + 06H) after DAA
. So, you'll have to handle the AC flag yourself.
---
Just found that this is the problem with sim8085 itself.
@jarp0l After DCR C
, ADI 01H
will be there, so Flags should again get adjusted (Reset) properly before getting up to DAA
. So yes this is an error with sim8085 itself...
It adds 06 to any numbers (i.e. although the number is less than 0xA) to adjust decimal using
DAA
after onceDAA
executed for number greater than 0x9.