Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Nested GOSUBs
Author | Message | ||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
I have been testing some code that I wrote that operates outputs at preset times. The code ran happily for about 5 days operating outputs until midnight that night when the code had to do some housekeeping (day of week etc)it crashed with the Error "Too many nested GOSUB" I have looked through the MMbasic Language Manual (V4) in particular the "Implementation Characteristics" area but cannot see a limit on the nesting of GOSUB's. Is there a limit and if so how would you check the number that the program has nested? |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
The topic came up for discussion about 12 months ago. http://www.thebackshed.com/forum/forum_posts.asp?TID=4469&PN =31 MM Basic has come a long way since then but I think the limits are still the same. Jim VK7JH MMedit MMBasic Help |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
Thanks TassyJim, In that discussion Geoff has stated that the limit is 250. This number seems to be ample but I will have to check back thru my code and set a counter to see where I am coming unstuck. |
||||
djuqa Guru Joined: 23/11/2011 Location: AustraliaPosts: 447 |
I would be totally revisiting the code 5 Nested GOSUB would be a nightmare to debug More than 250 Bloody Heck! VK4MU MicroController Units |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
Djuqa, The program has been trimmed to around 1100 lines of code, I have had to do this because I was running out of memory. If I have to do a major re-write I may have to put it on the back burner. BTW Even though there is no women around to hear him, she would know that he is still wrong. |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
250 is a lot. I suspect that there is a subroutine where it will call itself. That can get the count up real quick. Microblocks. Build with logic. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
In an effort to save a little memory later versions have reduced the maximum number of nested GOSUBs to 100. Still a lot. Geoff Graham - http://geoffg.net |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
Thanks for the update Geoff. As I havn't got enough memory for colour which version was wound down to 100 nested GOSUB's ? |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
Not sure without a lot of digging, probably 4.0. You can test it easily enough on the version that you are using. GOSUB TST
TST: A = A + 1 PRINT A GOSUB TST Geoff Graham - http://geoffg.net |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
Checked previous versions, Versions 3.XX have 250 nested GOSUB limit and Version 4.0X have 100 limit. |
||||
graynomad Senior Member Joined: 21/07/2010 Location: AustraliaPosts: 122 |
Even 100 is a limit you should never get remotely close to...unless of course you are doing some recursion. Rob Gray, AKA the Graynomad, www.robgray.com |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1101 |
I agree Rob, I'm not a programmer but nesting GOSUBs in some form of loop that would get up to 100, particularly recursion and with the practical limits of the MM seems like a recipe for debugging hell and a future nightmare in the making. Graeme, as an (not overly smart) observer, seems to me you might need to re-think your program structure. Not trying to teach you how to suck eggs, just a suggestion from my own experience, Regards, Doug. ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3802 |
For cute things like Sierpinski curves and various other mathematical curios you might use a lot of recursion but otherwise I'm with you that it's unlikely to be needed. Cmon Microchip let's have more RAM or an external memory bus... John |
||||
graynomad Senior Member Joined: 21/07/2010 Location: AustraliaPosts: 122 |
Yeah I've used recursion many times, easy enough but you can get into trouble. Rob Gray, AKA the Graynomad, www.robgray.com |
||||
Print this page |