BCDFuck

BCDFuck takes a stream of bytes and reads each byte as two BCD-encoded 4-bit words. Like other Brainfuck variants, BCDFuck operates on an array of cells, which in this case are 4 bits wide. The digits 0-9 are entered directly into the cells while the six 'wasted' states of 4-bit BCD encoding are translated into brainfuck-like instructions that act on the aforementioned array. Since any 4-bit word is a valid BCDFuck instruction, it would follow that all cells can be executed (as long as potential problems like unbalanced brackets can be ignored).

Each 4-bit word, represented by its corresponding hexadecimal digit, manipulates the cell array as follows


 * 0 through 9 add the corresponding value to the current cell, and advances the cell pointer to the next cell. Thus, 0 is equivalent to > in Brainfuck. All cells in the cell array start with 0 as their default value, and wrap around when they are incremented beyond the limits. The upper limit of a cell is naturally F, and not 9.


 * A moves the cell pointer to the previous cell, and is thus equivalent to < in brainfuck. Thus, 1A increments the value in a cell and 9A 6A decrements it, in a way similar to + and - in brainfuck, respectively.


 * B and C act like the brainfuck's [ and ] operators, respectively.


 * D acts like brainfuck's , operator. However, in this case it reads a byte from the input stream and buffers it until both the high and the low word are read, and in that order


 * E acts like . in brainfuck, sending a word to the output stream. The order of output mirrors the order of input above, and an incomplete pair will be padded with a 0 if the program exits before the pair can be completed


 * F is the Freaky Friday operator. It swaps the program array with the cell array so that their roles are reversed until another F swaps it back, much like the X operator in Braintwist