Sie sind auf Seite 1von 41

INSTRUCTION SET

CHARACTERISTICS AND
FUNCTIONS
CHAPTER # 7 Computer Organization & Architecture
What is an Instruction Set?
S H E H E R YAR MALI K

 The complete collection of different instructions that


the processor can execute or understand is referred
to as the processor’s instruction set
 Machine Code
 Binary
 Usually represented by assembly codes

Chapter # 7 Computer Organization & Architecture 2


Elements of an Instruction
S H E H E R YAR MALI K

 Operation code (Op code)


 Specifies the operation to be performed
 Source Operand reference
 To this
 The operation may involve one or more source operands
 Result Operand reference
 Put the answer here
 Next Instruction Reference
 This tells the processor where to fetch the next instruction
after the execution of this instruction is complete

Chapter # 7 Computer Organization & Architecture 3


Instruction Cycle State Diagram
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 4


Where the Source and Result Operands can be
S H E H E R YAR MALI K

 Main or virtual memory


 As with next instruction references, the main or virtual
memory address must be supplied
 I/O device
 The instruction must specify the I/O module and device for
the operation
 Processor register
 A processor contains one or more registers that may be
referenced by machine instructions
 Immediate
 The value of the operand is contained in a field in the
instruction being executed
Chapter # 7 Computer Organization & Architecture 5
Instruction Representation
S H E H E R YAR MALI K

 In machine code each instruction has a unique bit


pattern
 For human consumption (well, programmers
anyway) a symbolic representation is used
 e.g. ADD, SUB, LOAD
 Operands can also be represented in this way
 ADD A,B

Chapter # 7 Computer Organization & Architecture 6


Simple Instruction Format
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 7


Instruction Types
S H E H E R YAR MALI K

 Data processing
 Data storage (main memory)
 Data movement (I/O)
 Program flow control

Chapter # 7 Computer Organization & Architecture 8


Number of Addresses
S H E H E R YAR MALI K

 3 addresses
 Operand 1, Operand 2, Result
 a = b + c;
 ADD a, b, c
 May be a forth - next instruction (usually implicit)
 Not common
 Needs very long words to hold everything

Chapter # 7 Computer Organization & Architecture 9


Number of Addresses
S H E H E R YAR MALI K

 2 addresses
 One address doubles as operand and result
 a=a+b
 ADD a, b
 Reduces length of instruction
 Requires some extra work
 Temporary storage to hold some results

Chapter # 7 Computer Organization & Architecture 10


Number of Addresses
S H E H E R YAR MALI K

 1 address
 Implicit second address
 ADD a
 Usually a register (accumulator)
 Common on early machines

Chapter # 7 Computer Organization & Architecture 11


Number of Addresses
S H E H E R YAR MALI K

 0 (zero) addresses
 All addresses implicit
 Uses a stack
 e.g. c = a + b
 push a
 push b
 Add
 pop c

Chapter # 7 Computer Organization & Architecture 12


Number of Addresses
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 13


How Many Addresses
S H E H E R YAR MALI K

 More addresses
 More complex (powerful?) instructions
 More registers
 Inter-register operations are quicker
 Fewer instructions per program
 Fewer addresses
 Less complex (powerful?) instructions
 More instructions per program
 Faster fetch/execution of instructions

Chapter # 7 Computer Organization & Architecture 14


Instruction Set Design Decisions
S H E H E R YAR MALI K

 Operation range
 How many ops?
 What can they do?
 How complex are they?
 Data types
 The various types of data upon which operations are performed
 Instruction formats
 Instruction length in bits
 Length of op code field
 Number of addresses
 Size of various fields, etc.

Chapter # 7 Computer Organization & Architecture 15


Instruction Set Design Decisions
S H E H E R YAR MALI K

 Registers
 Number of CPU registers available
 Which operations can be performed on which registers?
 Addressing modes
 RISC v CISC

Chapter # 7 Computer Organization & Architecture 16


Types of Operand
S H E H E R YAR MALI K

 Addresses
 Numbers
 Integer/floating point
 Characters
 ASCII etc.
 Logical Data
 Bits or flags

Chapter # 7 Computer Organization & Architecture 17


x86 Data Types
S H E H E R YAR MALI K

 8 bit Byte
 16 bit word
 32 bit double word
 64 bit quad word
 128 bit double quadword
 Addressing is by 8 bit unit
 Words do not need to align at even-numbered
address
 Data accessed across 32 bit bus in units of double
word read at addresses divisible by 4
 Little endian
Chapter # 7 Computer Organization & Architecture 18
x86 Numeric Data Formats
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 19


