Instruction Set




Instruction Set

Every CPU has built-in ability to execute a set of machine instructions called its instruction set. Most CPUs have 200 or more instructions (such as add, subtract, and compare) in their instruction set. The list of instructions supported by a CPU in its instruction set forms the basis for designing the machine language for the CPU. Since each processor has a unique instruction set, machine language programs written for one computer will generally not run on another computer with a different CPU.

CPUs made by different manufactures have different instruction sets. In fact, different CPU models of the same manufacturer may have different instruction sets. However, manufacturers tend to group their CPUs into includes all instructions in the instruction set of its predecessor CPU plus some new ones. This manufacturing strategy is known as backward compatibility and the new CPU is said to be backward compatible with its predecessor. This feature allows software written for a computer with a particular CPU to work on computers with newer processors of the same family. In turn, it allows users of these computer systems to upgrade their systems easily without worrying about converting all their existing software.

An instruction set is a list of all the instructions that a processor can execute. Such instructions include arithmetic operations such as add and subtract, logical operations such as AND, OR and NOT, data instructions such as move, input and output, and control instructions such as goto, call and return. The instruction set specifies the opcodes (machine language operation codes) that are used to identify each instruction. The instruction set architecture (ISA) is largely independent of the microarchitecture used within the microprocessor itself. The Intel Pentium and the AMD Athlon, for example, implement almost identical versions of the x86 instruction set, but have vary different internal microarchitectures.

Historically, there have been several approaches used to store the instruction set inside the CPU, but these generally break down into two main approaches. All early computer designs (and some of the simpler RISC designs that came later) had the instruction set hard-wired into the CPU. Later, many designs implemented the instruction set as microcode within a separate ROM inside the CPU. The microcode used to implement a single machine code instruction consists of a number of microinstructions that are used to fetch, decode and execute the machine code instruction (or macroinstruction). The microcode may also be required to poll for hardware interrupts between each macroinstruction.

In the early days of computing, the cost of computer memory was very high, and the amount of memory available tended to be limited by this factor. Limiting the size of a program in memory was therefore an important consideration. Program size was influenced by the number and size of the instructions required to carry out a particular task. An instruction set with a high code density used powerful instructions that could perform several functions at once. Computers that used such an instruction set are called Complex Instruction Set Computers (CISC), and the instruction typically combine one or more basic operations such as add or multiply with the instructions required to access memory or update the contents of a CPU register.

The CISC approach made the best use of the available memory, but as more and more memory became available, Reduced Instruction Set Computers (RISC) began to appear that used a larger number of much simpler instructions to carry out program instructions. The resulting low code density meant that more memory space was required to store the program instructions for a given programming task, but the cost of the microprocessor could be reduced while performance (in terms of speed of operation) improved. The main disadvantage was to the programmer, who had to write more code to achieve the same goals.