Nyarlathotep

From Esolang
Jump to navigation Jump to search

Nyarlathotep (named after a deity in the Cthulhu Mythos) is a esoteric language created by User:CosmoConsole in 2015, and has received a large amount of inspiration from Malbolge. Similarly to the aforementioned language, it is designed to be as difficult to program in as possible.

Description

Memory

The memory consists of 6 436 343 (23 ^ 5) cells of 5 duodecatrits (base-23), giving them the range of 0 - 6 436 342 (inclusive). When initializing, the code is placed as ASCII directly in the memory and the rest is filled by adding the two previous cells together modulo 6 436 343.

Registers

There are four registers in use:

  • X acts as the accumulator and is used in a few instructions.
  • C is the code pointer, starting at 0.
  • R0 is a value that starts as 0.
  • R1 is also a value that starts as 0.

Internal variables

  • L stores the last instruction, and starts as 0.

Operation

The interpreter does this every cycle:

  Set B to the data in memory at C.
  'Decrypt' B.
  Set A to CRC32 ( CRC32(L) + B * 39 + C ) mod 64.
  Set L to B.
  Interpret A as an instruction.
  C is set to (C + 1) % 6436343.
  R0 is set to (R0 + 1) % 6436343.
  Rotate R0 one duodecatrit to the left. (2J8FM (795454) => J8FM2 (5422758))
  R1 is set to (R0 + R1) % 6436343.
  Repeat until program hits a stop instruction.

Decryption

The decryption goes as follows.

  Set B to B mod 256.
  If the character represented in ASCII by B is in the decryption table:
     Set B to the index of that character.
  Else:
     Update C, R0, R1, but don't update L and continue with the next cell in the memory (NOP).
  

Decryption table

index in hexadecimal

   Index: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
   Char :  N  M  0  b  v  C  4  V  w  ;  n  x  U  q  6  S
   
   Index: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
   Char :  Z  5  P  J  i  Q  L  y  R  z  B  d  E  K  h  f 
   
   Index: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
   Char :  m  A  g  e  s  l  8  =  Y  u  r  D  W  7  k  o
   
   Index: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
   Char :  1  j  H  G  a  O  p  I  T  c  9  3  X  t  F  2
   
   NM0bvC4Vw;nxUq6S
   Z5PJiQLyRzBdEKhf
   mAgesl8=YurDW7ko
   1jHGaOpITc93XtF2
   
   NM0bvC4Vw;nxUq6SZ5PJiQLyRzBdEKhfmAgesl8=YurDW7ko1jHGaOpITc93XtF2

Instructions

As per to A above:

A Description Pseudocode Letter
0 Outputs the value of X modulo 256 as EBCDIC. PRINT_EBCDIC(X%256) 0
5 Do nothing. NOP 1
8 Take one character from standard input and store the ASCII character code to X. X = (INPUT%256) 2
11 Stop the program execution. STOP 3
17 Rotate current data at R0 one duodecatrit to the right and store to X as well. X = [R0] = ROT_RIGHT([R0]) 4
19 Rotate current data at R1 one duodecatrit to the left and store to X as well. X = [R1] = ROT_LEFT([R1]) 5
26 Copy the value of R1 to C. C = R1 6
34 Copy the value of R0 to X. X = R0 7
39 Perform the 'mine operation' on R0 and X, store result to X only. X = R0 ¤ X = MINE(R0,X) 8
41 Perform the 'mine operation' on data in memory at R0 and X, store result to X and [R0]. X = [R0] = [R0] ¤ X = MINE([R0],X) 9
45 Copy the value of R0 to R1. R1 = R0 "
47 Copy the value of R1 to R0. R0 = R1 ;
52 Copy the value of memory at R1 to R0. R0 = [R1] (
54 Copy the value of memory at R0 to R1. R1 = [R0] )
60 Reserved for future expansion. (NOP) =

Rest of the numbers run a random instruction.

Mine operator

   #  0123456789ABCDEFGHIJKLM
   
   0  0123456789ABCDEFGHIJKLM
   1  1032547698BADCFEHGJILKL
   2  23016745AB89EFCDIJGHMLK
   3  32107654BA98FEDCJIHGHIJ
   4  45670123CDEF89ABCDEFIJI
   5  54761032DCFE98BADCFEJIH
   6  67452301EFCDAB89EFCDEFG
   7  76543210FEDCBA98FEDCFGF
   8  89ABCDEF0123456789ABGFE
   9  98BADCFE1032547698BABCD
   A  AB89EFCD23016745AB89CDC
   B  BA98FEDC32107654BA98DCB
   C  CDEF89AB45670123456789A
   D  DCFE98BA5476103254769A9
   E  EFCDAB89674523016745A98
   F  FEDCBA98765432107654567
   G  GHIJCDEF89AB45670123676
   H  HGJIDCFE98BA54761032765
   I  IJGHEFCDAB8967452301234
   J  JIHGFEDCBA9876543210343
   K  KLMHIJEFGBCD89A56723032
   L  LKLIJIFGFCDC9A967634301
   M  MLKJIHGFEDCBA9876543210

For every duodecatrit in both numbers. (The operation is commutative)

Example programs

There aren't any yet.

External resources