Thanks for the reminder, I made that mistake once or twice myself. On the assumption that 0x70 and 0x80 are valid packed bcd numbers I just finished a simple test to isolate the problem. The shortened version of the code goes like this; (Note: 18F452 processor, checking apparent addwfc and/or daw problem) cblock 0x00 binvar:1 bcdval:1 end clrc movf binvar,w addwfc binvar,w daw movwf bcdval Test 1: set binvar = 0x70 after the addwfc, WREG = 0xE0 Carry = 0 after the daw, WREG = 0x40 Carry = 1 So far so good! Test 2 set binvar = 0x80 after the addwfc, WREG = 0x00 Carry = 1 after the daw, WREG = 0x60 Carry = 0 What happened to the carry bit ?? I rather expected it to still be there. In fairness, the data sheet doesn't say much about how or why the carry bit is affected, it just say that it is affected. There may be other documents that give more detailed information about the status bits during and after a 'daw' but I haven't found any yet. Going back to the original problem: I don't know how completely valid this is yet but, after a very brief test, it appears that if I save the carry bit after the addwfc and restore it after the daw, all may be well. Mike Jones ----- Original Message ----- From: "Jan-erik Svderholm (QAC)" To: Sent: Tuesday, February 04, 2003 12:11 AM Subject: Re: [PIC]: Binary to Packed BCD Conversion Problem I wrote a routine to convert a bin value to BCD some time ago. One thing that I missed about the DAW instruction, is that DAW "Decimal adjust W" when W containes the result of an addition of two other values *which both was in BCD format before the addition*. So you can not add two *binary* values and then use DAW on the result. You'll get all kinds of funny results. (And if one read the data sheet carefully, this is clearly written there...) I have not checked is this is the case for your code, but anyway... Jan-Erik Svderholm. -- 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