[Filling a register with the Carry Flag]               [Assembler][/][8086]

This gem will fill any register with the Carry Flag. There are numerous
situations where this is a usefull thing. This small gem looks like this:

;
; filling a register with the carry flag
;
; input:
;   none
;
; output:
;   ax = ffff if CF=1, else 0
;
; destroys:
;   flags
;

        sbb     ax,ax

The gem works because when you subtract AX from AX a zero will be the
return, however if the carry flag (CF=1) is set the instruction will use
the extra bit to borrow from and this will make the selected register
contain FFFFh. Note that the Carry Flag will not be modified. AX may be
replaced with any available register. Also note that there is an
instruction that does the same thing for AL, see SALC - Set AL on Carry.
                                                     Gem writer: Ervin Toth
                                                   last updated: 1998-03-16
