set a base directory (just to make things easier)
$ basedir="$(pwd)"
set up Emscripten https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
$ cd "$basedir"
$ git clone https://github.com/juj/emsdk.git
#include <assert.h> | |
#include <fcntl.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <termios.h> | |
#include <unistd.h> | |
#include <sys/ioctl.h> | |
#include <sys/timerfd.h> |
#!/bin/sh | |
r2 -qc "e anal.bb.maxsize=2048;s sym.$2;af;agfj" "$1" | python3 control-flow-graph.py |
set a base directory (just to make things easier)
$ basedir="$(pwd)"
set up Emscripten https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
$ cd "$basedir"
$ git clone https://github.com/juj/emsdk.git
00: 902 !..! .... ..!. mov r0, 2 | |
01: cf0 !!.. !!!! .... mov [0xf0], r0 | |
02: 901 !..! .... ...! mov r0, 1 | |
03: cf1 !!.. !!!! ...! mov [0xf1], r0 | |
04: 912 !..! ...! ..!. mov r1, 2 | |
05: 923 !..! ..!. ..!! mov r2, 3 | |
06: dff !!.! !!!! !!!! mov r0, [0xff] | |
07: a19 !.!. ...! !..! mov [r1:r9], r0 | |
08: dff !!.! !!!! !!!! mov r0, [0xff] | |
09: a29 !.!. ..!. !..! mov [r2:r9], r0 |
# https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html | |
from bs4 import BeautifulSoup | |
soup = BeautifulSoup(open('jvms-6.html', encoding='ISO8859').read(), 'html.parser') | |
ops = { | |
div['title']: { | |
'words': len(div.find('div', {'class': 'literallayout'}).find_all('br')) - 1, | |
'opcodes': [ | |
int(p.text.split(' ')[2]) |
# this builds on https://gist.github.com/acdimalev/ff75aa864e49a41231d19c921132faf1 | |
# double-word division takes three input parameters and outputs two | |
# for ALU-type usage, it makes sense to re-use two of the input registers as output registers | |
# A : dividend high-word -> remainder | |
# B : dividend low-word -> quotient | |
# C : divisor | |
# long-division is accomplished by zeroing out the dividend high-word, |
// modprobe snd_pcm_oss | |
#include <fcntl.h> | |
#include <linux/soundcard.h> | |
#include <math.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/ioctl.h> |
from math import log | |
from random import random, randrange | |
sample = lambda: (randrange(1, 101), random()) | |
q = [ | |
(1 - y) * log(x) + y * x | |
for (x, y) | |
in (sample() for _ in range(1000)) |
#!/usr/bin/env python3 | |
# interactive log-log profiling visualizer with scales I personally find useful for microprocessor-scale optimizations | |
# usage: ./profile <depth> <filename> | |
# | |
# "depth" is basically the height of the graph | |
# it controlls how many samples are stored at any given time | |
# legend for reading the output |
from socket import create_server | |
MAX_SOCKETS = 1024 | |
BUFFER_SIZE = 4096 | |
sockets = [(0, None)] * MAX_SOCKETS | |
buffers = [b''] * MAX_SOCKETS | |
connections = [] |