The Keystone assembler framework, now available for JavaScript.
Keystone.js is a port of the Keystone assembler framework for JavaScript+WASM, powered by Emscripten. The released 4.2 MiB bundle supports the architectures: ARM, ARM64, EVM, Hexagon, MIPS, PowerPC, SPARC, SystemZ and x86. Follow the Readme to compile a subset of these, with an average size of 300 KiB per platform.
Keystone is a lightweight multi-architecture assembler framework originally developed by Nguyen Anh Quynh et al. and released under GPLv2. None of its source code has been altered for this port.
To use Keystone.js in your web application, download and include it with:
<script src="keystone.js"></script>
or install it with the NPM command:
npm install @alexaltea/keystone-js
// Input: Assembly
const assembly =
`inc rax
call 0x10040
mov rax, qword ptr[rdx + 4]
sub esp, 0x100
pop rbx`;
MKeystone().then((ks) => {
// Initialize the encoder
var a = new ks.Keystone(ks.ARCH_X86, ks.MODE_64);
// Choose preferred syntax
a.option(ks.OPT_SYNTAX, ks.OPT_SYNTAX_INTEL);
// Assemble instructions
var result = a.asm(assembly);
console.log(result.failed); // false
console.log(result.count); // 5
console.log(result.mc); // Uint8Array([0x48, 0xFF, 0xC0, ...])
// Delete encoder
a.close();
});