I was searching for a binary to BCD conversion routine and found this: http://www.piclist.org/techref/postbot.asp?by=3Dtime&id=3Dpiclist/2002/12= /24/164925a from Bob Ammerman. It appeared to be just what I was looking for but it 'seems' to have a problem. Can anyone tell me what is missing/wrong with = this macro or suggest where I may be going wrong with its use?=20 The macro was listed as "untested" but it looks like it should work and = in fact does for many, but not all, numbers. 0x2FF, for example, converts to 00 00 00 00 67. When stepping through the macro on paper, I get the correct result, 00 00 00 07 67. It's almost as if DAW and/or ADDWFC=20 and/or RLCF isn't working correctly (not likely) or at least not as I = expected. The only change I made to the macro was to substitute RLCF for RLF. I can probably find or write another binary to BCD conversion routine but I'd really like to understand what the problem is with this macro or my use of it. Thank you Mike Jones My code: ----------------------------------------------------------------- #define bcdbytes 5 #define binbytes 4 ; Access Ram 128 Bytes (00h - 7Fh) Bank 0 cblock 0x000 bcdval:bcdbytes binvar:binbytes mytemp:1 BinB:4 ; Since binvar is destroyed, BinB is used ; to keep the original around as a sanity check endc ExtA1 ; Test Binary to Packed BCD macro movf BinB,w movwf binvar ; LSB movf BinB+1,w movwf binvar+1 movf BinB+2,w movwf binvar+2 movf BinB+3,w ; MSB movwf binvar+3 BIN2BCD binvar,binbytes,bcdval,bcdbytes,mytemp ; Test return A sample of the test results; ; = -------------------------------------------------------------------------= - bcdval bcdval binvar Expected from macro Diff ----------- ------------ ------------- ----- 00 00 00 FF 00 00 02 55 00 00 02 55 0 00 00 01 FF 00 00 05 11 00 00 05 11 0 00 00 02 00 00 00 05 12 00 00 05 12 0 00 00 02 0F 00 00 05 27 00 00 05 27 0 00 00 02 F0 00 00 07 52 00 00 01 52 600 00 00 02 FF 00 00 07 67 00 00 00 67 700 00 00 03 FF 00 00 10 23 00 00 10 23 0 00 00 04 FF 00 00 12 79 00 00 12 79 0 00 00 05 FF 00 00 15 35 00 00 01 35 1400 00 00 FF FF 00 06 55 35 00 02 41 35 41,400 -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.