Someone asked, "I'm reading four 4-bit BCD switches, and I need to convert the numbers I get to one 16-bit binary number. I tried the Microchip BCD-to-Binary appnote, but it didn't work." I don't remember who it was, but he later posted the same question to Parallax's "STAMPS" mailing list, so he must really be desperate. Ok... I don't know why Microchip's appnote didn't work for you... Those math appnotes are abysmally slow, but I don't think any of them are WRONG. 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. The code is a couple bytes longer than what's in the Microchip appnote, but it's about 4 times faster. It also uses only one extra register, instead of Microchip's 4, and doesn't eat up any subroutine stack space. The code assumes that your four 4-bit values are stored in registers named "THOU", "HUND", "TENS", and "ONES". It also assumes that you've defined a register named "TEMP". It stores the 16-bit result in THOU:HUND (hi-byte in THOU, lo-byte in HUND), and thoroughly scrambles the other three registers. If you need to remember the original values, copy them elsewhere before you execute this code. ; ; Four-Digit BCD to 2-Byte Binary Converter, 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 ;W = TENS*2. RLF TENS,W ; MOVWF TEMP ;W = TENS*4. RLF TEMP,W ; ADDWF TENS ;TENS = TENS*5. RLF TENS ;TENS = TENS*10. ADDWF ONES ;ONES = TENS*10 + ONES RLF THOU,W ;W = THOU*2 (CLRC not necessary here). ADDWF THOU,W ;W = THOU*3. MOVWF TEMP ;W = THOU*6. RLF TEMP,W ; SUBWF THOU ;THOU = THOU*250 / 256. RLF THOU ;THOU = THOU*500 / 256. RLF THOU ;THOU = THOU*1000 / 256. RLF HUND,W ;W = HUND*2 (CLRC not necessary here). 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 ;TENS:HUND = HUND*50. RLF HUND ;(CLRC not necessary here). RLF TENS ; RLF HUND ;TENS:HUND = HUND*100. RLF TENS ; MOVF ONES,W ;HUND = LO-BYTE OF RESULT. ADDWF HUND ; SKPNC ;THOU = HI-BYTE OF RESULT. INCF TENS ; MOVF TENS,W ; ADDWF THOU ; DONE: ;THOU:HUND = 1000*THOU + 100*HUND ; + 10 * TENS + ONES. Enjoy... -Andy -- Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California