Branch instructions



      beq      bge      bge_un      bgt
      bgt_un      ble      ble_un      blt
      blt_un      bne      br      br_long
      br_peq      br_pne      brfalse      brnonnull
      brnull      brtrue      switch 


 beq 
  ·  OperationBranch conditionally if int32 values are equal
  ·  Format
beq
offset
0
0
0
0
br_long
beq
offset1
offset2
offset3
offset4
  ·  Direct Format
{beq}
dest
  ·  Forms beq = 162 (0xA2)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type int32. If the values are equal, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with br_peq. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 bge 
  ·  OperationBranch conditionally if int32 values are greater than or equal
  ·  Format
bge
offset
0
0
0
0
br_long
bge
offset1
offset2
offset3
offset4
  ·  Direct Format
{bge}
dest
  ·  Forms bge = 170 (0xAA)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type int32. If value1 is greater than or equal to value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 bge_un 
  ·  OperationBranch conditionally if uint32 values are greater than or equal
  ·  Format
bge_un
offset
0
0
0
0
br_long
bge_un
offset1
offset2
offset3
offset4
  ·  Direct Format
{bge_un}
dest
  ·  Forms bge_un = 171 (0xAB)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type uint32. If value1 is greater than or equal to value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 bgt 
  ·  OperationBranch conditionally if int32 values are greater than
  ·  Format
bgt
offset
0
0
0
0
br_long
bgt
offset1
offset2
offset3
offset4
  ·  Direct Format
{bgt}
dest
  ·  Forms bgt = 168 (0xA8)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type int32. If value1 is greater than value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 bgt_un 
  ·  OperationBranch conditionally if uint32 values are greater than
  ·  Format
bgt_un
offset
0
0
0
0
br_long
bgt_un
offset1
offset2
offset3
offset4
  ·  Direct Format
{bgt_un}
dest
  ·  Forms bgt_un = 169 (0xA9)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type uint32. If value1 is greater than value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 ble 
  ·  OperationBranch conditionally if int32 values are less than or equal
  ·  Format
ble
offset
0
0
0
0
br_long
ble
offset1
offset2
offset3
offset4
  ·  Direct Format
{ble}
dest
  ·  Forms ble = 166 (0xA6)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type int32. If value1 is less than or equal to value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 ble_un 
  ·  OperationBranch conditionally if uint32 values are less than or equal
  ·  Format
ble_un
offset
0
0
0
0
br_long
ble_un
offset1
offset2
offset3
offset4
  ·  Direct Format
{ble_un}
dest
  ·  Forms ble_un = 167 (0xA7)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type uint32. If value1 is less than or equal to value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 blt 
  ·  OperationBranch conditionally if int32 values are less than
  ·  Format
blt
offset
0
0
0
0
br_long
blt
offset1
offset2
offset3
offset4
  ·  Direct Format
{blt}
dest
  ·  Forms blt = 164 (0xA4)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type int32. If value1 is less than value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 blt_un 
  ·  OperationBranch conditionally if uint32 values are less than
  ·  Format
blt_un
offset
0
0
0
0
br_long
blt_un
offset1
offset2
offset3
offset4
  ·  Direct Format
{blt_un}
dest
  ·  Forms blt_un = 165 (0xA5)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type uint32. If value1 is less than value2, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.


 bne 
  ·  OperationBranch conditionally if int32 values are not equal
  ·  Format
bne
offset
0
0
0
0
br_long
bne
offset1
offset2
offset3
offset4
  ·  Direct Format
{bne}
dest
  ·  Forms bne = 163 (0xA3)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type int32. If the values are not equal, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with br_pne. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 br 
  ·  OperationBranch unconditionally
  ·  Format
br
offset
0
0
0
0
br_long
br
offset1
offset2
offset3
offset4
  ·  Direct Format
{br}
dest
  ·  Forms br = 161 (0xA1)
  ·  Stack... => ...
   · Description In the first form, the program branches to the address pc + offset, where pc is the address of the first byte of the br instruction, and offset is a signed 8-bit quantity.

