Jump to content
Sign in to follow this  
crash_n_burn

Ram Memory Allocation For Variables

Recommended Posts

I am using Boost C V1.9.2 with IDE V5.9.1. Im writing code for a PIC 18F6720.

 

The program is getting bigger everyday and lately I saw a strange beavior of the code.

For some reason, some functions don't input the right value in the parameters...

 

In my search for bugs, I looked at the .ASM file produced by the compiler. I was suprised to see many variables using the same RAM adress. For example, RAM location 0x2D is used many times. Here are some sample lines for my .ASM file :

 

CompTempVar32                    EQU	0x0000002D; bytes:1
CompTempVar34                    EQU	0x0000002D; bytes:1
eewrite_00000_1_ll               EQU	0x0000002D; bytes:2
CompTempVar43                    EQU	0x0000002D; bytes:1
printbmp_00000_1_lx              EQU	0x0000002D; bytes:1
box_00000_arg_layer              EQU	0x0000002D; bytes:1
showpar_00000_arg_x              EQU	0x0000002D; bytes:2
showprice_00000_arg_x            EQU	0x0000002D; bytes:2
showtemp_00000_arg_pol           EQU	0x0000002D; bytes:1
infusion_00000_1_tingcafe        EQU	0x0000002D; bytes:2
CompTempVar264                   EQU	0x0000002D; bytes:1

 

Variable "ll" in fonction eewrite is using it.

Variable "lx" in fonction printbmp is using it.

Variable "layer" in fonction box is using it.

and so on.

 

I compared with a .ASM file from a older program compiled with C2C and every variable is using it's own memory location. I think it's much better like this.

 

I got rid of my bugs by manualy put RAM arrays farther away in memory. My program is running fine, but still many variables are sharing the same RAM location.

I'm afraid the prog will crash when i had some more code because of all this RAM sharing.

 

Is the compilator doing things correcly ?

 

 

Thank you.

Share this post


Link to post
Share on other sites

crash_n_burn,

 

One of the great benifits of using the BoostC compiler and linker is that the linker does a call tree analysis.

 

On PICs the hardware stack does work so well for local data storage (or not at all on PIC16) for this type of storage, so we use a software stack. What this means is it works out when local variables live and die, and so can determine what memory space can be re-used.

 

The result is a software stack use memory efficiently, by re-use.

C2C compiler also has a selectible option for memory re-use (maybe you have it turned off).

 

The current software stack implementation on BoostC has looked pretty robust for a long time, so I'm surprise to here of an issue.

 

If you have a project that is mis-behaving and you think is down to the memory allocation on the sofware stack, please zip it up and submit if for examination. Send to support@picant.com. Please simplify the code as much as possible and provide as many details as possible as to the problem.

 

I got rid of my bugs by manualy put RAM arrays farther away in memory. My program is running fine, but still many variables are sharing the same RAM location.

Maybe you overrun the end of your arrays ???

 

 

Regards

Dave

Share this post


Link to post
Share on other sites

Dave, thanks a lot for the explanation of the call tree. Now i know it's purpose ! I'm learning while debugging.

 

Maybe you overrun the end of your arrays ???

 

This rings a bell. You might be right. I'll double check my code for any overrun issues.

 

I'm gonna trust the call tree analysis since it's been used for some time.

 

Thanks for the lightning-fast answer.

 

 

Crash

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...