http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Ask for help and support on things not being bugs. Help on how to program with ZX Basic, etc. Please, READ the How-To & Tutorials forum and Wiki before asking here: your question might already be answered.
oblo wrote:It happened to me during O-cman's development. I got this error because I putted a GOTO instead a GOSUB inside a SUBroutine, something like this:
10 REM main loop
20 stuff to do
30 GOSUB 100
90 GOTO 10
100 REM this is a SUB
110 stuff to do
120 GOTO 200
200 REM this is another SUB
210 more stuff to do
Line 120 must be GOSUB and not GOTO, that's why I got the Out Of Memory error. I don't know if this your case, but al least I hope gives you a clue.
boriel wrote:The code above is also ok, and should not produce any error. During execution time, every gosub must end with a return (to avoid stack overflow). Other than that, they needn't to be "balanced". If you execute the code above, it should work ok.
LCD wrote:I will check it again, and dramaticaly reduce the amount of gotos and gosubs later today. Maybe there are too many of them. After I added another gosub yesterday, I got the error already in level 2. I think, oblo is right, with gosub. Maybe a memory leak.
boriel wrote:LCD wrote:I will check it again, and dramaticaly reduce the amount of gotos and gosubs later today. Maybe there are too many of them. After I added another gosub yesterday, I got the error already in level 2. I think, oblo is right, with gosub. Maybe a memory leak.
It shouldn't be a memory leak, but a "Stack leak". GOTO == JP; RETURN = RET. It's pretty straightforward for the compiler.
I will add a "Stack check" flag to trap this.
Maybe your ORG is too low. Try setting it to ORG=30000
boriel wrote:The problem is, there is no stack zone. Stack is SP register. It's set automatically by the BASIC loader with the CLEAR statement (just below the ORG of your program). SP always grows downwards with each PUSH. When SP reaches 236XXX, for example, it's entering the ROM Variables area which are written very often (e.g. the FRAMES updates 50 times/sec), crashing your program.
A check could be comparing SP with a stack bottom mark (e.g. BASIC area Zone), or so, and raise an ERROR if SP gets into such area.
10 REM Program....
30 GOSUB 100
100 Bla bla bla
150 GOTO 10
160 RETURN: REM Never reached
oblo wrote:Boriel, I've just sent to you the code that failed. And yep, if I can recall correctly, my fault was that: a bad GOSUB/GOTO/RETURN combination
Users browsing this forum: No registered users and 0 guests