Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] GCC - locals performance

2005-12-16 by 42Bastian Schick

xjag74 <detlef.weidner@...> schrieb am Wed, 14 Dec 2005 14:51:16 
-0000:
> void functionname(void)
> {
>   unsigned char x=0;
>
> or
>
> void functionname(void)
> {
>   unsigned long x=0;
>
> The first example uses less stack, but it takes a longer time for
> initialization when calling the function cause the 8 bit have to be
> masked out.
> Am I right with that supposition?

Both version use the same amount of stack since the stack must be 4 byte 
aligened on a ARM7.
The unsigned char version will in many cases need more instruction with gcc
because it often does a 8->32 bit promoting (although a ldrb would 
suffice).

My hint: Look at the assmbly output (-S option for gcc) !


-- 
42Bastian Schick

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.