Hello, On Tue, 14 May 2013 23:31:03 +0530 kuldeep dhaka <kuldeepdha...@gmail.com> wrote:
> hello guys, > > while coding (embedded devices) i got an idea. > [] > in the above code, after sending uart_send(before) , "before" is no > more useful to me. > but for while loop i have to get a new variable "i" for iteration. > in this case the compiler allocates the memory in stack. > since in embedded system, everything is scare , reusing things come > handy and efficient. > > but if i try to reuse "before" in loop as replacement of "i" , it > looks odd > + bad coding practise, right? > > but if their is something like __reuse__("before", "i") ( like > __attribute__() or sizeof() ) or uart_send_param(uint8_t before|i, > uint8_t after, uint8_t default_value) > after that i could use "before" as "i". You don't need to do anything for this to work as you describe for *local variables* - compiler is supposed to do this for you (at relevant optimization levels, like -O2). Google for "live range analysis" for more info, http://en.wikipedia.org/wiki/Register_allocation and http://en.wikipedia.org/wiki/Live_variable_analysis are a good start. More interesting question is such support for static (if not global) variables. When trying to do Elliptic Curve Cryptography on MSP430 value line devices which top up at 0.5K RAM, you really wish that compiler could "pack" together static buffers of functions which cannot be active at the same time ;-). If anyone know of that to be done by gcc, would be nice to get some pointers. -- Best regards, Paul mailto:pmis...@gmail.com ------------------------------------------------------------------------------ AlienVault Unified Security Management (USM) platform delivers complete security visibility with the essential security capabilities. Easily and efficiently configure, manage, and operate all of your security controls from a single console and one unified framework. Download a free trial. http://p.sf.net/sfu/alienvault_d2d _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users