O.K. But remember: Im using the PIC16F84A.. Best Regards > Date: Fri, 30 Jul 2004 16:14:33 0000 > From: "Phil" <> > Subject: Re: RE. RE. RE. etc. MAKING SOFT COUNTERS > > multiply and divide by 10 is trivial with BCD. Mul/div by 2 is > pretty simple. Mul by 5 is mul 10/div 2. Div 5 is mul 2/div 10. > > I still don't get why there is an undercurrent of "BCD is bad". For > some applications like this one, its the perfect data structure.  Germ Herndez C. 

..SOFT COUNTERS
I didn't forget  my point is still quite valid. Though, you really should be using something more modern like a 16F628A but you've heard that before...  In , "German Enred" <german@e...> wrote: > > > O.K. But remember: Im using the PIC16F84A.. > > Best Regards > > Date: Fri, 30 Jul 2004 16:14:33 0000 > > From: "Phil" <phil1960us@y...> > > Subject: Re: RE. RE. RE. etc. MAKING SOFT COUNTERS > > > > multiply and divide by 10 is trivial with BCD. Mul/div by 2 is > > pretty simple. Mul by 5 is mul 10/div 2. Div 5 is mul 2/div 10. > > > > I still don't get why there is an undercurrent of "BCD is bad". For > > some applications like this one, its the perfect data structure. > >  > Germ Herndez C. 
But keep in mind that it doesn't really matter if you are using a 16F84A or an x86  these are relatively simple operations. Multiply by 10 is simply a matter of shifting all the digits one BCD digit and putting a 0 in the least significant digit. Multiply and divide by two are a single bit shift operation just like in binary but you must fixup the value afterword like you do with addition and subtraction. These are special cases of multiply/divide that are very easy to handle on *any* processor. I think Phil pointed them out to remind everyone that not all multiply/divide routines are difficult. Thus if your app can work with the constraints of using only these special case multiply/divide operations and there are some benefits from using BCD then the fact that you need some multiply/divide ability should not be a deterant. Scott  In , "German Enred" <german@e...> wrote: > > > O.K. But remember: Im using the PIC16F84A.. > > Best Regards > > Date: Fri, 30 Jul 2004 16:14:33 0000 > > From: "Phil" <phil1960us@y...> > > Subject: Re: RE. RE. RE. etc. MAKING SOFT COUNTERS > > > > multiply and divide by 10 is trivial with BCD. Mul/div by 2 is > > pretty simple. Mul by 5 is mul 10/div 2. Div 5 is mul 2/div 10. > > > > I still don't get why there is an undercurrent of "BCD is bad". For > > some applications like this one, its the perfect data structure. > >  > Germ Herndez C. 

FYI,
Multiplying by 10 is pretty simple…
Y=X<<1 + X<<3; //This is same as Y=X*2 + X*8 which is the same as Y=X*(2+8) = X*10;
Regards, Trampas
Original
Message
But keep in
mind that it doesn't really matter if you
are using a 

if we are talking BCD (which I believe we are), then. as was pointed out earlier, its at most shifting the value by a byte or nibble. no need to monkey with anything else. Now, for binary, you are right. However, you have to handle the fact that the result needs to fit into twice the bits (8 bit multiplicands, 16 bit result). Your intermediate results need to be double the bits as well.  In , "Trampas" <tstern@n...> wrote: > FYI, > > Multiplying by 10 is pretty simple > > Y=X<<1 + X<<3; //This is same as Y=X*2 + X*8 which is the same as Y=X*(2+8) > = X*10; > > Regards, > > Trampas > Original Message > From: Scott Lee [mailto:midl_man@y...] > Sent: Sunday, August 01, 2004 11:21 AM > To: > Subject: [piclist] Re: ..SOFT COUNTERS > > But keep in mind that it doesn't really matter if you are using a > 16F84A or an x86  these are relatively simple operations. > > Multiply by 10 is simply a matter of shifting all the digits one BCD > digit and putting a 0 in the least significant digit. Multiply and > divide by two are a single bit shift operation just like in binary but > you must fixup the value afterword like you do with addition and > subtraction. > > These are special cases of multiply/divide that are very easy to > handle on *any* processor. I think Phil pointed them out to remind > everyone that not all multiply/divide routines are difficult. Thus if > your app can work with the constraints of using only these special > case multiply/divide operations and there are some benefits from using > BCD then the fact that you need some multiply/divide ability should > not be a deterant. > > Scott > >  In , "German Enred" <german@e...> wrote: > > > > > > O.K. But remember: Im using the PIC16F84A.. > > > > Best Regards > > > > > > > Date: Fri, 30 Jul 2004 16:14:33 0000 > > > From: "Phil" <phil1960us@y...> > > > Subject: Re: RE. RE. RE. etc. MAKING SOFT COUNTERS > > > > > > multiply and divide by 10 is trivial with BCD. Mul/div by 2 is > > > pretty simple. Mul by 5 is mul 10/div 2. Div 5 is mul 2/div > 10. > > > > > > I still don't get why there is an undercurrent of "BCD is bad". > For > > > some applications like this one, its the perfect data structure. > > > >  > > Germ Herndez C. > > to unsubscribe, go to http://www.yahoogroups.com and follow the instructions > <http://us.ard.yahoo.com/SIG9h4hjuh/M)5196.4901138.6071305.300117 6/D=gr > oups/S06554205:HM/EXP91460092/A!28215/R=0/SIGse96mf6/*http: /compa > nion.yahoo.com> click here > > <http://us.adserver.yahoo.com/l? M)5196.4901138.6071305.3001176/D=groups/S= > :HM/A!28215/rand$2291181 > > _____ > > > Service. 

Technically speaking the result needs to be log2(10) bigger than the multiplicand. So that would mean if the multiplicand is 8 bits you would need 12bit result. However if the multiplicand is 4 bits then your results will be 8 bits.
But you are correct in assuming that most people would use a 16 bit result for 8 bit multiplicands, the same as I was correct in assuming most people would realize it was for binary and also assuming most people would know they need more bits in the result.
Regards, Trampas
Original
Message
if we are
talking BCD (which I believe we are), then.
as was pointed 