Professional Documents
Culture Documents
Agenda
2 Addressing Modes
Instruction Characteristics
Instruction Characteristics
Interface Design
A good interface:
Lasts through many implementations (portability,
compatability)
Is used in many different ways (generality)
Provides convenient functionality to higher levels
Permits an efficient implementation at lower levels
Instruction Characteristics
Instruction Characteristics
CISC RISC
Intel x86, Pentium (MIPS,Sparc,HP-PA,IBM RS6000,PowerPC . . .1987)
Instruction Characteristics
Instruction Characteristics
Elements of an Instruction
Instruction Characteristics
Instruction Representation
Instruction Characteristics
Instruction Characteristics
Instruction Types
Data processing
Data storage (main memory)
Data movement (internal transfer and I/O)
Program flow control
Instruction Characteristics
Instruction Characteristics
Number of Addresses
Instruction Characteristics
More addresses
More complex (powerful?) instructions
Less instructions per program
slower instruction cycle
Fewer addresses
Less complex (powerful?) instructions
More instructions per program, e.g. data movement
Faster instruction cycle
Instruction Characteristics
Compute
(A − B)
(C + (D ∗ E ))
assuming each of them is in a read-only register which cannot
be modified.
Additional registers can be used if needed.
Instruction Characteristics
Instruction Comment
SUB Y, A, B Y←A-B
MPY T, D, E T←DxE
ADD T, T, C T←T+C
DIV Y, Y, T Y←Y/T
Instruction Characteristics
Instruction Comment
MOVE Y, A Y←A
SUB Y, B Y←Y-B
MOVE T, D T←D
MPY T, E T←TxE
ADD T, C T←T+C
DIV Y, T Y←Y/T
Instruction Characteristics
Instruction Comment
LOAD D AC ← D
MPY E AC ← AC xE
ADD C AC ← AC +C
STOR Y Y ← AC
LOAD A AC ← A
SUB B AC ← AC -B
DIV Y AC ← AC /Y
STOR Y Y ← AC
Instruction Characteristics
Types of operands
Types of Operands
Types of operands
Numbers
Types of operands
Characters
Types of operands
Logical Data
Types of operations
Instruction Types
Types of operations
Data Transfer
Specify
Source
Destination
Amount of data
May be different instructions for different movements
Or one instruction and different addresses
Types of operations
Arithmetic
Types of operations
Types of operations
Types of operations
Types of operations
Conversion
Types of operations
Input/Output
Types of operations
Systems Control
Privileged instructions
CPU needs to be in specific state
Ring 0 on 80386+
Kernel mode
For operating systems use
Types of operations
Transfer of Control
Types of operations
Branch Instruction
Types of operations
Procedures
Types of operations
Nested Procedures
Types of operations
Addressing Modes
Immediate
Direct
Indirect
Register
Register indirect
Displacement
Stack
Immediate Addressing
Instruction
Opcode Operand
Direct Addressing
Instruction
Opcode Address A
Memory
Operand
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
A rarely used variant of indirect addressing is multilevel or
cascaded indirect addressing
EA = ( . . . (A) . . . )
multiple memory accesses required to find operand
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
Register Addressing
Instruction
Operand
Instruction
Registers
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
Most common uses:
Relative addressing
Base-register addressing
Indexing
Instruction
Registers
Relative Addressing
Base-Register Addressing
Indexed Addressing
The address field references a main memory address and the
referenced register contains a positive displacement from that
address
The method of calculating the EA is the same as for
base-register addressing
An important use is to provide an efficient mechanism for
performing iterative operations
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
Preindexing - Indexing is performed before the indirection
Stack Addressing
Instruction Formats
Instruction Length
Allocation of Bits