chapter 2.2 machine language. to apply the stored-program concept, cpus are designed to recognize...
Post on 21-Dec-2015
212 views
TRANSCRIPT
![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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/1.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/2.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/5.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/6.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/7.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/8.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/9.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/10.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/11.jpg)
• 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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/12.jpg)
• 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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/13.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/14.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/15.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/16.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/17.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/18.jpg)
![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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/19.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/20.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/21.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/22.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/23.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/24.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/25.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/26.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/27.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/28.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/29.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/30.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/31.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/32.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/33.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/34.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649d5e5503460f94a3d29a/html5/thumbnails/35.jpg)
Figure 2.11 Performing the fetch step of the machine cycle (cont’d)