If I do the following (where cx has 0b1011 or 11 in decimal prior to the shift):
shl cx, 1
After shl, the carry flag should be set. As shl will move 0b1011 to 0b0110 and 1 will be in CF.
My question is: how do I access the value in the carry flag? Let's say I want to append it to register bx, obviously mov bx, cf does not work so how would you go about doing that?
That's what "add-with-carry" is for:
adc bx, 0 ; adds "0" plus the value of CF to bx
If you want to set a (byte) register exactly equal to the value of the carry flag, use "set-if-carry":
setc bl ; BL = CF ? 1 : 0
You should probably use the JC and JNC conditional branching instructions to determine if the flag is set or not.
There is also the PUSHFD instructions to dump the entire EFLAGS to the stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With