
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
This is an emscripten-compiled version of the dasm macro assembler.
The dasm macro assembler transforms assembly code into 6502-compatible executable binary code. Since this is a JavaScript port of dasm, it allows that compilation process from JavaScript programs; more especifically, it can be used to create Atari VCS 2600 and Fairchild Channel F ROMs from a string containing dasm-compatible assembly source code.
In other words, it turns something like this:
; Pick the correct processor type
processor 6502
; Basic includes
include "vcs.h"
include "macro.h"
; Start address
org $f000
; Actual instructions
start SEI
CLD
LDX #$FF
TXS
LDA #$00
...
...into its equivalent byte code:
f000 78
f001 d8
f002 a2 ff
f004 9a
f005 a9 00
...
Among other features, dasm sports:
This package uses version 2.20.11 of dasm. It supports the following processor architectures:
This specific port was built on Linux (err, Windows 10 bash) from the dasm source using emscripten 1.37.0. Check the dasm folder for the script that was used to compile dasm.js
, including its pre/post-JS includes to wrap the code in a module function and return its results in a more usable way.
Install:
npm install dasm --save
Import as a module:
import dasm from "dasm"; // ES6
var dasm = require("dasm").default; // ES5
Finally, convert code to a binary data ROM. Instead of forcing developers to use a command line-like interface, the function that wraps the emscripten module provides a modern interface to dasm:
// Read utf-8 assembly source
const src = "...";
// Run with the source
const result = dasm(src);
// Read the output as a binary (Uint8Array array)
const ROM = result.data;
Advanced options can be passed to the dasm
call via an options parameter. For example:
// Create a rom using the typical Atari VCS 4096-byte format
dasm(src, { format: 3 });
// Just create a rom without exporting symbols or lists
dasm(src, { quick: true });
// Typical assembly to create an Atari VCS ROM with built-in .h includes
dasm(src, { format: 3, quick: true, machine: "atari2600" });
// Pass original command-line parameters
dasm(src, { parameters: "-f3 -p2 -v4 -DVER=5" });
These are all the options currently parsed:
format
: binary output format. Dictates the size and arrangement of the generated ROM.
1
(default): output includes a 2-byte origin header.2
: random access segment format. Output is made of chuncks that include a 4-byte origin and length header.3
: raw format. Just the data, no headers.quick
: boolean. If set to true
, don't export any symbol and pass list as part of its returned data. Defaults to false.parameters
: string. List of switches passed to dasm as if it was being called from the command line.include
: key-value object. This is a list of files that should be made available for the source code to include
. The key contains the filename, and the value, its content.machine
: target machine. Similarly to dasm's -I
switch, this picks a list of (embedded) files to make available to the include
command.
"atari2600"
: includes dasm's own atari2600/macro.h
and atari2600/vcs.h
files."channel-f"
: includes dasm's own channel-f/macro.h
and channel-f/ves.h
files.Check any cloned copy of the dasm documentation on GitHub for a list of all command-line switches available, and more information on binary formats.
The object returned by the dasm
function has more than just a binary ROM. This is what's available:
data
: Uint8Array
. The exported ROM, as a list of integers.output
: string[]
. All data written by dasm to stdout
.list
: IList[]
. A list of all lines available in the source code, and their parsed info (address, bytecode, comments, command, etc).listRaw
: string
. The raw output of the list file (equivalent to the -L
switch).symbols
: ISymbol[]
. A parsed list of all symbols (labels and constants) defined by the source code.symbolsRaw
: string
. The raw output of the symbols file (equivalent to the -s
switch).TypeScript definitions are included with this distribution, so TypeScript projects can use the module and get type checking and completion for all dasm
calls. Non-TypeScript JavaScript developers using Visual Studio Code will also benefit from auto-completion without any change thanks to VSC's Automatic Type Acquisition.
dasm-cli
)Contributions are welcome.
Check the release list for a list of what has changed in every new version.
This follows dasm itself and uses the GNU Public License v2.0.
FAQs
An emscripten-compiled version of the dasm macro assembler
The npm package dasm receives a total of 20 weekly downloads. As such, dasm popularity was classified as not popular.
We found that dasm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.