DYSTOPIANPIXEL

The accumulator

Understand the A register and how it holds values for simple calculations.

Next Asset Lab concept artwork showing sprite patterns, palette colours and animation frames
Next Asset Lab concept artwork · Begin with Odin Dev.2k and the foundations of Z80 assembly.
TUTORIAL 1 / PART 07

The accumulator

Why A is special

The A register is usually called the accumulator. Historically, processors often had a main register in which arithmetic and logic results accumulated. The Z80 is more flexible than that simple description suggests, but A is still central to many instructions.

For example:

ld a,$10
add a,$05

The first instruction places $10 into A. The second instruction adds $05 to the value already in A. Afterwards A contains $15.

It is useful to read the two lines almost as plain English:

load A with hexadecimal 10
add hexadecimal 05 to A

LD means load

LD is the Z80 instruction mnemonic for 'load'. A mnemonic is a short human-readable name for an instruction. The CPU does not execute the letters L and D. Odin translates the mnemonic into machine code.