sub

Subtract

Subtracts the value of the first operand from the second operand and stores the result in the second operand.

Sizes .b .w .l, .w by default

Used in
XNZVC ●●●●●
  • ● depends on the result

Forms

Operands

<ea>
An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With opt p=68020, an allowed d(An,Xn) or d(PC,Xn) mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More
#imm
An immediate value written after #: a number, character or label, such as #10, #$FF or #'a'. It must fit the operation’s size: byte -128 to 255, word -32768 to 65535, or long -2147483648 to 4294967295; signed and unsigned spellings are accepted. More

If the second operand is an address register, the SUBA instruction is used instead.

move.l #$100, d0
sub.b #$01, d0 ; only affects low byte

* --- Borrow: subtracting more than available ---
move.l #$00, d1
sub.b #$01, d1 ; carry flag set (borrow)

* --- Overflow ---
move.l #$80, d2
sub.b #$01, d2 ; $7F, V flag set