BCD is binary coded decimal. This means that there is one decimal number every four bits. Your 06 is binary 0000 0110, which means that there is a 0 in the top four bits, and a 6 in the bottom four. The 85 is binary 0101 0101, which is 5 and 5 The 53 is binary 0011 0101, which is 3 and 5 If you look at the numbers in hexadecimal they come out to 06 55 35 The reason many people use BCD is that it's then easy to look at each four bits and output them to a display or another chip which displays things in BCD. Calculations in BCD are not very difficult either. -Adam Tan Chun Chiek wrote: >Added the PIC tag. > >I remembered running this snippet few days ago and the result wasn't >anything like that. >Did you copy the source from the PDF? Have you tried the source from the ZIP >file accompanying the AN? > >Tan CC > >----- Original Message ----- >From: "Morgenbrise Ent. Co., Ltd." >To: >Sent: Friday, May 30, 2003 11:36 AM >Subject: Binary to BCD conversion > > >As a novice, I studied the "AN-526". Tried to run the program "Appendix H: >Binary (16bit) to BCD". > >However, the result in R0, R1, R2 become 06,85,53 in stead of 06,55,35 when >converting the number B'11111111' in both H_byte & L_byte. > >I traced every step but can't find where is the problem? > >Not yet understand the algorithm of such a conversion, my first step is to >follow the codes; even so the result is not correct. > >The sample routine was publilshed many years ago, there must be many people >ever study it. I would appreciate if someone hints me the blind point(s) >where I stuck? > >Regards > >Paul Tsai > >-- >http://www.piclist.com hint: The PICList is archived three different >ways. See http://www.piclist.com/#archives for details. > >-- >http://www.piclist.com#nomail Going offline? Don't AutoReply us! >email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body