ICBINB
ICBINB (short for I Can't Believe It's Not Brainfuck) is an esolang made by User:ArthroStar11 the code entirely uses valid Brainfuck tokens however the language behaves very differently, not least of which that it is a stack based language.
Modes
Due to stack based languages generally using more than 8 commands, in ICBINB there are 3 command modes, labeled 0 through 2 that can be incremented between using the comma(,). More details are provided below but in general
- Mode 0 deals with math
- Mode 1 deals with flow control
- Mode 2 deals with IO
Data Structure
ICBINB uses a stack of signed 32-bit integers as its only data structure
Command List
NOTE: mentions of variables a and b refer to popping a then b off the stack, mentions of variable c refer to popping the top value off the stack
- ,
- Mode = (Mode + 1) % 3
- Mode 0
- +
- if stack size is less than 2 pushes 1 to the stack
- else pushes b + a
- -
- if stack size is less than 2 pushes -1 to the stack
- else pushes b - a
- <
- pushes b * a
- >
- pushes b / a
- [
- pushes c << 1
- ]
- pushes c >> 1
- .
- pushes b % a
- +
- Mode 1
- +
- pushes 1 if a > b
- else pushes 0
- -
- pushes 1 if a < b
- else pushes 0
- <
- push a random number with range a and offset b
- works like JavaScript's Math.floor(Math.random() * a) + b
- >
- push two copies of c
- [
- skip to corresponding ] if c == 0
- ]
- loop back to corresponding [ if c != 0
- .
- push 1 if a == b
- else push 0
- +
- Mode 2
- +
- push a string to the stack using c as the max string size
- -
- pop a string of size c
- <
- integer output
- >
- integer input
- [
- character output
- ]
- character input
- .
- print a list of size c as integers
- +
Sample Programs
Print "HI"
+[[[[[[+[[[+,>,[,++,,[
Commented
+[[[[[[ //push 64 onto the stack +[[[ //push 8 onto the stack + //add 64 and 8 , //switch to mode 1 > //duplicate 72 , //switch to mode 2 [ //print H (ASCII 72) , //switch to mode 0 ++ //add 72 and 1 ,, //switch to mode 2 [ //print I (ASCII 73)
Truth Machine
,,>,,>[>>,<,,],<
Commented
,, //switch to mode 2 > //get user input as int ,, //switch to mode 1 > //duplicate input [ //skip to ] if input is 0 >> //duplicate input twice , //switch to mode 2 < //output user input as int ,, //switch to mode 1 ] //loop back to [ if input isn't 0 , //switch to mode 2 < //output user input as int
99 to 0
+[[[[[[+[[[[[++[[+,>[,,+-,>>,<,,]
Commented
+[[[[[[ //push 64 onto the stack +[[[[[ //push 32 onto the stack + //add 64 and 32 +[[ //push 4 onto the stack + //add 96 and 4 , //switch to mode 1 > //duplicate top value of the stack [ //begin loop ,, //switch to mode 0 +- //subtract one from top value of the stack , //switch to mode 1 >> //duplicate top value twice , //switch to mode 2 < //pop top value as int ,, //switch to mode 1 ] //end loop
Reverse Cat Program (16 char cap, see comments for why)
---+[[[[,,+,,>[>,[,,]
Commented
--- //push 0 onto the stack +[[[[ //push 16 onto the stack ,, //switch to mode 2 + //get user input as string; pops 16 as arg for buffer size ,, //switch to mode 1 > //duplicate top value [ //begin loop , //switch to mode 2 [ //pop top value as char ,, //switch to mode 1 ] //end loop
Implementation
ArthroStar11's Interpreter (C++ Source)