:::::Shikhor Himadrir :::::

Please Give your valuable comments on my blogs and make me more responsible blogger
Thursday 11 February 2010

Instruction Codes



Preface
Computer is a well organized digital system which is internally defined by the sequence of micro operations[micro operation : some basic function of computer by which all other tasks are performed by computer. hints: it was discussed on my blog :Register and Register Transfer] it performs on data stored in its registers.The general purpose of digital computer is capable of executing various micro operations and in addition, can be instructed as to what specific sequence of operations it must perform.There is controller who can control the process. This controller is the user of computer.Programs are the user of computer.
A program is set of instructions that specify the operations, operands, and the sequence by which processing has to occur. the data processing may be altered by specifying a new program with different instructions or specifying same instructions with different data.So there are clearly some instructions for defining sequence micro operations. These instructions are called computer instructions.
Computer instructions
A computer instruction is a binary code that specifies a sequence of micro operations for the computer.These binary codes are called instruction codes. All instruction codes together with their data are kept stored in computer memory.The computer can read each instructions from the memory and places it in a control register.The control then interpret the binary of instruction code and proceeds to execute it by issuing a sequence of micro operations .Every computer has its own unique instruction set.

Instruction Code
An instruction code is a group of bits that instruct the computer to perform a specific operation.it is usually divided into parts, each having its own particular interpretation.The most basic part of a instruction code is its operation part.The operation part of instruction code is called operation code or op-code.The op-code is a group of bits that define such operations as add, subtract, multiply, shift and complement.The number of bits required for the operation code of an instruction code depends on the total number of operations available in the computer.The operation code must consists of at least n bit for given 2^n (or less) distinct operations.So if there are 16 operations available in the computer,then operation code must have 4 bits of code .For illustration, consider a computer with 64 distinct operations, one of them is an ADD operations.Then the op-code will have 6 bits length and the 6 bit binary op-code 110010 represent the ADD operation.So these code are just like acting as a token for a specific operation.When this operation code is decoded in the control unit, the computer issues the control signals to read an operand from memory and add the operand to a processor register.

We could be confused with 2 wards computer operation and micro operation.So we must recognize the relationship between computer operation and micro operation. An operation is part of an instruction stored in the computer memory.It is a binary code that tells the computer to perform a specific operation.The control unit receives the instruction from the memory and interprets the operation bits.It then issues a sequence of control signals to initiate micro operations in internal computer registers.For every operation code, the control issues a sequence of micro operations needed for the hardware implementation of the specified operation.For this reason, an operation code is sometimes called a micro operation because it specifies a set of micro operations.

The operation part of an instruction code specifies the operation be performed. This operation must be performed on some data stored on processor register or in memory.An instruction code must therefore specify not only the operation but also the registers or the memory words where the operands are to be found, as well as the register or memory word where the result is to be stored.memory words can be specified in instruction codes by their address.Processor registers can be specified by assigning to the instruction another binary code of k-bits that specifies one of 2^k registers.There are many variations for arranging the binary code of instructions and each computer has its own particular instruction code format.instruction code format are conceived by computer designers who specify the architecture of computer.

Stored Program Organization
The simplest way to organize a computer is to have one processor register and an instruction code format with two parts.The first part specifies the operation to be performed and the second specifies an address.This operand is read from memory and used as the data to be operated on together with the data stored in the processor register.

The given figure depicts this type of organization.Instructions are stored in one section of memory and data in another.For a memory unit with 4096 words we need 12 bits to specify an address since 2^12 = 4096.if we store each instruction code in one 16-bit word, we have available 4-bits for the operation code(abbreviated op code) to specify one of 16 possible operations, and 12-bits to specify the address of an operand.The control reads 16-bit instruction from the program portion of the memory.It uses the 12-bit address part of the instruction to read a 16-bit operand from the data portion of memory.It then executes the operation specified by the operation code.


Computer that have a single processor register usually assign to it the name accumulator and label it AC.The operation is performed with the memory operand and the content of AC.
If an operation in an instruction code does not need an operand from memory, the rest of the bits in the instruction can be used for other purposes.For example, operations such as clear AC complement AC, and increment AC operate on data stored in the AC register.They do not need an operand from memory.For these types of operations, the second part of the instruction code (bits 0 through 11) is not needed for specifying a memory address and can be used to specify other operations for the computer.

Indirect Address
It is sometimes convenient to use the address bits of an instruction code not as an address but as the actual operand.When the second part of an instruction code specifies an operand, the instruction is said to have an immediate operand.When second part specifies the address of an operand, the instruction has said to have a direct address.This is an contrast to a third possibility
called indirect address, where the bits in the second part of the instruction designate an address of a memory word in which the address of the operand is found.One bit of the instruction code can can be used to distinguish between a direct and an indirect address.

As an illustration of this configuration of instruction, consider the instruction code format shown in given figure fig(a).It consists of a 3-bit operation code, a 12-bit address, and an indirect address mode bit designated by 'I'.When the mode bit I = 0, then instruction code is in direct address form and when the mode bit I = 0, then instruction code is in indirect address form.A direct address instruction is shown in given figure fig(b). It is placed in address 20 in memory.The I bit is 0, so the instruction is recognized as a direct address instruction.The op code specifies an ADD operation, and the address part is the binary equivalent of 400. The control finds the operation in memory at address 400 and adds it to the content of AC.The instruction in address 30 is shown in figure fig(c) has a mode bit I = 1.Therefore, it is recognized as an indirect address instruction.The address part is the binary equivalent of 300.The control goes to address 300 to find the address of the operand.The address of the operand in this case is 1200.The operand found in address 1200 is then added to the content of AC.

The indirect address instruction needs two references to memory to fetch an operand.The first reference is needed to read the address of the operand ; the second is for the operand itself.We define the effective address to be the address of the operand in a computation-type instruction of the target address in a branch type instruction.Thus the effective address in the instruction of fig(b)is 400 and in the instruction of fig(c) is 1200.So if any reader is familiar with some programing language, he/she can clearly see that indirect addressing is as like pointer referencing.


Note : For more information, you can also visit my other blogs. And don't forget to give your valuable comments.

0 comments:

Post a Comment