Clever Geek Handbook
📜 ⬆️ ⬇️

Malbolge

Malbolge is an esoteric programming language invented by Ben Olmstead in 1998 . The language is designed to be as complex as possible for writing programs .

Got its name from Malebolge, the eighth circle of hell Dante .

Content

Malbolge Programming

The code for the first program outputting “HEllO WORld” was generated by another Lisp program that used the search in the set of all possible programs, two years after the appearance of the Malbolge language itself. [one]

On August 24, 2000, Anthony Jujas announced in his blog [2] 3 running Malbolge programs that display the phrases “Hello, world.”, “Malbolge sucks.” And “antwon.com rules!”.

Lou Schaeffer later performed a cryptanalysis of the language.

On August 17, 2004, Tomasz Vegzhanowski wrote a generator of programs that output given lines. However, the programs obtained in this way are longer than the Juhas programs.

Hello world

This Malbolge program displays “ Hello, world .”:

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

Another variant:

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

Virtual machine

Malbolge is a machine language for a virtual machine ( interpreter ) running in a ternary number system .

Registers

There are three registers in the Malbolge virtual machine: 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. When the program starts, all the registers are zero.

Memory

The memory size of the virtual machine is 59049 (3 10 ) cells with numbers of 10 ternary digits . All cells with addresses from 0 to 59048 have values ​​from 0 to 59048. All changes occur modulo 59049 ( mod 59049). When the program starts, the beginning of the memory is filled with ASCII codes for the characters of its source text. White space characters (spaces, tabs, line breaks, etc.) are ignored, and the rest of the characters must be Malbolge commands (see below). The remaining memory is filled using the crazy operation (see below): [m] = crz [m-2], [m-1].

Commands

There are 8 teams in Malbolge. The virtual 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 used as the command (since there are 94 characters in the input alphabet of the language , ASCII codes which from the 33rd to the 126th). Interpreter action table:

Teams
Value
([c] + c)% 94
Instruction manualExplanation
fourmov c, [d]Go to the cell with the number [d] .
fiveout aDisplays the value of the ASCII character with the code a % 256 on the screen.
23in aEntering an ASCII character in a . The line separator has a code of 10 . The end of the file is 59048 .
39rotr [d]
mov a, [d]
Shifts the value [d] by one ternary digit to the right (000211111 2 turns into 2 000211111). The result is stored in [d] and in a .
40mov d, [d]Copy value from [d] to d .
62crz [d], a
mov a, [d]
Perform crazy operation (see below) with values [d] and a . The result is stored in [d] and in a .
68nopDoing nothing.
81endThe end of the program.
Any other values ​​do nothing. They are not allowed when loading the program, but are allowed after that.

After each instruction is executed, it is encrypted with the Crazy operation. After that, the values ​​of c and d are increased by 1 and execution continues with the next instruction.

Operation crazy

An operation is an analog of bitwise operations — it is applied to two corresponding digits.

Crazy operation
crz2nd digit
0one2
1st digit0one00
oneone02
222one

Encryption

After the next instruction is completed, the instruction is encrypted using the following translation table (if it is one of the possible language characters):

  ! "# $%> & '() * +, -. / 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 @

i.e ! becomes 5, etc.

In popular culture

In the 10th episode of the first season of the “ Elementary ” series, the key clue in solving the crime was a piece of paper, on one side of which the malbolge program code (which is an inaccurate copy of the Hello World program above) was printed, and the order of coffee was recorded on the other.

Examples

  • The working source code for the song “99 Beer Bottles” using real loops. Written by Hisashi Izawa.
  • A working quine was written on December 3rd, 2012, 14 years after the creation of the language itself.

Notes

  1. ↑ Description of the search algorithm on Andrew Cooke
  2. ↑ Anthony Malbolge Blog Post
Source - https://ru.wikipedia.org/w/index.php?title=Malbolge&oldid=89503141


More articles:

  • Cortelainen, Jorma
  • Rostislav Vsevolodovich
  • Muravyov, Valerian Nikolaevich (philosopher)
  • Klas Aldenburg
  • Jachimovich, Shelley
  • Aksu (airport)
  • Schindler, Christopher
  • Burul
  • Le Pera
  • Orzhevsky, Vasily Vladimirovich

All articles

Clever Geek | 2019