The Lotg Pseudocode

"Lotg" (originally standing for "Language of the Gods") is a pseudocode I developed during my first year at the Technion. I wanted to develop such a code with a minimal set of instructions. Initially it had eight instructions, but I was able to reduce it to five. I believe it is Turing-complete. Here is an explanation of it.

Lotg is defined on a memory in which there is a cell associated with every integral number (positive, negative and zero), and every cell can contain one integral value. The cells will be marked as m[i] where i is the index of teh cell. There are two registers - "pointer" and "register" which will be marked as r and p.

The following instructions are defined:

  1. p ← i, where i is any integral parameter. This is the only instruction that accepts an arbitrary parameter.
  2. r ← r+p
  3. p ← m[p]
  4. m[p] ← r ; r ← 0 - a composite instruction doing two instructions one after the other.
  5. if r>0 jump to p (If r is greater than 0 jump to the instruction whose index is p).

Sample Constructs

Using these instructions one can define the following macros:

m[m[i]] = m[m[j]]

p = -10**100   # Essentially a number that should not concern us.
m[p] = r ; r = 0
p = j
p = m[p]
p = m[p]
r += p
p = i
p = m[p]
m[p] = r ; r = 0

m[m[i]] += m[m[j]]

p = -10**100
m[p] = r; r = 0
p = j
p = m[p]
p = m[p]
r += p
p = i
p = m[p]
p = m[p]
r += p
p = i
p = m[p]
m[p] = r ; r = 0

if (m[i] = j) { [BLOCK] }

p = -10**100
m[p] = r ; r = 0
p = -j
r += p
p = i
p = m[p]
r += p
p = i(end)
if r > 0 jump p
p = 1
r += p
p = i(after)
if r > 0 jump p
p = -10**100
m[p] = r ; r = 0
p = 1
r += p
p = i(end)
if r > 0 jump p
after:
    [BLOCK]
end:
AddThis Social Bookmark Button