Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Variabel list

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Tubeampman

Bascom Member



Joined: 27 Feb 2006
Posts: 100
Location: Bodo

norway.gif
PostPosted: Sun May 17, 2015 10:46 pm    Post subject: Variabel list Reply with quote

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
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Sun May 17, 2015 11:46 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
Tubeampman

Bascom Member



Joined: 27 Feb 2006
Posts: 100
Location: Bodo

norway.gif
PostPosted: Mon May 18, 2015 9:10 pm    Post subject: Reply with quote

Hi

Thanx for the answer Smile




Øyvind
Back to top
View user's profile
protoncek

Bascom Member



Joined: 16 May 2011
Posts: 52
Location: Slovenia

slovenia.gif
PostPosted: Mon Feb 15, 2016 12:18 pm    Post subject: Reply with quote

(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
View user's profile Visit poster's website
six1

Bascom Expert



Joined: 27 Feb 2009
Posts: 553

germany.gif
PostPosted: Mon Feb 15, 2016 2:11 pm    Post subject: Reply with quote

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"

Laughing

_________________
For technical reasons, the signature is on the back of this message.
Back to top
View user's profile
protoncek

Bascom Member



Joined: 16 May 2011
Posts: 52
Location: Slovenia

slovenia.gif
PostPosted: Mon Feb 15, 2016 3:46 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Mon Feb 15, 2016 6:58 pm    Post subject: Reply with quote

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 ?

Rolling Eyes
jp
Back to top
View user's profile Visit poster's website
protoncek

Bascom Member



Joined: 16 May 2011
Posts: 52
Location: Slovenia

slovenia.gif
PostPosted: Mon Feb 15, 2016 7:17 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum