Supporting a processor in Binary Ninja is about more than teaching a disassembler its opcodes. Our Architecture API lets plugins describe how instructions interact across parallel packets, pipeline stages, and entire functions. For Digital Signal Processors (DSPs), that flexibility is the difference between recognizing instructions and recovering the program they actually execute. For background on custom control-flow recovery, I recommend reading my earlier post on function-level basic block analysis.
In this post, we’ll demonstrate how we used our API to model Texas Instruments TMS320 C6x and produce useful
decompilation from its exposed instruction pipeline. We’ll start with parallel packets and compact instruction encodings,
then work through loads whose results arrive several cycles later, branches issued in other branches’ delay slots, and
software-pipelined loops. Even a block containing only a NOP can require context from earlier blocks to recover its
outgoing control flow.
For reverse engineers, the payoff is being able to follow calls, assignments, and loops instead of manually untangling instruction schedules. For architecture plugin authors, we’ll show how context-aware control-flow recovery, lifting, and disassembly make that possible – and how the same APIs can accommodate execution models that don’t fit an instruction-at-a-time approach.
Why DSP Analysis Needs Context
On an architecture such as x86, a lifter can usually translate an instruction using its bytes and address. Consider a load followed by an addition that uses the loaded register: the addition consumes the loaded value. The processor handles waiting for memory or forwarding the result internally. It may execute instructions out of order, but the decompiler can usually model their architectural effects in program order without reproducing the processor’s pipeline.
DSPs frequently expose scheduling decisions to software instead. A compiler can deliberately schedule an instruction to read a register’s old value while an earlier operation’s result is still in flight. Several parallel instructions can read the same incoming register state, and a branch opcode doesn’t necessarily mark the point where execution leaves a block. Treating these instructions as a sequence of immediate register assignments and jumps produces the wrong program – not just less attractive pseudocode. Getting the pipeline semantics right is a prerequisite for useful data-flow analysis and decompilation.

