tw

Trap Word

tw TO, RA, RB

Traps if condition (comparison of words) is met.

Details

The Trap Word instruction compares the low-order 32 bits of register RA with the low-order 32 bits of register RB. If any of the specified conditions (Less Than, Greater Than, Equal, Less Than Unsigned, Greater Than Unsigned) are met and the corresponding TO bit is set, the system trap handler is invoked.

Pseudocode Operation

a ←EXTS((RA)32:63)
b ←EXTS((RB)32:63)
if (a < b) & TO0 then TRAP
if (a > b) & TO1 then TRAP
if (a = b) & TO2 then TRAP
if (a <u b) & TO3 then TRAP
if (a >u b) & TO4 then TRAP

Programming Note

Generates a program exception (System Call or Trap type) when the trap condition is true. The condition codes in TO select which comparisons trigger the trap: bit 0 = LT, bit 1 = GT, bit 2 = EQ, bit 3 = LU (unsigned), bit 4 = GU (unsigned). TO=31 (all bits set) always traps.

Example

tw 4, r4, r5

Encoding

Binary Layout
31
0
TO
6
RA
11
RB
16
4
21
 
Format X-form
Opcode 0x7C000008
Extension Base
Registers Altered CR0, CR1, CR6

Operands

  • TO
    Options
  • RA
    Src A
  • RB
    Src B