Chapter 2.2 Machine Language
Machine Language To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection of instructions along with the encoding system is called the machine language. An instruction expressed in this language is called a machine-level instruction or a machine instruction.
Machine language: definitions Machine instruction = an instruction coded as a bit pattern directly recognizable by the CPU Machine language = the set of all instructions recognized by a machine
Machine language philosophies Two philosophies of CPU architectures: Reduced Instruction Set Computing (RISC) Few, simple, efficient, and fast instructions Example: PowerPC from Apple/IBM/Motorola Complex Instruction Set Computing (CISC) Many, convenient, and powerful instructions Example: Pentium from Intel
Machine instruction types When discussing the instructions in a machine’s repertoire, it is helpful to recognize that they can be classified into three categories: Data Transfer group Arithmetic/Logic group Control group
Machine instruction types Data Transfer: copy data between CPU and main memory Arithmetic/Logic: use existing data values to compute a new data value Control: direct the execution of the program
Figure 2.2 Adding values stored in memory
Data Transfer part
Data Transfer Part A request to fill a general-purpose register with the contents of a memory cell is commonly referred to as a LOAD instruction A request to transfer the contents of a register to a memory cell is called a STORE instruction.
Data Transfer part LOAD STORE
ARITHMETIC / LOGIC GROUP It consists of the instructions that tells the control unit to request an activity within the arithmetic / logic unit.
It includes: Basic arithmetic operations Boolean operations AND OR XOR Shift or Rotate operations They are available within most arithmetic / logic units They allow the contents of registers to be moved to the right or the left within the register. Examples:
Control Group The control group consists of those instructions that direct the execution of the program rather than the manipulation of data.
Figure 2.2 Adding values stored in memory
Control group Step five in Fig 2.2 falls into this category.
Control This group contains many other instructions, such as the family of JUMP instructions used to direct the control unit to execute an instruction other than the next one in the list. Example : Fig 2.3 on page 85
Figure 2.3 Dividing values stored in memory
An Illustrative Machine Language Let us now consider how the instructions of a typical computer are encoded. The machine that we will use for our discussion is described in Appendix C and summarized in Fig 2.4. It has 16 general-purpose registers and 256 main memory cells. Each of the memory cells has a capacity of eight bits.
Figure 2.4: The architecture of the machine described in Appendix C
Parts of a machine instruction Op-code: specifies which machine operation to execute One per instruction Operand: more detailed information about this operation Number of operands varies depending on op-code
Figure 2.5 The composition of an instruction for the machine in Appendix C
Figure 2.6 Decoding the instruction 35A7
Figure 2.7 An encoded version of the instructions in Figure 2.2
Figure 2.2 Adding values stored in memory
Chapter 2.3 Program Execution
Program execution A computer follows a program stored in its memory by copying the instructions from memory into the control unit as needed.
Program execution Controlled by two special-purpose registers Program counter: address of next instruction Instruction register: current instruction
Program execution Steps performed by control unit Fetch Decode Execute
Machine cycle. The control unit performs its job by continually repeating an algorithm that guides it through a three-step process known as the machine cycle.
Figure 2.8 The machine cycle
Figure 2.9 Decoding the instruction B258
Figure 2. 10 The program from Figure 2 Figure 2.10 The program from Figure 2.7 stored in main memory ready for execution
Figure 2.11 Performing the fetch step of the machine cycle
Figure 2.11 Performing the fetch step of the machine cycle (cont’d)