Documente Academic
Documente Profesional
Documente Cultură
Douglas Comer Computer Science Department Purdue University 250 N. University Street West Lafayette, IN 47907-2066 http://www.cs.purdue.edu/people/comer
Copyright 2006. All rights reserved. This document may not be reproduced by any means without written consent of the author.
CS250 -- Chapt. 6
2006
CS250 -- Chapt. 6
2006
0-Address Architecture
d No explicit operands in the instruction d Operands kept on stack in memory d Instruction removes top N items from stack d Instruction leaves result on top of stack
CS250 -- Chapt. 6
2006
d Increments X by 7
CS250 -- Chapt. 6
2006
1-Address Architecture
d One explicit operand per instruction d Second operand is implicit
Always found in hardware register Known as accumulator
CS250 -- Chapt. 6
2006
CS250 -- Chapt. 6
2006
2-Address Architecture
d Two explicit operands per instruction d Result overwrites one of the operands d Operands known as source and destination d Works well for instructions such as memory copy
CS250 -- Chapt. 6
2006
add 7, X
d Computes X X + 7
CS250 -- Chapt. 6
2006
3-Address Architecture
d Three explicit operands per instruction d Operands specify source, destination, and result
CS250 -- Chapt. 6
2006
add X, Y, Z
d Computes Z X + Y
CS250 -- Chapt. 6
10
2006
CS250 -- Chapt. 6
11
2006
CS250 -- Chapt. 6
12
2006
On a computer that follows the Von Neumann architecture, the time spent performing memory accesses can limit the overall performance. Architects use the term Von Neumann bottleneck to characterize the situation, and avoid the bottleneck with techniques such as restricting most operands to registers.
CS250 -- Chapt. 6
13
2006
Operand Encoding
d Implicit type encoding
For given opcode, the type of each operand is xed More opcodes required Example: opcode is add_signed_immediate_to_register
CS250 -- Chapt. 6
14
2006
Opcode Add register Add immediate signed Add immediate unsigned Add memory
Operands R1 R1 R1 R1 R2 I UI M R1 R1 R1 R1
Meaning R1 R1 R1 R1 + + + + R2 I UI memory[M]
CS250 -- Chapt. 6
15
2006
opcode add
operand 1
. . . . . . . register . . . . . . .
operand 2 1
. . . . . . . register . . . . . . .
operand 1 add
. . . . . . . register . . . . . . .
-93
CS250 -- Chapt. 6
16
2006
Combinations
d Operand species multiple items d Processor computes nal value from individual items d Typical computation: sum d Example
Register-offset species register and immediate value Processor adds immediate value to contents of register
CS250 -- Chapt. 6
17
2006
Illustration Of Register-Offset
opcode add
. . . . . register- . . . offset . . . . . .
operand 1 2
. . . . . . . . . . . . . .
operand 2 -17
. . . . . register- . . . offset . . . . . .
. . . . . . . . . . . . . .
76
CS250 -- Chapt. 6
18
2006
Operand Tradeoffs
d No single style of operands optimal for all purposes d Tradeoffs among
Ease of programming Fewer instructions Smaller instructions Larger range of immediate values Faster operand fetch and decode Decreased hardware size
CS250 -- Chapt. 6
19
2006
CS250 -- Chapt. 6
20
2006
Types Of Indirection
d Indirection through a register
Operand species register number, R Obtain A, the current value from register R Interpret A as a memory address, and fetch the operand from memory location A
CS250 -- Chapt. 6
21
2006
1 Immediate value (in the instruction) 2 Direct register reference 3 Indirect through a register 4 Direct memory reference 5 Indirect memory reference
CS250 -- Chapt. 6
22
2006
Summary
d Architect chooses the number and types of operands for each instruction d Possibilities include
Immediate (constant value) Contents of register Value in memory Indirect reference to memory
CS250 -- Chapt. 6
23
2006
Summary
(continued)
d Type of operand can be encoded
Implicitly Explicitly
CS250 -- Chapt. 6
24
2006
Questions?