ASSEMBLY INTERPRETER

Available commands

mov x y - copies y (either a constant value or the content of a register) into register x

inc x - increases the content of the register x by one

dec x - decreases the content of the register x by one

add x y - add the content of the register x with y (either an integer or the value of a register) and stores the result in x (i.e. register[x] += y).

sub x y - subtract y (either an integer or the value of a register) from the register x and stores the result in x (i.e. register[x] -= y).

mul x y - same with multiply

div x y - same with integer division

jnz x y - jumps to an instruction y steps away (positive means forward, negative means backward, y can be a register or a constant), but only if x (a constant or a register) is not zero

label: - define a label position (label = identifier + ":", an identifier being a string that does not match any other command). Jump commands and call are aimed to these labels positions in the program.

jmp lbl - jumps to the label lbl.

cmp x y - compares x (either an integer or the value of a register) and y (either an integer or the value of a register). The result is used in the conditional jumps (jne, je, jge, jg, jle and jl)

jne lbl - jump to the label lbl if the values of the previous cmp command were not equal.

je lbl - jump to the label lbl if the values of the previous cmp command were equal.

jge lbl - jump to the label lbl if x was greater or equal than y in the previous cmp command.

jg lbl - jump to the label lbl if x was greater than y in the previous cmp command.

jle lbl - jump to the label lbl if x was less or equal than y in the previous cmp command.

jl lbl - jump to the label lbl if x was less than y in the previous cmp command.