View
219
Download
0
Category
Preview:
Citation preview
7/27/2019 Ch_9_95
1/30
William Stallings
Computer Organizationand Architecture
Chapter 9Instruction Sets:Characteristics
and Functions
7/27/2019 Ch_9_95
2/30
What is an instruction set?
The complete collection of instructions that areunderstood by a CPU
Machine CodeBinaryUsually represented by assembly codes
7/27/2019 Ch_9_95
3/30
Elements of an Instruction
Operation code (Op code)Do this
Source Operand referenceTo this
Result Operand referencePut the answer here
Next Instruction ReferenceWhen you have done that, do this...
7/27/2019 Ch_9_95
4/30
Where have all the Operandsgone?
Long time passing. (If you dont understand, youre too young!)
Main memory (or virtual memory or cache)CPU registerI/O device
7/27/2019 Ch_9_95
5/30
Instruction Representation
In machine code each instruction has a uniquebit pattern
For human consumption (well, programmersanyway) a symbolic representation is usede.g. ADD, SUB, LOAD
Operands can also be represented in this way ADD A,B
7/27/2019 Ch_9_95
6/30
Instruction Types
Data processingData storage (main memory)
Data movement (I/O)Program flow control
7/27/2019 Ch_9_95
7/30
Number of Addresses (a)
3 addressesOperand 1, Operand 2, Result
a = b + c;May be a forth - next instruction (usually implicit)Not commonNeeds very long words to hold everything
7/27/2019 Ch_9_95
8/30
Number of Addresses (b)
2 addressesOne address doubles as operand and result
a = a + bReduces length of instructionRequires some extra work
Temporary storage to hold some results
7/27/2019 Ch_9_95
9/30
Number of Addresses (c)
1 addressImplicit second address
Usually a register (accumulator)Common on early machines
7/27/2019 Ch_9_95
10/30
Number of Addresses (d)
0 (zero) addresses All addresses implicit
Uses a stack e.g. push apush badd
pop c
c = a + b
7/27/2019 Ch_9_95
11/30
How Many Addresses
More addressesMore complex (powerful?) instructions
More registersInter-register operations are quickerFewer instructions per program
Fewer addresses
Less complex (powerful?) instructionsMore instructions per programFaster fetch/execution of instructions
7/27/2019 Ch_9_95
12/30
Design Decisions (1)
Operation repertoireHow many ops?
What can they do?How complex are they?
Data typesInstruction formats
Length of op code fieldNumber of addresses
7/27/2019 Ch_9_95
13/30
Design Decisions (2)
RegistersNumber of CPU registers available
Which operations can be performed on whichregisters?
Addressing modes (later)
RISC v CISC
7/27/2019 Ch_9_95
14/30
Types of Operand
AddressesNumbers
Integer/floating pointCharacters
ASCII etc.
Logical DataBits or flags
(Aside: Is there any difference between numbers and characters? Ask a C programmer!)
7/27/2019 Ch_9_95
15/30
Pentium Data Types
8 bit Byte16 bit word
32 bit double word64 bit quad word
Addressing is by 8 bit unit
A 32 bit double word is read at addressesdivisible by 4
7/27/2019 Ch_9_95
16/30
Specific Data Types
General - arbitrary binary contentsInteger - single binary valueOrdinal - unsigned integerUnpacked BCD - One digit per bytePacked BCD - 2 BCD digits per byteNear Pointer - 32 bit offset within segment
Bit fieldByte StringFloating Point
7/27/2019 Ch_9_95
17/30
Pentium Floating Point DataTypes
See Stallings p324
7/27/2019 Ch_9_95
18/30
Types of Operation
Data Transfer Arithmetic
LogicalConversionI/O
System ControlTransfer of Control
7/27/2019 Ch_9_95
19/30
Data Transfer
SpecifySourceDestination
Amount of data
May be different instructions for differentmovements
e.g. IBM 370Or one instruction and different addresses
e.g. VAX
7/27/2019 Ch_9_95
20/30
Arithmetic
Add, Subtract, Multiply, DivideSigned Integer
Floating point ?May include
Increment (a++)Decrement (a--)Negate (-a)
7/27/2019 Ch_9_95
21/30
Logical
Bitwise operations AND, OR, NOT
7/27/2019 Ch_9_95
22/30
Conversion
E.g. Binary to Decimal
7/27/2019 Ch_9_95
23/30
Input/Output
May be specific instructionsMay be done using data movement instructions
(memory mapped)May be done by a separate controller (DMA)
7/27/2019 Ch_9_95
24/30
Systems Control
Privileged instructionsCPU needs to be in specific state
Ring 0 on 80386+Kernel mode
For operating systems use
7/27/2019 Ch_9_95
25/30
Transfer of Control
Branche.g. branch to x if result is zero
Skipe.g. increment and skip if zeroISZ Register1Branch xxxx
ADD A Subroutine call
c.f. interrupt call
7/27/2019 Ch_9_95
26/30
Foreground Reading
Pentium and PowerPC operation typesStallings p338 et. Seq.
7/27/2019 Ch_9_95
27/30
Byte Order (A portion of chips?)
What order do we read numbers that occupymore than one byte
e.g. (numbers in hex to make it easy to read)12345678 can be stored in 4x8bit locations asfollows
7/27/2019 Ch_9_95
28/30
Byte Order (example)
Address Value (1) Value(2)184 12 78
185 34 56186 56 34186 78 12
i.e. read top down or bottom up?
7/27/2019 Ch_9_95
29/30
Byte Order Names
The problem is called EndianThe system on the left has the least significant
byte in the lowest addressThis is called big-endianThe system on the right has the leastsignificant byte in the highest addressThis is called little-endian
7/27/2019 Ch_9_95
30/30
StandardWhat Standard?
Pentium (80x86), VAX are little-endianIBM 370, Moterola 680x0 (Mac), and most RISC
are big-endianInternet is big-endianMakes writing Internet programs on PC moreawkward!
WinSock provides htoi and itoh (Host to Internet & Internet to Host) functions to convert
Recommended