The C6x Execution Pipeline
C6x is a VLIW (Very Long Instruction Word) architecture that issues multiple instructions in parallel. Its two data paths,
associated with the A and B register files, each have four functional units: .L, .S, .M, and .D. These provide
arithmetic and logic, shift and control, multiplication, and address-generation and memory operations. An execute packet
can issue as many as eight instructions across those units. The compiler selects units and schedules work around their
dependencies and latencies; the suffixes in the disassembly, such as .d2 or .l1, identify those choices.
The processor fetches and decodes code, dispatches execute packets to the functional units, and advances the issued operations through execution stages. Issuing together does not mean finishing together. An integer operation can produce a result while a load or floating-point operation from the same packet is still progressing through its pipeline. Meanwhile, later execute packets can issue more work. Parallelism exists both within a packet and between operations from different packets that are in flight at the same time. This keeps the functional units busy in tight signal-processing loops instead of waiting for each load or multiply to finish before starting more work.
For a decompiler, the important difference from x86 is that this timing can change which values instructions read and where control goes. We don’t need to simulate caches or predict performance. We do need to preserve architecturally visible operand reads, register updates, and control transfers at the right points in the schedule. A packet-wide “read everything, then write everything” model is not sufficient when some writes belong several cycles in the future.
What Is an Instruction, Anyway?
Before looking at control flow, we need to distinguish three things in C6x:
| Unit | What it describes |
|---|---|
| Fetch packet | An aligned, 32-byte region fetched from instruction memory: eight 32-bit words. |
| Execute packet | A group of up to eight instructions issued in parallel. It is not necessarily the same size as a fetch packet and can cross a fetch-packet boundary. |
| Instruction | An individual operation within an execute packet. Depending on the encoding, it can occupy a full 32-bit word or a compact 16-bit halfword. |
A fetch packet containing compact instructions uses its final word as a fetch-packet header. The header identifies which words contain compact instructions and supplies additional decoding information, including parallel-execution bits. It is metadata, not another operation to execute. Consequently, eight fetch words do not necessarily mean eight instructions, and advancing by four bytes does not necessarily find the next instruction.
Consider the beginning of memset at 0x11805ea0:
The first three instructions are each two bytes long and belong to one execute packet. The || notation identifies
instructions issued in parallel with the preceding instruction. They copy the incoming values of a6 and a4 into
different destinations; they are not three sequential moves. The next execute packet begins at 0x11805ea6, halfway
through a fetch word.
Before we can model parallel execution, we first have to reconcile fetch-packet and execute-packet boundaries to identify the operations being issued. Control-flow recovery needs the header to find instruction and packet boundaries. The lifter needs the same interpretation to preserve parallel reads and writes. The disassembler needs it to display the correct instructions at the correct addresses. Giving each stage its own guess is an excellent way to make all three disagree.
Issuing an Instruction Is Not Completing It
Packet boundaries only solve the first part of C6x scheduling. Execution stages are conventionally named E1, E2, and
so on. An instruction begins execution at E1, but its effects need not all happen there. For a load, the address-register
update and the eventual destination-register write belong to different stages. The loaded result is written at E5;
the four intervening delay slots can contain instructions that still read the destination’s previous value.
These stages describe the progress of that load, not a pause in instruction issue. A new execute packet can begin while
the load advances to its next stage. In the memcpy below, four more execute packets issue between the packet containing
the byte load and the packet that stores its result:
The lifter must preserve both sequences: the issue order of those packets and the completion of the older load. If it
writes the loaded value into a3 immediately, intervening packets see it too soon. If it waits until E5 to evaluate the
load’s original inputs, those registers may already have changed. Simply moving one register assignment later does not
solve both problems.
Branches have their own timing: an ordinary branch has five delay slots before its transfer takes effect. Floating-point
and multiply operations introduce other result latencies, and some instructions have effects spread over more than one
execution stage. All of this is measured in execution cycles, not bytes or disassembly lines. Parallel instructions share
an issue cycle, while instructions such as NOP and BNOP can account for multiple cycles without occupying multiple
instruction addresses. Consequently, a count of the next few instructions is not a reliable substitute for a pipeline
model.
Our C6x lifter separates an instruction’s effects rather than assigning a single “execute later” time to the entire
instruction. For example, this execute packet appears in memcpy:
1180678c [a0] ldb.d2t1 *b4++[0x1], a3
11806790 || [a0] mvk.s1 0x2, a8
11806794 || mv.l1x b4, a9
The load uses b4 as its address, updates the base register, and eventually writes the loaded byte to a3. Those are
distinct effects. The parallel move into a9 must still see the old b4, and subsequent packets must not see the loaded
value in a3 before it becomes available.
To represent this in Low Level IL (LLIL), Binary Ninja’s architecture-level intermediate language, we capture the required packet-entry values in temporary registers. The load captures its memory value at issue and schedules the destination write separately. Its address update is not postponed until the loaded value arrives. Stores similarly have to use the appropriate source value and effective address before an addressing-mode writeback changes a register they depend on.
This distinction matters even if the final decompilation contains only a simple pointer increment and assignment. Delaying the entire load would read a potentially different address or memory value. Writing the destination immediately would let intervening instructions consume a value the DSP has not made available yet.
Predicates Are Inputs Too
The [a0] prefix means that the instruction executes when a0 is nonzero; [!a0] selects zero instead. Predication applies
to ordinary operations as well as control transfers. It does not mean that each predicated instruction starts a new
native basic block.
A delayed predicated operation must retain the decision made when it was issued. If another instruction changes a0
before the result is written, reevaluating the predicate at writeback can enable an operation that never executed – or
discard one that did. We snapshot the predicate where necessary and use that decision for the associated effects. For a
predicated load, that also means a false predicate must not produce a memory read or a later write of an uninitialized
temporary.
The same principle applies to an indirect branch’s destination: capture the target when the instruction reads it, rather than reading a possibly overwritten register when the branch finally takes effect.
A Branch in Another Branch’s Delay Slots
Delayed branches become particularly interesting when a second branch is issued before the first one completes. Consider
this sequence in __TI_decompress_rle_core:
On the b0 == 0 path, both branches execute. The branch at 0x1180558c eventually transfers to 0x1180563c. Before that
happens, the BNOP at 0x11805590 has already scheduled another transfer, this time to 0x11805578. The store and move
shown between them are real work, not padding to discard.
Execution reaches the NOP at 0x1180563c with the second branch still pending. That NOP occupies its remaining delay
slot, after which execution continues at 0x11805578. Looking only at the NOP’s opcode cannot tell us about that outgoing
edge. Its control-flow behavior depends on how execution reached it.
This breaks two tempting shortcuts. Ending the block at the first branch loses the delay-slot instructions. Extending it by a fixed number of following instruction addresses still doesn’t model a pending transfer that survives into the first branch’s destination. An instruction-level delay-slot count alone is not enough.
Our analyzer tracks pending control transfers, their predicates, and their remaining cycles while traversing the function. Successor blocks inherit the relevant state. A block can be revisited with a different incoming state, so its address alone is not sufficient to decide that analysis is finished. The function lifter consumes the recovered context and carries delayed effects across the corresponding edges instead of treating every block as an empty pipeline.
The result is that the control flow graph (CFG) and LLIL describe the same transfers. Recovering an edge is not enough: the lifter also needs the state that explains that edge. This is where packet-level context becomes function-level context, and where the ability to replace Binary Ninja’s default analysis and lifting algorithms becomes essential.
Software-Pipelined Loops
C6x’s software-pipelined loops add another dimension: work from different logical iterations overlaps in the execution pipeline. For example, one iteration can be loading data while an earlier iteration processes or stores its result. The initiation interval describes how many cycles separate the starts of successive iterations. It is not necessarily the number of instructions in the loop or the time required for one iteration to finish.
The loop buffer, iteration counters, and instructions such as SPLOOP, SPMASK, and SPKERNEL coordinate this execution.
There may be no ordinary branch instruction at the loop boundary. Correct analysis also has to distinguish the loading,
steady-state, and draining phases of the pipeline rather than assuming that every instruction in the byte range repeats
identically.
We can see this in memset. The setup writes the iteration count to ILC, and SPLOOP 1 selects an initiation interval of
one cycle. The kernel contains two parallel doubleword stores. SPMASK l2 marks the L2 operation in its packet as
prologue-only; Binary Ninja displays that operation with a ^ marker. Treating it as ordinary repeated kernel work would
change the program’s bookkeeping on every iteration.
As you can see, the recovered inner loop in High Level IL (HLIL) exposes the two stores, pointer advances, and iteration count. This is useful decompilation without making the analyst manually reconstruct a loop from packet headers and loop-buffer instructions. The register-pair notation in the excerpt is Binary Ninja’s concatenation notation, not original C source.
There is an important distinction between recovering that loop structure and providing stage-accurate modeling of every possible loop-buffer schedule. Our implementation includes a schedule-aware lifter for supported loop-buffer regions, including per-stage validity and delayed load results. Embedded loops such as the one above also retain a compatibility path that exposes useful bodies and continuations without claiming fully stage-accurate scheduling. Unsupported schedules must not be mistaken for a universally solved hardware-loop model.
Context matters for disassembly here too. Interpreting SPKERNEL’s packed stage/cycle operands requires the initiation
interval established by its associated SPLOOP. That information is not present in the SPKERNEL opcode itself. The
analyzer records the relationship so the disassembler can print meaningful operands instead of decoding the field in
isolation.
Connecting Analysis, Lifting, and Disassembly
These examples explain why adding more instructions to a decoder was not enough. We needed the architecture plugin to
participate at a broader scope, and the core to preserve its results for later consumers. Function-level control-flow
recovery was the first step: Binary Ninja 5.1 introduced analyze_basic_blocks so a plugin could build a function’s CFG
using more than individual branch opcodes. This was necessary for our Qualcomm Hexagon decompiler.
C6x required us to connect that recovery to function-wide lifting and contextual disassembly. Together, three complementary callbacks let a plugin carry its execution model through all three stages, shown here using their Python API names:
| Callback | Responsibility |
|---|---|
analyze_basic_blocks |
Recover a function’s blocks and edges using function- and view-level information, and record architecture-specific context. |
lift_function |
Generate LLIL for the complete function, coordinating operations across instructions, packets, and blocks. |
get_instruction_text_with_context |
Render disassembly using the architecture context produced during basic-block analysis. |
Sharing What We Already Learned
BasicBlockAnalysisContext
is the object supplied to analyze_basic_blocks. Besides creating blocks and recording edges, the plugin can assign its
own data to function_arch_context. For C6x, that includes fetch-packet headers, software-loop relationships,
prologue-only instructions, and incoming delayed-control-flow state. The analyzer has access to the function’s
BinaryView, so it can read the surrounding bytes needed to establish these facts.
FunctionLifterContext
supplies the recovered blocks and that same function_arch_context to lift_function. The lifter can prepare block
labels, retain native source-block attribution, and emit effects in semantic order rather than forcing each opcode to
produce its complete LLIL immediately. The plugin still owns the architecture’s scheduling rules; the API makes room for
them rather than imposing one universal DSP pipeline.
The core’s function-backed disassembly renderer passes the shared context to get_instruction_text_with_context, so
instruction widths, packet grouping, and contextual operands agree with the recovered function. Rendering consumes those
facts; it should not rebuild the CFG or advance a mutable pipeline every time the UI redraws an instruction.
From Pipeline Bookkeeping to Useful Decompilation
The goal isn’t to make analysts read a software model of a DSP pipeline. It is to model the architecturally visible behavior accurately enough that Binary Ninja’s existing data-flow analysis and decompiler can simplify it. Temporary registers, delayed effects, and predicate snapshots belong in the lifting machinery; ordinary calls, assignments, and loops belong in the output.
A C6x call-and-return sequence such as:
11806fa0 f654bc01 stw.d2t2 b3, *b15--[0x2]
11806fa4 28a84202 mvk.s1 0xffff8550, a4
11806fa8 69c00802 mvkh.s1 0x1180, a4
11806fac 12fcfd1f || callp.s2 printf, b3
11806fb0 2606 mvk.l1 0x0, a4
11806fb2 f771 ldw.d2t2 *++b15[0x2], b3
11806fb4 6e6c nop 0x4
11806fb6 efa1 bnop.s2 b3, 0x5
can be reduced to:
printf("Hello world!")
return 0
Behind those two lines are parallel instructions, compact encodings, a delayed load restoring the return address, and branch timing. The delayed branches and pipelined loops above require more context, but the goal is the same: expose the code’s behavior rather than its scheduling machinery. Recovering a graph, lifting the right semantics, and displaying consistent disassembly are parts of one problem, not three independent decoding tasks.
Our TMS320 C6x decompiler debuted in Binary Ninja 6.0 Ultimate Edition and has received significant improvements in the 6.1.11218 development build. These enhancements include numerous bug fixes, big-endian support, and expanded instruction coverage. If you’re interested in reverse engineering TMS320 C6x binaries with Binary Ninja, you can purchase Ultimate Edition!
If you’re developing an architecture plugin with packet encodings, hardware loops, or other context-dependent behavior, take a look at the context-aware analysis guide. It covers the callbacks, context objects, and responsibilities involved in replacing the default analysis and lifting algorithms. We’re excited to see what else the community builds with these capabilities!




