Skip to content

Instantly share code, notes, and snippets.

View balt-dev's full-sized avatar

Balt balt-dev

  • 06:24 (UTC -05:00)
View GitHub Profile
@balt-dev
balt-dev / objection.md
Last active November 22, 2024 01:40
Objection!

Objection

Objection is a (currently unimplemented) interpreted programming language with one tenet: anything and everything is an object.

Objective C's syntax highlighting will be used for examples here, as it fits pretty well.

Types

Primitives

  • char, uchar, short, ushort, int, uint, long, ulong
    Stores an integer with varying precision. \
@balt-dev
balt-dev / average_video.py
Last active January 3, 2024 20:38
Average of all video frames in a video
import cv2
import numpy as np
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
def main():
# Get the file name
args = sys.argv [1:]
-- From https://gist.github.com/kedarmhaswade/ca46b689652b98e0bbdb995e1dd615ec
local element_list = [[
Muonium,Mu,0
Hydrogen,H,1
Helium,He,2
Lithium,Li,3
Beryllium,Be,4
Boron,B,5
Carbon,C,6
@balt-dev
balt-dev / twiddle.md
Last active November 19, 2024 21:43
twiddle - a fantasty 16-bit microprocessor

twiddle - a fantasty 16-bit microprocessor

8 bits in a byte, 2 bytes in a word.

Registers

All registers are 16-bit little-endian. There are 8 registers, being X, Y, Z, O, A, S, P, and C.

X, Y, and Z are general purpose, O is used as an offset in addressing, A is used for math, S is used as a hardware stack pointer (grows down),

Twidl - A 6502-inspired 8-bit microprocessor
Each instruction listed has an 8-bit value. A letter denotes a value used by the instruction.
0000 CCCC - INT - Sends an interrupt of the given 4-bit code if bit 6 of S is set. In a compliant implementation, code 0 must be a noop, and code 15 must jump PROG to the address specified at FFFE and FFFF.
0001 0RRR - TES - Sets bit 0 of S to whether the register is zero, sets bit 7 of S to bit 7 of the register.
0001 1III - CHK - Sets bit 3 of S to the bit of A at the index specified by the 3-bit number in I.
0010 0000 - NAN - Takes the NAND of the U register and the A register, and stores it in the A register.
0010 0001 - IOR - ^ but IOR
0010 0010 - AND - ^ but AND

uint and distinct type aliases

In Rust today, we have distinct primitive types for all integers. u8, u16, i64, usize, etc.

This works fine, and serves well as a way of handling numbers. Every programming langauge under the sun does this, and it works.

But we could do better.