bs2p: jumping to different banks resets variables?!?
trend
Posts: 112
Hello, I have a bs2p24 project in which the code is so large, we had to use 4 banks. Bank 0 has the main routine.. and a couple of subroutines. banks 1,2,3 have all subroutines.
The way the main routine accesses the subroutines (between different banks) is:
com = 1 (1 of course can be different depending on what subroutine I need to access)
RUN 2· (this is different depending on what bank I need to access)
and
in banks 1,2, and 3.. I have something like this:
Main:
IF com = 1 THEN PBScan········· 'from Bank 0 Main
IF com = 2 THEN contactscan
IF com = 3 THEN contactscan1
IF com = 5 THEN contactscan3
Of course, I have to declare the variables in each bank (?) so I do so like: com············ VAR···· Byte
my problem is that everytime the routine goes to a bank, the "com" is set/reset to 255... and thus doesn't run any of the subroutines.. I know it is 255 because I do a "debug ? com, cr"
do you'll have any ideas? is it because I am redeclaring the variable com in each bank? (I thought that.. but i do a debug ? cmd, cr before com gets first declared.. and it says com is 0.. i believe itwas 0.. it definitly wasn't 255)
thanks for any pointers! Lee
The way the main routine accesses the subroutines (between different banks) is:
com = 1 (1 of course can be different depending on what subroutine I need to access)
RUN 2· (this is different depending on what bank I need to access)
and
in banks 1,2, and 3.. I have something like this:
Main:
IF com = 1 THEN PBScan········· 'from Bank 0 Main
IF com = 2 THEN contactscan
IF com = 3 THEN contactscan1
IF com = 5 THEN contactscan3
Of course, I have to declare the variables in each bank (?) so I do so like: com············ VAR···· Byte
my problem is that everytime the routine goes to a bank, the "com" is set/reset to 255... and thus doesn't run any of the subroutines.. I know it is 255 because I do a "debug ? com, cr"
do you'll have any ideas? is it because I am redeclaring the variable com in each bank? (I thought that.. but i do a debug ? cmd, cr before com gets first declared.. and it says com is 0.. i believe itwas 0.. it definitly wasn't 255)
thanks for any pointers! Lee
Comments
If you need more variables and don't want to do all the copying, have a look at this article I wrote on how to put subroutines into extra program banks:
http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
thanks!
Lee
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office