//This demonstration shows how to:
//  *Use the state of an input in a conditional jump
//  *Use the "WAIT" command to wait until a position has been reached
//  *Use an infinite loop
//  *Specifiy and use symbolic constants
//  *Use a digital output
//  *Use a subroutine
//Run the program on a module and see what happens when you change the inputs #0 an #7.

//Symbolic constants
Large = 50000
Small = Large / 5

//Main program
Loop:      GIO 0, 0               //Get the state of digital input #0
           JC NZ, SmallWay        //Conditional jump to "SmallWay" if input #0 is high (not zero)

           MVP ABS, 0, Large      //Move large way
           JA MoveBack            //Jump to "MoveBack"

SmallWay:  MVP ABS, 0, Small      //Move small way

MoveBack:  WAIT POS, 0, 0         //Wait until the position has been reached
           SIO 3, 2, 1            //Set digital output #3 high
           MVP ABS, 0, 0          //Move back to zero
           WAIT POS, 0, 0         //Wait until that position has been reached
           SIO 3, 2, 0            //Set digital output #3 low

           CSUB Pause             //Call a subroutine

           JA Loop                //Jump to beginning of the infinite loop
 
//Subroutine
Pause:     GIO 7, 0               //Get the state of digital input #7
           JC ZE, Pause           //Loop until input #7 is low (zero)
           RSUB                   //Return to main program 

