No exact or substring matches. trying for part
PICList
Thread
'Andy's Annual Challenge #2: 10-Bit Binary-to-BCD '
1995\08\25@010125
by
Andrew Warren
|
A couple of days ago, someone (I don't remember who) asked for a 10-Bit
binary-to-BCD converter. Below is the best converter I could come up
with. It'll actually do a little more than 10 bits; it works on all
binary inputs from 0 to 1285.
Since it's that time of year again, I'm offering to buy a beer for the
first person who a) can explain how the code works, and b) will be at
the Embedded Systems Conference on Tuesday, September 12th.
If you won't be attending the Conference, post an explanation anyway...
I'll drink your beer for you.
REGA EQU [any file register]
REGB EQU [any file register]
REGC EQU [any file register]
; Enter with 10-bit binary number in REGB:REGC (high 2 bits in bits
; 1 and 0 of REGB, low 8 bits in REGC). Exits with BCD equivalent
; in REGA:REGB (thousands/hundreds digits in REGA, tens/ones in
; REGB).
;
;Executes in 113 cycles.
BIN2BCD MOVLW 00000001B
MOVWF REGA
B2BLOOP RLF REGC
RLF REGB
RLF REGA
BC DONE
MOVLW 003H
ADDWF REGB
BTFSS REGB,3
SUBWF REGB
MOVLW 030H
ADDWF REGB
BTFSS REGB,7
SUBWF REGB
GOTO B2BLOOP
DONE ....
-Andy
P.S. Terry Rudersdorfer solved last year's "Square Root" challenge,
posted on the Microchip BBS. Is he on the PICLIST? Maybe he can make
it two-for-two...
--
Andrew Warren - spam_OUTfastfwdTakeThisOuT
ix.netcom.com
Fast Forward Engineering, Vista, California
More... (looser matching)
- Last day of these posts
- In 1995
, 1996 only
- Today
- New search...