# The bakerVM instruction set
The bakerVM implements its very own highly performant instruction set. Every instruction has a designated functionality. The instructions are defined by the file `instruction.rs`:
```rust
pub enum Instruction {
Add(Target, Target),
Sub(Target, Target),
Div(Target, Target),
Mul(Target, Target),
Rem(Target, Target),
Cmp(Target, Target),
Jmp(Address),
JmpLt(Address),
JmpGt(Address),
JmpEq(Address),
JmpLtEq(Address),
JmpGtEq(Address),
Cast(Target, Type),
Push(Target, Value),
Mov(Target, Target),
Swp(Target, Target),
Dup(Target),
Call(Address),
Ret,
Halt,
Pause,
Nop,
Sig(Signal),
}
```
## Instruction listing
| Add(Target, Target) | add `dest`, `src` | **dest**: `value` → `value`<br>**src**: `value` → | Adds the values of the `src` and `dest` targets |
| Sub(Target, Target) | sub `dest`, `src` | **dest**: `value` → `value`<br>**src**: `value` → | Subtracts the value of the `src` target from the value of the `dest` target |
| Div(Target, Target) | div `dest`, `src` | **dest**: `value` → `value`<br>**src**: `value` → | Divides the value of the `dest` target through the value of the `src` target |
| Mul(Target, Target) | mul `dest`, `src` | **dest**: `value` → `value`<br>**src**: `value` → | Multiplies the values of the `src` and `dest` targets |
| Rem(Target, Target) | rem `dest`, `src` | **dest**: `value` → `value`<br>**src**: `value` → | Calulates the remainder of the division `dest`/`src` |
| Cmp(Target, Target) | cmp `target_a`, `target_b` | **cmp_register**: `ordering` → `ordering` | Compares the two targets saving the result into the `cmp_register` |
| Jmp(Address) | jmp `jump_target` | [no change] | Jumps unconditionally to the specified `jump_target` |
| JmpLt(Address) | jmplt `jump_target` | [no change] | Jumps to the specified `jump_target` if the result of the last comparison is `less` |
| JmpGt(Address) | jmpgt `jump_target` | [no change] | Jumps to the specified `jump_target` if the result of the last comparison is `greater` |
| JmpEq(Address) | jmpeq `jump_target` | [no change] | Jumps to the specified `jump_target` if the result of the last comparison is `equal` |
| JmpLtEq(Address) | jmplteq `jump_target` | [no change] | Jumps to the specified `jump_target` if the result of the last comparison is either `less` or `equal` |
| JmpGtEq(Address) | jmpgteq `jump_target` | [no change] | Jumps to the specified `jump_target` if the result of the last comparison is either `greater` or `equal` |
| Cast(Target, Type) | cast `target`, `type` | **target**: `value` → `value` | Casts the value of the `target` into the specified `type` in-place |
| Push(Target, Value) | push `target`, `value` | **target**: → `value` | Writes the `value` to the target |
| Mov(Target, Target) | mov `dest`, `src` | **dest**: → `value`<br>**src**: `value` → | Moves the value of the `src` target to the `dest` target |
| Swp(Target, Target) | swp `target_a`, `target_b` | **target_a**: `value` → `value`<br>**target_b**: `value` → `value` | Swaps the values of `target_a` and `target_b` |
| Dup(Target) | dup `target` | **stack**: → `value` | Duplicates the value of `target` to the `stack` |
| Call(Address) | call `call_target` | **call_stack**: → `address` | Calls the `call_target` pushing the return address to the `call_stack` |
| Ret | ret | **call_stack**: `address` → | Returns from a call using the top most address on the `call_stack` |
| Halt | halt | [no change] | Halts the execution of the current program and causes the VM to shut down |
| Pause | pause | [no change] | Pauses the execution of the current program until an event is received |
| Nop | nop | [no change] | Does nothing. Good for optimizing code |
| Sig(Signal) | sig `signal` | [no change] | Triggers the given `signal` |