-
What values can the carry flag hold? Is it just 0x00 and 0x01 (boolean) or is it 16 (or 32/64) bits like the rest of the CPU registers?
-
How do I check its status? Do I just use it like a normal CPU register like
cmp cf, 0x00thenjg <jump destination>? -
I am writing a mini-OS. Is it good practice to use it for my own purposes, or should it be reserved for exclusive write-permissions for the CPU, and all I do is read from it?
What values can the carry flag hold? Is it just 0x00 and 0x01 (boolean)
Share
It’s a flag, it can only hold true or false (technically 1 or 0, but effectively the truth values as shown).
In terms of using it, no, you don’t compare it to something and then use
jg. It’s at the same level of abstraction as other flags so you can just use:It’s set automatically by certain instructions so, for example, to add two values and detect carry, you can use something like:
And, while it’s mostly set by those instructions, you can also do it manually with
stc(set),clc(clear) andcmc(complement). For example, it’s often useful to clear it before-hand if you’re entering a loop where the value is carried forward to the next iteration.