InstructionPointerBF
InstructionPointerBF is a PocketBF variant. There are only 2 instructions, so it can take instruction in binary. The motivation for creating InstructionPointerBF is to allow Brainfuck code to compressed by converting characters to InstructionPointerBF, so that no ASCII character is wasted.
Commands
Command | Description |
---|---|
0 |
Increments instruction pointer by 1 |
1 |
Executes instruction at pointer as PocketBF code |
A PocketBF command selector, starting at the instruction =
, selects upon each encounter with a zero-bit (0
) the next command, following this ordering:
= + > | ;
Having reached the desinent member (;
), the selector wraps around, starting again with =
.
A description of these instructions can be found in the article here.
A more explicit illustration of the command selector's advance shall be provided below:
Current PocketBF command | = |
+ |
> |
| |
;
|
---|---|---|---|---|---|
Next PocketBF command | + |
> |
| |
; |
=
|
Examples
Cat Program
01001010 10000100 00100000
On the last line, 5 zeros had to be padded to make a complete byte.
While slightly inefficient, a Cat program is only 3 bytes, compared to Brainfuck's 5 bytes. If the "junk bits" are removed, a Cat program is only 19 bits, compared to Brainfuck's 40. So significant compression has been achieved.
Note:
I think it is more efficient to iterate through PocketBF's instructions that Brainfuck's or TinyBF's, but I will have to test to see if there is a better language to have the pointer point to.
Examples
Cat program
In the following is an infinitely repeating cat program implemented:
01001001010000100001010000101000100101001001010000100010
Interpreter
- Common Lisp implementation of the InstructionPointerBF programming language. The program also contains a PocketBF interpreter, given their consanguinity.