SUBBIG
SUBBIG (SUBtract and jump if BIGger than zero) is an OISC by User:ChuckEsoteric08.
Description
SUBBIG has memory-mapped commands, with them being at the start of a memory and everything else being 0.
a b c
Subtract memory address b
from memory address a
and jump to memory address c
if result was bigger than zero. If you try to goto to address -1 program halts
I/O
a -1 c
Would set memory address a
to user input.
-1 b c
Would output memory address b
.
I/O Could be either character-based or integer-based depending on implementation.
Programming in SUBBIG
For simplicity we will use assembly-like syntax. Where
X:Y
Means "Declare label X
with value Y
". And :X
would return location of label X
.
a b NEXT
Means "Go to the next memory address".
a b HALT
Means "Execute command and halt".
Writing a program that prints "Hi"
Note that this program would only work in a version with character-based I/O:
-1 :H NEXT -1 :I NEXT -1 :! HALT H:72 i:105 !:33
First three lines are dedicated for outputing value of value of labels "H", "i" and "!" with last line ending in "HALT" so the program would halt without executing last line. Last line of code contains value of this labels.
In normal SUBBIG it would look like this:
-1 10 3 -1 11 6 -1 12 -1 72 105 33
Writing Truth-machine
This one is a little bit harder.
Version for character-based I/O
:X -1 NEXT :X :SUB :preloop -1 :X NEXT :X :NEG HALT preloop::X ADD :loop loop:-1 :X :loop X:0 SUB:48 NEG:-1 ADD:-48 0 0
First you need to type either 0 or 1 and store it in X. Then subtract 48 and if result was bigger than 0 goto label preloop where 48 is added to X and goto label loop where it prints X infinitly. Else We would print 0 and halt.
Here it is in normal SUBBIG:
19 -1 3 19 20 13 -1 20 9 19 21 -1 19 22 16 -1 19 16 0 48 -1 -48 0 0
Version with integer-based I/O
This version is a lot easier to do than in character-based I/O version:
:X -1 :loop -1 :X HALT loop:-1 :X :loop X:0 0 0
In normal SUBBIG:
9 -1 6 -1 9 -1 -1 9 6 0 0 0