Skip to content

Instantly share code, notes, and snippets.

View drguildo's full-sized avatar

Simon Morgan drguildo

View GitHub Profile

C data type sizes

C type Intel data type Assembly suffix Bytes
char Byte b 1
short Word w 2
int Double word l 4
long Quad word q 8
char * Quad word q 8
float Single precision s 4
#include <stdio.h>
#include <stdint.h>
typedef struct {
char a;
long b;
char c;
} Struct;
int main(int argc, char const *argv[])
@drguildo
drguildo / TIS-100.md
Last active June 27, 2021 13:06
TIS-100 Cheat Sheet

TIS-100 Cheat Sheet

Instructions

Name Syntax Name Syntax
NOP NOP JMP JMP <LABEL>
MOV MOV <SRC>, <DST> JEZ JEZ <LABEL>
SWP SWP JNZ JNZ <LABEL>
SAV SAV JGZ JGZ
@drguildo
drguildo / gist:8151017
Created December 27, 2013 18:48
Raspberry Pi /proc/cpuinfo
pi@raspberrypi ~ $ cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
@drguildo
drguildo / bisbic.c
Last active September 16, 2020 21:39
Solution to Practice Problem 2.13 in Computer Systems: A Programmer's Perspective.
#include <stdio.h>
void dump(unsigned int i) {
printf("%#08x = %d\n", i, i);
}
/* Declarations of functions implementing operations bis and bic */
int bis(int x, int m) {
return x | m;
}
fn foo1() {
let foo: Option<i32> = Some(1234);
println!("{}", foo.unwrap_or(4321));
let bar = foo;
}
fn foo2() {
let foo: Option<String> = Some("1234".to_string());
println!("{}", foo.unwrap_or("4321".to_string()));
const std = @import("std");
const fs = std.fs;
const warn = std.debug.warn;
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
const cwd = try fs.cwd().openDir(".", fs.Dir.OpenDirOptions{
import os
import streams
import system
import tables
var data: array[30_000, byte]
var dataPointer: int = 0
var instructions: seq[char]
var instructionPointer: int = 0
@drguildo
drguildo / morrowind-mods.md
Last active February 15, 2020 09:44
The Elder Scrolls III: Morrowind mods that I recommend.
  • mlox - Analyzes and sorts your plugin load order.
  • Official Plugins - Official plugins released by Bethesda exclusively for the PC version of Morrowind. Helm of Tohan was originally released online as a free pre-order exclusive, while the rest were published by Bethesda on their website.
  • Morrowind Optimization Patch - Improves performance and fixes some mesh errors.
  • Morrowind Code Patch - Fixes and improves various things (CTDs, save corruption etc.) in the Morrowind executable that can't be fixed with mods.
  • Patch for Purists - Tons of bug fixes that aren't in the official patches.
  • Expansion Delay - Fixes Bethesda's overly enthusiastic expansion hooks by delaying the Dark Brotherhood attacks and limiti
@drguildo
drguildo / covariance-and-contravariance.cs
Last active February 4, 2020 09:29
Covariance and contravariance.
static void SetObject(object o) { }
void Main()
{
// Assignment compatibility.
string str = "test";
// An object of a more derived type is assigned to an object of a less derived type.
object obj = str;
// Covariance.