Skip to content

The Command Line Tool ​

Install the oakasm tool globally:

bash
dotnet tool install --global MrKWatkins.OakAsm.Tool

Assembling ​

Assemble a project file to a binary:

bash
oakasm assemble MyProject.yaml Output.bin

Assembly errors are reported with source positions and the tool exits with a non-zero exit code. If the project's ORG directives leave gaps between blocks of code, the gaps are filled with zeroes in the output file so every byte is at the correct offset from the first block.

Disassembling ​

Disassemble a ZX Spectrum file (currently .z80 snapshots) to assembly:

bash
oakasm disassemble HungryHorace.z80              # To the console.
oakasm disassemble HungryHorace.z80 -o Out.asm   # To a file.

Disassembly starts from the snapshot's program counter and follows jumps, calls, DJNZ loops and RST vectors to discover reachable code.

OptionDescription
-o, --outputWrite the disassembly to a file instead of the console.
-e, --entry-point <ADDRESS>Extra entry point to disassemble from. Can be repeated.
--exclude-before <ADDRESS>Exclude routines before this address. Defaults to $4000, the start of RAM on the ZX Spectrum.
--no-follow-jumpsOnly disassemble linearly from the entry points.

Addresses are decimal, or hex with a 0x or $ prefix.

Disassembly Projects ​

Disassembly is iterative: run it, work out what an address is, record it, run again. A disassembly project keeps that knowledge in a YAML file so the generated assembly can be regenerated at any time — pass it to disassemble in place of the input file:

bash
oakasm disassemble HungryHorace.yaml
yaml
input: "HungryHorace.z80"
entry_points:
  - "0x6000"
exclude_before: "0x4000"
labels:
  "0x6000": start
  "0x6C40": print_score
data:
  - start: "0x7000"
    end: "0x77FF"
output: "HungryHorace.asm"
FieldDescription
inputThe file to disassemble, relative to the project.
entry_pointsExtra entry points, merged with any from the input file such as a snapshot's program counter.
exclude_beforeExclude routines before this address. Defaults to $4000.
labelsLabels for known addresses; used for the definition and everywhere the address is referenced.
dataRanges known to contain data. They are output as DEFB rows and never disassembled as code — recording these stops data being misread as garbage instructions.
outputThe file to write, relative to the project. Written to the console if not set.

Command line options override the project's settings. Output is deterministic, so rerunning after editing the project shows only the changes your new knowledge produced.

Formatting ​

Reformat an assembly file to a consistent style:

bash
oakasm format Main.asm                           # To the console.
oakasm format Main.asm -o Main.asm               # In place.
oakasm format Main.asm -c Formatting.yaml        # With a configuration file.
OptionDescription
-o, --outputWrite the formatted assembly to a file instead of the console.
-c, --configA YAML formatting configuration file controlling case, number formats and spacing.
--cpuThe CPU the assembly targets: Z80 (default) or Z80N.