COA 2nd Unit Full
COA 2nd Unit Full
COA 2nd Unit Full
The computer reads each instruction from memory and places it in a control register
The ability to store and execute instructions, the stored program concept, is the most
important property of a general-purpose computer
• An instruction code is a group of bits that instruct the computer to perform
a specific operation.
It is usually divided into parts
operation part
• The operation code of an instruction is a group of bits that define such
operations as add, subtract, multiply, shift, and complement
• The number of bits required for the operation code of an instruction
depends on the total number of operations available in the computer
• Consider a computer with 64 (26) distinct operations, one of them being an
ADD operation. The operation code consists of six bits, with a bit
configuration 110010 assigned to the ADD operation.
•Operation code is decoded in the control unit
•Computer issues control signals to read an operand from memory
•Add the operand to a processor register.
Stored Program Organization
• Organize a computer is to have one processor register and an instruction
code format with two parts.
• The first part specifies => operation to be performed
• The second specifies => an address
• The memory address tells the control where to find an operand in memory
• This operand is read from memory
• The data to be operated on together with the data stored in the processor
register.
• Instructions are stored in one section of
memory and data in another.
• For a memory unit with 4096 words we
need 12 bits to specify an address since
212 = 4096.
• one 16-bit memory word, we have
available four bits for the operation code
(opcode) to specify one out of 16 possible
operations, and 12 bits to specify the
address of an operand.
• The control reads a 16-bit instruction
from the program portion of memory.
• It uses the 12-bit address part of the
instruction to read a 16-bit operand from
the data portion of memory.
• It then executes the operation specified
by the operation code
• Computers that have a single-processor register usually use
accumulator (AC).
• The operation is performed with the memory operand and the
content of AC.
• Sometimes the instruction code not need an operand from memory
• For example, operations such as clear AC, complement AC, and
increment AC operate on data stored in the AC register.
• They do not need an operand from memory. For these types of
operations, the second part of the instruction code (bits 0 through
11) is not needed for specifying a memory address and can be used to
specify other operations for the computer.
Instruction Format
There are three parts of the Instruction Format which are as follows −
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.
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) − An absolute address that is either a direct
address or has been computed by one of the addressing schemes such as
augmenting, relative addressing, or indexing
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.
• It consists of 12 bits of memory that
are required to define the address as
the memory includes (212) 4096
words.
• The 15th bit of the instruction
determines the addressing mode
0 for direct addressing
1 for indirect addressing
The instruction format includes 12 bits of address and 1 bit for the
addressing mode, 3 bits are left for Opcodes.
Address
• The address is 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.
1. Direct Addressing Mode:
In direct addressing mode, address field in the instruction contains the
effective address of the operand and no intermediate memory access is
required.
Example:
Add the content of R1 and 1001 and store back to R1:
Add R1, (1001) Here 1001 is the address where operand is stored.
2. Indirect Addressing Mode:
In Indirect addressing mode, address field in the instruction contains
the memory location or register where effective address of operand is
present. It requires two memory access. It is further classified into two
categories: Register Indirect, and Memory Indirect.
Example:
LOAD R1, @500
• Above instruction is used to load the content of memory location
stored at memory location 500 to register R1. In other words we can
say, effective address is stored at memory location 500.
• This is the mode of addressing where the instruction contains the
address of the location where the target address is stored. So in this
way it is Indirectly storing the address of the target location in
another memory location. So it is called Indirect Addressing mode.
Difference between Direct and Indirect Addressing Modes:
No further calculation is
Require further calculation to find the
5. required to perform the
effective address
operation
There are 2 types(or versions) of Indirect Addressing Mode: Memory
Indirect, and Register Indirect.
1. Memory Indirect –
Directly mention the address of the memory location in the instruction
either enclosed by parenthesis or preceded by ‘@’ character.
Example :
LOAD R1, (1005) or LOAD R1, @1005
2. Register Indirect –
In this type the address of the target memory location will be stored in
the register and the register will be mentioned in the instruction.
Example :
MOV R@, 1005 LOAD R1, (R2)
Computer Registers / Processor 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 memory unit has a capacity of 4096 words and each word
contains 16 bits.
• Twelve bits of an instruction word are needed to specify the address
of an operand.
• This leaves three bits for the operation part of the instruction and a
bit to specify a direct or indirect address.
• The data register (DR) holds the operand read from memory.
• 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 temporary data during
the processing.
• The memory address register (AR) has 12 bits since this is the width of a memory
address.
• The program counter (PC) also has 12 bits and it holds the address of the next
instruction to be executed
• The PC goes through a counting sequence and causes the computer to read
sequential instructions previously stored in memory.
• Instruction words are read and executed in sequence unless a branch instruction
is encountered.
• A branch instruction calls for a transfer to a non-consecutive instruction in the
program.
• The address part of a branch instruction is transferred to PC to become the
address of the next instruction.
• To read an instruction, the content of PC is taken as the address for memory and
a memory read cycle is initiated.
• PC is then incremented by one, so it holds the address of the next instruction in
sequence.
• Two registers are used for input and output. The input register (INPR) receives an
8-bit character from an input device.
• The output register (OUTR) holds an 8-bit character for an output device.
Computer Instructions
• Computer instructions are a set of machine language instructions which processor
understands and executes.
• A computer will perform tasks based on the instruction provided.
• An instruction comprises of groups called fields.
• The bulk of the binary information is stored in memory, but all computations are
done in processor registers
• Therefore, the user must have the capability of moving information between
these two units.
• Program control instructions such as branch instructions are used to change the
sequence in which the program is executed.
• Input and output instructions are needed for communication between the
computer
Timing and Control
• 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 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.
The Control Unit is classified into two major categories:
• Hardwired Control [Hardware]
• Microprogrammed Control [software]
Hardwired Control
• The Hardwired Control
organization involves
the control logic to be
implemented with
gates, flip-flops,
decoders, and other
digital circuits.
A Hard-wired Control consists of two decoders, a sequence counter, and a
number of logic gates.
An instruction fetched from the memory unit is placed in the instruction register
(IR).
The component of an instruction register includes; I bit, the operation code, and
bits 0 through 11.
Timing signal T4 initiates a memory write operation, places the content of PC onto the bus,
and enables the INR input of AR .
The memory write operation is completed and AR is incremented by the time the next
clock transition occurs.
The bus is used at T5 to transfer the content of AR to PC.
ISZ: Increment and Skip if Zero
• This instruction increments the word specified by the effective address, and
if the incremented value is equal to 0, PC is incremented by 1.
• As this negative number is repeatedly incremented by one, it eventually
reaches the value of zero. At that time PC is incremented by one in order to
skip the next instruction in the program.
• Since it is not possible to increment a word inside the memory, it is
necessary to read the word into DR, increment DR, and store the word back
into memory. This is done with the following sequence of microoperations:
D6T4: DR M[AR]
D6T5: DR DR+1
D6T: M[AR] DR, if(DR=0)then(PC PC+1), SC 0
Input-Output and Interrupt
• Instructions and data stored in memory must come from some input device.
Computed results must be transmitted to the user through some output device.
Input-Output Configuration
• The terminal sends and receives serial information has eight bits of an
alphanumeric code.
• The serial information from the keyboard is shifted into the input register INPR .
• The serial information for the printer is stored in the output register OUTR .
• These two registers communicate with a communication interface serially and
with the AC in parallel.
• The transmitter interface receives serial information from the keyboard and
transmits it to INPR.
• The receiver interface receives information from OUTR and sends it to the printer
serially.
• The input register INPR consists of eight bits and holds an alphanumeric input
information.
• The 1-bit input flag FGI is a control flip-flop.
• The flag bit is set to 1 when new information is available in the input device and is
cleared to 0 when the information is accepted by the computer.
• The flag is needed to synchronize the timing rate difference between the input
device and the computer.
The process of information transfer is as follows.
• Initially, the input flag FGI is cleared to 0 .
• When a key is pressed in the keyboard, an 8-bit alpha-numeric code is shifted into
INPR and the input flag FGI is set to 1.
• If the flag is set, the information in INPR cannot be changed
• computer checks the flag bit;
• if it is 1, the information from INPR is transferred in parallel into AC and FGI is
cleared to 0.
• Once the flag is cleared, new information can be shifted into INPR by striking
another key.
• The output register OUTR works similarly but the direction of information flow
is reversed.
• Initially, the output flag FGO is set to 1.
• The computer checks the flag bit;
• if it is 1, the information from AC is transferred in parallel to OUTR and FGO is
cleared to 0
• The output device accepts the coded information, prints the corresponding
character, and when the operation is completed, it sets FGO to 1
• The computer does not load a new character into OUTR when FGO is 0 which
indicates that the output device is in the process of printing the character.
Input-Output Instructions
• Input and output instructions are needed for transferring information to and
from AC register, for checking the flag bits, and for controlling the interrupt
facility.
• Input-output instructions have an operation code 1111 and are recognized by
the control when D7 = 1 and I = 1.
• The remaining bits of the instruction specify the particular operation.
• These instructions are executed with the clock transition associated with timing
signal T3.
• Each control function needs a Boolean relation D7IT3 (p)
• The control function is distinguished by one of the bits in IR(6-11).
Input Output Instructions
The INP instruction transfers the input information from lNPR into the eight low-order
bits of AC and also clears the input flag to 0.
The OUT instruction transfers the eight least significant bits of AC into the output
register OUTR and clears the output flag to 0.
The next two instructions check the status of the flags and cause a skip of the next
instruction if the flag is I. The instruction that is skipped will normally be a branch
instruction to return and check the flag again.
The last two instructions set and clear an interrupt enable flip flop lEN
Program Interrupt
• The computer is wasting time while checking the flag (FGI/FGO) instead of doing
some other useful processing task.
• An alternative way is the programmed controlled procedure; here the external device
inform the computer when it is ready for the transfer. Meantime the computer can be
busy with other tasks. This type of transfer uses the interrupt facility.
When a interrupt_flag is set, the computer is interrupted the current program
Computer deviates from current process and take care of the input or output transfer.
It then returns to the current program after I/O transfer
• When lEN =0 (with the IOF instruction), the flags cannot interrupt the computer.
• When lEN = 1 (with the ION instruction), the computer can be interrupted.
These two instructions provide the programmer with the capability of making a
decision, whether to use the interrupt facility or not.
Interrupt Cycle
An interrupt flip-flop R is included in the computer.
When R = 0, the computer goes through an instruction cycle.
During the execute phase of the instruction cycle lEN is checked by the control.
If IEN is 0, it indicates that the programmer does not want to use the interrupt,
so control continues with the next instruction cycle.
If lEN is 1, control checks the flag bits. If both flags are 0, it indicates that neither
the input nor the output registers are ready for transfer of information. In this
case, control continues with the next instruction cycle.
If either flag is set to 1 while lEN = 1, flip-flop R is set to 1.
At the end of the execute phase, control checks the value of R, and if it is equal
to 1 , it goes to an interrupt cycle instead of an instruction cycle.
• The interrupt cycle is a hardware implementation of a branch and save return
address operation. The return address available in PC is stored in a specific
location where it can be found later when the program returns to the
instruction at which it was interrupted.
• The memory location at address 0 is used for storing the return address.
• Control then inserts address 1 into PC and clears IEN and R so that no more interruptions
can occur until the interrupt request from the flag has been serviced.
• Suppose that an interrupt occurs and R is set to 1 while the control is executing the
instruction at address 255.
• At this time, the return address 256 is in PC.
• The input-output service program in memory starting from address 1120 and a BUN 1120
instruction at address 1.
3. Stack organization.
Single accumulator organization.
All operations are done between the AC register and a memory operand. T is the
address of a temporary memory location required for storing the intermediate
result.
Zero Address Instruction Instruction
A stack-organized computer does not use an address field for the instructions
The PUSH and POP instructions (specify an address field of the operand)
communicates with the stack.
X = (A + B)*(C + D) will be written for a
stack organized computer. (TOS stands for
top of stack.)
Basically, the operands are specified implicitly Here, the operands are contained in an operand
2.
in the definition of instruction . field rather than address field .
This type of mode can be used in all register This type of mode is quite useful for initializing
3.
reference instructions . the registers to a constant value .