Skip to content

Instantly share code, notes, and snippets.

@dougallj
dougallj / gist:9211fd24c3759f7f340dede28929c659
Last active Jan 13, 2020 — forked from zwegner/gist:6841688fa897aef64a11016967c36f2d
Ternary logic multiplication (0, 1, unknown)
View gist:9211fd24c3759f7f340dede28929c659
N_BITS = 8
MASK = (1 << N_BITS) - 1
class Ternary:
def __init__(self, ones, unknowns):
self.ones = ones & MASK
self.unknowns = unknowns & MASK
assert (self.ones & self.unknowns) == 0, (bin(self.ones), bin(self.unknowns))
def __add__(self, other):
@dougallj
dougallj / asm.s
Created Jan 3, 2018
x86-64 Speculative Execution Harness
View asm.s
global _time_load
global _cache_flush
global _run_attempt
extern _bools
extern _values
extern _pointers
section .text
@dougallj
dougallj / draw-patterns.c
Last active Dec 29, 2020
All distinct 4x4 patterns
View draw-patterns.c
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#define WIDTH_IN_BLOCKS 29
#define HEIGHT_IN_BLOCKS 28
#define PADDING 4
#define BLOCK_WIDTH (4 * 4)
#define BLOCK_HEIGHT (4 * 4)