npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts.asm

v0.0.5

Published

A X86_64 assember written in TypeScript. Chaining API. Supports macros. Advanced instruction support.

Downloads

3

Readme

asm.ts

X86_64 assember with a chaining API and auto-complete support.

Motivation

Learning assembly for real. Having fun while doing so. Feel free to join me in this; keep calm and PR! :)

Install

npm install ts.asm

# or

yarn add ts.asm

Usage

Example in ts.asm (a.k.a. TSASM):

import { asm } from 'ts.asm'

// standard-compliant x86_64 machine code
// this code creates a 512 byte bootloader which ends up
// in an infinite loop; can be loaded e.g. via QEmu, VMWare, v86, etc.
const machineCode = asm()
  .code()
  .label('hang') // declare label
  .jmp('hang') // jump to iself; initinite loop
  .macro((asm) => {
    // pad until 510 bytes are reached
    for (let i = 0; i < 510 - asm.$; i++) {
      asm.code().db(0x0)
    }
  })
  // this data is put at the end, packed in the data section
  .data()
  // internal big endian to little endian conversion
  .dw(0xaa55)
  // returns a Buffer (native in Node.js, polyfilled in browser)
  .assemble()

The same code in Netwide Assembler (NASM):

loop:
  jmp loop
times 510 -( $ - $$ ) db 0
dw 0xaa55

To assemple using NASM:

nasm boot_sect.asm -f bin -o boot_sect.bin

Current status

The x86_64 code generation backend is based on the original ass.js implementation. I'm still refactoring it, but the codebase seems to be stable and supporting even advanced instruction sets like SSE up to version 4.1. However, there is no guarantee on the stability. Please consider this project as a work in progress.

On top of the code generation backend, the TSASM library provides a chaining API. The chaining API allows for easy creation of complex assembly code. It features macros, code and data sections and several other features to improve the DX, like auto-completion and built-in label referencing.

However, the chaining API is in alpha stage and instructions are only added in a step-by-step progress, following TDD practices.

Future plans

For the future I'd like to add more features; please beware that this is no clear roadmap, just an unordered list of ideas that are driven by my own demand and interest. If you'd like to see some features, you're very welcome to PR! :)

  • [ ] Complete the chaining API (MVP-stage); e.g. via Proxy and interfaces
  • [ ] Parser for the NASM syntax and bridging to the chaining API
  • [ ] Executable file format support (Mach-O, ELF, PE)
  • [ ] Integration and testing with modern, widly-used linkers like lld
  • [ ] CLI tsasm with a NASM CLI compatibility
  • [ ] Support for more CPU architectures (namely aarch64 would be cool)

Learning Resources

Beginner course on assembler

https://www.youtube.com/playlist?list=PL9C96j-WSJzIGSzImXyK2Yec2Z0cbPZ5p

X86 Cheat sheets

OpCode table for x86_64: http://ref.x86asm.net/coder.html

Instruction set reference: https://www.felixcloutier.com/x86/

Low Level from 0 to hero

Low level from zero to hero (MIT OpenCourseWare) MIT 6.004 Computation Structures, Spring 2017 by Chris Terman https://www.youtube.com/watch?v=qyBuzeUYs2M&list=PLUl4u3cNGP62WVs95MNq3dQBqY2vGOtQ2&index=1

Complete course: https://ocw.mit.edu/courses/6-004-computation-structures-spring-2017/

Performance - and Assembly deep dive

MIT 6.172 Performance Engineering of Software Systems, Fall 2018 by Charles Leiserson https://www.youtube.com/watch?v=o7h_sYMk_oc&list=PLUl4u3cNGP63VIBQVWguXxZZi0566y7Wf

Complete course: https://ocw.mit.edu/courses/6-004-computation-structures-spring-2017/

Own Operating System course

A course on how to write your own operating system by Daedalus Community. https://www.youtube.com/watch?v=MwPjvJ9ulSc

Another course on writing your own operating system

Writing a Simple Operating System — from Scratch by Nick Blundell https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf