liveBook · Manning

ADC

As explained in Classic Game Programming on the NES: Make your own retro video game

ADC is a 6502 instruction that adds a value and the current carry flag to the accumulator register.

ADC adds a source value and the current carry flag to the accumulator register, storing the result back in A. Use CLC first when carry must not contribute. section 4.1.1

ADC reads its operand through several addressing forms:

  • Direct values, such as ADC #$05. section 4.1.1
  • Absolute or zero-page memory addresses, such as ADC $0300 or ADC $06. section 4.1.1
  • Indexed and indirect addresses using X or Y registers. section 4.1.1

Adding a direct value

CLC LDA #$01 ADC #$05 The accumulator becomes $06. Assemble and run the commands in the Online Assembler Simulator, then verify the result in the Debug window. section 4.1.1

Listing 4.2 Adding a direct value
clc          #1
lda #$01
adc #$05

Shows the minimal sequence for clearing carry, loading A, and adding an immediate value. section 4.1.1

How Classic Game Programming on the NES: Make your own retro video game covers it

How deep it goes
Defines carry behavior and demonstrates direct, memory, indexed, and indirect addressing with simulator-verifiable listings.
Examples
Uses immediate values, absolute and zero-page memory, indexed addresses, indirect addresses, and simulator debug output.
What you can do after
Apply it via the Online Assembler Simulator and verify accumulator and flag results after assembling and running examples.
How it connects
Connects the accumulator, carry flag, CLC, LDA, X and Y registers, and several memory-addressing modes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Game Programming on the NES: Make your own retro video game. The section links point to the parts of the book it draws on.