Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






The Central Processing Unit

Information from an input device or from the computer’s memory is communicated via the bus to the central processing unit (CPU), which is the part of the computer that translates commands and runs programs. The CPU is a microprocessor chip-that is, a single piece of silicon containing millions of tiny, microscopically wired electrical components. Information is stored in a CPU memory location called a register. Registers can be thought of as the CPU’s tiny scratchpad, temporarily storing instructions or data. When a program is running, one special register called the program counter keeps track of which program instruction comes next by maintaining the memory location of the next program instruction to be executed. The CPU’s control unit coordinates and times the CPU’s functions, and it uses the program counter to locate and retrieve the next instruction from memory.

In a typical sequence, the CPU locates the next instruction in the appropriate memory device. The instruction then travels along the bus from the computer’s memory to the CPU, where it is stored in a special instruction register. Meanwhile, the program counter changes-usually increasing a small amount-so that it contains the location of the instruction that will be executed next. The current instruction is analyzed by a decoder, which determines what the instruction will do. Any data the instruction needs are retrieved via the bus and placed in the CPU’s registers. The CPU executes the instruction, and the results are stored in another register or copied to specific memory locations via a bus. This entire sequence of steps is called an instruction cycle. Frequently, several instructions may be in process simultaneously, each at a different stage in its instruction cycle. This is called pipeline processing.

Output Devices

Once the CPU has executed the program instruction, the program may request that the information be communicated to an output device, such as a video display monitor or a flat liquid crystal display. Other output devices are printers, overhead projectors, videocassette recorders (VCRs), and speakers.

Programming Languages

Programming languages contain the series of commands that create software. A CPU has a limited set of instructions known as machine code that it is capable of understanding. The CPU can understand only this language. All other programming languages must be converted to machine code for them to be understood. Computer programmers, however, prefer to use other computer languages that use words or other commands because they are easier to use. These other languages are slower because the language must be translated first so that the computer can understand it. The translation can lead to code that may be less efficient to run than code written directly in the machine’s language.

Machine Language

Computer programs that can be run by a computer’s operating system are called executables. An executable program is a sequence of extremely simple instructions known as machine code. These instructions are specific to the individual computer’s CPU and associated hardware; for example, Intel Pentium and Power PC microprocessor chips each have different machine languages and require different sets of codes to perform the same task. Machine code instructions are few in number (roughly 20 to 200, depending on the computer and the CPU). Typical instructions are for copying data from a memory location or for adding the contents of two memory locations (usually registers in the CPU). Complex tasks require a sequence of these simple instructions. Machine code instructions are binary-that is, sequences of bits (0s and 1s). Because these sequences are long strings of 0s and 1s and are usually not easy to understand, computer instructions usually are not written in machine code. Instead, computer programmers write code in languages known as an assembly language or a high-level language.



Assembly Language

Assembly language uses easy-to-remember commands that are more understandable to programmers than machine-language commands. Each machine language instruction has an equivalent command in assembly language. For example, in one Intel assembly language, the statement “MOV A, B” instructs the computer to copy data from location A to location B. The same instruction in machine code is a string of 16 0s and 1s. Once an assembly-language program is written, it is converted to a machine-language program by another program called an assembler.

Assembly language is fast and powerful because of its correspondence with machine language. It is still difficult to use, however, because assembly-language instructions are a series of abstract codes and each instruction carries out a relatively simple task. In addition, different CPUs use different machine languages and therefore require different programs and different assembly languages. Assembly language is sometimes inserted into a high-level language program to carry out specific hardware tasks or to speed up parts of the high-level program that are executed frequently.


Date: 2015-12-18; view: 1285


<== previous page | next page ==>
The Operating System | High-Level Languages
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.009 sec.)