OISC

From Esolang
Jump to navigation Jump to search

OISC is the One Instruction Set Computer (by analogy with RISC and CISC), a machine providing only one instruction. The abbreviation URISC (Ultimate RISC) has been used in some publications with the same meaning as OISC.

A general focus of OISCs is to be the extremely simple and yet meaningfull (i.e. to allow memory, loops and computation as you know it).

An extremely simple OISC is FlipJump. Its instruction has 2 operands a;b: flip the bit addressed by a, and jump to address b.

A famous OISC language is subleq - subtract and branch if less or equal to zero. This language has three parameters, subleq(a,b,c) - subtracts a from b, stores the result in b, and then transfers control to the address in c if the result was non-positive. Another version is SBN - subtract and branch if negative, which only differ by zero-inclusion.

Another very simple OISC is BitBitJump. Its instruction has 3 operands as in Subleq, but the meaning is: copy the bit addressed by a to the bit addressed by b and jump to the address c. BitBitJump has a "big brother" ByteByteJump that copies 1 byte at a time instead of 1 bit. Both of these machines belong to a larger class of machines, WordWordJump, that copy b bits at a time but have address operands of size n*b, where n≥2 (e.g. 32-bit addresses and 8-bit data for a 32-bit WordWordJump machine). It is this feature that allows FlipJump, BitBitJump, ByteByteJump, and similar machines to perform arithmetic and conditional jumps through the use of self-modifying code.

Some languages use a memory mapped instruction pointer (as in RSSB). Branching is done by writing to IP in these implementations. More advanced memory mapping allows complex functionality such as arithmetic but with the benefit of having a simple copy operation (MOVE, or mov).

Some OISC languages are Turing-complete, making them Turing tarpits, while others are bounded-storage machines, more akin to physical CPUs. Turing-completeness requires the OISC to be defined with sufficient abstraction with respect to both addressing scheme and operand size. For example, Subleq uses absolute addressing and does not specify its operand size, so it is TC. BitBitJump, on the other hand, is defined to use bounded operand size and absolute addressing, so it is only a bounded storage machine. It is not known whether either of these languages with bounded operand size could achieve TC-ness by revising them to use relative addressing. It seems likely, however, because relative addressing is the Turing machine property.

Any OISC language belongs to either one of the two groups: with memory mapping (MOVE, RSSB) or without (Subleq, SBN, FlipJump, BitBitJump, ByteByteJump). Note, that a language from the second group may have an extension with memory mapped special addresses, but those addresses are not required for computations; they are used for IO or any other system calls.

List of OISCs

In this table, the OISC's command is given in C-like syntax. a, b, c, etc. are placeholders for arguments to the command, and are treated as literals (thus for example the INC command from x86 assembler would have its semantics written as (*a)++; it's incrementing the value at a specific address, so the address is literal and needs to be dereferenced once in order to produce the value at that address, which is the thing that is incremented). X, Y etc. are placeholders for "magic numbers" that allow multiple variants of an instruction, such as addressing modes. p, q, r, etc. are registers that are not memory-mapped. Many OISCs memory-map instructions (to allow for self-modifying code, often increasing their computational power), and/or the instruction pointer (to provide a method to implement loops). (Some OISCs also memory-map other things, like I/O, but this is not shown in the table below.)

