NeoLoch Home Page
Home Inquisitor Tester Learning Lab Consulting Shipping Policy Contact us Support
Coming soon! 9060 Blade.
GOTO Command:
Status Flags Effected:

The GOTO command tells the program to jump to program address specified by the value k. K is usually represented in assembly language by a text label. However, "$" represents the current address that the program is currently at and "$" can be used to jump to, back from, or ahead of the current program counter.

Code Example 1: Follows are some examples of using GOTO to jump to specific addresses in program memory.  This program is, in essence, and endless loop. First the program will jump to the routine MAIN_2, which in turn tells the MCU to jump to the routine MAIN+1 (which is the NOP command), and then the program jumps to the current program counter - 2, which is the first GOTO command in the list.
     GOTO     MAIN_2
     GOTO     $-2

     GOTO     MAIN+1
A label defining this code block as MAIN.
Jump to the code block labeled MAIN_2
No operation.
Jump to the current address - 1, which would be the NOP.

A label defining this code block as MAIN_2
Go to the code block labeled MAIN plus 1 address.

Another example of an endless loop would be "GOTO $" which tells the program to jump to the current program address. The MCU will execute this command forever, or until you kill the power.

GOTO is useful command in the aseembly arsenal, but it shouldn't be used to replace the CALL (and RETURN) commands, which are more powerful when used correctly.

Secured by PayPal
Official PayPal Seal

All contents of this website are copyrighted 2010-2017 NeoLoch, LLC