Instruction codes

8,364 views 22 slides Feb 16, 2018
Slide 1
Slide 1 of 22
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22

About This Presentation

Describe about Instruction codes


Slide Content

Submitted by V. Pradeepa msc (cs&it) Nadar Saraswathi College of Arts & Science, Theni INSTRUCTION CODES Unit-IV

Instruction Codes A  Program as we all know is A set of instructions that specify the operations, operands, and the sequence by which processing has to occur. An  instruction code  is a group of bits that tells the computer to perform a specific operation part.

Operation Code The operation code of an instruction is a group of bits that define operations such as add, subtract, multiply, shift and compliment. The number of bits required for the operation code depends upon the total number of operations available on the computer. The operation code must consist of at least  n bits  for a given  2^n  operations. The operation part of an instruction code specifies the operation to be performed.

Stored Program Organisation The simplest way to organize a computer is to have  Processor Register  and instruction code with two parts. The first part specifies the operation to be performed and second specifies an address. The memory address tells where the operand in memory will be found. Instructions are stored in one section of memory and data in another. Computers with a single processor register is known as  Accumulator (AC) . The operation is performed with the memory operand and the content of AC.

Computer Register: A processor register (CPU register) is one of a small set of data holding places that are part of the computer  processor . A register may hold an  instruction , a storage address, or any kind of data (such as a bit sequence or individual characters ). Some instructions specify registers as part of the instruction. For example, an instruction may specify that the contents of two defined registers be added together and then placed in a specified register.

Registers Registers are common sequential devices. They’re a good example of sequential analysis and design . They are also frequently used in building larger sequential circuits. Registers hold larger quantities of data than individual flops . Registers are central to the design of modern processors. There are many different kinds of registers. Some applications of these special registers.

Benefits of registers Flip-flops are limited because they can store only one bit. Two flip-flops are used for two-bit counters . Most computers work with integers and single-precision floating-point numbers that are 32-bits long . Registers are commonly used as temporary storage in a processor. They are faster and more convenient than main memory . More registers can help speed up complex calculations.

Computer Instructions Computer instructions are the basic components of a machine language program. They are also known as  macro operations , since each one is comprised of a sequences of micro operations. Each instruction initiates a sequence of micro operations that fetch operands from registers or memory, possibly perform arithmetic, logic, or shift operations, and store results in registers or memory.

Computer Instruction: Instructions are encoded as binary  instruction codes . Each instruction code contains of a  operation code , or  opcode , which designates the overall purpose of the instruction (e.g. add, subtract, move, input, etc.). The number of bits allocated for the opcode determined how many different instructions the architecture supports.

Computer Instruction Set An instruction has two components: e.g The operand field may have the following formats: 1) zero-address 2) one-address 3) two-address 4) three-address The total number of instructions and the types and formats of the operands determine the length of an instruction . . Op-code Operand(s) ADD R0 100

Computer Instruction Set The shorter the instruction, the faster the time that it can be fetched and decoded . Shorter instructions are better than longer ones: ( i ) take up less space in memory (ii) transferred to the CPU faster A machine with 2^N instructions must require at least N-bit to encode all the op-codes.

Bits/cell (word)

Instruction sets Byte ordering Big-endian : bytes in word ordered from left-to-right eg . Motorola Little-endian : bytes in word ordered right-to-left eg . Intel Creates havoc when transferring data; need to swap byte order in transferred words.

Op-code Encoding To each of the 2 K instructions a unique binary bit pattern of length K is assigned . An K-to-2 K decoder can then be used to decode all the instructions. For example, 3-to-8 decoder 3-bit Op-code instruction 0 instruction 1 instruction 2 instruction 3 instruction 4 instruction 5 instruction 6 instruction 7

Addressing modes inherent an op-code indicates the address of its operand CLI ; clear the interrupt flag immediate an instruction contains or immediately precedes its operand value ADD #250, R1 % R1 := R1 + 250; Absolute/Direct an instruction contains the memory address of its operand ADD 250, R1 % R1 := R1 + *(250); register an instruction contains the register address of its operand ADD R2, R1 % R1 := R1 + R2;

Addressing Modes register indirect the register address in an instruction specifies the address of its operand ADD @R2, @R1 % *R1 := *R1 + *R2; auto-decrement or auto-increment The contents of the register is automatically decremented or incremented before or after the execution of the instruction MOV (R2)+, R1 % R1 := *(R2); R2 := R2 + k; MOV -(R2), R1 % R2 := R2 - k; R1 := *(R2);

Addressing Modes indexed an offset is added to a register to give the address of the operand MOV 2(R2), R1 % R1 := R2[2]; base-register a displacement is added to an implicit or explicit base register to give the address of the operand relative same as base-register mode except that the instruction pointer is used as the base register

Instruction Types Instructions, of most modern computers, may be classified into the following six groups: Data transfer (40% of user program instructions) MOV, LOAD Arithmetic ADD, SUB, DIV, MUL Logical AND, OR, NOT, SHIFT, ROTATE System-control Test-And-Set

Timing and Control Instruction Cycle: A  hardwired  control unit is designed from scratch using traditional digital logic design techniques to produce a minimal, optimized circuit. In other words, the control unit is like an ASIC (application-specific integrated circuit). A  micro programmed  control unit is built from some sort of ROM. The desired control signals are simply stored in the ROM, and retrieved in sequence to drive the micro operations needed by a particular instruction.

THANK YOU!
Tags