SUB

SUB (Subtraction) operator:

Name of the operator

The "SUB" (Subtraction) operator is used in programming languages to subtract two register or to subtract a value to a specified destination.

Syntax

SUB RX, Y

Where :

  • RX: Represents the destination register where the difference of RX - Y will be moved.

  • Y: Represents the source register or immediate value that will be subtracted to the destination register.

Usage

  • Addition of Register Values:

    SUB R1, R2
    • Detail: This example demonstrates the subtraction of the values in registers R1 and R2.

      The result is stored in register R1.

  • Addition of Immediate Value:

    SUB R3, #10
    • Detail: This code subtracts the immediate value 10 to the contents of register R3. The result is stored back in register R3.

Last updated