Malbolge: Programming from Hell

Good day, Habrastvo.

I once suffered from nonsense, tracking the emergence of various esoteric programming languages ​​and I came across the well-known to all of us Malbolge. That's actually about him I want to tell. Well, let's start with.

And to begin with, the notorious BrainFuck didn’t even lie nearby - this Malbolge is so cool and complicated. The first code in this language was written not by people, but by another program written in Lisp, and then only two years after the appearance of this language.
But let's talk about hell Malbolg programming. Firstly, it works in a ternary number system, which is important for understanding the code that should be entered in the interpreter.

There are three registers in Malbolge: a, c, and d. Register c is a code register used as a pointer to the current command. Register d is a data register used to manage data. Register a is a battery, also used by some commands for data manipulation.

There are 8 teams in Malbolge. The machine determines which command to execute as follows: the value c is added to the value of the cell with the address c ([c]), and the remainder of dividing this number by 94 is added as the command if [C] is not in the range from 33 to 126 inclusive.

And here is the actual list of commands:
  • j D = [D] Shifts the data pointer to the cell indicated by its past value
  • i C = [C] Shifts the instruction pointer to the cell indicated by its past value
  • * A = [D] = ROTATE ([D]) Cyclically shifts the value in the cell that D points to one third to the right. Along the way, this value is written in A.
  • p A = [D] = CRAZY (A, [D]) Applies the crazy operation to the value of register A and the cell pointed to by D.
  • / A = INPUT Reads one character from the input stream and stores it in A.
  • <PRINT A Prints an ASCII character A mod 256.
  • v STOP End a program.
  • o NOP A command that does nothing (the only valid one).

After each instruction, it is encrypted with Crazy.
An operation is an analog of bitwise operations — it is applied to two corresponding digits.

Crazy operation:
CRZ                     2-я цифра
                                0 	1	2
1-я цифра 	        0  	1	0	0
                        1  	1	0	2
                        2   	2	2	1


After the instruction is completed, it is initialized with a special table:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
5z]&gqtyfr$(we4{WP)H-Zn,[%\3dL+Q;>U!pJS72FhOA1CB6v^=I_0/8|jsb9m<.TVac`uY*MK'X~xDl}REokN:#?G"i@


We sorted out the basics in half with grief, it's time to write code.

But here, it turned out a bummer: no matter how hard I tried, I could not write a working program in this language.
Therefore, I give examples of cool hackers of smart people who succeeded.

This program outputs Hello, world:
(=<`:9876Z4321UT.-Q+*)M'&%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk**hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98\6543W10/.R,+O<


and this one too:
('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}=<M:9wv6WsU2T|nm-,jcL(I&%$#"`CB]V?Tx<uVtT`Rpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@>


That, in fact, is all. And if you still manage to write at least something on Malbolge, be sure to let me know - I want to take a picture with a genius.

Also popular now: