
The "crazy" operation is defined according to the following table. D Q b c u in the second memory position the list is: & ' = C P a b t, and so on, decreasing the code at each step and wrapping from ! to ~. Output the character in A, modulo 256, to standard output. Set code pointer to the value pointed to by the current data pointer. Depending on the result, the following instructions are executed: Otherwise, in order to determine the actual instruction to execute, the value pointed to by the C register is added to the C register itself and the result divided by 94, taking the remainder. If the instruction to execute is not in the range 33-126, execution stops (the reference interpreter hangs in this case due to a bug). There are three registers, each of which holds one machine word, initially 0: the code register C which is a pointer to the instruction that is about to be executed, the data register D used for data manipulation and the accumulator A also used by several instructions to manipulate data. (At this place it may be interesting to know that in the 1960s and 1970s trit-based computers were developed in the "eastern bloc" and still some engineers think about trit-based computers when talking about new non-silicon-based technologies.) Both data and code share the same memory space. Each memory position holds a machine word the addresses are one machine word wide too. Each machine word is ten trits wide, making it range from 0 to 2222222222 ternary = 59048 decimal. The virtual machine is based on trits ( trinary, i.e. There's only one officially allowed NOP code that can be entered, even if many possible NOPs are possible at run time (each non-instruction that is a printable character is a NOP).Įach word in the remainder of the memory is initialized as the result of applying the crazy operation (see below) to the contents of the previous and the second previous word (in that order). Only valid instructions and whitespace are allowed in the source, but a bug in the reference implementation makes it possible to enter instructions with a code greater than 126, which hang that interpreter if executed. Any whitespace is skipped, including newlines. The program is fed directly into the virtual machine's memory starting at position 0. The actual spelling Malbolge is also used for the sixth hell in the Dungeons and Dragons roleplaying game. The language is named after Malebolge, the eighth level of hell in Dante's Inferno, which is reserved for perpetrators of fraud.
