Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize...

35
Chapter 2.2 Machine Language
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    212
  • download

    0

Transcript of Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize...

Page 1: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Chapter 2.2Machine Language

Page 2: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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.

Page 3: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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

Page 4: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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

Page 5: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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

Page 6: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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

Page 7: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.2 Adding values stored in memory

Page 8: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Data Transfer part

Page 9: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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.

Page 10: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Data Transfer part

• LOAD

• STORE

Page 11: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

• ARITHMETIC / LOGIC GROUP• It consists of the instructions that tells the

control unit to request an activity within the arithmetic / logic unit.

Page 12: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

• 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:

Page 13: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Control Group• The control group consists of those

instructions that direct the execution of the program rather than the manipulation of data.

Page 14: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.2 Adding values stored in memory

Page 15: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Control group

• Step five in Fig 2.2 falls into this category.

Page 16: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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

Page 17: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.3 Dividing values stored in memory

Page 18: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.
Page 19: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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.

Page 20: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.4: The architecture of the machine described in Appendix C

Page 21: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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

Page 22: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.5 The composition of an instruction for the machine in Appendix C

Page 23: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.6 Decoding the instruction 35A7

Page 24: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.7 An encoded version of the instructions in Figure 2.2

Page 25: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.2 Adding values stored in memory

Page 26: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Chapter 2.3Program Execution

Page 27: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Program execution• A computer follows a program stored in its

memory by copying the instructions from memory into the control unit as needed.

Page 28: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Program execution• Controlled by two special-purpose registers

• Program counter: address of next instruction• Instruction register: current instruction

Page 29: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Program execution• Steps performed by control unit

• Fetch• Decode• Execute

Page 30: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

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.

Page 31: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.8 The machine cycle

Page 32: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.9 Decoding the instruction B258

Page 33: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.10 The program from Figure 2.7 stored in main memory ready for execution

Page 34: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.11 Performing the fetch step of the machine cycle

Page 35: Chapter 2.2 Machine Language. To apply the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. This collection.

Figure 2.11 Performing the fetch step of the machine cycle (cont’d)