William Stallings Computer Organization and Architecture 7 Edition Instruction Sets: Addressing Modes and Formats
William Stallings Computer Organization and Architecture 7 Edition Instruction Sets: Addressing Modes and Formats
Computer Organization
and Architecture
7th Edition
Chapter 11
Instruction Sets:
Addressing Modes and Formats
Addressing Modes
• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement (Indexed)
• Stack
Immediate Addressing
• Operand is part of instruction
• Operand = address field
• e.g. ADD 5
—5 is operand
—Add 5 to contents of accumulator
• The simplest form of addressing is immediate addressing
• No memory reference to fetch data (saving one memory
• or cache cycle in the instruction cycle)
• Fast
• The disadvantage is that the size of the number is restricted
to the size of the address field
Immediate Addressing Diagram
Instruction
Opcode Operand
Direct Addressing
• Address field contains address of operand
• Effective address (EA) = address field (A)
• e.g. ADD A
—Add contents of cell A in the memory to accumulator
—Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective
address
• Limited address space:
The length of the address field is usually less than the
word length, thus limiting the address range
Direct Addressing Diagram
Instruction
Opcode Address A
Memory
Operand
Indirect Addressing (1)
• Memory cell pointed by address field contains the
address of (pointer to) the operand
• EA = (A)
—Look in A, find address (A) and look there for operand
• e.g. ADD (A)
—Add contents of cell pointed to by contents of A to
accumulator
Indirect Addressing (2)
• Large address space
• 2n where n = word length
• May be nested, multilevel, cascaded
—e.g. EA = (((A)))
– Draw the diagram yourself
• Multiple memory accesses to find operand
• Hence slower
Indirect Addressing Diagram
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
Register Addressing (1)
• Operand is held in register named in
address filed
• EA = R
• Limited number of registers
• Very small address field needed
—Shorter instructions:
An address field that references registers will
have from 3 to 5 bits, so that a total of from 8
to 32 general-purpose registers can be
referenced
—Faster instruction fetch
Register Addressing (2)
• No memory access
• Very fast execution
• Very limited address space
• Multiple registers helps performance
—Requires good assembly programming or
compiler writing
• Direct addressing
Register Addressing Diagram
Instruction
Opcode Register Address R
Registers
Operand
Register Indirect Addressing
• Similar to indirect addressing
• EA = (R)
• Operand is in memory cell pointed by
contents of register R
• Large address space (2n)
• One fewer (less) memory access than
indirect addressing
Register Indirect Addressing Diagram
Instruction
Opcode Register Address R
Memory
Registers
Instruction
Opcode Register R Address A
Memory
Registers
• Post-indexing:
EA = (A) + (R)
First, the contents of the address field are used to access a memory
location containing a direct address. This address is then indexed by
the register value
• e.g.
—ADD Pop top two items from stack
and add
Conclusion
Pentium Addressing Modes
• Virtual or effective address is offset into segment
— Starting address plus offset gives linear address
— This goes through page translation if paging enabled
• 12 addressing modes available
— Immediate
— Register operand
— Displacement
— Base
— Base with displacement
— Scaled index with displacement
— Base with index and displacement
— Base scaled index with displacement
— Relative
Pentium Addressing Modes
• For the immediate mode, the operand is included in the
instruction. The operand can be a byte, word, or doubleword
of data.
Offset:
For this addressing method, indexing is not used. An offset value is added to the
value in the base register to form the memory address. As an example Figure 11.3a
illustrates this method with the assembly language instruction
STRB r0, [r1, #12].
PowerPC Addressing Modes
Pre-index:
The memory address is formed in the same way as for offset addressing.
The memory address is also written back to the base register
PowerPC Addressing Modes
Post-index:
• Number of operands
• Register versus memory:
With a single user-visible register
(usually called the accumulator), one operand address is
implicit and consumes no instruction bits