If the Carry (C
) flag holds a value that you want to put into a register, the naïve way is to do something like this:
mov al, 1
jc NotZero
mov al, 0
NotZero:
A more direct way, avoiding the jump, is to use "Subtract with Borrow":
sbb al,al ; Move Carry to al
If C
is zero, then al
will be zero. Otherwise it will be 0xFF
(-1
). If you need it to be 0x01
, add:
and al, 0x01 ; Mask down to 1 or 0