Skip to content

a standard library made in x86 assembly, including sockets, SHA1, base64 and more!

License

Notifications You must be signed in to change notification settings

NoamRothschild/asm

Repository files navigation

asm CC BY 4.0

Table of contents


a whole working standard library (non production ready use) built from the ground up in x86 assesmbly, and some projects using it

The stdlib

the stdlib includes:

  • common string operations (c-like strings)
  • debuggning functions (print, colored print)
  • file handling
  • multiprocessing wrappers (fork, shmget, shmat, mmap)
  • socket creating and handling
  • time formatting
  • shared data store managers (used for "databases")
  • simple HTTP library (client && server side)
  • websockets from scratch
  • SHA1 hashing
  • BASE64 encoding and decoding

NOTE: the misc folder is not related to the stdlib but includes some other 8086 projects, most notably snake

all of the code is x86 assembly. the project can only run under a linux kernel since it relies on its internal syscalls

stdlib docs

Projects made using it

A discord clone

image

  • clients can register or login to an existing account
  • credential verification + hashing of the important + cookie session creating, storing, and loading
  • talk on 4 different chats, each with their own history of messages and stream
  • clients are connected to the channels using websockets to receive messages in a full-duplex communication manner
  • routing of static files, custom paths, and websocket creation endpoints
  • profile picture uploading

NOTES: if you want to test it out yourself, open localhost:8000 (or use nginx to expose). make sure you are opening it using a chromium based browser since firefox has an unresolved issue with the login mechanism

Voxel Space Game

image

link to an old demo

The demo video perscribed is from an older with python as the renderer, that demonstrated the rendering, but all works visually the same when using the browser

How does it work?

  • The clients enters the browser, a canvas is created and a websocket is established
  • keystrokes of the user are sent through the websocket, to which the server (assembly) simulates, generates the next frame and sends back using the websocket the new buffer

For a great explanation about the rendering algorithm used, check out this amazing github page about Voxel Space.

NOTE FOR RUNNING:

revert the repo to commit 6877abe and run from game_prototypes. the stdlib has changed since and the renderer didnt update acordingly.

Compiling

Firstly install required packages:

apt-get install nasm
apt-get install binutils

And then compile using the build script:

./asm.sh %FILENAME%

or alternatively,

nasm -f elf "$1.asm"
ld -m elf_i386 "$1.o" -o "$1"

Documentation

documentation deployed here

Or, in the json file docs/docs.json.

calling conventions && understanding the docs

  • Arguments are provided through the stack by pushing them before calling (from bottom to top)
  • Retreive values from functions by poping them into a 32 bit register after call
  • All values passed back and fourth must be in chunks of 32 bits and no less (the size of a normal register)
  • [&] - Pass by reference (pointer to a specified memory region)
  • [#] - Pass by value (a 32 bit value)

This work is licensed under a Creative Commons Attribution 4.0 International License.

About

a standard library made in x86 assembly, including sockets, SHA1, base64 and more!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors