Address Registers

An address register is a box containing the address of a location in main memory. Each address register is entirely seperate from the others. It can be thought of as a pointer pointing to a memory location.

Load Effective Address - LEA

Initially an address is placed in an address register using the LEA instruction.

eg
LEA $2004,A0

places the address $2004 in the address register A0.

Working with Address Regsiters and Pointers

Once LEA has been used to initialise an address register, the pointer can be used to access the memory location. The pointer can also be moved so that it points to a different memory location.

This is done using post increment register indirect addressing, predecrement register indirect addressing and register indirect addressing. 

Post Increment Register Indirect Addressing

MOVE.B (A0)+, D2

A0 is inside round brackets. This means the memory location pointed to by address register A0.

The + sign after the brackets means after performing the instruction, move the pointer forward one place.

Copy a byte from the memory location pointed to by address register A0 to data register D2, finally move the pointer forward one place.


MOVE.W (A0)+, D2

This instruction is working with a word rather than a byte. so the word pointed to by A0 is copied from memory to the data register. After the instruction has been performed the pointer is moved forward one word, that is, two memory locations!


MOVE.L (A0)+, D2

This instruction is working with a longword. After the instruction has been performed the pointer is moved forward one longword, that is, four memory locations!

Pre Decrement Register Indirect Addressing

MOVE.B -(A0), D2

The - sign before the brackets means before performing the instruction, move the pointer back one place.

Firstly move the pointer back one place, then copy a byte from the memory location pointed to by address register A0 to data register D2.


MOVE.W D2, -(A0)

The previous instruction copied fata from memory into a data register. In contrast, this instruction copies a word from data register D2 into memory. The - sign means before performing the instruction, move the pointer back one place.

The instruction says firstly, move the pointer back one place (in this case a word, which is two memory locations), then copy a word from data register D2 to the new memory location pointed to by address register A0.

Register Indirect Addressing

MOVE.B (A0), D2

There is no + or - sign, so the pointer remains unchanged.

Copy a byte from the memory location pointed to by address register A0 to data register D2.

 


Revision #2
Created Sun, Apr 30, 2017 9:16 PM by Christopher Wilkinson
Updated Mon, May 1, 2017 7:32 PM by Christopher Wilkinson