Today you implement 16-bit INC/DEC - stepping a whole register pair up or down which, unlike their 8-bit cousins, touch no flags at all. It rounds out the arithmetic core and gives you the pointer-stepping the memory chapter will lean on.
Implement INC BC and DEC BC, which step a register pair up or down without touching any flags.
INC BC (opcode 0x03) adds one to a whole register pair, carrying naturally
from the low byte into the high byte - 0x00FF becomes 0x0100. Unlike its
8-bit cousin from lesson 15, the 16-bit INC/DEC affect no flags whatsoever,
because the pair is usually a pointer being walked and the program does not want
its status bits disturbed for that.
With this you have a complete arithmetic core: 8- and 16-bit add and subtract, carries, logic, compare, and counting. If you want a victory lap, hand-assemble a short straight-line program - a few adds and increments - and check the final registers against what you worked out on paper; that’s an optional stretch, not required today. Real loops need the conditional jumps of the next chapter, but the math underneath them is done.
case 0x03: // INC BC - no flags touched at allc.SetBC(c.BC() + 1)return 8case 0x0B: // DEC BC - likewise leaves every flag alonec.SetBC(c.BC() - 1)return 8
16-bit INC/DEC rr - unlike the 8-bit versions, these set no flags.