mips-inst
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

mips-inst

npm version

Convert between text and hex representation of MIPS instructions. Used as the basis for the mips-assembler package.

Supports the MIPS IV instruction set.

Usage

import { parse } from "mips-inst";

parse("jr ra");
// 0x03E00008

parse(`
  ADDIU SP SP 0xFFE0
  SW RA 0x18(SP)
  LW RA 0x18(SP)
  JR RA
`);
// [0x27BDFFE0, 0xAFBF0018, 0x8FBF0018, 0x03E00008]
import { print } from "mips-inst";

print(0x03E00008);
// "JR RA"

print([0x27BDFFE0,
  0xAFBF0018,
  0x8FBF0018,
  0x03E00008
]);
// ["ADDIU SP SP -0x20", "SW RA 0x18(SP)", "LW RA 0x18(SP)", "JR RA"]

print(0x27BDFFE0, {
  commas: true,
  include$: true,
  casing: "toLowerCase",
  numBase: 10
});
// "addiu $sp, $sp, -32"

// print also accepts an ArrayBuffer or DataView.

The distributed dist/umd/mipsinst.umd.js exports a MIPSInst global.

Development

To build:

npm install
npm run build

To run tests:

npm test

License

MIT

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i mips-inst

    Weekly Downloads

    16

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    75.3 kB

    Total Files

    15

    Last publish

    Collaborators

    • wnayes