This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constexpr uint64_t mask(int i) | |
{ | |
return (1ull << i) - 1; | |
} | |
float Round1(double tmp) | |
{ | |
uint64_t i; | |
memcpy(&i, &tmp, sizeof i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
echo Building GCC m68k toolchain... | |
mkdir -p sources | |
mkdir -p build | |
CORES=8 | |
TARGET=m68k-unknown-elf | |
PREFIX=$PWD/m68k-unknown-elf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__m128 Uint32_Float_Round(__m128i in) | |
{ | |
// Generate mask when input elements are > 2^31 - 1 | |
__m128i mask = _mm_srai_epi32(in, 31); | |
// Version of the input shifted down one bit logically | |
__m128i t = _mm_srli_epi32(in, 1); | |
// Add lowest bit of each word to round. | |
__m128i in1 = _mm_or_epi32(t, _mm_and_si128(in, _mm_set1_epi32(1))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Pure Lisp based assembler | |
(def my-fun (input1 :in d1 | |
input2 :in d2 | |
output :out d0) | |
(move.l input1 output) | |
(add.l input2 output)) | |
---------------------------------------------------------------------------------------- | |
; We can also have loop constructions by doing a macro (no need for it to be 'built-in') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type-safe varargs with C++11 variadic templates. | |
// | |
// Andreas Fredriksson <deplinenoise at gmail dott com> | |
// minor changes from: | |
// Thomas Hume <thomas dot hume at labri dot fr> | |
// | |
// This code is in the public domain. | |
#include <stdio.h> | |
#include <stdarg.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type-safe varargs with C++11 variadic templates. | |
// | |
// Andreas Fredriksson <deplinenoise at gmail dott com> | |
// | |
// This code is in the public domain. | |
#include <stdio.h> | |
#include <stdarg.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; clang++ --version | |
; Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn) | |
; Target: x86_64-apple-darwin12.2.0 | |
; Thread model: posix | |
Djb2HashNoCase(char const*): | |
.cfi_startproc | |
## BB#0: | |
pushq %rbp | |
Ltmp14: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t Djb2HashNoCase(const char *str_) | |
{ | |
const uint8_t *str = (const uint8_t *) str_; | |
uint32_t hash = 5381; | |
int c; | |
while (0 != (c = *str++)) | |
{ | |
#if 1 | |
// Branch free case folding for ASCII |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
def compute_chksum(data) | |
sum = 0 | |
(0...256).each do |x| | |
i = 4 * x | |
val = data[i,i+4].unpack('N')[0] | |
sum = sum + val | |
if sum > 0xffffffff | |
sum = (sum + 1) & 0xffffffff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import sys | |
import struct | |
def splice_checksum(block, chksum): | |
return block[0:4] + struct.pack('>I', chksum) + block[8:] | |
def makeit(fn, ofn): | |
f = open(fn, 'rb') |
NewerOlder