The SBB instruction

The SBB (Subtract with Borrow) instruction performs subtraction operations taking into account the carry (borrow) flag from the previous operation.

The SBB instruction format

InstructionDescription
SBB reg8 This format is used to subtract reg8 from the 8-bit value in register A with carry. Here reg8 can be any general-purpose register, for example A, B, C, D, E, H or L.
SBB mem8 This format is used to subtract the value in the memory location pointed to by the contents of the HL register pair from the 8-bit value in register A with carry.

Usage example

; Author: Evgeny Sergeevich Dovgopolov

main:
    mvi     a, 50h  ; Load the hexadecimal value 50h into register A
    mvi     b, 20h  ; Load the hexadecimal value 20h into register B
    stc             ; Set the carry flag CY
    sbb     b       ; Subtract the value in register B + the CY flag from the value in register A

    hlt             ; Stop program execution

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

S
Yes
Z
Yes
AC
Yes
P
Yes
CY
Yes