Sean Alcorn - Avion Sydney wrote: > > Hi Guys, > > I am just about to embark on my next project, and am in the planning stages. > > Whilst I understand the difference between BCD and straight binary, I am a > little confused about what actually determines whether a value is stored as > BCD or straight binary. > > For example, the command; > > RETLW 99 > > Would return the value 99 as BCD in W right? Nope. The value '99' that the assembler will read is dependant on the RADIX setting at the time of assembly. Usually this defaults to HEX. So RETLW 99 would generate 0x3499 as the HEX code, or return with 0x99 in W. (153dec) If the RADIX is decimal then RETLW 99 will generate 0x3463, or return with 0x63 in W. (99dec) > But what about; > > RETLW 255 > or > MOVLW 99 > or > MOVLW 255 > > Obviously the 255 gets stored as straight binary, but how is that 'decision' > made? Is 99 the maximum for BCD? Same rules apply. The PIC doesn't work directly with BCD numbers and you would have to write code that handles them yourself. The RADIX can be set manually in your code using the RADIX command, or by setting it in the pop-up screen that appears when you assemble the asm file. -- Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body