Skip to content

Instantly share code, notes, and snippets.

View howerj's full-sized avatar

Richard James Howe howerj

View GitHub Profile
@howerj
howerj / subleq-bitwise.c
Created February 4, 2021 17:57
Using operations easily available on a SUBLEQ OISC (One Instruction Set Computer) to compute bitwise and/or/xor
/* Author: Richard James Howe
* Email: [email protected]
* Using primitives available in SUBLEQ to perform bitwise operations */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define N (16)
#define TST (9999)
@howerj
howerj / eforth.c
Created February 18, 2021 19:25
eForth for SUBLEQ in one file
#include <stdio.h> /* [email protected], Richard James Howe */
int main(void){short p=0,m[65536] = { /* eForth for 16-bit SUBLEQ */
0,0,40,7,3168,-32768,-2,-1,1,2,16,0,5646,7642,8728,10118,11034,8728,0,0,0,
0,0,0,0,0,11492,0,0,10,-1,0,0,11474,0,3358,-32768,-32768,32512,32512,37,37,
43,36,0,46,0,37,49,0,0,52,39,39,55,38,0,58,0,39,61,0,0,64,18,18,67,12,0,70,
0,18,73,0,0,76,19,19,79,18,0,82,0,19,85,0,0,88,7,18,91,106,106,94,19,0,97,0,
106,100,0,0,103,21,21,106,0,0,109,0,21,112,0,0,115,19,19,118,21,0,121,0,19,
124,0,0,127,35,21,130,21,0,136,0,0,139,0,0,154,153,153,142,19,0,145,0,153,
148,0,0,151,0,0,154,7,39,157,193,193,160,39,0,163,0,193,166,0,0,169,194,194,
172,39,0,175,0,194,178,0,0,181,200,200,184,39,0,187,0,200,190,0,0,193,0,0,
@howerj
howerj / if.c
Created April 6, 2023 21:39
Operators for comparision using only SUBLEQ
/* This short program uses Less-Than-Or-Equal-To-Zero
* to create the various signed comparison operators.
*
* The reason for this program is to understand how
* those operators can be implemented on a SUBLEQ
* One Instruction Set Computer.
*
* It is trivial to construct addition, subtraction
* and branching with the SUBLEQ machine, but the
* comparison and bitwise operators are more complex.