Statement:Assume the DAA instruction is not present. Write a sub routine which will perform the same task as DAA.
Home
8085 Forum
8085 Free Projects
8085 Free Programs
8085 Tutorials
8085 details
Interfacing Techniques
Electronic Tutorials
Electronic Projects
Assembler/ IDE
Datasheets
Guest Book
About Me
Sample Problem:

Execution of DAA instruction:
1. If the value of the low order four bits (03-00) in the accumulator is greater than 9 or if auxiliary carry flag is set, the instruction adds 6 '(06) to the low-order four bits.
2. If the value of the high-order four bits (07-04) in the accumulator is greater than 9 or if carry flag is set, the instruction adds 6(06) to the high-order four bits.
               
Source Program:

       LXI SP, 27FFH        : Initialize stack pointer
       MOV E, A                : Store the contents of accumulator
       ANI 0FH                : Mask upper nibble
       CPI 0A H                : Check if number is greater than 9
       JC SKIP                : if no go to skip
       MOV A, E                : Get the number
       ADI 06H                : Add 6 in the number
       JMP SECOND                : Go for second check
SKIP: PUSH PSW                : Store accumulator and flag contents in stack
       POP B                        : Get the contents of accumulator in B register and flag register contents in                                C register
       MOV A, C                : Get flag register contents in accumulator
       ANI 10H                 : Check for bit 4
       JZ SECOND                 : if zero, go for second check
       MOV A, E                 : Get the number
       ADI 06                : Add 6 in the number
SECOND: MOV E, A                : Store the contents of accumulator
       ANI FOH                : Mask lower nibble
       RRC 
       RRC
       RRC
       RRC                        : Rotate number 4 bit right
       CPI 0AH                : Check if number is greater than 9
       JC SKIPl                 : if no go to skip 1
       MOV A, E                : Get the number
       ADI 60 H                 : Add 60 H in the number
       JMP LAST                : Go to last
SKIP1: JNC LAST                  : if carry flag = 0 go to last
       MOV A, E                : Get the number
       ADI 60 H                 : Add 60 H in the number
LAST: HLT

Note: To check auxiliary carry flag it is necessary to get the flag register contents in one of the registers and then we can check the auxiliary carry flag by checking bit 4 of that register. To get the flag register contents in any general purpose register we require stack operation and therefore stack pointer is initialized at the beginning of the source program.


FLOWCHART