SUBX Instruction



The instruction SUBX (SUBtract eXtended) works the same as SUB but the X flag is also subtracted. This makes it possible to add big numbers stored in many bytes (multi-precision).

This instruction has two methods:

1. Subtract a data register from a data register.
2. Subtract a memory location to another memory location. You must use -(An) on both operands then.

ADDRESS METHODS: Dn, -(An)

DATA LENGTH: Byte, word, longword


FLAGS: X - Set if a loan was required from the most significant bit, else 0.
N - S
Z - Cleared if the result is not zero, else unaffected
C - Same as X
V - S

The Z flag works in another way now, making it possible to check if a big number (much bigger than 32 bits) is zero. You must set the zero flag before making the addition though, shorter than comparing a register with itself.

SYNTAX: SUBX Dy,Dx
SUBX -(Ay),-(Ax)

EXAMPLE CODE:

    SUBX.B    D0,D1    D1 = D1 - D0 - X