tw

Trap Word

tw TO, RA, RB

Traps if condition (comparison of words) is met.

Details

Compares the 32-bit signed values in RA and RB according to the trap condition bits in TO. If the condition is true, a program interrupt (trap) is generated; otherwise execution continues. The TO field encodes up to five independent comparison conditions (less-than, greater-than, equal, unsigned less-than, unsigned greater-than).

Pseudocode Operation

if (TO[0] & (RA <s RB)) | (TO[1] & (RA >s RB)) | (TO[2] & (RA = RB)) | (TO[3] & (RA <u RB)) | (TO[4] & (RA >u RB)) then
  Trap_Exception ← 1
else
  Trap_Exception ← 0

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