Here's how you code in it:
1. type random gibberish
2. Success!
Malbolge has three registers, a, c, and d. When a program starts, the value of all three registers is zero. c is special: it points to the current instruction.
d can hold a memory address;
[d] is the value stored at that address.
[c] is similar.
The virtual machine has 59049 (310)
memory locations that can each hold a ten-digit
ternary number. Each memory location has an address from 0 to 59048 and can hold a value from 0 to 59048. Incrementing past this limit wraps back to zero.
Before a Malbolge program starts, the first part of memory is filled with the program. All whitespace in the program is ignored and, to make programming more difficult, everything else in the program must start out as one of the instructions below.
The rest of memory is filled by using the
crazy operation (see below) on the previous two addresses (
[m] = crz [m - 2], [m - 1]). Memory filled this way will repeat every twelve addresses (the individual ternary digits will repeat every three or four addresses, so a group of ternary digits is guaranteed to repeat every twelve).
Malbolge has eight
instructions. Malbolge figures out which instruction to execute by taking the value at
[c], adding the value of
c to it, and taking the remainder when this is divided by 94. The final result tells the interpreter what to do:
For each ternary digit of both inputs, use the following table to get a ternary digit of the result. For example,
crz 0001112220, 0120120120 gives 1001022211.
Crazy operationcrzInput 2012Input 1010011022221
[edit] Encryption
After an instruction is executed, the value at
[c] (without anything added to it) will be replaced with itself
mod 94. Then, the result is
encrypted with one of the following two equivalent
methods.
Value of
([c] + c) % 94Instruction representedExplanation4
jmp [d] + 1The value at
[d], plus one, is where Malbolge will jump to and start executing instructions.5
out aPrints the value of
a, as an
ASCII character, to the screen.23
in aInputs a character, as an ASCII code, into
a. Newlines or line feeds are both code
10. An end-of-file condition is code
59048.39
rotr [d]
mov a, [d]Rotates the value at
[d] by one ternary digit (000211111
2 becomes
2000211111). Stores the result both at
[d] and in
a.40
mov d, [d]Copies the value at
[d] to
d.62
crz [d], a
mov a, [d]Does the
crazy operation (see below) with the value at
[d] and the value of
a. Stores the result both at
[d] and in
a.68
nopDoes nothing.81
endEnds the Malbolge program.
Copied it. Read n pray