# Doreq

Doreq is a OISC interpreter of the same named instruction.

## Basic

Each doreq instruction has 8 memory address operands.

```A B C X Y Z J K
```

## Examples

This example will count down from 10 to 0 and then halt.

``` 8,  9,  10, 11, 12, 13, 14, 15,
10,  1,  -1,  8,  9, 16, -1,  0,
99
```

The example below is an extension of the one above and results in the sum of 9+8+7+6+5+4+3+2+1 being assigned to memory address 17

``` 8,  9,  10, 11, 12, 13, 14, 15,
10,  1,  -1,  8,  9, 16, -1, 24,
99,  0,   1, 98,  0,  0,  0,  0,
17,  8,  18, 24, 25, 19, 14, 20
```

## An Interpreter

This is an interpreter for Doreq written in Javascript

```var memory = []
var program_counter = 0
var A, B, C, X, Y, Z, J, K
while (program_counter >= 0) {
A = memory[memory[program_counter]]
B = memory[memory[program_counter+1]]
C = memory[memory[program_counter+2]]
X = memory[memory[program_counter+3]]
Y = memory[memory[program_counter+4]]
Z = memory[memory[program_counter+5]]
J = memory[memory[program_counter+6]]
K = memory[memory[program_counter+7]]
if (C >= 0) {
memory[X] = A+B
} else {
memory[X] = A-B
}
memory[Y] = B
memory[Z] = -C
if (memory[X] === 0) {
program_counter = J
} else {
program_counter = K
}
}
```

This next interpreter is 200% more woke and uses ternary operators to rekt the one above and is absolutely useful as an example!

```var memory = []
var program_counter = 0
while (program_counter >= 0) {
memory[memory[memory[program_counter+3]]] = (memory[memory[program_counter+2]] >= 0) ? memory[memory[program_counter]]+memory[memory[program_counter+1]] : memory[memory[program_counter]]-memory[memory[program_counter+1]]
memory[memory[memory[program_counter+4]]] = memory[memory[program_counter+1]]
memory[memory[memory[program_counter+5]]] = -memory[memory[program_counter+2]]
program_counter = (memory[memory[memory[program_counter+3]]] === 0) ? memory[memory[program_counter+6]] : memory[memory[program_counter+7]]
}
```