To me it looks more like a BCD to binary conversion. BCD=16*tens+ones. To get it on to binary you require 10*tens+ones. so you do a BCD-8*tens+2*tens. If you happen to get a binary to BCD converter, please forward it to be. I'm really interested. PS. It might be possible to get a binary to BCD converter using the same logic. Am trying to work it out. At 17:01 4/27/98 +0100, John Midgley wrote: >Dear All > >Cannily realising that I'd want a binary to BCD conversion routine >in the future, I carefully filed and kept a brief thread on the subject >from a few weeks ago. Slightly less cannily, I can't understand what >it's doing. Can anyone point me in the right direction, pseudo-code- >wise? Let's say I have a byte 'count'; if it can run to FFh, I guess I >need 12 bytes of BCD (3 lots of 4 bytes?) to encode '255'. Or would >it be customary to stop at 63h (99 dec.)? Either way, in English (or some >approximation) what am I doing? This was the routine: > >> rrf bcd,W >> andlw 01111000b ;W = tens*8 >> movwf temp >> clrc >> rrf temp,f ;temp = tens*4 >> rrf temp,f ;temp = tens*2 >> subwf bcd,W ;W = tens*16 + ones - tens*8 >> ;W = tens*8 + ones >> addwf temp,W ;W = tens*10 + ones >> > >I know what all the opcodes mean, but that's not quite the same as >understanding the whole thing! > >And if I wanted to go to 9999 decimal (270Fh) could I scale it up easily? > >Any help greatly appreciated. > >Regards > >John M > > with best wishes and regards Sujay Sirur Email: sirur@giasbg01.vsnl.net.in Home: 604, Chitrapur Housing Society, Plot no 68, 15th Cross, 8th Main, Malleshwaram Bangalore 560 055. INDIA Tel. no: 91-80-344-3688 ================================================================= If love is in the air, then its polluted :-) :-) =================================================================