Searching \ for '[PIC]: PCW C Compiler - How do I Minimise Stack le' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=c
Search entire site for: 'PCW C Compiler - How do I Minimise Stack le'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PCW C Compiler - How do I Minimise Stack le'
2001\01\15@042519 by etorius Johan * Spoornet

flavicon
face
I have a problem that my program produce code that use the stack 9 levels
deep. The pic16f877 has a 8 level stack. Help  C Fundies?

Cheers

Johan Pretorius
(083) 6506752 (Cell)
(011) 7732423 (Phone)
(011) 7732184 (Fax)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@043150 by Michael Rigby-Jones

flavicon
face
Without resorting to messy solutions such as software stacks, you will have
to rewrite the code to minimise nested function calls.  It may be possible
to convert a small function to a macro so the code will be "inlined".  This
will reduce stack useage at the expense of code size.

Mike

> {Original Message removed}

2001\01\15@055356 by Vasile Surducan

flavicon
face
On Mon, 15 Jan 2001, Michael Rigby-Jones wrote:

> Without resorting to messy solutions such as software stacks, you will have
> to rewrite the code to minimise nested function calls.  It may be possible
> to convert a small function to a macro so the code will be "inlined".  This
> will reduce stack useage at the expense of code size.

 Mike, could you give me a little example ?
 Thank's, Vasile

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@062436 by Michael Rigby-Jones

flavicon
face
> -----Original Message-----
> From: Vasile Surducan [SMTP:vasilespamKILLspamL30.ITIM-CJ.RO]
> Sent: Monday, January 15, 2001 10:29 AM
> To:   .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
> Subject:      Re: [PIC]: PCW C Compiler - How do I Minimise Stack level
> usage ?
>
> On Mon, 15 Jan 2001, Michael Rigby-Jones wrote:
>
> > Without resorting to messy solutions such as software stacks, you will
> have
> > to rewrite the code to minimise nested function calls.  It may be
> possible
> > to convert a small function to a macro so the code will be "inlined".
> This
> > will reduce stack useage at the expense of code size.
>
>   Mike, could you give me a little example ?
>   Thank's, Vasile
>
I don't use the CCS compiler so I am not familliar with it's syntax if it
differs from straight ANSI.  The Hitech compiler provides some usefull
functions such as EEPROM read and write in both macro and function form.

e.g.
#define EEPROM_WRITE(addr, value)
while(WR)continue;EEADR=(addr);EEDATA=(value);GIE=0;WREN=1;\
                                       EECON2=0x55;EECON2=0xAA;WR=1;WREN=0

would replace something like:

void eeprom_write(unsigned char addr, unsigned char value)
{
       while(WR) continue:
       EEADR = addr;
       EEDATA = value;
       GIE=0;
       WREN=1;
       EECON2=0x55;
       EECON2=0xAA;
       WR=1;
       WREN=0;
}

Hope that helps

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@101804 by Bob Ammerman

picon face
I'm afraid you have no real choice but to restructure your program to reduce
the maximum call depth.


Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2001\01\15@114124 by Mike Mansheim

flavicon
face
>>Without resorting to messy solutions such as software stacks, you will
have
>>to rewrite the code to minimise nested function calls.  It may be
possible
>>to convert a small function to a macro so the code will be "inlined".
This
>>will reduce stack useage at the expense of code size.

> I have a problem that my program produce code that use the stack 9 levels
> deep. The pic16f877 has a 8 level stack. Help  C Fundies?

With the CCS compiler, you can inline functions with the "#inline"
directive,
which will save stack space at the expense of program memory (the converse
is
also available - the "#separate" directive).
If you enable the "generate call tree" option (node properties), the
compiler
will create a .tre file in the project directory that you can look at to
determine where the #inline directive could best be utilized.  Note that
this
file is only current after a successful compile.
Proper use of these directives *might* let you solve the problem without
re-
writing code.
This is discussed a bit in the CCS manual in the "common questions and
answers"
section (albeit for a different problem), in the answer to "Why do I get an
OUT OF ROM error when there seems to be ROM left?"

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2001\01\16@030610 by dr. Imre Bartfai

flavicon
face
Hi,
u can insert the directive
#inline

immediately before the function declaration in question. You can produce
the calling tree with Alt-T, and the deepest level should be inlined. Of
course, it costs ROM!

Regards,
Imre


On Mon, 15 Jan 2001, Michael Rigby-Jones wrote:

> > {Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...