Program to implement BCD counter to count from 99-0
25;Program to implement BCD counter to count from 99-0 :
here:mov b,#99h ;move 99h to bup:mov a,b ;move data from b to a
add a,#99h ;add 99h to a
da a ;decimal adjust accumulator after addition
mov b,a ;move data from b to a
mov p0,a ;move data from a to p0
acall delay ;call delay routine
mov a,b ;move data from b to a
cjne a,#0ffh,up ;compare a with 0ffh, if not equal , jump to location up
sjmp here ;jump to location here
delay routine:
delay:mov r1,#25h ;move 25h to r1
l3:mov r2,#0ffh ;move 0ffh to r2
l2:mov r3,#0ffh ;move 0ffh to r3
l1:djnz r3,l1 ;decrement r3, jump if not equal to 0 to l1
djnz r2,l2 ;decrement r2, jump if not equal to 0 to l2
djnz r1,l3 ; decrement r1, jump if not equal to 0 to l3
ret
end