Skip to main content

nyxstone-tricore-gcc (Python)

Python bindings to the NyxstoneTricoreGCC in-process TriCore assembler/disassembler.

Uses CFFI to compile a small C extension directly from the C++/C wrapper sources, linking in the bundled binutils-tricore prebuilt archives and gas object files. The build is self-contained -- no prior make step and no runtime shared library needed.

The API mirrors that of the sibling project Nyxstone (LLVM-MC based, covers LLVM-supported architectures; this package uses GNU binutils for TriCore). Six methods: assemble, assemble_to_instructions, disassemble, and disassemble_to_instructions mirror Nyxstone, plus assemble_with_relocs and assemble_to_instructions_with_relocs for gas -r-style relocation output. Each takes an absolute address (and for the assembly entry points, an iterable of LabelDefinition).

Install

pip install ./    # from the python/ directory

Or develop in-place:

python setup.py build_ext --inplace
PYTHONPATH=. python examples/smoke.py

Usage

from nyxstone_tricore_gcc import LabelDefinition, NyxstoneTricoreGCC

nx = NyxstoneTricoreGCC()

# Assemble.  Local branches get their displacement encoded directly.
bytes_ = nx.assemble("start:\n nop\n j here\nhere:\n ret\n", address=0)
assert bytes_ == b"\x00\x00\x3c\x01\x00\x90"

# Assemble with an external label.
bytes2 = nx.assemble(
    "nop\n j ext\n",
    address=0x1000,
    labels=[LabelDefinition("ext", 0x2000)],
)

# Disassemble to instructions.
for ins in nx.disassemble_to_instructions(bytes_, address=0x80000000):
    print(f"0x{ins.address:08x}  {ins.assembly}")

# Or as a single string.
print(nx.disassemble(bytes_, address=0x80000000))

# Limit the number of instructions decoded.
first_two = nx.disassemble_to_instructions(bytes_, address=0, count=2)

Errors

from nyxstone_tricore_gcc import NyxstoneTricoreGCC, AssembleError, SectionViolationError

nx = NyxstoneTricoreGCC()

try:
    nx.assemble("not_a_real_mnemonic %d4")
except AssembleError as e:
    print("encoder failed:", e)

try:
    nx.assemble(".data\n .byte 0x42\n")
except (SectionViolationError, AssembleError) as e:
    # The library is .text-only; data/bss/section .foo are rejected.
    print("non-.text section:", e)

Threading

Methods are safe to call from multiple threads, a process-wide threading.Lock serializes them.

Metadata

Release files for nyxstone-tricore-gcc 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nyxstone-tricore-gcc 0.2.3
File Size Uploaded Provenance Actions
nyxstone_tricore_gcc-0.2.3.tar.gz 4.6 MB Without provenance Details for nyxstone_tricore_gcc-0.2.3.tar.gz

Release files / nyxstone_tricore_gcc-0.2.3.tar.gz

Download URL nyxstone_tricore_gcc-0.2.3.tar.gz
Size 4.6 MB
Tags Source
SHA-256 checksum
How to use checksums
63141c34318e9b65cdb01adf39e472385db157f1109dbaa6cefe6b4d6c6e85fd
BLAKE2b-256 checksum
How to use checksums
8e112b0fc93d2086418764b15711d3a3730ac80f598644a8fec05dfe9ebb8042
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for nyxstone-tricore-gcc 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page