Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:14 27 Nov 2024 Privacy Policy
Jump to

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: Australia
Posts: 926
Posted: 07:22pm 28 Jan 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 6098
Posted: 09:50pm 28 Jan 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 926
Posted: 10:07pm 28 Jan 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 447
Posted: 11:00pm 28 Jan 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 926
Posted: 11:15pm 28 Jan 2013
Copy link to clipboard 
Print this post

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: Thailand
Posts: 2209
Posted: 12:07am 29 Jan 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 3194
Posted: 10:09pm 29 Jan 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 926
Posted: 11:05pm 29 Jan 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 3194
Posted: 11:35pm 29 Jan 2013
Copy link to clipboard 
Print this post

  Graeme Meager said   Thanks for the update Geoff. As I havn't got enough memory for colour which version was wound down to 100 nested GOSUB's ?

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: Australia
Posts: 926
Posted: 04:06pm 02 Feb 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 122
Posted: 01:43pm 03 Feb 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 1101
Posted: 10:20pm 05 Feb 2013
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 3802
Posted: 12:42am 06 Feb 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 122
Posted: 01:04am 06 Feb 2013
Copy link to clipboard 
Print this post

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


To reply to this topic, you need to log in.

© JAQ Software 2024