We're looking for your comments on how to best organize the wiki's content.

IFG

From 0x10c Wiki
Jump to: navigation, search

IFG (If Greater) is one of the opcodes in the DCPU-16 specification. It represents an (unsigned) check that arg1 is strictly greater than arg2. If the check fails, the next operation is not executed.

Contents

[edit] Usage

 IFG arg1, arg2

[edit] Example

  :ifg_example
    SET A, [0x1000]   ; sets A to the data at address 0x1000
    SET B, 0          ; sets B to 0
    IFG A, B          ; checks if A > B
      SET Y, 1          ; if A <= B, this line is skipped and Y isn't set to 1
    SET PC, POP       ; returns subroutine

[edit] Signing dependence

IFG is only designed to work with unsigned numbers. For signed numbers, use IFA.

[edit] Processing

In binary machine code, this Basic opcode's five-bit representation is: 0b1 0100 (0x14)

The instruction has a takes two cycles to execute, plus one cycle if the check fails, plus any additional cycles necessary to evaluate the arguments. If a branching (i.e. an "if-something") instruction is skipped, one more instruction is skipped at the cost of one cycle. This allows conditionals to be chained together.

[edit] References

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox