Module 2 COA
Module 2 COA
An instruction code is a group of bits that instruct the computer to perform a specific
operation.
Computer Instructions
The operation code of an instruction is a group of bits that define operations such as
addition, subtraction, shift, complement, etc. An instruction must also include one or more
operands, which indicate the registers and/or memory addresses from which data is taken
or to which data is deposited.
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.
The Register-reference instructions are represented by the Opcode 111 with a 0 in the
leftmost bit (bit 15) of the instruction.
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.
Computer Registers
Registers are a type of computer memory used to quickly accept, store, and transfer data
and instructions that are being used immediately by the CPU. The registers used by the CPU
are often termed as Processor registers.
A processor register may hold an instruction, a storage address, or any data (such as bit
sequence or individual characters).
The computer needs processor registers for manipulating data and a register for holding a
memory address. The register holding the memory location is used to calculate the address
of the next instruction after the execution of the current instruction is completed.
Following is the list of some of the most common registers used in a basic computer s
Register Symbol Number of bits Function
The following image shows the register and memory configuration for a basic computer.
The Memory unit has a capacity of 4096 words, and each word contains 16 bits.
The Data Register (DR) contains 16 bits which hold the operand read from the
memory location.
The Memory Address Register (MAR) contains 12 bits which hold the address for
the memory location.
The Program Counter (PC) also contains 12 bits which hold the address of the next
instruction to be read from memory after the current instruction is executed.
The Accumulator (AC) register is a general purpose processing register.
The instruction read from memory is placed in the Instruction register (IR).
The Temporary Register (TR) is used for holding the temporary data during the
processing.
The Input Registers (IR) holds the input characters given by the user.
The Output Registers (OR) holds the output after processing the input data .
Instruction Cycle
The timing for all registers in the basic computer is controlled by a master clock generator.
The clock pulses are applied to all flip-flops and registers in the system, including the flip-
flops and registers in the control unit. The clock pulses do not change the state of a register
unless the register is enabled by a control signal. The control signals are generated in the
control unit and provide control inputs for the multiplexers in the common bus, control
inputs in processor registers, and microoperations for the accumulator.
In the hardwired organization, the control logic is implemented with gates, flip-flops,
decoders, and other digital circuits. It has the advantage that it can be optimized to produce
a fast mode of operation. In the microprogrammed organization, the control information is
stored in a control memory. The control memory is programmed to initiate the required
sequence of microoperations. A hardwired control, as the name implies, requires changes
in the wiring among the various components if the design has to be modified or changed.
An instruction read from memory is placed in the instruction register (IR). The instruction
register is divided into three parts:
1. the 1 bit,
2. the operation code, and
3. bits 0 through 11.
The operation code in bits 12 through 14 are decoded with a 3 x 8 decoder. The eight
outputs of the decoder are designated by the symbols D 0 through D 7. The subscripted
decimal number is equivalent to the binary value of the corresponding operation code. Bit
15 of the instruction is transferred to a flip-flop designated by the symbol I. Bits 0 through
11 are applied to the control logic gates. The 4-bit sequence counter can count in binary
from 0 through 15. The outputs of the counter are decoded into 16 timing signals T 0
through T15.
The sequence counter SC can be incremented or cleared synchronously. Most of the time,
the counter is incremented to provide the sequence of timing signals out of the 4 x 16
decoder. Once in a while, the counter is cleared to 0, causing the next active timing signal to
be T0.
The timing diagram below shows the time relationship of the control signals.
The sequence counter SC responds to the positive transition of the clock. Initially, the CLR
input of SC is active. The first positive transition of the clock clears SC to 0, which in tum
activates the timing signal T0 out of the decoder. T0 is active during one clock cycle. The
positive clock transition labeled T0 in the dagram will trigger only those registers whose
control inputs are transition, to timing signal T0. SC is incremented with every positive
clock transition unless its CLR input is active. This produces the sequence of timing signals
T0, T1, T2, T3 ,T4 and so on, as shown in the dagram. (Note the the relationshuip between the
timing signal and and its corresponding positive clock transition.) If SC is not cleared, the
Memory reference instructions are those commands or instructions which are in the
custom to generate a reference to the memory and approval to a program to have an
approach to the commanded information and that states as to from where the data is cache
continually. These instructions are known as Memory Reference Instructions.
There are seven memory reference instructions which are as follows &
AND
The AND instruction implements the AND logic operation on the bit collection from the
register and the memory word that is determined by the effective address. The result of
this operation is moved back to the register.
ADD
The ADD instruction adds the content of the memory word that is denoted by the effective
address to the value of the register.
LDA
The LDA instruction shares the memory word denoted by the effective address to the
register.
STA
STA saves the content of the register into the memory word that is defined by the effective
address. The output is next used to the common bus and the data input is linked to the bus.
It needed only one micro-operation.
BUN
The Branch Unconditionally (BUN) instruction can send the instruction that is determined
by the effective address. They understand that the address of the next instruction to be
performed is held by the PC and it should be incremented by one to receive the address of
the next instruction in the sequence. If the control needs to implement multiple
instructions that are not next in the sequence, it can execute the BUN instruction.
BSA
BSA stands for Branch and Save return Address. These instructions can branch a part of the
program (known as subroutine or procedure). When this instruction is performed, BSA will
store the address of the next instruction from the PC into a memory location that is
determined by the effective address.
ISZ
The Increment if Zero (ISZ) instruction increments the word determined by effective
address. If the incremented cost is zero, thus PC is incremented by 1. A negative value is
saved in the memory word through the programmer. It can influence the zero value after
getting incremented repeatedly. Thus, the PC is incremented and the next instruction is
skipped.
An interrupt in computer architecture is a signal that requests the processor to suspend its
current execution and service the occurred interrupt. To service the interrupt the
processor executes the corresponding interrupt service routine (ISR). After the execution
of the interrupt service routine, the processor resumes the execution o f the suspended
program. Interrupts can be of two types of hardware interrupts and software interrupts.
The interrupts can be various type but they are basically classified into hardware
interrupts and software interrupts.
1. Hardware Interrupts
If a processor receives the interrupt request from an external I/O device it is termed as a
hardware interrupt. Hardware interrupts are further divided into maskable and non -
maskable interrupt.
Maskable Interrupt: The hardware interrupt that can be ignored or delayed for some time
if the processor is executing a program with higher priority are termed as maskable
interrupts.
Non-Maskable Interrupt: The hardware interrupts that can neither be ignored nor
delayed and must immediately be serviced by the processor are termed as non-maskeable
interrupts.
2. Software Interrupts
The software interrupts are the interrupts that occur when a condition is met or a system
call occurs.
STACK ORGANIZATION
Stack is also known as the Last In First Out (LIFO) list. It is the most important feature in
the CPU. It saves data such that the element stored last is retrieved first. A stack is a
memory unit with an address register. This register influence the address for the stack,
which is known as Stack Pointer (SP). The stack pointer continually influences the address
of the element that is located at the top of the stack.
It can insert an element into or delete an element from the stack. The insertion operation is
known as push operation and the deletion operation is known as pop operation. In a
computer stack, these operations are simulated by incrementing or decrementing the SP
register.
Register Stack
The stack can be arranged as a set of memory words or registers. Consider a 64-word
register stack arranged as displayed in the figure. The stack pointer register includes a
binary number, which is the address of the element present at the top of the stack. The
three-element A, B, and C are located in the stack.
The element C is at the top of the stack and the stack pointer holds the address of C that is
3. The top element is popped from the stack through reading memory word at address 3
and decrementing the stack pointer by 1. Then, B is at the top of the stack and the SP holds
the address of B that is 2. It can insert a new word, the stack is pushed by incrementing the
stack pointer by 1 and inserting a word in that incremented location.
The stack pointer includes 6 bits, because 2 6 = 64, and the SP cannot exceed 63 (111111 in
binary). After all, if 63 is incremented by 1, therefore the result is 0(111111 + 1 =
1000000). SP holds only the six least significant bits. If 000000 is decremented by 1 thus
the result is 111111.
Therefore, when the stack is full, the one-bit register ‘FULL’ is set to 1. If the stack is null,
then the one-bit register ‘EMTY’ is set to 1. The data register DR holds the binary
information which is composed into or readout of the stack.
First, the SP is set to 0, EMTY is set to 1, and FULL is set to 0. Now, as the stack is not full
(FULL = 0), a new element is inserted using the push operation.
The stack pointer is incremented by 1 and the address of the next higher word is saved in
the SP. The word from DR is inserted into the stack using the memory write operation. The
first element is saved at address 1 and the final element is saved at address 0. If the stack
pointer is at 0, then the stack is full and ‘FULL’ is set to 1. This is the condition when the SP
was in location 63 and after incrementing SP, the final element is saved at addre ss 0.
During an element is saved at address 0, there are no more empty registers in the stack.
The stack is full and the ‘EMTY’ is set to 0.
A new element is deleted from the stack if the stack is not empty (if EMTY = 0). The pop
operation includes the following sequence of micro-operations −
The top element from the stack is read and transfer to DR and thus the stack pointer is
decremented. If the stack pointer reaches 0, then the stack is empty and ‘EMTY’ is set to 1.
This is the condition when the element in location 1 is read out and the SP is decremented
by 1.
Instruction Formats
The instructions provided to computers help the computer perform a task. The computers
comprise instructions in groups called fields. Each field has different information and
different significance based on which the CPU decides what to perform.
The set of instructions that manages the operation codes is called the format of instruction.
The design of bits in instruction is supported by the format of instruction. The length of
instruction is generally preserved in multiples of character, which is 8bits. The instruction
format determines the behaviour and complexity of instruction. Depending upon the
number of addresses, the format of instruction is of variable length.
The instruction format in which there is no address field is called zero address
instruction
The instruction format in which the instruction uses only one address field is called
the one address instruction format
In this type of instruction format, one operand is in the accumulator and the other is
in the memory location
It has only one operand
It has two special instructions LOAD and STORE
The instruction format in which the instruction uses only two address fields is called
the two address instruction format
This type of instruction format is the most commonly used instruction format
As in one address instruction format, the result is stored in the accumulator only,
but in two addresses instruction format the result can be stored in different
locations
This type of instruction format has two operands
It requires shorter assembly language instructions
The instruction format in which the instruction uses the three address fields is
called the three address instruction format
It has three operands
It requires shorter assembly language instructions
It requires more bits
ADDRESSING MODES
Each instruction requires some data on which it has to operate. There are different
techniques to specify data for instructions. These techniques are called addressing modes.
Intel 8085 uses the following addressing modes:
1. Direct Addressing
In this addressing mode, the address of the operand (data) is given in the instruction itself.
Example
STA 2400H: It stores the content of the accumulator in the memory location 2400H.
In this instruction, 2400H is the memory address where data is to be stored. It is given in
the instruction itself. The 2nd and 3rd bytes of the instruction specify the address of the
memory location. Here, it is understood that the source of the data is accumulator.
2. Register Addressing
In register addressing mode, the operand is in one of the general purpose re gisters. The
opcode specifies the address of the register(s) in addition to the operation to be performed.
In the above example, MOV A, B is 78H. Besides the operation to be performed the opcode
also specifies source and destination registers.
The opcode 78H can be written in binary form as 01111000. The first two bits, i.e. 0 1 are
for MOV operation, the next three bits 1 1 1 are the binary code for regis ter A, and the last
three bits 000 are the binary code for register B.
Example:
4. Immediate Addressing
In this addressing mode, the operand is specified within the instruction itself.
Example : LXI H, 2500 is an example of immediate addressing. 2500 is 16-bit data which is
given in the instruction itself. It is to be loaded into H-L pair.
5. Implicit Addressing
There are certain instructions which operate on the content of the accumulator. Such
instructions do not require the address of the operand.
As the name suggests data transfer instructions are meant for transfer for data from
one location to another, keeping the binary information intact. The useful transfer are
between memory and processing registers, between processor registers and input or
output, and between the processor registers themselves. Each instruction is accompanied
with the mnemonic symbol which are different in different computers for the same
instruction name. Table below gives a list of eight data transfer instructions used in many
computers.
The “load” instruction represent a transfer from memory to a processor register, usually an
“accumulator” where as the store instruction designates a transfer from a processor
register into memory.
The move instruction is employed in computers with multiple CPU registers to designate a
transfer from one register to another. It has also been used for data transfers between CPU
registers and memory or between two memory words. Swapping of information between
to registers of a register and memory word its accomplished by using the exchange
instruction. The input and output instructions cause transfer of data among processor
registers and input or output terminals. The push and pop instructions take care of transfer
of data between processor registers and a memory stack.
To distinguish with between the various address modes, the mnemonic symbol are
modified by assembly language conventions. For instance, the mnemonic for load
immediate becomes LDI. Other assembly language conventions use a special character to
designate the addressing mode. For example, the immediate mode is recognized from a
pound sign # placed before the operand. What ever may be the case, the important thing is
to realize that each instruction can occur with a variety of addressing modes.
1. Arithmetic instructions
2. Logical and bit manipulation instructions
3. Shift instructions
1. Arithmetic instructions:
The four basic arithmetic operations are addition, subtraction, multiplication, and
division. Most computers provide instructions for all four operations.
COM
It will complement the accumulator, AC<-(AC)’
Complement COM A
3. Shift Instructions:
Shifts are operations in which the bits of a word are moved to the left or right. Shift
instructions may specify either logical shifts, arithmetic shifts, or rotate-type
operations.
Types of Processors:
RISC stands for Reduced Instruction Set Computer and CISC stands for Complex
Instruction Set Computer.
RISC PROCESSOR
Examples of RISC processors are SUN's SPARC, PowerPC, Microchip PIC processors, RISC -V.
1. The RISC processor's performance is better due to the simple and limited number of
the instruction set.
2. It requires several transistors that make it cheaper to design.
3. RISC allows the instruction to use free space on a microprocessor because of its
simplicity.
4. RISC processor is simpler than a CISC processor because of its simple and quick
design, and it can complete its work in one clock cycle.
1. One cycle execution time: For executing each instruction in a computer, the RISC
processors require one CPI (Clock per cycle). And each CPI includes the fetch,
decode and execute method applied in computer instruction.
2. Pipelining technique: The pipelining technique is used in the RISC processors to
execute multiple parts or stages of instructions to perform more efficiently.
3. A large number of registers: RISC processors are optimized with multiple
registers that can be used to store instruction and quickly respond to the computer
and minimize interaction with computer memory.
4. It supports a simple addressing mode and fixed length of instruction for executing
the pipeline.
5. It uses LOAD and STORE instruction to access the memory location.
6. Simple and limited instruction reduces the execution time of a process in a RISC.
CISC PROCESSOR
The CISC Stands for Complex Instruction Set Computer, developed by the Intel. It has a
large collection of complex instructions that range from simple to very complex and
specialized in the assembly language level, which takes a long time to execute the
instructions. So, CISC approaches reducing the number of instruction on each program and
ignoring the number of cycles per instruction. It emphasizes to build complex instructions
directly in the hardware because the hardware is always faster than software. However,
CISC chips are relatively slower as compared to RISC chips but use little instruction than
RISC. Examples of CISC processors are VAX, AMD, Intel x86 and the System/360.
4 It requires multiple register sets to store It requires a single register set to store
the instruction. the instruction.
6 Uses of the pipeline are simple in RISC. Uses of the pipeline are difficult in CISC.
8 It uses LOAD and STORE that are It uses LOAD and STORE instruction in
independent instructions in the register- the memory-to-memory interaction of a
to-register a program's interaction. program.
10 The execution time of RISC is very short. The execution time of CISC is longer.
11 RISC architecture can be used with high- CISC architecture can be used with low-
end applications like telecommunication, end applications like home automation,
image processing, video processing, etc. security system, etc.
14 Example of RISC: ARM, PA-RISC, Power Examples of CISC: VAX, Motorola 68000
Architecture, Alpha, AVR, ARC and the family, System/360, AMD and the Intel
SPARC. x86 CPUs.