170. Instruction bvc

implement Branch if Overflow Clear behavior.

Lesson 170 of 356 · tests/chapter_01_cpu/test_170_instruction_bvc.py

Why this step exists

BVC observes the existing signed-arithmetic Overflow condition and branches when that flag is clear without modifying it.

In this step, after BMI, add exactly

`emulator/cpu/instructions.py::bvc`::

def bvc(cpu: CPU, offset: int):
    if not cpu.flags.get_overflow_flag():
        cpu.pc = (cpu.pc + offset) & 0xFFFF

If clear, it adds the signed relative displacement to the post-operand PC and masks the target into the 16-bit address space.

Invariants: Overflow clear takes the branch; Overflow set leaves PC unchanged. The instruction changes no flags, other registers, or memory. Misconception: BVC neither clears Overflow nor decides from Carry or the offset's sign.

Out of scope: complementary BVS is lesson 171. Branch imports, relative opcode handlers, and table entries are lessons 172-179.

Run this lesson

uv run pytest tests/chapter_01_cpu/test_170_instruction_bvc.py -v