Saturday 31 December 2011

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



  • Operation code (Op code)

  • Source Operand reference

  • Result Operand reference

  • Next Instruction Reference


Instruction Cycle State Diagram



Instruction Representation



  • In machine code each instruction has a unique bit pattern

  • For human consumption a symbolic representation is used


—   e.g. ADD, SUB, LOAD




  • Operands can also be represented in this way


—  ADD A,B



Simple Instruction Format



Instruction Types



  • Data processing

  • Data storage (main memory)

  • Data movement (I/O)

  • Program flow control


Types of Operand


1)    Addresses


2)    Numbers


—   Integer/floating point


3)    Characters


—   ASCII etc.


4)    Logical Data


— Bits or flags



Types of Operation


1)    Data Transfer


2)    Arithmetic


3)    Logical


4)    Conversion


5)    I/O


6)    System Control


7)     Transfer of Control



1. Data Transfer



  • 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



2. Arithmetic



  • Add, Subtract, Multiply, Divide

  • Signed Integer

  • Floating point ?

  • May include


—   Increment (a++)


—   Decrement (a--)


—   Negate (-a)



Shift and Rotate Operations



3. Logical



  • Bitwise operations



  • AND, OR, NOT


4. Conversion


E.g. Binary to Decimal



5. Input/Output



  • May be specific instructions

  • May be done using data movement instructions (memory mapped)

  • May be done by a separate controller (DMA)


6. Systems Control



  • Privileged instructions

  • CPU needs to be in specific state


—   Ring 0 on 80386+


—   Kernel mode




  • For operating systems use


7. Transfer of Control



  • 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


—  interrupt call

No comments:

Post a Comment