Skip to main content

Disassembler for TMS320C6x DSP family

Project description

TMS320C6x Disassembler

A pure python disassembler for the TMS320C6x family, currently supported up to ISA C674. Disassembles to python instruction objects for a configured ISA version.

This project is based on the TI C6X Disassembler included in libopcodes. The conversion scripts of this project are intended to parse opcode definitions from this source and convert them to JSON.

Usage

To make use of this library, create a Disassembler object for your ISA version. For an address and instruction bytes the disassembler returns a generator of instructions. The disassembly can optionally be limited to a number of (32-bit) words.

Please note that from version C64x+ the ISA supports header-based fetch packets (FPs). If such a version is specified, the disassembler requires knowledge about the last word of the FP to correctly disassembly instructions. Distinguishing between compact and regular instructions is only possible using the header (or the absence of one). Additionally, header information may be relevant for regular instructions (see protected loads). This library assumes no header if data ends in the middle of the FP and no header is specified. You can pass the header bytes (or last FP word in general) as a separate argument.

Example:

from tms320c6x_disassembler import Disassembler
from tms320c6x_disassembler.types import ISA

disassembler = Disassembler(ISA.C67XP)
instr = disassembler.disasm(bytes.fromhex('00000028'), 0x80)
str(next(instr)) # '00000080: mvk .S1 0, A0'

hb_disassembler = Disassembler(ISA.C674X)
instr = list(hb_disassembler.disasm(bytes.fromhex('6eec'), 0x80))
assert len(instr) == 0 # header word missing for compact instruction

instr = hb_disassembler.disasm(bytes.fromhex('6eec'), 0x80, header=bytes.fromhex('000020e0'))
str(next(instr)) # '00000080: nop  8'

Instruction Definitions

The source of truth for instructions, their encodings and semantics are the CPU and Instruction Set Reference Guides provided by TI. As mentioned above, the JSON definitions of the instructions are generated from header files from libopcodes. In some cases, the definitions in this repository differ from one of these sources.

This project updates the access information of the ADDK instruction. Only a write to the dst register is documented, but instead of reading the constant, this register should also be read. The register is treated as read+write here.

The following changes update the definitions of libobcodes in accordance with the reference guide. First, the flags of non-aligned load/store instructions were updated. All variants of these instructions should have the unaligned flag. Also, LDNDW/STNDW operands were updated to use scaled offsets. Lastly, the access information for BNOP and MVC was corrected to read in all cases. This is taken from the reference guide and seemingly incorrect in libobcodes.

For some instructions, the reference guide is not correct or at least less precise than libopcodes. The formats from libopcodes correct or specialize some formats, like for SPEKERNEL(R) and SPMASK(R). Additionally, libopcodes documents several errors in the reference guide for specific instructions. For example, a missing format for CMPGTU/CMPLTU instructions. In such cases, libopcodes is trusted.

Please also note that access information for memory operands does not document the register accesses in cycle 1 performed during address generation and optional base register update. Similarly, some instructions implicitly read control registers.

Contributing

Contributions are welcome. Please feel free to submit a pull request. Please refrain from purely AI-driven contributions (keep a human in the loop).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tms320c6x_disassembler-1.0.1.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tms320c6x_disassembler-1.0.1-py3-none-any.whl (47.3 kB view details)

Uploaded Python 3

File details

Details for the file tms320c6x_disassembler-1.0.1.tar.gz.

File metadata

  • Download URL: tms320c6x_disassembler-1.0.1.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for tms320c6x_disassembler-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a76e3d20b6e6b82e04731abd04debd10a2d98a1794c8b954dae144bb896a5dc0
MD5 0cb84a84f7c5c8f1e42a49b218719d00
BLAKE2b-256 eab10e54ec336953059210c02210c3b910772a9fdf9cd9f1d5592c19b5b838c8

See more details on using hashes here.

File details

Details for the file tms320c6x_disassembler-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tms320c6x_disassembler-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d91b53d45e947c85b6402b8431bf26d32829336edf7b1bb968c68bb47299295b
MD5 5a05cde42c144927a4fe7a11d37f836a
BLAKE2b-256 8a0018d6746df79abae14a54a725de46d109009d12be7b5939f347fe8e8650fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page