william stallings computer organization and architecture 6 th edition
Download
Skip this Video
Download Presentation
William Stallings Computer Organization and Architecture 6 th Edition

Loading in 2 Seconds...

play fullscreen
1 / 64

William Stallings Computer Organization and Architecture 6 th Edition - PowerPoint PPT Presentation


  • 42 Views
  • Uploaded on

William Stallings Computer Organization and Architecture 6 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions. What is an instruction set?. The complete collection of instructions that are understood by a CPU Machine Code Binary Usually represented by assembly codes.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' William Stallings Computer Organization and Architecture 6 th Edition' - kata


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
william stallings computer organization and architecture 6 th edition

William Stallings Computer Organization and Architecture6th Edition

Chapter 10

Instruction Sets:

Characteristics

and Functions

what is an instruction set
What is an instruction set?
  • The complete collection of instructions that are understood by a CPU
  • Machine Code
  • Binary
  • Usually represented by assembly codes
elements of an instruction
Elements of an Instruction
  • Operation code (Op code)
    • Specifies the operation to be performed.
  • Source Operand reference
    • Input operands for the operation.
  • Result Operand reference
    • Put the answer here
  • Next Instruction Reference
    • Tell the CPU where to fetch the next instruction after the execution of this instruction is complete.
elements of an instruction cont
Elements of an Instruction (cont.)
  • Source and Result operands can be in one of three areas:
    • Main memory (or virtual memory or cache)
    • CPU register
    • I/O device
instruction representation
Instruction Representation
  • 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
instruction types
Instruction Types
  • Data processing
    • Arithmetic and logic instructions
  • Data storage (main memory)
    • Memory instruction
  • Data movement (I/O)
    • I/O instruction are need to transfer programs and data into memory and the results of computations back out to the user.
  • Program flow control
    • Test and branch instruction
    • Test instructions are used to test the value of a data word or the status of a computation.
    • Branch instructions are used to branch a different set of instructions depending on the decision made.
number of addresses a
Number of Addresses (a)
  • 3 addresses
    • Operand 1, Operand 2, Result
    • a = b + c;
    • May be a forth - next instruction (usually implicit)
    • Not common
    • Needs very long words to hold everything
number of addresses b
Number of Addresses (b)
  • 2 addresses
    • One address doubles as operand and result
    • a = a + b
    • Reduces length of instruction
    • Requires some extra work
      • Temporary storage to hold some results
number of addresses c
Number of Addresses (c)
  • 1 address
    • Implicit second address
    • Usually a register (accumulator)
    • Common on early machines
number of addresses d
Number of Addresses (d)
  • 0 (zero) addresses
    • All addresses implicit
    • Uses a stack
    • e.g. push a
    • push b
    • add
    • pop c
    • c = a + b
example y a b c d e
Example: Y=(A-B)/(C+D*E)
  • Three-address instruction
    • SUB Y, A, B (Y=A-B)MPY T, D, E (T=D*E)ADD T, T, C (T=T+C)DIV Y, Y, T (Y=Y/T)
  • Two-address instruction
    • MOVE Y, A (Y=A)SUB Y, B (Y=Y-B)MOVE T, D (T=D)MPY T, E (T=T*E)ADD T, C (T=T+C)DIV Y, T (Y=Y/T)
example y a b c d e1
Example: Y=(A-B)/(C+D*E)
  • One-address instruction
    • LOAD D (AC=D)MPY E (AC=AC*E)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)
how many addresses
How Many Addresses
  • More addresses
    • More complex instructions
    • More registers
      • Inter-register operations are quicker
    • Fewer instructions per program
  • Fewer addresses
    • Less complex instructions
    • More instructions per program
    • Faster fetch/execution of instructions
design decisions 1
Design Decisions (1)
  • Operation repertoire
    • 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
    • Length of op code field
    • Number of addresses
design decisions 2
Design Decisions (2)
  • Registers
    • Number of CPU registers available
    • Which operations can be performed on which registers?
  • Addressing modes (later…)
    • The mode or modes by which the address of an operand is specified.
  • RISC v CISC
