lec 11
lec 11
Instruction Codes
• Program: A Program is a set of instruction that specify the operations, operands
and the sequence by which processing has to occur.
• Operation can be addition, subtraction, shifting and operand can be
register operand or memory operand
• Computer Instruction: A computer instruction is a binary code that specifies a
sequence of microoperation for the computer.
• I want to perform addition and for performing addition the basic operation
which are required to fetch the data from memory to get it stored into the
register then perform the addition store back result to the memory so such
microoperation are defined based on this binary code and that is
instruction.
• The computer reads each instruction from memory and places it in a
control register.
• The control then interprets the binary code of the instruction and
proceeds to execute it by issuing a sequence of microoperation.
Instruction Code
An instruction code is a group of bits that instruct the computer
to perform a specific operation.
ADD 457
Instruction code divide into two parts:
Operation code(Opcode); is a group of bits that
define such operations as add, subtract, multiply,
shift….
Must consist of at least n bits for a given 2n
distinct operation.
Unique binary code is assigned to every opcode,
they are to be fixed at the timing of designing of
the computer.
For 64 distinct operation 6-bit opcode is
required.
110010 for ADD. When this operation code is
decoded in the control unit the computer issues
control signals to read an operation from
memory and add the operand to a process
register.
Stored
program
Organization
If the second part of an instruction
format specifies the address of an
Direct and In operand, the instruction is said to have
a direct address
Direct
Addressing In indirect address, the bits in the
second part of the instruction designate
an address of a memory word in which
the address of the operand found.
PC (program Counter (12)): holds the
address of next instruction
01 02 03 04 05
Instruction set is said 1. Arithmetic, logic 2. Instruction for 3. Program control 4 Input and output
to be complete if it and shift instruction moving information instruction together instruction
include sufficient to and from memory with instruction that
number of instruction and processor check status
in each of the register conditions.
following categories:
Timing and control
CLOCK PLUS ARE APPLIED TO ALL FLIP THE CONTROL SIGNAL ARE GENERATED IN
ALL REGISTER ARE CONTROLLED BY A FLOP AND REGISTER IN THE SYSTEM. BUT THE CONTROL UNIT.
MASTER CLOCK GENERATOR. THIS CLOCK PLUS DOES NOT CHANGE
STATE OF REGISTER UNLESS THE REGISTER
IS ENABLED BY A CONTROL SIGNAL.
Control organization
D3T4: SC<-0
Instruction cycle
• A program residing in the memory unit of the computer
consists of a sequence of instructions. In the basic
computer each instruction cycle consists of the
following phases:
1. Fetch an instruction form memory.
2. Decode the instruction
3. Read the effective address from memory if the
instruction has an indirect.
4. Execute the instruction.
• After step 4 the control goes back to step 1 to fetch
decode and execute the next instruction.
• This process continues unless a HALT instruction is
encountered
Fetch and decode
• PC is loaded with the address of the first instruction in the program.
• Sequence counter SC is cleared to zero (0). After each clock plus SC is
incremented by one.
• The microoperation for fetch and decode phases are as follow:
Determine the
type
of instruction
Questions
A computer uses a memory unit with 256K words of 32 bits each. A binary instruction code is stored in one
word of memory. The instruction has four parts: an indirect bit, an operation code, a register code part to
specify one of 64 registers, and an address part.
a) How many bits are there in the operation code, the register code part, and the address part?
b) Draw the instruction word format and indicate the number of bits in each part.
Register
reference
instruction
Memory reference instruction
FGI is set to 0
Input data is shifted into
INPR
FGI is set to 1
Information from INPR is
transferred to AC
Initially FGO is 1
Information from AC to
OUTR
FGO is set to 0
Data transfer from OUTR to
output device
Input-output instruction
Interrupt cycle
• During the normal execution, the
program interrupt may occur that
means some input or output operation
may occur and we are changing our
control of execution of our program
Design of basic computer
• A relative mode branch type of instruction is stored in memory at an address equivalent to decimal 900. The
branch is made to an address equivalent to decimal 382. What should be the value of the relative address field of
the instruction (in decimal)?
• a. direct = 400
• b. Immediate = 301
• c. Relative = 302 + 400 = 702
• d. Reg. Indirect = 200
• e. Indexed = 200 + 400 = 600
• If an instruction has the value B03F (Hex) then explain the operation performed by it.
• Consider the following snapshot of memory:
2A3 603B
3CB 059A
4AC 83CB
59A 8A26
If the contents of PC=4AC and AC=2FA1 then which instruction will be fetched next and what it
means?
Explain the binary operations that will be performed by the instruction fetched in part b above and
what will be the contents of AC after execution of that instruction.
a. Contents of AC are stored to memory location 03F
b. Next instruction fetched: 83CB and it will perform AND operation between AC and
indirect memory word.
c. 8A2C & 2FA1
1000 1010 0010 1100
0010 1111 1010 0001
----------------------------
0000 1010 0010 0000 = 0A20 is the accumulator contents