|
From: | Dean Hall |
Subject: | Re: [avr-gcc-list] Union as parameter |
Date: | Wed, 24 Aug 2005 08:29:00 -0500 |
Larry,Sounds like you're passing the union by value. If you are, can you instead pass it by reference (which would occupy 2 bytes on the stack)? If you're worried about modifying the data in the function, you can shield it with a const declaration. More details here: http://www.embedded.com/shared/printableArticle.jhtml?articleID=9900322
I compiled to assembly a dummy program that used your union. I didn't see anything out of the ordinary (but I'm not an expert in gcc prologue code, so take that statement with a modicum of sodium chloride). One thing you might consider is to make the types in the bits struct all uint32_t. This way you explicitly tell the compiler to pack them all into a 4 byte container. I did this in my dummy program and didn't see a difference, but I didn't see a much of a "riot" in the first place. Maybe my dummy program didn't exercise a certain case of bit manipulation that your program does.
!!Dean On Aug 24, 2005, at 07:15, address@hidden wrote:
------------------------------ Message: 8 Date: Wed, 24 Aug 2005 00:19:08 -0700 From: "Larry Barello" <address@hidden> Subject: [avr-gcc-list] Union as parameter To: "AVR GCC List" <address@hidden> Message-ID: <address@hidden> Content-Type: text/plain; charset="us-ascii"I tried using this typedef, below, as a parameter to a function. When I do, it gets stuck onto the stack frame. The resulting code is a riot since there is all sorts of set up and teardown, the value gets stuck onto the stack, the routine called, the variable pulled off the stack into registerswhere it is acted upon.
[Prev in Thread] | Current Thread | [Next in Thread] |