View previous topic :: View next topic |
Author |
Message |
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Sun May 17, 2015 10:46 pm Post subject: Variabel list |
|
|
Hi there.
Is there a limit on how many variables there can be in a program?, lets say how many single and how many word.
If so, is there a list somewhere i can get.
And if there is a limit, would it include INC.files to?.
Thanx
Øyvind :-)
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Sun May 17, 2015 11:46 pm Post subject: |
|
|
The limit is set by the total space all the global variables ( the ones set by DIM statements ) take up in SRAM, after allowing space for the hardware and software stacks and the frame.
Does not matter whether the variables are in the main program, or in INC files, the total space used will be the same.
You can considerably conserve space by using local variables inside SUBs and FUNCTIONs, that way many working variables can be created on the software stack, used within a SUB, and destroyed afterwards. Then the next SUB ( or Function ) just uses the same stack space for its local variables.
You can see how much RAM is used ( and left ) by reading the compiler report after a compile. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Mon May 18, 2015 9:10 pm Post subject: |
|
|
Hi
Thanx for the answer
Øyvind |
|
Back to top |
|
|
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Mon Feb 15, 2016 12:18 pm Post subject: |
|
|
(After some time...)
Hi!
Since i'm always a bit puzzled with stack settings, too, and always set them...random, i guess... i wonder... after compiling report says that certain amount of RAM is left "unused".
Does this mean that it's totally unused, like it isn't there at all? Wasted space?
With other words: when my program is finished and compiled, can i increase swstack, hwstack and framesize up until that "RAM space left" is almost zero?
If that RAM is unused and wasted, it's better to be unused in stack than nowhere...
Am i thinking in a right way?
And ---i often use "Gosub" and subs without declaring and defining LOCAL variables - is here same as declared sub regarding variables or is it more like "Goto" statement?
Thanks!
Regards, Paul |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Mon Feb 15, 2016 2:11 pm Post subject: |
|
|
it is philosophical...
unused Stack or unused variables .... what can be the difference between?
I can tell you, what they have both: the word "unused"
_________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Mon Feb 15, 2016 3:46 pm Post subject: |
|
|
I agree, sure. But, if i have extra unused space is then still better to increase those three things too much and be sure that they won't overflow at any moment...
I just wanted to be sure that 'unused' space is really not used and i can safely use it to the end... |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Feb 15, 2016 6:58 pm Post subject: |
|
|
local variables use the "Frame" they use dynamic memory, when you leave the procedure, memory is again available.
I use a lot of sub and function in my programs and I never use " gosub " anymore.
and of course ! is so nice : Config Submode = New
and Goto ?
only for a soft reset
Goto 0
do you know an other way ?
jp |
|
Back to top |
|
|
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Mon Feb 15, 2016 7:17 pm Post subject: |
|
|
Well, i'm not very experienced programmer, so "goto" is still on my list, unfortunately. I know, it's not professional, but...i'm learning... so far i've only had projects with enough RAM space, so i was be able to "waste" it... |
|
Back to top |
|
|
|