Skip to content

IF -K GO - Conditional Jump Flag Clear

Overview

Mnemonic: if-kgo Function: Conditional jump flag clear Class: BRANCH Privilege: user

Format: IF -K GO <<displacement>>


Description

Transfers control if K=0 (K flag clear). The K flag is a user-controlled flag that can be set with SETK and cleared with CLRK, providing a flexible condition for control flow.

Operation:

if K=0 then PC += displacement

Key Characteristics:

  • Tests K flag (user-controlled flag bit)
  • Independent of arithmetic operations (unlike Z, C, S)
  • Set with SETK, cleared with CLRK
  • Two displacement ranges (byte: ±127, halfword: ±32767)
  • Useful for custom state tracking in algorithms
  • Common in multi-phase algorithms and state machines

Operands: 1 Variants: 2


Variants

Variant Opcode Displacement
1/2 0x00D2 Byte
2/2 0x00D3 Halfword

Operands

Operand 1 (Displacement)

Signed displacement.


Trap Conditions

  • Branch trap (BT): If enabled

Data Status Bits

Unaffected.


Examples

Example 1: Basic usage

        CLRK
        IF -K GO K_CLEAR

Example 2: Loop control

LOOP:
        % loop body
        IF -K GO:B LOOP

Performance Notes

  • Cycles: 2-3 (not taken), 3-4 (taken)

Reference Manual

Section: §13.3 Title: Conditional Jump


See Also

  • IF=GO - Jump if equal
  • COMP - Compare
  • GO - Unconditional jump