JXX-Commands: "Jump If ..."

<< Click to Display Table of Contents >>

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

JXX-Commands: "Jump If ..."

JIZ. - Jump-If-Zero

Previous Top Next


MiniRobotLanguage (MRL)

 

JIZ. Conditional Jump

Jump If Zero

 

Intention

 

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

 

VAR.§§TST=0

:try

' just jump without other features

JIZ.§§TST|over

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":

 

' We'll count from -20 to 0

VAR.§§TST=-20

:try

JIZ.§§TST>over

PRT.Hier

JMP.try

: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 code-example:

 

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

JIZ.$$NUM|:over

 

' we can use Labels that are in variables, too

: $$LAB=:over

JIZ.$$NUM|$$LAB

 

JIZ. is somehow the counterpart to JNZ. - Jump-if-not-zero .

 

 

 

Syntax

 

JIZ.P1P2P3

 

 

Parameter Explanation

 

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

 

P2 - can be an

   > increment-operator

   < decrement operator or

   | (Pipe Symbol) if no change of the value should happen

 

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

 

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

' JIZ - Example

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

VAR.§§TST=0

:try

JIZ.§§TST|over

PRT.Hier

:over

DMP.

MBX.!

END.

 

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

' Advanced JIZ - Example (using :Label)

' this one makes a JSR.-Jump.

' Also we packed the Label into a Variable

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

VAR.§§TST=0

: §§LAB=:over

:try

JIZ.§§TST|§§LAB

PRT.Here ...

DMP.

MBX.!

END.

 

:over

PRT.Was here first.

RET.

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

' JIZ - Example with Post-Increment

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

VAR.§§TST=-20

:try

JIZ.§§TST>over

PRT.Hier

JMP.try

:over

DMP.

MBX.!

END.

 

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

' JIZ - Example with Post-Decrement

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

VAR.§§TST=20

:try

JIZ.§§TST<over

PRT.Hier

JMP.try

:over

DMP.

MBX.!

END.

 

 

Remarks

 

-

 

Limitations:

 

-

 

See also:

 

    JIV. - Jump-If-Variable

    JIZ. - Jump-If-Zero

    JIN. - Jump if Not 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)