I speak Spanish to God, the Italian to women, the franch to the men, and the German to my horse. Charles V, Holy Roman Emperor (1500-1558)
2.1 Introduce
2.2 Operations of the computer Hardware
2.3 Operands of the compter Hardware
2.4 Signed and unsigned number
2.5 representing instructions in the computer
2.6 Logical Operations
2.7 Instructions for Making decisions
2.8 Supporting procedures in computer Hardware
2.9 MIPS addressing for 32-bit immediates and Addresses
2.10 Parallelism and Instructions:synchronization
2.11 Translating and starting a program
2.12 A C Short Example-Put It all Together
2.13 Advanced Material:complling C
2.14 Real stuff:armv7 (32-bit) instructions
2.15 Real stuff:x86 Instructions
2.16 Real Stuff:armv8 (64-bit) instructions
2.17 Fallacies and pitfalls
2.18 concluding Remarks
2.19Historical perspective and further Reading
2.20 Exercises
2.1 Introduction
To command a computer ' s hardware, you must speak its language. The words of a computer ' s language are called instructions, and its vocabulary was called an instruction set. In this chapter, you'll see the instruction set of a real computer, both in the form written by people and in the form R EAD by the computer. We introduce instructions in a top-down fashion. Starting from a notation so looks like a restricted programming language, we refine it step-by-step until your see the RE Al language of a real computer. Chapter 3 continues our downward descent, unveiling the hardware for arthmetic and the representation of Floatin-point num Bers.
You might think the languages of computers would is as diverse as those of people, but in reality computer languages is quite similar, more like regional dialects than like independent languages. Hence, once you learn one, it's easy-to-pick up others.
The chosen instruction set comes from MIPS Technologies, and are an elegant example of the instruction sets designed since The 1980s. To demonstrate how easy it was to pick up other instruction sets, we'll take a quick look at three other popular instruct Ion sets.
- ARMv7 is similar to MIPS. More than 9 billion chips with ARM processors were manufactured in, making it the most popular instruction set in the World.
- The second example is the Intel X86, which powers both the PC and the cloud of the Postpc Era.
- the Third example is ARMV8, which extends the address size of the ARM V7 from + bits to. Ironically, as we shall see, the instruction set is closer to MIPS than it's to ARMv7.
This similarity of instruction set occurs because all computers is constructed from hardware technologies base D on similar underlying principles and because there is a few basic operations that all computers must provide. Moreover, computer designers has a common goal:to find a language that makes it easy to build the hardware and the Compl Ier while maximizing performance and minimizing cost and energy. This goal is time honored; The following quote was written before you could buy a computer, and it is true today as it's in 1947:
It's easy-to-see by formal-logical methods, there exist certain [instruction sets] that's in the abstract adequate to C Ontrol and cause the execution of any sequence of operations ... The really decisive considerations from the present point of view, in selecting an [instruction set], is more of a practi Cal Nature:simplicity of the equipment demanded by the [instruction set], and the clarity of their application to the Actua Lly important problems together with the speed of its handling of those problems.
Burks, Goldstine, and von Neumann, 1974
The "simplicity of the equipment" is as valuable a consideration for today's computers as it was for those of The 1950s. The goal of this chapter are to teach a instruction set that follows this advice, showing both how it's represented in Ha Rdware and the relationship between high-level programming languages and this more primitive one. Our examples is in the C programming language; Section 2.13 shows how these would the change for a object-oriented language like java.
By learning-to-represent instructions, you'll also discover the secret of computing:the Stored-program concept. Moreover, you'll exercise your "foreign language" skills by writing programs in the language of the computer and running them on the simulator, which comes with the this book. You'll also see the impact of programming language and compiler optimization on performance. We conclude with a look at the historical evolution of instruction sets and an overview of other computer dialects.
We reveal first instruction set a piece at a time, giving the rationale along with the computer structures. This top-down, step-by-step tutorial weaves the components with their explanations, making the computer ' s language more PA Latable. Figure 2.1 gives a sneak preview of the instruction set coverd on this chapter.
2.2 Operations of the computer Hardware
Every computer must is able to perform arithmetic. The MIPS assembly language notation:
Add a, B, c
Instructions a computer to add the both variables B and C and to put their sum in a.
This notation are rigid in, each MIPS arithmetic instruction performs only one operation and must always has exactly t Hree variables. For example, suppopse we want to place the sum of four variables B, C, D, and e into variable a. Eing deliberately vague what a "variable" is; In the next section we'll explain in detail.)
The following sequence of instructions adds the four variables:
Add a, B, C # The sum of B and C are placed in a
Add a, a, d #The sum of B, C, and D are now in a
Add a, a, e #The sum of B, C, D, and E are now in a
Thus, it takes three instructions to sum of the four variables.
The words to the right of the sharp symbol (#) on the above is comments for the human reader, so the computer Ignoe s them. Note that unlike other programming languages, each line of this language can contain at the most one instruction. Another difference from C was that comments always terminate at the end of a line.
The natural number of operands for a operation like addition is three:the, numbers being added together and a place t O Put the sum. Requiring every instruction to has exactly three operands, no more and no Les, conforms to the philosophy of keeping the Hardware simple:hardware for a variable number of operands are more complicated than hardware for a fixed number. This situation illustrates the first of three underlying principles of hardware design:
Design Principle 1:simplicity Favors regularity.
2. Instructions:language of the computer (instruction: computer language)