Search code examples
assemblyz80

What does a LD statement passed a single argument do when the HL register is used as a 16-bit accumulator?


I'm learning z80 assembly. I'm using the Zaks textbook "Programming the Z80," and he includes the following as an elementary example of 32-bit addition after introducing how to use the HL registers as an accumulator for 16-bit operations:

LD HL,(ADR1)
LD BC,(ADR2)
ADD HL, BC
LD (ADR3)
LD HL,(ADR1+2)
LD BC,(ADR2+2)
ADC HL,BC
LD (ADR3+2)

where (ADRx) refers to an arbitrary address.

Is the instruction "LD (ADR3)" a printing error? In every other example, LD is passed two arguments.

Thanks for helping.


Solution

  • Is the instruction "LD (ADR3)" a printing error?

    Yes

    Obviously, the instructions meant are "LD (ADR3), HL" instead of "LD (ADR3)" and "LD (ADR3+2), HL" instead of "LD (ADR3+2)".