Computer Instructions: Types of Operations

  1. Boolean Logic Operations (involving bits, usually a register's bits):
    • NOT: flips the bits of a number. Example: NOT X flips the bits of variable X in memory: $X'$.
    • AND: ANDs numbers. Example: AND R1, R2, R3 will do the bitwise AND operation $R1 \cdot R2 \cdot R3$.
    • OR: ORs numbers. Example: OR R1, R2 will do the bitwise OR operation $R1 + R2 + R3$.
    • XOR: XORs numbers. Example: XOR R1 will do the bitwise XOR operation $AC ⊕ R1$ (AC is an accumulator register.)
    • TEST: ANDs numbers, but only sets bits in the status register: if the result of the ANDing is a $0$, the zero flag (bit) is set to $1$, and if the result of the ANDing is a negative, the sign flag (bit) is set to $1$. The registers or variables themselves don't change. Example: TEST X, Y.
    • CMP: Compares numbers by subtracting one from the other, but only sets bits in the status register: if the result of the subtraction is a $0$, the zero flag (bit) is set to $1$, and if the result of the subtraction is a negative, the sign flag (bit) is set to $1$. The registers or variables themselves don't change. Example: CMP X, R1.