Computer Instructions: Types of Operations
We can divide instructions into several type categories:
- Arithmetic Operations (involving integers or floating-point numbers):
- ADD: Adds up 2 or 3 numbers. Example: ADD R1, R2 to add the number in register R2 to the number in register R1.
- SUB: Subtracts numbers. Example: SUB R1, X, Y to subtract the memory variables X and Y from register R1.
- MUL: Multiplies numbers. Example: MUL X to multiply the variable X by a specific accumulator register.
- DIV: Divides numbers. Example: DIV X, Y to divide the variable X by the variable Y, and store the result in X.
- INC: Increments a number (= add $1$ to it.) Example: INC R1 to add $1$ to the register R1.
- DEC: Decrements a number (= subtract $1$ from it.) Example: DEC X to subtract $1$ from the variable X.
- NEG: Changes the sign of a number from positive to negative and vice versa. Example: NEG R2 to negate R2.
[Note that an instruction's name on one computer may differ from its name on another computer. E.g., a computer may call the multiplication instruction as MUL, MULT, or MULTIPLY: it depends on the decision of the computer's architecturers.]