Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Problem Understanding CONFIG SUBMODE = NEW

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

Bascom Member



Joined: 13 Aug 2007
Posts: 376

newzealand.gif
PostPosted: Fri Sep 13, 2019 8:38 am    Post subject: Problem Understanding CONFIG SUBMODE = NEW Reply with quote

Historically. I have been using submode = old, and I am reluctant to change because my program is 8000 lines long, with many units in the field.
But I am considering it.

I have a question- the help for submode says
Quote:

When working with $include files, this requires that you insert an $include file with the SUBS/FUNCTIONS at the end of your code, and that you insert an $include file with the DECLARE statements at the start of your code.


Does this mean that when using submode = old, there needs to be TWO iterations of $include? One at the end of the code and one with the declarations?

This is confusing because the help for $include says
Quote:
An include file will only be included once, even if you include it multiple times.


(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.8.2 )

_________________
Neil
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4774
Location: Holland

blank.gif
PostPosted: Fri Sep 13, 2019 9:04 am    Post subject: Reply with quote

it means what it says.
But there are 2 different include files. Like this :

$regfile...
$include "myheaders.inc"

your code

$include "mysubs.inc"


myheaders.inc would have content like :
declare sub test()

and mysubs.inc would have the implementation like:
sub test()
..
end sub



When using submode=new, there is no need for a declaration as they are extracted from the implementation. And you must put the implementation before the main code since otherwise the calling code has no idea about these subs and functions.

In that case the code will end up after your code and only the used modules are included. in the old way, the code ends up where you put it.
For that case it is needed that the implementation goes behind the code. and since the calling code has no idea in that case, you must put the declaration in front.
Otherwise consider this :

your code
...
sub test
nop
end sub

the main code would walk into the sub and get a return without calling.
submode=new will remove that code and put it automatic behind your code and only the modules that were actually used.

_________________
Mark
Back to top
View user's profile Visit poster's website
njepsen

Bascom Member



Joined: 13 Aug 2007
Posts: 376

newzealand.gif
PostPosted: Fri Sep 13, 2019 9:57 pm    Post subject: Reply with quote

Thankyou mark for taking the time to explain that.

You said:
Quote:
Otherwise consider this :

your code
...
sub test
nop
end sub

the main code would walk into the sub and get a return without calling.

and I dont understand this in the context that my code ( which I assume is what most people do) is this:
Code:

declarations etc
do
   my code
   call subs & functions
loop

sub()
end sub

sub()
end sub

function
end function

etc
end
[/code]
_________________
Neil
Back to top
View user's profile
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