Instruction Sets: Addressing Modes and Formats: William Stallings, Computer Organization and Architecture, 9 Edition
Instruction Sets: Addressing Modes and Formats: William Stallings, Computer Organization and Architecture, 9 Edition
Instruction Sets:
Objectives
After studying this chapter, you should be able to:
Describe the various types of addressing modes common in
instruction sets.
Present an overview of x86 and ARM addressing modes (ARM:
Advanced RISC Machine, RISC: Reduced Instruction Set
Computer).
Summarize the issues and trade-offs involved in designing an
instruction format.
Present an overview of x86 and ARM instruction formats.
Understand the distinction between machine language and
assembly language.
+ 3
Contents
Immediate
Direct
Ways to specify an operand
Indirect
in an instruction:
Register
Register indirect
Displacement (replace)
Stack
+
Addressing Immediate :
Operand is a
Direct :
Operand is the
value of a
Modes specific value
variable
Indirect : Operand
Register : Operand is
address is stored in
a specific register
another variable
Displacement :
Register Indirect : Replace the value of a
Operand address is variable with an
stored in a register expression
Implicit : Operand
address is stored in
stack register
+ 6
Immediate Addressing
Operand = A
This mode can be used to define and use constants or set initial values of
variables
Typically the number will be stored in twos complement form
The leftmost bit of the operand field is used as a sign bit
Advantage:
no memory reference other than the instruction fetch is required to obtain the
operand, thus saving one memory or cache cycle in the instruction cycle
Disadvantage:
The size of the number is restricted to the size of the address field, which, in most
instruction sets, is small compared with the word length
Direct Addressing
8
Was common in
earlier generations of
computers
Limitation is that it
provides only a
limited address space
+ 9
Indirect Addressing
Reference to the address of a word in memory which contains a full-length
address of the operand
EA = (A)
Parentheses are to be interpreted as meaning contents of
Advantage:
For a word length of N an address space of 2N is now available
Disadvantage:
Instruction execution requires two memory references to fetch the operand
One to get its address and a second to get its value
Register Addressing
Address
field refers to a register rather than a main
memory address
EA = R
Advantages:
Only a small address field is needed in the instruction
No time-consuming memory references are required
Disadvantage:
The address space is very limited
+ 11
EA = (R)
Address space limitation of the address field is overcome
by having that field refer to a word-length location
containing an address
Uses one less memory reference than indirect addressing
+ 12
Displacement Addressing
Combines the capabilities of direct addressing and register indirect
addressing
EA = A + (R)
Requires that the instruction have two address fields, at least one of
which is explicit
The value contained in one address field (value = A) is used directly
The other address field refers to a register whose contents are added to A to
produce the effective address
Relative Addressing
Theimplicitly referenced register is the program counter
(PC)
The next instruction address is added to the address field to
produce the EA
Typically the address field is treated as a twos complement number
for this operation
Thus the effective address is a displacement relative to the address
of the instruction
Base-Register Addressing
The referenced register contains a main memory address and the
address field contains a displacement from that address
The address field references a main memory address and the referenced register
contains a positive displacement from that address
Autoindexing
Automatically increment or decrement the index register after each reference to it
EA = A + (R)
(R) (R) + 1
Postindexing
Indexing is performed after the indirection
EA = (A) + (R)
Preindexing
Indexing is performed before the indirection
EA = (A + (R))
+ 16
Stack Addressing
A stack is a linear array of locations
Sometimes referred to as a pushdown list or last-in-first-out queue
A stack is a reserved block of locations
Items are appended to the top of the stack so that the block is partially
filled
Associated with the stack is a pointer whose value is the address of
the top of the stack
The stack pointer is maintained in a register
Thus references to stack locations in memory are in fact register indirect
addresses
Is a form of implied addressing
The machine instructions need not include a memory reference but
implicitly operate on the top of the stack
Must include an
For most opcode and, Define the layout
instruction sets implicitly or of the bits of an
more than one explicitly, indicate instruction, in
instruction format the addressing terms of its
is used mode for each constituent fields
operand
17
13.3- Instruction Formats
+ Instruction Length 18
Allocation of Bits
Number of addressing modes
Number of operands
Register versus memory
Number of register sets
Address range
Address granularity (cốt lõi)
PDP-8 Instruction Format 20
+ 21
More understandable
More readable
( Assembly program
looks like this)
Assembly Language (Wiki) 28