2. Instruction code
ā¢ A computer instruction is a binary code that
determines the micro-operations in a
sequence for a computer.
ā¢ They are saved in the memory along with the
information. Each computer has its specific
group of instructions.
3. Instruction code
ā¢ They can be categorized into two elements as
Operation codes (Opcodes) and Address.
Opcodes specify the operation for specific
instructions.
ā¢ An address determines the registers or the
areas that can be used for that operation.
Operands are definite elements of computer
instruction that show what information is to
be operated on.
4. Instruction code
ā¢ It consists of 12 bits of memory that are required to
define the address as the memory includes 4096
words.
ā¢ The 15th bit of the instruction determines the
addressing mode (where direct addressing corresponds
to 0, indirect addressing corresponds to 1).
ā¢ Therefore, the instruction format includes 12 bits of
address and 1 bit for the addressing mode, 3 bits are
left for Opcodes.
6. Addressing Modes
ā¢ Instructions that define the address of a
definite memory location are known as
memory reference instructions.
ā¢ The method in which a target address or
effective address is recognized within the
instruction is known as addressing mode.
7. Addressing Mode
ā¢ The address field for instruction can be represented
in two different ways are as follows ā
Direct Addressing ā It uses the address of the
operand.
Indirect Addressing ā It facilitates the address
as a pointer to the operand.
ā¢ The address of the operand or the target address is
called the effective address.
ā¢ Effective Address (EA) ā It defines the address that
can be executed as a target address for a branch type
instruction or the address that can be used directly
to create an operand for a computation type
instruction, without creating any changes.
8. Opcodes
ā¢ An opcode is a collection of bits that represents
the basic operations including add, subtract,
multiply, complement, and shift. The total
number of operations provided through the
computer determines the number of bits needed
for the opcode.
ā¢ The minimum bits accessible to the opcode
should be n for 2n operations. These operations
are implemented on information that is saved in
processor registers or memory.
9. Address
ā¢ The address is represented as the location where a
specific instruction is constructed in the memory. The
address bits of an instruction code is used as an
operand and not as an address.
ā¢ In such methods, the instruction has an immediate
operand. If the second part has an address, the
instruction is referred to have a direct address.
ā¢ There is another possibility in the second part including
the address of the operand. This is referred to as an
indirect address. In the instruction code, one bit can
signify if the direct or indirect address is executed.
10. The figure shows a diagram showing
direct and indirect addresses
11. Computer Instructions
ā¢ Computer instructions are a set of machine
language instructions that a particular processor
understands and executes. A computer performs
tasks on the basis of the instruction provided.
ā¢ An instruction comprises of groups called fields.
These fields include:
ā¢ The Operation code (Opcode) field which specifies
the operation to be performed.
ā¢ The Address field which contains the location of
the operand, i.e., register or memory location.
ā¢ The Mode field which specifies how the operand
will be located.
12. ā¢ A basic computer has three instruction code
formats which are:
ā¢ Memory - reference instruction
ā¢ Register - reference instruction
ā¢ Input-Output instruction
13. Memory - reference instruction
ā¢ In Memory-reference instruction, 12 bits of
memory is used to specify an address and one
bit to specify the addressing mode 'I'.
14. Register Reference Instruction
ā¢ The Register-reference instructions are
represented by the Opcode 111 with a 0 in the
leftmost bit (bit 15) of the instruction.
ā¢ A Register-reference instruction specifies an
operation on or a test of the AC (Accumulator)
register.
15. Input-Output instruction
ā¢ Just like the Register-reference instruction, an Input-
Output instruction does not need a reference to
memory and is recognized by the operation code 111
with a 1 in the leftmost bit of the instruction. The
remaining 12 bits are used to specify the type of the
input-output operation or test performed.
17. Instruction Cycle
ā¢ A program residing in the memory unit of a computer
consists of a sequence of instructions. These instructions
are executed by the processor by going through a cycle for
each instruction.
ā¢ In a basic computer, each instruction cycle consists of the
following phases:
ā¢ Fetch instruction from memory.
ā¢ Decode the instruction.
ā¢ Read the effective address from memory.
ā¢ Execute the instruction.
19. Instruction Cycle
ā¢ Fetch and Decode:- Initially, the program counter
PC is loaded with the address of the first
instruction in the program.
ā¢ The sequence counter SC is cleared to 0,
providing a decoded timing signal T0.
ā¢ After each clock pulse, SC is incremented by one,
so that the timing signals go through a sequence
T0, T1, T2, and so on.
ā¢ The microoperations for the fetch and decode
phases can be specified by the following register
transfer statements.
20. Instruction Cycle
ā¢ Since only AR is connected to the address inputs of memory, it
is necessary to transfer the address from PC to AR during the
clock transition associated with timing signal T0
ā¢ The instruction read from memory is then placed in the
instruction register IR with the clock transition associated with
timing signal T1
ā¢ At the same time, PC is incremented by one to prepare it for
the address of the next instruction in the program. At time T2,
the operation code in IR is decoded, the indirect bit is
transferred to flip-flop I, and the address part of the instruction
is transferred to AR .
ā¢ Note that SC is incremented after each clock pulse to produce
the sequence To, T1, and T2
22. flowchart
ā¢ Determine the Type of Instruction:-The timing signal that is active after
the decoding is T3
ā¢ During time T3 the control unit determines the type of instruction that
was just read from memory.
ā¢ Decoder output D7 is equal to 1 if the operation code is equal to binary
111.
ā¢ If D7 = 1 and I = 1, then execute the input output instruction .
ā¢ If D7 = 1 and I = 0, then execute the register reference instruction .
ā¢ If D7= 0, the operation code must be one of the other seven values 000
through 110, specifying a memory-reference
ā¢ instruction.
ā¢ If D7 = 0 and I = 1, we have a memory reference instruction with an
indirect address access .
ā¢ If D7 = 0 and I = 0, we have a memory reference instruction with an direct
address access.
23. Instruction Formats
ā¢ Operations specified by computer instructions are
executed on some data stored in memory or processor
registers.
ā¢ Operands residing in memory are specified by their
memory address.
ā¢ Operands residing in processor registers are specified
with a register address.
ā¢ Thus a CPU with 16 processor registers R0 through R15
will have a register address field of four bits.
ā¢ The binary number 0101, for example, will designate
register RS.
24. Instruction Format
ā¢ Computers may have instructions of several different
lengths containing varying number of addresses.
ā¢ The number of address fields in the instruction format
of a computer depends on the internal organization of
its registers.
ā¢ Most computers fall into one of three types of CPU
organizations:
ā¢ 1. Single accumulator organization.
ā¢ 2. General register organization.
ā¢ 3. Stack organization.
25. Instruction Format
ā¢ An example of an accumulator-type organization instruction.
A D D X where X is the address of the operand.
ā¢ The ADD instruction in this case results in the operation AC <--
AC + M [X]. AC is the accumulator register and M [X]
symbolizes the memory word located at address X.
ā¢ An example of a general register type of organization was
presented in An example of register organization instruction.
ā¢ Thus the instruction for an arithmetic addition may be written
in an assembly language as ADD R 1 , R 2 , R 3 t o denote the
operation R 1 <--- R2 + R 3 .
ā¢ The number o f address fields in the instruction can be
reduced from three to two if the destination register is the
same as one of the source registers.
26. Instruction Format
ā¢ Thus the instruction A D D R 1 , R 2 would denote the
operation R 1 <--- R 1 + R2.
ā¢ Only register addresses for R 1 and R2 need be specified in
this instruction. . The stack-organized instruction .
ā¢ Computers with stack organization would have PUSH and
POP instructions which require an address field.
ā¢ PUSH X will push the word at address X to the top of the
stack. The stack pointer is updated automatically.
ā¢ Operation type instructions do not need an address field in
stack-organized computers. This is because the operation is
performed on the two items that are on top of the stack.
The instruction ADD .
27. Three-Address Instructions
ā¢ Computers with three-address instruction formats can use each
address field to specify either a processor register or a memory
operand.
ā¢ The program in assembly language that evaluates X = (A + B) *
(C + D) is shown below, together with comments that explain
the register transfer operation of each instruction.
ā¢ It is assumed that the computer has two processor registers, R 1
and R2.
ā¢ The symbol M [A ] denotes the operand at memory address
symbolized by A .
28. Three-Address Instructions
ā¢ The advantage o f the three-address format i s
that i t results i n short programs when
evaluating arithmetic expressions.
ā¢ The disadvantage is that the binary-coded
instructions require too many bits to specify
three addresses.
29. Two-Address Instructions
ā¢ Two-address instructions are the most
common in commercial computers. Here again
each address field can specify either a
processor register or a memory word. The
program to evaluate X = (A + B) * (C + D) is as
follows
30.
31.
32. RISC Instructions
ā¢ A reduced instruction set computer (RISC). The instruction
set of a typical RISC processor is restricted to the use of
load and store instructions when communicating between
memory and CPU.
ā¢ All other instructions are executed within the registers of
the CPU without referring to memory.
ā¢ A program for a RISC-type CPU consists of LOAD and STORE
instructions that have one memory and one register
address, and computational-type instructions that have
three addresses with all three specifying processor
registers.
ā¢ The following is a program to evaluate X = (A + B) ā¢ (C + D).