INSTRUCTION SET
The instruction set, also called instruction set architecture (ISA), is a part of the computer that pertains to programming, which is basically machine language. The collection of different instructions that the CPU can execute is referred to as the CPU’s instruction set. A machine instruction should contain the following elements: * Operation code: Specifies the operation to be performed. * Source operand reference: The reference to the operand should be there in the instruction. * Result operand reference: The address of the memory where output should be stored must be mentioned. * Next instruction reference: This tells CPU where to find the next instruction to be executed.
All the machine instructions can be categorized in to the following types: * Data processing: This classification contains arithmetic instructions which provide computational capabilities for processing numeric data and logical instructions which operate on the bits of a word as bits. * Data storage: This classification contains instruction to store data in memory and the registers. * Data movement: This classification contains instructions to move data between memory and the registers. These instructions are also known as I/O instructions. * Control: This classification contains test instructions that are used to test the value of a data word or the status of a computation and branch instructions that are used to branch to a different set of instructions depending on the decision made.
The most fundamental issues relating to the design of instruction sets are as follows: * Operation repertoire: How many and which operations to provide. And how complex operations should be. * Data types: The various types of data upon which operations are performed.
Instruction format: Instruction length, number of addresses, size of various fields, etc. The instruction set provides commands to the processor, to tell it what it needs to do. The instruction set consists of multiple pieces, including addressing modes, instructions, native data types, registers, memory architecture, interrupt and exception handling, and external I/O. An example of an instruction set is the x86 instruction set, which is common to find on computers today. Different computer processors can use almost the same instruction set, while still having very different internal design. Both the Intel Pentium and AMD Athlon processors use nearly the same x86 instruction set. An instruction set can be built into the hardware of the processor, or it can be emulated in software, using an interpreter. The hardware design is more efficient and faster for running programs than the emulated software version. We can say the instruction sets are designed to achieve the following goals. a ). Maximize performance b ). Minimize cost
c). Reduce design time d ). Minimize memory space e ). Minimize power consumption
COMPLEX
INSTRUCTION SET
COMPUTER
(
CISC
)
REDUCED
INSTRUCTION SET
COMPUTER
(
RISC
)
MINIMAL
INSTRUCTION SET
COMPUTER
VERY LONG
INSTRUCTION
WORD
(
VLIW
)
INSTRUCUON SET
COMPLEX
INSTRUCTION SET
COMPUTER
(
CISC
)
REDUCED
INSTRUCTION SET
COMPUTER
(
RISC
)
MINIMAL
INSTRUCTION SET
COMPUTER
VERY LONG
INSTRUCTION
WORD
(
VLIW
)
INSTRUCUON SET
A complex instruction set computer (CISC) has many specialized instructions, which may only be rarely used in practical programs. A reduced instruction set computer (RISC) simplifies the processor by only implementing instructions that are frequently used in programs unusual operations are implemented as subroutines, where the extra processor execution time is offset by their rare use. Examples of such CPUs are the IBM 360, DEC VAX, Intel 80x86 and Motorola 68xxx. Theoretically, important types are the minimal instruction set computer and the one instruction set computer, but these are not implemented in commercial processors. Another variation is the very long instruction word (VLIW) where the processor receives many instructions encoded and retrieved in one instruction word.
Examples of operations common to many instruction sets include: Data handling and memory operation * Set a register to a fixed constant value. * Move data from a memory location to a register, or vice versa. Used to store the contents of a register, result of a computation, or to retrieve stored data to perform a computation on it later. * Read and write data from hardware devices. Arithmetic and logic operations * Add, subtract, multiply, or divide the values of two registers, placing the result in a register, possibly setting one or more condition codes in a status register. * Perform bitwise operations, e.g., taking the conjunction and disjunction of corresponding bits in a pair of registers, taking the negation of each bit in a register. * Compare two values in registers (for example, to see if one is less, or if they are equal). Control flow operations * Branch to another location in the program and execute instructions there. * Conditionally branch to another location if a certain condition holds. * Indirectly branch to another location, while saving the location of the next instruction as a point to return to (a call)
ADDRESSING MODES
An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction or elsewhere. This method is used to identify the location of an operand .Almost always, one operand is held in a register. Addressing mode refers to the other operand .The actual address of the operand after all address computations of the addressing mode have been performed is called effective address.
INDIRECT
REGISTER
REGISTER
INDIRECT
ADDRESSING
MODES
DISPLACEMENT
(
INDEXED
)
IMMEDIATE
DIRECT
STACK
INDIRECT
REGISTER
REGISTER
INDIRECT
ADDRESSING
MODES
DISPLACEMENT
(
INDEXED
)
IMMEDIATE
DIRECT
STACK
IMMEDIATE ADDRESSING
Here operand is part of instruction .That is operand is the address field
E.g. ADD 5 —Add 5 to contents of accumulator —5 is operand .Since there is no memory reference to fetch data it is fast but has limited range.
DIRECT ADDRESSING
Here address field contains address of operand and effective address (EA) = address field (A)
e.g. ADD A
Here contents of cell A is added to accumulator the processor looks in memory at address A for operand. Since single memory reference is required to access data there is no additional calculations to work out effective address but it has limited address space.
INDIRECT ADDRESSING
In indirect addressing mode memory cell pointed to by address field contains the address of (pointer to) the operand .That is EA = (A) .The processor looks in A, find address (A) and looks there for operand
E.g. ADD (A) —Add contents of cell pointed to by contents of A to accumulator
It requires large address space .It can be nested, multilevel, cascaded. Since it has the provision of multiple memory accesses to find operand it is slower compared to other modes.
REGISTER ADDRESSING
Here operand is held in register named in address field, effective address is the address of the register .Since there are limited number of registers available very small address field is needed and hence shorter instructions which results in faster instruction fetch. Also since there is no memory access involved execution is very fast Use of multiple registers helps to improve performance
REGISTER INDIRECT ADDRESSING
It is similar to indirect addressing except that effective address is the register address The operand is in memory cell pointed to by contents of register R It has fewer memory access than indirect addressing.
DISPLACEMENT ADDRESSING
Here effective address is register address + complimentary address .That is address field hold two values —A = base value,R = register that holds displacement —or vice versa
RELATIVE ADDRESSING
It is a version of displacement addressing except that R = Program counter, PC Here EA = A
+ (PC) i.e. get operand from A cells from current location pointed to by PC
Base-Register Addressing
Here A holds displacement and R holds pointer to base address. R may be explicit or implicit e.g. segment registers in 80x86
INDEXED ADDRESSING
Here A = base and R = displacement and EA = A + R .It is the best addressing mode for accessing arrays
STACK ADDRESSING
It is the mode of addressing in which operand is (implicitly) on top of stack