According to the original specification '98, Ben Olmstead Malbolge VM fill empty memory cells using crazy op on two previous cells. "Cells which are not initialized are set by performing op on the previous two cells repetitively." I.e.
[m] = crz [m-2], [m-1]
For the sake of sanity what should I do if the program contains only 1 instruction?
Or should I assume the last character always to be EOF
?
Judging by the implementation and language-lawyering, there are two options -
If we consider the definition of "two previous cells" as, literally, the two previous cells, then a single-char or empty malbolge program is illegal in the language, because it can not be executed according to the specs.
If we consider the definition of [m] = crz [m-2], [m-1]
, it gets interesting. The main implementation (alongside probably most of the rest) uses unsigned short
(or int
) for the memory pointer. When you try subtracting 2
from 1
(m-2
) it results in 0xffff
, decimal 65535
(see this answer for details), which is just a bit over malbolge's 59049
memory limit. That glitch runs (almost) perfectly on a normal machine, using the 0xffff
cell for crazy-op computing (without even harming the out-of-environment memory!), but will fail on a limited-memory or virtual machine.
0xffffffff
instead of 0xffff
, depending on the way you use the pointer.In short,
0xffff
is a random-valued memory cell, leading to random values along the environment memory. On the other hand, what can you expect from a single-byte malbolge program?