Arithmetic
Arithmetic instructions perform integer math on register and immediate operands.
NEG
Negates a register. Has the same effect as multiplying by -1.
| Instruction | Operand 1 | Operation |
|---|---|---|
NEG | Reg | OP1 = -OP1 |
block->neg(REG_SP);ADD
Adds a register or immediate value to a register.
| Instruction | Operand 1 | Operand 2 | Operation |
|---|---|---|---|
ADD | Reg | Reg/Imm | OP1 = OP1 + OP2 |
block->add(REG_SP, 1);SUB
Subtracts a register or immediate value from a register.
| Instruction | Operand 1 | Operand 2 | Operation |
|---|---|---|---|
SUB | Reg | Reg/Imm | OP1 = OP1 - OP2 |
block->sub(REG_SP, 1);MUL
Multiplies a register with another register or immediate value (unsigned, low half).
| Instruction | Operand 1 | Operand 2 | Operation |
|---|---|---|---|
MUL | Reg | Reg/Imm | OP1 = OP1 * OP2 |
block->mul(REG_SP, 2);MULHI
Multiplies a register with another register or immediate value and saves the higher bits.
| Instruction | Operand 1 | Operand 2 | Operation |
|---|---|---|---|
MULHI | Reg | Reg/Imm | OP1 = [OP1 * OP2] >> N |
block->mulhi(REG_SP, 2);IMUL
Signed multiplication of a register with another register or immediate value (low half).
| Instruction | Operand 1 | Operand 2 | Operation |
|---|---|---|---|
IMUL | Reg | Reg/Imm | OP1 = OP1 * OP2 (signed) |
block->imul(REG_SP, 2);IMULHI
Signed multiplication saving the higher bits of the result.
| Instruction | Operand 1 | Operand 2 | Operation |
|---|---|---|---|
IMULHI | Reg | Reg/Imm | OP1 = [OP1 * OP2] >> N (signed) |
block->imulhi(REG_SP, 2);DIV
Performs an unsigned division. The dividend spans two registers for high and low bits.
| Instruction | Operand 1 | Operand 2 | Operand 3 | Operation |
|---|---|---|---|---|
DIV | Reg | Reg/Imm | Reg/Imm | OP1 = [OP2:OP1] / OP3 |
block->div(REG_SP, 0, REG_SP); // sets REG_SP to 1IDIV
Performs a signed division. The dividend spans two registers for high and low bits.
| Instruction | Operand 1 | Operand 2 | Operand 3 | Operation |
|---|---|---|---|---|
IDIV | Reg | Reg/Imm | Reg/Imm | OP1 = [OP2:OP1] / OP3 (signed) |
block->idiv(REG_SP, 0, REG_SP);REM
Performs an unsigned modulo operation. The source spans two registers.
| Instruction | Operand 1 | Operand 2 | Operand 3 | Operation |
|---|---|---|---|---|
REM | Reg | Reg/Imm | Reg/Imm | OP1 = [OP2:OP1] % OP3 |
block->rem(REG_SP, 0, REG_SP); // sets REG_SP to 0IREM
Performs a signed modulo operation. The source spans two registers.
| Instruction | Operand 1 | Operand 2 | Operand 3 | Operation |
|---|---|---|---|---|
IREM | Reg | Reg/Imm | Reg/Imm | OP1 = [OP2:OP1] % OP3 (signed) |
block->irem(REG_SP, 0, REG_SP);