[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Optimizing a 16-bit * 8-bit -> 24-bit multiplication
From: |
Eric Weddington |
Subject: |
RE: [avr-gcc-list] Optimizing a 16-bit * 8-bit -> 24-bit multiplication |
Date: |
Thu, 07 Dec 2006 01:42:13 -0700 |
Hi Shaun,
Please add this to a Patch Tracker in the avr-libc project page on Savannah.
Emails have a tendency to get lost and I wouldn't want this to be forgotten.
Eric Weddington
> -----Original Message-----
> From:
> address@hidden
> [mailto:address@hidden
> org] On Behalf Of Shaun Jackman
> Sent: Wednesday, December 06, 2006 11:26 AM
> To: Galen Seitz
> Cc: address@hidden
> Subject: Re: [avr-gcc-list] Optimizing a 16-bit * 8-bit ->
> 24-bit multiplication
>
> On 12/1/06, Galen Seitz <address@hidden> wrote:
> > Not exactly what you want, but this might help you get started.
> >
> > galen
> >
> >
> > extern inline int16_t
> > mult_s16_u8s16(uint8_t a, int16_t b)
> ...
>
> Thanks for the code snippet, Galen. Using your mult_s16_u8s16 for
> inspiration, I wrote mul_16_8 (u16 * u8 -> u24). Perhaps these
> functions should be added to avr-libc.
>
> Cheers,
> Shaun
>
> static inline uint32_t mul_16_8(uint16_t a, uint8_t b)
> {
> uint32_t product;
> asm (
> "mul %A1, %2\n\t"
> "movw %A0, r0\n\t"
> "clr %C0\n\t"
> "clr %D0\n\t"
> "mul %B1, %2\n\t"
> "add %B0, r0\n\t"
> "adc %C0, r1\n\t"
> "clr r1"
> : "=&r" (product)
> : "r" (a), "r" (b));
> return product;
> }
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>
[avr-gcc-list] Re: Optimizing a 16-bit * 8-bit -> 24-bit multiplication, David Nicol, 2006/12/04