Crate glulx_asm

source ·
Expand description

This crate implements an assembler for the Glulx virtual machine for interactive fiction. It supports version 3.1.3 of the Glulx specification.

Currently, the functionality of this crate is limited to generating binary Glulx files from the in-memory data structures defined herein. It is designed and suitable as a library for use by translation tools that generate Glulx, but cannot be used as a standalone assembler. Display impls are provided for generating human-readable assembly listings, but the syntax is subject to change and there is no tool which parses what these impls emit. This crate may be extended with such functionality in the future.

This crate’s main entry point is the Assembly struct and its assemble method, which outputs a BytesMut (see the bytes crate) from the public fields you create the Assembly from.

The bulk of what you provide to the Assembly is a list of Items, each of which may be tagged with a label. The label parameter is generic; you can use any type you like provided only that it implements Clone + Eq + Hash. Do note that the assembler is a bit indiscriminant about cloning, so if you’re considering using Strings as labels you may want to use something like Rc<str> instead. Every type in this crate which takes a label parameter is, in the Haskell/loosely-category-theoretical sense, a functor over its labels. That is, it provides a map method which lets you replace every label within it with the output of a callback, possibly changing the label’s type.

See examples/hello.rs for an illustration of using this crate to assemble a story file that prints “Hello, Sailor!” and exits.

Modules§

  • Functions for concisely constructing items.

Structs§

Enums§

  • Errors that can occur during assembly.
  • Specifies how a function receives its arguments.
  • Argument to a function invoked from a decoding table.
  • A node in a decoding table.
  • Representation of a Glulx instruction.
  • An item of top-level content in a story file assembly.
  • An operand indicating where to get a value from.
  • An operand indicating where to put a value.
  • Placeholder for space in RAM that shoud be allocated at startup with initially-zeroed content.

Functions§

  • Creates an immediate operand out of the given f32.
  • Creates a pair of immediate operands out of the given f64, returned as (hi,lo).