Jumps and Function Calls – Related TML Instructions and Data

Instructions

GOTO label        Unconditional jump to the address indicated by the label.
GOTO value16Unconditional jump to the address set in value16. Value16 is a 16-bit unsigned integer.
GOTO var16Unconditional jump to the address indicated by var16. Var16 is a 16-bit TML variable whose value is the jump address
GOTO label, var, condConditional jump to the address indicated by the label. Var is a 16 or 32-bit TML variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ
GOTO value16, var, condConditional jump to the address set in value16. Var is a 16 or 32-bit TML variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ
GOTO var16, var, condConditional jump to the address indicated by var16. Var is a 16 or 32-bit TML variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ
CALL label        Unconditional call from the address indicated by the function starting label (i.e. function name)
CALL value16Unconditional call from the address set in value16. Value16 is a 16-bit unsigned integer.
CALL var16Unconditional call from the address indicated by var16. Var16 is a 16-bit TML variable whose value is the TML function address
CALL label, var, condConditional call from the address indicated by the function starting label. Var is a 16 or 32-bit TML variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ
CALL value16, var, condConditional call from the address set in value16. Var is a 16 or 32-bit TML variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ
CALL var16, var, condConditional call from the address indicated by var16. Var is a 16 or 32-bit TML variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ
CALLS labelCancelable call from the address indicated by the function starting label.
CALLS value16Cancelable call from the address set in value16. Value16 is a 16-bit unsigned integer.
CALLS var16Cancelable call from the address indicated by var16. Var16 is a 16-bit TML variable whose value is the TML function address
ABORTAbort the execution of a TML function called with CALLS

RET        Return from a TML function

Remarks:

All labels mentioned in the GOTO or CALL instructions must exist i.e. must be defined somewhere in the TML program.
The label values are assigned after TML program compilation
When you call a TML function, the return address pointed by the IP (instruction pointer) is saved into the TML stack. When RET is executed, the IP is set with the last value from the TML stack, hence the TML program execution continues with the next instruction after the call. The TML stack dimension is 12 words. Each function call and TML interrupt service routine call uses one word of the TML stack
The body of the TML subroutines must be placed outside the main TML program, for example, after the END instruction.

Programming Examples        

GOTO label1, var1, LT;        // jump to label1 if var1 < 0

GOTO label2, var1, LEQ;        // jump to label2 if var1 <= 0

GOTO label3, var1, GT;        // jump to label3 if var1 > 0

GOTO label4;                        // unconditional jump to label4

CALL fct1, var2, GEQ;        // call function fct1, if var2 >= 0

CALL fct1, var2, EQ;                // call function fct1, if var2 = 0

CALL fct1, var2, NEQ;        // call function fct1, if var2 != 0

CALL fct1;                        // unconditional call of function fct1

CALLS fct2;                // unconditional cancelable call of fct1

...

END;                                // end of main program

fct1:

...

...

RET;

fct2:

...

ABORT;                        // abort function, return to next TML

// command after the CALLS

RET;

See also:

Jumps and Function Calls - TML Programming Details

TML Description