Skip to content

Instantly share code, notes, and snippets.

View Ravenslofty's full-sized avatar
💭
Black lives matter.

Lofty Ravenslofty

💭
Black lives matter.
View GitHub Profile
-int readcmd(usbdevice* kb, const char* line){
+int readcmd(usbdevice* kb, const char* line)
+{
char* word = malloc(strlen(line) + 1);
int wordlen;
const char* newline = 0;
- const devcmd* vt = kb->vtable;
+ const devcmd* vt = kb->vtable;
usbprofile* profile = kb->profile;
- usbmode* mode = 0;
// AlignConsecutiveAssignments: true
// AlignConsecutiveDeclarations: true
int readcmd(usbdevice* kb, const char* line)
{
char* word = malloc(strlen(line) + 1);
int wordlen;
const char* newline = 0;
const devcmd* vt = kb->vtable;
usbprofile* profile = kb->profile;
usbmode* mode = 0;
(* TODO: PING, NOTICE *)
type nick = {nickname: string}
type privmsg = {channel: string; message: string}
type numeric = {code: int; nickname: string; message: string}
type verb = Nick of nick | Numeric of numeric | PrivMsg of privmsg | NoVerb
@Ravenslofty
Ravenslofty / ignore_crc.diff
Created June 25, 2018 21:30
An AFL testing harness for ocaml-imagelib
diff --git a/imagePNG.ml b/imagePNG.ml
index 19452e4..c73b651 100644
--- a/imagePNG.ml
+++ b/imagePNG.ml
@@ -171,16 +171,17 @@ module ReadPNG : ReadImage = struct
*)
let read_chunk ich =
let length = int32_of_str4 (get_bytes ich 4) in
if length >= 2147483647l || length < 0l then
raise (Corrupted_image "Size of chunk greater than 2^31 - 1...");
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 1 column, instead of 4 in line 2.
This file contains data to be turned into decoding logic for the EE CPU.
It has the following format:
1. Instruction format; e.g. R, I, RI, J etc
2. Mnemonic; e.g. SLL
3. Opcode; for ALU instructions this will be zero.
4-6. A register, or a constant value.
7. Shift amount, or a constant value.
8. ALU function; should be zero for non-R opcodes.
9. Code to execute upon getting this opcode.
@Ravenslofty
Ravenslofty / cuexmls.rs
Last active January 10, 2019 15:24
An Eldritch abomination for parsing CUE device XMLs
use std::{error, env, fs::File, io::{Read, Write}, str::FromStr};
use roxmltree::{Document, Node};
fn main() -> Result<(), Box<dyn error::Error>> {
let mut outfile = File::create("ids.txt")?;
for filename in env::args().skip(1) {
let mut contents = String::new();
File::open(filename)?.read_to_string(&mut contents)?;
let xml = Document::parse(&contents)?;
function x9fc42f20(s)
s:lui(15, 0, 7, 22, 8, 0); s:cycle_update(); s:bus_cycle_update();
s:addiu(9, 0, 3, 0, 0, 7); s:cycle_update();
s:dsll(0, 0, 3, 3, 16, 56); s:cycle_update(); s:bus_cycle_update();
s:bori(13, 3, 3, 8, 2, 3); s:cycle_update();
s:dsll(0, 0, 3, 3, 16, 56); s:cycle_update(); s:bus_cycle_update();
s:bori(13, 3, 3, 8, 20, 4); s:cycle_update();
s:bori(13, 7, 7, 0, 0, 16); s:cycle_update(); s:bus_cycle_update();
s:lui(15, 0, 2, 22, 8, 0); s:cycle_update();
s:sd(63, 7, 3, 0, 0, 0); s:cycle_update(); s:bus_cycle_update();
local c0_prid = 0x2E20LL
local k0 = c0_prid
local at = (k0 < 0x00000059LL) and 1LL or 0LL
local zero = 0LL
local branch_condition = (at ~= zero)
s.gpr[1] = at
s.gpr[26] = k0
if branch_condition then
return run[0xbfc00020]()
else
--- cc2/decode_mips.lua 2019-02-27 16:16:48.338797400 +0000
+++ sol/decode_mips.sol 2019-02-27 16:08:40.508730600 +0000
@@ -5,45 +5,51 @@
local mips_decode = {}
+typedef decode_handler = {
+ shift: int?,
+ mask: int?,
+ table: [function(table, int, int, int, int, int, int) -> bool, string, string?, bool]
#!/usr/bin/env python3
from migen import Array, Cat, Module, Signal
from migen import sim
from migen.fhdl import verilog
# 74LS153 dual 4:1 multiplexer
class IC74153(Module):
def __init__(self):
self.table0 = Array(Signal() for a in range(4))