types of operand
Types of Operand
  • Machine instruction operate on data, the most important categories of data are
    • Addresses
    • Numbers
      • Integer/floating point
    • Characters
      • ASCII etc.
    • Logical Data
      • Bits or flags
types of operand cont
Types of Operand (cont.)
  • Address
    • Addresses are a form of data.
    • Addresses can be considered to be unsigned integers
  • Numbers
    • There is a limit to the magnitude of numbers representable on a machine.
    • In the FP numbers, a limit to their precision.
    • Three types of numerical data are common in computer
      • Integer or fixed point
      • Floating point
      • Decimal
        • Binary/decimal converter
types of operand cont1
Types of Operand (cont.)
  • Characters
    • A number of codes have been devised by which characters are represented by a sequence of bits
    • International Reference Alphabet (IRA)
      • American Standard Code for Information Interchange (ASCII)
        • 7 bit, 128 different characters, including some control characters.
      • IRA-encoded characters
        • 8 bit
        • The last bit is parity bit
      • Extended Binary Coded Decimal Interchange Code (EBCDIC)
        • Used on IBM S/390 machines
        • 8 bit
types of operand cont2
Types of Operand (cont.)
  • Logical Data
    • To consider an n-bit unit as consisting of n 1-bit items of data
    • Each item having the value 0 or 1
  • The same data are treated sometimes as logical and other times as numerical or text.
    • The “type” of a unit of data is determined by the operation being performed on it
    • It is almost always the case with machine language.
pentium data types
Pentium Data Types
  • 8 bit Byte
  • 16 bit word
  • 32 bit double word
  • 64 bit quad word
  • Addressing is by 8 bit unit
  • A 32 bit double word is read at addresses divisible by 4
  • Little-endian style
    • The least significant byte is stored in the lowest address.
specific data types
Specific Data Types
  • General - arbitrary binary contents
  • Integer - signed binary value (2s complement)
  • Ordinal - unsigned integer
  • Unpacked BCD - One digit per byte
  • Packed BCD - 2 BCD digits per byte
  • Near Pointer - 32 bit offset within segment
  • Bit field
  • Byte String
  • Floating Point – IEEE 754 standard
powerpc data types
PowerPC Data Types
  • The PowerPC can deal with data type of
    • 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) length data types
  • Some instructions need operand aligned on 32 bit boundary
  • Can be big- or little-endian
  • Fixed point processor recognises:
    • Unsigned byte, unsigned halfword, signed halfword, unsigned word, signed word, unsigned doubleword, byte string (<128 bytes)
  • Floating point
    • IEEE 754
    • Single or double precision
types of operation
Types of Operation
  • Data Transfer
  • Arithmetic
  • Logical
  • Conversion
  • I/O
  • System Control
  • Transfer of Control
data transfer
Data Transfer
  • The data transfer instruction must specify the followings:
    • Source
    • Destination
    • Amount of data
    • The mode of addressing for each operand
  • May be different instructions for different movements
    • e.g. IBM 370
  • Or one instruction and different addresses
    • e.g. VAX
data transfer cont
Data Transfer (cont.)
  • CPU actions
    • If both source and destination are register, the CPU transfer data from one register to another.
    • If one or both operands are in memory, the CPU must perform some or all of the following actions
      • Calculate the memory address
      • If the address refers to virtual memory, translate from virtual to actual memory address.
      • Determine whether the addressed item is in cache
      • If not, issue a command to the memory module.
arithmetic
Arithmetic
  • Most machine provide the basic arithmetic
    • Add, Subtract, Multiply, Divide
  • These are always provided for signed integer (fixed-point) numbers.
  • They are often provide floating point and packed decimal numbers.
  • Other possible operations include
    • Absolute
    • Negate
    • Increment
    • Decrement
logical
Logical
  • Bitwise operations
  • AND, OR, NOT
    • The AND operation can be used as a mask that selects certain bits in a word and zeros out the remaining bits
  • Logical shift
    • The bits of a word are shifted left or right
    • On one end, the bit shifted out is lost.
    • On the other end, a o is shifted in,
