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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/15/07 14:39
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#135049 - BCD
Responding to: ???'s previous message
What you need is called BCD (Binary Coded Decimal).
There is a certain support for it in '51 - have a look at the DAA instruction.

A short hint:
;each second do the following:
   mov  a,Seconds
   add  a,#1
   daa
   cjne a,#60h,SecondsDone
   mov  a,Minutes
   add  a,#1
   daa

;   etc. - by now you should've get the idea

   mov  a,#0         ;clear the seconds
SecondsDone:
   mov  Seconds,a
   mov  P1,a


---------------------------------
A completely different approach:

Of course, you can also count as now up to 60 binary and before sending it out to port, split it like:
   mov   a,SecondsInDecimal
   mov   b,#10
   div   ab     ;isn't it wonderful that we have div in '51?!
   swap  a      ;tens will go into upper 4 bits
   orl   a,b    ;ones will go into lower 4 bits
   mov   P1,a



Have fun!

JW

List of 4 messages in thread
TopicAuthorDate
help with 8051 byte manipulation for Binary CLock            01/01/70 00:00      
   BCD            01/01/70 00:00      
   Thanks !!!            01/01/70 00:00      
      keep a cheatsheet around            01/01/70 00:00      

Back to Subject List