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§

concise
Functions for concisely constructing items.

Structs§

Assembly
Collection of all inputs needed to assemble a story file.
LabelRef
A reference to a label plus an offset.
MysteryString
A string whose encoding is defined by the IO system, but probably treated as Latin-1.
StringConversionError
Error returned when constructing a Utf32String or MysteryString from malformed input.
Utf32String
A string encoded as UTF-32.

Enums§

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

Functions§

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