Last night, I wrote: >In any case, your problem can probably be solved by the following code. >I say "probably" because I haven't tested (or even assembled) it; I >just wrote it on-line. I'm sure that if there are any errors, you and >I will both hear about them soon enough. ... and then I posted a BCD-to-Binary converter with a major bug. Duh. This one should work. Again, I haven't assembled and tested it, but I HAVE spent more than a couple minutes thinking about it, so already it's got more going for it than the version I posted last night. Also, I moved the comments around so that they'll make a little more sense to anyone trying to understand how the code works. In this version, a comment like "W = TENS*4" means that AS SOON AS THE LINE WITH THE COMMENT IS EXECUTED, W will hold TENS' original value times 4; in the previous version, the same comment meant that the following code, UNTIL THE NEXT COMMENT, worked to fill W with TENS' original value times 4. Ok... Here's version 2 (don't you wish Microsoft would find, admit to, and fix bugs this quickly?): ; ; Four-Digit BCD to 2-Byte Binary Converter (version 2), ; written by Andy Warren. ; ; (C) 1995 Fast Forward Engineering. All right reserved. ; ; Permission is hereby granted for any non-commercial use, so long as ; this copyright notice remains intact. ; THOU EQU [any register] HUND EQU [any register] TENS EQU [any register] ONES EQU [any register] TEMP EQU [any register] ; Enter with four-digit BCD value in THOU, HUND, TENS, and ONES. ; Exits with 16-bit result in THOU (hi-byte) and HUND (lo-byte); TENS, ; ONES, and TEMP are scrambled. BCD2BIN: CLRC ;------------------------ RLF TENS,W ;W = TENS*2. ; MOVWF TEMP ; ; By the way, this RLF TEMP,W ;W = TENS*4. ;-- is a pretty good ADDWF TENS ;TENS = TENS*5. ; 2-digit BCD to RLF TENS ;TENS = TENS*10. ; binary converter ADDWF ONES ;ONES = TENS*10 + ONES. ; by itself... ;------------------------ RLF THOU,W ;W = THOU*2 (CLRC not necessary here). ADDWF THOU,W ;W = THOU*3. MOVWF TEMP ; RLF TEMP,W ;W = THOU*6. CLRF TEMP ; SUBWF TEMP ; DECF THOU ;THOU:TEMP = THOU*250 / 256. RLF TEMP ; RLF THOU ;THOU:TEMP = THOU*500 / 256. RLF TEMP ; RLF THOU ;THOU:TEMP = THOU*1000 / 256. RLF HUND,W ;W = HUND*2. ADDWF HUND,W ;W = HUND*3. MOVWF TENS ;TENS = HUND*3. RLF TENS ;TENS = HUND*6. RLF TENS ;TENS = HUND*12. RLF TENS,W ;W = HUND*24. ADDWF HUND ;HUND = HUND*25. CLRF TENS ; RLF HUND ; RLF TENS ;TENS:HUND = HUND*50. RLF HUND ; RLF TENS ;TENS:HUND = HUND*100. MOVF ONES,W ; ADDWF TEMP,W ; SKPNC ; INCF TENS ; ADDWF HUND ;HUND = LO-BYTE OF RESULT. SKPNC ; INCF TENS ; MOVF TENS,W ; ADDWF THOU ;THOU = HI-BYTE OF RESULT. DONE: ;THOU:HUND = 1000*THOU + 100*HUND ; + 10 * TENS + ONES. Enjoy... -Andy -- Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California