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 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.
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.
 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
• 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.
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.
To each of the 2K instructions a unique binary bit
pattern of length K is assigned.
An K-to-2K decoder can then be used to decode all the
instructions. For example,
3-to-8
decoder3-bit Op-code
instruction 0
instruction 1
instruction 2
instruction 3
instruction 4
instruction 5
instruction 6
instruction 7
 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;
 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);
 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
 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!

Instruction codes

  • 1.
  • 2.
    Instruction Codes A Programas 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.
  • 3.
    Operation Code The operationcode 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.
  • 4.
    Stored Program Organisation Thesimplest 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.
  • 5.
    Computer Register: A processorregister (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.
  • 6.
    Registers are commonsequential 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.
  • 7.
    Flip-flops are limitedbecause 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.
  • 8.
    Computer Instructions Computer instructionsare 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.
  • 9.
    Computer Instruction: Instructions areencoded 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.
  • 10.
     An instructionhas 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
  • 11.
    • The shorterthe 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.
  • 13.
    Byte ordering Big-endian: bytesin 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.
  • 14.
    To each ofthe 2K instructions a unique binary bit pattern of length K is assigned. An K-to-2K decoder can then be used to decode all the instructions. For example, 3-to-8 decoder3-bit Op-code instruction 0 instruction 1 instruction 2 instruction 3 instruction 4 instruction 5 instruction 6 instruction 7
  • 15.
     inherent ◦ anop-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;
  • 16.
     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);
  • 17.
     indexed ◦ anoffset 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
  • 18.
     Instructions, ofmost 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
  • 20.
    Timing and ControlInstruction 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.
  • 22.