# LMCode

LMCode — esoteric programming language. Based on the Little man computer command system.

LMCode operates on an array of memory cells, also referred to as the tape, each initially set to zero. There is a pointer, initially pointing to the first memory cell. The commands are:

Command Description
. Upload a value from the accumulator into OUTBOX
~ Download a value from the accumulator into the current memory cell
^ Upload a value from the current memory cell into the accumulator
> Move the pointer to the right
< Move the pointer to the left
+ Add a value from the current cell to the accumulator
- Sub a value in the current cell from the accumulator
! The label of the command ?

This does only work if acc>=0

} The label of the command {

This does only work if acc=0

) The label of the command (

## Examples

### Double a value

``` ,~+. ```

So the way this works is:

Add a value from the cell 0 to the accumulator (double a value)

Upload doubled value from the accumulator into OUTBOX

### The largest element in the list

To run the program, you must first upload initial values to cells 0 and 1, then go back to cell 0.

`,~>,~<`

Then run

``` ^>-{^?}<^!. ```

The way this works is:

Upload the first value from cell 0 into the accumulator

Move the pointer to cell 1

Sub the second value from the accumulator

Upload the second value from the cell 1 into the accumulator

Move the pointer to cell 0

Upload the first value from cell 0 into the accumulator

Upload a value from the accumulator into OUTBOX

### Fibonacci

`}>>^>+.~<+.~<<^>-<~{`

To run the program, you must first upload count of the cycles (into cell 0), decremet of the count - the natural number 1 (into cell 1), first Fibonacci number - the natural number 1 (into cell 2).