avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Global variables and ISRs ???


From: Galen Seitz
Subject: Re: [avr-gcc-list] Global variables and ISRs ???
Date: Wed, 07 Sep 2005 08:51:36 -0700

Joerg Wunsch <address@hidden> wrote:

> "David Brown" <address@hidden> wrote:
> 
> > ..., and it will also change "multiply by constant" into a series of
> > shifts and adds.  The target chip has a hardware multiplier and
> > divider, but they are slower than the shift-and-add sequences.
> 
> Unfortunately, AVR-GCC also does this, even though the hardware
> multiplier is faster than a series of shift and add. :-(
> 

Because I wanted more control over multiplies, I've started creating
routines like these:


extern inline uint16_t
mult_u16_u8u8(uint8_t a, uint8_t b)
{
    uint16_t product;
    asm (
        "mul %1, %2"    "\n\t"
        "movw %0, r0"   "\n\t"
        "clr r1"        "\n\t"
        : "=w" (product)
        : "r" (a), "r" (b)
        );
    return product;
}


extern inline uint16_t
mult_u8h_u8u8(uint8_t a, uint8_t b)
{
    uint8_t product_high;
    asm (
        "mul %1, %2"    "\n\t"
        "mov %0, r1"    "\n\t"
        "clr r1"        "\n\t"
        : "=w" (product_high)
        : "r" (a), "r" (b)
        );
    return product_high;
}



I have a few others if people are interested.

galen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]