NABC
Jump to navigation
Jump to search
NABC is an esolang by User:ChuckEsoteric08 in which command is defined by number of a, b and c.
Specification
d is used to separate commands. Data is stored in Accumulator and stack. Line numbers are 0-indexed.n(x) means "number of symbol X".
| Name | Number of A | Number of B | Number of C | Meaning |
|---|---|---|---|---|
| inc x | 1 | 2 | x | Increment Accumulator by n(c) |
| dec x | 2 | 1 | x | Decrement Accumulator by n(c). |
| psh x | 0 | 2 | x | Push n(c) to the stack. |
| inp | 3 | 0 | 1 | Push ASCII value of next byte of user input to the stack. |
| psa | 3 | 1 | 0 | Push accumulator to the stack. |
| swp | 2 | 4 | 0 | Swap top stack elements. |
| peq x y | 9 | x | y | Pop and if that value is equal to n(b) goto n(c). |
| rev | 4 | 2 | 0 | Reverse Stack. |
| dup | 5 | 5 | 0 | Duplicate top element. |
| add | 5 | 4 | 1 | Pop value and add it to accumulator. |
| sub | 5 | 3 | 2 | Pop value and subtract it from accumulator. |
| set | 0 | 0 | 0 | Set accumulator to zero. |
| neq | 3 | 4 | 3 | Pop two numbers and skip next instruction if they are not equal. |
| jmp x | 0 | 3 | x | Jump to line n(c). |
| out | 4 | 0 | 0 | Pop number and output it as ASCII character. |
Examples
Cat Program
A perpetually repeating cat program shall be demonstrated:
aaacdaaaad bbb
Truth-Machine
A truth-machine is realized in the following:
bbcccccccccccccccccccccccccccccccccccccccccccccccccd aaacd aaaaabbbbbd aaaaabbbbbd aaaabbd aaabbbbcccd bbbccccccccccd aaaad aaaaabbbbbd bbbcccccccd aaaad
Interpreter
- Common Lisp implementation of the NABC programming language.