Lenta

v0.11 This a work in progress. Written by User:Milcho.

Programs in Lenta consist in a two-dimensional grid of instructions, like Befunge, and operate on a tape of cells, like brainfuck. There is also an extra variable, the buffer, that can be accessed at all times.

Instructions

• Unary operators apply to the buffer.
• Binary operators take the current cell and the buffer as operands, and store result in the buffer.
• Logic operators read 0 and less as false, 1 and greater as true, and return 0 for false, 1 for true.
• Any character that is not a valid instruction is ignored.
Symbol Operator
`+`
`PLUS` Add buffer and current cell and store result in buffer.
`-`
`MINUS` Subtract buffer from current cell and store result in buffer.
`*`
`MULT` Multiply buffer and current cell and store result in buffer.
`_`
`DIV` Divide current cell by buffer and store integer quotient in buffer.
`%`
`MOD` Divide current cell by buffer and store remainder in buffer.
`0`
`ZERO` Zero the buffer.
`<`
`LESS` Store 1 in buffer if current cell is less than buffer, 0 otherwise.
`>`
`GREATER` Store 1 in buffer if current cell is greater than buffer, 0 otherwise.
`=`
`EQUAL` Store 1 in buffer if current cell is equal to buffer, 0 otherwise.
`&`
`AND` Store 1 in buffer if both current cell and buffer are true, 0 otherwise.
`|`
`OR` Store 1 in buffer if current cell or buffer is true, 0 if both are false.
`!`
`NOT` If buffer is 0 or less, set it to 1; if it is 1 or greater, set it to 0.
Symbol Instruction
`\$`
`START` Start program here, moving right.
`[`
`LEFT` Move to previous cell.
`]`
`RIGHT` Move to next cell.
`{`
`N-LEFT` Move n cells to the left, where n is the value in the buffer.
`}`
`N-RIGHT` Move n cells to the right, where n is the value in the buffer.
`/`
`RULD` Reflect flow: right-up, left-down.
`\`
`LURD` Reflect flow: left-up, right-down.
`:`
`CEL<BUF` Overwrite current cell with a copy of the buffer.
`;`
`BUF<CEL` Overwrite buffer with a copy of the current cell.
`@`
`INDEX` Overwrite buffer with the location index of the current cell.
`~`
`SWAP` Swap the buffer and current cell values.
`'`
`OUT` Output the buffer as a character.
`,`
`OUT` Output the buffer as an integer.
`.`
`IN` Read an ASCII character or an integer from input, and store it in the buffer.
`"`
`SET` Overwrite buffer with the ASCII value of the next character in the program (and skip it?).
`?`
`SKIP` If the buffer is 0 or less (false), skip next valid instruction.
`#`
`HALT` Halt execution.

Example programs

Those programs haven't been tested yet.

Hello, World!

```\$ "H'"e'"l' '"o'" '"W'"o'"r'"l'"d'"!' #
```

Read in two ints, add their values and print it, and loop until both ints are 0.

```\$ 0? / .:].:[+,0=:]0=[&!?\#
\                   /
```

Fibonacci sequence

Read a number N, and print the first N Fibonacci numbers.

```                            /    \
\$ ]0: ]0!: [[  .:  0?/  ; ? / \  \ ] ; , ",' ] ; [ ~ + ] : [[ 0! - : \
#
\                                               /
```