Skip to content

Instantly share code, notes, and snippets.

View merryhime's full-sized avatar

merry merryhime

  • UK
  • 19:20 (UTC +01:00)
View GitHub Profile
@rygorous
rygorous / fma3_codegen.txt
Last active November 19, 2017 06:45
FMA3 codegen
So the general idea with FMA3 is that it's designed to have enough degrees of
freedom so you can just have a more general FMA4 op in the IR and pick the right
FMA3 op *very* late (ideally, after register allocation!).
The generalized FMA op looks like this:
dst = FMA ±src0, ±src1, ±src2
where at most one of the src's can be a memory operand. This computes
(±src0 * ±src1) ± src2. The two signs for src0 and src1 combine
@ecliptik
ecliptik / aarch64qemu.md
Last active August 16, 2023 11:03
Ubuntu 14.04 arm64 Port QEMU Configuration

Setting up a Ubuntu 14.04 or Debian 8 (jessie) arm64 VM

This is mainly a notes dump and should be used for reference. This guide assumes:

  • Ubuntu 14.04 (or Debian 8) hypervisor/host with bridge networking
  • Knowledge of qemu
  • Knowledge of debootstrap

Limitations of the qemu-system-aarch64 emulator on x86 include only being able to emulate one CPU and no KVM support.

# Poker II Firmware disassembly help tool.
original = IO.read("./Poker II original firmware.bin")
extracted = ""
original.each_byte{|b|
m = (((b & 0x0f) << 4) | ((b & 0xf0) >> 4)) ^ 0xff
extracted << m.chr
}
puts extracted
@ocornut
ocornut / (Archived) imgui_memory_editor.h
Last active January 1, 2024 04:27
Mini memory editor for dear imgui (to embed in your game/tools)
// Mini memory editor for Dear ImGui (to embed in your game/tools)
// Animated GIF: https://twitter.com/ocornut/status/894242704317530112
// THE MEMORY EDITOR CODE HAS MOVED TO GIT:
// https://github.com/ocornut/imgui_club/tree/master/imgui_memory_editor
// Click "Revisions" on the Gist to see old version.
@graphitemaster
graphitemaster / WORKING_AROUND_OFFSETOF_LIMITATIONS.MD
Last active June 3, 2024 08:05
Working around offsetof limitations in C++

Working around offsetof limitations in C++:

There is sometimes a situation in which one needs to get the relative offset of a structure field, common examples of this include serialization frameworks which aid to serialize objects, vertex attributes for rendering (D3D, GL.), etc.

The most common technique for getting this information is through the offsetof macro defined in stddef.h. Unfortunately using the macro in C++ comes with a new set of restrictions that prevent some (subjectively valid) uses of it.

@NocturnDragon
NocturnDragon / Swizzles.h
Last active October 15, 2023 01:20
Swizzles in Clang, GCC, and Visual c++
#include <stdio.h>
// #define CLANG_EXTENSION
// Clang compile with -O3
#define VS_EXTENSION
// https://godbolt.org/z/sVWrF4
// Clang compile with -O3 -fms-compatibility
// VS2017 compile with /O3
@hthh
hthh / a-diff.py
Last active March 10, 2024 23:47
Switch IPC changes
from data1 import data1
from data2 import data2
from data3 import data3
from data4 import data4
from data500 import data500
from data600 import data600
from data610 import data610
from data700 import data700
all_data = (data1, data2, data3, data4, data500, data600, data610, data700)
@wareya
wareya / find.py
Last active March 13, 2018 00:04
search for han characters based on a list of components
#!python
# coding=utf-8
# Get ids.txt from https://github.com/cjkvi/cjkvi-ids/ and place it next to this script
# ~requires python 3.6 or newer on windows~
# note: depends on the accuracy of ids.txt. for some characters, like 祭, it's pretty bad.
# see also: http://www.chise.org/ids-find
contains = {}
# Polyrhythmic Prime Discovery
# by Leonard Ritter <contact@leonard-ritter.com>
primes = []
phases = []
counter = 2
def is_any_phase_zero ():
@imbushuo
imbushuo / simplevm.c
Last active April 8, 2024 07:06
Demonstrates Hypervisor.Framework usage in Apple Silicon
// simplevm.c: demonstrates Hypervisor.Framework usage in Apple Silicon
// Based on the work by @zhuowei
// @imbushuo - Nov 2020
// To build:
// Prepare the entitlement with BOTH com.apple.security.hypervisor and com.apple.vm.networking WHEN SIP IS OFF
// Prepare the entitlement com.apple.security.hypervisor and NO com.apple.vm.networking WHEN SIP IS ON
// ^ Per @never_released, tested on 11.0.1, idk why
// clang -o simplevm -O2 -framework Hypervisor -mmacosx-version-min=11.0 simplevm.c
// codesign --entitlements simplevm.entitlements --force -s - simplevm