Z80 Assembly 08: Multi-Byte Math and the Alternate Registers
Arithmetic with Carry: ADC and SBC When adding numbers larger than 8 bits (like a 16-bit word or a 32-bit integer), you must add the Carry flag (C) from the previous operation into the current one. This is done with the ADC and SBC instructions. The Principle: Add (or Subtract) the current byte PLUS the Carry flag. Instruction Action Purpose ADC A, R A ← A + R + C Add with Carry: Used to link the result of the previous 8-bit addition. SBC A, R A ← A - R - C Subtract with Carry/Borrow: Used to link the result of the previous 8-bit subtraction. Example: 16-bit Addition (BC + DE) ...