Indirect

From Esolang
Jump to: navigation, search

Indirect is a brainfuck derivative inspired by other brainfuck derivatives designed by User:Quojil in 2014. It extends a lot of functionality also. It's primary inspiration is Minifuck, as it is a very small version of brainfuck, but does not have much functionality. Like Minifuck, Indirect has only three instructions, but can do a lot more.

How is it different

Indirects name is inspired by how all the operations you can do, a total of 15, can be managed with only three instructions.

In order to achieve this, Indirect has two parts of memory, the "instruction bay" and the "data memory". Using three instructions, you can increment and decrement the value in the instruction bay. After you use the "!" instruction, it will execute the operation the number in the instruction bay references. For example:

+!! increment current cell by two
++++++++++++! sleep for two second seconds
+! terminate

The first line sets the instruction bay to 1 and then executes it twice to set the current cell to two. Next, the instruction bay gets incremented to 13 and then executed to sleep. It sleeps for two seconds because the current cell is two. And finally, the instruction bay is set to 14 and executed to terminate the program.

Instructions

"instruction bay"

Command Description
+ Increment number in the instruction memory
- Decrement the data in the instruction memory
! Run operation

"operations"

(the things that are ran from the instruction bay)
(these operations ONLY use the number memory)
(whenever the word "byte" is used, it means the current byte. "byte+1" means the byte one cell right)

Operation Description
0 move cell pointer left
1 increment current cell
2 decrement current cell
3 zero out current cell
4 input if current cell equals zero, else output
5 open/close file
6 skip next instruction in the program if current cell equals zero
7 AND byte and byte+1
8 NAND byte and byte+1
9 OR byte and byte+1
10 NOR byte and byte+1
11 XOR byte and byte+1
12 NOT byte and byte+1
13 sleep for time (in seconds) designated by current cell
14 stop the program
15 nop

Note:
The open/close file operation has a funky functionality. When you call it, a file in the directory the interpreter is being ran in will be created with the name "i/o". After opening the file, the 4th operation (input/output) will add the letter the current cell holds to the end of the file if it outputs, and when input is called it will load the last byte in the file. After calling open/close again, it will close i/o and the input/output operation will return to normal.

Specifications

The size of the instruction bay is one nibble, and the number memory has 8 one-byte cells.