[Top][All Lists]

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

RE: [avr-gcc-list] movw and asm

From: James Dabbs
Subject: RE: [avr-gcc-list] movw and asm
Date: Wed, 6 Aug 2003 11:34:43 -0400

> I found the following from the avr-libc-manual
> * Function call conventions:
> Arguments - allocated left to right, r25 to r8. All arguments are aligned
> start in even-numbered registers (odd-sized arguments, including char,
have one
> free register above them). This allows making better use of the movw
> on the enhanced core. If too many, those that don't fit are passed on the
stack. Return
> values: 8-bit in r24 (not r25!), 16-bit in r25:r24, up to 32 bits in
r22-r25, up to
> 64 bits in r18-r25. 8-bit return values are zero/sign-extended to 16 bits
by the
> caller (unsigned char is more efficient than signed char - just clr r25).
> to functions with variable argument lists (printf etc.) are all passed on
stack, and
> char is extended to int.

Thanks Rune!  These links are helpful, and they answered my next question.
But I am still wondering about parameters passed into asm blocks.  For

inline unsigned long Test(unsigned long Input)
    unsigned long Output;

    Input = ((Input << 4) ^ (Input >> 5)) + Input;

        "mov %A0,%A1\n\t"
        "mov %B0,%B1\n\t"
        "mov %C0,%C1\n\t"
        "mov %D0,%D1\n\t"

    Output = Output << 4;

    return Output;

Is there is any determinism in how the compiler arranges the 8 registers
used to hold "Output" and "Input" before it falls into the asm block?  I'm
also looking to see if there is a trick to emit conditional statements to
gas, like "if A0 and A1 are even registers and B0 and B1 are adjacent to
them then use movd" or whatever.

At this point, we met the benchmark by writing the whole routine over in
assembler.  However, I'd still like to know.  Atmel added movd to their
enhanced core.. It would be nice to be able to make use of it.

reply via email to

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