cpucpu-architectureinstruction-setinstructionsmachine-instruction

Is carry flag usually cleared after Jump-Not-Carry instruction has been evaluated?


I'm writing a simple simulation of a microprocessor, and, for the JNC instruction, I am unsure if the carry bit is automatically reset after the JNC instruction. Is it (generally, although different cpu architectures might not solve it the same way there are probably trends)?


Solution

  • On normal CPUs, branch instructions only read flags, they don't modify them, as you can see from looking at popular existing ISAs such as

    Just like how add dst, src or mov dst, src doesn't zero the source.

    A pure branch instruction only writes the program counter, no other side-effects. Some ISAs with FLAGS may also have a sub-and-branch instruction like x86's loop, although that doesn't use CF at all.