Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/27/05 06:40
Read: times


 
#95984 - binary-decimal
Responding to: ???'s previous message
hi,

Alex Anselmi said:
This is the part that counts. It works if I use ADD instead of SUBB and I remove the comment ; from the DA instruction but, of course it counts from 0 to 9. I need to count from 9 to 0
   MOV A, R1
   SUBB A, #01H               
   ;DA A                      
   MOV R1, A
   CJNE R1, #000H, END_T0_INT   ; Check if 1 min has passed. 
   MOV R1, #59H                 ; Reset Seconds to 59
   MOV A, R2
   SUBB A, #01H                 
   ;DA A                         
   MOV R2, A
   CJNE R2, #060H, END_T0_INT


Alex, DA A instruction does not work correct after substraction. To do such way you need a little trick - change substraction to addition with complement BCD number, something like next:
   MOV A,R1
   ADD A,#99H               
   DA  A                      
   MOV R1,A

Regards,
Oleg

List of 17 messages in thread
TopicAuthorDate
Countdown with 8051            01/01/70 00:00      
   No Code ,,, But an Idea            01/01/70 00:00      
   Tutorials            01/01/70 00:00      
      Hi.            01/01/70 00:00      
   Third way            01/01/70 00:00      
   I have a part of code...            01/01/70 00:00      
      Delays.....            01/01/70 00:00      
         Countdown            01/01/70 00:00      
            Show us the code !            01/01/70 00:00      
            "The" code...            01/01/70 00:00      
               What ?            01/01/70 00:00      
                  R1 and R2            01/01/70 00:00      
               binary-decimal            01/01/70 00:00      
                  Another trick            01/01/70 00:00      
                     It's working...            01/01/70 00:00      
   Start your count decimal            01/01/70 00:00      
   count down with 8051            01/01/70 00:00      

Back to Subject List