You are on page 1of 7

Addressing modes

Addressing
Memory can be visualised as a series of pigeon-holes into which instructions and data can be stored. Each block of memory has a unique address. Data can be written to or read from each address. Addressing modes are the different ways in which the addresses can be accessed. For example, you may want to load the accumulator with a particular value. Depending on how and where the value is stored this will require the use of different addressing modes.

Immediate addressing (relative addressing)


The value to be loaded is not stored in a memory address at all, but is included as part of the instruction. For example: LDAA #12H LDA means load the accumulator # indicates that it is a value that should be loaded and not an address 12 is the value to be loaded H indicates that in this case it is a hexadecimal number.

Direct addressing (absolute addressing)


Direct addressing tells the CPU the address that contains the data you want to access. For example: LDAA 100 means load the accumulator with the data stored at memory address 100. With an 8-bit address bus, only 256 different memory locations are addressable. Even with 32-bit, you are still limiting the amount of memory that is addressable using this method.

Indirect addressing
Indirect addressing tells the CPU an address that contains another address where the data is stored. For example, LDAI 132: points to memory address 132 there will be another address at this location the accumulator is loaded with the data at this address. This method makes it easier to alter the actions of a program, as the data can be altered without having to adjust the original program.

Index addressing
The address to be accessed is modified by the addition of a number held in an index register. For example, LDX R1 32: LDX means load the accumulator (using indexed addressing) R1 is the register that contains the start number for the address 32 is the number to be added to the number at R1 to locate the address where the data is stored. This increases the amount of addressable memory. This particular method is used for addressing data stored in an array, as it will be stored in consecutive memory locations.

Base register addressing


This is the same as indexed addressing, except the start address is held in a base register. It uses a larger offset than index addressing. The contents of this register rarely change during the execution of the program (unlike index addressing).

You might also like