2.4 CONCEPT OF INSTRUCTION

 The CPU is a semiconductor integrated circuit chip consisting of a large number of transistors. In personal computers, the CPU is also referred by the term Microprocessor. Every CPU is capable of performing certain instructions (known as machine instruction). Modern CPUs have the logic built in to perform 400-550 machine instructions. The machine instructions that a CPU can execute demonstrates its capability. Every processor is capable of performing certain operations. An instruction refers to an operation that can be performed by the processor directly. The entire set of instructions that can be executed by the processor directly, through the logic in hardware, form the instruction set of the processor. An instruction tells the processor what task is to be performed and what micro-operations need to be completed to perform the task. Every instruction execution requires execution of a set of arithmetic and logical operations (micro-operations). The size and format of the instruction varies with different processors.

Every instruction is comprised of two parts: opcode and operands. The opcode specifies the operation to be performed and the operands provide the data on which the operation is to be performed. To understand the concept of instruction more clearly let us assume a simple hypothetical computer which the capability to perform eight different operations. Every operation is specified by a unique opcode as given in Table 2.2.


Let us further assume that our computer can process only two-digit decimal numbers, i.e. there can be a maximum of two operands each of a maximum of two digits. Thus the computer can add or subtract numbers containing a maximum of two digits. A simple instruction can thus be written as a combination of an opcode and its associated operands. Opcode is denoted by its unique binary code. The operands are decimal digits and therefore also need to be converted to binary code system to pass them as operands to the processor. Suppose BCD code is used to represent the operands. Then following are examples of some valid instructions on the processor:

In the first instruction, the first three bits represent the opcode and the remaining sixteen bits represent the two operands each a two digit decimal number expressed using BCD code. The opcode for addition as described in the table is 000 and the BCD codes for 9,3,2 and 5 are 1001, 0011, 0010 and 0101 respectively. Thus the instruction 0001001001100100101 represents 93 + 25. Similarly, in the second instruction, first three bits represent the opcode and the remaining eight bits specify the operand to perform the operation. However, this is the case of a very simple hypothetical computer. Real world processors are much more complex and capable of performing more than 500 machine instructions. Further they can take their operands in a number ways: directly, from registers, from memory etc. Moreover, modern processors can perform calculations on large numbers. Thus an instruction in a modern CPU could easily comprise more than 50 bits.

Execution of a machine instruction on modern processors involves a complex sequence of operations with multiple cycles. One instruction cycle typically involves Fetch, Decode, Execute and Write back cycles. During Fetch cycle the instruction is fetched from memory. During Decode cycle the instruction is processed by the control unit of the CPU, which generate the set of micro-operations and timing signals required to execute the instruction. The micro-operations are then executed during Execute cycle to complete the instruction and any results generated are then written back to memory during Write back cycle. An instruction cycle may also involve one or more operand fetch cycles. The control unit is responsible for overall control and coordination of instruction execution. It generates the set of micro-operations either through a hard wired logic or with the help of micro program sequencer. Executing a program therefore involves executing a large number of machine instructions, where every machine instruction execution requires executing several micro-operations.

Comments

Popular posts from this blog

3.5 SOCIAL NETWORKING

3.6 BLOG

3.4 COLLABORATIONS