ARM Data Types
S H E H E R YAR MALI K

 8 (byte), 16 (halfword), 32 (word) bits


 Halfword and word accesses should be word aligned
 Unsigned integer interpretation supported for all
types
 Twos-complement signed integer interpretation
supported for all types
 Majority of implementations do not provide floating-
point hardware
 Saves power and area
 Floating-point arithmetic implemented in software
 Optional floating-point coprocessor
 Single- and double-precision IEEE 754 floating point data
types

Chapter # 7 Computer Organization & Architecture 20


Types of Operation
S H E H E R YAR MALI K

 Data Transfer
 Arithmetic
 Logical
 Conversion
 I/O
 System Control
 Transfer of Control

Chapter # 7 Computer Organization & Architecture 21


Types of Operation
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 22


Types of Operation
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 23


Data Transfer
S H E H E R YAR MALI K

 Specify
 Source
 Destination
 Amount of data
 May be different instructions for different
movements
 e.g. IBM 370
 Or one instruction and different addresses
 e.g. VAX

Chapter # 7 Computer Organization & Architecture 24


Arithmetic
S H E H E R YAR MALI K

 Add, Subtract, Multiply, Divide


 Signed Integer
 Floating point
 May include
 Increment (a++)
 Decrement (a--)
 Negate (-a)

Chapter # 7 Computer Organization & Architecture 25


Logical
S H E H E R YAR MALI K

 Bitwise operations
 AND
 OR
 NOT
 Test
 Compare

Chapter # 7 Computer Organization & Architecture 26


Conversion
S H E H E R YAR MALI K

 E.g. Binary to Decimal

Chapter # 7 Computer Organization & Architecture 27


Input/Output
S H E H E R YAR MALI K

 May be specific instructions


 May be done using data movement instructions
(memory mapped)
 May be done by a separate controller (DMA)
 Examples
 Input
 Output
 Start I/O

Chapter # 7 Computer Organization & Architecture 28


Systems Control
S H E H E R YAR MALI K

 Privileged instructions
 CPU needs to be in specific state
 Ring 0 on 80386+
 Kernel mode
 For operating systems use

Chapter # 7 Computer Organization & Architecture 29


Transfer of Control
S H E H E R YAR MALI K

 Branch
 e.g. branch to x if result is zero
 Skip
 e.g. increment and skip if zero
 ISZ Register1
 Branch xxxx
 ADD A
 Subroutine call
 c.f. interrupt call

Chapter # 7 Computer Organization & Architecture 30


Branch Instruction
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 31


 x86 Operation Types
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 32


 x86 Operation Types
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 33


x86 Single-Instruction, Multiple-Data (SIMD)
Instructions
S H E H E R YAR MALI K

 1996 Intel introduced MMX technology into its Pentium


product line
 MMX is a set of highly optimized instructions for multimedia tasks
 Video and audio data are typically composed of large
arrays of small data types
 Three new data types are defined in MMX
 Packed byte
 Packed word
 Packed doubleword
 Each data type is 64 bits in length and consists of multiple
smaller data fields, each of which holds a fixed-point
integer

Chapter # 7 Computer Organization & Architecture 34


MMX Instruction Set
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 35


ARM Operation Types
S H E H E R YAR MALI K

 Load and store instructions


 Branch instructions
 Data-processing instructions
 Multiply instructions
 Parallel addition and subtraction instructions
 Extend instructions
 Status register access instructions

Chapter # 7 Computer Organization & Architecture 36


Byte Order (A portion of chips?)
S H E H E R YAR MALI K

 What order do we read numbers that occupy more


than one byte
 e.g. (numbers in hex to make it easy to read)
 12345678 can be stored in 4x8bit locations as
follows
 Address Value (1) Value(2)
 184 12 78
 185 34 56
 186 56 34
 186 78 12

Chapter # 7 Computer Organization & Architecture 37


Byte Order Names
S H E H E R YAR MALI K

 The problem is called Endian


 Big endian
 In big endian, you store the most significant byte in the
smallest address.
 Little-endian
 In little endian, you store the least significant byte in the
smallest address

Chapter # 7 Computer Organization & Architecture 38


Example of C Data Structure
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 39


Alternative View of Memory Map
S H E H E R YAR MALI K

Chapter # 7 Computer Organization & Architecture 40


Byte Order Standard
S H E H E R YAR MALI K

 Pentium (x86), VAX are little-endian


 IBM 370, Motorola 680x0 (Mac), and most RISC are
big-endian
 Internet is big-endian
 Makes writing Internet programs on PC more awkward!
 WinSock provides htoi and itoh (Host to Internet & Internet
to Host) functions to convert

Chapter # 7 Computer Organization & Architecture 41

Das könnte Ihnen auch gefallen