logical cont
Logical (cont.)
  • Arithmetic shift
    • The arithmetic shift operation treats the data as a signed integer and does the sign bit.
    • A right arithmetic shift corresponds to a division by 2
    • A left arithmetic shift corresponds to a multiplication by 2
  • Rotate
    • Preserve all of the bits being operated on.
logical cont1
Logical (cont.)
  • Conversion
    • That change the format or operate on the format of data
    • E.g. Binary to Decimal
input output
Input/Output
  • A variety of approaches
    • Isolated programmed I/O, memory-mapped programmed I/O, DMA, and I/O processor
  • May be specific instructions (Isolated)
  • May be done using data movement instructions (memory mapped)
  • May be done by a separate controller (DMA)
systems control
Systems Control
  • System control
    • Can be executed only while the CPU is in a certain privileged state or is executing a program in a special privileged area of memory.
  • CPU needs to be in specific state
    • Ring 0 on 80386+
    • Kernel mode
  • For operating systems use
transfer of control
Transfer of Control
  • Branch
    • Jump instruction, has as one of its operands, the address of the next instruction to be executed.
    • Conditional branch
      • e.g. branch to x if result is zero
    • User-visible register
      • Most machine provide a 1-bit or multiple-bit condition code
  • Skip
    • Includes an implied address, the address of the next instruction plus one instruction-length
    • e.g. increment and skip if zero (ISZ)
    • ISZ Register1
transfer of control cont
Transfer of Control (cont.)
  • Procedure Call instruction
    • The reasons for the use of procedures are economy and modularity.
    • A procedure allows the same piece of code to be used many times.
    • The procedure mechanism involves two basic instructions
      • Call instruction
      • Return instruction
    • A procedure can be called from more than one location
    • A procedure call can appear in a procedure (nesting of procedures to an arbitrary depth)
    • Each procedure call is matched by a return in the called program
transfer of control cont1
Transfer of Control (cont.)
  • There are three common places for storing the return address
    • Register
    • Start of called procedure
    • Top of stack
  • Reentrant procedure
    • A reentrant procedure is one in which it is possible to have several calls open to it at the same time
    • Eg. Recursive procedure
assembly language
Assembly Language
  • A CPU can understand and execute machine instructions
  • Such instructions are simply binary numbers stored in computer
  • For more improvement
    • Make use of the symbolic name or mnemonic of each instruction
    • Symbolic program
    • Pseudo instruction
  • Programs written in assembly language are translated into machine language by assembler
stacks
Stacks
  • A stack is an ordered set of elements
  • Only one of which can be accessed at a time
  • The point of access is called the top of the stack
  • The number of element in the stack is called length
  • Stack is a pushdown list or a last-in-first-out list
stack implementation
Stack Implementation
  • Because all of these operations refer to the top of the stack, the address of the operand or operands is implicit and need not be included in the instruction.
  • Zero-address instruction
  • Three address are needed for proper operation
    • Stack pointer
      • Contains the address of the top of the stack
    • Stack base
      • Contains the address of the bottom location in the reserved block
    • Stack limit
      • Contains the address of the other end of the reserved block
expression evaluation
Expression Evaluation
  • Reverse Polish (postfix)
  • The postfix is easily evaluated using a stack
  • Algorithm
    • If the element is a variable or constant, push it onto the stack
    • If the element is an operator,
      • pop the top two items of the stack,
      • perform the operation,
      • and push the result.
byte order a portion of chips
Byte Order(A portion of chips?)
  • 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
byte order example
Byte Order (example)
  • Address Value (1) Value(2)
  • 184 12 78
  • 185 34 56
  • 186 56 34
  • 187 78 12
  • i.e. read top down or bottom up?

Littleendian

最小有效位元由低位址往高位址方向存放

Big endian

最大有效位元由低位址往高位址方向存放

byte order names
Byte Order Names
  • The problem is called Endian
  • The system on the left has the most significant byte in the lowest address
    • This is called big-endian
  • The system on the right has the least significant byte in the lowest address
    • This is called little-endian
standard what standard
Standard…What Standard?
  • Pentium (80x86), VAX are little-endian
  • IBM 370, Moterola 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
ad