In the second form, offset is constructed by interpreting offset1, ..., offset4 as a 32-bit signed quantity in little-endian order.

   · Notes Branch instructions are always 6 bytes long, but may contain either short or long forms of a branch. The short form is always "opcode offset pad" where offset is an 8-bit offset and pad is 4 bytes of padding. The long form is always "br.long opcode loffset" where loffset is a 32-bit offset. This allows the code generator to output branch instructions with a uniform length, while the interpreter runs faster on short branches.


 br_long 
  ·  OperationModify a branch instruction to its long form
  ·  Format
br_long
opcode
...
  ·  Forms br_long = 178 (0xB2)
   · Description The br_long instruction modifies a branch instruction to take longer operands.
   · Notes The documentation for other branch instructions includes information on their long forms.

There is no direct format for this instruction, because br_long is not required for the direct encoding.



 br_peq 
  ·  OperationBranch conditionally if ptr values are equal
  ·  Format
br_peq
offset
0
0
0
0
br_long
br_peq
offset1
offset2
offset3
offset4
  ·  Direct Format
{br_peq}
dest
  ·  Forms br_peq = 176 (0xB0)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type ptr. If the values are equal, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with beq. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 br_pne 
  ·  OperationBranch conditionally if ptr values are not equal
  ·  Format
br_pne
offset
0
0
0
0
br_long
br_pne
offset1
offset2
offset3
offset4
  ·  Direct Format
{br_pne}
dest
  ·  Forms br_pne = 177 (0xB1)
  ·  Stack..., value1, value2 => ...
   · Description Both value1 and value2 are popped from the stack as type ptr. If the values are not equal, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with bne. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 brfalse 
  ·  OperationBranch conditionally if int32 value is zero
  ·  Format
brfalse
offset
0
0
0
0
br_long
brfalse
offset1
offset2
offset3
offset4
  ·  Direct Format
{brfalse}
dest
  ·  Forms brfalse = 173 (0xAD)
  ·  Stack..., value => ...
   · Description The value is popped from the stack as type int32. If value is zero, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with brnull. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 brnonnull 
  ·  OperationBranch conditionally if ptr value is not null
  ·  Format
brnonnull
offset
0
0
0
0
br_long
brnonnull
offset1
offset2
offset3
offset4
  ·  Direct Format
{brnonnull}
dest
  ·  Forms brnonnull = 175 (0xAF)
  ·  Stack..., value => ...
   · Description The value is popped from the stack as type ptr. If value is not null, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with brtrue. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 brnull 
  ·  OperationBranch conditionally if ptr value is null
  ·  Format
brnull
offset
0
0
0
0
br_long
brnull
offset1
offset2
offset3
offset4
  ·  Direct Format
{brnull}
dest
  ·  Forms brnull = 174 (0xAE)
  ·  Stack..., value => ...
   · Description The value is popped from the stack as type ptr. If value is null, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with brfalse. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 brtrue 
  ·  OperationBranch conditionally if int32 value is non-zero
  ·  Format
brtrue
offset
0
0
0
0
br_long
brtrue
offset1
offset2
offset3
offset4
  ·  Direct Format
{brtrue}
dest
  ·  Forms brtrue = 172 (0xAC)
  ·  Stack..., value => ...
   · Description The value is popped from the stack as type int32. If value is non-zero, then the program branches to pc + offset. Otherwise, the program continues with the next instruction.
   · Notes This instruction must not be confused with brnonnull. Values of type int32 and ptr do not necessarily occupy the same amount of space in a stack word on all platforms.


 switch 
  ·  OperationSwitch on uint32 value
  ·  Format
switch
max
defoffset
...
  ·  Direct Format
{switch}
max
defaddr
...
  ·  Forms switch = 179 (0xB3)
  ·  Stack..., value => ...
   · Description The value is popped from the stack as type uint32. If it is greater than or equal to max, then the program continues at pc + defoffset. Otherwise, the 32-bit signed value at pc + 9 + value * 4 is fetched and added to pc.
   · Notes The max value is an unsigned 32-bit value, and the defoffset is a signed 32-bit value. All 32-bit values are in little-endian byte order.


Copyright © Southern Storm Software Pty Ltd 2002
Licensed under GNU FDL