LOAD

There are five different addressing modes.

1. Direct Addressing

LD A, (0F1C)

This loads the contents of 0F1C into the A-register. Note that, by convention, the movement is from right to left, so that we can write:

LD (0F1C), A

and mean "copy the contents of the A-register into 0F1C".

The A-register is the only 8-bit register that can be directly addressed.

2. Indirect Addressing

LD A, (HL)

This means "load the A-register through (ie from the address contained in) the HL register". To pass data in the opposite direction we could have:

LD (HL), A

which puts the contents of A into the address contained in HL. (For this instruction, registers other than A are allowed.)

3. Indexed addressing

Here, we need to indicate which index register is in use, and the amount of the offset:

LD A, (IX+2E)

Note that in direct addressing, I showed an address of 4 hex digits, because 16 bits (2 bytes) are allowed for the address. The offset value in an indexed address instruction must be held in 1 byte, however, so I've only shown two hex digits.

4. Register-to-register

We can transfer data between registers like this:

LD D, B

which means "load the contents of B into D".

5. Immediate

Here, data itself, rather than the address of data, is placed in the address field. So we can write:

LD B, 07

to mean "put the number 7 in B". Note again that the number is two hex digits, since it has to be stored in the single byte of the B-register. Note also that a "LD" is really a copy: the numbers are retained in their original addresses or registers, but a copy is placed at the destination.

Back to Instructions Overview