GOTO

From MCS Wiki AVR
Jump to: navigation, search

Contents

Action

Jump to the specified label.

 

 

Syntax

GOTO label

 

 

Remarks

Labels can be up to 32 characters long.

When you use duplicate labels, the compiler will give you a warning.

 

Valid labels

- A valid label ends with a colon (:)

- A valid label starts on the line.

- There is no space between the label name and the colon.

 

Label:  is a valid label.

Label :  is invalid

 

Since a colon is also used to separate multiple lines of code, the label must be the only code on the line.

For example :

 

print "abc" : print "klm"  'these lines are separated by a colon.

abc:  : print "klm"  'this is invalid since the line starts with a label.

 

Besides using a label you can also specify an address. GOTO &H0000  would jump to the reset vector of the processor.

Because numeric addresses can be specified, it is advised to use non-numerical labels. 

See also

GOSUB

 

 

Example


Dim A As Byte
Start: 'a label must end with a colon
A = A + 1 'increment a
If A < 10 Then 'is it less than 10?
 Goto Start 'do it again
End If 'close IF
Print "Ready" 'that is it

Languages   English • Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language