Name Command Addresses Commands memory-mapped IP memory-mapped
abcout *a += *b; if (*a > 255) { *a %= 256; ip = c; } Absolute No No
Addbig *a += *b; if (*a > 0) goto c; Absolute Yes No
AddJump ++a; goto b; Absolute No No
Addo *a += *b; if ((*a % 2) != 0) goto c; Absolute No No
BitBitJump *b = *a; goto c; Absolute Yes No
Blues machine ++*a; *b *= *c; *d /= *e; if(*f) goto (g ? h : *h); Absolute No No
ByteByteJump *b = *a; goto c; Absolute Yes No
Cryptoleq *b = *b/*a; if (*b < 0) goto *c; Absolute Yes No
Decleq *b=*a-1; if (*b <= 0) goto c Absolute Yes No
DCI if(*a>0){--*a;if(b)*c=b;else *c=*d;} Absolute Yes Yes (address 1)
Divmeq if (x % a == 0) {x /= a; goto b;} Not used No No
Divrac *e = (a*d)/gcd(a*d, b*c); *(e+1) = (b*c)/gcd(a*d, b*c); Absolute
(some magic numbers)
No Partially
DJN (*b)--; if (*b ≠ 0) goto *a; Relative Yes No
FlipJump *a=~*a; goto b; Absolute Yes No
Flump if (b & *a) *a -= (*a & ~(b-1)) / 2;
else *a += (*a & ~(b-1)) + b;
if (!*a) goto *c;
Absolute Yes No
Hexagon says if b == n goto a;if b == d b +=c; if c == e printf(b); Absolute No No
Ichi cells[x % 2] += (int)(x / abs(x)); if (cells[x % 2] == -1) else goto abs(x) / 2;} Absolute No No
I/D machine *p += a; p = *p; Not used No No (implicit loop around program)
IDIJ (*a)++; (*b)--; if(*c==0) ip=d; Absolute No No
INJUQ *a+=*b; if (*a = *c) goto d; Absolute Yes No
JCLN b: if(a==-1)a=__LINE__; if(__LINE__==a) goto b;
//There has to be a "b" tag on every command.
Absolute Yes No
Lag a: b -= c; if (b == 0) goto d; Absolute No No
MISC *a = ((d & X) ? b : *b) - ((d & Y) ? c : *c);
goto *(d & ~X & ~Y);
Relative Yes No
Multleq *a *= *b; *a += *c; if (*a <= *d) goto e; Absolute Yes No
Nutes s = signum (*(x--)) + signum (*(x++)); *(x--) = *(x--) - *(x++); *(x++) = -*(x--); if (s < 0) goto *((*x)--); if (s == 0) goto **x; if (s > 0) goto *((*x)++); Relative No No
OISC:2 if a,b >= 0: *b = *b - *a; else special opcodes Absolute Yes Yes
OISC:3 if a,b,c >= 0: *c = *b - *a; else special opcodes Absolute Yes No
OISCalypse if(*p+a<0) ip=0; else *p+=a; p++; Not used No No
RSSB *a = *1 = *a - *1; Absolute Yes Yes
SBN (SBN2) *a = p = p - *a; if (p < 0) goto *b; Absolute No Yes
SBN (SBN3) X = X - Y; if (X < 0) goto *p; (aka subneg) Absolute No Yes
SBN (SBN4) Z = X - Y; if (Z < 0) goto *p; (aka subneg4) Absolute No Yes
Smaller a += b; if (a = 0) goto 0; Absolute No No
SUBBIG *a-=*b; if (*a > 0) goto c; Absolute Yes No
S*bleq *a-=*b; if (*a <= 0) goto *c; Absolute Yes Yes
Subleq *b = *b - *a; if (*b <= 0) goto c; Absolute Yes No
Subskin *c = *a - *b;
if (*c < 0) goto *(ip + 1);
Absolute Yes Yes
SICO if (*a <= *b) ip = c;
else *a -= *b;
Absolute Yes No
Simpler Subskin *a -= *b;
if (*a < 0) goto *(ip + 1);
Absolute No No (implicit loop around program)
Three Star Programmer (***a)++; Absolute No No (implicit loop around program)
Tip ip *= a; Absolute No (program repeats forever) No (but halt on IP 0)
TOGA computer not *a; if (*a) goto b; Absolute No No
XOṘ Mạchịne a ^= b; /*or any command like this*/ printf("%d",a>b); Not used No No

Additionally, the non-esoteric transport triggered architecture also has only one instruction, move.

Papers

See Also

External resources