On Thu, Jan 31, 2002 at 11:14:27AM +1100, 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. It's all a matter of perspective. > > For example, the command; > > RETLW 99 > > Would return the value 99 as BCD in W right? Presuming that you have your default radix set to hex W will be 0x99. Now what it means is a matter of perspective. If your software "decides" that it's BCD then is has a value of 99. However if it "decides" that it's hex when it'll have a value of 153 decimal. > > But what about; > > RETLW 255 Too big if the default radix is hex. 0xFF if radix is decimal. > or > MOVLW 99 Same as the 99 above. > or > MOVLW 255 Same as the 255 above. Just to make sure I tested with gpasm. Here's the List line: ------------ 0000 3055 00001 movlw 255 ------------ Note that only the 0x55 part got transferred into the instruction. The 2 was truncated. > > Obviously the 255 gets stored as straight binary, but how is that 'decision' > made? Is 99 the maximum for BCD? 99 is the maximum for 2 digit BCD, just as 99 is the maximum decimal for 2 digits. You can have multitype BCD for as many digits you need. I'd like to help you. Managing BCD and converting to and from decimal is a bit of work. For my digital thermostat project I had to read binary Celsius, convert to binary Fahrenheit, convert that to BCD, and finally display the result on a 2 digit 7 segment display. You can get the code from my PIC page: http://www.finitesite.com/d3jsys Hope this helps, BAJ -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body