Fortunately, I don't need anything but add for my bcd variables.  And I
too only really use them for display purposes.  Makes the lookup work
really fast.
I do use BCD for a couple of my actual counters (ie primary
instrumentation values) that if they were the only thing going on, the
battery would probably last for a decade (since there would be nothing
but dadd and display every so often).  But alas, I have found the need
to use floating point since one of my display's is based on time and
would be very slow if kept in the bcd realm (not slow to process, slow
to measure).
-Mark
Ps.  There is this quote from the CV:
"Nationality  British since birth (born London, England).
              Unconditional stay status in Hong Kong. "
I don't think the 3-yr old was born in 1954 :)

 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Steve
Underwood
Sent: Tuesday, June 10, 2003 10:57 AM
To: [email protected]
Subject: Re: [Mspgcc-users] FAQ


Mark Stokes wrote:

>I saw your picture on your web page...
>
How does that tell you I'm British? You do realise I'm the 3 year old 
half-Chinese in that picture, don't you? :-)

>Here's my Bin2Bcd4 routine.  Compiles to 370 bytes (dec)
>I like yours better.
>/*******************************************************************
> Convert from Binary to BCD
>*******************************************************************/
>unsigned long int Bin2Bcd4( unsigned long int val )
>{
>unsigned long int temp = 0;
>
>    temp = ( ( val ) % 10 );
>    val /= 10;
>    temp += ( ( ( val ) % 10 ) << 4 );
>    val /= 10;
>    temp += ( ( ( val ) % 10 ) << 8 );
>    val /= 10;
>    temp += ( ( ( val ) % 10 ) << 12 );
>    val /= 10;
>    temp += ( ( ( val ) % 10 ) << 16 );
>    val /= 10;
>    temp += ( ( ( val ) % 10 ) << 20 );
>    val /= 10;
>    temp += ( ( ( val ) % 10 ) << 24 );
>    val /= 10;
>    temp += ( ( ( val ) % 10 ) << 28 );
>    return( temp );
>}
>
Functionally that's now quite the same as mine, as it returns the BCD in

a long, and can overflow. Maybe its enough for what you do, though. My 5

byte return value is a pain to work with, but I needed a full 32 bit
range.

More significantly, not having used BCD on the MSP430 before, I never 
though to much about it. How do you do BCD subtraction quickly on a 430?

Does anyone, by any chance,  have a bunch of BCD functions they would 
like to contribute? :-)

Regards,
Steve





-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users


Reply via email to