PDA

View Full Version : subroutine with hserin



volcane
- 17th December 2007, 20:23
Hi!

My main program calls a subroutine.

I wonder if the subroutine "ricezione" do not have the answer jumps on "accensione" then exiting from the first subroutine return of this command may be problems?

Main:
.........
gosub ricezione
.........
goto Main

ricezione:
.........
HSERIN 2000,accensione,[WAIT ("+CREG: "),Tm1,Tm2,Tm3]
.........
return

mister_e
- 17th December 2007, 20:27
depending how "accensione" is made i guess... that snip above doesn't help us ;)

volcane
- 17th December 2007, 21:34
depending how "accensione" is made i guess... that snip above doesn't help us ;)



accensione:
pause 2000
power=0
led=1
pause 2000
power=1
led=0
Pause 30000
gosub setup
goto partenza

What is the problem if I go out without a subroutine switch RETURN?

mister_e
- 18th December 2007, 04:19
Is it possible to see the whole program?

Usually for each GOSUB, there's a RETURN



Start:
Gosub Somewhere
Gosub Elsewhere
goto Start

Somewhere:
HSERIN 2000, SomeWhereElse,[DataXYZ]
Return

SomewhereElse:
ToGGLE LED
RETURN

ElseWhere:
LCDOUT $FE,1,"Are AZERTY Keyboards still on the market???"
RETURN

In Somewhere, if a timeout occure, it jump to SomewhereElse. This is basically a GOTO, BUT you need to use a RETURN to return to Start... or use a variant like...


Somewhere:
HSERIN 2000, SomeWhereElse,[DataXYZ]

SomewhereEnd:
Return

SomewhereElse:
ToGGLE LED
Goto SomewhereEnd


HTH

volcane
- 18th December 2007, 06:10
Ok

Thanks for the explanations

Best regards

volcane
- 18th December 2007, 21:28
Start:
Gosub Somewhere
Gosub Elsewhere
goto Start

Somewhere:
HSERIN 2000, SomeWhereElse,[DataXYZ]
Return

SomewhereElse:
ToGGLE LED
RETURN

ElseWhere:
LCDOUT $FE,1,"Are AZERTY Keyboards still on the market???"
RETURN


Somewhere:
HSERIN 2000, SomeWhereElse,[DataXYZ]

SomewhereEnd:
Return

SomewhereElse:
ToGGLE LED
Goto SomewhereEnd
[/code]

HTH


Then i can use two examples? The compiler detects if it is a routine principal or if it is a subroutine?

mister_e
- 19th December 2007, 02:56
Both example have to work. Once it hit a RETURN, it remove 1 from the stack level and jump one instruction bellow the last calling GOSUB.