What compiler flags did you use?  It sounds to me that you are compiling
without enabling optimisation - in which case you can't expect good code.

mvh.,

David


On 14/05/13 20:01, kuldeep dhaka wrote:
> hello guys,
> 
> while coding (embedded devices) i got an idea.
> 
> void uart_send_param(uint8_t before, uint8_t after, uint8_t default_value)
> {
>     uint8_t i = 0;
> 
>     uart_send(ASCII_ESCAPE);
>     uart_send(before);
> 
>     while(before < vt100_param_getcount())
>     {
>         if(vt100_param_get(i) != default_value)
>         {
>             uart_send_int(vt100_param_get(i));
>         }
> 
>         if(++i < vt100_param_getcount())
>             uart_send(VT100_PARAM_DELIMITER);
>     }
> 
>     uart_send(after);
> }
> 
> 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".
> 
> if "i" is just finished up with register indexing and no stack allocation,
> then that good but still the problem of reuse might arise in some other
> case.
> 
> in some case union can be used but i think it cannot solve the above
> problem.
> it can help alot to reduce push and pop operations, making thing efficient.
> 
> more or like saving 4 bytes flash and 2(or 1 byte, i dont know :) ) byte of
> stack.( msp are 16bit MCU's, msp430G2552 only have 8K flash and 256Byte Ram
> , so that comparable).
> and when the flash get full or ram overflows it really hurts :)
> 
> note: rejected by mail demon of g...@gcc.gnu.org so im trying here.
> 


------------------------------------------------------------------------------
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

Reply via email to