GOSUB/de
From MCS Wiki AVR
Contents |
Funktion
Verzweigt zu einer SUB-Routine.
Syntax
GOSUB label
Anmerkungen
Label |
Der Name des Labels zu dem verzweigt wird. |
Mit GOSUB springt der Programmablauf zu dem angegebenen Label und führt den nachfolgenden Programmcode aus.
Trifft die Programmausführung auf den Befehl Return, wird wieder mit der Ausführung des Programms nach dem Aufrufenden GOSUB fortgefahren.
Siehe auch
Beispiel
'----------------------------------------------------------------------------------------- 'name : gosub.bas 'copyright : (c) 1995-2005, MCS Electronics 'purpose : demo: GOTO, GOSUB and RETURN 'micro : Mega48 'suited for demo : yes 'commercial addon needed : no '----------------------------------------------------------------------------------------- $regfile = "m48def.dat" ' specify the used micro $crystal = 4000000 ' used crystal frequency $baud = 19200 ' use baud rate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 ' default use 40 for the frame space Goto Continue Print "This code will not be executed" Continue: 'end a label with a colon Print "We will start execution here" Gosub Routine Print "Back from Routine" End Routine: 'start a subroutine Print "This will be executed" Return 'return from subroutine
Languages | English • Deutsch |
---|