Torque

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

This project was discussed on news.ycombinator.com

For a quick overview of the language, either read the language overview section of the manual, see this example of a completed program, or read one of the tutorials listed below.

For examples of advanced programming techniques in Torque, see the Examples page.

Background

Existing assemblers for proprietary platforms suffer from a number of issues. These assemblers tend to be poorly documented, provide languages that are clunky and verbose, be bloated and difficult to operate, or work only on one operating system. Development of C compilers is often a higher priority than the development of good assemblers.

Instead of learning a new assembler for every platform, it would be preferrable to instead use a single general-purpose assembler for every project. Torque was created to fill this niche.

Overview

Torque is a meta-assembler 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 encoding for a target processor can be defined as a set of macros in the program itself, using templates to specify how values are packed into ranges of bits. A program can be written for any processor using only Torque and the datasheet for that processor.

Installation

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

The latest release is available at tq-2.5.0 as a pre-compiled Linux executable.

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 in the chosen format.

tq [source] [destination] --format=<format>

Tutorials

Documentation

Development

License

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