PDA

View Full Version : Goto inside a gosub??? Problems...



leonel
- 13th October 2005, 09:56
Hi...
There are any problem putting a goto inside a gosub?
Sometimes i have strange problems and i donīt see anything in my code that might cause this problems. The strange thing is sometimes doing the same precedure every thing works fine!
The only thing i have doubts one goto inside a gosub...
Regards

PaulJC
- 13th October 2005, 11:05
Post your code so people can have a look at it for you and then they may be able to provide an answer.

leonel
- 13th October 2005, 11:33
...
start:
...
if portb.1 = 1 then
gosub dez
portc.1 = 1
gosub dez
portc.2 = 1
gosub dez
portc.3 = 1
gosub dez
portc.4 = 1
gosub dez
endif

dez:
for i = 1 to 20
pause 10
if portb.2 = 1 then
goto start
endif
next i

Acetronics2
- 13th October 2005, 11:46
...
start:
...
if portb.1 = 1 then
gosub dez
portc.1 = 1
gosub dez
portc.2 = 1
gosub dez
portc.3 = 1
gosub dez
portc.4 = 1
gosub dez
endif

dez:
for i = 1 to 20
pause 10
if portb.2 = 1 then
goto start
endif
next i

I do not see any RETURN ... at the end of your sub ... the only chance to work is PortB.2 = 1 and others = 0 ... 15 chances of "punchthrough"
Alain

leonel
- 13th October 2005, 11:51
It was my mistake... I forgot to copy return, but it has!
Sorry but I don't understand what you want to say!

leonel
- 13th October 2005, 12:15
there are any way to clear my return adress saved on the stack?

PaulJC
- 13th October 2005, 12:17
What are you trying to achieve with the code, what do you have connected to the ports:

portb.1 - ?
portc.1 - ?
portc.2 - ?
portc.3 - ?
portc.4 - ?
portb.2 - ?

Cheers

Paul