JXX-Commands: "Jump If ..."

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > JXX. - Jump - Instructions >

JXX-Commands: "Jump If ..."

JNZ. - Jump-if-Not-Zero

Previous Top Next


MiniRobotLanguage (MRL)

 

JNZ. Conditional Jump

Jump is Not Zero

 

 

Intention

 

This command can be used to test a Variable for zero and Jump to a label if the variable is not zero. Here is a short example:

 

VAR.§§TST=-50

:try

VIC.§§TST

' just jump without other features

JNZ.§§TST|try

PRT.Hier

:over

DMP.

MBX.!

END.

 

Additionally the Command allows a "post-decrement" or alternatively a "post-increment" for easy Loop-Constructions. "Post-increment" will increment the given variable after the test inside the variable was done. Here is an example with "Post-increment":

 

VAR.§§TST=50

:try

DBP.Number is: §§TST

JNZ.§§TST<try

DBP.Hier

:over

DMP.

MBX.!

END.

 

The command can be switched from default mode (Jump Mode)  into "Gosub Mode" if you prefix the Label-Parameter P3 with a colon. Here is an example:

 

' will jump to the Label "over" in Gosub-Mode

JNZ.$$NUM|:over

 

' we can use Labels that are in variables, too

: $$LAB=:over

JNZ.$$NUM|$$LAB

 

JNZ. is somehow the counterpart to JIZ. - Jump-If-Zero .

 

 

 

Syntax

 

 

JNZ.P1P2P3

 

 

Parameter Explanation

 

P1 - Must be a Variable, like $$AAA or §§BBB or $$001

 

P2 - increment/decrement operator or just a | .

 

P3 - Label or Variable that evaluates to a Label.

         If it starts with a ":" (colon) a JSR. - Jump SubRoutine (Label) (GOSUB like)

        Jump is done instead of the normal JMP. - Jump to Label (GOTO like) Jump..

 

 

 

Example

 

'*************************************

' JNZ - Example

'*************************************

VAR.§§TST=-50

:try

VIC.§§TST

' just jump without other features

JNZ.§§TST|try

PRT.Hier

:over

DMP.

MBX.!

END.

 

'*************************************

' Advanced JNZ - Example (using :Label)

' the second one makes a JSR.-Jump.

' Also we packed the Label into a Variable

'*************************************

VAR.§§TST=10

: §§LAB=try

:try

DBP.The number is §§TST

JNZ.§§TST<§§LAB

JNZ.§§TST|:over

PRT.Hier

DMP.

MBX.!

END.

 

:over

DBP.Was here with §§TST

VDC.§§TST

RET.

 

'*************************************

' JNZ - Example

' with Post-Increment

'*************************************

VAR.§§TST=-50

:try

DBP.Number is: §§TST

' just jump without other features

JNZ.§§TST>try

DBP.Hier

:over

DMP.

MBX.!

END.

 

'*************************************

' JNZ - Example

' with Post-Decrement

'*************************************

VAR.§§TST=50

:try

DBP.Number is: §§TST

' just jump without other features

JNZ.§§TST<try

DBP.Hier

:over

DMP.

MBX.!

END.

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also:

 

    JIV. - Jump-If-Variable

    JIZ. - Jump-If-Zero

    JOR. - Jump On Repeat-Count

    JME. - Jump on More or Equal

    JLE. - Jump on Less or Equal

    JMP. - Jump to Label

    JSR. - Jump SubRoutine (Label)