Yahoo Groups archive

Lpc2000

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

Thread

unexplained RAM use on GCC and CrrosWorks

unexplained RAM use on GCC and CrrosWorks

2005-11-21 by Gus

put the following code in a file and compile it. it takes 240 byte 
of RAM!!!!!!

Can anyone explain why?
Remove any one of the cases and the RAM usage goes down to NONE!!!

int foo(int i)
{
    switch (i)
    {
            case 0x22:
            case 0x2A:
            case 0x2B:
            case 0x3E:
            case 0x5C:
            case 0x5D:
                    return 12;
            break;
    }    
}

Re: [lpc2000] unexplained RAM use on GCC and CrrosWorks

2005-11-21 by Tom Walsh

Gus wrote:

>put the following code in a file and compile it. it takes 240 byte 
>of RAM!!!!!!
>
>Can anyone explain why?
>Remove any one of the cases and the RAM usage goes down to NONE!!!
>
>int foo(int i)
>{
>    switch (i)
>    {
>            case 0x22:
>            case 0x2A:
>            case 0x2B:
>            case 0x3E:
>            case 0x5C:
>            case 0x5D:
>                    return 12;
>            break;
>    }    
>}
>
>  
>
Perhaps you can explain it to yourself, did you try  taking a look at 
the listing file (lss) or did you try an arm-elf-objdump -S -D 
<filename.obj)  to see what is "in there" ??

TomW


>
>
>
>
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>  
>


-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------

RE: [lpc2000] unexplained RAM use on GCC and CrrosWorks

2005-11-21 by Paul Curtis

Gus,

I don't see this take any static RAM.  Why do you think it does?

--
Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
CrossWorks for MSP430, ARM, AVR and now MAXQ processors 
Show quoted textHide quoted text
> -----Original Message-----
> From: Gus [mailto:gus_is_working@...] 
> Sent: 21 November 2005 01:45
> To: lpc2000@yahoogroups.com
> Subject: [lpc2000] unexplained RAM use on GCC and CrrosWorks
> 
> put the following code in a file and compile it. it takes 240 byte 
> of RAM!!!!!!
> 
> Can anyone explain why?
> Remove any one of the cases and the RAM usage goes down to NONE!!!
> 
> int foo(int i)
> {
>     switch (i)
>     {
>             case 0x22:
>             case 0x2A:
>             case 0x2B:
>             case 0x3E:
>             case 0x5C:
>             case 0x5D:
>                     return 12;
>             break;
>     }    
> }
> 
> 
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> --------------------~--> 
> Get fast access to your favorite Yahoo! Groups. Make Yahoo! 
> your home page
> http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/dN_tlB/TM
> --------------------------------------------------------------
> ------~-> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
>

RE: [lpc2000] Re: unexplained RAM use on GCC and CrrosWorks

2005-11-21 by Paul Curtis

Gus, 

> When I look at the memory usage in CrossStudio, I see 240 bytes and 
> then when I remove any one of the "cases" the usage goes down to 0!

*Where* do you see this and get this number from?  If it's "data" then
data encompasses data placed into flash, IIRC.

> Even if this goes on the stack. 0 to 240 is a big change for just 
> one more "case"

Depends upon how the case statement is codegen'd.  If it's a table-based
approach, I would expect a table in flash with a number of entries.  If
it's if-then-else'd then it will bot have a table in flash.  Adding a
single case element is enough to switch between the two, I would guess.

--
Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
CrossWorks for MSP430, ARM, AVR and now MAXQ processors

Re: unexplained RAM use on GCC and CrrosWorks

2005-11-21 by Gus

When I look at the memory usage in CrossStudio, I see 240 bytes and 
then when I remove any one of the "cases" the usage goes down to 0!

Even if this goes on the stack. 0 to 240 is a big change for just 
one more "case"

Gus
--- In lpc2000@yahoogroups.com, "Paul Curtis" <plc@r...> wrote:
>
> Gus,
> 
> I don't see this take any static RAM.  Why do you think it does?
> 
> --
> Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
> CrossWorks for MSP430, ARM, AVR and now MAXQ processors 
> 
> > -----Original Message-----
> > From: Gus [mailto:gus_is_working@y...] 
> > Sent: 21 November 2005 01:45
> > To: lpc2000@yahoogroups.com
> > Subject: [lpc2000] unexplained RAM use on GCC and CrrosWorks
> > 
> > put the following code in a file and compile it. it takes 240 
byte 
> > of RAM!!!!!!
> > 
> > Can anyone explain why?
> > Remove any one of the cases and the RAM usage goes down to 
NONE!!!
Show quoted textHide quoted text
> > 
> > int foo(int i)
> > {
> >     switch (i)
> >     {
> >             case 0x22:
> >             case 0x2A:
> >             case 0x2B:
> >             case 0x3E:
> >             case 0x5C:
> >             case 0x5D:
> >                     return 12;
> >             break;
> >     }    
> > }
> > 
> > 
> > 
> > 
> > 
> > 
> > ------------------------ Yahoo! Groups Sponsor 
> > --------------------~--> 
> > Get fast access to your favorite Yahoo! Groups. Make Yahoo! 
> > your home page
> > http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/dN_tlB/TM
> > --------------------------------------------------------------
> > ------~-> 
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> >
>

Re: unexplained RAM use on GCC and CrrosWorks

2005-11-21 by Gus

I think you are right! It generats a 240 byte jump table! Still seem 
to be overkill

Gus
--- In lpc2000@yahoogroups.com, "Paul Curtis" <plc@r...> wrote:
>
> Gus, 
> 
> > When I look at the memory usage in CrossStudio, I see 240 bytes 
and 
> > then when I remove any one of the "cases" the usage goes down to 
0!
> 
> *Where* do you see this and get this number from?  If it's "data" 
then
> data encompasses data placed into flash, IIRC.
> 
> > Even if this goes on the stack. 0 to 240 is a big change for 
just 
> > one more "case"
> 
> Depends upon how the case statement is codegen'd.  If it's a table-
based
> approach, I would expect a table in flash with a number of 
entries.  If
> it's if-then-else'd then it will bot have a table in flash.  
Adding a
> single case element is enough to switch between the two, I would 
guess.
Show quoted textHide quoted text
> 
> --
> Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
> CrossWorks for MSP430, ARM, AVR and now MAXQ processors
>

Re: unexplained RAM use on GCC

2005-11-21 by John Heenan

I am impressed GCC for ARM looks to use genuine jump tables.

This is how the code worked in an assembly listing.

A branch to a jump table was made if the value passed in was between 
the minimum and maximum case values. This took only three instructions:
sub...  ;subtract minimum from value passed in
cmp...  ;compare result with maximum-minimun constant value
ldrls pc,...   ;if result is less than maximum-minimum then use result 
as as an index value into a table to determine where to branch to next

The size of the jump table is the difference between the maximum and 
minimum case values + 1. The jump table contained one of two values: a 
location to branch to corresponding to the action to take if any of the 
case values was satisfied or a location to branch to if there was no 
case match between the minumum and maximum case values.

John Heenan



--- In lpc2000@yahoogroups.com, "Gus" <gus_is_working@y...> wrote:
Show quoted textHide quoted text
>
> I think you are right! It generats a 240 byte jump table! Still seem 
> to be overkill
> 
> Gus

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.