iag

From Esolang
Jump to navigation Jump to search

iag is an esoteric programming language with only three commands. It was invented by Panu Kalliokoski.

Memory

iag supplies an unbounded number of memory cells initialized to zero. Each cell holds a 32-bit signed integer. There is also an accumulator register, which holds a 32-bit signed integer as well. Looping is performed with the | command and an accompanying stack.

Commands

Command Description
< Move memory pointer to the left.
= Subtract contents of this memory cell from accumulator, storing the result in both this memory cell and the accumulator, then move memory pointer to the right.
| If accumulator is
5 quit.
4 call time() and save the result in active memory cell.
3 read a character from stdin to active memory cell (EOF = 0).
2 print a character to stdout from active memory cell.
1 do nothing.
0 set accumulator to 1, add the location of this instruction to the stack, then, only if active memory cell = 0, jump to the command after the next |.
-n return to the | instruction you were at n jumps ago, remove n items from the stack, and set the accumulator to 0.
Panu's interpreter also offers the following, presumably not part of the language proper:
d Dump memory cells for debugging.
s Dump stack.
x End the program.

Examples

|| === =<=< <<<=== =<=< <=
==== |<|<|<|<|<|<|<|
ds

Reads eight characters of input, storing them in reverse order in the first eight memory cells.

= || ==<<==== =<=< <= =<=< <<<<<=<==== |
<= <<= <<== <<= <<== <<= |

Prints all characters 0 to 256 (starting with 1) endlessly.

External resources