Statement:Assume the DAA instruction is not present. Write a sub routine which will perform the same task as DAA.
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
This Page is a little effort to make you Sharing of some own materials .This is just a Kick-Start to make the aware of Practical World !!! Best of luck.-DHRUVANG SUTHAR
0 Comments