simple rule : every gosub must have a RETURN at some point. Then it continues on the next line of code.
The processor hardware pushes the address of the next code on the hardware stack before it jumps to the label.
When a RETURN is found, the address is popped back from the stack so the code can continue.
When you only have gosub and never a RETURN it will give problems.
your example is not real good since it is not clear to me what happens.
But when you say we do not return in : never return from nowhere, there is no problem.
gosub test
print "high"
test:
goto test
return
that will not be a problem when it is intended that way.
So hard to give an answer for the example.
But simple advise : try to use goto little as possible.
this code will be bad :
main:
gosub test
print "abc"
end
test:
nop
goto main
return 'never executed so this will trash the stack _________________ Mark
Stricte about "no return"
I saw this many times because it can be a developer mistake and you dont get warning from the compiler because it can also be intended.
Next line will be executed.
This can easly be tested in the simulator.
First Gosub 123 will increase Test variable twice and then print it because no return.
Second Gosub 456 will increase Test only once and then print it.
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