<<< STOS Store String     Index     XCHG Exchange Operands >>>


SUB Arithmetic Subtraction

Flags affected:

        O D I T S Z A P C  OF: Overflow flag  TF: Trap flag AF: Aux carry
        F F F F F F F F F  DF: Direction flag SF: Sign flag PF: Parity flag
        *       * * * * *  IF: Interrupt flag ZF: Zero flag CF: Carry flag

Legal forms:

        SUB r8,r8
        SUB m8,r8
        SUB r8,m8
        SUB r16,r16
        SUB m16,r16
        SUB r16,m16
        SUB r32,r32    386+
        SUB m32,r32    386+
        SUB r32,m32    386+
        SUB r8,i8
        SUB m8,i8
        SUB r16,i16
        SUB m16,i16
        SUB r32,i32    386+
        SUB m32,i32    386+
        SUB r16,i8
        SUB m16,i8
        SUB r32,i8     386+
        SUB m32,i8     386+
        SUB AL,i8
        SUB AX,i16
        SUB EAX,i32    386+

Examples:

        SUB BX,DI
        SUB AX,0FFFFH            ;Uses single-byte opcode
        SUB AL,42H               ;Uses single-byte opcode
        SUB BP,17H
        SUB ECX,DWORD [ESI+5]
        SUB EAX,17
        SUB WORD [BX+SI+Inset],5
        SUB WORD [ES:BX],0B800H

Notes:

SUB performs a subtraction without borrow, where the source is subtracted from the destination, and the result replaces the destination. If the result is negative, the Carry flag is set. Multiple-precision subtraction can be performed by following SUB with SBB (Subtract with Borrow) which takes the Carry flag into account as a borrow.

        r8 = AL AH BL BH CL CH DL DH        r16 = AX BX CX DX BP SP SI DI
        sr = CS DS SS ES FS GS              r32 = EAX EBX ECX EDX EBP ESP ESI EDI
        m8 = 8-bit memory data              m16 = 16-bit memory data
        m32 = 32-bit memory data            i8 = 8-bit immediate data
        i16 = 16-bit immediate data         i32 = 32-bit immediate data
        d8 = 8-bit signed displacement      d16 = 16-bit signed displacement
        d32 = 32-bit unsigned displacement


<<< STOS Store String     Index     XCHG Exchange Operands >>>