Torque

Torque is a lightweight meta-assembler that provides tools to write programs for any processor architecture.

This project was discussed on news.ycombinator.com and lobste.rs.

Overview

Torque is a meta-assembler that can be used to write programs for any processor architecture, designed around the idea that any assembly language can be emulated with just integers, bit sequences, labels, and sufficiently powerful macros. With Torque, the instruction encodings for a target processor are defined as a set of macros in the program source code itself, using templates to specify how values should be packed into ranges of bits. This allows programs to be written for any processor using only Torque and the datasheet for that processor.

Torque was created as an alternative to proprietary assemblers, and in particular as an alternative to assemblers for embedded platforms, which can often be clunky, bloated, poorly documented, or overly restrictive.

Installation

Source code for the torque assembler can be downloaded from code.benbridle.com/torque-asm.

The latest release is available as pre-built executables for Windows and Linux:

Build from source

To build the Torque assembler from source, first install the Rust compiler from www.rust-lang.org/tools/install, and then run cargo build --release inside the torque-asm source code directory.

The compiled binary will be created at ./target/release/tq.

Usage

The following command will assemble the Torque source file source and save the assembled output to the file destination as raw bytes.

tq [source] [destination] --format=raw

Tutorials

Documentation

Development

License

Torque is licensed under the MIT License. Feel free to use it, change it, and share it however you want.