Instruction Set Architecture and Principles
Instruction Set Architecture and Principles
Principles
Chapter 2
Instruction Sets
• What’s an instruction set?
– Set of all instructions understood by the CPU
– Each instruction directly executed in hardware
• Instruction Set Representation
– Sequence of bits, typically 1-4 words
– May be variable length or fixed length
– Some bits represent the op code, others
represent the operand
Instruction Set Affects CPU
Performance
• Recall
– ExecTime = Instruction_Count * CPI * Cycle_Time
– Instruction Set is at the heart of the matter!
Compiler
Instr Decode
% of
Displacement
• We’ll see the role of this later with branch prediction and pipelining
Operand Type and Size
• Operands may have many types, how to distinguish
which?
• Annotate with a tag interpreted by hardware
– Not used anymore today
• The opcode also encodes the type of the operand
– Amounts to different instructions per type
• Typical types
– character – byte (UNICODE?)
– short integer – two bytes, 2’s complement
– integer - one word, 2’s complement
– float - one word - IEEE 754
– double - two words - IEEE 754
– BCD or packed decimal
Most Frequently Used Operand
Types
• Double word
– TeX 0%, Spice 66%, GCC 0%
• Word
– TeX 89%, Spice 34%, GCC 91%
• Halfword
– TeX 0%, Spice 0%, GCC 4%
• Byte
– TeX 11%, Spice 0%, GCC 5%
• Move underway now to 64 bit machines
– BCD likely to go away
– larger offsets and immediates is likely
– usage of 64 and 128 bit values will increase
Encoding the Instruction Set
• How to actually store, in binary, the instructions
we want
– Depends on previous discussion, operands, addressing
modes, number of registers, etc.
– Will affect code size, and CPI
• Tradeoffs:
– Desire to have many registers, many addressing modes
– Desire to have the average instruction size small
– Desire to encode into lengths the hardware can easily
and efficiently handle
• Fixed or variable length?
• Remember data delivered in blocks of cache line sizes
Instruction Set Encoding Options
Variable (e.g. VAX)
Everything 81%