Brainfuck bitwidth conversions
From Esolang
This is a set of translations to make normal 8-bit Brainfuck use 2 or 4 cells. Basically, by applying one of these conversions, you can make a normal BF program run as its 16-bit or 32-bit version on an 8-bit BF interpreter.
For both conversions, the output code must be prefixed with a single '>'.
| Original | 1->2 | 1->4 |
| . | . | . |
| , | , | , |
| > | >>> | >>>>> |
| < | <<< | <<<<< |
| + |
+ [<+>>>+<<-]<[>+<-]+>>>[<<<->>>[-]]<<<[- >>+<< ]> |
+ [<+>>>>>+<<<<-]<[>+<-]+>>>>>[<<<<<->>>>>[-]]<<<<<[- >>+ [<<+>>>>>+<<<-]<<[>>+<<-]+>>>>>[<<<<<->>>>>[-]]<<<<<[- >>>+ [<<<+>>>>>+<<-]<<<[>>>+<<<-]+>>>>>[<<<<<->>>>>[-]]<<<<<[- >>>>+<<<< ] ] ]> |
| - |
[<+>>>+<<-]<[>+<-]+>>>[<<<->>>[-]]<<<[- >>-<< ]>- |
[<+>>>>>+<<<<-]<[>+<-]+>>>>>[<<<<<->>>>>[-]]<<<<<[- >> [<<+>>>>>+<<<-]<<[>>+<<-]+>>>>>[<<<<<->>>>>[-]]<<<<<[- >>> [<<<+>>>>>+<<-]<<<[>>>+<<<-]+>>>>>[<<<<<->>>>>[-]]<<<<<[- >>>>-<<<< ] >>>-<<< ] >>-<< ]>- |
| [ |
[>>+>>>+<<<<<-]>>>>>[<<<<<+>>>>>-]<<< [[-]<<<+>>>]< [>+>>>+<<<<-]>>>>[<<<<+>>>>-]<<< [[-]<<<+>>>]<<< [[-]> |
[>>>>+>>>>>+<<<<<<<<<-]>>>>>>>>>[<<<<<<<<<+>>>>>>>>>-]<<<<< [[-]<<<<<+>>>>>]<<< [>>>+>>>>>+<<<<<<<<-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]<<<<< [[-]<<<<<+>>>>>]<< [>>+>>>>>+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<<<<< [[-]<<<<<+>>>>>]< [>+>>>>>+<<<<<<-]>>>>>>[<<<<<<+>>>>>>-]<<<<< [[-]<<<<<+>>>>>]<<<<< [[-]> |
| ] |
[>>+>>>+<<<<<-]>>>>>[<<<<<+>>>>>-]<<< [[-]<<<+>>>]< [>+>>>+<<<<-]>>>>[<<<<+>>>>-]<<< [[-]<<<+>>>]<<< ]> |
[>>>>+>>>>>+<<<<<<<<<-]>>>>>>>>>[<<<<<<<<<+>>>>>>>>>-]<<<<< [[-]<<<<<+>>>>>]<<< [>>>+>>>>>+<<<<<<<<-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]<<<<< [[-]<<<<<+>>>>>]<< [>>+>>>>>+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<<<<< [[-]<<<<<+>>>>>]< [>+>>>>>+<<<<<<-]>>>>>>[<<<<<<+>>>>>>-]<<<<< [[-]<<<<<+>>>>>]<<<<< ]> |
It is also possible to combine these, and detect the bitwidth of the interpreter at runtime like so:
++++++++[>++++++++<-]>[<++++>-]< [>+>+<<-]>[<+>-]+ >[ [-]<[-]< [>>+>+<<<-] >>>[<[<+<+>>-]<[>+<-]>>-]<<< [>+>+<<-]>[<+>-]+ >[<-<[-] 1cell code [-]>[-]>[-]] <[-<[-] 2cell code [-]>[-]] ] <[-<[-] 4cell code [-]>[-]]

