Aarkinitio
Aarkinitio is an esoteric programming language created by User:RainbowDash.
Aarkinitio composes of an array of text cells, each are set to the number zero upon initialization. There is a memory pointer that can be set but not normally incremented nor decremented. Aarkinitio includes labels that you are able to jump to. The instructions are as follows:
Instruction | Use case | Arguments |
---|---|---|
EQR | if the text at mp is equal to WORD then replace it with TEXT | WORD, TEXT |
BNE | Jump to LABEL if the text at mp is not equal to TEXT | TEXT,LABEL |
RET | Jump to the last time BNE was called | * |
POKE | Sets the memory pointer | NUMBER |
PEEK | Output the text at mp | * |
INP | Gets text input then stores that text at mp | * |
The EQR instruction only allows for a single word on the first argument.
Aarkinitio programs follow the filetype ".AARK"
Base code tutorials
Simple Goto Loop
poke 0 :loop //PUT CODE HERE// poke 0 bne goto loop
the word "goto" in this program does not mean anything as it is just checking if the word is "goto" which it normally should not be
Cat
:loop poke 0 inp peek bne goto loop
Code Examples
Hello World
poke 0 eqr 0 Hello world! peek
Addition NIM
First to 7 wins pick either 1 or 2 each time. You can not win this version of NIM as the computer always goes first. The program runs indefinitely.
poke 8 eqr 0 NIM: Add 1 or 2 to the total sum. First to 7 wins! peek :restart poke 7 eqr 0 PC:1 poke 5 eqr 0 NIM: Computer goes first. peek poke 7 peek poke 1 eqr 0 Sum:1 peek bne goto start :gameloop poke 7 peek poke 1 peek :start poke 0 inp bne 1 add2 poke 0 bne 2 add1 poke 7 eqr PC:2 PC:1 poke 1 bne Sum:2 next :2add poke 7 eqr PC:1 PC:2 poke 1 bne goto add1 :next bne goto add1 bne Sum:6 skip bne goto 2add :skip poke 1 bne Win! gameloop poke 7 peek poke 6 eqr 0 NIM: Computer wins! peek poke 1 eqr Win! 0 bne goto restart :add1 poke 1 eqr Sum:6 Win! eqr Sum:5 Sum:6 eqr Sum:4 Sum:5 eqr Sum:3 Sum:4 eqr Sum:2 Sum:3 eqr Sum:1 Sum:2 eqr Sum:0 Sum:1 ret :add2 poke 1 eqr Sum:6 Win! eqr Sum:5 Win! eqr Sum:4 Sum:6 eqr Sum:3 Sum:5 eqr Sum:2 Sum:4 eqr Sum:1 Sum:3 eqr Sum:0 Sum:2 ret :halt
Incrementing and Decrementing
Click HERE for the code. (It is very large)
Implementations
JavaScript
function aark(inputPrgm){ // Initialize Variables let memorysize = 3000 let memory = new Array(3000).fill(0); let words = inputPrgm.split(/[ \n/\\]+/); let memorypointer = 0 let bm = 0 let i = 0; let instructions = "eqr,bne,peek,poke,ret".split(',') while (i < words.length) { switch(words[i].toLowerCase()) { case "eqr": if(memory[memorypointer] == words[i+1]){ memory[memorypointer] = "" let wordsearch = i+2 while(!instructions.includes(words[wordsearch])){ if(words[wordsearch].startsWith(':')) break memory[memorypointer] += words[wordsearch] + " " wordsearch++ } memory[memorypointer] = memory[memorypointer].replace(/\s+$/, ''); } break; case "bne": bm = i if(memory[memorypointer] != words[i+1]){ i = words.indexOf(":" + words[i+2]); } else { i += 2 } break; case "peek": console.log(memory[memorypointer]); break; case "poke": memorypointer = words[i+1] i += 1 break; case "ret": i = bm break; case "inp": memory[memorypointer] = prompt("") break; } i++ } }
C
This was written by ChatGPT (This is the only thing here written by ChatGPT) because the author is lazy. However the author had it reference off of the JavaScript code which he wrote himself.
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MEMORY_SIZE 3000 #define MAX_WORD_LENGTH 50 #define MAX_WORDS 10000 void eqr(FILE *inputFile) { int memorysize = MEMORY_SIZE; char memory[MEMORY_SIZE][MAX_WORD_LENGTH]; char words[MAX_WORDS][MAX_WORD_LENGTH]; int memorypointer = 0; int bm = 0; int i = 0; char *instructions[] = {"eqr", "bne", "peek", "poke", "ret", "inp"}; int numWords = 0; char inputBuffer[1024]; // Buffer for user input int inputPos = 0; // Position in the input buffer int inputLength = 0; // Length of the current input // Fill memory array with '0' for (int j = 0; j < MEMORY_SIZE; j++) { memset(memory[j], '0', 1); memory[j][MAX_WORD_LENGTH - 1] = '\0'; // Null-terminate each string } // Read the file and split into words char line[1024]; while (fgets(line, sizeof(line), inputFile)) { const char *delimiters = " \n/\\"; char *token = strtok(line, delimiters); while (token != NULL && numWords < MAX_WORDS) { strncpy(words[numWords++], token, MAX_WORD_LENGTH - 1); token = strtok(NULL, delimiters); } } // Main loop to process instructions while (i < numWords) { if (strcmp(words[i], "eqr") == 0) { if (strcmp(memory[memorypointer], words[i + 1]) == 0) { strcpy(memory[memorypointer], ""); int wordsearch = i + 2; while (1) { int found = 0; for (int j = 0; j < 6; j++) { if (strcmp(words[wordsearch], instructions[j]) == 0) { found = 1; break; } } if (found || words[wordsearch][0] == ':') { break; } strcat(memory[memorypointer], words[wordsearch]); strcat(memory[memorypointer], " "); wordsearch++; } // Remove trailing whitespace memory[memorypointer][strlen(memory[memorypointer]) - 1] = '\0'; } } else if (strcmp(words[i], "bne") == 0) { bm = i; if (strcmp(memory[memorypointer], words[i + 1]) != 0) { char label[MAX_WORD_LENGTH]; snprintf(label, sizeof(label), ":%s", words[i + 2]); for (int k = 0; k < numWords; k++) { if (strcmp(words[k], label) == 0) { i = k; break; } } } else { i += 2; } } else if (strcmp(words[i], "peek") == 0) { printf("%s\n", memory[memorypointer]); } else if (strcmp(words[i], "poke") == 0) { memorypointer = atoi(words[i + 1]); i++; } else if (strcmp(words[i], "ret") == 0) { i = bm; }else if (strcmp(words[i], "inp") == 0) { char temp[256]; // Buffer to hold the input string // Read the whole line of input including spaces fgets(temp, sizeof(temp), stdin); // Remove the newline character at the end, if present size_t len = strlen(temp); if (len > 0 && temp[len - 1] == '\n') { temp[len - 1] = '\0'; } // Store the input string in the memory cell strcpy(memory[memorypointer], temp); } i++; } } int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %s <filename>\n", argv[0]); return EXIT_FAILURE; } FILE *file = fopen(argv[1], "r"); if (file == NULL) { perror("Failed to open file"); return EXIT_FAILURE; } eqr(file); fclose(file); return EXIT_SUCCESS; }