tbb

Table Branch Byte

TBB [<Rn>, <Rm>]

PC-relative branch using a table of bytes (Switch statements).

Pseudocode Operation

index ← Rm; offset ← 2 × [Rn + index]; PC ← PC + offset + 4

Example

TBB [r1, r2]

Encoding

Binary Layout
111010001101
31:20
Rn
19:16
1
15
1
14
1
13
1
12
0
11
0
10
0
9
0
8
000
7:5
0
4
Rm
3:0
 
Format Thumb Branch
Opcode 0xE8D0F000
Extension T32 (Thumb)

Operands

  • Rn
    Table Base
  • Rm
    Index

Related

More in T32 (Thumb)

Reference

Instruction Forms

Encoding Instruction ISA Bit pattern
0xE8D0F000 TBB{<c>}{<q>} [<Rn>, <Rm>] T32 111010001101 | Rn | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 000 | 0 | Rm

Description

Table Branch Byte or Halfword causes a PC-relative forward branch using a table of single byte or halfword offsets. A base register provides a pointer to the table, and a second register supplies an index into the table. The branch length is twice the value returned from the table.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    integer halfwords;
    if is_tbh then
        halfwords = UInt(MemU[R[n]+LSL(R[m],1), 2]);
    else
        halfwords = UInt(MemU[R[n]+R[m], 1]);
    BranchWritePC(PC + 2*halfwords, BranchType_INDIR);