Search code examples
assemblyx86carryflag

Connection between the BT instruction and the carry flag CF


I know that for example BT BX, 0 transfers the first bit of the BX register to the carry flag CF.

Isn't the carry flag restricted to only have values of 0 and 1, because it's a flag?

Does BT change the CF value from the first bit of the register even if it doesn't hold 0 or 1?

If someone would be able to write here how it works, it would be great!


Solution

  • Yes, the Carry flag can have one of only two possible values: 0 or 1. So does any bit of any register, for instance the least significant bit Nr.0 of BX. Its value is copied by BT BX,0 to CF; BTW this can be used to test if the number in BX is odd or even:

        BT BX,0
        JC Odd
    Even: