CS 219 Chapter 13.1 Addressing Modes

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Preindexing Usage

•Each indexing points to different base memory address •Multiway branch table •Location A has a table for addresses to branch

Types of displacement addressing

1) Relative addressing 2)Base-Register Addressing 3)Indexing

What are the 7 addressing modes?

1. Immediate 2. Direct 3. Indirect 4. Register 5. Register Indirect 6. Displacement 7. Stack

Direct Addressing

The address field contains the effective address of the operand

Register Addressing

The address field refers to a register rather than a main memory address:

Indirect Addressing

The address field refers to the address of a word in memory, which in turn contains a full-length address of the operand.

Postindexing

The indexing (increasing R values) is done after the indirection on A is applied •The indirection is done only once on A EA = (A) + (R) •The content of the memory location A is looked up •It is then indexed by the register R

Preindexing

The indexing (increasing R values) is done before the indirection is applied on the whole thing (A + (R) ) •The indirection is done every time when R is incremented EA = ( A + (R) ) 1. A is taken from the instruction 2. It is then indexed by the register R 3. Then, indirection is performed

Relative addressing

Also called PC-relative addressing The register R is implicit, which is PC (program counter) EA = A + (PC) i.e. get operand from A cells from current location pointed to by PC Exploits locality of reference & cache usage Since the register number is implicit, the instruction is short

Displacement Addressing

Combination of direct addressing and register indirect addressing EA = A + (R) Address field holds two values A = base value, used directly R = register that holds a displacement (this could be implicit depending on opcode)

Base-Register addressing

EA = A + (R) A holds displacement R holds pointer to base address R may be explicit or implicit When to use it? Convenient for implementing segmentation e.g. segment registers in 80x86 Either single base register (implied), or one designated one out of multiple can be used

Immediate Addressing

Operand is part of instruction •Operand = Address field •e.g. ADD 5 = Add 5 to contents of accumulator 5 is operand •Used for constants, or initial values of variables

Indexing

Opposite of the Base-Register addressing Memory has the base address EA = A + (R) A = base (R) = displacement Advantage of using A as base In A, more bits are available than in registers Good for accessing arrays List of numbers stored in A, A+1, A+2, ... With EA = A + R Value A is stored in the instruction Chosen register R (index register) is initialized to 0 and incremented

Register Indirect Addressing

Register indirect addressing is analogous to indirect addressing. In both cases, the only difference is whether the address field refers to a memory location or a register.

Stack Addressing

•Stack is a memory block with last-in-first-out scheme •Operand is (implicitly) on top of stack e.g. ADD ->Pop top two items from stack and add •Stack pointer (or the top location of a stack) is in a register ->similar to register indirect addressing •Implied addressing •No need to specify any address

Postindexing Usage

•The instruction does not change, but can be used for different memory areas •The referenced memory location (A) has a variable pointer, pointing to different data blocks by time


Ensembles d'études connexes

Chapter 1, 2 & 3 - CompTIA Security+

View Set

Med Surg II - Chapt 66 - Management of Pts with Neurologic Dysfunction

View Set

Exam 2 - Renal, Muskoskeletal (Respiratory & Fluid & Electrolytes)

View Set

A2H 4/14 Solving Quadratic Equations

View Set