Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/22/03 02:49
Read: times


 
#46327 - RE: 8-bit*16-bit multiplication
Responding to: ???'s previous message
And now if you want to get rid of any pesky library calls (portability is left as an exercise for the reader):
typedef unsigned char   U8;
typedef unsigned short  U16;
typedef unsigned long   U32;

union U32_
{
    U32 l;
    U16 w[2];
    U8  b[4];
};

U32 product;

U32 Mul8x16(U8 b, U16 w)
{
    union U32_ retVal;
    U16 tmp;

    tmp         = b * (U8)w;
    retVal.l    = b * (U8)(w >> 8);
    retVal.b[1] = retVal.b[2];
    retVal.b[2] = retVal.b[3];
    retVal.b[3] = 0;

    return (retVal.l + tmp);
}

void main(void)
{
    product = Mul8x16(0x80, 0x1234);
}



List of 32 messages in thread
TopicAuthorDate
8-bit*16-bit multiplication            01/01/70 00:00      
   RE: 8-bit*16-bit multiplication            01/01/70 00:00      
   RE: 8-bit*16-bit multiplication            01/01/70 00:00      
      RE: Integer Promotion Rules            01/01/70 00:00      
   RE: 8-bit*16-bit multiplication            01/01/70 00:00      
      RE: 8-bit*16-bit multiplication            01/01/70 00:00      
      RE: 8-bit*16-bit multiplication            01/01/70 00:00      
         RE: 8-bit*16-bit multiplication            01/01/70 00:00      
            RE: 8-bit*16-bit multiplication            01/01/70 00:00      
               RE: 8-bit*16-bit multiplication            01/01/70 00:00      
                  RE: 8-bit*16-bit multiplication            01/01/70 00:00      
                     RE: 8-bit*16-bit multiplication            01/01/70 00:00      
                        RE: 8-bit*16-bit multiplication            01/01/70 00:00      
                        RE: 8-bit*16-bit multiplication            01/01/70 00:00      
                           RE: 8-bit*16-bit multiplication            01/01/70 00:00      
   RE: 8-bit*16-bit multiplication            01/01/70 00:00      
   RE: 8-bit*16-bit multiplication            01/01/70 00:00      
      RE: 8-bit*16-bit multiplication            01/01/70 00:00      
   RE: 8-bit*16-bit multiplication            01/01/70 00:00      
      RE: 8-bit*16-bit multiplication            01/01/70 00:00      
   RE: 8-bit*16-bit multiplication            01/01/70 00:00      
      RE: 8-bit*16-bit multiplication            01/01/70 00:00      
         RE: 8-bit*16-bit multiplication            01/01/70 00:00      
            RE: 8-bit*16-bit multiplication            01/01/70 00:00      
               MY project Details            01/01/70 00:00      
                  RE: MY project Details            01/01/70 00:00      
                     RE: MY project Details            01/01/70 00:00      
                        RE: MY project Details            01/01/70 00:00      
                           RE: MY project Details            01/01/70 00:00      
                           RE: MY project Details            01/01/70 00:00      
                           RE: MY project Details            01/01/70 00:00      
                              RE: MY project Details            01/01/70 00:00      

Back to Subject List