lc3asm

An assembler for Little Computer 3 (LC-3).

Usage no npm install needed!

<script type="module">
  import lc3asm from 'https://cdn.skypack.dev/lc3asm';
</script>

README

lc3asm.js

An assembler for Little Computer 3 (LC-3).

Installation

$ npm install lc3asm.js

Running

$ lc3asm <inputfile>.asm

This will generate inputfile.obj and inputfile.sym with the resulting object code and symbols respectively.

API

import Assembler from "lc3asm";

const asm = new Assembler(`
.orig 0
.fill 0
.end`, "filename"); // May throw a Peggy syntax error

asm.symbols(); // Returns a string
asm.object(); // Returns a Uint8Array

Syntax errors have a format() function that will generate nice output:

catch (e) {
  if (typeof e.format === "function") {
    console.error(e.format([{
      source, // must match what was passed to the Assembler constructor
      text,   // The text associated with that file
    }]));

Node.js CI codecov