From Esolang
Jump to navigation Jump to search

Addbig is a OISC created by User:Joaozin003 which the only instruction is "Add the values of A and B, store the result in A and branch to C if the result is bigger than zero."

This instruction can be written in C with the code:

*a += *b; if (*a > 0) goto c;

It is also the literal opposite of Subleq.

Programming in Addbig

The full Addbig instruction

In C:

if (b < 0) *a += scanf();
else *a += *b;
if (a < 0) {
    printf("%c", (char)*a);
    *a = 0;
if (*a > 0) {
    if (c < 0) return;
    else goto c;

Memory Mapping

Since Addbig has no I/O, it is memory-mapped to addresses less than 0. Adding from -1 means input, and adding to -1 means output (the result does not go to address -1, it goes to the console, effectively discarding the result (for discarding the result by not using output, discard it into an unused address)).

And jumping to -1 effectively means ending the program, as that address is useless as an instruction (the first actual instruction is at address 0, the start of the program).

Storage of data

Data can be stored in lots of ways, but I'm just showing one:

The Stack

A stack is a way of storing data which follows the "first in, last out" pattern.

Stack Push

Stack push puts a value on top of the stack, and increases the stack pointer. I'm going to label the stack pointer with "sp" to help traverse code.

sp v 3 # v is the value to push
0 1 ... # increment stack pointer
Stack Pop

Stack pop takes a value out of the stack, stores it somewhere and decreases the stack pointer.

3 sp 6
0 0 -1
# zeroing out old stack top code goes here
1 5 ...


Here are some examples to show off the OISC:

Hello Program

-1 15 3
-1 16 6
-1 17 9
-1 18 12
-1 19 -1
72 101 108
108 111

The junk below the first 5 instructions is actually data to output (more precisely, the string "Hello" in ASCII), which never gets jumped to.


4 -1 6
0 0 -1
4 5 12
3 5 6
-1 3 15
0 0 -1

The program above takes a number, negates it, and outputs the negated number. The program uses looping to emulate subtraction from 0, which effectively means negation.

Cat Program Until <=0

-1 -1 0
2 3 -1

Indeed, this is one of the simplest programs ever.

See also